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

From: 刘金龙

Date: Tue Oct 13 2026 - 21:34:03 EST


On Wed, Oct 14, 2026 at 1:31 AM Rafael J. Wysocki <rafael@xxxxxxxxxx> wrote:
>
> You'd need to update the ACPI specification first as that's where the
> notification values are defined.
 
Thank you for the review, Rafael.
 
You're right.  I'll drop the new notify values and take a different
approach in v2: evaluate a _PSB control method when the existing 0x80
notification is received to determine the real button state.  No ACPI
specification change is needed, and if _PSB is absent the current
press+release behavior is preserved.
 
I'll send v2 shortly.

 




主   题:Re: [PATCH] ACPI: button: Support separate press and release events
日   期:2026年10月14日01:31
发件人:Rafael J. Wysocki (Intel)
收件人:liujinlong176,Rafael J. Wysocki (Intel)
抄送人:Rafael J . Wysocki,Len Brown,linux-acpi,linux-kernel

On Tue, Oct 13, 2026 at 8:39 AM <liujinlong176@xxxxxxx> wrote: > > 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. You'd need to update the ACPI specification first as that's where the notification values are defined. > 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 > </liujinlong@xxxxxxxxxx></liujinlong@xxxxxxxxxx></liujinlong176@xxxxxxx>