summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2011-01-04 23:08:57 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2011-01-04 23:08:57 +0000
commitef8edffe9d292eb00c2ab3e2c9d768e2fd79b06e (patch)
tree42646f9fc4eb1b7cc4f06648d2547d2a6812dd58 /sys/dev
parent3f808e58f9b1e56a31e679de60386c10cefbe115 (diff)
Support machdep.lidsuspend support in apm(4) land, at least on thinkpads
which have aps(4). You can now turn off the BIOS option for lid suspends, and control it with sysctl.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/isa/aps.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/dev/isa/aps.c b/sys/dev/isa/aps.c
index c3b7c00625d..edc55fd6992 100644
--- a/sys/dev/isa/aps.c
+++ b/sys/dev/isa/aps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aps.c,v 1.21 2010/09/07 16:21:43 deraadt Exp $ */
+/* $OpenBSD: aps.c,v 1.22 2011/01/04 23:08:55 deraadt Exp $ */
/*
* Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2008 Can Erkin Acar <canacar@openbsd.org>
@@ -28,10 +28,18 @@
#include <sys/sensors.h>
#include <sys/timeout.h>
#include <machine/bus.h>
+#include <sys/event.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
+#ifdef __i386__
+#include "apm.h"
+#include <machine/acpiapm.h>
+#include <machine/biosvar.h>
+#include <machine/apmvar.h>
+#endif
+
#if defined(APSDEBUG)
#define DPRINTF(x) do { printf x; } while (0)
#else
@@ -439,6 +447,10 @@ aps_refresh_sensor_data(struct aps_softc *sc)
{
int64_t temp;
int i;
+#if NAPM > 0
+ extern int lid_suspend;
+ extern int apm_lidclose;
+#endif
if (aps_read_data(sc))
return;
@@ -468,6 +480,15 @@ aps_refresh_sensor_data(struct aps_softc *sc)
(sc->aps_data.input & APS_INPUT_KB) ? 1 : 0;
sc->sensors[APS_SENSOR_MSACT].value =
(sc->aps_data.input & APS_INPUT_MS) ? 1 : 0;
+#if NAPM > 0
+ if (lid_suspend &&
+ (sc->sensors[APS_SENSOR_LIDOPEN].value == 1) &&
+ (sc->aps_data.input & APS_INPUT_LIDOPEN) == 0) {
+ /* Inform APM that the lid has closed */
+ printf("lid close\n");
+ apm_lidclose = 1;
+ }
+#endif
sc->sensors[APS_SENSOR_LIDOPEN].value =
(sc->aps_data.input & APS_INPUT_LIDOPEN) ? 1 : 0;
}