diff --git a/power-libperfmgr/Android.bp b/power-libperfmgr/Android.bp index 6c0033c..6cb0fa4 100644 --- a/power-libperfmgr/Android.bp +++ b/power-libperfmgr/Android.bp @@ -20,7 +20,8 @@ cc_binary { vintf_fragments: ["android.hardware.power-service.moto_sm6375.xml"], vendor: true, shared_libs: [ - "android.hardware.power-V1-ndk_platform", + "android.hardware.power-V2-ndk_platform", + "libadpf-pixel", "libbase", "libcutils", "liblog", diff --git a/power-libperfmgr/InteractionHandler.cpp b/power-libperfmgr/InteractionHandler.cpp index fdf6bef..dd135b0 100644 --- a/power-libperfmgr/InteractionHandler.cpp +++ b/power-libperfmgr/InteractionHandler.cpp @@ -15,7 +15,7 @@ */ #define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL) -#define LOG_TAG "android.hardware.power-service.moto_sm6375-libperfmgr" +#define LOG_TAG "powerhal-libperfmgr" #include #include diff --git a/power-libperfmgr/Power.cpp b/power-libperfmgr/Power.cpp index a18e415..23ab4eb 100644 --- a/power-libperfmgr/Power.cpp +++ b/power-libperfmgr/Power.cpp @@ -15,7 +15,7 @@ */ #define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL) -#define LOG_TAG "android.hardware.power-service.moto_sm6375-libperfmgr" +#define LOG_TAG "powerhal-libperfmgr" #include "Power.h" @@ -26,10 +26,13 @@ #include #include #include +#include #include #include +#include "adpf/PowerHintSession.h" + #define TAP_TO_WAKE_NODE "/sys/class/sensors/dt-gesture/enable" namespace aidl { @@ -39,40 +42,45 @@ namespace power { namespace impl { namespace pixel { +using ::aidl::google::hardware::power::impl::pixel::adpf::PowerHintSession; + constexpr char kPowerHalStateProp[] = "vendor.powerhal.state"; constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio"; constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering"; +constexpr char kPowerHalAdpfRateProp[] = "vendor.powerhal.adpf.rate"; +constexpr int64_t kPowerHalAdpfRateDefault = -1; Power::Power(std::shared_ptr hm) : mHintManager(hm), mInteractionHandler(nullptr), - mSustainedPerfModeOn(false) { + mSustainedPerfModeOn(false), + mAdpfRate(::android::base::GetIntProperty(kPowerHalAdpfRateProp, kPowerHalAdpfRateDefault)) { mInteractionHandler = std::make_unique(mHintManager); mInteractionHandler->Init(); std::string state = ::android::base::GetProperty(kPowerHalStateProp, ""); if (state == "SUSTAINED_PERFORMANCE") { - ALOGI("Initialize with SUSTAINED_PERFORMANCE on"); + LOG(INFO) << "Initialize with SUSTAINED_PERFORMANCE on"; mHintManager->DoHint("SUSTAINED_PERFORMANCE"); mSustainedPerfModeOn = true; } else { - ALOGI("Initialize PowerHAL"); + LOG(INFO) << "Initialize PowerHAL"; } state = ::android::base::GetProperty(kPowerHalAudioProp, ""); if (state == "AUDIO_STREAMING_LOW_LATENCY") { - ALOGI("Initialize with AUDIO_LOW_LATENCY on"); + LOG(INFO) << "Initialize with AUDIO_LOW_LATENCY on"; mHintManager->DoHint(state); } state = ::android::base::GetProperty(kPowerHalRenderingProp, ""); if (state == "EXPENSIVE_RENDERING") { - ALOGI("Initialize with EXPENSIVE_RENDERING on"); + LOG(INFO) << "Initialize with EXPENSIVE_RENDERING on"; mHintManager->DoHint("EXPENSIVE_RENDERING"); } // Now start to take powerhint - ALOGI("PowerHAL ready to process hints"); + LOG(INFO) << "PowerHAL ready to take hints, Adpf update rate: " << mAdpfRate; } ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) { @@ -194,6 +202,34 @@ binder_status_t Power::dump(int fd, const char **, uint32_t) { return STATUS_OK; } +ndk::ScopedAStatus Power::createHintSession(int32_t tgid, int32_t uid, + const std::vector &threadIds, + int64_t durationNanos, + std::shared_ptr *_aidl_return) { + if (mAdpfRate == -1) { + *_aidl_return = nullptr; + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + } + if (threadIds.size() == 0) { + LOG(ERROR) << "Error: threadIds.size() shouldn't be " << threadIds.size(); + *_aidl_return = nullptr; + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } + std::shared_ptr session = + ndk::SharedRefBase::make(tgid, uid, threadIds, durationNanos); + *_aidl_return = session; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus Power::getHintSessionPreferredRate(int64_t *outNanoseconds) { + *outNanoseconds = mAdpfRate; + if (mAdpfRate == -1) { + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + } + + return ndk::ScopedAStatus::ok(); +} + } // namespace pixel } // namespace impl } // namespace power diff --git a/power-libperfmgr/Power.h b/power-libperfmgr/Power.h index 712d0f0..6f4a938 100644 --- a/power-libperfmgr/Power.h +++ b/power-libperfmgr/Power.h @@ -33,6 +33,7 @@ namespace impl { namespace pixel { using ::aidl::android::hardware::power::Boost; +using ::aidl::android::hardware::power::IPowerHintSession; using ::aidl::android::hardware::power::Mode; using ::android::perfmgr::HintManager; @@ -43,12 +44,18 @@ class Power : public ::aidl::android::hardware::power::BnPower { ndk::ScopedAStatus isModeSupported(Mode type, bool *_aidl_return) override; ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override; ndk::ScopedAStatus isBoostSupported(Boost type, bool *_aidl_return) override; + ndk::ScopedAStatus createHintSession(int32_t tgid, int32_t uid, + const std::vector &threadIds, + int64_t durationNanos, + std::shared_ptr *_aidl_return) override; + ndk::ScopedAStatus getHintSessionPreferredRate(int64_t *outNanoseconds) override; binder_status_t dump(int fd, const char **args, uint32_t numArgs) override; private: std::shared_ptr mHintManager; std::unique_ptr mInteractionHandler; std::atomic mSustainedPerfModeOn; + const int64_t mAdpfRate; }; } // namespace pixel diff --git a/power-libperfmgr/android.hardware.power-service.moto_sm6375.xml b/power-libperfmgr/android.hardware.power-service.moto_sm6375.xml index caf6ea2..9f56deb 100644 --- a/power-libperfmgr/android.hardware.power-service.moto_sm6375.xml +++ b/power-libperfmgr/android.hardware.power-service.moto_sm6375.xml @@ -1,6 +1,7 @@ android.hardware.power + 2 IPower/default diff --git a/power-libperfmgr/service.cpp b/power-libperfmgr/service.cpp index 1fe5334..a52c956 100644 --- a/power-libperfmgr/service.cpp +++ b/power-libperfmgr/service.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#define LOG_TAG "android.hardware.power-service.moto_sm6375-libperfmgr" +#define LOG_TAG "powerhal-libperfmgr" #include