From 8f6c27c44271aec966b39f4276bafb7d973e4e5c Mon Sep 17 00:00:00 2001 From: Arian Date: Fri, 5 Nov 2021 16:44:55 +0100 Subject: [PATCH] sm8450-common: Add power HAL extension and use xiaomi-touch to handle dt2w Change-Id: I5c65e0df255853eb2b3018a27ceb807c111bc4df --- BoardConfigCommon.mk | 3 ++ power/power-mode.cpp | 55 +++++++++++++++++++++++++++++++ rootdir/etc/init.xiaomi_sm8450.rc | 4 +++ 3 files changed, 62 insertions(+) create mode 100644 power/power-mode.cpp diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 24ec38c..3633cbc 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -82,6 +82,9 @@ TARGET_COPY_OUT_VENDOR_DLKM := vendor_dlkm BOARD_USES_QCOM_HARDWARE := true TARGET_BOARD_PLATFORM := taro +# Power +TARGET_POWERHAL_MODE_EXT := $(COMMON_PATH)/power/power-mode.cpp + # Properties TARGET_ODM_PROP += $(COMMON_PATH)/properties/odm.prop TARGET_PRODUCT_PROP += $(COMMON_PATH)/properties/product.prop diff --git a/power/power-mode.cpp b/power/power-mode.cpp new file mode 100644 index 0000000..5a2674a --- /dev/null +++ b/power/power-mode.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2021 The LineageOS Project + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +#define SET_CUR_VALUE 0 +#define TOUCH_DOUBLETAP_MODE 14 +#define TOUCH_MAGIC 't' +#define TOUCH_IOC_SETMODE _IO(TOUCH_MAGIC, SET_CUR_VALUE) +#define TOUCH_DEV_PATH "/dev/xiaomi-touch" +#define TOUCH_ID 0 + +namespace aidl { +namespace android { +namespace hardware { +namespace power { +namespace impl { + +using ::aidl::android::hardware::power::Mode; + +bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return) { + switch (type) { + case Mode::DOUBLE_TAP_TO_WAKE: + *_aidl_return = true; + return true; + default: + return false; + } +} + +bool setDeviceSpecificMode(Mode type, bool enabled) { + switch (type) { + case Mode::DOUBLE_TAP_TO_WAKE: { + int fd = open(TOUCH_DEV_PATH, O_RDWR); + int arg[3] = {TOUCH_ID, TOUCH_DOUBLETAP_MODE, enabled ? 1 : 0}; + ioctl(fd, TOUCH_IOC_SETMODE, &arg); + close(fd); + return true; + } + default: + return false; + } +} + +} // namespace impl +} // namespace power +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/rootdir/etc/init.xiaomi_sm8450.rc b/rootdir/etc/init.xiaomi_sm8450.rc index de79a07..5947b87 100644 --- a/rootdir/etc/init.xiaomi_sm8450.rc +++ b/rootdir/etc/init.xiaomi_sm8450.rc @@ -61,6 +61,10 @@ on boot chmod 0660 /dev/goodix_fp chown system system /dev/goodix_fp + # Xiaomi touch + chown system system /dev/xiaomi-touch + chmod 0660 /dev/xiaomi-touch + on post-fs-data # Create folder of camera mkdir /data/vendor/camera/offlinelog 0777 cameraserver audio