acpi: button: trigger wakeup key event
PATCH v6 1/1 acpi: button: trigger wakeup key event
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.
---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 messageV4->V5: add "select ACPI_BUTTON" to fix build error if CONFIG_ACPI_BUTTON=m. https://lore.kernel.org/oe-kbuild-all/[email protected]/V5->V6: report WAKEUP event from button driver instead of acpi sleep.c
--- drivers/acpi/button.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/acpi/button.c +10 -0
@@ -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 :
Signature · 1 line
2.35.1
Quoted 54 lines · Ken Xue
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_STATUSandACPI_BITMASK_POWER_BUTTON_STATUSare set inpm1a_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 <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>---
V1->V2: fix some compile warning/error caused by lack of
"structacpi_device" declaration by includingacpi.h.V2->V3: use "forward declaration" to fix compile warning/error.V3->V4: refine coding style and commit messageV4->V5: add "selectACPI_BUTTON" to fix build error ifCONFIG_ACPI_BUTTON=m. https://lore.kernel.org/oe-kbuild-all/[email protected]/V5->V6: report WAKEUP event from button driver instead of acpisleep.c--- drivers/acpi/button.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/acpi/button.c +9
-0@@ -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
drivers/acpi/button.c static int acpi_button_add(struct acpi_device *device)
Quoted 8 lines
drivers/acpi/button.c +1
-1@@ -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!