power-libperfmgr: Correctly implement DT2W support

Change-Id: I9ed6e8886322c787ae69f2f79eb7c9b664ce08d7
tirimbino
Andreas Schneider 4 years ago
parent 1d1b2d4b2e
commit 3b4d392992
  1. 23
      hidl/power-libperfmgr/Power.cpp
  2. 2
      hidl/power-libperfmgr/Power.h
  3. 9
      hidl/power-libperfmgr/powerhint.json.template

@ -41,6 +41,7 @@ using ::android::hardware::Return;
using ::android::hardware::Void; using ::android::hardware::Void;
using ::android::hardware::power::V1_0::Feature; using ::android::hardware::power::V1_0::Feature;
using ::android::hardware::power::V1_0::Status; using ::android::hardware::power::V1_0::Status;
using namespace std::chrono_literals;
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state"; constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio"; constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
@ -119,6 +120,8 @@ Power::Power()
setProfile(PowerProfile::HIGH_PERFORMANCE); setProfile(PowerProfile::HIGH_PERFORMANCE);
mCurrentPerfProfile = PowerProfile::HIGH_PERFORMANCE; mCurrentPerfProfile = PowerProfile::HIGH_PERFORMANCE;
} }
mDoubleTapEnabled = false;
// Now start to take powerhint // Now start to take powerhint
mReady.store(true); mReady.store(true);
ALOGI("PowerHAL ready to process hints"); ALOGI("PowerHAL ready to process hints");
@ -185,7 +188,23 @@ Return<void> Power::setProfile(PowerProfile profile) {
// Methods from ::android::hardware::power::V1_0::IPower follow. // Methods from ::android::hardware::power::V1_0::IPower follow.
Return<void> Power::setInteractive(bool interactive) { Return<void> 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<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) { Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
@ -262,7 +281,7 @@ Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
Return<void> Power::setFeature(Feature feature, bool activate) { Return<void> Power::setFeature(Feature feature, bool activate) {
switch (feature) { switch (feature) {
case Feature::POWER_FEATURE_DOUBLE_TAP_TO_WAKE: case Feature::POWER_FEATURE_DOUBLE_TAP_TO_WAKE:
updateHint("DOUBLE_TAP_TO_WAKE", activate); mDoubleTapEnabled = activate;
break; break;
default: default:
break; break;

@ -95,6 +95,8 @@ class Power : public IPower, public ILineagePower {
std::atomic<bool> mReady; std::atomic<bool> mReady;
std::thread mInitThread; std::thread mInitThread;
std::atomic<bool> mDoubleTapEnabled;
int32_t mNumPerfProfiles; int32_t mNumPerfProfiles;
std::atomic<PowerProfile> mCurrentPerfProfile; std::atomic<PowerProfile> mCurrentPerfProfile;

@ -118,13 +118,12 @@
}, },
{ {
"Name": "DoubleTapToWakeEnable", "Name": "DoubleTapToWakeEnable",
"Path": "/sys/class/sec/tsp/dt2w_enable", "Path": "/sys/class/sec/tsp/cmd",
"Values": [ "Values": [
"0", "aot_enable,0",
"1" "aot_enable,1"
], ],
"DefaultIndex": 0, "DefaultIndex": 0,
"ResetOnInit": true
}, },
{ {
"Name": "PowerHALMainState", "Name": "PowerHALMainState",
@ -419,7 +418,7 @@
"PowerHint": "DOUBLE_TAP_TO_WAKE", "PowerHint": "DOUBLE_TAP_TO_WAKE",
"Node": "DoubleTapToWakeEnable", "Node": "DoubleTapToWakeEnable",
"Duration": 0, "Duration": 0,
"Value": "1" "Value": "aot_enable,1"
}, },
{ {
"PowerHint": "PROFILE_POWER_SAVE", "PowerHint": "PROFILE_POWER_SAVE",

Loading…
Cancel
Save