Skip to content

Commit 16f70fe

Browse files
firstbreadrafaeljw
authored andcommitted
ACPI: button: trigger wakeup key events
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> [ rjw: Subject edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 861deac commit 16f70fe

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/acpi/button.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ static int acpi_button_suspend(struct device *dev)
480480

481481
static int acpi_button_resume(struct device *dev)
482482
{
483+
struct input_dev *input;
483484
struct acpi_device *device = to_acpi_device(dev);
484485
struct acpi_button *button = acpi_driver_data(device);
485486

@@ -489,6 +490,14 @@ static int acpi_button_resume(struct device *dev)
489490
button->last_time = ktime_get();
490491
acpi_lid_initialize_state(device);
491492
}
493+
494+
if (button->type == ACPI_BUTTON_TYPE_POWER) {
495+
input = button->input;
496+
input_report_key(input, KEY_WAKEUP, 1);
497+
input_sync(input);
498+
input_report_key(input, KEY_WAKEUP, 0);
499+
input_sync(input);
500+
}
492501
return 0;
493502
}
494503
#endif
@@ -579,6 +588,7 @@ static int acpi_button_add(struct acpi_device *device)
579588
switch (button->type) {
580589
case ACPI_BUTTON_TYPE_POWER:
581590
input_set_capability(input, EV_KEY, KEY_POWER);
591+
input_set_capability(input, EV_KEY, KEY_WAKEUP);
582592
break;
583593

584594
case ACPI_BUTTON_TYPE_SLEEP:

0 commit comments

Comments
 (0)