Add a skeleton driver for Asus EeePC acpiwmi(4) mappings.

This commit is contained in:
jruoho 2011-02-16 07:30:26 +00:00
parent 3b6fd6df32
commit 7e0b5b7921
10 changed files with 306 additions and 12 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1288 2011/02/14 08:50:38 hannken Exp $ # $NetBSD: mi,v 1.1289 2011/02/16 07:30:27 jruoho Exp $
# #
# Note: don't delete entries from here - mark them as "obsolete" instead. # Note: don't delete entries from here - mark them as "obsolete" instead.
# #
@ -1762,6 +1762,7 @@
./usr/share/man/cat4/wi.0 man-sys-catman .cat ./usr/share/man/cat4/wi.0 man-sys-catman .cat
./usr/share/man/cat4/wm.0 man-sys-catman .cat ./usr/share/man/cat4/wm.0 man-sys-catman .cat
./usr/share/man/cat4/wmidell.0 man-sys-catman .cat ./usr/share/man/cat4/wmidell.0 man-sys-catman .cat
./usr/share/man/cat4/wmieeepc.0 man-sys-catman .cat
./usr/share/man/cat4/wmihp.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/wmimsi.0 man-sys-catman .cat
./usr/share/man/cat4/wpi.0 man-sys-catman .cat ./usr/share/man/cat4/wpi.0 man-sys-catman .cat
@ -4443,6 +4444,7 @@
./usr/share/man/html4/wi.html man-sys-htmlman html ./usr/share/man/html4/wi.html man-sys-htmlman html
./usr/share/man/html4/wm.html man-sys-htmlman html ./usr/share/man/html4/wm.html man-sys-htmlman html
./usr/share/man/html4/wmidell.html man-sys-htmlman html ./usr/share/man/html4/wmidell.html man-sys-htmlman html
./usr/share/man/html4/wmieeepc.html man-sys-htmlman html
./usr/share/man/html4/wmihp.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/wmimsi.html man-sys-htmlman html
./usr/share/man/html4/wpi.html man-sys-htmlman html ./usr/share/man/html4/wpi.html man-sys-htmlman html
@ -7059,6 +7061,7 @@
./usr/share/man/man4/wi.4 man-sys-man .man ./usr/share/man/man4/wi.4 man-sys-man .man
./usr/share/man/man4/wm.4 man-sys-man .man ./usr/share/man/man4/wm.4 man-sys-man .man
./usr/share/man/man4/wmidell.4 man-sys-man .man ./usr/share/man/man4/wmidell.4 man-sys-man .man
./usr/share/man/man4/wmieeepc.4 man-sys-man .man
./usr/share/man/man4/wmihp.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/wmimsi.4 man-sys-man .man
./usr/share/man/man4/wpi.4 man-sys-man .man ./usr/share/man/man4/wpi.4 man-sys-man .man

View File

@ -1,4 +1,4 @@
# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1506 $> # LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1507 $>
# #
# #
# [Note: This file does not mention every change made to the NetBSD source tree. # [Note: This file does not mention every change made to the NetBSD source tree.
@ -614,8 +614,8 @@ Changes from NetBSD 5.0 to NetBSD 6.0:
hpcarm: Add support for Sharp W-ZERO3 series. [nonaka 20100417] hpcarm: Add support for Sharp W-ZERO3 series. [nonaka 20100417]
acpi(4): The sysctl(8) tree was reorganized into hw.acpi. acpi(4): The sysctl(8) tree was reorganized into hw.acpi.
[jruoho 20100419] [jruoho 20100419]
acpiwmi(4): Add three mappings, wmidell(4), wmihp(4), and wmimsi(4). acpiwmi(4): Add four mappings; wmidell(4), wmieeepc(4),
[jruoho 20100419] wmihp(4), and wmimsi(4). [jruoho 20100419]
kernel: Enforce RLIMIT_FSIZE above the file system. This fixes kernel: Enforce RLIMIT_FSIZE above the file system. This fixes
the feature for some file systems. [pooka 20100423] the feature for some file systems. [pooka 20100423]
libc: Added a space-efficient write-once database (cdbr(3), cdbw(3)). libc: Added a space-efficient write-once database (cdbr(3), cdbw(3)).

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.550 2011/02/14 08:50:39 hannken Exp $ # $NetBSD: Makefile,v 1.551 2011/02/16 07:30:26 jruoho Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93 # @(#)Makefile 8.1 (Berkeley) 6/18/93
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \ MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@ -155,6 +155,7 @@ MLINKS+=drm.4 viadrm.4
MLINKS+=acpiec.4 acpiecdt.4 MLINKS+=acpiec.4 acpiecdt.4
MLINKS+=acpivga.4 acpiout.4 MLINKS+=acpivga.4 acpiout.4
MLINKS+=acpiwmi.4 wmidell.4 \ MLINKS+=acpiwmi.4 wmidell.4 \
acpiwmi.4 wmieeepc.4 \
acpiwmi.4 wmihp.4 \ acpiwmi.4 wmihp.4 \
acpiwmi.4 wmimsi.4 acpiwmi.4 wmimsi.4
MLINKS+=aibs.4 aiboost.4 MLINKS+=aibs.4 aiboost.4

View File

@ -1,4 +1,4 @@
.\" $NetBSD: acpiwmi.4,v 1.6 2010/10/25 07:34:30 wiz Exp $ .\" $NetBSD: acpiwmi.4,v 1.7 2011/02/16 07:30:26 jruoho Exp $
.\" .\"
.\" Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi> .\" Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi>
.\" All rights reserved. .\" All rights reserved.
@ -24,7 +24,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE. .\" POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd October 24, 2010 .Dd February 16, 2011
.Dt ACPIWMI 4 .Dt ACPIWMI 4
.Os .Os
.Sh NAME .Sh NAME
@ -35,6 +35,7 @@
.Cd "acpiwmi* at acpi?" .Cd "acpiwmi* at acpi?"
.Cd "acpiwmibus* at acpiwmi?" .Cd "acpiwmibus* at acpiwmi?"
.Cd "wmidell* at acpiwmibus?" .Cd "wmidell* at acpiwmibus?"
.Cd "wmieeepc* at acpiwmibus?"
.Cd "wmihp* at acpiwmibus?" .Cd "wmihp* at acpiwmibus?"
.Cd "wmimsi* at acpiwmibus?" .Cd "wmimsi* at acpiwmibus?"
.Sh DESCRIPTION .Sh DESCRIPTION
@ -56,6 +57,8 @@ mappings are supported:
.Bl -tag -width "wmidell " -offset indent .Bl -tag -width "wmidell " -offset indent
.It Sy wmidell .It Sy wmidell
Dell laptops Dell laptops
.It Sy wmieeepc
Some models of Asus Eee PC
.It Sy wmihp .It Sy wmihp
Hewlett-Packard laptops Hewlett-Packard laptops
.It Sy wmimsi .It Sy wmimsi

View File

@ -1,4 +1,4 @@
# $NetBSD: ALL,v 1.287 2011/02/14 08:50:39 hannken Exp $ # $NetBSD: ALL,v 1.288 2011/02/16 07:30:27 jruoho Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
# #
# ALL machine description file # ALL machine description file
@ -17,7 +17,7 @@ include "arch/i386/conf/std.i386"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "ALL-$Revision: 1.287 $" #ident "ALL-$Revision: 1.288 $"
maxusers 64 # estimated number of users maxusers 64 # estimated number of users
@ -400,6 +400,7 @@ ug* at acpi? # Abit uGuru Hardware monitor
wb* at acpi? # Winbond W83L518D SD/MMC reader wb* at acpi? # Winbond W83L518D SD/MMC reader
sdmmc* at wb? # SD/MMC bus sdmmc* at wb? # SD/MMC bus
wmidell* at acpiwmibus? # Dell WMI mappings wmidell* at acpiwmibus? # Dell WMI mappings
wmieeepc* at acpiwmibus? # Asus Eee PC WMI mappings
wmihp* at acpiwmibus? # HP WMI mappings wmihp* at acpiwmibus? # HP WMI mappings
wmimsi* at acpiwmibus? # MSI WMI mappings wmimsi* at acpiwmibus? # MSI WMI mappings
wss* at acpi? # NeoMagic 256AV in wss mode wss* at acpi? # NeoMagic 256AV in wss mode

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.1015 2011/02/15 12:06:22 jmcneill Exp $ # $NetBSD: GENERIC,v 1.1016 2011/02/16 07:30:27 jruoho Exp $
# #
# GENERIC machine description file # GENERIC machine description file
# #
@ -22,7 +22,7 @@ include "arch/i386/conf/std.i386"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.1015 $" #ident "GENERIC-$Revision: 1.1016 $"
maxusers 64 # estimated number of users maxusers 64 # estimated number of users
@ -391,6 +391,7 @@ vald* at acpi? # Toshiba Libretto hotkeys
wb* at acpi? # Winbond W83L518D SD/MMC reader wb* at acpi? # Winbond W83L518D SD/MMC reader
sdmmc* at wb? # SD/MMC bus sdmmc* at wb? # SD/MMC bus
wmidell* at acpiwmibus? # Dell WMI mappings wmidell* at acpiwmibus? # Dell WMI mappings
wmieeepc* at acpiwmibus? # Asus Eee PC WMI mappings
#wmihp* at acpiwmibus? # HP WMI mappings #wmihp* at acpiwmibus? # HP WMI mappings
wmimsi* at acpiwmibus? # MSI WMI mappings wmimsi* at acpiwmibus? # MSI WMI mappings
wss* at acpi? # NeoMagic 256AV in wss mode wss* at acpi? # NeoMagic 256AV in wss mode

View File

@ -1,4 +1,4 @@
# $NetBSD: files.wmi,v 1.7 2010/10/24 08:54:15 jruoho Exp $ # $NetBSD: files.wmi,v 1.8 2011/02/16 07:30:26 jruoho Exp $
define acpiwmibus { } define acpiwmibus { }
@ -12,6 +12,11 @@ device wmidell: sysmon_power
attach wmidell at acpiwmibus attach wmidell at acpiwmibus
file dev/acpi/wmi/wmi_dell.c wmidell file dev/acpi/wmi/wmi_dell.c wmidell
# Asus Eee PC WMI mappings
device wmieeepc: sysmon_power
attach wmieeepc at acpiwmibus
file dev/acpi/wmi/wmi_eeepc.c wmieeepc
# HP WMI mappings # HP WMI mappings
device wmihp: sysmon_envsys device wmihp: sysmon_envsys
attach wmihp at acpiwmibus attach wmihp at acpiwmibus

View File

@ -0,0 +1,257 @@
/* $NetBSD: wmi_eeepc.c,v 1.1 2011/02/16 07:30:26 jruoho Exp $ */
/*-
* Copyright (c) 2011 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_eeepc.c,v 1.1 2011/02/16 07:30:26 jruoho Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/module.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_eeepc")
#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_DISPLAY_CYCLE 0xCC
#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
#define WMI_EEEPC_GUID_EVENT "ABBC0F72-8EA1-11D1-00A0-C90629100000"
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;
};
static int wmi_eeepc_match(device_t, cfdata_t, void *);
static void wmi_eeepc_attach(device_t, device_t, void *);
static int wmi_eeepc_detach(device_t, int);
static void wmi_eeepc_notify_handler(ACPI_HANDLE, uint32_t, void *);
static bool wmi_eeepc_suspend(device_t, const pmf_qual_t *);
static bool wmi_eeepc_resume(device_t, const pmf_qual_t *);
CFATTACH_DECL_NEW(wmieeepc, sizeof(struct wmi_eeepc_softc),
wmi_eeepc_match, wmi_eeepc_attach, wmi_eeepc_detach, NULL);
static int
wmi_eeepc_match(device_t parent, cfdata_t match, void *aux)
{
return acpi_wmi_guid_match(parent, WMI_EEEPC_GUID_EVENT);
}
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);
if (ACPI_FAILURE(rv)) {
aprint_error(": failed to install WMI notify handler\n");
return;
}
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;
(void)pmf_device_register(self, wmi_eeepc_suspend, wmi_eeepc_resume);
}
static int
wmi_eeepc_detach(device_t self, int flags)
{
struct wmi_eeepc_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_eeepc_suspend(device_t self, const pmf_qual_t *qual)
{
struct wmi_eeepc_softc *sc = device_private(self);
device_t parent = sc->sc_parent;
(void)acpi_wmi_event_deregister(parent);
return true;
}
static bool
wmi_eeepc_resume(device_t self, const pmf_qual_t *qual)
{
struct wmi_eeepc_softc *sc = device_private(self);
device_t parent = sc->sc_parent;
(void)acpi_wmi_event_register(parent, wmi_eeepc_notify_handler);
return true;
}
static void
wmi_eeepc_notify_handler(ACPI_HANDLE hdl, uint32_t evt, void *aux)
{
static const int dc = WMI_EEEPC_PSW_DISPLAY_CYCLE;
struct wmi_eeepc_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_LIMIT;
goto out;
}
val = obj->Integer.Value;
switch (val) {
case WMI_EEEPC_HK_VOLUME_UP:
pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_UP);
break;
case WMI_EEEPC_HK_VOLUME_DOWN:
pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_DOWN);
break;
case WMI_EEEPC_HK_VOLUME_MUTE:
pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_TOGGLE);
break;
case WMI_EEEPC_HK_DISPLAY_CYCLE:
if (sc->sc_smpsw_valid != true) {
rv = AE_ABORT_METHOD;
break;
}
sysmon_pswitch_event(&sc->sc_smpsw[dc], PSWITCH_EVENT_PRESSED);
break;
case WMI_EEEPC_HK_DISPLAY_OFF:
break;
default:
aprint_debug_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));
}
MODULE(MODULE_CLASS_DRIVER, wmieeepc, NULL);
#ifdef _MODULE
#include "ioconf.c"
#endif
static int
wmieeepc_modcmd(modcmd_t cmd, void *aux)
{
int rv = 0;
switch (cmd) {
case MODULE_CMD_INIT:
#ifdef _MODULE
rv = config_init_component(cfdriver_ioconf_wmieeepc,
cfattach_ioconf_wmieeepc, cfdata_ioconf_wmieeepc);
#endif
break;
case MODULE_CMD_FINI:
#ifdef _MODULE
rv = config_fini_component(cfdriver_ioconf_wmieeepc,
cfattach_ioconf_wmieeepc, cfdata_ioconf_wmieeepc);
#endif
break;
default:
rv = ENOTTY;
}
return rv;
}

View File

@ -0,0 +1,13 @@
# $NetBSD: Makefile,v 1.1 2011/02/16 07:30:28 jruoho Exp $
.include "../Makefile.inc"
.PATH: ${S}/dev/acpi/wmi
KMOD= wmieeepc
IOCONF= wmieeepc.ioconf
SRCS= wmi_eeepc.c
WARNS= 4
.include <bsd.kmodule.mk>

View File

@ -0,0 +1,10 @@
# $NetBSD: wmieeepc.ioconf,v 1.1 2011/02/16 07:30:28 jruoho Exp $
ioconf wmieeepc
include "conf/files"
include "dev/acpi/wmi/files.wmi"
pseudo-root acpiwmi*
wmieeepc* at acpiwmibus?