sm6375-common: power-libperfmgr: add PowerHintSession for ADPF implementation
Adapted from PoC from ag/13100800 Added more ATRACE for further tuning and debug Test: APPPID=$(adb shell pidof com.prefabulated.touchlatency); watch -n 1 adb shell grep uclamp /proc/${APPPID}/sched Test: atest VtsHalPowerTargetTest Bug: 177492680 Change-Id: I6bfd61b21dc1cde04f6ba9ae8d3533cd263ad814 Signed-off-by: Wei Wang <wvw@google.com>
This commit is contained in:
parent
1f8a6a10d6
commit
89c05aa49a
6 changed files with 55 additions and 10 deletions
|
@ -20,7 +20,8 @@ cc_binary {
|
||||||
vintf_fragments: ["android.hardware.power-service.moto_sm6375.xml"],
|
vintf_fragments: ["android.hardware.power-service.moto_sm6375.xml"],
|
||||||
vendor: true,
|
vendor: true,
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"android.hardware.power-V1-ndk_platform",
|
"android.hardware.power-V2-ndk_platform",
|
||||||
|
"libadpf-pixel",
|
||||||
"libbase",
|
"libbase",
|
||||||
"libcutils",
|
"libcutils",
|
||||||
"liblog",
|
"liblog",
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
#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 <array>
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
#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"
|
#include "Power.h"
|
||||||
|
|
||||||
|
@ -26,10 +26,13 @@
|
||||||
#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 <cutils/properties.h>
|
||||||
|
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
#include <utils/Trace.h>
|
#include <utils/Trace.h>
|
||||||
|
|
||||||
|
#include "adpf/PowerHintSession.h"
|
||||||
|
|
||||||
#define TAP_TO_WAKE_NODE "/sys/class/sensors/dt-gesture/enable"
|
#define TAP_TO_WAKE_NODE "/sys/class/sensors/dt-gesture/enable"
|
||||||
|
|
||||||
namespace aidl {
|
namespace aidl {
|
||||||
|
@ -39,40 +42,45 @@ namespace power {
|
||||||
namespace impl {
|
namespace impl {
|
||||||
namespace pixel {
|
namespace pixel {
|
||||||
|
|
||||||
|
using ::aidl::google::hardware::power::impl::pixel::adpf::PowerHintSession;
|
||||||
|
|
||||||
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
|
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
|
||||||
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
|
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
|
||||||
constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
|
constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
|
||||||
|
constexpr char kPowerHalAdpfRateProp[] = "vendor.powerhal.adpf.rate";
|
||||||
|
constexpr int64_t kPowerHalAdpfRateDefault = -1;
|
||||||
|
|
||||||
Power::Power(std::shared_ptr<HintManager> hm)
|
Power::Power(std::shared_ptr<HintManager> hm)
|
||||||
: mHintManager(hm),
|
: mHintManager(hm),
|
||||||
mInteractionHandler(nullptr),
|
mInteractionHandler(nullptr),
|
||||||
mSustainedPerfModeOn(false) {
|
mSustainedPerfModeOn(false),
|
||||||
|
mAdpfRate(::android::base::GetIntProperty(kPowerHalAdpfRateProp, kPowerHalAdpfRateDefault)) {
|
||||||
mInteractionHandler = std::make_unique<InteractionHandler>(mHintManager);
|
mInteractionHandler = std::make_unique<InteractionHandler>(mHintManager);
|
||||||
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") {
|
||||||
ALOGI("Initialize with SUSTAINED_PERFORMANCE on");
|
LOG(INFO) << "Initialize with SUSTAINED_PERFORMANCE on";
|
||||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
||||||
mSustainedPerfModeOn = true;
|
mSustainedPerfModeOn = true;
|
||||||
} else {
|
} else {
|
||||||
ALOGI("Initialize PowerHAL");
|
LOG(INFO) << "Initialize PowerHAL";
|
||||||
}
|
}
|
||||||
|
|
||||||
state = ::android::base::GetProperty(kPowerHalAudioProp, "");
|
state = ::android::base::GetProperty(kPowerHalAudioProp, "");
|
||||||
if (state == "AUDIO_STREAMING_LOW_LATENCY") {
|
if (state == "AUDIO_STREAMING_LOW_LATENCY") {
|
||||||
ALOGI("Initialize with AUDIO_LOW_LATENCY on");
|
LOG(INFO) << "Initialize with AUDIO_LOW_LATENCY on";
|
||||||
mHintManager->DoHint(state);
|
mHintManager->DoHint(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
state = ::android::base::GetProperty(kPowerHalRenderingProp, "");
|
state = ::android::base::GetProperty(kPowerHalRenderingProp, "");
|
||||||
if (state == "EXPENSIVE_RENDERING") {
|
if (state == "EXPENSIVE_RENDERING") {
|
||||||
ALOGI("Initialize with EXPENSIVE_RENDERING on");
|
LOG(INFO) << "Initialize with EXPENSIVE_RENDERING on";
|
||||||
mHintManager->DoHint("EXPENSIVE_RENDERING");
|
mHintManager->DoHint("EXPENSIVE_RENDERING");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now start to take powerhint
|
// 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) {
|
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;
|
return STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ndk::ScopedAStatus Power::createHintSession(int32_t tgid, int32_t uid,
|
||||||
|
const std::vector<int32_t> &threadIds,
|
||||||
|
int64_t durationNanos,
|
||||||
|
std::shared_ptr<IPowerHintSession> *_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<IPowerHintSession> session =
|
||||||
|
ndk::SharedRefBase::make<PowerHintSession>(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 pixel
|
||||||
} // namespace impl
|
} // namespace impl
|
||||||
} // namespace power
|
} // namespace power
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace impl {
|
||||||
namespace pixel {
|
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::Mode;
|
using ::aidl::android::hardware::power::Mode;
|
||||||
using ::android::perfmgr::HintManager;
|
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 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;
|
||||||
ndk::ScopedAStatus isBoostSupported(Boost type, bool *_aidl_return) override;
|
ndk::ScopedAStatus isBoostSupported(Boost type, bool *_aidl_return) override;
|
||||||
|
ndk::ScopedAStatus createHintSession(int32_t tgid, int32_t uid,
|
||||||
|
const std::vector<int32_t> &threadIds,
|
||||||
|
int64_t durationNanos,
|
||||||
|
std::shared_ptr<IPowerHintSession> *_aidl_return) override;
|
||||||
|
ndk::ScopedAStatus getHintSessionPreferredRate(int64_t *outNanoseconds) override;
|
||||||
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::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 mAdpfRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pixel
|
} // namespace pixel
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<manifest version="1.0" type="device">
|
<manifest version="1.0" type="device">
|
||||||
<hal format="aidl">
|
<hal format="aidl">
|
||||||
<name>android.hardware.power</name>
|
<name>android.hardware.power</name>
|
||||||
|
<version>2</version>
|
||||||
<fqname>IPower/default</fqname>
|
<fqname>IPower/default</fqname>
|
||||||
</hal>
|
</hal>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_TAG "android.hardware.power-service.moto_sm6375-libperfmgr"
|
#define LOG_TAG "powerhal-libperfmgr"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue