Browse Source

sm8450-common: power: Set double-tap mode for secondary panel if exists

Change-Id: I20c06b5dbf88b07a330af8af3455318acbdeb276
Signed-off-by: Jens Reidel <[email protected]>
Jens Reidel 1 year ago
parent
commit
652efb6b64
1 changed files with 13 additions and 3 deletions
  1. 13 3
      power/power-mode.cpp

+ 13 - 3
power/power-mode.cpp

@@ -8,13 +8,16 @@
 #include <android-base/file.h>
 #include <android-base/logging.h>
 #include <sys/ioctl.h>
+#include <sys/stat.h>
 
 #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
+#define TOUCH_ID_PRIMARY 0
+#define TOUCH_ID_SECONDARY 1
+#define MI_DISP_SECONDARY "/sys/devices/virtual/mi_display/disp_feature/disp-DSI-1"
 
 namespace aidl {
 namespace android {
@@ -38,8 +41,15 @@ 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);
+            int arg_primary[3] = {TOUCH_ID_PRIMARY, TOUCH_DOUBLETAP_MODE, enabled ? 1 : 0};
+            ioctl(fd, TOUCH_IOC_SETMODE, &arg_primary);
+
+            struct stat buffer;
+            if (stat(MI_DISP_SECONDARY, &buffer) == 0) {
+                int arg_secondary[3] = {TOUCH_ID_SECONDARY, TOUCH_DOUBLETAP_MODE, enabled ? 1 : 0};
+                ioctl(fd, TOUCH_IOC_SETMODE, &arg_secondary);
+            }
+
             close(fd);
             return true;
         }