Wake on screen touch

I have an Edge2 running Android 13 v240611 with a Dell P2714Tt 27" touchscreen monitor (running in portrait mode). The monitor and touchscreen work great. The monitor is connected via HDMI but the touchscreen part is connected via USB. The problem I’m having is once the system goes to sleep.

When the system goes to sleep, the monitor goes to sleep as well, but touching the screen does not wake it up. I have to hit the power button on the Edge2 to wake it. Is there a way to have it wake by touch?

Also sometimes when I wake it via the power button, the touchscreen doesn’t work until I turn the monitor off and on again via the monitor’s power button.

@liam821 After entering sleep mode, the USB power is turned off, causing the USB touch screen to malfunction during sleep mode. To solve this, we can only do a fake sleep mode, not allowing the machine to enter deep sleep mode, only shallow sleep mode.

    sleep: do not enter deep sleep

diff --git a/drivers/misc/khadas-mcu.c b/drivers/misc/khadas-mcu.c
index df96ca24e014..03e1b8666367 100644
--- a/drivers/misc/khadas-mcu.c
+++ b/drivers/misc/khadas-mcu.c
@@ -14,6 +14,7 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/amlogic/pm.h>
+#include <linux/wakelock.h>
 
 /* Device registers */
 #define MCU_BOOT_EN_WOL_REG             0x21
@@ -41,6 +42,7 @@
 #define MCU_FAN_SPEED_HIGH_V2           0x64
 
 extern int meson_get_temperature(void);
+static struct wake_lock wake_lock_always;
 
 enum mcu_fan_mode {
        MCU_FAN_MODE_MANUAL = 0,
@@ -870,7 +872,8 @@ static int mcu_probe(struct i2c_client *client, const struct i2c_device_id *id)
        */
 
        create_mcu_attrs();
-
+       wake_lock_init(&wake_lock_always, WAKE_LOCK_SUSPEND, "wake_lock_always");
+       wake_lock(&wake_lock_always);
        //if (is_support_wol()) {
                reg[0] = 0x01;
                ret = mcu_i2c_write_regs(client, 0x87, reg, 1);

Please refer to the link and add the corresponding IDC file to take a look.

Thank you for the patch, not entering deep sleep sounds perfect! But I can’t find that version of khadas-mcu.c your patch is against in the khadas-edge2-android13 git repo.

It looks like your patch is for the vim4 perhaps?

I’ll give the IDC a try tomorrow and report back.

Thanks,
Liam

@liam821 Yes, you can refer to and add it. Just a few lines of code.

Just wanted to update you. I’ve applied the following patch (see below) and it fixed the issue I was having. The screen still goes to sleep but now I can quickly wake via a key press. Unfortunately, I cannot wake by the touchscreen but I think that is caused by the display not accepting an input while in sleep mode.

This patch also fixed the touchscreen not working after wake because USB was never dropped.

Thanks!
Liam

--- /home/liam/orig/kernel-5.10/drivers/misc/khadas-mcu.c	2024-08-17 01:15:12.800399695 +0000
+++ /home/liam/work/kernel-5.10/drivers/misc/khadas-mcu.c	2024-08-14 07:23:01.268588718 +0000
@@ -20,6 +20,7 @@
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/wakelock.h>
 
 /* Device registers */
 #define MCU_PWR_OFF_CMD_REG       0x80
@@ -57,6 +58,8 @@
 #define MCU_FAN_SPEED_MID_V2            0x48
 #define MCU_FAN_SPEED_HIGH_V2           0x64
 
+static struct wake_lock wake_lock_always;
+
 enum khadas_board {
 	KHADAS_BOARD_NONE = 0,
 	KHADAS_BOARD_EDGE2
@@ -758,6 +761,8 @@
 	mcu_fan_level_set(&g_mcu_data->fan_data, 0);
 	schedule_delayed_work(&g_mcu_data->fan_data.work, MCU_FAN_LOOP_SECS);
 	create_mcu_attrs();
+	wake_lock_init(&wake_lock_always, WAKE_LOCK_SUSPEND, "wake_lock_always");
+        wake_lock(&wake_lock_always);
 
 	return 0;
 }