Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1 | /* |
| 2 | * USB HID quirks support for Linux |
| 3 | * |
| 4 | * Copyright (c) 1999 Andreas Gal |
| 5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> |
| 6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc |
| 7 | * Copyright (c) 2006-2007 Jiri Kosina |
| 8 | * Copyright (c) 2007 Paul Walmsley |
| 9 | * Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com> |
| 10 | */ |
| 11 | |
| 12 | /* |
| 13 | * This program is free software; you can redistribute it and/or modify it |
| 14 | * under the terms of the GNU General Public License as published by the Free |
| 15 | * Software Foundation; either version 2 of the License, or (at your option) |
| 16 | * any later version. |
| 17 | */ |
| 18 | |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 20 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 21 | #include <linux/device.h> |
| 22 | #include <linux/hid.h> |
| 23 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 24 | #include <linux/slab.h> |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 25 | #include <linux/usb.h> |
| 26 | |
| 27 | #include "hid-ids.h" |
| 28 | |
| 29 | #define APPLE_RDESC_JIS 0x0001 |
| 30 | #define APPLE_IGNORE_MOUSE 0x0002 |
| 31 | #define APPLE_HAS_FN 0x0004 |
| 32 | #define APPLE_HIDDEV 0x0008 |
| 33 | #define APPLE_ISO_KEYBOARD 0x0010 |
| 34 | #define APPLE_MIGHTYMOUSE 0x0020 |
| 35 | #define APPLE_INVERT_HWHEEL 0x0040 |
| 36 | #define APPLE_IGNORE_HIDINPUT 0x0080 |
| 37 | #define APPLE_NUMLOCK_EMULATION 0x0100 |
| 38 | |
| 39 | #define APPLE_FLAG_FKEY 0x01 |
| 40 | |
| 41 | static unsigned int fnmode = 1; |
| 42 | module_param(fnmode, uint, 0644); |
| 43 | MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, " |
| 44 | "[1] = fkeyslast, 2 = fkeysfirst)"); |
| 45 | |
Stefan Glasenhardt | 54a6593 | 2010-01-05 23:30:30 +0100 | [diff] [blame] | 46 | static unsigned int iso_layout = 1; |
| 47 | module_param(iso_layout, uint, 0644); |
| 48 | MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. " |
| 49 | "(0 = disabled, [1] = enabled)"); |
| 50 | |
Nanno Langstraat | 1ec40bd3 | 2013-10-14 16:07:15 +0200 | [diff] [blame^] | 51 | static unsigned int swap_opt_cmd = 0; |
| 52 | module_param(swap_opt_cmd, uint, 0644); |
| 53 | MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\") keys. " |
| 54 | "(For people who want to keep Windows PC keyboard muscle memory. " |
| 55 | "[0] = as-is, Mac layout. 1 = swapped, Windows layout.)"); |
| 56 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 57 | struct apple_sc { |
| 58 | unsigned long quirks; |
| 59 | unsigned int fn_on; |
| 60 | DECLARE_BITMAP(pressed_fn, KEY_CNT); |
| 61 | DECLARE_BITMAP(pressed_numlock, KEY_CNT); |
| 62 | }; |
| 63 | |
| 64 | struct apple_key_translation { |
| 65 | u16 from; |
| 66 | u16 to; |
| 67 | u8 flags; |
| 68 | }; |
| 69 | |
Edgar (gimli) Hucek | 99b9f75 | 2010-11-03 10:36:18 -0400 | [diff] [blame] | 70 | static const struct apple_key_translation macbookair_fn_keys[] = { |
| 71 | { KEY_BACKSPACE, KEY_DELETE }, |
| 72 | { KEY_ENTER, KEY_INSERT }, |
| 73 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, |
| 74 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, |
| 75 | { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY }, |
| 76 | { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY }, |
| 77 | { KEY_F6, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, |
| 78 | { KEY_F7, KEY_PLAYPAUSE, APPLE_FLAG_FKEY }, |
| 79 | { KEY_F8, KEY_NEXTSONG, APPLE_FLAG_FKEY }, |
| 80 | { KEY_F9, KEY_MUTE, APPLE_FLAG_FKEY }, |
| 81 | { KEY_F10, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, |
| 82 | { KEY_F11, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, |
| 83 | { KEY_F12, KEY_EJECTCD, APPLE_FLAG_FKEY }, |
| 84 | { KEY_UP, KEY_PAGEUP }, |
| 85 | { KEY_DOWN, KEY_PAGEDOWN }, |
| 86 | { KEY_LEFT, KEY_HOME }, |
| 87 | { KEY_RIGHT, KEY_END }, |
| 88 | { } |
| 89 | }; |
| 90 | |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 91 | static const struct apple_key_translation apple_fn_keys[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 92 | { KEY_BACKSPACE, KEY_DELETE }, |
Henrik Rydberg | 437184a | 2008-11-04 13:31:38 +0100 | [diff] [blame] | 93 | { KEY_ENTER, KEY_INSERT }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 94 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, |
| 95 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, |
Henrik Rydberg | 437184a | 2008-11-04 13:31:38 +0100 | [diff] [blame] | 96 | { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY }, |
| 97 | { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 98 | { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, |
| 99 | { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, |
| 100 | { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, |
| 101 | { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY }, |
| 102 | { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY }, |
| 103 | { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY }, |
| 104 | { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, |
| 105 | { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, |
| 106 | { KEY_UP, KEY_PAGEUP }, |
| 107 | { KEY_DOWN, KEY_PAGEDOWN }, |
| 108 | { KEY_LEFT, KEY_HOME }, |
| 109 | { KEY_RIGHT, KEY_END }, |
| 110 | { } |
| 111 | }; |
| 112 | |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 113 | static const struct apple_key_translation powerbook_fn_keys[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 114 | { KEY_BACKSPACE, KEY_DELETE }, |
| 115 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, |
| 116 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, |
| 117 | { KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY }, |
| 118 | { KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, |
| 119 | { KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, |
| 120 | { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY }, |
| 121 | { KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY }, |
| 122 | { KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY }, |
| 123 | { KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, |
| 124 | { KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, |
| 125 | { KEY_UP, KEY_PAGEUP }, |
| 126 | { KEY_DOWN, KEY_PAGEDOWN }, |
| 127 | { KEY_LEFT, KEY_HOME }, |
| 128 | { KEY_RIGHT, KEY_END }, |
| 129 | { } |
| 130 | }; |
| 131 | |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 132 | static const struct apple_key_translation powerbook_numlock_keys[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 133 | { KEY_J, KEY_KP1 }, |
| 134 | { KEY_K, KEY_KP2 }, |
| 135 | { KEY_L, KEY_KP3 }, |
| 136 | { KEY_U, KEY_KP4 }, |
| 137 | { KEY_I, KEY_KP5 }, |
| 138 | { KEY_O, KEY_KP6 }, |
| 139 | { KEY_7, KEY_KP7 }, |
| 140 | { KEY_8, KEY_KP8 }, |
| 141 | { KEY_9, KEY_KP9 }, |
| 142 | { KEY_M, KEY_KP0 }, |
| 143 | { KEY_DOT, KEY_KPDOT }, |
| 144 | { KEY_SLASH, KEY_KPPLUS }, |
| 145 | { KEY_SEMICOLON, KEY_KPMINUS }, |
| 146 | { KEY_P, KEY_KPASTERISK }, |
| 147 | { KEY_MINUS, KEY_KPEQUAL }, |
| 148 | { KEY_0, KEY_KPSLASH }, |
| 149 | { KEY_F6, KEY_NUMLOCK }, |
| 150 | { KEY_KPENTER, KEY_KPENTER }, |
| 151 | { KEY_BACKSPACE, KEY_BACKSPACE }, |
| 152 | { } |
| 153 | }; |
| 154 | |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 155 | static const struct apple_key_translation apple_iso_keyboard[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 156 | { KEY_GRAVE, KEY_102ND }, |
| 157 | { KEY_102ND, KEY_GRAVE }, |
| 158 | { } |
| 159 | }; |
| 160 | |
Nanno Langstraat | 1ec40bd3 | 2013-10-14 16:07:15 +0200 | [diff] [blame^] | 161 | static const struct apple_key_translation swapped_option_cmd_keys[] = { |
| 162 | { KEY_LEFTALT, KEY_LEFTMETA }, |
| 163 | { KEY_LEFTMETA, KEY_LEFTALT }, |
| 164 | { KEY_RIGHTALT, KEY_RIGHTMETA }, |
| 165 | { KEY_RIGHTMETA,KEY_RIGHTALT }, |
| 166 | { } |
| 167 | }; |
| 168 | |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 169 | static const struct apple_key_translation *apple_find_translation( |
| 170 | const struct apple_key_translation *table, u16 from) |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 171 | { |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 172 | const struct apple_key_translation *trans; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 173 | |
| 174 | /* Look for the translation */ |
| 175 | for (trans = table; trans->from; trans++) |
| 176 | if (trans->from == from) |
| 177 | return trans; |
| 178 | |
| 179 | return NULL; |
| 180 | } |
| 181 | |
| 182 | static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, |
| 183 | struct hid_usage *usage, __s32 value) |
| 184 | { |
| 185 | struct apple_sc *asc = hid_get_drvdata(hid); |
Jiri Kosina | a4bc692 | 2010-11-03 10:42:02 -0400 | [diff] [blame] | 186 | const struct apple_key_translation *trans, *table; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 187 | |
| 188 | if (usage->code == KEY_FN) { |
| 189 | asc->fn_on = !!value; |
| 190 | input_event(input, usage->type, usage->code, value); |
| 191 | return 1; |
| 192 | } |
| 193 | |
| 194 | if (fnmode) { |
| 195 | int do_translate; |
| 196 | |
Jiri Kosina | a4bc692 | 2010-11-03 10:42:02 -0400 | [diff] [blame] | 197 | if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI && |
| 198 | hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) |
| 199 | table = macbookair_fn_keys; |
| 200 | else if (hid->product < 0x21d || hid->product >= 0x300) |
| 201 | table = powerbook_fn_keys; |
| 202 | else |
| 203 | table = apple_fn_keys; |
| 204 | |
| 205 | trans = apple_find_translation (table, usage->code); |
Edgar (gimli) Hucek | 99b9f75 | 2010-11-03 10:36:18 -0400 | [diff] [blame] | 206 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 207 | if (trans) { |
| 208 | if (test_bit(usage->code, asc->pressed_fn)) |
| 209 | do_translate = 1; |
| 210 | else if (trans->flags & APPLE_FLAG_FKEY) |
| 211 | do_translate = (fnmode == 2 && asc->fn_on) || |
| 212 | (fnmode == 1 && !asc->fn_on); |
| 213 | else |
| 214 | do_translate = asc->fn_on; |
| 215 | |
| 216 | if (do_translate) { |
| 217 | if (value) |
| 218 | set_bit(usage->code, asc->pressed_fn); |
| 219 | else |
| 220 | clear_bit(usage->code, asc->pressed_fn); |
| 221 | |
| 222 | input_event(input, usage->type, trans->to, |
| 223 | value); |
| 224 | |
| 225 | return 1; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | if (asc->quirks & APPLE_NUMLOCK_EMULATION && |
| 230 | (test_bit(usage->code, asc->pressed_numlock) || |
| 231 | test_bit(LED_NUML, input->led))) { |
| 232 | trans = apple_find_translation(powerbook_numlock_keys, |
| 233 | usage->code); |
| 234 | |
| 235 | if (trans) { |
| 236 | if (value) |
| 237 | set_bit(usage->code, |
| 238 | asc->pressed_numlock); |
| 239 | else |
| 240 | clear_bit(usage->code, |
| 241 | asc->pressed_numlock); |
| 242 | |
| 243 | input_event(input, usage->type, trans->to, |
| 244 | value); |
| 245 | } |
| 246 | |
| 247 | return 1; |
| 248 | } |
| 249 | } |
| 250 | |
Stefan Glasenhardt | 54a6593 | 2010-01-05 23:30:30 +0100 | [diff] [blame] | 251 | if (iso_layout) { |
| 252 | if (asc->quirks & APPLE_ISO_KEYBOARD) { |
| 253 | trans = apple_find_translation(apple_iso_keyboard, usage->code); |
| 254 | if (trans) { |
| 255 | input_event(input, usage->type, trans->to, value); |
| 256 | return 1; |
| 257 | } |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | |
Nanno Langstraat | 1ec40bd3 | 2013-10-14 16:07:15 +0200 | [diff] [blame^] | 261 | if (swap_opt_cmd) { |
| 262 | trans = apple_find_translation(swapped_option_cmd_keys, usage->code); |
| 263 | if (trans) { |
| 264 | input_event(input, usage->type, trans->to, value); |
| 265 | return 1; |
| 266 | } |
| 267 | } |
| 268 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 269 | return 0; |
| 270 | } |
| 271 | |
| 272 | static int apple_event(struct hid_device *hdev, struct hid_field *field, |
| 273 | struct hid_usage *usage, __s32 value) |
| 274 | { |
| 275 | struct apple_sc *asc = hid_get_drvdata(hdev); |
| 276 | |
| 277 | if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput || |
| 278 | !usage->type) |
| 279 | return 0; |
| 280 | |
| 281 | if ((asc->quirks & APPLE_INVERT_HWHEEL) && |
| 282 | usage->code == REL_HWHEEL) { |
| 283 | input_event(field->hidinput->input, usage->type, usage->code, |
| 284 | -value); |
| 285 | return 1; |
| 286 | } |
| 287 | |
| 288 | if ((asc->quirks & APPLE_HAS_FN) && |
| 289 | hidinput_apple_event(hdev, field->hidinput->input, |
| 290 | usage, value)) |
| 291 | return 1; |
| 292 | |
| 293 | |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | /* |
| 298 | * MacBook JIS keyboard has wrong logical maximum |
| 299 | */ |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 300 | static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
| 301 | unsigned int *rsize) |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 302 | { |
| 303 | struct apple_sc *asc = hid_get_drvdata(hdev); |
| 304 | |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 305 | if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 && |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 306 | rdesc[53] == 0x65 && rdesc[59] == 0x65) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 307 | hid_info(hdev, |
| 308 | "fixing up MacBook JIS keyboard report descriptor\n"); |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 309 | rdesc[53] = rdesc[59] = 0xe7; |
| 310 | } |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 311 | return rdesc; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | static void apple_setup_input(struct input_dev *input) |
| 315 | { |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 316 | const struct apple_key_translation *trans; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 317 | |
| 318 | set_bit(KEY_NUMLOCK, input->keybit); |
| 319 | |
| 320 | /* Enable all needed keys */ |
| 321 | for (trans = apple_fn_keys; trans->from; trans++) |
| 322 | set_bit(trans->to, input->keybit); |
| 323 | |
| 324 | for (trans = powerbook_fn_keys; trans->from; trans++) |
| 325 | set_bit(trans->to, input->keybit); |
| 326 | |
| 327 | for (trans = powerbook_numlock_keys; trans->from; trans++) |
| 328 | set_bit(trans->to, input->keybit); |
| 329 | |
| 330 | for (trans = apple_iso_keyboard; trans->from; trans++) |
| 331 | set_bit(trans->to, input->keybit); |
| 332 | } |
| 333 | |
| 334 | static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 335 | struct hid_field *field, struct hid_usage *usage, |
| 336 | unsigned long **bit, int *max) |
| 337 | { |
| 338 | if (usage->hid == (HID_UP_CUSTOM | 0x0003)) { |
| 339 | /* The fn key on Apple USB keyboards */ |
| 340 | set_bit(EV_REP, hi->input->evbit); |
| 341 | hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN); |
| 342 | apple_setup_input(hi->input); |
| 343 | return 1; |
| 344 | } |
| 345 | |
| 346 | /* we want the hid layer to go through standard path (set and ignore) */ |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi, |
| 351 | struct hid_field *field, struct hid_usage *usage, |
| 352 | unsigned long **bit, int *max) |
| 353 | { |
| 354 | struct apple_sc *asc = hid_get_drvdata(hdev); |
| 355 | |
| 356 | if (asc->quirks & APPLE_MIGHTYMOUSE) { |
| 357 | if (usage->hid == HID_GD_Z) |
| 358 | hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL); |
| 359 | else if (usage->code == BTN_1) |
| 360 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2); |
| 361 | else if (usage->code == BTN_2) |
| 362 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1); |
| 363 | } |
| 364 | |
| 365 | return 0; |
| 366 | } |
| 367 | |
| 368 | static int apple_probe(struct hid_device *hdev, |
| 369 | const struct hid_device_id *id) |
| 370 | { |
| 371 | unsigned long quirks = id->driver_data; |
| 372 | struct apple_sc *asc; |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 373 | unsigned int connect_mask = HID_CONNECT_DEFAULT; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 374 | int ret; |
| 375 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 376 | asc = kzalloc(sizeof(*asc), GFP_KERNEL); |
| 377 | if (asc == NULL) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 378 | hid_err(hdev, "can't alloc apple descriptor\n"); |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 379 | return -ENOMEM; |
| 380 | } |
| 381 | |
| 382 | asc->quirks = quirks; |
| 383 | |
| 384 | hid_set_drvdata(hdev, asc); |
| 385 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 386 | ret = hid_parse(hdev); |
| 387 | if (ret) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 388 | hid_err(hdev, "parse failed\n"); |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 389 | goto err_free; |
| 390 | } |
| 391 | |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 392 | if (quirks & APPLE_HIDDEV) |
| 393 | connect_mask |= HID_CONNECT_HIDDEV_FORCE; |
| 394 | if (quirks & APPLE_IGNORE_HIDINPUT) |
| 395 | connect_mask &= ~HID_CONNECT_HIDINPUT; |
| 396 | |
| 397 | ret = hid_hw_start(hdev, connect_mask); |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 398 | if (ret) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 399 | hid_err(hdev, "hw start failed\n"); |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 400 | goto err_free; |
| 401 | } |
| 402 | |
| 403 | return 0; |
| 404 | err_free: |
| 405 | kfree(asc); |
| 406 | return ret; |
| 407 | } |
| 408 | |
| 409 | static void apple_remove(struct hid_device *hdev) |
| 410 | { |
| 411 | hid_hw_stop(hdev); |
| 412 | kfree(hid_get_drvdata(hdev)); |
| 413 | } |
| 414 | |
| 415 | static const struct hid_device_id apple_devices[] = { |
Peter Korsgaard | 0f492f2 | 2008-10-06 11:15:34 +0200 | [diff] [blame] | 416 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL), |
| 417 | .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 418 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4), |
| 419 | .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT }, |
| 420 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE), |
| 421 | .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL }, |
| 422 | |
| 423 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 424 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 425 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 426 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 427 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 428 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 429 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO), |
| 430 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 431 | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 432 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 433 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 434 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 435 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 436 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO), |
| 437 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 438 | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 439 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS), |
| 440 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 441 | APPLE_RDESC_JIS }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 442 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 443 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 444 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO), |
| 445 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 446 | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 447 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS), |
| 448 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 449 | APPLE_RDESC_JIS }, |
Ryan Finnie | fef3f57 | 2009-03-05 10:18:01 +0100 | [diff] [blame] | 450 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI), |
| 451 | .driver_data = APPLE_HAS_FN }, |
| 452 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO), |
| 453 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 454 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS), |
| 455 | .driver_data = APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 456 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI), |
| 457 | .driver_data = APPLE_HAS_FN }, |
| 458 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO), |
| 459 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 460 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS), |
| 461 | .driver_data = APPLE_HAS_FN }, |
| 462 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 463 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 464 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 465 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 466 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS), |
| 467 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 468 | APPLE_RDESC_JIS }, |
Dan Bastone | 4a4c879 | 2011-07-31 07:40:49 -0400 | [diff] [blame] | 469 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI), |
| 470 | .driver_data = APPLE_HAS_FN }, |
| 471 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO), |
| 472 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 473 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS), |
| 474 | .driver_data = APPLE_HAS_FN }, |
Jan Scholz | ee8a1a0 | 2008-11-26 15:33:45 +0100 | [diff] [blame] | 475 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 476 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jan Scholz | ee8a1a0 | 2008-11-26 15:33:45 +0100 | [diff] [blame] | 477 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO), |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 478 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
| 479 | APPLE_ISO_KEYBOARD }, |
Andreas Krist | ad734bc | 2011-10-28 18:50:39 +0200 | [diff] [blame] | 480 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO), |
| 481 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
| 482 | APPLE_ISO_KEYBOARD }, |
Jan Scholz | ee8a1a0 | 2008-11-26 15:33:45 +0100 | [diff] [blame] | 483 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS), |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 484 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
| 485 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 486 | .driver_data = APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 487 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 488 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 489 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 490 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 491 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 492 | .driver_data = APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 493 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 494 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 495 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 496 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Henrik Rydberg | a96d6ef | 2008-11-04 20:03:45 +0100 | [diff] [blame] | 497 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), |
| 498 | .driver_data = APPLE_HAS_FN }, |
| 499 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), |
| 500 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 501 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), |
| 502 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Edgar (gimli) Hucek | 99b9f75 | 2010-11-03 10:36:18 -0400 | [diff] [blame] | 503 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI), |
| 504 | .driver_data = APPLE_HAS_FN }, |
| 505 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO), |
| 506 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 507 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS), |
| 508 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
| 509 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI), |
| 510 | .driver_data = APPLE_HAS_FN }, |
| 511 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO), |
| 512 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 513 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), |
| 514 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Andy Botting | 47340bd | 2011-03-12 20:27:22 -0800 | [diff] [blame] | 515 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI), |
| 516 | .driver_data = APPLE_HAS_FN }, |
| 517 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO), |
| 518 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 519 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS), |
| 520 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Joshua V. Dillon | 5d922ba | 2011-08-05 12:05:22 -0700 | [diff] [blame] | 521 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI), |
| 522 | .driver_data = APPLE_HAS_FN }, |
| 523 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO), |
| 524 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 525 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS), |
| 526 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Nobuhiro Iwamatsu | d762cc2 | 2011-10-01 15:54:53 +0900 | [diff] [blame] | 527 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI), |
| 528 | .driver_data = APPLE_HAS_FN }, |
| 529 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO), |
| 530 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 531 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS), |
| 532 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Gökçen Eraslan | 213f9da | 2011-10-22 22:39:06 +0300 | [diff] [blame] | 533 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI), |
| 534 | .driver_data = APPLE_HAS_FN }, |
| 535 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO), |
| 536 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 537 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS), |
| 538 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Ryan Bourgeois | c7e51c3 | 2012-07-10 09:43:33 -0700 | [diff] [blame] | 539 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI), |
| 540 | .driver_data = APPLE_HAS_FN }, |
| 541 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO), |
| 542 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 543 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS), |
| 544 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Christian Schuerer-Waldheim | 23aeb61 | 2010-01-06 14:49:57 +0100 | [diff] [blame] | 545 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), |
| 546 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
| 547 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), |
| 548 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
| 549 | APPLE_ISO_KEYBOARD }, |
| 550 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS), |
| 551 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 552 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 553 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 554 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 555 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 556 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 557 | { } |
| 558 | }; |
| 559 | MODULE_DEVICE_TABLE(hid, apple_devices); |
| 560 | |
| 561 | static struct hid_driver apple_driver = { |
| 562 | .name = "apple", |
| 563 | .id_table = apple_devices, |
| 564 | .report_fixup = apple_report_fixup, |
| 565 | .probe = apple_probe, |
| 566 | .remove = apple_remove, |
| 567 | .event = apple_event, |
| 568 | .input_mapping = apple_input_mapping, |
| 569 | .input_mapped = apple_input_mapped, |
| 570 | }; |
| 571 | |
Peter Huewe | a24f423 | 2009-07-02 19:08:38 +0200 | [diff] [blame] | 572 | static int __init apple_init(void) |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 573 | { |
| 574 | int ret; |
| 575 | |
| 576 | ret = hid_register_driver(&apple_driver); |
| 577 | if (ret) |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 578 | pr_err("can't register apple driver\n"); |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 579 | |
| 580 | return ret; |
| 581 | } |
| 582 | |
Peter Huewe | a24f423 | 2009-07-02 19:08:38 +0200 | [diff] [blame] | 583 | static void __exit apple_exit(void) |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 584 | { |
| 585 | hid_unregister_driver(&apple_driver); |
| 586 | } |
| 587 | |
| 588 | module_init(apple_init); |
| 589 | module_exit(apple_exit); |
| 590 | MODULE_LICENSE("GPL"); |