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/dev/acpica/acpi_button.c | |
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/dev/acpica/acpi_button.c')
-rw-r--r-- | sys/dev/acpica/acpi_button.c | 44 |
1 files changed, 32 insertions, 12 deletions
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 */ |