Define THINKPAD_EXTENDED_HOTKEYS to enable more hotkeys on ThinkPads.

This has only been tested on a T61.
XXX: Should we put THINKPAD_EXTENDED_HOTKEYS into a opt_*.h include
     (defflag) or just always enable it?
This commit is contained in:
christos 2013-03-30 03:09:44 +00:00
parent aea4bddf45
commit 262712cd9f
2 changed files with 136 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: thinkpad_acpi.c,v 1.42 2012/11/24 20:56:39 riastradh Exp $ */
/* $NetBSD: thinkpad_acpi.c,v 1.43 2013/03/30 03:09:44 christos Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: thinkpad_acpi.c,v 1.42 2012/11/24 20:56:39 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: thinkpad_acpi.c,v 1.43 2013/03/30 03:09:44 christos Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -55,15 +55,28 @@ typedef struct thinkpad_softc {
ACPI_HANDLE sc_powhdl;
ACPI_HANDLE sc_cmoshdl;
#define TP_PSW_SLEEP 0
#define TP_PSW_HIBERNATE 1
#define TP_PSW_DISPLAY_CYCLE 2
#define TP_PSW_LOCK_SCREEN 3
#define TP_PSW_BATTERY_INFO 4
#define TP_PSW_EJECT_BUTTON 5
#define TP_PSW_ZOOM_BUTTON 6
#define TP_PSW_VENDOR_BUTTON 7
#define TP_PSW_LAST 8
#define TP_PSW_SLEEP 0 /* FnF4 */
#define TP_PSW_HIBERNATE 1 /* FnF12 */
#define TP_PSW_DISPLAY_CYCLE 2 /* FnF7 */
#define TP_PSW_LOCK_SCREEN 3 /* FnF2 */
#define TP_PSW_BATTERY_INFO 4 /* FnF3 */
#define TP_PSW_EJECT_BUTTON 5 /* FnF9 */
#define TP_PSW_ZOOM_BUTTON 6 /* FnSPACE */
#define TP_PSW_VENDOR_BUTTON 7 /* ThinkVantage */
#define TP_PSW_FNF1_BUTTON 8 /* FnF1 */
#define TP_PSW_WIRELESS_BUTTON 9 /* FnF5 */
#define TP_PSW_WWAN_BUTTON 10 /* FnF6 */
#define TP_PSW_POINTER_BUTTON 11 /* FnF8 */
#define TP_PSW_FNF10_BUTTON 12 /* FnF10 */
#define TP_PSW_FNF11_BUTTON 13 /* FnF11 */
#define TP_PSW_BRIGHTNESS_UP 14
#define TP_PSW_BRIGHTNESS_DOWN 15
#define TP_PSW_THINKLIGHT 16
#define TP_PSW_VOLUME_UP 17
#define TP_PSW_VOLUME_DOWN 18
#define TP_PSW_VOLUME_MUTE 19
#define TP_PSW_LAST 20
struct sysmon_pswitch sc_smpsw[TP_PSW_LAST];
bool sc_smpsw_valid;
@ -83,16 +96,16 @@ typedef struct thinkpad_softc {
#define THINKPAD_NOTIFY_DisplayCycle 0x007
#define THINKPAD_NOTIFY_PointerSwitch 0x008
#define THINKPAD_NOTIFY_EjectButton 0x009
#define THINKPAD_NOTIFY_FnF10 0x00a
#define THINKPAD_NOTIFY_FnF10 0x00a /* XXX: Not seen on T61 */
#define THINKPAD_NOTIFY_FnF11 0x00b
#define THINKPAD_NOTIFY_HibernateButton 0x00c
#define THINKPAD_NOTIFY_BrightnessUp 0x010
#define THINKPAD_NOTIFY_BrightnessDown 0x011
#define THINKPAD_NOTIFY_ThinkLight 0x012
#define THINKPAD_NOTIFY_Zoom 0x014
#define THINKPAD_NOTIFY_VolumeUp 0x015
#define THINKPAD_NOTIFY_VolumeDown 0x016
#define THINKPAD_NOTIFY_VolumeMute 0x017
#define THINKPAD_NOTIFY_VolumeUp 0x015 /* XXX: Not seen on T61 */
#define THINKPAD_NOTIFY_VolumeDown 0x016 /* XXX: Not seen on T61 */
#define THINKPAD_NOTIFY_VolumeMute 0x017 /* XXX: Not seen on T61 */
#define THINKPAD_NOTIFY_ThinkVantage 0x018
#define THINKPAD_CMOS_BRIGHTNESS_UP 0x04
@ -245,6 +258,20 @@ thinkpad_attach(device_t parent, device_t self, void *opaque)
psw[TP_PSW_EJECT_BUTTON].smpsw_name = PSWITCH_HK_EJECT_BUTTON;
psw[TP_PSW_ZOOM_BUTTON].smpsw_name = PSWITCH_HK_ZOOM_BUTTON;
psw[TP_PSW_VENDOR_BUTTON].smpsw_name = PSWITCH_HK_VENDOR_BUTTON;
#ifdef THINKPAD_EXTENDED_HOTKEYS
psw[TP_PSW_FNF1_BUTTON].smpsw_name = PSWITCH_HK_FNF1_BUTTON;
psw[TP_PSW_WIRELESS_BUTTON].smpsw_name = PSWITCH_HK_WIRELESS_BUTTON;
psw[TP_PSW_WWAN_BUTTON].smpsw_name = PSWITCH_HK_WWAN_BUTTON;
psw[TP_PSW_POINTER_BUTTON].smpsw_name = PSWITCH_HK_POINTER_BUTTON;
psw[TP_PSW_FNF10_BUTTON].smpsw_name = PSWITCH_HK_FNF10_BUTTON;
psw[TP_PSW_FNF11_BUTTON].smpsw_name = PSWITCH_HK_FNF11_BUTTON;
psw[TP_PSW_BRIGHTNESS_UP].smpsw_name = PSWITCH_HK_BRIGHTNESS_UP;
psw[TP_PSW_BRIGHTNESS_DOWN].smpsw_name = PSWITCH_HK_BRIGHTNESS_DOWN;
psw[TP_PSW_THINKLIGHT].smpsw_name = PSWITCH_HK_THINKLIGHT;
psw[TP_PSW_VOLUME_UP].smpsw_name = PSWITCH_HK_VOLUME_UP;
psw[TP_PSW_VOLUME_DOWN].smpsw_name = PSWITCH_HK_VOLUME_DOWN;
psw[TP_PSW_VOLUME_MUTE].smpsw_name = PSWITCH_HK_VOLUME_MUTE;
#endif /* THINKPAD_EXTENDED_HOTKEYS */
for (i = 0; i < TP_PSW_LAST; i++) {
/* not supported yet */
@ -343,15 +370,39 @@ thinkpad_get_hotkeys(void *opaque)
switch (event) {
case THINKPAD_NOTIFY_BrightnessUp:
thinkpad_brightness_up(self);
#ifdef THINKPAD_EXTENDED_HOTKEYS
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_BRIGHTNESS_UP],
PSWITCH_EVENT_PRESSED);
#endif
break;
case THINKPAD_NOTIFY_BrightnessDown:
thinkpad_brightness_down(self);
#ifdef THINKPAD_EXTENDED_HOTKEYS
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_BRIGHTNESS_DOWN],
PSWITCH_EVENT_PRESSED);
#endif
break;
case THINKPAD_NOTIFY_WirelessSwitch:
thinkpad_wireless_toggle(sc);
#ifdef THINKPAD_EXTENDED_HOTKEYS
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_WIRELESS_BUTTON],
PSWITCH_EVENT_PRESSED);
#endif
break;
case THINKPAD_NOTIFY_wWANSwitch:
thinkpad_wwan_toggle(sc);
#ifdef THINKPAD_EXTENDED_HOTKEYS
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_WWAN_BUTTON],
PSWITCH_EVENT_PRESSED);
#endif
break;
case THINKPAD_NOTIFY_SleepButton:
if (sc->sc_smpsw_valid == false)
@ -409,6 +460,59 @@ thinkpad_get_hotkeys(void *opaque)
&sc->sc_smpsw[TP_PSW_VENDOR_BUTTON],
PSWITCH_EVENT_PRESSED);
break;
#ifdef THINKPAD_EXTENDED_HOTKEYS
case THINKPAD_NOTIFY_FnF1:
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_FNF1_BUTTON],
PSWITCH_EVENT_PRESSED);
break;
case THINKPAD_NOTIFY_PointerSwitch:
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_POINTER_BUTTON],
PSWITCH_EVENT_PRESSED);
break;
case THINKPAD_NOTIFY_FnF11:
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_FNF11_BUTTON],
PSWITCH_EVENT_PRESSED);
break;
case THINKPAD_NOTIFY_ThinkLight:
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_THINKLIGHT],
PSWITCH_EVENT_PRESSED);
break;
/*
* For some reason the next four aren't seen on my T61.
*/
case THINKPAD_NOTIFY_FnF10:
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_FNF10_BUTTON],
PSWITCH_EVENT_PRESSED);
break;
case THINKPAD_NOTIFY_VolumeUp:
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_VOLUME_UP],
PSWITCH_EVENT_PRESSED);
break;
case THINKPAD_NOTIFY_VolumeDown:
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_VOLUME_DOWN],
PSWITCH_EVENT_PRESSED);
break;
case THINKPAD_NOTIFY_VolumeMute:
if (sc->sc_smpsw_valid == false)
break;
sysmon_pswitch_event(&sc->sc_smpsw[TP_PSW_VOLUME_MUTE],
PSWITCH_EVENT_PRESSED);
break;
#else
case THINKPAD_NOTIFY_FnF1:
case THINKPAD_NOTIFY_PointerSwitch:
case THINKPAD_NOTIFY_FnF10:
@ -419,6 +523,7 @@ thinkpad_get_hotkeys(void *opaque)
case THINKPAD_NOTIFY_VolumeMute:
/* XXXJDM we should deliver hotkeys as keycodes */
break;
#endif /* THINKPAD_EXTENDED_HOTKEYS */
default:
aprint_debug_dev(self, "notify event 0x%03x\n", event);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: power.h,v 1.17 2012/07/15 18:31:35 pgoyette Exp $ */
/* $NetBSD: power.h,v 1.18 2013/03/30 03:09:44 christos Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -97,6 +97,20 @@
#define PSWITCH_HK_EJECT_BUTTON "eject-button"
#define PSWITCH_HK_ZOOM_BUTTON "zoom-button"
#define PSWITCH_HK_VENDOR_BUTTON "vendor-button"
#ifdef THINKPAD_EXTENDED_HOTKEYS
#define PSWITCH_HK_FNF1_BUTTON "fnf1-button"
#define PSWITCH_HK_WIRELESS_BUTTON "wireless-button"
#define PSWITCH_HK_WWAN_BUTTON "wWAN-button"
#define PSWITCH_HK_POINTER_BUTTON "pointer-button"
#define PSWITCH_HK_FNF10_BUTTON "fnf10-button"
#define PSWITCH_HK_FNF11_BUTTON "fnf11-button"
#define PSWITCH_HK_BRIGHTNESS_UP "brightness-up"
#define PSWITCH_HK_BRIGHTNESS_DOWN "brightness-down"
#define PSWITCH_HK_THINKLIGHT "thinklight"
#define PSWITCH_HK_VOLUME_UP "volume-up"
#define PSWITCH_HK_VOLUME_DOWN "volume-down"
#define PSWITCH_HK_VOLUME_MUTE "volume-mute"
#endif /* THINKPAD_EXTENDED_HOTKEYS */
#define PSWITCH_EVENT_PRESSED 0 /* button pressed, lid closed, AC off */
#define PSWITCH_EVENT_RELEASED 1 /* button released, lid open, AC on */