Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add WMI mappings for HP laptops. Requested by cegger@.
details: https://anonhg.NetBSD.org/src/rev/416a79e04f1c
branches: trunk
changeset: 753740:416a79e04f1c
user: jruoho <jruoho%NetBSD.org@localhost>
date: Thu Apr 08 17:32:30 2010 +0000
description:
Add WMI mappings for HP laptops. Requested by cegger@.
Thanks to apb@ and cegger@ for initial testing.
XXX: This conflicts with hpqlb(4). Someone with the suitable hardware needs
to complete the list of hotkeys before -- and if -- this can replace
hpqlb(4). For now, the driver was left uncommented in the GENERICs.
diffstat:
sys/arch/amd64/conf/GENERIC | 5 +-
sys/arch/i386/conf/GENERIC | 5 +-
sys/dev/acpi/wmi/files.wmi | 7 +-
sys/dev/acpi/wmi/wmi_hp.c | 528 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 540 insertions(+), 5 deletions(-)
diffs (truncated from 602 to 300 lines):
diff -r f4f0bcac977a -r 416a79e04f1c sys/arch/amd64/conf/GENERIC
--- a/sys/arch/amd64/conf/GENERIC Thu Apr 08 16:49:34 2010 +0000
+++ b/sys/arch/amd64/conf/GENERIC Thu Apr 08 17:32:30 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.273 2010/04/08 09:45:17 jruoho Exp $
+# $NetBSD: GENERIC,v 1.274 2010/04/08 17:32:30 jruoho Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.273 $"
+#ident "GENERIC-$Revision: 1.274 $"
maxusers 64 # estimated number of users
@@ -305,6 +305,7 @@
wb* at acpi? # Winbond W83L518D SD/MMC reader
sdmmc* at wb? # SD/MMC bus
wmidell* at acpiwmibus? # Dell WMI mappings
+#wmihp* at acpiwmibus? # HP WMI mappings
#apm0 at mainbus0 # Advanced power management
diff -r f4f0bcac977a -r 416a79e04f1c sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC Thu Apr 08 16:49:34 2010 +0000
+++ b/sys/arch/i386/conf/GENERIC Thu Apr 08 17:32:30 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.976 2010/04/08 09:45:17 jruoho Exp $
+# $NetBSD: GENERIC,v 1.977 2010/04/08 17:32:30 jruoho Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.976 $"
+#ident "GENERIC-$Revision: 1.977 $"
maxusers 64 # estimated number of users
@@ -381,6 +381,7 @@
wb* at acpi? # Winbond W83L518D SD/MMC reader
sdmmc* at wb? # SD/MMC bus
wmidell* at acpiwmibus? # Dell WMI mappings
+#wmihp* at acpiwmibus? # HP WMI mappings
wss* at acpi? # NeoMagic 256AV in wss mode
ym* at acpi? # Yamaha OPL3-SA[23] audio
diff -r f4f0bcac977a -r 416a79e04f1c sys/dev/acpi/wmi/files.wmi
--- a/sys/dev/acpi/wmi/files.wmi Thu Apr 08 16:49:34 2010 +0000
+++ b/sys/dev/acpi/wmi/files.wmi Thu Apr 08 17:32:30 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.wmi,v 1.2 2010/04/08 12:14:19 jruoho Exp $
+# $NetBSD: files.wmi,v 1.3 2010/04/08 17:32:30 jruoho Exp $
define acpiwmibus { }
@@ -11,3 +11,8 @@
device wmidell: sysmon_power
attach wmidell at acpiwmibus
file dev/acpi/wmi/wmi_dell.c wmidell
+
+# HP WMI mappings
+device wmihp: sysmon_envsys
+attach wmihp at acpiwmibus
+file dev/acpi/wmi/wmi_hp.c wmihp
diff -r f4f0bcac977a -r 416a79e04f1c sys/dev/acpi/wmi/wmi_hp.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/acpi/wmi/wmi_hp.c Thu Apr 08 17:32:30 2010 +0000
@@ -0,0 +1,528 @@
+/* $NetBSD: wmi_hp.c,v 1.1 2010/04/08 17:32:30 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 2009 Michael Gmelin <freebsd%grem.de@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1.1 2010/04/08 17:32:30 jruoho Exp $");
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/kmem.h>
+
+#include <dev/acpi/acpireg.h>
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/wmi/wmi_acpivar.h>
+
+#include <dev/sysmon/sysmonvar.h>
+
+#define _COMPONENT ACPI_RESOURCE_COMPONENT
+ACPI_MODULE_NAME ("wmi_hp")
+
+#define WMI_HP_METHOD_ARG_READ 0x01
+#define WMI_HP_METHOD_ARG_WRITE 0x02
+#define WMI_HP_METHOD_ARG_WRITE_SIZE 0x04
+#define WMI_HP_METHOD_ARG_MAGIC 0x55434553
+#define WMI_HP_METHOD_ARG_SIZE 0x05 * sizeof(uint32_t)
+
+#define WMI_HP_METHOD_CMD_DISPLAY 0x01
+#define WMI_HP_METHOD_CMD_HDDTEMP 0x02
+#define WMI_HP_METHOD_CMD_ALS 0x03
+#define WMI_HP_METHOD_CMD_DOCK 0x04
+#define WMI_HP_METHOD_CMD_SWITCH 0x05
+#define WMI_HP_METHOD_CMD_HOTKEY 0x0C
+
+#define WMI_HP_EVENT_DOCK 0x01
+#define WMI_HP_EVENT_HOTKEY 0x04
+#define WMI_HP_EVENT_SWITCH 0x05
+/* WMI_HP_EVENT_UNKNOWN 0xXX */
+
+#define WMI_HP_HOTKEY_BRIGHTNESS_UP 0x02
+#define WMI_HP_HOTKEY_BRIGHTNESS_DOWN 0x03
+/* WMI_HP_HOTKEY_UNKNOWN 0xXX */
+
+#define WMI_HP_SWITCH_WLAN 0x01
+#define WMI_HP_SWITCH_BT 0x02
+#define WMI_HP_SWITCH_WWAN 0x04
+
+#define WMI_HP_SWITCH_ARG_WLAN_OFF 0x100
+#define WMI_HP_SWITCH_ARG_WLAN_ON 0x101
+#define WMI_HP_SWITCH_ARG_BT_OFF 0x200
+#define WMI_HP_SWITCH_ARG_BT_ON 0x202
+#define WMI_HP_SWITCH_ARG_WWAN_OFF 0x400
+#define WMI_HP_SWITCH_ARG_WWAN_ON 0x404
+
+#define WMI_HP_SWITCH_MASK_WLAN_ONAIR __BIT(8)
+#define WMI_HP_SWITCH_MASK_WLAN_ENABLED __BIT(9)
+#define WMI_HP_SWITCH_MASK_WLAN_RADIO __BIT(11)
+#define WMI_HP_SWITCH_MASK_BT_ONAIR __BIT(16)
+#define WMI_HP_SWITCH_MASK_BT_ENABLED __BIT(17)
+#define WMI_HP_SWITCH_MASK_BT_RADIO __BIT(19)
+#define WMI_HP_SWITCH_MASK_WWAN_ONAIR __BIT(24)
+#define WMI_HP_SWITCH_MASK_WWAN_ENABLED __BIT(25)
+#define WMI_HP_SWITCH_MASK_WWAN_RADIO __BIT(27)
+
+#define WMI_HP_GUID_EVENT "95F24279-4D7B-4334-9387-ACCDC67EF61C"
+#define WMI_HP_GUID_METHOD "5FB7F034-2C63-45E9-BE91-3D44E2C707E4"
+
+#define WMI_HP_SENSOR_WLAN 0
+#define WMI_HP_SENSOR_BT 1
+#define WMI_HP_SENSOR_WWAN 2
+#define WMI_HP_SENSOR_COUNT 3
+#define WMI_HP_SENSOR_SIZE 3 * sizeof(envsys_data_t)
+
+struct wmi_hp_softc {
+ device_t sc_dev;
+ device_t sc_parent;
+ struct sysmon_envsys *sc_sme;
+ envsys_data_t *sc_sensor;
+ uint32_t *sc_arg;
+ uint32_t sc_val;
+};
+
+static int wmi_hp_match(device_t, cfdata_t, void *);
+static void wmi_hp_attach(device_t, device_t, void *);
+static int wmi_hp_detach(device_t, int);
+static bool wmi_hp_suspend(device_t, const pmf_qual_t *);
+static bool wmi_hp_resume(device_t, const pmf_qual_t *);
+static void wmi_hp_notify_handler(ACPI_HANDLE, uint32_t, void *);
+static void wmi_hp_hotkey(void *);
+static bool wmi_hp_method(struct wmi_hp_softc *);
+static bool wmi_hp_method_read(struct wmi_hp_softc *, uint8_t);
+
+#if 0
+static bool wmi_hp_method_write(struct wmi_hp_softc *, uint8_t, uint32_t);
+#endif
+
+static void wmi_hp_sensor_init(struct wmi_hp_softc *);
+static void wmi_hp_sensor_update(void *);
+
+CFATTACH_DECL_NEW(wmihp, sizeof(struct wmi_hp_softc),
+ wmi_hp_match, wmi_hp_attach, wmi_hp_detach, NULL);
+
+static int
+wmi_hp_match(device_t parent, cfdata_t match, void *aux)
+{
+ return acpi_wmi_guid_match(parent, WMI_HP_GUID_METHOD);
+}
+
+static void
+wmi_hp_attach(device_t parent, device_t self, void *aux)
+{
+ struct wmi_hp_softc *sc = device_private(self);
+ ACPI_STATUS rv = AE_ERROR;
+
+ sc->sc_dev = self;
+ sc->sc_parent = parent;
+
+ sc->sc_sme = NULL;
+ sc->sc_sensor = NULL;
+
+ sc->sc_arg = kmem_alloc(WMI_HP_METHOD_ARG_SIZE, KM_SLEEP);
+
+ if (sc->sc_arg == NULL)
+ return;
+
+ aprint_naive("\n");
+ aprint_normal(": HP WMI mappings\n");
+
+ (void)pmf_device_register(sc->sc_dev, wmi_hp_suspend, wmi_hp_resume);
+
+ if (acpi_wmi_guid_match(parent, WMI_HP_GUID_EVENT) != 0)
+ rv = acpi_wmi_event_register(parent, wmi_hp_notify_handler);
+
+ if (ACPI_FAILURE(rv))
+ return;
+
+ sc->sc_sensor = kmem_alloc(WMI_HP_SENSOR_SIZE, KM_SLEEP);
+
+ if (sc->sc_sensor == NULL)
+ return;
+
+ wmi_hp_sensor_init(sc);
+}
+
+static int
+wmi_hp_detach(device_t self, int flags)
+{
+ struct wmi_hp_softc *sc = device_private(self);
+ device_t parent = sc->sc_parent;
+
+ (void)acpi_wmi_event_deregister(parent);
+
+ if (sc->sc_sme != NULL)
+ sysmon_envsys_unregister(sc->sc_sme);
+
+ if (sc->sc_sensor != NULL)
+ kmem_free(sc->sc_sensor, WMI_HP_SENSOR_SIZE);
+
+ if (sc->sc_arg != NULL)
+ kmem_free(sc->sc_arg, WMI_HP_METHOD_ARG_SIZE);
+
+ pmf_device_deregister(self);
+
+ return 0;
+}
+
+static bool
+wmi_hp_suspend(device_t self, const pmf_qual_t *qual)
+{
+ struct wmi_hp_softc *sc = device_private(self);
+ device_t parent = sc->sc_parent;
+
+ if (sc->sc_sensor != NULL)
Home |
Main Index |
Thread Index |
Old Index