From 3b4d3929921be3fb6cf3506d8ce7dace24fc599c Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 1 Jul 2020 08:23:57 +0200 Subject: [PATCH] power-libperfmgr: Correctly implement DT2W support Change-Id: I9ed6e8886322c787ae69f2f79eb7c9b664ce08d7 --- hidl/power-libperfmgr/Power.cpp | 23 +++++++++++++++++-- hidl/power-libperfmgr/Power.h | 2 ++ hidl/power-libperfmgr/powerhint.json.template | 9 ++++---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/hidl/power-libperfmgr/Power.cpp b/hidl/power-libperfmgr/Power.cpp index a7d8842c..08c0a748 100644 --- a/hidl/power-libperfmgr/Power.cpp +++ b/hidl/power-libperfmgr/Power.cpp @@ -41,6 +41,7 @@ using ::android::hardware::Return; using ::android::hardware::Void; using ::android::hardware::power::V1_0::Feature; using ::android::hardware::power::V1_0::Status; +using namespace std::chrono_literals; constexpr char kPowerHalStateProp[] = "vendor.powerhal.state"; constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio"; @@ -119,6 +120,8 @@ Power::Power() setProfile(PowerProfile::HIGH_PERFORMANCE); mCurrentPerfProfile = PowerProfile::HIGH_PERFORMANCE; } + mDoubleTapEnabled = false; + // Now start to take powerhint mReady.store(true); ALOGI("PowerHAL ready to process hints"); @@ -185,7 +188,23 @@ Return Power::setProfile(PowerProfile profile) { // Methods from ::android::hardware::power::V1_0::IPower follow. Return Power::setInteractive(bool interactive) { - return updateHint("NOT_INTERACTIVE", !interactive); + // Enable dt2w before turning TSP off + if (mDoubleTapEnabled && !interactive) { + updateHint("DOUBLE_TAP_TO_WAKE", true); + // It takes some time till the cmd is executed in the Kernel, there + // is an interface to check that. To avoid that just wait for 25ms + // till we turn off the touchscreen and lcd. + std::this_thread::sleep_for(25ms); + } + + updateHint("NOT_INTERACTIVE", !interactive); + + // Disable dt2w after turning TSP back on + if (mDoubleTapEnabled && interactive) { + updateHint("DOUBLE_TAP_TO_WAKE", false); + } + + return Void(); } Return Power::powerHint(PowerHint_1_0 hint, int32_t data) { @@ -262,7 +281,7 @@ Return Power::powerHint(PowerHint_1_0 hint, int32_t data) { Return Power::setFeature(Feature feature, bool activate) { switch (feature) { case Feature::POWER_FEATURE_DOUBLE_TAP_TO_WAKE: - updateHint("DOUBLE_TAP_TO_WAKE", activate); + mDoubleTapEnabled = activate; break; default: break; diff --git a/hidl/power-libperfmgr/Power.h b/hidl/power-libperfmgr/Power.h index 81687b2c..8ff4aea4 100644 --- a/hidl/power-libperfmgr/Power.h +++ b/hidl/power-libperfmgr/Power.h @@ -95,6 +95,8 @@ class Power : public IPower, public ILineagePower { std::atomic mReady; std::thread mInitThread; + std::atomic mDoubleTapEnabled; + int32_t mNumPerfProfiles; std::atomic mCurrentPerfProfile; diff --git a/hidl/power-libperfmgr/powerhint.json.template b/hidl/power-libperfmgr/powerhint.json.template index 87871319..359dad82 100644 --- a/hidl/power-libperfmgr/powerhint.json.template +++ b/hidl/power-libperfmgr/powerhint.json.template @@ -118,13 +118,12 @@ }, { "Name": "DoubleTapToWakeEnable", - "Path": "/sys/class/sec/tsp/dt2w_enable", + "Path": "/sys/class/sec/tsp/cmd", "Values": [ - "0", - "1" + "aot_enable,0", + "aot_enable,1" ], "DefaultIndex": 0, - "ResetOnInit": true }, { "Name": "PowerHALMainState", @@ -419,7 +418,7 @@ "PowerHint": "DOUBLE_TAP_TO_WAKE", "Node": "DoubleTapToWakeEnable", "Duration": 0, - "Value": "1" + "Value": "aot_enable,1" }, { "PowerHint": "PROFILE_POWER_SAVE",