Module Name: src Committed By: jruoho Date: Sun Oct 24 08:54:15 UTC 2010
Modified Files: src/distrib/sets/lists/man: mi src/share/man/man4: acpiwmi.4 src/sys/arch/amd64/conf: GENERIC src/sys/arch/i386/conf: GENERIC src/sys/dev/acpi/wmi: files.wmi Added Files: src/sys/dev/acpi/wmi: wmi_msi.c Log Message: Add acpiwmi(4) mappings for MSI laptops. XXX: It may be necessary to fix PR # 43659 before this works on all models. To generate a diff of this commit: cvs rdiff -u -r1.1241 -r1.1242 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/acpiwmi.4 cvs rdiff -u -r1.286 -r1.287 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.994 -r1.995 src/sys/arch/i386/conf/GENERIC cvs rdiff -u -r1.6 -r1.7 src/sys/dev/acpi/wmi/files.wmi cvs rdiff -u -r0 -r1.1 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/distrib/sets/lists/man/mi diff -u src/distrib/sets/lists/man/mi:1.1241 src/distrib/sets/lists/man/mi:1.1242 --- src/distrib/sets/lists/man/mi:1.1241 Tue Oct 19 11:58:00 2010 +++ src/distrib/sets/lists/man/mi Sun Oct 24 08:54:14 2010 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1241 2010/10/19 11:58:00 pgoyette Exp $ +# $NetBSD: mi,v 1.1242 2010/10/24 08:54:14 jruoho Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -1719,6 +1719,7 @@ ./usr/share/man/cat4/wm.0 man-sys-catman .cat ./usr/share/man/cat4/wmidell.0 man-sys-catman .cat ./usr/share/man/cat4/wmihp.0 man-sys-catman .cat +./usr/share/man/cat4/wmimsi.0 man-sys-catman .cat ./usr/share/man/cat4/wpi.0 man-sys-catman .cat ./usr/share/man/cat4/wscons.0 man-sys-catman .cat ./usr/share/man/cat4/wsdisplay.0 man-sys-catman .cat @@ -4326,6 +4327,7 @@ ./usr/share/man/html4/wm.html man-sys-htmlman html ./usr/share/man/html4/wmidell.html man-sys-htmlman html ./usr/share/man/html4/wmihp.html man-sys-htmlman html +./usr/share/man/html4/wmimsi.html man-sys-htmlman html ./usr/share/man/html4/wpi.html man-sys-htmlman html ./usr/share/man/html4/wscons.html man-sys-htmlman html ./usr/share/man/html4/wsdisplay.html man-sys-htmlman html @@ -6871,6 +6873,7 @@ ./usr/share/man/man4/wm.4 man-sys-man .man ./usr/share/man/man4/wmidell.4 man-sys-man .man ./usr/share/man/man4/wmihp.4 man-sys-man .man +./usr/share/man/man4/wmimsi.4 man-sys-man .man ./usr/share/man/man4/wpi.4 man-sys-man .man ./usr/share/man/man4/wscons.4 man-sys-man .man ./usr/share/man/man4/wsdisplay.4 man-sys-man .man Index: src/share/man/man4/acpiwmi.4 diff -u src/share/man/man4/acpiwmi.4:1.4 src/share/man/man4/acpiwmi.4:1.5 --- src/share/man/man4/acpiwmi.4:1.4 Thu Apr 8 18:31:53 2010 +++ src/share/man/man4/acpiwmi.4 Sun Oct 24 08:54:15 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: acpiwmi.4,v 1.4 2010/04/08 18:31:53 jruoho Exp $ +.\" $NetBSD: acpiwmi.4,v 1.5 2010/10/24 08:54:15 jruoho Exp $ .\" .\" Copyright (c) 2010 Jukka Ruohonen <jruoho...@iki.fi> .\" All rights reserved. @@ -36,10 +36,11 @@ .Cd "acpiwmibus* at acpiwmi?" .Cd "wmidell* at acpiwmibus?" .Cd "wmihp* at acpiwmibus?" +.Cd "wmimsi* at acpiwmibus?" .Sh DESCRIPTION The .Nm -driver provides an +device driver provides an .Tn ACPI interface for Windows Management Instrumentation .Pq Tn WMI . @@ -57,13 +58,16 @@ Dell laptops .It Sy wmihp Hewlett-Packard laptops +.It Sy wmimsi +MSI laptops .El .Pp The functionality varies from vendor to vendor. Typically the interface is used for function and hotkey handling, but additional features may be present. .Sh SEE ALSO -.Xr acpi 4 +.Xr acpi 4 , +.Xr acpidalb 4 .Rs .%A Microsoft Corporation .%D December 4, 2001 @@ -78,19 +82,9 @@ .Sh AUTHORS .An Jukka Ruohonen .Aq jruoho...@iki.fi -wrote the actual +wrote .Nm -as well as -.Sy wmidell -and -.Sy wmihp . -The -.Sy wmihp -was based on the earlier work done by -.An Michael Gmelin -.Aq free...@grem.de -for -.Fx . +and most of the mappings. .Sh CAVEATS While .Tn WMI @@ -100,5 +94,5 @@ .Pp The .Sy wmihp -driver conflicts with +driver may conflict with .Xr hpqlb 4 . Index: src/sys/arch/amd64/conf/GENERIC diff -u src/sys/arch/amd64/conf/GENERIC:1.286 src/sys/arch/amd64/conf/GENERIC:1.287 --- src/sys/arch/amd64/conf/GENERIC:1.286 Tue Oct 12 19:10:49 2010 +++ src/sys/arch/amd64/conf/GENERIC Sun Oct 24 08:54:14 2010 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.286 2010/10/12 19:10:49 gsutre Exp $ +# $NetBSD: GENERIC,v 1.287 2010/10/24 08:54:14 jruoho Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.286 $" +#ident "GENERIC-$Revision: 1.287 $" maxusers 64 # estimated number of users @@ -310,6 +310,7 @@ sdmmc* at wb? # SD/MMC bus wmidell* at acpiwmibus? # Dell WMI mappings #wmihp* at acpiwmibus? # HP WMI mappings +wmimsi* at acpiwmibus? # MSI WMI mappings #apm0 at mainbus0 # Advanced power management Index: src/sys/arch/i386/conf/GENERIC diff -u src/sys/arch/i386/conf/GENERIC:1.994 src/sys/arch/i386/conf/GENERIC:1.995 --- src/sys/arch/i386/conf/GENERIC:1.994 Tue Oct 12 19:10:50 2010 +++ src/sys/arch/i386/conf/GENERIC Sun Oct 24 08:54:14 2010 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.994 2010/10/12 19:10:50 gsutre Exp $ +# $NetBSD: GENERIC,v 1.995 2010/10/24 08:54:14 jruoho Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.994 $" +#ident "GENERIC-$Revision: 1.995 $" maxusers 64 # estimated number of users @@ -390,6 +390,7 @@ sdmmc* at wb? # SD/MMC bus wmidell* at acpiwmibus? # Dell WMI mappings #wmihp* at acpiwmibus? # HP WMI mappings +wmimsi* at acpiwmibus? # MSI WMI mappings wss* at acpi? # NeoMagic 256AV in wss mode ym* at acpi? # Yamaha OPL3-SA[23] audio Index: src/sys/dev/acpi/wmi/files.wmi diff -u src/sys/dev/acpi/wmi/files.wmi:1.6 src/sys/dev/acpi/wmi/files.wmi:1.7 --- src/sys/dev/acpi/wmi/files.wmi:1.6 Fri Aug 6 22:45:00 2010 +++ src/sys/dev/acpi/wmi/files.wmi Sun Oct 24 08:54:15 2010 @@ -1,4 +1,4 @@ -# $NetBSD: files.wmi,v 1.6 2010/08/06 22:45:00 jruoho Exp $ +# $NetBSD: files.wmi,v 1.7 2010/10/24 08:54:15 jruoho Exp $ define acpiwmibus { } @@ -16,3 +16,8 @@ device wmihp: sysmon_envsys attach wmihp at acpiwmibus file dev/acpi/wmi/wmi_hp.c wmihp + +# MSI WMI mappings +device wmimsi +attach wmimsi at acpiwmibus +file dev/acpi/wmi/wmi_msi.c wmimsi Added files: Index: src/sys/dev/acpi/wmi/wmi_msi.c diff -u /dev/null src/sys/dev/acpi/wmi/wmi_msi.c:1.1 --- /dev/null Sun Oct 24 08:54:15 2010 +++ src/sys/dev/acpi/wmi/wmi_msi.c Sun Oct 24 08:54:15 2010 @@ -0,0 +1,194 @@ +/* $NetBSD: wmi_msi.c,v 1.1 2010/10/24 08:54:15 jruoho Exp $ */ + +/*- + * Copyright (c) 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 <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: wmi_msi.c,v 1.1 2010/10/24 08:54:15 jruoho Exp $"); + +#include <sys/param.h> +#include <sys/device.h> + +#include <dev/acpi/acpireg.h> +#include <dev/acpi/acpivar.h> +#include <dev/acpi/wmi/wmi_acpivar.h> + +#define _COMPONENT ACPI_RESOURCE_COMPONENT +ACPI_MODULE_NAME ("wmi_msi") + +#define WMI_MSI_HOTKEY_BRIGHTNESS_UP 0xD0 +#define WMI_MSI_HOTKEY_BRIGHTNESS_DOWN 0xD1 +#define WMI_MSI_HOTKEY_VOLUME_UP 0xD2 +#define WMI_MSI_HOTKEY_VOLUME_DOWN 0xD3 +/* WMI_MSI_HOTKEY_UNKNOWN 0xXXXX */ + +#define WMI_MSI_GUID_EVENT "B6F3EEF2-3D2F-49DC-9DE3-85BCE18C62F2" + +struct wmi_msi_softc { + device_t sc_dev; + device_t sc_parent; +}; + +static int wmi_msi_match(device_t, cfdata_t, void *); +static void wmi_msi_attach(device_t, device_t, void *); +static int wmi_msi_detach(device_t, int); +static void wmi_msi_notify_handler(ACPI_HANDLE, uint32_t, void *); +static bool wmi_msi_suspend(device_t, const pmf_qual_t *); +static bool wmi_msi_resume(device_t, const pmf_qual_t *); + +CFATTACH_DECL_NEW(wmimsi, sizeof(struct wmi_msi_softc), + wmi_msi_match, wmi_msi_attach, wmi_msi_detach, NULL); + +static int +wmi_msi_match(device_t parent, cfdata_t match, void *aux) +{ + return acpi_wmi_guid_match(parent, WMI_MSI_GUID_EVENT); +} + +static void +wmi_msi_attach(device_t parent, device_t self, void *aux) +{ + struct wmi_msi_softc *sc = device_private(self); + ACPI_STATUS rv; + + sc->sc_dev = self; + sc->sc_parent = parent; + + rv = acpi_wmi_event_register(parent, wmi_msi_notify_handler); + + if (ACPI_FAILURE(rv)) { + aprint_error(": failed to install WMI notify handler\n"); + return; + } + + aprint_naive("\n"); + aprint_normal(": MSI WMI mappings\n"); + + (void)pmf_device_register(self, wmi_msi_suspend, wmi_msi_resume); +} + +static int +wmi_msi_detach(device_t self, int flags) +{ + struct wmi_msi_softc *sc = device_private(self); + device_t parent = sc->sc_parent; + + (void)pmf_device_deregister(self); + (void)acpi_wmi_event_deregister(parent); + + return 0; +} + +static bool +wmi_msi_suspend(device_t self, const pmf_qual_t *qual) +{ + struct wmi_msi_softc *sc = device_private(self); + device_t parent = sc->sc_parent; + + (void)acpi_wmi_event_deregister(parent); + + return true; +} + +static bool +wmi_msi_resume(device_t self, const pmf_qual_t *qual) +{ + struct wmi_msi_softc *sc = device_private(self); + device_t parent = sc->sc_parent; + + (void)acpi_wmi_event_register(parent, wmi_msi_notify_handler); + + return true; +} + +static void +wmi_msi_notify_handler(ACPI_HANDLE hdl, uint32_t evt, void *aux) +{ + struct wmi_msi_softc *sc; + device_t self = aux; + ACPI_OBJECT *obj; + ACPI_BUFFER buf; + ACPI_STATUS rv; + uint32_t val; + + buf.Pointer = NULL; + + sc = device_private(self); + rv = acpi_wmi_event_get(sc->sc_parent, evt, &buf); + + if (ACPI_FAILURE(rv)) + goto out; + + obj = buf.Pointer; + + if (obj->Type != ACPI_TYPE_INTEGER) { + rv = AE_TYPE; + goto out; + } + + if (obj->Integer.Value > UINT32_MAX) { + rv = AE_AML_NUMERIC_OVERFLOW; + goto out; + } + + val = obj->Integer.Value; + + switch (val) { + + case WMI_MSI_HOTKEY_BRIGHTNESS_DOWN: + pmf_event_inject(NULL, PMFE_DISPLAY_BRIGHTNESS_DOWN); + break; + + case WMI_MSI_HOTKEY_BRIGHTNESS_UP: + pmf_event_inject(NULL, PMFE_DISPLAY_BRIGHTNESS_UP); + break; + + case WMI_MSI_HOTKEY_VOLUME_DOWN: + pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_DOWN); + break; + + case WMI_MSI_HOTKEY_VOLUME_UP: + pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_UP); + break; + + default: + aprint_normal_dev(sc->sc_dev, + "unknown key 0x%02X for event 0x%02X\n", val, evt); + break; + } + +out: + if (buf.Pointer != NULL) + ACPI_FREE(buf.Pointer); + + if (ACPI_FAILURE(rv)) + aprint_error_dev(sc->sc_dev, "failed to get data for " + "event 0x%02X: %s\n", evt, AcpiFormatException(rv)); +}