OSDN Git Service

ACPI: Power button event after resume
authorsrinivas pandruvada <srinivas.pandruvada@intel.com>
Fri, 3 Aug 2012 20:50:08 +0000 (13:50 -0700)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Sat, 13 Dec 2014 17:06:38 +0000 (01:06 +0800)
When system is resumed because of user pressed a power button,
this event is not passed to user space. This event is important
to resume user mode in some systems like Android.
This is built on the patch from "Daniel Drake" for OLPC.
We need some mechanism where user space doesn't have to use polling.
If we resort to polling to get the wake up source, because of
auto-suspend mode system sleep before user mode can complete polling.

Change-Id: I2901f543492d1454b0ceefc96da740215f3a3b10
Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
drivers/acpi/Kconfig
drivers/acpi/button.c
drivers/acpi/internal.h
drivers/acpi/sleep.c

index b23fe37..b6dd2fd 100644 (file)
@@ -370,6 +370,16 @@ config ACPI_REDUCED_HARDWARE_ONLY
 
        If you are unsure what to do, do not enable this option.
 
+config ACPI_RESUME_POWER_BUTTON_EVENT
+       bool "Power Button Event on Resume"
+       depends on ACPI_BUTTON
+       depends on ACPI_SLEEP
+       default n
+       help
+         This enable power button notification after system resume because
+         of user action through a power/sleep button. Some user mode system
+         has hard dependency on this event for system suspend and resume.
+
 source "drivers/acpi/apei/Kconfig"
 
 config ACPI_EXTLOG
index 6d5d183..a31c9de 100644 (file)
 #include <linux/slab.h>
 #include <linux/acpi.h>
 #include <acpi/button.h>
-
-#define PREFIX "ACPI: "
-
-#define ACPI_BUTTON_CLASS              "button"
-#define ACPI_BUTTON_FILE_INFO          "info"
-#define ACPI_BUTTON_FILE_STATE         "state"
-#define ACPI_BUTTON_TYPE_UNKNOWN       0x00
-#define ACPI_BUTTON_NOTIFY_STATUS      0x80
-
-#define ACPI_BUTTON_SUBCLASS_POWER     "power"
-#define ACPI_BUTTON_HID_POWER          "PNP0C0C"
-#define ACPI_BUTTON_DEVICE_NAME_POWER  "Power Button"
-#define ACPI_BUTTON_TYPE_POWER         0x01
-
-#define ACPI_BUTTON_SUBCLASS_SLEEP     "sleep"
-#define ACPI_BUTTON_HID_SLEEP          "PNP0C0E"
-#define ACPI_BUTTON_DEVICE_NAME_SLEEP  "Sleep Button"
-#define ACPI_BUTTON_TYPE_SLEEP         0x03
-
-#define ACPI_BUTTON_SUBCLASS_LID       "lid"
-#define ACPI_BUTTON_HID_LID            "PNP0C0D"
-#define ACPI_BUTTON_DEVICE_NAME_LID    "Lid Switch"
-#define ACPI_BUTTON_TYPE_LID           0x05
+#include "internal.h"
 
 #define _COMPONENT             ACPI_BUTTON_COMPONENT
 ACPI_MODULE_NAME("button");
index 447f6d6..791ea27 100644 (file)
@@ -89,6 +89,30 @@ bool acpi_device_is_present(struct acpi_device *adev);
 bool acpi_device_is_battery(struct acpi_device *adev);
 
 /* --------------------------------------------------------------------------
+                                 Button
+   -------------------------------------------------------------------------- */
+#define ACPI_BUTTON_CLASS              "button"
+#define ACPI_BUTTON_FILE_INFO          "info"
+#define ACPI_BUTTON_FILE_STATE         "state"
+#define ACPI_BUTTON_TYPE_UNKNOWN       0x00
+#define ACPI_BUTTON_NOTIFY_STATUS      0x80
+
+#define ACPI_BUTTON_SUBCLASS_POWER     "power"
+#define ACPI_BUTTON_HID_POWER          "PNP0C0C"
+#define ACPI_BUTTON_DEVICE_NAME_POWER  "Power Button"
+#define ACPI_BUTTON_TYPE_POWER         0x01
+
+#define ACPI_BUTTON_SUBCLASS_SLEEP     "sleep"
+#define ACPI_BUTTON_HID_SLEEP          "PNP0C0E"
+#define ACPI_BUTTON_DEVICE_NAME_SLEEP  "Sleep Button"
+#define ACPI_BUTTON_TYPE_SLEEP         0x03
+
+#define ACPI_BUTTON_SUBCLASS_LID       "lid"
+#define ACPI_BUTTON_HID_LID            "PNP0C0D"
+#define ACPI_BUTTON_DEVICE_NAME_LID    "Lid Switch"
+#define ACPI_BUTTON_TYPE_LID           0x05
+
+/* --------------------------------------------------------------------------
                                   Power Resource
    -------------------------------------------------------------------------- */
 int acpi_power_init(void);
index 05a31b5..f052968 100644 (file)
@@ -429,6 +429,13 @@ static void acpi_pm_finish(void)
        pwr_btn_dev = bus_find_device(&acpi_bus_type, NULL, NULL,
                                      find_powerf_dev);
        if (pwr_btn_dev) {
+#ifdef CONFIG_ACPI_RESUME_POWER_BUTTON_EVENT
+               struct acpi_device *device = to_acpi_device(pwr_btn_dev);
+               if (device->driver && device->driver->ops.notify) {
+                       device->driver->ops.notify(device,
+                                               ACPI_BUTTON_NOTIFY_STATUS);
+               }
+#endif
                pm_wakeup_event(pwr_btn_dev, 0);
                put_device(pwr_btn_dev);
        }