[PATCH] ACPI: button: Support separate press and release events

From: liujinlong176

Date: Tue Oct 13 2026 - 02:40:53 EST


From: liujinlong <liujinlong@xxxxxxxxxx>

The ACPI button driver only recognizes notify value 0x80 and
always synthesizes a press followed by an immediate release.
This makes it impossible for userspace to determine the actual
duration of a power button press.

Add two new notify values, 0x81 and 0x82, that firmware can use
to report the press and the release separately. The 0x80 path
is unchanged for compatibility with existing firmware.

Move the notify value definitions to include/acpi/button.h so
they can be shared between the driver and other users.

Signed-off-by: liujinlong <liujinlong@xxxxxxxxxx>
---
drivers/acpi/button.c | 24 ++++++++++++++++++------
include/acpi/button.h | 4 ++++
2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index cdbb1023a8ee..b72ed9fc429d 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -26,7 +26,6 @@
#define ACPI_BUTTON_FILE_STATE "state"
#define ACPI_BUTTON_TYPE_UNKNOWN 0x00
#define ACPI_BUTTON_NOTIFY_WAKE 0x02
-#define ACPI_BUTTON_NOTIFY_STATUS 0x80

#define ACPI_BUTTON_CLASS_POWER "button/power"
#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button"
@@ -465,7 +464,8 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)

switch (event) {
case ACPI_BUTTON_NOTIFY_STATUS:
- break;
+ case ACPI_BUTTON_NOTIFY_PRESS:
+ case ACPI_BUTTON_NOTIFY_RELEASE:
case ACPI_BUTTON_NOTIFY_WAKE:
break;
default:
@@ -482,10 +482,22 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
input = button->input;
keycode = test_bit(KEY_SLEEP, input->keybit) ? KEY_SLEEP : KEY_POWER;

- input_report_key(input, keycode, 1);
- input_sync(input);
- input_report_key(input, keycode, 0);
- input_sync(input);
+ switch (event) {
+ case ACPI_BUTTON_NOTIFY_STATUS:
+ input_report_key(input, keycode, 1);
+ input_sync(input);
+ input_report_key(input, keycode, 0);
+ input_sync(input);
+ break;
+ case ACPI_BUTTON_NOTIFY_PRESS:
+ input_report_key(input, keycode, 1);
+ input_sync(input);
+ break;
+ case ACPI_BUTTON_NOTIFY_RELEASE:
+ input_report_key(input, keycode, 0);
+ input_sync(input);
+ break;
+ }

acpi_bus_generate_netlink_event(button->class, dev_name(&device->dev),
event, ++button->pushed);
diff --git a/include/acpi/button.h b/include/acpi/button.h
index af2fce5d2ee3..832f1a308828 100644
--- a/include/acpi/button.h
+++ b/include/acpi/button.h
@@ -6,6 +6,10 @@
#define ACPI_BUTTON_HID_LID "PNP0C0D"
#define ACPI_BUTTON_HID_SLEEP "PNP0C0E"

+#define ACPI_BUTTON_NOTIFY_STATUS 0x80
+#define ACPI_BUTTON_NOTIFY_PRESS 0x81
+#define ACPI_BUTTON_NOTIFY_RELEASE 0x82
+
#if IS_ENABLED(CONFIG_ACPI_BUTTON)
extern int acpi_lid_open(void);
#else
--
2.25.1


No virus found
Checked by Hillstone Network AntiVirus