From cec3b97edae811711457c0706c9ca4feefec75e5 Mon Sep 17 00:00:00 2001 From: Jimmy Shiu Date: Sat, 25 Feb 2023 08:44:31 +0800 Subject: [PATCH] power-libperfmgr: ADPF: support sending power hint Send a hint only when the system can support the hint. Bug: 243025173 Test: PtsUiBench & CUJ Change-Id: If56d0c22f8dd61f5fe27ba79f08f2963269abe41 Merged-In: If56d0c22f8dd61f5fe27ba79f08f2963269abe41 --- aidl/power-libperfmgr/PowerHintSession.cpp | 9 +++++++++ aidl/power-libperfmgr/PowerHintSession.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/aidl/power-libperfmgr/PowerHintSession.cpp b/aidl/power-libperfmgr/PowerHintSession.cpp index 1eb0172..b8390df 100644 --- a/aidl/power-libperfmgr/PowerHintSession.cpp +++ b/aidl/power-libperfmgr/PowerHintSession.cpp @@ -189,6 +189,15 @@ void PowerHintSession::updateUniveralBoostMode() { } } +void PowerHintSession::tryToSendPowerHint(std::string hint) { + if (!mSupportedHints[hint].has_value()) { + mSupportedHints[hint] = HintManager::GetInstance()->IsHintSupported(hint); + } + if (mSupportedHints[hint].value()) { + HintManager::GetInstance()->DoHint(hint); + } +} + int PowerHintSession::setSessionUclampMin(int32_t min) { { std::lock_guard guard(mSessionLock); diff --git a/aidl/power-libperfmgr/PowerHintSession.h b/aidl/power-libperfmgr/PowerHintSession.h index 33c6ed7..9b32f9f 100644 --- a/aidl/power-libperfmgr/PowerHintSession.h +++ b/aidl/power-libperfmgr/PowerHintSession.h @@ -130,6 +130,7 @@ class PowerHintSession : public BnPowerHintSession { private: void updateUniveralBoostMode(); int setSessionUclampMin(int32_t min); + void tryToSendPowerHint(std::string hint); std::string getIdString() const; AppHintDesc *mDescriptor = nullptr; sp mStaleTimerHandler; @@ -142,6 +143,9 @@ class PowerHintSession : public BnPowerHintSession { int64_t mLastStartedTimeNs; int64_t mLastDurationNs; int64_t mWorkPeriodNs; + + // To cache the status of whether ADPF hints are supported. + std::unordered_map> mSupportedHints; }; } // namespace pixel