Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Dell WMI hotkeys |
| 3 | * |
| 4 | * Copyright (C) 2008 Red Hat <mjg@redhat.com> |
| 5 | * |
| 6 | * Portions based on wistron_btns.c: |
| 7 | * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz> |
| 8 | * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org> |
| 9 | * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | */ |
| 25 | |
| 26 | #include <linux/kernel.h> |
| 27 | #include <linux/module.h> |
| 28 | #include <linux/init.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 29 | #include <linux/slab.h> |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 30 | #include <linux/types.h> |
| 31 | #include <linux/input.h> |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 32 | #include <linux/input/sparse-keymap.h> |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 33 | #include <acpi/acpi_drivers.h> |
| 34 | #include <linux/acpi.h> |
| 35 | #include <linux/string.h> |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 36 | #include <linux/dmi.h> |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 37 | |
| 38 | MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>"); |
| 39 | MODULE_DESCRIPTION("Dell laptop WMI hotkeys driver"); |
| 40 | MODULE_LICENSE("GPL"); |
| 41 | |
| 42 | #define DELL_EVENT_GUID "9DBB5994-A997-11DA-B012-B622A1EF5492" |
| 43 | |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 44 | static int acpi_video; |
| 45 | |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 46 | MODULE_ALIAS("wmi:"DELL_EVENT_GUID); |
| 47 | |
Mario Limonciello | 5cab009 | 2009-06-10 19:40:47 +0000 | [diff] [blame] | 48 | /* |
| 49 | * Certain keys are flagged as KE_IGNORE. All of these are either |
| 50 | * notifications (rather than requests for change) or are also sent |
| 51 | * via the keyboard controller so should not be sent again. |
| 52 | */ |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 53 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 54 | static const struct key_entry dell_wmi_legacy_keymap[] __initconst = { |
| 55 | { KE_KEY, 0xe045, { KEY_PROG1 } }, |
| 56 | { KE_KEY, 0xe009, { KEY_EJECTCD } }, |
Mario Limonciello | 5cab009 | 2009-06-10 19:40:47 +0000 | [diff] [blame] | 57 | |
| 58 | /* These also contain the brightness level at offset 6 */ |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 59 | { KE_KEY, 0xe006, { KEY_BRIGHTNESSUP } }, |
| 60 | { KE_KEY, 0xe005, { KEY_BRIGHTNESSDOWN } }, |
Mario Limonciello | 5cab009 | 2009-06-10 19:40:47 +0000 | [diff] [blame] | 61 | |
| 62 | /* Battery health status button */ |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 63 | { KE_KEY, 0xe007, { KEY_BATTERY } }, |
Mario Limonciello | 5cab009 | 2009-06-10 19:40:47 +0000 | [diff] [blame] | 64 | |
| 65 | /* This is actually for all radios. Although physically a |
| 66 | * switch, the notification does not provide an indication of |
| 67 | * state and so it should be reported as a key */ |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 68 | { KE_KEY, 0xe008, { KEY_WLAN } }, |
Mario Limonciello | 5cab009 | 2009-06-10 19:40:47 +0000 | [diff] [blame] | 69 | |
| 70 | /* The next device is at offset 6, the active devices are at |
| 71 | offset 8 and the attached devices at offset 10 */ |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 72 | { KE_KEY, 0xe00b, { KEY_SWITCHVIDEOMODE } }, |
Mario Limonciello | 5cab009 | 2009-06-10 19:40:47 +0000 | [diff] [blame] | 73 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 74 | { KE_IGNORE, 0xe00c, { KEY_KBDILLUMTOGGLE } }, |
Mario Limonciello | 5cab009 | 2009-06-10 19:40:47 +0000 | [diff] [blame] | 75 | |
| 76 | /* BIOS error detected */ |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 77 | { KE_IGNORE, 0xe00d, { KEY_RESERVED } }, |
Mario Limonciello | 5cab009 | 2009-06-10 19:40:47 +0000 | [diff] [blame] | 78 | |
| 79 | /* Wifi Catcher */ |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 80 | { KE_KEY, 0xe011, {KEY_PROG2 } }, |
Mario Limonciello | 5cab009 | 2009-06-10 19:40:47 +0000 | [diff] [blame] | 81 | |
| 82 | /* Ambient light sensor toggle */ |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 83 | { KE_IGNORE, 0xe013, { KEY_RESERVED } }, |
Mario Limonciello | 5cab009 | 2009-06-10 19:40:47 +0000 | [diff] [blame] | 84 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 85 | { KE_IGNORE, 0xe020, { KEY_MUTE } }, |
| 86 | { KE_IGNORE, 0xe02e, { KEY_VOLUMEDOWN } }, |
| 87 | { KE_IGNORE, 0xe030, { KEY_VOLUMEUP } }, |
| 88 | { KE_IGNORE, 0xe033, { KEY_KBDILLUMUP } }, |
| 89 | { KE_IGNORE, 0xe034, { KEY_KBDILLUMDOWN } }, |
| 90 | { KE_IGNORE, 0xe03a, { KEY_CAPSLOCK } }, |
| 91 | { KE_IGNORE, 0xe045, { KEY_NUMLOCK } }, |
| 92 | { KE_IGNORE, 0xe046, { KEY_SCROLLLOCK } }, |
| 93 | { KE_END, 0 } |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 96 | static bool dell_new_hk_type; |
| 97 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 98 | struct dell_bios_keymap_entry { |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 99 | u16 scancode; |
| 100 | u16 keycode; |
| 101 | }; |
| 102 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 103 | struct dell_bios_hotkey_table { |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 104 | struct dmi_header header; |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 105 | struct dell_bios_keymap_entry keymap[]; |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 106 | |
| 107 | }; |
| 108 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 109 | static const struct dell_bios_hotkey_table *dell_bios_hotkey_table; |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 110 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 111 | static const u16 bios_to_linux_keycode[256] __initconst = { |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 112 | |
| 113 | KEY_MEDIA, KEY_NEXTSONG, KEY_PLAYPAUSE, KEY_PREVIOUSSONG, |
| 114 | KEY_STOPCD, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, |
| 115 | KEY_WWW, KEY_UNKNOWN, KEY_VOLUMEDOWN, KEY_MUTE, |
| 116 | KEY_VOLUMEUP, KEY_UNKNOWN, KEY_BATTERY, KEY_EJECTCD, |
| 117 | KEY_UNKNOWN, KEY_SLEEP, KEY_PROG1, KEY_BRIGHTNESSDOWN, |
| 118 | KEY_BRIGHTNESSUP, KEY_UNKNOWN, KEY_KBDILLUMTOGGLE, |
| 119 | KEY_UNKNOWN, KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN, |
| 120 | KEY_SWITCHVIDEOMODE, KEY_UNKNOWN, KEY_UNKNOWN, KEY_PROG2, |
| 121 | KEY_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 122 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 123 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 124 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 125 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 126 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 127 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 128 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 129 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 130 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 131 | KEY_PROG3 |
| 132 | }; |
| 133 | |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 134 | static struct input_dev *dell_wmi_input_dev; |
| 135 | |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 136 | static void dell_wmi_notify(u32 value, void *context) |
| 137 | { |
| 138 | struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 139 | union acpi_object *obj; |
Len Brown | fda11e6 | 2009-12-26 23:02:24 -0500 | [diff] [blame] | 140 | acpi_status status; |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 141 | |
Len Brown | fda11e6 | 2009-12-26 23:02:24 -0500 | [diff] [blame] | 142 | status = wmi_get_event_data(value, &response); |
| 143 | if (status != AE_OK) { |
| 144 | printk(KERN_INFO "dell-wmi: bad event status 0x%x\n", status); |
| 145 | return; |
| 146 | } |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 147 | |
| 148 | obj = (union acpi_object *)response.pointer; |
| 149 | |
| 150 | if (obj && obj->type == ACPI_TYPE_BUFFER) { |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 151 | const struct key_entry *key; |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 152 | int reported_key; |
| 153 | u16 *buffer_entry = (u16 *)obj->buffer.pointer; |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 154 | |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 155 | if (dell_new_hk_type && (buffer_entry[1] != 0x10)) { |
| 156 | printk(KERN_INFO "dell-wmi: Received unknown WMI event" |
| 157 | " (0x%x)\n", buffer_entry[1]); |
Yong Wang | a0624a9 | 2010-04-05 21:09:40 +0800 | [diff] [blame] | 158 | kfree(obj); |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 159 | return; |
| 160 | } |
| 161 | |
Islam Amer | d5164db | 2010-06-24 13:39:47 -0400 | [diff] [blame] | 162 | if (dell_new_hk_type || buffer_entry[1] == 0x0) |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 163 | reported_key = (int)buffer_entry[2]; |
| 164 | else |
| 165 | reported_key = (int)buffer_entry[1] & 0xffff; |
| 166 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 167 | key = sparse_keymap_entry_from_scancode(dell_wmi_input_dev, |
| 168 | reported_key); |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 169 | if (!key) { |
| 170 | printk(KERN_INFO "dell-wmi: Unknown key %x pressed\n", |
| 171 | reported_key); |
| 172 | } else if ((key->keycode == KEY_BRIGHTNESSUP || |
| 173 | key->keycode == KEY_BRIGHTNESSDOWN) && acpi_video) { |
| 174 | /* Don't report brightness notifications that will also |
| 175 | * come via ACPI */ |
Yong Wang | a0624a9 | 2010-04-05 21:09:40 +0800 | [diff] [blame] | 176 | ; |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 177 | } else { |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 178 | sparse_keymap_report_entry(dell_wmi_input_dev, key, |
| 179 | 1, true); |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 180 | } |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 181 | } |
Anisse Astier | 3e9b988 | 2009-12-04 10:10:09 +0100 | [diff] [blame] | 182 | kfree(obj); |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 185 | static const struct key_entry * __init dell_wmi_prepare_new_keymap(void) |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 186 | { |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 187 | int hotkey_num = (dell_bios_hotkey_table->header.length - 4) / |
| 188 | sizeof(struct dell_bios_keymap_entry); |
| 189 | struct key_entry *keymap; |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 190 | int i; |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 191 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 192 | keymap = kcalloc(hotkey_num + 1, sizeof(struct key_entry), GFP_KERNEL); |
| 193 | if (!keymap) |
| 194 | return NULL; |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 195 | |
| 196 | for (i = 0; i < hotkey_num; i++) { |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 197 | const struct dell_bios_keymap_entry *bios_entry = |
| 198 | &dell_bios_hotkey_table->keymap[i]; |
| 199 | keymap[i].type = KE_KEY; |
| 200 | keymap[i].code = bios_entry->scancode; |
| 201 | keymap[i].keycode = bios_entry->keycode < 256 ? |
| 202 | bios_to_linux_keycode[bios_entry->keycode] : |
| 203 | KEY_RESERVED; |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 204 | } |
| 205 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 206 | keymap[hotkey_num].type = KE_END; |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 207 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 208 | return keymap; |
Rezwanul Kabir | 5ea2559 | 2009-11-02 12:00:42 -0500 | [diff] [blame] | 209 | } |
| 210 | |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 211 | static int __init dell_wmi_input_setup(void) |
| 212 | { |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 213 | int err; |
| 214 | |
| 215 | dell_wmi_input_dev = input_allocate_device(); |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 216 | if (!dell_wmi_input_dev) |
| 217 | return -ENOMEM; |
| 218 | |
| 219 | dell_wmi_input_dev->name = "Dell WMI hotkeys"; |
| 220 | dell_wmi_input_dev->phys = "wmi/input0"; |
| 221 | dell_wmi_input_dev->id.bustype = BUS_HOST; |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 222 | |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 223 | if (dell_new_hk_type) { |
| 224 | const struct key_entry *keymap = dell_wmi_prepare_new_keymap(); |
| 225 | if (!keymap) { |
| 226 | err = -ENOMEM; |
| 227 | goto err_free_dev; |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 228 | } |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 229 | |
| 230 | err = sparse_keymap_setup(dell_wmi_input_dev, keymap, NULL); |
| 231 | |
| 232 | /* |
| 233 | * Sparse keymap library makes a copy of keymap so we |
| 234 | * don't need the original one that was allocated. |
| 235 | */ |
| 236 | kfree(keymap); |
| 237 | } else { |
| 238 | err = sparse_keymap_setup(dell_wmi_input_dev, |
| 239 | dell_wmi_legacy_keymap, NULL); |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 240 | } |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 241 | if (err) |
| 242 | goto err_free_dev; |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 243 | |
| 244 | err = input_register_device(dell_wmi_input_dev); |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 245 | if (err) |
| 246 | goto err_free_keymap; |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 247 | |
| 248 | return 0; |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 249 | |
| 250 | err_free_keymap: |
| 251 | sparse_keymap_free(dell_wmi_input_dev); |
| 252 | err_free_dev: |
| 253 | input_free_device(dell_wmi_input_dev); |
| 254 | return err; |
| 255 | } |
| 256 | |
| 257 | static void dell_wmi_input_destroy(void) |
| 258 | { |
| 259 | sparse_keymap_free(dell_wmi_input_dev); |
| 260 | input_unregister_device(dell_wmi_input_dev); |
| 261 | } |
| 262 | |
| 263 | static void __init find_hk_type(const struct dmi_header *dm, void *dummy) |
| 264 | { |
| 265 | if (dm->type == 0xb2 && dm->length > 6) { |
| 266 | dell_new_hk_type = true; |
| 267 | dell_bios_hotkey_table = |
| 268 | container_of(dm, struct dell_bios_hotkey_table, header); |
| 269 | } |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | static int __init dell_wmi_init(void) |
| 273 | { |
| 274 | int err; |
Len Brown | abb631b | 2009-12-26 21:51:38 -0500 | [diff] [blame] | 275 | acpi_status status; |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 276 | |
Dmitry Torokhov | 7a9568f | 2009-12-25 11:49:35 -0800 | [diff] [blame] | 277 | if (!wmi_has_guid(DELL_EVENT_GUID)) { |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 278 | printk(KERN_WARNING "dell-wmi: No known WMI GUID found\n"); |
Dmitry Torokhov | 1fdd407 | 2009-12-17 22:19:42 -0800 | [diff] [blame] | 279 | return -ENODEV; |
| 280 | } |
| 281 | |
| 282 | dmi_walk(find_hk_type, NULL); |
| 283 | acpi_video = acpi_video_backlight_support(); |
| 284 | |
| 285 | err = dell_wmi_input_setup(); |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 286 | if (err) |
Dmitry Torokhov | 1fdd407 | 2009-12-17 22:19:42 -0800 | [diff] [blame] | 287 | return err; |
| 288 | |
Len Brown | abb631b | 2009-12-26 21:51:38 -0500 | [diff] [blame] | 289 | status = wmi_install_notify_handler(DELL_EVENT_GUID, |
Dmitry Torokhov | 1fdd407 | 2009-12-17 22:19:42 -0800 | [diff] [blame] | 290 | dell_wmi_notify, NULL); |
Len Brown | abb631b | 2009-12-26 21:51:38 -0500 | [diff] [blame] | 291 | if (ACPI_FAILURE(status)) { |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 292 | dell_wmi_input_destroy(); |
Dmitry Torokhov | 1fdd407 | 2009-12-17 22:19:42 -0800 | [diff] [blame] | 293 | printk(KERN_ERR |
| 294 | "dell-wmi: Unable to register notify handler - %d\n", |
Len Brown | abb631b | 2009-12-26 21:51:38 -0500 | [diff] [blame] | 295 | status); |
| 296 | return -ENODEV; |
Dmitry Torokhov | 1fdd407 | 2009-12-17 22:19:42 -0800 | [diff] [blame] | 297 | } |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 298 | |
| 299 | return 0; |
| 300 | } |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 301 | module_init(dell_wmi_init); |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 302 | |
| 303 | static void __exit dell_wmi_exit(void) |
| 304 | { |
Dmitry Torokhov | 1fdd407 | 2009-12-17 22:19:42 -0800 | [diff] [blame] | 305 | wmi_remove_notify_handler(DELL_EVENT_GUID); |
Dmitry Torokhov | 890a7c8 | 2010-08-04 22:30:08 -0700 | [diff] [blame^] | 306 | dell_wmi_input_destroy(); |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 307 | } |
Matthew Garrett | 0b3f610 | 2009-01-09 20:17:11 +0000 | [diff] [blame] | 308 | module_exit(dell_wmi_exit); |