summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2010-08-05 19:23:07 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2010-08-05 19:23:07 +0000
commite3029935663f89afaf6013c4da558086f83520aa (patch)
treef18b293ed767dbadf414e3fb2f4a0365f5305fc2
parent01e60ce4b43b4751018af47fe743f5074766207b (diff)
Wakeup machine when lid is opened on laptops that have acpibtn _LID.
initial diff from me, this version pruned by deraadt ok deraadt
-rw-r--r--sys/dev/acpi/acpibtn.c25
1 files changed, 16 insertions, 9 deletions
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 <marco@openbsd.org>
*
@@ -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;