sm8350-common: Add power HAL extension and use xiaomi-touch to handle dt2w

Change-Id: I5c65e0df255853eb2b3018a27ceb807c111bc4df
This commit is contained in:
Arian 2021-11-05 16:44:55 +01:00
parent a0ec4101e4
commit d90172a404
5 changed files with 67 additions and 1 deletions

View File

@ -147,7 +147,7 @@ TARGET_COPY_OUT_PRODUCT := product
TARGET_BOARD_PLATFORM := lahaina TARGET_BOARD_PLATFORM := lahaina
# Power # Power
TARGET_TAP_TO_WAKE_NODE := "/sys/devices/virtual/touch/tp_dev/double_tap" TARGET_POWERHAL_MODE_EXT := $(COMMON_PATH)/power/power-mode.cpp
# Properties # Properties
TARGET_ODM_PROP += $(COMMON_PATH)/odm.prop TARGET_ODM_PROP += $(COMMON_PATH)/odm.prop

57
power/power-mode.cpp Normal file
View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2021 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <aidl/android/hardware/power/BnPower.h>
#include <android-base/file.h>
#include <android-base/logging.h>
#include <sys/ioctl.h>
// 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 {
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

View File

@ -118,6 +118,10 @@ on boot
chown system system /sys/class/thermal/thermal_message/balance_mode chown system system /sys/class/thermal/thermal_message/balance_mode
chown system system /sys/devices/virtual/touch/tp_dev/double_tap chown system system /sys/devices/virtual/touch/tp_dev/double_tap
# Set xiaomi touch permissions
chown system system /dev/xiaomi-touch
chmod 0660 /dev/xiaomi-touch
write /dev/cpuset/audio-app/cpus 1-2 write /dev/cpuset/audio-app/cpus 1-2
# Add a cpuset for the camera daemon # Add a cpuset for the camera daemon

View File

@ -20,6 +20,9 @@
# Power # Power
/sys/devices/virtual/touch/tp_dev/double_tap u:object_r:vendor_sysfs_double_tap:s0 /sys/devices/virtual/touch/tp_dev/double_tap u:object_r:vendor_sysfs_double_tap:s0
# Power
/dev/xiaomi-touch u:object_r:vendor_touchfeature_device:s0
# Powershare # Powershare
/vendor/bin/hw/vendor\.lineage\.powershare@1\.0-service\.xiaomi_sm8350 u:object_r:hal_lineage_powershare_default_exec:s0 /vendor/bin/hw/vendor\.lineage\.powershare@1\.0-service\.xiaomi_sm8350 u:object_r:hal_lineage_powershare_default_exec:s0

View File

@ -1,3 +1,5 @@
type vendor_sysfs_double_tap, sysfs_type, fs_type; type vendor_sysfs_double_tap, sysfs_type, fs_type;
type vendor_touchfeature_device, dev_type;
allow hal_power_default vendor_sysfs_double_tap:file rw_file_perms; allow hal_power_default vendor_sysfs_double_tap:file rw_file_perms;
allow hal_power_default vendor_touchfeature_device:chr_file rw_file_perms;