1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-22 15:47:37 +00:00

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:
This commit is contained in:
Nate Lawson 2004-02-11 02:57:33 +00:00
parent 02312219eb
commit 33febf93d6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125679
3 changed files with 42 additions and 24 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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