-/* $OpenBSD: acpibtn.c,v 1.28 2010/08/05 17:26:57 deraadt Exp $ */
+/* $OpenBSD: acpibtn.c,v 1.29 2010/08/05 19:23:06 marco Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
sc->sc_acpi = (struct acpi_softc *)parent;
sc->sc_devnode = aa->aaa_node;
- if (!strcmp(aa->aaa_dev, ACPI_DEV_LD))
+ if (!strcmp(aa->aaa_dev, ACPI_DEV_LD)) {
+ struct aml_value val;
+
sc->sc_btn_type = ACPIBTN_LID;
- else if (!strcmp(aa->aaa_dev, ACPI_DEV_PBD))
+ bzero(&val, sizeof val);
+ val.type = AML_OBJTYPE_INTEGER;
+ val.v_integer = 1;
+ val.length = 1;
+ (void) aml_evalname(sc->sc_acpi, sc->sc_devnode, "_PSW",
+ 1, &val, NULL);
+ } else if (!strcmp(aa->aaa_dev, ACPI_DEV_PBD))
sc->sc_btn_type = ACPIBTN_POWER;
else if (!strcmp(aa->aaa_dev, ACPI_DEV_SBD))
sc->sc_btn_type = ACPIBTN_SLEEP;
* _LID method. 0 means the lid is closed and we
* should go to sleep.
*/
+ if (acpi_lid_suspend)
+ break;
if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode,
"_LID", 0, NULL, &lid))
return (0);
- if (acpi_lid_suspend && lid == 0) {
- if (acpi_record_event(sc->sc_acpi, APM_USER_SUSPEND_REQ)) {
- sc->sc_acpi->sc_sleepmode = ACPI_STATE_S3;
- acpi_wakeup(sc->sc_acpi);
- }
- }
+ if (lid == 0)
+ goto sleep;
#endif /* SMALL_KERNEL */
break;
case ACPIBTN_SLEEP:
/* "something" has been taken care of by the system */
break;
case 0x80:
+sleep:
/* Request to go to sleep */
if (acpi_record_event(sc->sc_acpi, APM_USER_SUSPEND_REQ)) {
sc->sc_acpi->sc_sleepmode = ACPI_STATE_S3;