From e480d89ce536a3ad6748ab0aea1c78824ae02c85 Mon Sep 17 00:00:00 2001 From: "Christopher N. Hesse" Date: Wed, 22 Jun 2016 23:04:39 +0200 Subject: [PATCH] power: Add double tap to wake support Change-Id: Icb0b6d442544b39576ec74e70e97751d6bc70590 --- power/Android.mk | 4 ++++ power/power.c | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/power/Android.mk b/power/Android.mk index 2aaaac87..cf968fc2 100644 --- a/power/Android.mk +++ b/power/Android.mk @@ -24,6 +24,10 @@ LOCAL_SHARED_LIBRARIES := liblog libcutils LOCAL_SRC_FILES := power.c LOCAL_MODULE_TAGS := optional +ifneq ($(TARGET_TAP_TO_WAKE_NODE),) + LOCAL_CFLAGS := -DDT2W_PATH=\"$(TARGET_DT2W_PATH)\" +endif + include $(BUILD_SHARED_LIBRARY) endif diff --git a/power/power.c b/power/power.c index 3cf9cc21..f28dce51 100644 --- a/power/power.c +++ b/power/power.c @@ -503,6 +503,22 @@ static int samsung_get_feature(struct power_module *module __unused, return -1; } +static void samsung_set_feature(struct power_module *module, feature_t feature, int state) +{ + struct samsung_power_module *samsung_pwr = (struct samsung_power_module *) module; + + switch (feature) { +#ifdef DT2W_PATH + case POWER_FEATURE_DOUBLE_TAP_TO_WAKE: + ALOGV("%s: %s double tap to wake", __func__, state ? "enabling" : "disabling"); + sysfs_write(DT2W_PATH, state > 0 ? "1" : "0"); + break; +#endif + default: + break; + } +} + static struct hw_module_methods_t power_module_methods = { .open = NULL, }; @@ -522,7 +538,8 @@ struct samsung_power_module HAL_MODULE_INFO_SYM = { .init = samsung_power_init, .setInteractive = samsung_power_set_interactive, .powerHint = samsung_power_hint, - .getFeature = samsung_get_feature + .getFeature = samsung_get_feature, + .setFeature = samsung_set_feature }, .lock = PTHREAD_MUTEX_INITIALIZER,