[PATCH] Make power-button key report the button-up event when the 5-button array does not exist

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am running Fedora 28 and Android-x86 on a Dell Latitude 5175 tablet. The 
power button functionality is driven by the intel-hid driver. I am using 
kernel version 4.16.

Currently, the intel-hid driver does not supply a KEY_POWER up event in cases 
where the platform doesn't expose the 5-button array. Without this patch, the 
power button can't reliably respond when the platform is running Android.

When running Fedora, I can use the power button to suspend and resume the 
tablet. I can initiate this suspend by short-pressing the power button for a 
second, and can resume it using another short-press.

When running Android-x86, I can only short-press the power button once. After 
the press, the button seems to no longer respond. This is problematic when 
using a short-press to initiate a suspend, since a subsequent short press will 
not wake the tablet.

I used getevent to display the KeyEvents[1] detected by Android, and a 
combination of 'cat /proc/kmsg' and debug statements in the intel-hid driver 
to display the events generated by the driver. I found the block in the intel-
hid driver that generates power button events for my device. On line 253 of 
intel-hid.c:

        if (!priv->array) {
                if (event == 0xce) {
                        input_report_key(priv->input_dev, KEY_POWER, 1);
                        input_sync(priv->input_dev);
                        return;
                }

                if (event == 0xcf)
                        return;
}

When I short-press the power button, intel-hid produces a KEY_POWER down 
event, but doesn't produce a KEY_POWER up event when I release the power 
button. Suppose intel-hid has been mapped to the input device /dev/input/
event19. Then, on Android-x86, the command "getevent -lt" produces the 
following output:

/dev/input/event19: EV_KEY       KEY_POWER            DOWN                
/dev/input/event19: EV_SYN       SYN_REPORT           00000000

Subsequent presses produced no output for that input device.

When I added a call to input_report_key(...) and input_sync(...) on the 
KEY_POWER up event in the intel-hid driver, I could repeatedly short-press the 
power button and have Android respond appropriately, including resuming the 
device from suspend. My hunch as to why this is the case is that Android needs 
a paired KEY_POWER DOWN and UP event before it will handle the press.
>From 13f7f1cd9dfb71275f41dc598b17a92503fb991c Mon Sep 17 00:00:00 2001
From: Tristian Celestin <tristian.celestin@xxxxxxxxxxx>
Date: Tue, 10 Apr 2018 00:52:53 -0400
Subject: [PATCH] Make power-button key report the button-up event when the
 5-button array does not exist.

---
 drivers/platform/x86/intel-hid.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c
index 5e3df19..170ad950 100644
--- a/drivers/platform/x86/intel-hid.c
+++ b/drivers/platform/x86/intel-hid.c
@@ -260,6 +260,8 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 		}
 
 		if (event == 0xcf)
+			input_report_key(priv->input_dev, KEY_POWER, 0);
+			input_sync(priv->input_dev);
 			return;
 	}
 
-- 
1.8.3.1


[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux