constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
-constexpr char kPowerHalProfileProp[] = "vendor.powerhal.perf_profile";
Power::Power(std::shared_ptr<HintManager> hm)
: mHintManager(hm),
mInteractionHandler(nullptr),
mVRModeOn(false),
- mSustainedPerfModeOn(false),
- mCurrentPerfProfile(PowerProfile::BALANCED) {
+ mSustainedPerfModeOn(false) {
mInteractionHandler = std::make_unique<InteractionHandler>(mHintManager);
mInteractionHandler->Init();
mHintManager->DoHint("EXPENSIVE_RENDERING");
}
- state = ::android::base::GetProperty(kPowerHalProfileProp, "");
- if (state == "POWER_SAVE") {
- ALOGI("Initialize with POWER_SAVE profile");
- setProfile(PowerProfile::POWER_SAVE);
- } else if (state == "BIAS_POWER_SAVE") {
- ALOGI("Initialize with BIAS_POWER_SAVE profile");
- setProfile(PowerProfile::BIAS_POWER_SAVE);
- } else if (state == "BIAS_PERFORMANCE") {
- ALOGI("Initialize with BIAS_PERFORMANCE profile");
- setProfile(PowerProfile::BIAS_PERFORMANCE);
- } else if (state == "HIGH_PERFORMANCE") {
- ALOGI("Initialize with HIGH_PERFORMANCE profile");
- setProfile(PowerProfile::HIGH_PERFORMANCE);
- }
-
// Now start to take powerhint
ALOGI("PowerHAL ready to process hints");
}
return ndk::ScopedAStatus::ok();
}
-ndk::ScopedAStatus Power::setProfile(PowerProfile profile) {
- if (mCurrentPerfProfile == profile) {
- return ndk::ScopedAStatus::ok();
- }
-
- // End previous perf profile hints
- switch (mCurrentPerfProfile) {
- case PowerProfile::POWER_SAVE:
- mHintManager->EndHint("PROFILE_POWER_SAVE");
- break;
- case PowerProfile::BIAS_POWER_SAVE:
- mHintManager->EndHint("PROFILE_BIAS_POWER_SAVE");
- break;
- case PowerProfile::BIAS_PERFORMANCE:
- mHintManager->EndHint("PROFILE_BIAS_PERFORMANCE");
- break;
- case PowerProfile::HIGH_PERFORMANCE:
- mHintManager->EndHint("PROFILE_HIGH_PERFORMANCE");
- break;
- default:
- break;
- }
-
- // Apply perf profile hints
- switch (profile) {
- case PowerProfile::POWER_SAVE:
- mHintManager->DoHint("PROFILE_POWER_SAVE");
- break;
- case PowerProfile::BIAS_POWER_SAVE:
- mHintManager->DoHint("PROFILE_BIAS_POWER_SAVE");
- break;
- case PowerProfile::BIAS_PERFORMANCE:
- mHintManager->DoHint("PROFILE_BIAS_PERFORMANCE");
- break;
- case PowerProfile::HIGH_PERFORMANCE:
- mHintManager->DoHint("PROFILE_HIGH_PERFORMANCE");
- break;
- default:
- break;
- }
-
- mCurrentPerfProfile = profile;
-
- return ndk::ScopedAStatus::ok();
-}
-
ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
LOG(DEBUG) << "Power setBoost: " << toString(type) << " duration: " << durationMs;
ATRACE_INT(toString(type).c_str(), durationMs);
using ::aidl::android::hardware::power::Mode;
using ::android::perfmgr::HintManager;
-enum PowerProfile {
- POWER_SAVE = 0,
- BALANCED,
- HIGH_PERFORMANCE,
- BIAS_POWER_SAVE,
- BIAS_PERFORMANCE,
- MAX
-};
-
class Power : public ::aidl::android::hardware::power::BnPower {
public:
Power(std::shared_ptr<HintManager> hm);
ndk::ScopedAStatus setMode(Mode type, bool enabled) override;
ndk::ScopedAStatus isModeSupported(Mode type, bool *_aidl_return) override;
- ndk::ScopedAStatus setProfile(PowerProfile profile);
ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override;
ndk::ScopedAStatus isBoostSupported(Boost type, bool *_aidl_return) override;
binder_status_t dump(int fd, const char **args, uint32_t numArgs) override;
std::unique_ptr<InteractionHandler> mInteractionHandler;
std::atomic<bool> mVRModeOn;
std::atomic<bool> mSustainedPerfModeOn;
- std::atomic<PowerProfile> mCurrentPerfProfile;
};
} // namespace pixel