diff options
author | njl <njl@FreeBSD.org> | 2004-02-11 02:57:33 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2004-02-11 02:57:33 +0000 |
commit | dfc906ec95fc478c611f5ef93b40dc04b3ecb6e8 (patch) | |
tree | 1e5a9e04f9689a3f51b87f749a1f7e18790de29e /sys | |
parent | e68c7765414386daa6e31258d6c4968061681bb6 (diff) | |
download | FreeBSD-src-dfc906ec95fc478c611f5ef93b40dc04b3ecb6e8.zip FreeBSD-src-dfc906ec95fc478c611f5ef93b40dc04b3ecb6e8.tar.gz |
Prefer buttons defined in the AML over the ones in the FADT. Some
systems define power/sleep buttons in both places but only deliver
notifies to the ones defined in the AML.
Also, reduce length of various function handler names.
PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
MFC after:
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/acpica/acpi.c | 14 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_button.c | 44 | ||||
-rw-r--r-- | sys/dev/acpica/acpivar.h | 8 |
3 files changed, 42 insertions, 24 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 856fad0..0f81f2a 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1125,8 +1125,7 @@ acpi_enable_fixed_events(struct acpi_softc *sc) AcpiEnableEvent(ACPI_EVENT_POWER_BUTTON, 0); AcpiClearEvent(ACPI_EVENT_POWER_BUTTON); AcpiInstallFixedEventHandler(ACPI_EVENT_POWER_BUTTON, - acpi_eventhandler_power_button_for_sleep, - sc); + acpi_event_power_button_sleep, sc); if (first_time) device_printf(sc->acpi_dev, "Power Button (fixed)\n"); } @@ -1134,8 +1133,7 @@ acpi_enable_fixed_events(struct acpi_softc *sc) AcpiEnableEvent(ACPI_EVENT_SLEEP_BUTTON, 0); AcpiClearEvent(ACPI_EVENT_SLEEP_BUTTON); AcpiInstallFixedEventHandler(ACPI_EVENT_SLEEP_BUTTON, - acpi_eventhandler_sleep_button_for_sleep, - sc); + acpi_event_sleep_button_sleep, sc); if (first_time) device_printf(sc->acpi_dev, "Sleep Button (fixed)\n"); } @@ -1719,7 +1717,7 @@ acpi_system_eventhandler_wakeup(void *arg, int state) * ACPICA Event Handlers (FixedEvent, also called from button notify handler) */ UINT32 -acpi_eventhandler_power_button_for_sleep(void *context) +acpi_event_power_button_sleep(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; @@ -1731,7 +1729,7 @@ acpi_eventhandler_power_button_for_sleep(void *context) } UINT32 -acpi_eventhandler_power_button_for_wakeup(void *context) +acpi_event_power_button_wake(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; @@ -1743,7 +1741,7 @@ acpi_eventhandler_power_button_for_wakeup(void *context) } UINT32 -acpi_eventhandler_sleep_button_for_sleep(void *context) +acpi_event_sleep_button_sleep(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; @@ -1755,7 +1753,7 @@ acpi_eventhandler_sleep_button_for_sleep(void *context) } UINT32 -acpi_eventhandler_sleep_button_for_wakeup(void *context) +acpi_event_sleep_button_wake(void *context) { struct acpi_softc *sc = (struct acpi_softc *)context; diff --git a/sys/dev/acpica/acpi_button.c b/sys/dev/acpica/acpi_button.c index 33ace78..3bab1dd 100644 --- a/sys/dev/acpica/acpi_button.c +++ b/sys/dev/acpica/acpi_button.c @@ -60,8 +60,8 @@ static void acpi_button_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context); static ACPI_STATUS acpi_button_fixed_handler(void *context); -static void acpi_button_notify_pressed_for_sleep(void *arg); -static void acpi_button_notify_pressed_for_wakeup(void *arg); +static void acpi_button_notify_sleep(void *arg); +static void acpi_button_notify_wakeup(void *arg); static device_method_t acpi_button_methods[] = { /* Device interface */ @@ -127,10 +127,13 @@ acpi_button_attach(device_t dev) sc = device_get_softc(dev); sc->button_dev = dev; sc->button_handle = acpi_get_handle(dev); + event = (sc->button_type == ACPI_SLEEP_BUTTON) ? + ACPI_EVENT_SLEEP_BUTTON : ACPI_EVENT_POWER_BUTTON; + /* Install the appropriate new handler. */ if (sc->fixed) { - event = (sc->button_type == ACPI_SLEEP_BUTTON) ? - ACPI_EVENT_SLEEP_BUTTON : ACPI_EVENT_POWER_BUTTON; + AcpiEnableEvent(event, 0); + AcpiClearEvent(event); status = AcpiInstallFixedEventHandler(event, acpi_button_fixed_handler, sc); } else { @@ -143,6 +146,23 @@ acpi_button_attach(device_t dev) return_VALUE (ENXIO); } acpi_device_enable_wake_capability(sc->button_handle, 1); + + /* + * If we have fixed buttons defined in the FADT, remove them now that + * we have found one in the AML. Some systems define buttons both ways + * but only deliver events to the AML object. + */ + if (event == ACPI_EVENT_POWER_BUTTON && AcpiGbl_FADT->PwrButton == 0) { + AcpiDisableEvent(event, 0); + AcpiClearEvent(event); + AcpiRemoveFixedEventHandler(event, acpi_event_power_button_sleep); + } + if (event == ACPI_EVENT_SLEEP_BUTTON && AcpiGbl_FADT->SleepButton == 0) { + AcpiDisableEvent(event, 0); + AcpiClearEvent(event); + AcpiRemoveFixedEventHandler(event, acpi_event_sleep_button_sleep); + } + return_VALUE (0); } @@ -163,7 +183,7 @@ acpi_button_resume(device_t dev) } static void -acpi_button_notify_pressed_for_sleep(void *arg) +acpi_button_notify_sleep(void *arg) { struct acpi_button_softc *sc; struct acpi_softc *acpi_sc; @@ -180,11 +200,11 @@ acpi_button_notify_pressed_for_sleep(void *arg) switch (sc->button_type) { case ACPI_POWER_BUTTON: ACPI_VPRINT(sc->button_dev, acpi_sc, "power button pressed\n"); - acpi_eventhandler_power_button_for_sleep((void *)acpi_sc); + acpi_event_power_button_sleep(acpi_sc); break; case ACPI_SLEEP_BUTTON: ACPI_VPRINT(sc->button_dev, acpi_sc, "sleep button pressed\n"); - acpi_eventhandler_sleep_button_for_sleep((void *)acpi_sc); + acpi_event_sleep_button_sleep(acpi_sc); break; default: break; /* unknown button type */ @@ -192,7 +212,7 @@ acpi_button_notify_pressed_for_sleep(void *arg) } static void -acpi_button_notify_pressed_for_wakeup(void *arg) +acpi_button_notify_wakeup(void *arg) { struct acpi_button_softc *sc; struct acpi_softc *acpi_sc; @@ -209,11 +229,11 @@ acpi_button_notify_pressed_for_wakeup(void *arg) switch (sc->button_type) { case ACPI_POWER_BUTTON: ACPI_VPRINT(sc->button_dev, acpi_sc, "wakeup by power button\n"); - acpi_eventhandler_power_button_for_wakeup((void *)acpi_sc); + acpi_event_power_button_wake(acpi_sc); break; case ACPI_SLEEP_BUTTON: ACPI_VPRINT(sc->button_dev, acpi_sc, "wakeup by sleep button\n"); - acpi_eventhandler_sleep_button_for_wakeup((void *)acpi_sc); + acpi_event_sleep_button_wake(acpi_sc); break; default: break; /* unknown button type */ @@ -230,11 +250,11 @@ acpi_button_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) switch (notify) { case ACPI_NOTIFY_BUTTON_PRESSED_FOR_SLEEP: AcpiOsQueueForExecution(OSD_PRIORITY_LO, - acpi_button_notify_pressed_for_sleep, sc); + acpi_button_notify_sleep, sc); break; case ACPI_NOTIFY_BUTTON_PRESSED_FOR_WAKEUP: AcpiOsQueueForExecution(OSD_PRIORITY_LO, - acpi_button_notify_pressed_for_wakeup, sc); + acpi_button_notify_wakeup, sc); break; default: break; /* unknown notification value */ diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 13b7fa5..4b64b07 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -225,10 +225,10 @@ extern ACPI_STATUS acpi_parse_resources(device_t dev, ACPI_HANDLE handle, #define ACPI_RESOURCE_NEXT(Res) (ACPI_RESOURCE *)((UINT8 *)Res + Res->Length) /* ACPI event handling */ -extern UINT32 acpi_eventhandler_power_button_for_sleep(void *context); -extern UINT32 acpi_eventhandler_power_button_for_wakeup(void *context); -extern UINT32 acpi_eventhandler_sleep_button_for_sleep(void *context); -extern UINT32 acpi_eventhandler_sleep_button_for_wakeup(void *context); +extern UINT32 acpi_event_power_button_sleep(void *context); +extern UINT32 acpi_event_power_button_wake(void *context); +extern UINT32 acpi_event_sleep_button_sleep(void *context); +extern UINT32 acpi_event_sleep_button_wake(void *context); #define ACPI_EVENT_PRI_FIRST 0 #define ACPI_EVENT_PRI_DEFAULT 10000 |