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
This commit is contained in:
Jimmy Shiu 2023-02-25 08:44:31 +08:00 committed by Bruno Martins
parent e69da0c258
commit cec3b97eda
2 changed files with 13 additions and 0 deletions

View File

@ -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<std::mutex> guard(mSessionLock);

View File

@ -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<StaleTimerHandler> 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<std::string, std::optional<bool>> mSupportedHints;
};
} // namespace pixel