sm6375-common: power-libperfmgr: Make HintManager a singleton class
HintManager is unique and widely used in many different components. This is for making it easiler to be reloaded for debugging. Bug: 172285365 Test: adb push \ out/target/product/raven/data/nativetest64/libperfmgr_test/libperfmgr_test \ /data/nativetest64/libperfmgr_test/libperfmgr_test && \ adb shell /data/nativetest64/libperfmgr_test/libperfmgr_test Change-Id: I3affdfe780073ebbc50fac7bfbdd1530ee9dc8c2
This commit is contained in:
parent
40a340e68d
commit
53f1fc4eee
9 changed files with 68 additions and 96 deletions
|
@ -17,20 +17,20 @@
|
||||||
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
||||||
#define LOG_TAG "powerhal-libperfmgr"
|
#define LOG_TAG "powerhal-libperfmgr"
|
||||||
|
|
||||||
#include <array>
|
#include "InteractionHandler.h"
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
#include <android-base/properties.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <perfmgr/HintManager.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <sys/eventfd.h>
|
#include <sys/eventfd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <android-base/properties.h>
|
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
#include <utils/Trace.h>
|
#include <utils/Trace.h>
|
||||||
|
|
||||||
#include "InteractionHandler.h"
|
#include <array>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#define MAX_LENGTH 64
|
#define MAX_LENGTH 64
|
||||||
|
|
||||||
|
@ -79,10 +79,10 @@ static int FbIdleOpen(void) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
InteractionHandler::InteractionHandler(std::shared_ptr<HintManager> const &hint_manager)
|
using ::android::perfmgr::HintManager;
|
||||||
: mState(INTERACTION_STATE_UNINITIALIZED),
|
|
||||||
mDurationMs(0),
|
InteractionHandler::InteractionHandler()
|
||||||
mHintManager(hint_manager) {}
|
: mState(INTERACTION_STATE_UNINITIALIZED), mDurationMs(0) {}
|
||||||
|
|
||||||
InteractionHandler::~InteractionHandler() {
|
InteractionHandler::~InteractionHandler() {
|
||||||
Exit();
|
Exit();
|
||||||
|
@ -130,14 +130,14 @@ void InteractionHandler::Exit() {
|
||||||
|
|
||||||
void InteractionHandler::PerfLock() {
|
void InteractionHandler::PerfLock() {
|
||||||
ALOGV("%s: acquiring perf lock", __func__);
|
ALOGV("%s: acquiring perf lock", __func__);
|
||||||
if (!mHintManager->DoHint("INTERACTION")) {
|
if (!HintManager::GetInstance()->DoHint("INTERACTION")) {
|
||||||
ALOGE("%s: do hint INTERACTION failed", __func__);
|
ALOGE("%s: do hint INTERACTION failed", __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InteractionHandler::PerfRel() {
|
void InteractionHandler::PerfRel() {
|
||||||
ALOGV("%s: releasing perf lock", __func__);
|
ALOGV("%s: releasing perf lock", __func__);
|
||||||
if (!mHintManager->EndHint("INTERACTION")) {
|
if (!HintManager::GetInstance()->EndHint("INTERACTION")) {
|
||||||
ALOGE("%s: end hint INTERACTION failed", __func__);
|
ALOGE("%s: end hint INTERACTION failed", __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ void InteractionHandler::Acquire(int32_t duration) {
|
||||||
// 1) override property is set OR
|
// 1) override property is set OR
|
||||||
// 2) InteractionHandler not initialized
|
// 2) InteractionHandler not initialized
|
||||||
if (!kDisplayIdleSupport || mState == INTERACTION_STATE_UNINITIALIZED) {
|
if (!kDisplayIdleSupport || mState == INTERACTION_STATE_UNINITIALIZED) {
|
||||||
mHintManager->DoHint("INTERACTION", std::chrono::milliseconds(finalDuration));
|
HintManager::GetInstance()->DoHint("INTERACTION", std::chrono::milliseconds(finalDuration));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include <perfmgr/HintManager.h>
|
|
||||||
|
|
||||||
namespace aidl {
|
namespace aidl {
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace hardware {
|
namespace hardware {
|
||||||
|
@ -31,8 +29,6 @@ namespace power {
|
||||||
namespace impl {
|
namespace impl {
|
||||||
namespace pixel {
|
namespace pixel {
|
||||||
|
|
||||||
using ::android::perfmgr::HintManager;
|
|
||||||
|
|
||||||
enum InteractionState {
|
enum InteractionState {
|
||||||
INTERACTION_STATE_UNINITIALIZED,
|
INTERACTION_STATE_UNINITIALIZED,
|
||||||
INTERACTION_STATE_IDLE,
|
INTERACTION_STATE_IDLE,
|
||||||
|
@ -42,7 +38,7 @@ enum InteractionState {
|
||||||
|
|
||||||
class InteractionHandler {
|
class InteractionHandler {
|
||||||
public:
|
public:
|
||||||
InteractionHandler(std::shared_ptr<HintManager> const &hint_manager);
|
InteractionHandler();
|
||||||
~InteractionHandler();
|
~InteractionHandler();
|
||||||
bool Init();
|
bool Init();
|
||||||
void Exit();
|
void Exit();
|
||||||
|
@ -65,7 +61,6 @@ class InteractionHandler {
|
||||||
std::unique_ptr<std::thread> mThread;
|
std::unique_ptr<std::thread> mThread;
|
||||||
std::mutex mLock;
|
std::mutex mLock;
|
||||||
std::condition_variable mCond;
|
std::condition_variable mCond;
|
||||||
std::shared_ptr<HintManager> mHintManager;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pixel
|
} // namespace pixel
|
||||||
|
|
|
@ -18,16 +18,16 @@
|
||||||
|
|
||||||
#include "Power.h"
|
#include "Power.h"
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <android-base/properties.h>
|
#include <android-base/properties.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
|
#include <perfmgr/HintManager.h>
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#include "PowerHintSession.h"
|
#include "PowerHintSession.h"
|
||||||
#include "PowerSessionManager.h"
|
#include "PowerSessionManager.h"
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ namespace impl {
|
||||||
namespace pixel {
|
namespace pixel {
|
||||||
|
|
||||||
using ::aidl::google::hardware::power::impl::pixel::PowerHintSession;
|
using ::aidl::google::hardware::power::impl::pixel::PowerHintSession;
|
||||||
|
using ::android::perfmgr::HintManager;
|
||||||
|
|
||||||
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
|
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
|
||||||
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
|
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
|
||||||
|
@ -48,19 +49,18 @@ constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
|
||||||
constexpr char kPowerHalAdpfRateProp[] = "vendor.powerhal.adpf.rate";
|
constexpr char kPowerHalAdpfRateProp[] = "vendor.powerhal.adpf.rate";
|
||||||
constexpr int64_t kPowerHalAdpfRateDefault = -1;
|
constexpr int64_t kPowerHalAdpfRateDefault = -1;
|
||||||
|
|
||||||
Power::Power(std::shared_ptr<HintManager> hm)
|
Power::Power()
|
||||||
: mHintManager(hm),
|
: mInteractionHandler(nullptr),
|
||||||
mInteractionHandler(nullptr),
|
|
||||||
mSustainedPerfModeOn(false),
|
mSustainedPerfModeOn(false),
|
||||||
mAdpfRateNs(
|
mAdpfRateNs(
|
||||||
::android::base::GetIntProperty(kPowerHalAdpfRateProp, kPowerHalAdpfRateDefault)) {
|
::android::base::GetIntProperty(kPowerHalAdpfRateProp, kPowerHalAdpfRateDefault)) {
|
||||||
mInteractionHandler = std::make_unique<InteractionHandler>(mHintManager);
|
mInteractionHandler = std::make_unique<InteractionHandler>();
|
||||||
mInteractionHandler->Init();
|
mInteractionHandler->Init();
|
||||||
|
|
||||||
std::string state = ::android::base::GetProperty(kPowerHalStateProp, "");
|
std::string state = ::android::base::GetProperty(kPowerHalStateProp, "");
|
||||||
if (state == "SUSTAINED_PERFORMANCE") {
|
if (state == "SUSTAINED_PERFORMANCE") {
|
||||||
LOG(INFO) << "Initialize with SUSTAINED_PERFORMANCE on";
|
LOG(INFO) << "Initialize with SUSTAINED_PERFORMANCE on";
|
||||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
HintManager::GetInstance()->DoHint("SUSTAINED_PERFORMANCE");
|
||||||
mSustainedPerfModeOn = true;
|
mSustainedPerfModeOn = true;
|
||||||
} else {
|
} else {
|
||||||
LOG(INFO) << "Initialize PowerHAL";
|
LOG(INFO) << "Initialize PowerHAL";
|
||||||
|
@ -69,13 +69,13 @@ Power::Power(std::shared_ptr<HintManager> hm)
|
||||||
state = ::android::base::GetProperty(kPowerHalAudioProp, "");
|
state = ::android::base::GetProperty(kPowerHalAudioProp, "");
|
||||||
if (state == "AUDIO_STREAMING_LOW_LATENCY") {
|
if (state == "AUDIO_STREAMING_LOW_LATENCY") {
|
||||||
LOG(INFO) << "Initialize with AUDIO_LOW_LATENCY on";
|
LOG(INFO) << "Initialize with AUDIO_LOW_LATENCY on";
|
||||||
mHintManager->DoHint(state);
|
HintManager::GetInstance()->DoHint(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
state = ::android::base::GetProperty(kPowerHalRenderingProp, "");
|
state = ::android::base::GetProperty(kPowerHalRenderingProp, "");
|
||||||
if (state == "EXPENSIVE_RENDERING") {
|
if (state == "EXPENSIVE_RENDERING") {
|
||||||
LOG(INFO) << "Initialize with EXPENSIVE_RENDERING on";
|
LOG(INFO) << "Initialize with EXPENSIVE_RENDERING on";
|
||||||
mHintManager->DoHint("EXPENSIVE_RENDERING");
|
HintManager::GetInstance()->DoHint("EXPENSIVE_RENDERING");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now start to take powerhint
|
// Now start to take powerhint
|
||||||
|
@ -93,7 +93,7 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
||||||
#endif
|
#endif
|
||||||
case Mode::SUSTAINED_PERFORMANCE:
|
case Mode::SUSTAINED_PERFORMANCE:
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
HintManager::GetInstance()->DoHint("SUSTAINED_PERFORMANCE");
|
||||||
}
|
}
|
||||||
mSustainedPerfModeOn = true;
|
mSustainedPerfModeOn = true;
|
||||||
break;
|
break;
|
||||||
|
@ -120,9 +120,9 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
default:
|
default:
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
mHintManager->DoHint(toString(type));
|
HintManager::GetInstance()->DoHint(toString(type));
|
||||||
} else {
|
} else {
|
||||||
mHintManager->EndHint(toString(type));
|
HintManager::GetInstance()->EndHint(toString(type));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ndk::ScopedAStatus Power::isModeSupported(Mode type, bool *_aidl_return) {
|
ndk::ScopedAStatus Power::isModeSupported(Mode type, bool *_aidl_return) {
|
||||||
bool supported = mHintManager->IsHintSupported(toString(type));
|
bool supported = HintManager::GetInstance()->IsHintSupported(toString(type));
|
||||||
#ifdef TAP_TO_WAKE_NODE
|
#ifdef TAP_TO_WAKE_NODE
|
||||||
if (type == Mode::DOUBLE_TAP_TO_WAKE) {
|
if (type == Mode::DOUBLE_TAP_TO_WAKE) {
|
||||||
supported = true;
|
supported = true;
|
||||||
|
@ -162,11 +162,12 @@ ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (durationMs > 0) {
|
if (durationMs > 0) {
|
||||||
mHintManager->DoHint(toString(type), std::chrono::milliseconds(durationMs));
|
HintManager::GetInstance()->DoHint(toString(type),
|
||||||
|
std::chrono::milliseconds(durationMs));
|
||||||
} else if (durationMs == 0) {
|
} else if (durationMs == 0) {
|
||||||
mHintManager->DoHint(toString(type));
|
HintManager::GetInstance()->DoHint(toString(type));
|
||||||
} else {
|
} else {
|
||||||
mHintManager->EndHint(toString(type));
|
HintManager::GetInstance()->EndHint(toString(type));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +176,7 @@ ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool *_aidl_return) {
|
ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool *_aidl_return) {
|
||||||
bool supported = mHintManager->IsHintSupported(toString(type));
|
bool supported = HintManager::GetInstance()->IsHintSupported(toString(type));
|
||||||
LOG(INFO) << "Power boost " << toString(type) << " isBoostSupported: " << supported;
|
LOG(INFO) << "Power boost " << toString(type) << " isBoostSupported: " << supported;
|
||||||
*_aidl_return = supported;
|
*_aidl_return = supported;
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
|
@ -189,10 +190,10 @@ binder_status_t Power::dump(int fd, const char **, uint32_t) {
|
||||||
std::string buf(::android::base::StringPrintf(
|
std::string buf(::android::base::StringPrintf(
|
||||||
"HintManager Running: %s\n"
|
"HintManager Running: %s\n"
|
||||||
"SustainedPerformanceMode: %s\n",
|
"SustainedPerformanceMode: %s\n",
|
||||||
boolToString(mHintManager->IsRunning()),
|
boolToString(HintManager::GetInstance()->IsRunning()),
|
||||||
boolToString(mSustainedPerfModeOn)));
|
boolToString(mSustainedPerfModeOn)));
|
||||||
// Dump nodes through libperfmgr
|
// Dump nodes through libperfmgr
|
||||||
mHintManager->DumpToFd(fd);
|
HintManager::GetInstance()->DumpToFd(fd);
|
||||||
if (!::android::base::WriteStringToFd(buf, fd)) {
|
if (!::android::base::WriteStringToFd(buf, fd)) {
|
||||||
PLOG(ERROR) << "Failed to dump state to fd";
|
PLOG(ERROR) << "Failed to dump state to fd";
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <aidl/android/hardware/power/BnPower.h>
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include <aidl/android/hardware/power/BnPower.h>
|
|
||||||
#include <perfmgr/HintManager.h>
|
|
||||||
|
|
||||||
#include "InteractionHandler.h"
|
#include "InteractionHandler.h"
|
||||||
|
|
||||||
namespace aidl {
|
namespace aidl {
|
||||||
|
@ -35,11 +34,10 @@ namespace pixel {
|
||||||
using ::aidl::android::hardware::power::Boost;
|
using ::aidl::android::hardware::power::Boost;
|
||||||
using ::aidl::android::hardware::power::IPowerHintSession;
|
using ::aidl::android::hardware::power::IPowerHintSession;
|
||||||
using ::aidl::android::hardware::power::Mode;
|
using ::aidl::android::hardware::power::Mode;
|
||||||
using ::android::perfmgr::HintManager;
|
|
||||||
|
|
||||||
class Power : public ::aidl::android::hardware::power::BnPower {
|
class Power : public ::aidl::android::hardware::power::BnPower {
|
||||||
public:
|
public:
|
||||||
Power(std::shared_ptr<HintManager> hm);
|
Power();
|
||||||
ndk::ScopedAStatus setMode(Mode type, bool enabled) override;
|
ndk::ScopedAStatus setMode(Mode type, bool enabled) override;
|
||||||
ndk::ScopedAStatus isModeSupported(Mode type, bool *_aidl_return) override;
|
ndk::ScopedAStatus isModeSupported(Mode type, bool *_aidl_return) override;
|
||||||
ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override;
|
ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override;
|
||||||
|
@ -52,7 +50,6 @@ class Power : public ::aidl::android::hardware::power::BnPower {
|
||||||
binder_status_t dump(int fd, const char **args, uint32_t numArgs) override;
|
binder_status_t dump(int fd, const char **args, uint32_t numArgs) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<HintManager> mHintManager;
|
|
||||||
std::unique_ptr<InteractionHandler> mInteractionHandler;
|
std::unique_ptr<InteractionHandler> mInteractionHandler;
|
||||||
std::atomic<bool> mSustainedPerfModeOn;
|
std::atomic<bool> mSustainedPerfModeOn;
|
||||||
const int64_t mAdpfRateNs;
|
const int64_t mAdpfRateNs;
|
||||||
|
|
|
@ -17,18 +17,19 @@
|
||||||
#define LOG_TAG "android.hardware.power-service.realme_sm6375.ext-libperfmgr"
|
#define LOG_TAG "android.hardware.power-service.realme_sm6375.ext-libperfmgr"
|
||||||
|
|
||||||
#include "PowerExt.h"
|
#include "PowerExt.h"
|
||||||
#include "PowerSessionManager.h"
|
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <android-base/properties.h>
|
#include <android-base/properties.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
|
#include <perfmgr/HintManager.h>
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
#include "PowerSessionManager.h"
|
||||||
|
|
||||||
namespace aidl {
|
namespace aidl {
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace hardware {
|
namespace hardware {
|
||||||
|
@ -36,13 +37,15 @@ namespace power {
|
||||||
namespace impl {
|
namespace impl {
|
||||||
namespace pixel {
|
namespace pixel {
|
||||||
|
|
||||||
|
using ::android::perfmgr::HintManager;
|
||||||
|
|
||||||
ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
|
ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
|
||||||
LOG(DEBUG) << "PowerExt setMode: " << mode << " to: " << enabled;
|
LOG(DEBUG) << "PowerExt setMode: " << mode << " to: " << enabled;
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
mHintManager->DoHint(mode);
|
HintManager::GetInstance()->DoHint(mode);
|
||||||
} else {
|
} else {
|
||||||
mHintManager->EndHint(mode);
|
HintManager::GetInstance()->EndHint(mode);
|
||||||
}
|
}
|
||||||
PowerSessionManager::getInstance()->updateHintMode(mode, enabled);
|
PowerSessionManager::getInstance()->updateHintMode(mode, enabled);
|
||||||
|
|
||||||
|
@ -50,7 +53,7 @@ ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ndk::ScopedAStatus PowerExt::isModeSupported(const std::string &mode, bool *_aidl_return) {
|
ndk::ScopedAStatus PowerExt::isModeSupported(const std::string &mode, bool *_aidl_return) {
|
||||||
bool supported = mHintManager->IsHintSupported(mode);
|
bool supported = HintManager::GetInstance()->IsHintSupported(mode);
|
||||||
LOG(INFO) << "PowerExt mode " << mode << " isModeSupported: " << supported;
|
LOG(INFO) << "PowerExt mode " << mode << " isModeSupported: " << supported;
|
||||||
*_aidl_return = supported;
|
*_aidl_return = supported;
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
|
@ -60,18 +63,18 @@ ndk::ScopedAStatus PowerExt::setBoost(const std::string &boost, int32_t duration
|
||||||
LOG(DEBUG) << "PowerExt setBoost: " << boost << " duration: " << durationMs;
|
LOG(DEBUG) << "PowerExt setBoost: " << boost << " duration: " << durationMs;
|
||||||
|
|
||||||
if (durationMs > 0) {
|
if (durationMs > 0) {
|
||||||
mHintManager->DoHint(boost, std::chrono::milliseconds(durationMs));
|
HintManager::GetInstance()->DoHint(boost, std::chrono::milliseconds(durationMs));
|
||||||
} else if (durationMs == 0) {
|
} else if (durationMs == 0) {
|
||||||
mHintManager->DoHint(boost);
|
HintManager::GetInstance()->DoHint(boost);
|
||||||
} else {
|
} else {
|
||||||
mHintManager->EndHint(boost);
|
HintManager::GetInstance()->EndHint(boost);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
ndk::ScopedAStatus PowerExt::isBoostSupported(const std::string &boost, bool *_aidl_return) {
|
ndk::ScopedAStatus PowerExt::isBoostSupported(const std::string &boost, bool *_aidl_return) {
|
||||||
bool supported = mHintManager->IsHintSupported(boost);
|
bool supported = HintManager::GetInstance()->IsHintSupported(boost);
|
||||||
LOG(INFO) << "PowerExt boost " << boost << " isBoostSupported: " << supported;
|
LOG(INFO) << "PowerExt boost " << boost << " isBoostSupported: " << supported;
|
||||||
*_aidl_return = supported;
|
*_aidl_return = supported;
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
|
|
|
@ -30,18 +30,15 @@ namespace power {
|
||||||
namespace impl {
|
namespace impl {
|
||||||
namespace pixel {
|
namespace pixel {
|
||||||
|
|
||||||
using ::android::perfmgr::HintManager;
|
|
||||||
|
|
||||||
class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt {
|
class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt {
|
||||||
public:
|
public:
|
||||||
PowerExt(std::shared_ptr<HintManager> hm) : mHintManager(hm) {}
|
PowerExt() {}
|
||||||
ndk::ScopedAStatus setMode(const std::string &mode, bool enabled) override;
|
ndk::ScopedAStatus setMode(const std::string &mode, bool enabled) override;
|
||||||
ndk::ScopedAStatus isModeSupported(const std::string &mode, bool *_aidl_return) override;
|
ndk::ScopedAStatus isModeSupported(const std::string &mode, bool *_aidl_return) override;
|
||||||
ndk::ScopedAStatus setBoost(const std::string &boost, int32_t durationMs) override;
|
ndk::ScopedAStatus setBoost(const std::string &boost, int32_t durationMs) override;
|
||||||
ndk::ScopedAStatus isBoostSupported(const std::string &boost, bool *_aidl_return) override;
|
ndk::ScopedAStatus isBoostSupported(const std::string &boost, bool *_aidl_return) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<HintManager> mHintManager;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pixel
|
} // namespace pixel
|
||||||
|
|
|
@ -17,12 +17,13 @@
|
||||||
#define LOG_TAG "powerhal-libperfmgr"
|
#define LOG_TAG "powerhal-libperfmgr"
|
||||||
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
||||||
|
|
||||||
|
#include "PowerSessionManager.h"
|
||||||
|
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
|
#include <perfmgr/HintManager.h>
|
||||||
#include <processgroup/processgroup.h>
|
#include <processgroup/processgroup.h>
|
||||||
#include <utils/Trace.h>
|
#include <utils/Trace.h>
|
||||||
|
|
||||||
#include "PowerSessionManager.h"
|
|
||||||
|
|
||||||
namespace aidl {
|
namespace aidl {
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace hardware {
|
namespace hardware {
|
||||||
|
@ -30,12 +31,7 @@ namespace power {
|
||||||
namespace impl {
|
namespace impl {
|
||||||
namespace pixel {
|
namespace pixel {
|
||||||
|
|
||||||
void PowerSessionManager::setHintManager(std::shared_ptr<HintManager> const &hint_manager) {
|
using ::android::perfmgr::HintManager;
|
||||||
// Only initialize hintmanager instance if hint is supported.
|
|
||||||
if (hint_manager->IsHintSupported(kDisableBoostHintName)) {
|
|
||||||
mHintManager = hint_manager;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PowerSessionManager::updateHintMode(const std::string &mode, bool enabled) {
|
void PowerSessionManager::updateHintMode(const std::string &mode, bool enabled) {
|
||||||
ALOGV("PowerSessionManager::updateHintMode: mode: %s, enabled: %d", mode.c_str(), enabled);
|
ALOGV("PowerSessionManager::updateHintMode: mode: %s, enabled: %d", mode.c_str(), enabled);
|
||||||
|
@ -124,16 +120,16 @@ void PowerSessionManager::handleMessage(const Message &) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerSessionManager::enableSystemTopAppBoost() {
|
void PowerSessionManager::enableSystemTopAppBoost() {
|
||||||
if (mHintManager) {
|
if (HintManager::GetInstance()->IsHintSupported(kDisableBoostHintName)) {
|
||||||
ALOGV("PowerSessionManager::enableSystemTopAppBoost!!");
|
ALOGV("PowerSessionManager::enableSystemTopAppBoost!!");
|
||||||
mHintManager->EndHint(kDisableBoostHintName);
|
HintManager::GetInstance()->EndHint(kDisableBoostHintName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerSessionManager::disableSystemTopAppBoost() {
|
void PowerSessionManager::disableSystemTopAppBoost() {
|
||||||
if (mHintManager) {
|
if (HintManager::GetInstance()->IsHintSupported(kDisableBoostHintName)) {
|
||||||
ALOGV("PowerSessionManager::disableSystemTopAppBoost!!");
|
ALOGV("PowerSessionManager::disableSystemTopAppBoost!!");
|
||||||
mHintManager->DoHint(kDisableBoostHintName);
|
HintManager::GetInstance()->DoHint(kDisableBoostHintName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ class PowerSessionManager : public MessageHandler {
|
||||||
void removePowerSession(PowerHintSession *session);
|
void removePowerSession(PowerHintSession *session);
|
||||||
|
|
||||||
void handleMessage(const Message &message) override;
|
void handleMessage(const Message &message) override;
|
||||||
void setHintManager(std::shared_ptr<HintManager> const &hint_manager);
|
|
||||||
|
|
||||||
// Singleton
|
// Singleton
|
||||||
static sp<PowerSessionManager> getInstance() {
|
static sp<PowerSessionManager> getInstance() {
|
||||||
|
@ -64,7 +63,6 @@ class PowerSessionManager : public MessageHandler {
|
||||||
void disableSystemTopAppBoost();
|
void disableSystemTopAppBoost();
|
||||||
void enableSystemTopAppBoost();
|
void enableSystemTopAppBoost();
|
||||||
const std::string kDisableBoostHintName;
|
const std::string kDisableBoostHintName;
|
||||||
std::shared_ptr<HintManager> mHintManager;
|
|
||||||
std::unordered_set<PowerHintSession *> mSessions; // protected by mLock
|
std::unordered_set<PowerHintSession *> mSessions; // protected by mLock
|
||||||
std::unordered_map<int, int> mTidRefCountMap; // protected by mLock
|
std::unordered_map<int, int> mTidRefCountMap; // protected by mLock
|
||||||
std::mutex mLock;
|
std::mutex mLock;
|
||||||
|
@ -74,7 +72,6 @@ class PowerSessionManager : public MessageHandler {
|
||||||
PowerSessionManager()
|
PowerSessionManager()
|
||||||
: kDisableBoostHintName(::android::base::GetProperty(kPowerHalAdpfDisableTopAppBoost,
|
: kDisableBoostHintName(::android::base::GetProperty(kPowerHalAdpfDisableTopAppBoost,
|
||||||
"ADPF_DISABLE_TA_BOOST")),
|
"ADPF_DISABLE_TA_BOOST")),
|
||||||
mHintManager(nullptr),
|
|
||||||
mDisplayRefreshRate(60),
|
mDisplayRefreshRate(60),
|
||||||
mActive(false) {}
|
mActive(false) {}
|
||||||
PowerSessionManager(PowerSessionManager const &) = delete;
|
PowerSessionManager(PowerSessionManager const &) = delete;
|
||||||
|
|
|
@ -16,12 +16,13 @@
|
||||||
|
|
||||||
#define LOG_TAG "powerhal-libperfmgr"
|
#define LOG_TAG "powerhal-libperfmgr"
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <android-base/properties.h>
|
#include <android-base/properties.h>
|
||||||
#include <android/binder_manager.h>
|
#include <android/binder_manager.h>
|
||||||
#include <android/binder_process.h>
|
#include <android/binder_process.h>
|
||||||
|
#include <perfmgr/HintManager.h>
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include "Power.h"
|
#include "Power.h"
|
||||||
#include "PowerExt.h"
|
#include "PowerExt.h"
|
||||||
|
@ -34,37 +35,23 @@ using aidl::google::hardware::power::impl::pixel::PowerSessionManager;
|
||||||
using ::android::perfmgr::HintManager;
|
using ::android::perfmgr::HintManager;
|
||||||
|
|
||||||
constexpr std::string_view kPowerHalInitProp("vendor.powerhal.init");
|
constexpr std::string_view kPowerHalInitProp("vendor.powerhal.init");
|
||||||
constexpr std::string_view kConfigDebugPathProperty("vendor.powerhal.config.debug");
|
|
||||||
constexpr std::string_view kConfigProperty("vendor.powerhal.config");
|
|
||||||
constexpr std::string_view kConfigDefaultFileName("powerhint.json");
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::string config_path = "/vendor/etc/";
|
|
||||||
if (android::base::GetBoolProperty(kConfigDebugPathProperty.data(), false)) {
|
|
||||||
config_path = "/data/vendor/etc/";
|
|
||||||
LOG(WARNING) << "Power HAL AIDL Service for moto_sm6375 is using debug config from: " << config_path;
|
|
||||||
}
|
|
||||||
config_path.append(
|
|
||||||
android::base::GetProperty(kConfigProperty.data(), kConfigDefaultFileName.data()));
|
|
||||||
|
|
||||||
LOG(INFO) << "Power HAL AIDL Service for moto_sm6375 with Extension is starting with config: "
|
|
||||||
<< config_path;
|
|
||||||
|
|
||||||
// Parse config but do not start the looper
|
// Parse config but do not start the looper
|
||||||
std::shared_ptr<HintManager> hm = HintManager::GetFromJSON(config_path, false);
|
std::shared_ptr<HintManager> hm = HintManager::GetInstance();
|
||||||
if (!hm) {
|
if (!hm) {
|
||||||
LOG(FATAL) << "Invalid config: " << config_path;
|
LOG(FATAL) << "HintManager Init failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
// single thread
|
// single thread
|
||||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||||
|
|
||||||
// core service
|
// core service
|
||||||
std::shared_ptr<Power> pw = ndk::SharedRefBase::make<Power>(hm);
|
std::shared_ptr<Power> pw = ndk::SharedRefBase::make<Power>();
|
||||||
ndk::SpAIBinder pwBinder = pw->asBinder();
|
ndk::SpAIBinder pwBinder = pw->asBinder();
|
||||||
|
|
||||||
// extension service
|
// extension service
|
||||||
std::shared_ptr<PowerExt> pwExt = ndk::SharedRefBase::make<PowerExt>(hm);
|
std::shared_ptr<PowerExt> pwExt = ndk::SharedRefBase::make<PowerExt>();
|
||||||
|
|
||||||
// attach the extension to the same binder we will be registering
|
// attach the extension to the same binder we will be registering
|
||||||
CHECK(STATUS_OK == AIBinder_setExtension(pwBinder.get(), pwExt->asBinder().get()));
|
CHECK(STATUS_OK == AIBinder_setExtension(pwBinder.get(), pwExt->asBinder().get()));
|
||||||
|
@ -76,12 +63,11 @@ int main() {
|
||||||
|
|
||||||
if (::android::base::GetIntProperty("vendor.powerhal.adpf.rate", -1) != -1) {
|
if (::android::base::GetIntProperty("vendor.powerhal.adpf.rate", -1) != -1) {
|
||||||
PowerHintMonitor::getInstance()->start();
|
PowerHintMonitor::getInstance()->start();
|
||||||
PowerSessionManager::getInstance()->setHintManager(hm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::thread initThread([&]() {
|
std::thread initThread([&]() {
|
||||||
::android::base::WaitForProperty(kPowerHalInitProp.data(), "1");
|
::android::base::WaitForProperty(kPowerHalInitProp.data(), "1");
|
||||||
hm->Start();
|
HintManager::GetInstance()->Start();
|
||||||
});
|
});
|
||||||
initThread.detach();
|
initThread.detach();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue