Message ID | 20231225055835.1052555-1-Ken.Xue@amd.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
Series | [V6] acpi: button: trigger wakeup key event | expand |
On Mon, Dec 25, 2023 at 7:00 AM Ken Xue <Ken.Xue@amd.com> wrote: > > Andorid can wakeup from various wakeup sources, but only several wakeup > sources can wake up screen with right events(POWER, WAKEUP) from input > device. > > Regarding pressing acpi power button, it can resume system and > ACPI_BITMASK_WAKE_STATUS and ACPI_BITMASK_POWER_BUTTON_STATUS are set in > pm1a_sts, but kernel does not report any key event to user space during > resuming by default. > > So, send wakeup key event to user space during resume from power button. > > Signed-off-by: Ken Xue <Ken.Xue@amd.com> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > --- > V1->V2: fix some compile warning/error caused by lack of > "struct acpi_device" declaration by including acpi.h. > V2->V3: use "forward declaration" to fix compile warning/error. > V3->V4: refine coding style and commit message > V4->V5: add "select ACPI_BUTTON" to fix build error if CONFIG_ACPI_BUTTON=m. https://lore.kernel.org/oe-kbuild-all/202309150947.YLjvs2Vv-lkp@intel.com/ > V5->V6: report WAKEUP event from button driver instead of acpi sleep.c > --- > drivers/acpi/button.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c > index 1e76a64cce0a..cc61020756be 100644 > --- a/drivers/acpi/button.c > +++ b/drivers/acpi/button.c > @@ -480,6 +480,7 @@ static int acpi_button_suspend(struct device *dev) > > static int acpi_button_resume(struct device *dev) > { > + struct input_dev *input; > struct acpi_device *device = to_acpi_device(dev); > struct acpi_button *button = acpi_driver_data(device); > > @@ -489,6 +490,14 @@ static int acpi_button_resume(struct device *dev) > button->last_time = ktime_get(); > acpi_lid_initialize_state(device); > } > + > + if (button->type == ACPI_BUTTON_TYPE_POWER) { > + input = button->input; > + input_report_key(input, KEY_WAKEUP, 1); > + input_sync(input); > + input_report_key(input, KEY_WAKEUP, 0); > + input_sync(input); > + } > return 0; > } > #endif > @@ -579,6 +588,7 @@ static int acpi_button_add(struct acpi_device *device) > switch (button->type) { > case ACPI_BUTTON_TYPE_POWER: > input_set_capability(input, EV_KEY, KEY_POWER); > + input_set_capability(input, EV_KEY, KEY_WAKEUP); > break; > > case ACPI_BUTTON_TYPE_SLEEP: > -- Applied as 6.8 material with minor edits in the subject, thanks!
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 1e76a64cce0a..cc61020756be 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -480,6 +480,7 @@ static int acpi_button_suspend(struct device *dev) static int acpi_button_resume(struct device *dev) { + struct input_dev *input; struct acpi_device *device = to_acpi_device(dev); struct acpi_button *button = acpi_driver_data(device); @@ -489,6 +490,14 @@ static int acpi_button_resume(struct device *dev) button->last_time = ktime_get(); acpi_lid_initialize_state(device); } + + if (button->type == ACPI_BUTTON_TYPE_POWER) { + input = button->input; + input_report_key(input, KEY_WAKEUP, 1); + input_sync(input); + input_report_key(input, KEY_WAKEUP, 0); + input_sync(input); + } return 0; } #endif @@ -579,6 +588,7 @@ static int acpi_button_add(struct acpi_device *device) switch (button->type) { case ACPI_BUTTON_TYPE_POWER: input_set_capability(input, EV_KEY, KEY_POWER); + input_set_capability(input, EV_KEY, KEY_WAKEUP); break; case ACPI_BUTTON_TYPE_SLEEP: