diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2011-01-04 23:08:57 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2011-01-04 23:08:57 +0000 |
commit | ef8edffe9d292eb00c2ab3e2c9d768e2fd79b06e (patch) | |
tree | 42646f9fc4eb1b7cc4f06648d2547d2a6812dd58 /sys | |
parent | 3f808e58f9b1e56a31e679de60386c10cefbe115 (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')
-rw-r--r-- | sys/arch/i386/i386/apm.c | 9 | ||||
-rw-r--r-- | sys/dev/isa/aps.c | 23 |
2 files changed, 30 insertions, 2 deletions
diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c index 2499dc6a556..fc6084fa87c 100644 --- a/sys/arch/i386/i386/apm.c +++ b/sys/arch/i386/i386/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.94 2010/09/09 04:13:15 deraadt Exp $ */ +/* $OpenBSD: apm.c,v 1.95 2011/01/04 23:08:56 deraadt Exp $ */ /*- * Copyright (c) 1998-2001 Michael Shalayeff. All rights reserved. @@ -133,6 +133,7 @@ int cpu_apmwarn = 10; #define APMDEV_CTL 8 int apm_standbys; +int apm_lidclose; int apm_userstandbys; int apm_suspends; int apm_resumes; @@ -531,6 +532,12 @@ apm_periodic_check(struct apm_softc *sc) if (apm_error || APM_ERR_CODE(®s) == APM_ERR_NOTCONN) ret = -1; + if (apm_lidclose) { + apm_lidclose = 0; + /* Fake a suspend request */ + regs.bx = APM_SUSPEND_REQ; + apm_handle_event(sc, ®s); + } if (apm_suspends /*|| (apm_battlow && apm_userstandbys)*/) { apm_op_inprog = 0; apm_suspend(APM_SYS_SUSPEND); 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; } |