Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ken Xue and committed by
Rafael J. Wysocki
16f70fea 861deac3

+10
+10
drivers/acpi/button.c
··· 480 480 481 481 static int acpi_button_resume(struct device *dev) 482 482 { 483 + struct input_dev *input; 483 484 struct acpi_device *device = to_acpi_device(dev); 484 485 struct acpi_button *button = acpi_driver_data(device); 485 486 ··· 489 488 button->last_state = !!acpi_lid_evaluate_state(device); 490 489 button->last_time = ktime_get(); 491 490 acpi_lid_initialize_state(device); 491 + } 492 + 493 + if (button->type == ACPI_BUTTON_TYPE_POWER) { 494 + input = button->input; 495 + input_report_key(input, KEY_WAKEUP, 1); 496 + input_sync(input); 497 + input_report_key(input, KEY_WAKEUP, 0); 498 + input_sync(input); 492 499 } 493 500 return 0; 494 501 } ··· 588 579 switch (button->type) { 589 580 case ACPI_BUTTON_TYPE_POWER: 590 581 input_set_capability(input, EV_KEY, KEY_POWER); 582 + input_set_capability(input, EV_KEY, KEY_WAKEUP); 591 583 break; 592 584 593 585 case ACPI_BUTTON_TYPE_SLEEP: