CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: bouyer Date: Wed Dec 4 19:51:32 UTC 2019 Modified Files: src/sys/dev/acpi/wmi: wmi_dell.c Log Message: Finally fix problem discussed in this old thread: http://mail-index.netbsd.org/tech-kern/2017/12/03/msg022661.html Dell's radio hotkey sends a PMFE_RADIO_TOGGLE event, but nothing actually listen to it. Turn it into a PSWITCH_HK_WIRELESS_BUTTON hotkey, similar to what thinkpad_acpi.c does. Add type/subtypes seen on a Dell lattitude 5480 laptop. XXX we need a PMFE_AUDIO_MICRO_TOGGLE, and something to handle it. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/acpi/wmi/wmi_dell.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_dell.c diff -u src/sys/dev/acpi/wmi/wmi_dell.c:1.11 src/sys/dev/acpi/wmi/wmi_dell.c:1.12 --- src/sys/dev/acpi/wmi/wmi_dell.c:1.11 Sun Dec 3 23:43:00 2017 +++ src/sys/dev/acpi/wmi/wmi_dell.c Wed Dec 4 19:51:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_dell.c,v 1.11 2017/12/03 23:43:00 christos Exp $ */ +/* $NetBSD: wmi_dell.c,v 1.12 2019/12/04 19:51:32 bouyer Exp $ */ /*- * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.11 2017/12/03 23:43:00 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.12 2019/12/04 19:51:32 bouyer Exp $"); #include #include @@ -53,7 +53,8 @@ __KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v ACPI_MODULE_NAME ("wmi_dell") #define WMI_DELL_PSW_DISPLAY_CYCLE 0 -#define WMI_DELL_PSW_COUNT 1 +#define WMI_DELL_PSW_RADIO_TOGGLE 1 +#define WMI_DELL_PSW_COUNT 2 #define WMI_DELL_GUID_EVENT "9DBB5994-A997-11DA-B012-B622A1EF5492" #define WMI_DELL_GUID_DESC "8D9DDCBC-A997-11DA-B012-B622A1EF5492" @@ -82,7 +83,7 @@ const struct wmi_dell_actions { {WMI_DELLA_PMF, 0x, 0xe006, PMFE_DISPLAY_BRIGHTNESS_UP}, {WMI_DELLA_PSW, 0x, 0xe00b, WMI_DELL_PSW_DISPLAY_CYCLE}, - {WMI_DELLA_PMF, 0x, 0xe008, PMFE_RADIO_TOGGLE}, + {WMI_DELLA_PSW, 0x, 0xe008, WMI_DELL_PSW_RADIO_TOGGLE}, {WMI_DELLA_IGN, 0x, 0xe00c, 0}, /* keyboard illumination */ /* volume control */ @@ -96,14 +97,16 @@ const struct wmi_dell_actions { /* type 0x10 */ {WMI_DELLA_PMF, 0x0010, 0x0057, PMFE_DISPLAY_BRIGHTNESS_DOWN}, {WMI_DELLA_PMF, 0x0010, 0x0058, PMFE_DISPLAY_BRIGHTNESS_UP}, + {WMI_DELLA_IGN, 0x0010, 0x0150, 0}, /* XXX microphone toggle */ {WMI_DELLA_IGN, 0x0010, 0x0151, 0}, /* Fn-lock */ {WMI_DELLA_IGN, 0x0010, 0x0152, 0}, /* keyboard illumination */ - {WMI_DELLA_PMF, 0x0010, 0x0153, PMFE_RADIO_TOGGLE}, + {WMI_DELLA_PSW, 0x0010, 0x0153, WMI_DELL_PSW_RADIO_TOGGLE}, {WMI_DELLA_IGN, 0x0010, 0x0155, 0}, /* Stealth mode toggle */ + {WMI_DELLA_PSW, 0x0010, 0xE008, WMI_DELL_PSW_RADIO_TOGGLE}, {WMI_DELLA_IGN, 0x0010, 0xE035, 0}, /* Fn-lock */ /* type 0x11 */ - {WMI_DELLA_IGN, 0x0011, 0x02eb5, 0}, /* keyboard illumination */ + {WMI_DELLA_IGN, 0x0011, 0x02eb, 0}, /* keyboard illumination */ }; static int wmi_dell_match(device_t, cfdata_t, void *); @@ -182,9 +185,23 @@ wmi_dell_attach(device_t parent, device_ e = sysmon_pswitch_register(&sc->sc_smpsw[WMI_DELL_PSW_DISPLAY_CYCLE]); + if (e != 0) { + sc->sc_smpsw_valid = false; + goto end; + } + + sc->sc_smpsw[WMI_DELL_PSW_RADIO_TOGGLE].smpsw_name = + PSWITCH_HK_WIRELESS_BUTTON; + + sc->sc_smpsw[WMI_DELL_PSW_RADIO_TOGGLE].smpsw_type = + PSWITCH_TYPE_HOTKEY; + + e = sysmon_pswitch_register(&sc->sc_smpsw[WMI_DELL_PSW_RADIO_TOGGLE]); + if (e != 0) sc->sc_smpsw_valid = false; +end: (void)pmf_device_register(self, wmi_dell_suspend, wmi_dell_resume); }
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: christos Date: Sun Dec 3 23:43:00 UTC 2017 Modified Files: src/sys/dev/acpi/wmi: wmi_dell.c Log Message: make this compile again and: - remove extra space - use alternate form %x printing - use aprint_debug_dev instead of printf To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/acpi/wmi/wmi_dell.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_dell.c diff -u src/sys/dev/acpi/wmi/wmi_dell.c:1.10 src/sys/dev/acpi/wmi/wmi_dell.c:1.11 --- src/sys/dev/acpi/wmi/wmi_dell.c:1.10 Sun Dec 3 12:40:48 2017 +++ src/sys/dev/acpi/wmi/wmi_dell.c Sun Dec 3 18:43:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_dell.c,v 1.10 2017/12/03 17:40:48 bouyer Exp $ */ +/* $NetBSD: wmi_dell.c,v 1.11 2017/12/03 23:43:00 christos Exp $ */ /*- * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.10 2017/12/03 17:40:48 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.11 2017/12/03 23:43:00 christos Exp $"); #include #include @@ -164,8 +164,10 @@ wmi_dell_attach(device_t parent, device_ } } data = (uint32_t *)obj->Buffer.Pointer; - if (data[0] != 0x4C4C4544 || data[1] != 0x494D5720) { - aprint_error(": wrong WMI descriptor signature 0x%x 0x%x", +#define WMI_LLED 0x4C4C4544 +#define WMI_IMWsp 0x494D5720 + if (data[0] != WMI_LLED || data[1] != WMI_IMWsp) { + aprint_error(": wrong WMI descriptor signature %#x %#x", data[0], data[1]); } sc->sc_version = data[2]; @@ -230,7 +232,7 @@ wmi_dell_resume(device_t self, const pmf static void wmi_dell_action(struct wmi_dell_softc *sc, uint16_t *data, int len) { - int i; + size_t i; for (i = 0; i < __arraycount(wmi_dell_actions); i++) { const struct wmi_dell_actions *wda = &wmi_dell_actions[i]; if (wda->wda_type == data[0] && @@ -240,27 +242,25 @@ wmi_dell_action(struct wmi_dell_softc *s DPRINTF((" ignored")); return; case WMI_DELLA_PMF: -DPRINTF((" pmf %d", -wda->wda_data)); -pmf_event_inject(NULL, -wda->wda_data); +DPRINTF((" pmf %d", wda->wda_data)); +pmf_event_inject(NULL, wda->wda_data); return; case WMI_DELLA_PSW: -DPRINTF((" psw %d", -wda->wda_data)); +DPRINTF((" psw %d", wda->wda_data)); sysmon_pswitch_event( &sc->sc_smpsw[wda->wda_data], PSWITCH_EVENT_PRESSED); return; default: -printf("unknown dell wmi action %d\n", +aprint_debug_dev(sc->sc_dev, +"unknown dell wmi action %d\n", wda->wda_action); return; } } } - aprint_debug_dev(sc->sc_dev, "unkown event 0x%4X 0x%4X\n", + aprint_debug_dev(sc->sc_dev, "unknown event %#4X %#4X\n", data[0], data[1]); } @@ -312,7 +312,7 @@ wmi_dell_notify_handler(ACPI_HANDLE hdl, continue; } for (i = 1; i < len; i++) - DPRINTF((" 0x%04X", data[i])); + DPRINTF((" %#04X", data[i])); wmi_dell_action(sc, &data[1], len - 1); DPRINTF(("\n")); data = &data[len]; @@ -332,7 +332,7 @@ out: if (ACPI_FAILURE(rv)) aprint_error_dev(sc->sc_dev, "failed to get data for " - "event 0x%02X: %s\n", evt, AcpiFormatException(rv)); + "event %#02X: %s\n", evt, AcpiFormatException(rv)); } MODULE(MODULE_CLASS_DRIVER, wmidell, "acpiwmi,sysmon_power"); @@ -347,9 +347,7 @@ wmidell_modcmd(modcmd_t cmd, void *aux) int rv = 0; switch (cmd) { - case MODULE_CMD_INIT: - #ifdef _MODULE rv = config_init_component(cfdriver_ioconf_wmidell, cfattach_ioconf_wmidell, cfdata_ioconf_wmidell); @@ -357,7 +355,6 @@ wmidell_modcmd(modcmd_t cmd, void *aux) break; case MODULE_CMD_FINI: - #ifdef _MODULE rv = config_fini_component(cfdriver_ioconf_wmidell, cfattach_ioconf_wmidell, cfdata_ioconf_wmidell);
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: bouyer Date: Sun Dec 3 17:40:48 UTC 2017 Modified Files: src/sys/dev/acpi/wmi: wmi_dell.c Log Message: Fix dell WMI mappings: - query the descriptor to get the interface version, needed to workaround a bug in the BIOS/ACPI - properly decode the event buffer in type/subtype, and handle multiple events per handler call - record some known type/subtype in a table, with associated actions. Informations mostly from linux. Tested on a Dell 5480 laptop. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/acpi/wmi/wmi_dell.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_dell.c diff -u src/sys/dev/acpi/wmi/wmi_dell.c:1.9 src/sys/dev/acpi/wmi/wmi_dell.c:1.10 --- src/sys/dev/acpi/wmi/wmi_dell.c:1.9 Thu Apr 23 23:23:00 2015 +++ src/sys/dev/acpi/wmi/wmi_dell.c Sun Dec 3 17:40:48 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_dell.c,v 1.9 2015/04/23 23:23:00 pgoyette Exp $ */ +/* $NetBSD: wmi_dell.c,v 1.10 2017/12/03 17:40:48 bouyer Exp $ */ /*- * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.9 2015/04/23 23:23:00 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.10 2017/12/03 17:40:48 bouyer Exp $"); #include #include @@ -43,29 +43,69 @@ __KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v #include +#ifdef WMI_DEBUG +#define DPRINTF(x) printf x +#else +#define DPRINTF(x) +#endif + #define _COMPONENT ACPI_RESOURCE_COMPONENT ACPI_MODULE_NAME ("wmi_dell") -#define WMI_DELL_HOTKEY_BRIGHTNESS_DOWN 0xE005 -#define WMI_DELL_HOTKEY_BRIGHTNESS_UP 0xE006 -#define WMI_DELL_HOTKEY_DISPLAY_CYCLE 0xE00B -#define WMI_DELL_HOTKEY_VOLUME_MUTE 0xE020 -#define WMI_DELL_HOTKEY_VOLUME_DOWN 0xE02E -#define WMI_DELL_HOTKEY_VOLUME_UP 0xE030 -/* WMI_DELL_HOTKEY_UNKNOWN 0x */ - #define WMI_DELL_PSW_DISPLAY_CYCLE 0 #define WMI_DELL_PSW_COUNT 1 #define WMI_DELL_GUID_EVENT "9DBB5994-A997-11DA-B012-B622A1EF5492" +#define WMI_DELL_GUID_DESC "8D9DDCBC-A997-11DA-B012-B622A1EF5492" struct wmi_dell_softc { device_t sc_dev; device_t sc_parent; + int sc_version; struct sysmon_pswitch sc_smpsw[WMI_DELL_PSW_COUNT]; bool sc_smpsw_valid; }; +#define WMI_DELLA_PMF 0x0 +#define WMI_DELLA_PSW 0x1 +#define WMI_DELLA_IGN 0x2 + +const struct wmi_dell_actions { + u_int wda_action; + u_int wda_type; + u_int wda_subtype; + u_int wda_data; +} wmi_dell_actions[] = { + /* type 0 */ + /* brightness control */ + {WMI_DELLA_PMF, 0x, 0xe005, PMFE_DISPLAY_BRIGHTNESS_DOWN}, + {WMI_DELLA_PMF, 0x, 0xe006, PMFE_DISPLAY_BRIGHTNESS_UP}, + {WMI_DELLA_PSW, 0x, 0xe00b, WMI_DELL_PSW_DISPLAY_CYCLE}, + + {WMI_DELLA_PMF, 0x, 0xe008, PMFE_RADIO_TOGGLE}, + {WMI_DELLA_IGN, 0x, 0xe00c, 0}, /* keyboard illumination */ + + /* volume control */ + {WMI_DELLA_PMF, 0x, 0xe020, PMFE_AUDIO_VOLUME_TOGGLE}, + {WMI_DELLA_PMF, 0x, 0xe02e, PMFE_AUDIO_VOLUME_DOWN}, + {WMI_DELLA_PMF, 0x, 0xe030, PMFE_AUDIO_VOLUME_UP}, + {WMI_DELLA_PMF, 0x, 0xe0f8, PMFE_AUDIO_VOLUME_DOWN}, + {WMI_DELLA_PMF, 0x, 0xe0f9, PMFE_AUDIO_VOLUME_UP}, + + + /* type 0x10 */ + {WMI_DELLA_PMF, 0x0010, 0x0057, PMFE_DISPLAY_BRIGHTNESS_DOWN}, + {WMI_DELLA_PMF, 0x0010, 0x0058, PMFE_DISPLAY_BRIGHTNESS_UP}, + {WMI_DELLA_IGN, 0x0010, 0x0151, 0}, /* Fn-lock */ + {WMI_DELLA_IGN, 0x0010, 0x0152, 0}, /* keyboard illumination */ + {WMI_DELLA_PMF, 0x0010, 0x0153, PMFE_RADIO_TOGGLE}, + {WMI_DELLA_IGN, 0x0010, 0x0155, 0}, /* Stealth mode toggle */ + {WMI_DELLA_IGN, 0x0010, 0xE035, 0}, /* Fn-lock */ + + /* type 0x11 */ + {WMI_DELLA_IGN, 0x0011, 0x02eb5, 0}, /* keyboard illumination */ +}; + static int wmi_dell_match(device_t, cfdata_t, void *); static void wmi_dell_attach(device_t, device_t, void *); static int wmi_dell_detach(device_t, int); @@ -87,6 +127,9 @@ wmi_dell_attach(device_t parent, device_ { struct wmi_dell_softc *sc = device_private(self); ACPI_STATUS rv; + ACPI_BUFFER obuf; + ACPI_OBJECT *obj; + uint32_t *data; int e; sc->sc_dev = self; @@ -100,8 +143,34 @@ wmi_dell_attach(device_t parent, device_ return; } + memset(&obuf, 0, sizeof(obuf)); + rv = acpi_wmi_data_query(parent, WMI_DELL_GUID_DESC, 0, &obuf); + if (ACPI_FAILURE(rv)) { + aprint_error(": failed to query WMI descriptor: %s\n", + AcpiFormatException(rv)); + return; + } + obj = obuf.Pointer; + if (obj->Type != ACPI_TYPE_BUFFER) { + aprint_error(": wrong type %d for WMI descriptor\n", obj->Type); + return; + } + if (obj->Buffer.Length != 128) { + aprint_error(": wrong len %d for WMI descriptor", + obj->Buffer.Length); + if (obj->Buffer.Length < 16) { + aprint_error("\n"); + return; + } + } + data = (uint32_t *)obj->Buffer.Pointer; + if (data[0] != 0x4C4C4544 || data[1] != 0x494D5720) { + aprint_error(": wrong WMI descriptor signature 0x%x 0x%x", + data[0], dat
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: bouyer Date: Sun Dec 3 17:34:51 UTC 2017 Modified Files: src/sys/dev/acpi/wmi: wmi_acpi.c Log Message: - make sure strtoul() is called with a NULL-terminated string. - acpi_wmi_input(): a valid data block may have flags set to 0. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/acpi/wmi/wmi_acpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_acpi.c diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.15 src/sys/dev/acpi/wmi/wmi_acpi.c:1.16 --- src/sys/dev/acpi/wmi/wmi_acpi.c:1.15 Thu Jun 1 02:45:09 2017 +++ src/sys/dev/acpi/wmi/wmi_acpi.c Sun Dec 3 17:34:50 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_acpi.c,v 1.15 2017/06/01 02:45:09 chs Exp $ */ +/* $NetBSD: wmi_acpi.c,v 1.16 2017/12/03 17:34:50 bouyer Exp $ */ /*- * Copyright (c) 2009, 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.15 2017/06/01 02:45:09 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.16 2017/12/03 17:34:50 bouyer Exp $"); #include #include @@ -323,7 +323,7 @@ acpi_wmi_guid_get(struct acpi_wmi_softc struct wmi_t *wmi; struct guid_t *guid; char bin[16]; - char hex[2]; + char hex[3]; const char *ptr; uint8_t i; @@ -336,6 +336,7 @@ acpi_wmi_guid_get(struct acpi_wmi_softc ptr++; (void)memcpy(hex, ptr, 2); + hex[2] = '\0'; if (HEXCHAR(hex[0]) == 0 || HEXCHAR(hex[1]) == 0) return AE_BAD_HEX_CONSTANT; @@ -613,8 +614,10 @@ acpi_wmi_enable_collection(ACPI_HANDLE h static bool acpi_wmi_input(struct wmi_t *wmi, uint8_t flag, uint8_t idx) { - - if ((wmi->guid.flags & flag) == 0) + /* A data block may have no flags at all */ + if ((wmi->guid.flags & flag) == 0 && + (flag == ACPI_WMI_FLAG_DATA && + (wmi->guid.flags & ~ACPI_WMI_FLAG_EXPENSIVE) != 0)) return false; if (wmi->guid.count == 0x00)
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: cegger Date: Fri Oct 12 13:02:30 UTC 2012 Modified Files: src/sys/dev/acpi/wmi: wmi_hp.c Log Message: Add support for various things: - hddtemp sensor - ambient light sensor on/off (via sysctl) - display info - docking station info To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/acpi/wmi/wmi_hp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_hp.c diff -u src/sys/dev/acpi/wmi/wmi_hp.c:1.6 src/sys/dev/acpi/wmi/wmi_hp.c:1.7 --- src/sys/dev/acpi/wmi/wmi_hp.c:1.6 Wed Feb 16 13:15:49 2011 +++ src/sys/dev/acpi/wmi/wmi_hp.c Fri Oct 12 13:02:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_hp.c,v 1.6 2011/02/16 13:15:49 jruoho Exp $ */ +/* $NetBSD: wmi_hp.c,v 1.7 2012/10/12 13:02:28 cegger Exp $ */ /*- * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1.6 2011/02/16 13:15:49 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1.7 2012/10/12 13:02:28 cegger Exp $"); #include #include @@ -70,6 +70,13 @@ __KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1 #include +#include + +/* + * HP CMI whitepaper: + * http://h20331.www2.hp.com/Hpsub/downloads/cmi_whitepaper.pdf + */ + #define _COMPONENT ACPI_RESOURCE_COMPONENT ACPI_MODULE_NAME ("wmi_hp") @@ -93,6 +100,12 @@ ACPI_MODULE_NAME ("wmi_hp") #define WMI_HP_HOTKEY_BRIGHTNESS_UP 0x02 #define WMI_HP_HOTKEY_BRIGHTNESS_DOWN 0x03 +#define WMI_HP_HOTKEY_PROG1 0x20e6 +#define WMI_HP_HOTKEY_MEDIA1 0x20e8 +#define WMI_HP_HOTKEY_MEDIA2 0x2142 +#define WMI_HP_HOTKEY_INFO 0x213b +#define WMI_HP_HOTKEY_DIRECTION 0x2169 +#define WMI_HP_HOTKEY_HELP 0x231b /* WMI_HP_HOTKEY_UNKNOWN 0xXX */ #define WMI_HP_SWITCH_WLAN 0x01 @@ -118,12 +131,21 @@ ACPI_MODULE_NAME ("wmi_hp") #define WMI_HP_GUID_EVENT "95F24279-4D7B-4334-9387-ACCDC67EF61C" #define WMI_HP_GUID_METHOD "5FB7F034-2C63-45E9-BE91-3D44E2C707E4" +#define WMI_HP_GUID_CMI "2D114B49-2DFB-4130-B8FE-4A3C09E75133" #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) +#define WMI_HP_SENSOR_HDDTEMP 3 +#define WMI_HP_SENSOR_DISPLAY 4 +#define WMI_HP_SENSOR_DOCK 5 +#define WMI_HP_SENSOR_COUNT 6 +#define WMI_HP_SENSOR_SIZE WMI_HP_SENSOR_COUNT * sizeof(envsys_data_t) + +#define ACPI_HP_CMI_PATHS 0x01 +#define ACPI_HP_CMI_ENUMS 0x02 +#define ACPI_HP_CMI_FLAGS 0x04 +#define ACPI_HP_CMI_MAX_INSTANCE 0x08 struct wmi_hp_softc { device_t sc_dev; @@ -143,13 +165,17 @@ static void wmi_hp_notify_handler(ACPI_H 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 *); +static void wmi_hp_sensor_switch_update(void *); +static void wmi_hp_sensor_refresh(struct sysmon_envsys *, envsys_data_t *); + +static void sysctl_wmi_hp_setup(struct wmi_hp_softc *); +static int sysctl_wmi_hp_set_als(SYSCTLFN_PROTO); +static struct sysctllog *wmihp_sysctllog = NULL; +static int wmihp_als = 0; +static struct wmi_hp_softc *wmi_hp_sc = NULL; /* XXX */ CFATTACH_DECL_NEW(wmihp, sizeof(struct wmi_hp_softc), wmi_hp_match, wmi_hp_attach, wmi_hp_detach, NULL); @@ -193,7 +219,9 @@ wmi_hp_attach(device_t parent, device_t if (sc->sc_sensor == NULL) return; + wmi_hp_sc = sc; /* XXX Can I pass sc as a cookie to sysctl? */ wmi_hp_sensor_init(sc); + sysctl_wmi_hp_setup(sc); } static int @@ -215,6 +243,11 @@ wmi_hp_detach(device_t self, int flags) pmf_device_deregister(self); + if (wmihp_sysctllog != NULL) + sysctl_teardown(&wmihp_sysctllog); + wmihp_sysctllog = NULL; + wmi_hp_sc = NULL; + return 0; } @@ -283,7 +316,7 @@ wmi_hp_notify_handler(ACPI_HANDLE hdl, u switch (val) { case WMI_HP_EVENT_SWITCH: - rv = AcpiOsExecute(handler, wmi_hp_sensor_update, self); + rv = AcpiOsExecute(handler, wmi_hp_sensor_switch_update, self); break; case WMI_HP_EVENT_HOTKEY: @@ -327,6 +360,24 @@ wmi_hp_hotkey(void *aux) pmf_event_inject(NULL, PMFE_DISPLAY_BRIGHTNESS_DOWN); break; + case WMI_HP_HOTKEY_PROG1: + aprint_debug_dev(self, "PROG1 hotkey pressed\n"); + break; + case WMI_HP_HOTKEY_MEDIA1: + aprint_debug_dev(self, "MEDIA1 hotkey pressed\n"); + break; + case WMI_HP_HOTKEY_MEDIA2: + aprint_debug_dev(self, "MEDIA2 hotkey pressed\n"); + break; + case WMI_HP_HOTKEY_INFO: + aprint_debug_dev(self, "INFO hotkey pressed\n"); + break; + case WMI_HP_HOTKEY_DIRECTION: + aprint_debug_dev(self, "DIRECTION hotkey pressed\n"); + break; + case WMI_HP_HOTKEY_HELP: + aprint_debug_dev(self, "HELP hotkey pressed\n"
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jakllsch Date: Fri Jul 22 15:53:02 UTC 2011 Modified Files: src/sys/dev/acpi/wmi: wmi_eeepc.c Log Message: Implement recognition of more wmieeepc(4) hotkey events. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/acpi/wmi/wmi_eeepc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_eeepc.c diff -u src/sys/dev/acpi/wmi/wmi_eeepc.c:1.2 src/sys/dev/acpi/wmi/wmi_eeepc.c:1.3 --- src/sys/dev/acpi/wmi/wmi_eeepc.c:1.2 Wed Feb 16 13:15:49 2011 +++ src/sys/dev/acpi/wmi/wmi_eeepc.c Fri Jul 22 15:53:02 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_eeepc.c,v 1.2 2011/02/16 13:15:49 jruoho Exp $ */ +/* $NetBSD: wmi_eeepc.c,v 1.3 2011/07/22 15:53:02 jakllsch Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_eeepc.c,v 1.2 2011/02/16 13:15:49 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_eeepc.c,v 1.3 2011/07/22 15:53:02 jakllsch Exp $"); #include #include @@ -46,23 +46,57 @@ #define _COMPONENT ACPI_RESOURCE_COMPONENT ACPI_MODULE_NAME ("wmi_eeepc") + +/* + * Current brightness is reported by events in the range of 0x10 to 0x2f. + * The low nibble containing a value from 0x0 to 0xA proportionate to + * brightness, 0x0 indicates minimum illumination, not backlight off. + */ +#define WMI_EEEPC_HK_BACKLIGHT_STATUS_BRIGHTNESS_MASK 0x0f /* 0x0 to 0xA */ +#define WMI_EEEPC_HK_BACKLIGHT_STATUS_DIRECTION_MASK (~WMI_EEEPC_HK_BACKLIGHT_STATUS_BRIGHTNESS_MASK) +#define WMI_EEEPC_HK_BACKLIGHT_STATUS_DIRECTION_INC 0x10 +#define WMI_EEEPC_HK_BACKLIGHT_STATUS_DIRECTION_DEC 0x20 + #define WMI_EEEPC_HK_VOLUME_UP 0x30 #define WMI_EEEPC_HK_VOLUME_DOWN 0x31 #define WMI_EEEPC_HK_VOLUME_MUTE 0x32 +#define WMI_EEEPC_HK_EXPRESSGATE 0x5C /* Also, "SuperHybrid" */ +#define WMI_EEEPC_HK_TOUCHPAD 0x6B +#define WMI_EEEPC_HK_WIRELESS 0x88 +#define WMI_EEEPC_HK_WEBCAM 0xBD #define WMI_EEEPC_HK_DISPLAY_CYCLE 0xCC +#define WMI_EEEPC_HK_DISPLAY_SAVER 0xE8 #define WMI_EEEPC_HK_DISPLAY_OFF 0xE9 -/* WMI_EEEPC_HK_UNKNOWN 0xXX */ - -#define WMI_EEEPC_PSW_DISPLAY_CYCLE 0 -#define WMI_EEEPC_PSW_COUNT 1 + /* Unlabeled keys on 1215T */ +#define WMI_EEEPC_HK_UNKNOWN_xEC 0xEC /* Fn+E */ +#define WMI_EEEPC_HK_UNKNOWN_xED 0xED /* Fn+D */ +#define WMI_EEEPC_HK_UNKNOWN_xEE 0xEE /* Fn+S */ +#define WMI_EEEPC_HK_UNKNOWN_xEF 0xEF /* Fn+F */ + +#define WMI_EEEPC_IS_BACKLIGHT_STATUS(x) (((x & WMI_EEEPC_HK_BACKLIGHT_STATUS_DIRECTION_MASK) == WMI_EEEPC_HK_BACKLIGHT_STATUS_DIRECTION_INC) || ((x & WMI_EEEPC_HK_BACKLIGHT_STATUS_DIRECTION_MASK) == WMI_EEEPC_HK_BACKLIGHT_STATUS_DIRECTION_DEC)) + +enum eeepc_smpsw { + WMI_EEEPC_PSW_EXPRESSGATE = 0, + WMI_EEEPC_PSW_TOUCHPAD, + WMI_EEEPC_PSW_WIRELESS, + WMI_EEEPC_PSW_WEBCAM, + WMI_EEEPC_PSW_DISPLAY_CYCLE, + WMI_EEEPC_PSW_DISPLAY_SAVER, + WMI_EEEPC_PSW_DISPLAY_OFF, + WMI_EEEPC_PSW_UNKNOWN_xEC, + WMI_EEEPC_PSW_UNKNOWN_xED, + WMI_EEEPC_PSW_UNKNOWN_xEE, + WMI_EEEPC_PSW_UNKNOWN_xEF, + WMI_EEEPC_PSW_COUNT /* Must be last. */ +}; #define WMI_EEEPC_GUID_EVENT "ABBC0F72-8EA1-11D1-00A0-C9062910" struct wmi_eeepc_softc { device_t sc_dev; device_t sc_parent; - struct sysmon_pswitch sc_smpsw[WMI_EEEPC_PSW_COUNT]; - bool sc_smpsw_valid; + struct sysmon_pswitch sc_psw[WMI_EEEPC_PSW_COUNT]; + bool sc_psw_valid[WMI_EEEPC_PSW_COUNT]; }; static int wmi_eeepc_match(device_t, cfdata_t, void *); @@ -84,13 +118,11 @@ static void wmi_eeepc_attach(device_t parent, device_t self, void *aux) { - static const int dc = WMI_EEEPC_PSW_DISPLAY_CYCLE; struct wmi_eeepc_softc *sc = device_private(self); ACPI_STATUS rv; sc->sc_dev = self; sc->sc_parent = parent; - sc->sc_smpsw_valid = false; rv = acpi_wmi_event_register(parent, wmi_eeepc_notify_handler); @@ -102,11 +134,30 @@ aprint_naive("\n"); aprint_normal(": Asus Eee PC WMI mappings\n"); - sc->sc_smpsw[dc].smpsw_type = PSWITCH_TYPE_HOTKEY; - sc->sc_smpsw[dc].smpsw_name = PSWITCH_HK_DISPLAY_CYCLE; - - if (sysmon_pswitch_register(&sc->sc_smpsw[dc]) == 0) - sc->sc_smpsw_valid = true; + memset(sc->sc_psw, 0, sizeof(sc->sc_psw)); + sc->sc_psw[WMI_EEEPC_PSW_EXPRESSGATE].smpsw_name = "expressgate"; + sc->sc_psw[WMI_EEEPC_PSW_TOUCHPAD].smpsw_name = "touchpad-toggle"; + sc->sc_psw[WMI_EEEPC_PSW_WIRELESS].smpsw_name = "wireless-toggle"; + sc->sc_psw[WMI_EEEPC_PSW_WEBCAM].smpsw_name = "camera-button"; + sc->sc_psw[WMI_EEEPC_PSW_DISPLAY_CYCLE].smpsw_name = PSWITCH_HK_DISPLAY_CYCLE; + sc->sc_psw[WMI_EEEPC_PSW_DISPLAY_SAVER].smpsw_name = PSWITCH_HK_LOCK_SCREEN; + sc->sc_psw[WMI_EEEPC_PSW_DISPLAY_OFF].smpsw_name = "display-off"; + sc->sc_psw[WMI_EEEPC_PSW_UNKNOWN_xEC].smpsw_name = "unlabeled-xEC"; + sc->sc_psw[WMI_EEEPC_PSW_UNKNOWN_xED].smpsw_name = "unlabeled-xED"; + sc->sc_psw[WMI_EEEPC_PSW_UNKNOWN_xEE].smpsw_name = "unlabeled-xEE"; + sc->sc_psw[WMI_EEEPC_PSW_UNKNOWN_xEF].smp
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jakllsch Date: Sun Jul 17 02:46:01 UTC 2011 Modified Files: src/sys/dev/acpi/wmi: wmi_acpi.c Log Message: - Fix wmieeepc(4) hotkeys on Eee PC 1215T - Rework wmi_event_enable into appropriately seperate versions for enabling events and collection. - Enable all events, not just ones tagged as expensive. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/acpi/wmi/wmi_acpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_acpi.c diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.12 src/sys/dev/acpi/wmi/wmi_acpi.c:1.13 --- src/sys/dev/acpi/wmi/wmi_acpi.c:1.12 Wed Feb 16 08:19:56 2011 +++ src/sys/dev/acpi/wmi/wmi_acpi.c Sun Jul 17 02:46:01 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_acpi.c,v 1.12 2011/02/16 08:19:56 jruoho Exp $ */ +/* $NetBSD: wmi_acpi.c,v 1.13 2011/07/17 02:46:01 jakllsch Exp $ */ /*- * Copyright (c) 2009, 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.12 2011/02/16 08:19:56 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.13 2011/07/17 02:46:01 jakllsch Exp $"); #include #include @@ -73,7 +73,8 @@ uint32_t, ACPI_INTEGER *, void *, void *); static bool acpi_wmi_suspend(device_t, const pmf_qual_t *); static bool acpi_wmi_resume(device_t, const pmf_qual_t *); -static ACPI_STATUS acpi_wmi_enable(ACPI_HANDLE, const char *, bool, bool); +static ACPI_STATUS acpi_wmi_enable_event(ACPI_HANDLE, uint8_t, bool); +static ACPI_STATUS acpi_wmi_enable_collection(ACPI_HANDLE, const char *, bool); static bool acpi_wmi_input(struct wmi_t *, uint8_t, uint8_t); const char * const acpi_wmi_ids[] = { @@ -411,15 +412,14 @@ return; /* - * Enable possible expensive events. + * Enable possible events, expensive or otherwise. */ SIMPLEQ_FOREACH(wmi, &sc->wmi_head, wmi_link) { - if ((wmi->guid.flags & ACPI_WMI_FLAG_EVENT) != 0 && - (wmi->guid.flags & ACPI_WMI_FLAG_EXPENSIVE) != 0) { + if ((wmi->guid.flags & ACPI_WMI_FLAG_EVENT) != 0) { - rv = acpi_wmi_enable(sc->sc_node->ad_handle, - wmi->guid.oid, false, true); + rv = acpi_wmi_enable_event(sc->sc_node->ad_handle, + wmi->guid.nid, true); if (ACPI_SUCCESS(rv)) { wmi->eevent = true; @@ -449,10 +449,9 @@ continue; KASSERT((wmi->guid.flags & ACPI_WMI_FLAG_EVENT) != 0); - KASSERT((wmi->guid.flags & ACPI_WMI_FLAG_EXPENSIVE) != 0); - rv = acpi_wmi_enable(sc->sc_node->ad_handle, - wmi->guid.oid, false, false); + rv = acpi_wmi_enable_event(sc->sc_node->ad_handle, + wmi->guid.nid, false); if (ACPI_SUCCESS(rv)) { wmi->eevent = false; @@ -606,19 +605,23 @@ return true; } -/* - * Enables or disables data collection (WCxx) or an event (WExx). - */ static ACPI_STATUS -acpi_wmi_enable(ACPI_HANDLE hdl, const char *oid, bool data, bool flag) +acpi_wmi_enable_event(ACPI_HANDLE hdl, uint8_t nid, bool flag) { char path[5]; - const char *str; - str = (data != false) ? "WC" : "WE"; + snprintf(path, sizeof(path), "WE%02X", nid); + + return acpi_eval_set_integer(hdl, path, (flag != false) ? 0x01 : 0x00); +} + +static ACPI_STATUS +acpi_wmi_enable_collection(ACPI_HANDLE hdl, const char *oid, bool flag) +{ + char path[5]; - (void)strlcpy(path, str, sizeof(path)); - (void)strlcat(path, oid, sizeof(path)); + strlcpy(path, "WC", sizeof(path)); + strlcat(path, oid, sizeof(path)); return acpi_eval_set_integer(hdl, path, (flag != false) ? 0x01 : 0x00); } @@ -684,8 +687,8 @@ */ if ((wmi->guid.flags & ACPI_WMI_FLAG_EXPENSIVE) != 0) { - rvxx = acpi_wmi_enable(sc->sc_node->ad_handle, - wmi->guid.oid, true, true); + rvxx = acpi_wmi_enable_collection(sc->sc_node->ad_handle, + wmi->guid.oid, true); } rv = AcpiEvaluateObject(sc->sc_node->ad_handle, path, &arg, obuf); @@ -693,8 +696,8 @@ /* No longer needed. */ if (ACPI_SUCCESS(rvxx)) { - (void)acpi_wmi_enable(sc->sc_node->ad_handle, - wmi->guid.oid, true, false); + (void)acpi_wmi_enable_collection(sc->sc_node->ad_handle, + wmi->guid.oid, false); } #ifdef DIAGNOSTIC
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jruoho Date: Wed Feb 16 13:15:49 UTC 2011 Modified Files: src/sys/dev/acpi/wmi: wmi_dell.c wmi_eeepc.c wmi_hp.c wmi_msi.c Log Message: Make the WMI modules depend on the parent mapper. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/acpi/wmi/wmi_dell.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/acpi/wmi/wmi_eeepc.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/acpi/wmi/wmi_hp.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/acpi/wmi/wmi_msi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_dell.c diff -u src/sys/dev/acpi/wmi/wmi_dell.c:1.7 src/sys/dev/acpi/wmi/wmi_dell.c:1.8 --- src/sys/dev/acpi/wmi/wmi_dell.c:1.7 Wed Feb 16 08:19:56 2011 +++ src/sys/dev/acpi/wmi/wmi_dell.c Wed Feb 16 13:15:49 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_dell.c,v 1.7 2011/02/16 08:19:56 jruoho Exp $ */ +/* $NetBSD: wmi_dell.c,v 1.8 2011/02/16 13:15:49 jruoho Exp $ */ /*- * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.7 2011/02/16 08:19:56 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.8 2011/02/16 13:15:49 jruoho Exp $"); #include #include @@ -233,7 +233,7 @@ "event 0x%02X: %s\n", evt, AcpiFormatException(rv)); } -MODULE(MODULE_CLASS_DRIVER, wmidell, NULL); +MODULE(MODULE_CLASS_DRIVER, wmidell, "acpiwmi"); #ifdef _MODULE #include "ioconf.c" Index: src/sys/dev/acpi/wmi/wmi_eeepc.c diff -u src/sys/dev/acpi/wmi/wmi_eeepc.c:1.1 src/sys/dev/acpi/wmi/wmi_eeepc.c:1.2 --- src/sys/dev/acpi/wmi/wmi_eeepc.c:1.1 Wed Feb 16 07:30:26 2011 +++ src/sys/dev/acpi/wmi/wmi_eeepc.c Wed Feb 16 13:15:49 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_eeepc.c,v 1.1 2011/02/16 07:30:26 jruoho Exp $ */ +/* $NetBSD: wmi_eeepc.c,v 1.2 2011/02/16 13:15:49 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_eeepc.c,v 1.1 2011/02/16 07:30:26 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_eeepc.c,v 1.2 2011/02/16 13:15:49 jruoho Exp $"); #include #include @@ -220,7 +220,7 @@ "event 0x%02X: %s\n", evt, AcpiFormatException(rv)); } -MODULE(MODULE_CLASS_DRIVER, wmieeepc, NULL); +MODULE(MODULE_CLASS_DRIVER, wmieeepc, "acpiwmi"); #ifdef _MODULE #include "ioconf.c" Index: src/sys/dev/acpi/wmi/wmi_hp.c diff -u src/sys/dev/acpi/wmi/wmi_hp.c:1.5 src/sys/dev/acpi/wmi/wmi_hp.c:1.6 --- src/sys/dev/acpi/wmi/wmi_hp.c:1.5 Wed Feb 16 08:19:56 2011 +++ src/sys/dev/acpi/wmi/wmi_hp.c Wed Feb 16 13:15:49 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_hp.c,v 1.5 2011/02/16 08:19:56 jruoho Exp $ */ +/* $NetBSD: wmi_hp.c,v 1.6 2011/02/16 13:15:49 jruoho Exp $ */ /*- * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1.5 2011/02/16 08:19:56 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1.6 2011/02/16 13:15:49 jruoho Exp $"); #include #include @@ -531,7 +531,7 @@ } } -MODULE(MODULE_CLASS_DRIVER, wmihp, NULL); +MODULE(MODULE_CLASS_DRIVER, wmihp, "acpiwmi"); #ifdef _MODULE #include "ioconf.c" Index: src/sys/dev/acpi/wmi/wmi_msi.c diff -u src/sys/dev/acpi/wmi/wmi_msi.c:1.4 src/sys/dev/acpi/wmi/wmi_msi.c:1.5 --- src/sys/dev/acpi/wmi/wmi_msi.c:1.4 Wed Feb 16 08:19:56 2011 +++ src/sys/dev/acpi/wmi/wmi_msi.c Wed Feb 16 13:15:49 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_msi.c,v 1.4 2011/02/16 08:19:56 jruoho Exp $ */ +/* $NetBSD: wmi_msi.c,v 1.5 2011/02/16 13:15:49 jruoho Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_msi.c,v 1.4 2011/02/16 08:19:56 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_msi.c,v 1.5 2011/02/16 13:15:49 jruoho Exp $"); #include #include @@ -194,7 +194,7 @@ "event 0x%02X: %s\n", evt, AcpiFormatException(rv)); } -MODULE(MODULE_CLASS_DRIVER, wmimsi, NULL); +MODULE(MODULE_CLASS_DRIVER, wmimsi, "acpiwmi"); #ifdef _MODULE #include "ioconf.c"
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jruoho Date: Thu Oct 28 15:55:05 UTC 2010 Modified Files: src/sys/dev/acpi/wmi: wmi_acpi.c wmi_acpivar.h Log Message: Install EC space handler and pass everything to acpiec(4). Should fix PR # 43659. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/acpi/wmi/wmi_acpi.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/acpi/wmi/wmi_acpivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_acpi.c diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.10 src/sys/dev/acpi/wmi/wmi_acpi.c:1.11 --- src/sys/dev/acpi/wmi/wmi_acpi.c:1.10 Mon Oct 25 15:38:05 2010 +++ src/sys/dev/acpi/wmi/wmi_acpi.c Thu Oct 28 15:55:04 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_acpi.c,v 1.10 2010/10/25 15:38:05 jruoho Exp $ */ +/* $NetBSD: wmi_acpi.c,v 1.11 2010/10/28 15:55:04 jruoho Exp $ */ /*- * Copyright (c) 2009, 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.10 2010/10/25 15:38:05 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.11 2010/10/28 15:55:04 jruoho Exp $"); #include #include @@ -38,6 +38,7 @@ #include #include +#include #include #define _COMPONENT ACPI_RESOURCE_COMPONENT @@ -52,26 +53,28 @@ * (Obtained on Thu Feb 12 18:21:44 EET 2009.) */ -static int acpi_wmi_match(device_t, cfdata_t, void *); -static voidacpi_wmi_attach(device_t, device_t, void *); -static int acpi_wmi_detach(device_t, int); -static int acpi_wmi_rescan(device_t, const char *, const int *); -static voidacpi_wmi_childdet(device_t, device_t); -static int acpi_wmi_print(void *, const char *); -static boolacpi_wmi_init(struct acpi_wmi_softc *); -static boolacpi_wmi_add(struct acpi_wmi_softc *, ACPI_OBJECT *); -static voidacpi_wmi_del(struct acpi_wmi_softc *); -static void acpi_wmi_dump(struct acpi_wmi_softc *); - -static ACPI_STATUS acpi_wmi_guid_get(struct acpi_wmi_softc *, - const char *, struct wmi_t **); -static void acpi_wmi_event_add(struct acpi_wmi_softc *); -static void acpi_wmi_event_del(struct acpi_wmi_softc *); -static voidacpi_wmi_event_handler(ACPI_HANDLE, uint32_t, void *); -static boolacpi_wmi_suspend(device_t, const pmf_qual_t *); -static boolacpi_wmi_resume(device_t, const pmf_qual_t *); -static ACPI_STATUS acpi_wmi_enable(ACPI_HANDLE, const char *, bool, bool); -static boolacpi_wmi_input(struct wmi_t *, uint8_t, uint8_t); +static int acpi_wmi_match(device_t, cfdata_t, void *); +static void acpi_wmi_attach(device_t, device_t, void *); +static int acpi_wmi_detach(device_t, int); +static int acpi_wmi_rescan(device_t, const char *, const int *); +static void acpi_wmi_childdet(device_t, device_t); +static int acpi_wmi_print(void *, const char *); +static bool acpi_wmi_init(struct acpi_wmi_softc *); +static void acpi_wmi_init_ec(struct acpi_wmi_softc *); +static bool acpi_wmi_add(struct acpi_wmi_softc *, ACPI_OBJECT *); +static void acpi_wmi_del(struct acpi_wmi_softc *); +static void acpi_wmi_dump(struct acpi_wmi_softc *); +static ACPI_STATUS acpi_wmi_guid_get(struct acpi_wmi_softc *, +const char *, struct wmi_t **); +static void acpi_wmi_event_add(struct acpi_wmi_softc *); +static void acpi_wmi_event_del(struct acpi_wmi_softc *); +static void acpi_wmi_event_handler(ACPI_HANDLE, uint32_t, void *); +static ACPI_STATUS acpi_wmi_ec_handler(uint32_t, ACPI_PHYSICAL_ADDRESS, +uint32_t, ACPI_INTEGER *, void *, void *); +static bool acpi_wmi_suspend(device_t, const pmf_qual_t *); +static bool acpi_wmi_resume(device_t, const pmf_qual_t *); +static ACPI_STATUS acpi_wmi_enable(ACPI_HANDLE, const char *, bool, bool); +static bool acpi_wmi_input(struct wmi_t *, uint8_t, uint8_t); const char * const acpi_wmi_ids[] = { "PNP0C14", @@ -104,6 +107,7 @@ sc->sc_node = aa->aa_node; sc->sc_child = NULL; + sc->sc_ecdev = NULL; sc->sc_handler = NULL; aprint_naive("\n"); @@ -113,8 +117,8 @@ return; acpi_wmi_dump(sc); + acpi_wmi_init_ec(sc); acpi_wmi_event_add(sc); - acpi_wmi_rescan(self, NULL, NULL); (void)pmf_device_register(self, acpi_wmi_suspend, acpi_wmi_resume); @@ -127,6 +131,12 @@ acpi_wmi_event_del(sc); + if (sc->sc_ecdev != NULL) { + + (void)AcpiRemoveAddressSpaceHandler(sc->sc_node->ad_handle, + ACPI_ADR_SPACE_EC, acpi_wmi_ec_handler); + } + if (sc->sc_child != NULL) (void)config_detach(sc->sc_child, flags); @@ -291,6 +301,36 @@ } } +static void +acpi_wmi_init_ec(struct acpi_wmi_softc *sc) +{ + ACPI_STATUS rv; + deviter_t i; + device_t d; + + d = deviter_first(&i, DEVITER_F_ROOT_FIRST); + + for (; d != NULL; d = deviter_next(&i)) { + + if (device_is_a(d, "acpiec") != false || + device_is_a(d, "acpiecdt") != false) { + sc->sc_ecdev = d; + break; +
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jruoho Date: Mon Oct 25 15:38:06 UTC 2010 Modified Files: src/sys/dev/acpi/wmi: wmi_acpi.c Log Message: Fix build failure. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/acpi/wmi/wmi_acpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_acpi.c diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.9 src/sys/dev/acpi/wmi/wmi_acpi.c:1.10 --- src/sys/dev/acpi/wmi/wmi_acpi.c:1.9 Sun Oct 24 18:26:29 2010 +++ src/sys/dev/acpi/wmi/wmi_acpi.c Mon Oct 25 15:38:05 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_acpi.c,v 1.9 2010/10/24 18:26:29 jmcneill Exp $ */ +/* $NetBSD: wmi_acpi.c,v 1.10 2010/10/25 15:38:05 jruoho Exp $ */ /*- * Copyright (c) 2009, 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.9 2010/10/24 18:26:29 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.10 2010/10/25 15:38:05 jruoho Exp $"); #include #include @@ -751,7 +751,7 @@ .cf_pspec = &acpiparent, }, - { NULL } + { NULL, NULL, 0, 0, NULL, 0, NULL } }; static int
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jmcneill Date: Sun Oct 24 18:26:29 UTC 2010 Modified Files: src/sys/dev/acpi/wmi: wmi_acpi.c Log Message: add support for building as a module To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/acpi/wmi/wmi_acpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_acpi.c diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.8 src/sys/dev/acpi/wmi/wmi_acpi.c:1.9 --- src/sys/dev/acpi/wmi/wmi_acpi.c:1.8 Sun Oct 24 15:07:20 2010 +++ src/sys/dev/acpi/wmi/wmi_acpi.c Sun Oct 24 18:26:29 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_acpi.c,v 1.8 2010/10/24 15:07:20 jmcneill Exp $ */ +/* $NetBSD: wmi_acpi.c,v 1.9 2010/10/24 18:26:29 jmcneill Exp $ */ /*- * Copyright (c) 2009, 2010 Jukka Ruohonen @@ -27,13 +27,14 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.8 2010/10/24 15:07:20 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.9 2010/10/24 18:26:29 jmcneill Exp $"); #include #include #include #include #include +#include #include #include @@ -726,3 +727,79 @@ return AcpiEvaluateObject(sc->sc_node->ad_handle, path, &arg, obuf); } + +#ifdef _MODULE + +MODULE(MODULE_CLASS_DRIVER, acpiwmi, NULL); +CFDRIVER_DECL(acpiwmi, DV_DULL, NULL); + +static int acpiwmiloc[] = { -1 }; +extern struct cfattach acpiwmi_ca; + +static struct cfparent acpiparent = { + "acpinodebus", NULL, DVUNIT_ANY +}; + +static struct cfdata acpiwmi_cfdata[] = { + { + .cf_name = "acpiwmi", + .cf_atname = "acpiwmi", + .cf_unit = 0, + .cf_fstate = FSTATE_STAR, + .cf_loc = acpiwmiloc, + .cf_flags = 0, + .cf_pspec = &acpiparent, + }, + + { NULL } +}; + +static int +acpiwmi_modcmd(modcmd_t cmd, void *opaque) +{ + int err; + + switch (cmd) { + + case MODULE_CMD_INIT: + + err = config_cfdriver_attach(&acpiwmi_cd); + + if (err != 0) + return err; + + err = config_cfattach_attach("acpiwmi", &acpiwmi_ca); + + if (err != 0) { + config_cfdriver_detach(&acpiwmi_cd); + return err; + } + + err = config_cfdata_attach(acpiwmi_cfdata, 1); + + if (err != 0) { + config_cfattach_detach("acpiwmi", &acpiwmi_ca); + config_cfdriver_detach(&acpiwmi_cd); + return err; + } + + return 0; + + case MODULE_CMD_FINI: + + err = config_cfdata_detach(acpiwmi_cfdata); + + if (err != 0) + return err; + + config_cfattach_detach("acpiwmi", &acpiwmi_ca); + config_cfdriver_detach(&acpiwmi_cd); + + return 0; + + default: + return ENOTTY; + } +} + +#endif /* _MODULE */
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jmcneill Date: Sun Oct 24 16:25:31 UTC 2010 Modified Files: src/sys/dev/acpi/wmi: wmi_dell.c wmi_hp.c wmi_msi.c Log Message: add support for building as modules To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/acpi/wmi/wmi_dell.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/acpi/wmi/wmi_hp.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/acpi/wmi/wmi_msi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_dell.c diff -u src/sys/dev/acpi/wmi/wmi_dell.c:1.4 src/sys/dev/acpi/wmi/wmi_dell.c:1.5 --- src/sys/dev/acpi/wmi/wmi_dell.c:1.4 Wed Jun 30 07:58:11 2010 +++ src/sys/dev/acpi/wmi/wmi_dell.c Sun Oct 24 16:25:31 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_dell.c,v 1.4 2010/06/30 07:58:11 jruoho Exp $ */ +/* $NetBSD: wmi_dell.c,v 1.5 2010/10/24 16:25:31 jmcneill Exp $ */ /*- * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. @@ -31,10 +31,11 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.4 2010/06/30 07:58:11 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.5 2010/10/24 16:25:31 jmcneill Exp $"); #include #include +#include #include #include @@ -231,3 +232,79 @@ aprint_error_dev(sc->sc_dev, "failed to get data for " "event 0x%02X: %s\n", evt, AcpiFormatException(rv)); } + +#ifdef _MODULE + +MODULE(MODULE_CLASS_DRIVER, wmidell, NULL); +CFDRIVER_DECL(wmidell, DV_DULL, NULL); + +static int wmidellloc[] = { -1 }; +extern struct cfattach wmidell_ca; + +static struct cfparent wmiparent = { + "acpiwmibus", NULL, DVUNIT_ANY +}; + +static struct cfdata wmidell_cfdata[] = { + { + .cf_name = "wmidell", + .cf_atname = "wmidell", + .cf_unit = 0, + .cf_fstate = FSTATE_STAR, + .cf_loc = wmidellloc, + .cf_flags = 0, + .cf_pspec = &wmiparent, + }, + + { NULL } +}; + +static int +wmidell_modcmd(modcmd_t cmd, void *opaque) +{ + int err; + + switch (cmd) { + + case MODULE_CMD_INIT: + + err = config_cfdriver_attach(&wmidell_cd); + + if (err != 0) + return err; + + err = config_cfattach_attach("wmidell", &wmidell_ca); + + if (err != 0) { + config_cfdriver_detach(&wmidell_cd); + return err; + } + + err = config_cfdata_attach(wmidell_cfdata, 1); + + if (err != 0) { + config_cfattach_detach("wmidell", &wmidell_ca); + config_cfdriver_detach(&wmidell_cd); + return err; + } + + return 0; + + case MODULE_CMD_FINI: + + err = config_cfdata_detach(wmidell_cfdata); + + if (err != 0) + return err; + + config_cfattach_detach("wmidell", &wmidell_ca); + config_cfdriver_detach(&wmidell_cd); + + return 0; + + default: + return ENOTTY; + } +} + +#endif /* _MODULE */ Index: src/sys/dev/acpi/wmi/wmi_hp.c diff -u src/sys/dev/acpi/wmi/wmi_hp.c:1.2 src/sys/dev/acpi/wmi/wmi_hp.c:1.3 --- src/sys/dev/acpi/wmi/wmi_hp.c:1.2 Wed Jun 30 07:58:11 2010 +++ src/sys/dev/acpi/wmi/wmi_hp.c Sun Oct 24 16:25:31 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_hp.c,v 1.2 2010/06/30 07:58:11 jruoho Exp $ */ +/* $NetBSD: wmi_hp.c,v 1.3 2010/10/24 16:25:31 jmcneill Exp $ */ /*- * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. @@ -57,11 +57,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1.2 2010/06/30 07:58:11 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1.3 2010/10/24 16:25:31 jmcneill Exp $"); #include #include #include +#include #include #include @@ -529,3 +530,79 @@ sc->sc_sensor[WMI_HP_SENSOR_WWAN].state = ENVSYS_SVALID; } } + +#ifdef _MODULE + +MODULE(MODULE_CLASS_DRIVER, wmihp, NULL); +CFDRIVER_DECL(wmihp, DV_DULL, NULL); + +static int wmihploc[] = { -1 }; +extern struct cfattach wmihp_ca; + +static struct cfparent wmiparent = { + "acpiwmibus", NULL, DVUNIT_ANY +}; + +static struct cfdata wmihp_cfdata[] = { + { + .cf_name = "wmihp", + .cf_atname = "wmihp", + .cf_unit = 0, + .cf_fstate = FSTATE_STAR, + .cf_loc = wmihploc, + .cf_flags = 0, + .cf_pspec = &wmiparent, + }, + + { NULL } +}; + +static int +wmihp_modcmd(modcmd_t cmd, void *opaque) +{ + int err; + + switch (cmd) { + + case MODULE_CMD_INIT: + + err = config_cfdriver_attach(&wmihp_cd); + + if (err != 0) + return err; + + err = config_cfattach_attach("wmihp", &wmihp_ca); + + if (err != 0) { + config_cfdriver_detach(&wmihp_cd); + return err; + } + + err = config_cfdata_attach(wmihp_cfdata, 1); + + if (err != 0) { + config_cfattach_detach("wmihp", &wmihp_ca); + config_cfdriver_detach(&wmihp_cd); + return err; + } + + return 0; + + case MODULE_CMD_FINI: + + err = config_cfdata_detach(wmihp_cfdata); + + if (err != 0) + return err; + + config_cfattach_detach("wmihp", &wmihp_ca); + config_cfdriver_detach(&wmihp_cd); + + return 0; + + default: + return ENOTTY; + } +} + +#endif /* _MODULE */ Index: src/sys/dev/acpi/wmi/wmi_msi.c diff -u src/sys/dev/acpi/wmi/wmi_msi.c:1.1 src/sys/dev/acpi/wmi/wmi_msi.c:1.2 --- src/sys/dev/acpi/wmi/wmi_msi.c:1.1 Sun Oct 24 08:54:15 2010 +++
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jmcneill Date: Sun Oct 24 15:07:20 UTC 2010 Modified Files: src/sys/dev/acpi/wmi: wmi_acpi.c Log Message: add rescan support To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/acpi/wmi/wmi_acpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_acpi.c diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.7 src/sys/dev/acpi/wmi/wmi_acpi.c:1.8 --- src/sys/dev/acpi/wmi/wmi_acpi.c:1.7 Fri Aug 6 22:45:00 2010 +++ src/sys/dev/acpi/wmi/wmi_acpi.c Sun Oct 24 15:07:20 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_acpi.c,v 1.7 2010/08/06 22:45:00 jruoho Exp $ */ +/* $NetBSD: wmi_acpi.c,v 1.8 2010/10/24 15:07:20 jmcneill Exp $ */ /*- * Copyright (c) 2009, 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.7 2010/08/06 22:45:00 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.8 2010/10/24 15:07:20 jmcneill Exp $"); #include #include @@ -54,6 +54,8 @@ static int acpi_wmi_match(device_t, cfdata_t, void *); static voidacpi_wmi_attach(device_t, device_t, void *); static int acpi_wmi_detach(device_t, int); +static int acpi_wmi_rescan(device_t, const char *, const int *); +static voidacpi_wmi_childdet(device_t, device_t); static int acpi_wmi_print(void *, const char *); static boolacpi_wmi_init(struct acpi_wmi_softc *); static boolacpi_wmi_add(struct acpi_wmi_softc *, ACPI_OBJECT *); @@ -76,8 +78,9 @@ NULL }; -CFATTACH_DECL_NEW(acpiwmi, sizeof(struct acpi_wmi_softc), -acpi_wmi_match, acpi_wmi_attach, acpi_wmi_detach, NULL); +CFATTACH_DECL2_NEW(acpiwmi, sizeof(struct acpi_wmi_softc), +acpi_wmi_match, acpi_wmi_attach, acpi_wmi_detach, NULL, +acpi_wmi_rescan, acpi_wmi_childdet); static int acpi_wmi_match(device_t parent, cfdata_t match, void *aux) @@ -111,8 +114,7 @@ acpi_wmi_dump(sc); acpi_wmi_event_add(sc); - sc->sc_child = config_found_ia(self, "acpiwmibus", - NULL, acpi_wmi_print); + acpi_wmi_rescan(self, NULL, NULL); (void)pmf_device_register(self, acpi_wmi_suspend, acpi_wmi_resume); } @@ -134,6 +136,27 @@ } static int +acpi_wmi_rescan(device_t self, const char *ifattr, const int *locators) +{ + struct acpi_wmi_softc *sc = device_private(self); + + if (ifattr_match(ifattr, "acpiwmibus") && sc->sc_child == NULL) + sc->sc_child = config_found_ia(self, "acpiwmibus", + NULL, acpi_wmi_print); + + return 0; +} + +static void +acpi_wmi_childdet(device_t self, device_t child) +{ + struct acpi_wmi_softc *sc = device_private(self); + + if (sc->sc_child == child) + sc->sc_child = NULL; +} + +static int acpi_wmi_print(void *aux, const char *pnp) {
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jruoho Date: Thu Jul 29 07:10:39 UTC 2010 Modified Files: src/sys/dev/acpi/wmi: wmi_acpi.c Log Message: Add "pnp0c14" to the list of HIDs. Required for LG X110. As valid EISA IDs should be all upper case, leave this as a onetime quirk specific to acpiwmi(4). To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/acpi/wmi/wmi_acpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_acpi.c diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.5 src/sys/dev/acpi/wmi/wmi_acpi.c:1.6 --- src/sys/dev/acpi/wmi/wmi_acpi.c:1.5 Mon May 31 20:32:29 2010 +++ src/sys/dev/acpi/wmi/wmi_acpi.c Thu Jul 29 07:10:39 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_acpi.c,v 1.5 2010/05/31 20:32:29 pgoyette Exp $ */ +/* $NetBSD: wmi_acpi.c,v 1.6 2010/07/29 07:10:39 jruoho Exp $ */ /*- * Copyright (c) 2009, 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.5 2010/05/31 20:32:29 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.6 2010/07/29 07:10:39 jruoho Exp $"); #include #include @@ -71,6 +71,7 @@ const char * const acpi_wmi_ids[] = { "PNP0C14", + "pnp0c14", NULL }; @@ -322,7 +323,9 @@ if (acpi_register_notify(sc->sc_node, acpi_wmi_event_handler) != true) return; - /* Enable possible expensive events. */ + /* + * Enable possible expensive events. + */ SIMPLEQ_FOREACH(wmi, &sc->wmi_head, wmi_link) { if ((wmi->guid.flags & ACPI_WMI_FLAG_EVENT) != 0 && @@ -336,7 +339,7 @@ continue; } - aprint_error_dev(sc->sc_dev, "failed to enable " + aprint_debug_dev(sc->sc_dev, "failed to enable " "expensive WExx: %s\n", AcpiFormatException(rv)); } } @@ -369,7 +372,7 @@ continue; } - aprint_error_dev(sc->sc_dev, "failed to disable " + aprint_debug_dev(sc->sc_dev, "failed to disable " "expensive WExx: %s\n", AcpiFormatException(rv)); } }
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jakllsch Date: Mon Jul 19 18:22:53 UTC 2010 Modified Files: src/sys/dev/acpi/wmi: files.wmi Log Message: correct an obvious typo: acpwmi -> acpiwmi To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/acpi/wmi/files.wmi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/files.wmi diff -u src/sys/dev/acpi/wmi/files.wmi:1.4 src/sys/dev/acpi/wmi/files.wmi:1.5 --- src/sys/dev/acpi/wmi/files.wmi:1.4 Mon May 31 20:32:29 2010 +++ src/sys/dev/acpi/wmi/files.wmi Mon Jul 19 18:22:53 2010 @@ -1,4 +1,4 @@ -# $NetBSD: files.wmi,v 1.4 2010/05/31 20:32:29 pgoyette Exp $ +# $NetBSD: files.wmi,v 1.5 2010/07/19 18:22:53 jakllsch Exp $ define acpiwmibus { } @@ -6,7 +6,7 @@ device acpiwmi: acpiwmibus attach acpiwmi at acpinodebus file dev/acpi/wmi/wmi_acpi.c acpiwmi -file dev/acpi/wmi/wmi_dump.c acpwmi & acpiverbose +file dev/acpi/wmi/wmi_dump.c acpiwmi & acpiverbose # Dell WMI mappings device wmidell: sysmon_power
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jruoho Date: Wed Jun 30 07:58:11 UTC 2010 Modified Files: src/sys/dev/acpi/wmi: wmi_dell.c wmi_hp.c Log Message: Initialize pointers to NULL. Otherwise we may try to free garbage. Tries to address a panic reported by David Demelier in PR kern/43504. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/acpi/wmi/wmi_dell.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/acpi/wmi/wmi_hp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_dell.c diff -u src/sys/dev/acpi/wmi/wmi_dell.c:1.3 src/sys/dev/acpi/wmi/wmi_dell.c:1.4 --- src/sys/dev/acpi/wmi/wmi_dell.c:1.3 Thu Apr 8 12:14:19 2010 +++ src/sys/dev/acpi/wmi/wmi_dell.c Wed Jun 30 07:58:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_dell.c,v 1.3 2010/04/08 12:14:19 jruoho Exp $ */ +/* $NetBSD: wmi_dell.c,v 1.4 2010/06/30 07:58:11 jruoho Exp $ */ /*- * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.3 2010/04/08 12:14:19 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.4 2010/06/30 07:58:11 jruoho Exp $"); #include #include @@ -167,6 +167,8 @@ ACPI_STATUS rv; uint32_t val; + buf.Pointer = NULL; + sc = device_private(self); rv = acpi_wmi_event_get(sc->sc_parent, evt, &buf); Index: src/sys/dev/acpi/wmi/wmi_hp.c diff -u src/sys/dev/acpi/wmi/wmi_hp.c:1.1 src/sys/dev/acpi/wmi/wmi_hp.c:1.2 --- src/sys/dev/acpi/wmi/wmi_hp.c:1.1 Thu Apr 8 17:32:30 2010 +++ src/sys/dev/acpi/wmi/wmi_hp.c Wed Jun 30 07:58:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_hp.c,v 1.1 2010/04/08 17:32:30 jruoho Exp $ */ +/* $NetBSD: wmi_hp.c,v 1.2 2010/06/30 07:58:11 jruoho Exp $ */ /*- * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1.1 2010/04/08 17:32:30 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_hp.c,v 1.2 2010/06/30 07:58:11 jruoho Exp $"); #include #include @@ -252,6 +252,8 @@ ACPI_STATUS rv; uint32_t val; + buf.Pointer = NULL; + sc = device_private(self); rv = acpi_wmi_event_get(sc->sc_parent, evt, &buf); @@ -343,6 +345,7 @@ KDASSERT(cmd != 0); KDASSERT(sc->sc_arg[0] == WMI_HP_METHOD_ARG_MAGIC); + obuf.Pointer = NULL; ibuf.Pointer = sc->sc_arg; ibuf.Length = WMI_HP_METHOD_ARG_SIZE;
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jruoho Date: Fri Apr 9 04:48:23 UTC 2010 Modified Files: src/sys/dev/acpi/wmi: wmi_acpi.c Log Message: Fix a potential NULL pointer dereference. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/acpi/wmi/wmi_acpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_acpi.c diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.2 src/sys/dev/acpi/wmi/wmi_acpi.c:1.3 --- src/sys/dev/acpi/wmi/wmi_acpi.c:1.2 Thu Apr 8 12:36:21 2010 +++ src/sys/dev/acpi/wmi/wmi_acpi.c Fri Apr 9 04:48:23 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_acpi.c,v 1.2 2010/04/08 12:36:21 jruoho Exp $ */ +/* $NetBSD: wmi_acpi.c,v 1.3 2010/04/09 04:48:23 jruoho Exp $ */ /*- * Copyright (c) 2009, 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.2 2010/04/08 12:36:21 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.3 2010/04/09 04:48:23 jruoho Exp $"); #include #include @@ -501,14 +501,14 @@ ACPI_OBJECT obj; ACPI_HANDLE hdl; - hdl = sc->sc_node->ad_handle; - if (sc == NULL || obuf == NULL) return AE_BAD_PARAMETER; if (sc->sc_handler == NULL) return AE_ABORT_METHOD; + hdl = sc->sc_node->ad_handle; + obj.Type = ACPI_TYPE_INTEGER; obj.Integer.Value = event;
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jruoho Date: Thu Apr 8 12:36:21 UTC 2010 Modified Files: src/sys/dev/acpi/wmi: wmi_acpi.c wmi_acpivar.h Log Message: Semantics. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/acpi/wmi/wmi_acpi.c \ src/sys/dev/acpi/wmi/wmi_acpivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/wmi/wmi_acpi.c diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.1 src/sys/dev/acpi/wmi/wmi_acpi.c:1.2 --- src/sys/dev/acpi/wmi/wmi_acpi.c:1.1 Thu Apr 8 12:14:19 2010 +++ src/sys/dev/acpi/wmi/wmi_acpi.c Thu Apr 8 12:36:21 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_acpi.c,v 1.1 2010/04/08 12:14:19 jruoho Exp $ */ +/* $NetBSD: wmi_acpi.c,v 1.2 2010/04/08 12:36:21 jruoho Exp $ */ /*- * Copyright (c) 2009, 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.1 2010/04/08 12:14:19 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.2 2010/04/08 12:36:21 jruoho Exp $"); #include #include @@ -302,7 +302,7 @@ { struct wmi_t *wmi; - if (SIMPLEQ_EMPTY(&sc->wmi_head)) + if (SIMPLEQ_EMPTY(&sc->wmi_head) != 0) return; while (SIMPLEQ_FIRST(&sc->wmi_head) != NULL) { @@ -362,7 +362,7 @@ (void)memcpy(hex, ptr, 2); - if (!HEXCHAR(hex[0]) || !HEXCHAR(hex[1])) + if (HEXCHAR(hex[0]) == 0 || HEXCHAR(hex[1]) == 0) return AE_BAD_HEX_CONSTANT; bin[i] = strtoul(hex, NULL, 16) & 0xFF; @@ -499,6 +499,9 @@ struct wmi_t *wmi; ACPI_OBJECT_LIST arg; ACPI_OBJECT obj; + ACPI_HANDLE hdl; + + hdl = sc->sc_node->ad_handle; if (sc == NULL || obuf == NULL) return AE_BAD_PARAMETER; @@ -523,8 +526,7 @@ if (wmi->guid.nid != event) continue; - return AcpiEvaluateObject(sc->sc_node->ad_handle, "_WED", - &arg, obuf); + return AcpiEvaluateObject(hdl, "_WED", &arg, obuf); } return AE_NOT_FOUND; @@ -615,7 +617,7 @@ acpi_wmi_input(struct wmi_t *wmi, uint8_t flag, uint8_t idx) { - if (!(wmi->guid.flags & flag)) + if ((wmi->guid.flags & flag) == 0) return false; if (wmi->guid.count == 0x00) Index: src/sys/dev/acpi/wmi/wmi_acpivar.h diff -u src/sys/dev/acpi/wmi/wmi_acpivar.h:1.1 src/sys/dev/acpi/wmi/wmi_acpivar.h:1.2 --- src/sys/dev/acpi/wmi/wmi_acpivar.h:1.1 Thu Apr 8 12:14:19 2010 +++ src/sys/dev/acpi/wmi/wmi_acpivar.h Thu Apr 8 12:36:21 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: wmi_acpivar.h,v 1.1 2010/04/08 12:14:19 jruoho Exp $ */ +/* $NetBSD: wmi_acpivar.h,v 1.2 2010/04/08 12:36:21 jruoho Exp $ */ /*- * Copyright (c) 2009, 2010 Jukka Ruohonen @@ -27,11 +27,11 @@ * SUCH DAMAGE. */ -#ifndef _SYS_DEV_ACPI_WMI_ACPIVAR_H -#define _SYS_DEV_ACPI_WMI_ACPIVAR_H +#ifndef _SYS_DEV_ACPI_WMI_WMI_ACPIVAR_H +#define _SYS_DEV_ACPI_WMI_WMI_ACPIVAR_H #include -__KERNEL_RCSID(0, "$NetBSD: wmi_acpivar.h,v 1.1 2010/04/08 12:14:19 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wmi_acpivar.h,v 1.2 2010/04/08 12:36:21 jruoho Exp $"); ACPI_STATUS acpi_wmi_event_register(device_t, ACPI_NOTIFY_HANDLER); ACPI_STATUS acpi_wmi_event_deregister(device_t); @@ -47,4 +47,4 @@ ACPI_STATUS acpi_wmi_method(device_t, const char *, uint8_t, uint32_t, ACPI_BUFFER *, ACPI_BUFFER *); -#endif /* !_SYS_DEV_ACPI_WMI_ACPIVAR_H */ +#endif /* !_SYS_DEV_ACPI_WMI_WMI_ACPIVAR_H */
CVS commit: src/sys/dev/acpi/wmi
Module Name:src Committed By: jruoho Date: Thu Apr 8 09:35:15 UTC 2010 Added Files: src/sys/dev/acpi/wmi: files.wmi wmi_dell.c Log Message: Add WMI mappings for Dell laptops. Requested and tested by m...@. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/dev/acpi/wmi/files.wmi \ src/sys/dev/acpi/wmi/wmi_dell.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/dev/acpi/wmi/files.wmi diff -u /dev/null src/sys/dev/acpi/wmi/files.wmi:1.1 --- /dev/null Thu Apr 8 09:35:15 2010 +++ src/sys/dev/acpi/wmi/files.wmi Thu Apr 8 09:35:15 2010 @@ -0,0 +1,6 @@ +# $NetBSD: files.wmi,v 1.1 2010/04/08 09:35:15 jruoho Exp $ + +# Dell WMI mappings +device wmidell: sysmon_power +attach wmidell at acpiwmibus +file dev/acpi/wmi/wmi_dell.c wmidell Index: src/sys/dev/acpi/wmi/wmi_dell.c diff -u /dev/null src/sys/dev/acpi/wmi/wmi_dell.c:1.1 --- /dev/null Thu Apr 8 09:35:15 2010 +++ src/sys/dev/acpi/wmi/wmi_dell.c Thu Apr 8 09:35:15 2010 @@ -0,0 +1,231 @@ +/* $NetBSD: wmi_dell.c,v 1.1 2010/04/08 09:35:15 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. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: wmi_dell.c,v 1.1 2010/04/08 09:35:15 jruoho Exp $"); + +#include +#include + +#include +#include +#include + +#include + +#define _COMPONENT ACPI_RESOURCE_COMPONENT +ACPI_MODULE_NAME ("wmi_dell") + +#define WMI_DELL_HOTKEY_BRIGHTNESS_DOWN 0xE005 +#define WMI_DELL_HOTKEY_BRIGHTNESS_UP 0xE006 +#define WMI_DELL_HOTKEY_DISPLAY_CYCLE 0xE00B +#define WMI_DELL_HOTKEY_VOLUME_MUTE 0xE020 +#define WMI_DELL_HOTKEY_VOLUME_DOWN 0xE02E +#define WMI_DELL_HOTKEY_VOLUME_UP 0xE030 +/* WMI_DELL_HOTKEY_UNKNOWN 0x */ + +#define WMI_DELL_PSW_DISPLAY_CYCLE 0 +#define WMI_DELL_PSW_COUNT 1 + +#define WMI_DELL_GUID_EVENT "9DBB5994-A997-11DA-B012-B622A1EF5492" + +struct wmi_dell_softc { + device_t sc_dev; + device_t sc_parent; + struct sysmon_pswitch sc_smpsw[WMI_DELL_PSW_COUNT]; + bool sc_smpsw_valid; +}; + +static int wmi_dell_match(device_t, cfdata_t, void *); +static void wmi_dell_attach(device_t, device_t, void *); +static int wmi_dell_detach(device_t, int); +static void wmi_dell_notify_handler(ACPI_HANDLE, uint32_t, void *); +static bool wmi_dell_suspend(device_t, const pmf_qual_t *); +static bool wmi_dell_resume(device_t, const pmf_qual_t *); + +CFATTACH_DECL_NEW(wmidell, sizeof(struct wmi_dell_softc), +wmi_dell_match, wmi_dell_attach, wmi_dell_detach, NULL); + +static int +wmi_dell_match(device_t parent, cfdata_t match, void *aux) +{ + return acpi_wmi_guid_match(parent, WMI_DELL_GUID_EVENT); +} + +static void +wmi_dell_attach(device_t parent, device_t self, void *aux) +{ + struct wmi_dell_softc *sc = device_private(self); + ACPI_STATUS rv; + int e; + + sc->sc_dev = self; + sc->sc_parent = parent; + sc->sc_smpsw_valid = true; + + rv = acpi_wmi_event_register(parent, wmi_dell_notify_handler); + + if (ACPI_FAILURE(rv)) { + aprint_error(": failed to install WMI notify handler\n"); + return; + } + + aprint_naive("\n"); + aprint_normal(": Dell WMI mappings\n"); + + sc->sc_smpsw[WMI_DELL_PSW_DISPLAY_CYCLE].smpsw_name = + PSWITCH_HK_DISPLAY_CYCLE; + + sc->sc_smpsw[WMI_DELL_PSW_DISPLAY_CYCLE].smpsw_type = + PSWITCH_TYPE_HOTKEY; + + e = sysmon_pswitch_register(&sc->sc_smpsw[WMI_DELL_PSW_DISPLAY_CYCLE]); + + if (e != 0) + sc->sc_smpsw_valid = false; + + (void)pmf_device_register(self, wmi_dell_suspend, wmi_dell_resume); +} + +static int +wmi_