summaryrefslogtreecommitdiff
path: root/sys/dev/acpi/acpibtn.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2010-03-31 19:21:20 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2010-03-31 19:21:20 +0000
commit86522847c512d0f481c13afd50a8e1884a8551fa (patch)
tree384c18bf228bf1183eadb20ed60c3d2dacde33fb /sys/dev/acpi/acpibtn.c
parent03e578ef63dc46b1899f59c7405261b7e16e76bd (diff)
Bring /dev/apm support in line with apm(4). Make the suspend button send
a suspend request event to apmd(8) instead of suspending immediately. Also keep track of whether /dev/apm and /dev/apmctl are currently open, such that we can still suspend immediately if apmd(8) isn't running. ok deraadt@, marco@, pirofti@, jsing@, oga@
Diffstat (limited to 'sys/dev/acpi/acpibtn.c')
-rw-r--r--sys/dev/acpi/acpibtn.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c
index 09643d620c3..548dd3c800d 100644
--- a/sys/dev/acpi/acpibtn.c
+++ b/sys/dev/acpi/acpibtn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpibtn.c,v 1.25 2009/12/05 04:20:58 deraadt Exp $ */
+/* $OpenBSD: acpibtn.c,v 1.26 2010/03/31 19:21:19 kettenis Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -23,6 +23,7 @@
#include <sys/malloc.h>
#include <machine/bus.h>
+#include <machine/apmvar.h>
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
@@ -135,8 +136,10 @@ acpibtn_notify(struct aml_node *node, int notify_type, void *arg)
"_LID", 0, NULL, &lid))
return (0);
#if 0
- if (lid == 0)
- acpi_sleep_state(sc->sc_acpi, ACPI_STATE_S3);
+ if (lid == 0) {
+ if (acpi_record_event(sc->sc_acpi, APM_USER_SUSPEND_REQ))
+ acpi_sleep_state(sc->sc_acpi, ACPI_STATE_S3);
+ }
#endif
break;
#endif /* SMALL_KERNEL */
@@ -148,7 +151,8 @@ acpibtn_notify(struct aml_node *node, int notify_type, void *arg)
break;
case 0x80:
/* Request to go to sleep */
- acpi_sleep_state(sc->sc_acpi, ACPI_STATE_S3);
+ if (acpi_record_event(sc->sc_acpi, APM_USER_SUSPEND_REQ))
+ acpi_sleep_state(sc->sc_acpi, ACPI_STATE_S3);
break;
}
#endif /* SMALL_KERNEL */