diff --git a/BoardConfig.mk b/BoardConfig.mk index abfb8cf..8a341be 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -116,6 +116,9 @@ TARGET_COPY_OUT_VENDOR_DLKM := vendor_dlkm TARGET_BOARD_PLATFORM := mt6789 BOARD_HAS_MTK_HARDWARE := true +# Power +TARGET_POWERHAL_MODE_EXT := $(DEVICE_PATH)/power/power-mode.cpp + # Properties TARGET_SYSTEM_PROP += $(CONFIGS_PATH)/properties/system.prop TARGET_VENDOR_PROP += $(CONFIGS_PATH)/properties/vendor.prop diff --git a/power/power-mode.cpp b/power/power-mode.cpp new file mode 100644 index 0000000..abc47fe --- /dev/null +++ b/power/power-mode.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 The LineageOS Project + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +// defines from drivers/input/touchscreen/xiaomi/xiaomi_touch.h +#define SET_CUR_VALUE 0 +#define Touch_Doubletap_Mode 14 + +#define TOUCH_DEV_PATH "/dev/xiaomi-touch" +#define TOUCH_ID 0 +#define TOUCH_MAGIC 0x5400 +#define TOUCH_IOC_SETMODE TOUCH_MAGIC + SET_CUR_VALUE + +namespace aidl { +namespace android { +namespace hardware { +namespace power { +namespace impl { +namespace mediatek { + +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 mediatek +} // namespace impl +} // namespace power +} // namespace hardware +} // namespace android +} // namespace aidl diff --git a/rootdir/etc/init/hw/init.project.rc b/rootdir/etc/init/hw/init.project.rc index 5f21fcb..be38c25 100644 --- a/rootdir/etc/init/hw/init.project.rc +++ b/rootdir/etc/init/hw/init.project.rc @@ -6,6 +6,10 @@ on init mkdir /mnt/media_rw/usbotg 0700 media_rw media_rw mkdir /storage/usbotg 0700 root root + # Set xiaomi touch permissions + chown system system /dev/xiaomi-touch + chmod 0660 /dev/xiaomi-touch + on post-fs-data #Camera