static int acpi_lid_attach(device_t dev) { struct acpi_prw_data prw; struct acpi_lid_softc *sc; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); sc = device_get_softc(dev); sc->lid_dev = dev; sc->lid_handle = acpi_get_handle(dev); /* * If a system does not get lid events, it may make sense to change * the type to ACPI_ALL_NOTIFY. Some systems generate both a wake and * runtime notify in that case though. */ AcpiInstallNotifyHandler(sc->lid_handle, ACPI_DEVICE_NOTIFY, acpi_lid_notify_handler, sc); /* Enable the GPE for wake/runtime. */ acpi_wake_set_enable(dev, 1); if (acpi_parse_prw(sc->lid_handle, &prw) == 0) AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit); return (0); }
static int acpi_button_attach(device_t dev) { struct acpi_prw_data prw; struct acpi_button_softc *sc; ACPI_STATUS status; int event; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 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 new handler. We could remove any fixed handlers added * from the FADT once we have a duplicate from the AML but some systems * only return events on one or the other so we have to keep both. */ if (sc->fixed) { AcpiClearEvent(event); status = AcpiInstallFixedEventHandler(event, acpi_button_fixed_handler, sc); } else { /* * If a system does not get lid events, it may make sense to change * the type to ACPI_ALL_NOTIFY. Some systems generate both a wake * and runtime notify in that case though. */ status = AcpiInstallNotifyHandler(sc->button_handle, ACPI_DEVICE_NOTIFY, acpi_button_notify_handler, sc); } if (ACPI_FAILURE(status)) { device_printf(sc->button_dev, "couldn't install notify handler - %s\n", AcpiFormatException(status)); return_VALUE (ENXIO); } /* Enable the GPE for wake/runtime */ acpi_wake_set_enable(dev, 1); if (acpi_parse_prw(sc->button_handle, &prw) == 0) AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit); return_VALUE (0); }