* [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com> @ 2009-11-02 17:00 ` Matthew Garrett 2009-11-02 18:19 ` Matthew Garrett 2009-11-03 4:05 ` [mjg@redhat.com: [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com>] Andy Isaacson 0 siblings, 2 replies; 6+ messages in thread From: Matthew Garrett @ 2009-11-02 17:00 UTC (permalink / raw) To: linux-acpi; +Cc: lenb, Matthew Garrett, Rezwanul Kabir dell-wmi: Add support for new Dell systems Newer Dell systems support HotKey features differently from legacy systems. A new vendor specifc HotKey SMBIOS table (Type 0xB2) is defined. This table contains a mapping between scancode and the corresponding predefined keyfunction ( i.e. keycode).. Also, a new ACPI-WMI event type (called KeyIDList) with a value of 0x0010 is defined. Any BIOS containing 0xB2 table will send hotkey notifications using KeyIDList event. This is Rezwanul's patch, updated to ensure that brightness events are not sent if the backlight is controlled via ACPI and with the default keycode for the display output switching altered to match desktop expectations. Signed-off-by: Rezwanul Kabir <Rezwanul_Kabir@dell.com> Signed-off-by: Matthew Garrett <mjg@redhat.com> --- drivers/platform/x86/dell-wmi.c | 129 +++++++++++++++++++++++++++++++++++---- 1 files changed, 116 insertions(+), 13 deletions(-) diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c index 0f900cc..67f3fe7 100644 --- a/drivers/platform/x86/dell-wmi.c +++ b/drivers/platform/x86/dell-wmi.c @@ -31,6 +31,7 @@ #include <acpi/acpi_drivers.h> #include <linux/acpi.h> #include <linux/string.h> +#include <linux/dmi.h> MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>"); MODULE_DESCRIPTION("Dell laptop WMI hotkeys driver"); @@ -38,6 +39,8 @@ MODULE_LICENSE("GPL"); #define DELL_EVENT_GUID "9DBB5994-A997-11DA-B012-B622A1EF5492" +static int acpi_video; + MODULE_ALIAS("wmi:"DELL_EVENT_GUID); struct key_entry { @@ -54,7 +57,7 @@ enum { KE_KEY, KE_SW, KE_IGNORE, KE_END }; * via the keyboard controller so should not be sent again. */ -static struct key_entry dell_wmi_keymap[] = { +static struct key_entry dell_legacy_wmi_keymap[] = { {KE_KEY, 0xe045, KEY_PROG1}, {KE_KEY, 0xe009, KEY_EJECTCD}, @@ -72,7 +75,7 @@ static struct key_entry dell_wmi_keymap[] = { /* The next device is at offset 6, the active devices are at offset 8 and the attached devices at offset 10 */ - {KE_KEY, 0xe00b, KEY_DISPLAYTOGGLE}, + {KE_KEY, 0xe00b, KEY_SWITCHVIDEOMODE}, {KE_IGNORE, 0xe00c, KEY_KBDILLUMTOGGLE}, @@ -96,6 +99,47 @@ static struct key_entry dell_wmi_keymap[] = { {KE_END, 0} }; +static bool dell_new_hk_type; + +struct dell_new_keymap_entry { + u16 scancode; + u16 keycode; +}; + +struct dell_hotkey_table { + struct dmi_header header; + struct dell_new_keymap_entry keymap[]; + +}; + +static struct key_entry *dell_new_wmi_keymap; + +static u16 bios_to_linux_keycode[256] = { + + KEY_MEDIA, KEY_NEXTSONG, KEY_PLAYPAUSE, KEY_PREVIOUSSONG, + KEY_STOPCD, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, + KEY_WWW, KEY_UNKNOWN, KEY_VOLUMEDOWN, KEY_MUTE, + KEY_VOLUMEUP, KEY_UNKNOWN, KEY_BATTERY, KEY_EJECTCD, + KEY_UNKNOWN, KEY_SLEEP, KEY_PROG1, KEY_BRIGHTNESSDOWN, + KEY_BRIGHTNESSUP, KEY_UNKNOWN, KEY_KBDILLUMTOGGLE, + KEY_UNKNOWN, KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN, + KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN, KEY_PROG2, + KEY_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + KEY_PROG3 +}; + + +static struct key_entry *dell_wmi_keymap = dell_legacy_wmi_keymap; + static struct input_dev *dell_wmi_input_dev; static struct key_entry *dell_wmi_get_entry_by_scancode(int code) @@ -164,24 +208,78 @@ static void dell_wmi_notify(u32 value, void *context) obj = (union acpi_object *)response.pointer; if (obj && obj->type == ACPI_TYPE_BUFFER) { - int *buffer = (int *)obj->buffer.pointer; - /* - * The upper bytes of the event may contain - * additional information, so mask them off for the - * scancode lookup - */ - key = dell_wmi_get_entry_by_scancode(buffer[1] & 0xFFFF); - if (key) { + int reported_key; + u16 *buffer_entry = (u16 *)obj->buffer.pointer; + if (dell_new_hk_type && (buffer_entry[1] != 0x10)) { + printk(KERN_INFO "dell-wmi: Received unknown WMI event" + " (0x%x)\n", buffer_entry[1]); + return; + } + + if (dell_new_hk_type) + reported_key = (int)buffer_entry[2]; + else + reported_key = (int)buffer_entry[1] & 0xffff; + + key = dell_wmi_get_entry_by_scancode(reported_key); + + if (!key) { + printk(KERN_INFO "dell-wmi: Unknown key %x pressed\n", + reported_key); + } else if ((key->keycode == KEY_BRIGHTNESSUP || + key->keycode == KEY_BRIGHTNESSDOWN) && acpi_video) { + /* Don't report brightness notifications that will also + * come via ACPI */ + return; + } else { input_report_key(dell_wmi_input_dev, key->keycode, 1); input_sync(dell_wmi_input_dev); input_report_key(dell_wmi_input_dev, key->keycode, 0); input_sync(dell_wmi_input_dev); - } else if (buffer[1] & 0xFFFF) - printk(KERN_INFO "dell-wmi: Unknown key %x pressed\n", - buffer[1] & 0xFFFF); + } } } + +static void setup_new_hk_map(const struct dmi_header *dm) +{ + + int i; + int hotkey_num = (dm->length-4)/sizeof(struct dell_new_keymap_entry); + struct dell_hotkey_table *table = + container_of(dm, struct dell_hotkey_table, header); + + dell_new_wmi_keymap = kzalloc((hotkey_num+1) * + sizeof(struct key_entry), GFP_KERNEL); + + for (i = 0; i < hotkey_num; i++) { + dell_new_wmi_keymap[i].type = KE_KEY; + dell_new_wmi_keymap[i].code = table->keymap[i].scancode; + dell_new_wmi_keymap[i].keycode = + (table->keymap[i].keycode > 255) ? 0 : + bios_to_linux_keycode[table->keymap[i].keycode]; + } + + dell_new_wmi_keymap[i].type = KE_END; + dell_new_wmi_keymap[i].code = 0; + dell_new_wmi_keymap[i].keycode = 0; + + dell_wmi_keymap = dell_new_wmi_keymap; + +} + + +static void find_hk_type(const struct dmi_header *dm, void *dummy) +{ + + if ((dm->type == 0xb2) && (dm->length > 6)) { + dell_new_hk_type = true; + setup_new_hk_map(dm); + } + +} + + static int __init dell_wmi_input_setup(void) { struct key_entry *key; @@ -226,6 +324,9 @@ static int __init dell_wmi_init(void) int err; if (wmi_has_guid(DELL_EVENT_GUID)) { + + dmi_walk(find_hk_type, NULL); + err = dell_wmi_input_setup(); if (err) @@ -240,6 +341,8 @@ static int __init dell_wmi_init(void) return err; } + acpi_video = acpi_video_backlight_support(); + } else printk(KERN_WARNING "dell-wmi: No known WMI GUID found\n"); -- 1.6.5.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com> 2009-11-02 17:00 ` [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com> Matthew Garrett @ 2009-11-02 18:19 ` Matthew Garrett 2009-12-10 5:20 ` [PATCH] dell-wmi: Add support for new Dell systems ([PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com>) Len Brown 2009-11-03 4:05 ` [mjg@redhat.com: [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com>] Andy Isaacson 1 sibling, 1 reply; 6+ messages in thread From: Matthew Garrett @ 2009-11-02 18:19 UTC (permalink / raw) To: linux-acpi; +Cc: lenb, Rezwanul Kabir Oops. I seem to have got the subject and attribution the wrong way round there. Len, can you fix that or should I resend? -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dell-wmi: Add support for new Dell systems ([PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com>) 2009-11-02 18:19 ` Matthew Garrett @ 2009-12-10 5:20 ` Len Brown 0 siblings, 0 replies; 6+ messages in thread From: Len Brown @ 2009-12-10 5:20 UTC (permalink / raw) To: Matthew Garrett; +Cc: linux-acpi, Rezwanul Kabir applied thanks, Len Brown, Intel Open Source Technology Center ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [mjg@redhat.com: [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com>] 2009-11-02 17:00 ` [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com> Matthew Garrett 2009-11-02 18:19 ` Matthew Garrett @ 2009-11-03 4:05 ` Andy Isaacson 2009-11-03 14:36 ` Matthew Garrett 1 sibling, 1 reply; 6+ messages in thread From: Andy Isaacson @ 2009-11-03 4:05 UTC (permalink / raw) To: Matthew Garrett; +Cc: linux-acpi > > dell-wmi: Add support for new Dell systems > > > > Newer Dell systems support HotKey features differently from legacy > > systems. A new vendor specifc HotKey SMBIOS table (Type 0xB2) is [snip] I get improved, but still not flawless, behavior with this patch, testing on my Dell E4300 with bios A05 (tested on top of approximately Ubuntu's 2.6.31-14.47 which is more or less 2.6.31.4). [ 7.068589] input: Dell WMI hotkeys as /devices/virtual/input/input8 [ 621.845305] dell-wmi: Received unknown WMI event 0x11 [ 1580.825651] dell-wmi: Received unknown WMI event 0x11 [ 1585.239914] dell-wmi: Received unknown WMI event 0x11 [ 1586.675563] dell-wmi: Received unknown WMI event 0x11 [ 1587.442542] dell-wmi: Received unknown WMI event 0x11 [ 1623.471288] keyboard.c: can't emulate rawmode for keycode 241 [ 1623.471301] keyboard.c: can't emulate rawmode for keycode 241 [ 1626.035593] keyboard.c: can't emulate rawmode for keycode 241 [ 1626.035605] keyboard.c: can't emulate rawmode for keycode 241 The keyboard.c complaints are from when I hit Fn-F8 (display switch). I can trigger the same complaint with Fn-Left (display brightness auto), with code 240. I don't see keyboard.c complaints from Fn-Right, which toggles the keyboard illumination and reports code 228. I don't know what event causes the "event 0x11" complaint. It seems to be purely cosmetic and not directly tied to user interaction? Fn-F8, Display Toggle, gives code 241 on the WMI event8 *and* code 227 on /dev/input/event4 "Video Bus". That seems ... wrong. There is an interesting behavior with Fn-Up and Fn-Down -- normally they do not trigger events on /dev/input/event8 although I can see ACPI interrupt count increasing in /proc/interrupts. However there is some state that I can toggle after about 5 minutes of futzing -- I still haven't figured out what the toggle is -- that causes event8 to show Brightness key events: Event: time 1257214081.248619, type 1 (Key), code 236 (?), value 0 Event: time 1257214081.248621, -------------- Report Sync ------------ Event: time 1257214087.837272, type 1 (Key), code 240 (Unknown), value 1 Event: time 1257214087.837278, -------------- Report Sync ------------ Event: time 1257214087.837282, type 1 (Key), code 240 (Unknown), value 0 Event: time 1257214087.837284, -------------- Report Sync ------------ Event: time 1257214089.908451, type 1 (Key), code 225 (Brightness up), value 1 Event: time 1257214089.908457, -------------- Report Sync ------------ Event: time 1257214089.908460, type 1 (Key), code 225 (Brightness up), value 0 Event: time 1257214089.908462, -------------- Report Sync ------------ Event: time 1257214095.235095, type 1 (Key), code 240 (Unknown), value 1 Event: time 1257214095.235102, -------------- Report Sync ------------ Event: time 1257214095.235106, type 1 (Key), code 240 (Unknown), value 0 Event: time 1257214095.235108, -------------- Report Sync ------------ ^C Other keys of interest: Fn-F3, a Battery glyph, gives keycode 236 Fn-F2, Battery with lighting bolt, gives no WMI key event but does increase /proc/interrupts' ACPI entry Fn-F7, "DCP", gives code 148 (Prog1) Volume keys and mute don't show WMI events (they work fine through the 8042 keyboard channel), but /dev/input/event8 does have event codes for them. -andy ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [mjg@redhat.com: [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com>] 2009-11-03 4:05 ` [mjg@redhat.com: [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com>] Andy Isaacson @ 2009-11-03 14:36 ` Matthew Garrett 2009-11-03 20:51 ` Andy Isaacson 0 siblings, 1 reply; 6+ messages in thread From: Matthew Garrett @ 2009-11-03 14:36 UTC (permalink / raw) To: Andy Isaacson; +Cc: linux-acpi On Mon, Nov 02, 2009 at 08:05:25PM -0800, Andy Isaacson wrote: > The keyboard.c complaints are from when I hit Fn-F8 (display switch). I > can trigger the same complaint with Fn-Left (display brightness auto), > with code 240. Hm. 241 is KEY_VIDEO_NEXT - I thought I'd changed that to be KEY_SWITCHVIDEOMODE? 240 is KEY_UNKNOWN. I don't think we've currently got an appropriate key to map the ALS button to. > I don't know what event causes the "event 0x11" complaint. It seems to > be purely cosmetic and not directly tied to user interaction? On my test system, that's the "battery with lightning flash" key. I have no idea what it's meant to do, or how we're meant to interpret that event. > Fn-F8, Display Toggle, gives code 241 on the WMI event8 *and* code 227 > on /dev/input/event4 "Video Bus". That seems ... wrong. Yup. Unfortunately on my system, it only gets delivered via WMI and not via ACPI, so doing the same thing as for the brightness keys doesn't look like it'll work. -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [mjg@redhat.com: [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com>] 2009-11-03 14:36 ` Matthew Garrett @ 2009-11-03 20:51 ` Andy Isaacson 0 siblings, 0 replies; 6+ messages in thread From: Andy Isaacson @ 2009-11-03 20:51 UTC (permalink / raw) To: Matthew Garrett; +Cc: linux-acpi Right, so, brown paper bag time... my testing last night was with completely the wrong kernel, with a previous version of the patch. > Hm. 241 is KEY_VIDEO_NEXT - I thought I'd changed that to be > KEY_SWITCHVIDEOMODE? 240 is KEY_UNKNOWN. I don't think we've currently > got an appropriate key to map the ALS button to. Verified with the correct kernel on E4300 with GMA, I get 227 on the WMI input event device and 227 on the ACPI Video Bus device. > > I don't know what event causes the "event 0x11" complaint. It seems to > > be purely cosmetic and not directly tied to user interaction? > > On my test system, that's the "battery with lightning flash" key. I have > no idea what it's meant to do, or how we're meant to interpret that > event. Yes, Fn-F2 (battery with lighting bolt) is the trigger for the "Received unknown WMI event (0x11)" message. It also toggles battery charge -- if I press it when the battery is charging, the battery stops charging: grep 'charging state' /proc/acpi/battery/BAT0/state charging state: charged Pressing Fn-F2 again gets the battery charging again and triggers another "unknown WMI event (0x11)" message. > > Fn-F8, Display Toggle, gives code 241 on the WMI event8 *and* code 227 > > on /dev/input/event4 "Video Bus". That seems ... wrong. > > Yup. Unfortunately on my system, it only gets delivered via WMI and not > via ACPI, so doing the same thing as for the brightness keys doesn't > look like it'll work. On an E6400 with NVidia graphics, I do get 227 on WMI and do not have a Video Bus object (but the VID1 event does show up in acpi_listen). Appears to be a difference between laptops with Intel GMA versus NVidia, sigh. so... condition delivery of KEY_SWITCHVIDEOMODE on whether the videobus object is present? Seems kinda nasty... -andy ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-12-10 5:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20091103034212.GF31712@vmware.com>
[not found] ` <20091102174748.GA21342@srcf.ucam.org>
2009-11-02 17:00 ` [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com> Matthew Garrett
2009-11-02 18:19 ` Matthew Garrett
2009-12-10 5:20 ` [PATCH] dell-wmi: Add support for new Dell systems ([PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com>) Len Brown
2009-11-03 4:05 ` [mjg@redhat.com: [PATCH] From: Rezwanul Kabir <Rezwanul_Kabir@dell.com>] Andy Isaacson
2009-11-03 14:36 ` Matthew Garrett
2009-11-03 20:51 ` Andy Isaacson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox