From a0e115027a83be763acf55d4514280323eac506a Mon Sep 17 00:00:00 2001 From: TheScarastic Date: Wed, 30 Jan 2019 18:16:42 +0530 Subject: [PATCH] davinci: power: Support event-based dt2w node Change-Id: I08c874f3ca50fad1db820ddd85ef0f5d7ccf0ed2 --- power/Android.mk | 3 +++ power/power-feature.c | 17 ++++++++++++++++- power/power-feature.h | 5 +++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/power/Android.mk b/power/Android.mk index f581ccd..3901072 100644 --- a/power/Android.mk +++ b/power/Android.mk @@ -20,6 +20,9 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := power-feature.c LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_HEADER_LIBRARIES := \ + generated_kernel_headers \ + libhardware_headers LOCAL_MODULE := libpower_feature.davinci LOCAL_MODULE_TAGS := optional diff --git a/power/power-feature.c b/power/power-feature.c index a9c8878..1834c35 100644 --- a/power/power-feature.c +++ b/power/power-feature.c @@ -14,10 +14,25 @@ * limitations under the License. */ +#include +#include + #include "power-feature.h" +#include +#include #include void set_device_specific_feature(feature_t feature, int state) { - // stub + switch (feature) { + case POWER_FEATURE_DOUBLE_TAP_TO_WAKE: { + int fd = open(TAP_TO_WAKE_EVENT_NODE, O_WRONLY); + struct input_event ev; + ev.type = EV_SYN; + ev.code = SYN_CONFIG; + ev.value = state ? INPUT_EVENT_WAKUP_MODE_ON : INPUT_EVENT_WAKUP_MODE_OFF; + write(fd, &ev, sizeof(ev)); + close(fd); + } + } } diff --git a/power/power-feature.h b/power/power-feature.h index 1d9e7db..3f2ab19 100644 --- a/power/power-feature.h +++ b/power/power-feature.h @@ -15,3 +15,8 @@ */ #define LOG_TAG "libpower_feature.davinci" + +#define TAP_TO_WAKE_EVENT_NODE "/dev/input/event2" + +#define INPUT_EVENT_WAKUP_MODE_OFF 4 +#define INPUT_EVENT_WAKUP_MODE_ON 5