summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoshua stein <jcs@cvs.openbsd.org>2008-05-29 18:24:52 +0000
committerjoshua stein <jcs@cvs.openbsd.org>2008-05-29 18:24:52 +0000
commitc53337066e0c7500e866082618777bfff826f452 (patch)
tree68d094e3bb6a4bb010df07d5dd45198c8544887d
parent611010a80cee3438f04812bc6c10183f109214c9 (diff)
dlg backed out one too many revisions, bring back 1.2
only do aml_freevalue when necessary, noted by deanna
-rw-r--r--sys/dev/acpi/acpithinkpad.c72
1 files changed, 60 insertions, 12 deletions
diff --git a/sys/dev/acpi/acpithinkpad.c b/sys/dev/acpi/acpithinkpad.c
index 37d7a087a42..180a1d49601 100644
--- a/sys/dev/acpi/acpithinkpad.c
+++ b/sys/dev/acpi/acpithinkpad.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpithinkpad.c,v 1.4 2008/05/16 06:50:55 dlg Exp $ */
+/* $OpenBSD: acpithinkpad.c,v 1.5 2008/05/29 18:24:51 jcs Exp $ */
/*
* Copyright (c) 2008 joshua stein <jcs@openbsd.org>
@@ -27,6 +27,9 @@
#define THINKPAD_HKEY_VERSION 0x0100
+#define THINKPAD_CMOS_VOLUME_DOWN 0x00
+#define THINKPAD_CMOS_VOLUME_UP 0x01
+#define THINKPAD_CMOS_VOLUME_MUTE 0x02
#define THINKPAD_CMOS_BRIGHTNESS_UP 0x04
#define THINKPAD_CMOS_BRIGHTNESS_DOWN 0x05
@@ -51,6 +54,9 @@
#define THINKPAD_BUTTON_BRIGHTNESS_DOWN 0x011
#define THINKPAD_BUTTON_THINKLIGHT 0x012
#define THINKPAD_BUTTON_FN_SPACE 0x014
+#define THINKPAD_BUTTON_VOLUME_UP 0x015
+#define THINKPAD_BUTTON_VOLUME_DOWN 0x016
+#define THINKPAD_BUTTON_VOLUME_MUTE 0x017
#define THINKPAD_BUTTON_THINKVANTAGE 0x018
#define THINKPAD_BUTTON_FN_F11 0x00b
#define THINKPAD_BUTTON_HIBERNATE 0x00c
@@ -63,6 +69,9 @@
#define THINKPAD_TABLET_PEN_INSERTED 0x00b
#define THINKPAD_TABLET_PEN_REMOVED 0x00c
+/* type 7 events */
+#define THINKPAD_SWITCH_WIRELESS 0x000
+
struct acpithinkpad_softc {
struct device sc_dev;
@@ -77,6 +86,9 @@ int thinkpad_enable_events(struct acpithinkpad_softc *);
int thinkpad_toggle_bluetooth(struct acpithinkpad_softc *);
int thinkpad_toggle_wan(struct acpithinkpad_softc *);
int thinkpad_cmos(struct acpithinkpad_softc *sc, uint8_t);
+int thinkpad_volume_down(struct acpithinkpad_softc *);
+int thinkpad_volume_up(struct acpithinkpad_softc *);
+int thinkpad_volume_mute(struct acpithinkpad_softc *);
int thinkpad_brightness_up(struct acpithinkpad_softc *);
int thinkpad_brightness_down(struct acpithinkpad_softc *);
@@ -107,6 +119,7 @@ thinkpad_match(struct device *parent, void *match, void *aux)
if (aml_val2int(&res) != THINKPAD_HKEY_VERSION)
goto fail;
+ aml_freevalue(&res);
return (1);
fail:
@@ -118,7 +131,7 @@ void
thinkpad_attach(struct device *parent, struct device *self, void *aux)
{
struct acpithinkpad_softc *sc = (struct acpithinkpad_softc *)self;
- struct acpi_attach_args *aa = aux;
+ struct acpi_attach_args *aa = aux;
sc->sc_acpi = (struct acpi_softc *)parent;
sc->sc_devnode = aa->aaa_node->child;
@@ -145,10 +158,10 @@ thinkpad_enable_events(struct acpithinkpad_softc *sc)
/* get the supported event mask */
if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "MHKA", 0, NULL, &res)) {
printf("%s: no MHKA\n", DEVNAME(sc));
- aml_freevalue(&res);
return (1);
}
mask = aml_val2int(&res);
+ aml_freevalue(&res);
/* update hotkey mask */
memset(&args, 0, sizeof(args));
@@ -185,12 +198,11 @@ thinkpad_hotkey(struct aml_node *node, int notify_type, void *arg)
for (;;) {
if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "MHKP", 0, NULL,
- &res)) {
- aml_freevalue(&res);
+ &res))
return (1);
- }
val = aml_val2int(&res);
+ aml_freevalue(&res);
if (val == 0)
return (1);
@@ -230,9 +242,22 @@ thinkpad_hotkey(struct aml_node *node, int notify_type, void *arg)
case THINKPAD_BUTTON_EJECT:
case THINKPAD_BUTTON_THINKLIGHT:
case THINKPAD_BUTTON_FN_SPACE:
+ handled = 1;
+ break;
+ case THINKPAD_BUTTON_VOLUME_DOWN:
+ thinkpad_volume_down(sc);
+ handled = 1;
+ break;
+ case THINKPAD_BUTTON_VOLUME_UP:
+ thinkpad_volume_up(sc);
+ handled = 1;
+ break;
+ case THINKPAD_BUTTON_VOLUME_MUTE:
+ thinkpad_volume_mute(sc);
+ handled = 1;
+ break;
case THINKPAD_BUTTON_THINKVANTAGE:
case THINKPAD_BUTTON_FN_F11:
- /* TODO: notify userland */
handled = 1;
break;
}
@@ -246,12 +271,19 @@ thinkpad_hotkey(struct aml_node *node, int notify_type, void *arg)
case THINKPAD_LID_CLOSED:
case THINKPAD_TABLET_PEN_INSERTED:
case THINKPAD_TABLET_PEN_REMOVED:
- /* TODO: notify userland */
handled = 1;
break;
}
break;
+ case 7:
+ switch (event) {
+ case THINKPAD_SWITCH_WIRELESS:
+ handled = 1;
+
+ break;
+ }
+ break;
}
if (!handled)
@@ -268,12 +300,12 @@ thinkpad_toggle_bluetooth(struct acpithinkpad_softc *sc)
if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "GBDC", 0, NULL, &res)) {
/* no bluetooth, oh well */
- aml_freevalue(&res);
return (1);
}
bluetooth = aml_val2int(&res);
aml_freevalue(&res);
+
if (!(bluetooth & THINKPAD_BLUETOOTH_PRESENT))
return (1);
@@ -294,10 +326,8 @@ thinkpad_toggle_wan(struct acpithinkpad_softc *sc)
struct aml_value res, arg;
int wan;
- if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "GWAN", 0, NULL, &res)) {
- aml_freevalue(&res);
+ if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "GWAN", 0, NULL, &res))
return (1);
- }
wan = aml_val2int(&res);
aml_freevalue(&res);
@@ -334,6 +364,24 @@ thinkpad_cmos(struct acpithinkpad_softc *sc, uint8_t cmd)
}
int
+thinkpad_volume_down(struct acpithinkpad_softc *sc)
+{
+ return thinkpad_cmos(sc, THINKPAD_CMOS_VOLUME_DOWN);
+}
+
+int
+thinkpad_volume_up(struct acpithinkpad_softc *sc)
+{
+ return thinkpad_cmos(sc, THINKPAD_CMOS_VOLUME_UP);
+}
+
+int
+thinkpad_volume_mute(struct acpithinkpad_softc *sc)
+{
+ return thinkpad_cmos(sc, THINKPAD_CMOS_VOLUME_MUTE);
+}
+
+int
thinkpad_brightness_up(struct acpithinkpad_softc *sc)
{
return thinkpad_cmos(sc, THINKPAD_CMOS_BRIGHTNESS_UP);