diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-11-25 19:41:17 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-11-25 19:41:17 +0000 |
commit | cbb9f2abcbb2815ed0ed9fa549a7c97517d15a42 (patch) | |
tree | e6b2675a859880ff202545be1449ee657f0a6e92 /sys | |
parent | eeac4469fdaaf0d08c398d789b535b8ed2dd5433 (diff) |
Suspend when the lid closes (but not when it opens again).
ok deraadt@, mlarkin@, pirofti@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/acpi/acpibtn.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c index 9eda687d0b4..6231bf1a738 100644 --- a/sys/dev/acpi/acpibtn.c +++ b/sys/dev/acpi/acpibtn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibtn.c,v 1.23 2009/11/25 16:12:40 deraadt Exp $ */ +/* $OpenBSD: acpibtn.c,v 1.24 2009/11/25 19:41:16 kettenis Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -115,6 +115,9 @@ int acpibtn_notify(struct aml_node *node, int notify_type, void *arg) { struct acpibtn_softc *sc = arg; +#ifndef SMALL_KERNEL + int64_t lid; +#endif dnprintf(10, "acpibtn_notify: %.2x %s\n", notify_type, sc->sc_devnode->name); @@ -123,10 +126,18 @@ acpibtn_notify(struct aml_node *node, int notify_type, void *arg) case ACPIBTN_LID: /* * Notification of 0x80 for lid opens or closes. We - * need to check using other means, and if desirable, - * go to sleep. + * need to check the current status by calling the + * _LID method. Zero means the lid is closed and we + * should go to sleep. */ +#ifndef SMALL_KERNEL + if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, + "_LID", 0, NULL, &lid)) + return (0); + if (lid == 0) + acpi_sleep_state(sc->sc_acpi, ACPI_STATE_S3); break; +#endif /* SMALL_KERNEL */ case ACPIBTN_SLEEP: #ifndef SMALL_KERNEL switch (notify_type) { |