From: marco Date: Thu, 5 Aug 2010 19:23:06 +0000 (+0000) Subject: Wakeup machine when lid is opened on laptops that have acpibtn _LID. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1d0deb3bcc47eaa5a25f9e584d0e5639538701a6;p=openbsd Wakeup machine when lid is opened on laptops that have acpibtn _LID. initial diff from me, this version pruned by deraadt ok deraadt --- diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c index 9c9e66b40d7..028f5fc0483 100644 --- a/sys/dev/acpi/acpibtn.c +++ b/sys/dev/acpi/acpibtn.c @@ -1,4 +1,4 @@ -/* $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 * @@ -84,9 +84,17 @@ acpibtn_attach(struct device *parent, struct device *self, void *aux) 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; @@ -135,15 +143,13 @@ acpibtn_notify(struct aml_node *node, int notify_type, void *arg) * _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: @@ -153,6 +159,7 @@ acpibtn_notify(struct aml_node *node, int notify_type, void *arg) /* "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;