Linux 4.19.133
[linux/fpc-iii.git] / drivers / hid / hid-apple.c
blob8ab8f2350bbcdc7f28cccfc15d195807c503c32f
1 /*
2 * USB HID quirks support for Linux
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) 2008 Jiri Slaby <jirislaby@gmail.com>
9 */
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the Free
14 * Software Foundation; either version 2 of the License, or (at your option)
15 * any later version.
18 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20 #include <linux/device.h>
21 #include <linux/hid.h>
22 #include <linux/module.h>
23 #include <linux/slab.h>
25 #include "hid-ids.h"
27 #define APPLE_RDESC_JIS 0x0001
28 #define APPLE_IGNORE_MOUSE 0x0002
29 #define APPLE_HAS_FN 0x0004
30 #define APPLE_HIDDEV 0x0008
31 /* 0x0010 reserved, was: APPLE_ISO_KEYBOARD */
32 #define APPLE_MIGHTYMOUSE 0x0020
33 #define APPLE_INVERT_HWHEEL 0x0040
34 #define APPLE_IGNORE_HIDINPUT 0x0080
35 #define APPLE_NUMLOCK_EMULATION 0x0100
37 #define APPLE_FLAG_FKEY 0x01
39 #define HID_COUNTRY_INTERNATIONAL_ISO 13
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)");
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)");
51 static unsigned int swap_opt_cmd;
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.)");
57 struct apple_sc {
58 unsigned long quirks;
59 unsigned int fn_on;
60 DECLARE_BITMAP(pressed_numlock, KEY_CNT);
63 struct apple_key_translation {
64 u16 from;
65 u16 to;
66 u8 flags;
69 static const struct apple_key_translation macbookair_fn_keys[] = {
70 { KEY_BACKSPACE, KEY_DELETE },
71 { KEY_ENTER, KEY_INSERT },
72 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
73 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
74 { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
75 { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
76 { KEY_F6, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
77 { KEY_F7, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
78 { KEY_F8, KEY_NEXTSONG, APPLE_FLAG_FKEY },
79 { KEY_F9, KEY_MUTE, APPLE_FLAG_FKEY },
80 { KEY_F10, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
81 { KEY_F11, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
82 { KEY_F12, KEY_EJECTCD, APPLE_FLAG_FKEY },
83 { KEY_UP, KEY_PAGEUP },
84 { KEY_DOWN, KEY_PAGEDOWN },
85 { KEY_LEFT, KEY_HOME },
86 { KEY_RIGHT, KEY_END },
87 { }
90 static const struct apple_key_translation apple_fn_keys[] = {
91 { KEY_BACKSPACE, KEY_DELETE },
92 { KEY_ENTER, KEY_INSERT },
93 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
94 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
95 { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
96 { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
97 { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
98 { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
99 { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
100 { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
101 { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
102 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
103 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
104 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
105 { KEY_UP, KEY_PAGEUP },
106 { KEY_DOWN, KEY_PAGEDOWN },
107 { KEY_LEFT, KEY_HOME },
108 { KEY_RIGHT, KEY_END },
112 static const struct apple_key_translation powerbook_fn_keys[] = {
113 { KEY_BACKSPACE, KEY_DELETE },
114 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
115 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
116 { KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY },
117 { KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
118 { KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
119 { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY },
120 { KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY },
121 { KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY },
122 { KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
123 { KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
124 { KEY_UP, KEY_PAGEUP },
125 { KEY_DOWN, KEY_PAGEDOWN },
126 { KEY_LEFT, KEY_HOME },
127 { KEY_RIGHT, KEY_END },
131 static const struct apple_key_translation powerbook_numlock_keys[] = {
132 { KEY_J, KEY_KP1 },
133 { KEY_K, KEY_KP2 },
134 { KEY_L, KEY_KP3 },
135 { KEY_U, KEY_KP4 },
136 { KEY_I, KEY_KP5 },
137 { KEY_O, KEY_KP6 },
138 { KEY_7, KEY_KP7 },
139 { KEY_8, KEY_KP8 },
140 { KEY_9, KEY_KP9 },
141 { KEY_M, KEY_KP0 },
142 { KEY_DOT, KEY_KPDOT },
143 { KEY_SLASH, KEY_KPPLUS },
144 { KEY_SEMICOLON, KEY_KPMINUS },
145 { KEY_P, KEY_KPASTERISK },
146 { KEY_MINUS, KEY_KPEQUAL },
147 { KEY_0, KEY_KPSLASH },
148 { KEY_F6, KEY_NUMLOCK },
149 { KEY_KPENTER, KEY_KPENTER },
150 { KEY_BACKSPACE, KEY_BACKSPACE },
154 static const struct apple_key_translation apple_iso_keyboard[] = {
155 { KEY_GRAVE, KEY_102ND },
156 { KEY_102ND, KEY_GRAVE },
160 static const struct apple_key_translation swapped_option_cmd_keys[] = {
161 { KEY_LEFTALT, KEY_LEFTMETA },
162 { KEY_LEFTMETA, KEY_LEFTALT },
163 { KEY_RIGHTALT, KEY_RIGHTMETA },
164 { KEY_RIGHTMETA,KEY_RIGHTALT },
168 static const struct apple_key_translation *apple_find_translation(
169 const struct apple_key_translation *table, u16 from)
171 const struct apple_key_translation *trans;
173 /* Look for the translation */
174 for (trans = table; trans->from; trans++)
175 if (trans->from == from)
176 return trans;
178 return NULL;
181 static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
182 struct hid_usage *usage, __s32 value)
184 struct apple_sc *asc = hid_get_drvdata(hid);
185 const struct apple_key_translation *trans, *table;
186 bool do_translate;
187 u16 code = 0;
189 if (usage->code == KEY_FN) {
190 asc->fn_on = !!value;
191 input_event(input, usage->type, usage->code, value);
192 return 1;
195 if (fnmode) {
196 if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
197 hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
198 table = macbookair_fn_keys;
199 else if (hid->product < 0x21d || hid->product >= 0x300)
200 table = powerbook_fn_keys;
201 else
202 table = apple_fn_keys;
204 trans = apple_find_translation (table, usage->code);
206 if (trans) {
207 if (test_bit(trans->from, input->key))
208 code = trans->from;
209 else if (test_bit(trans->to, input->key))
210 code = trans->to;
212 if (!code) {
213 if (trans->flags & APPLE_FLAG_FKEY) {
214 switch (fnmode) {
215 case 1:
216 do_translate = !asc->fn_on;
217 break;
218 case 2:
219 do_translate = asc->fn_on;
220 break;
221 default:
222 /* should never happen */
223 do_translate = false;
225 } else {
226 do_translate = asc->fn_on;
229 code = do_translate ? trans->to : trans->from;
232 input_event(input, usage->type, code, value);
233 return 1;
236 if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
237 (test_bit(usage->code, asc->pressed_numlock) ||
238 test_bit(LED_NUML, input->led))) {
239 trans = apple_find_translation(powerbook_numlock_keys,
240 usage->code);
242 if (trans) {
243 if (value)
244 set_bit(usage->code,
245 asc->pressed_numlock);
246 else
247 clear_bit(usage->code,
248 asc->pressed_numlock);
250 input_event(input, usage->type, trans->to,
251 value);
254 return 1;
258 if (iso_layout) {
259 if (hid->country == HID_COUNTRY_INTERNATIONAL_ISO) {
260 trans = apple_find_translation(apple_iso_keyboard, usage->code);
261 if (trans) {
262 input_event(input, usage->type, trans->to, value);
263 return 1;
268 if (swap_opt_cmd) {
269 trans = apple_find_translation(swapped_option_cmd_keys, usage->code);
270 if (trans) {
271 input_event(input, usage->type, trans->to, value);
272 return 1;
276 return 0;
279 static int apple_event(struct hid_device *hdev, struct hid_field *field,
280 struct hid_usage *usage, __s32 value)
282 struct apple_sc *asc = hid_get_drvdata(hdev);
284 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
285 !usage->type)
286 return 0;
288 if ((asc->quirks & APPLE_INVERT_HWHEEL) &&
289 usage->code == REL_HWHEEL) {
290 input_event(field->hidinput->input, usage->type, usage->code,
291 -value);
292 return 1;
295 if ((asc->quirks & APPLE_HAS_FN) &&
296 hidinput_apple_event(hdev, field->hidinput->input,
297 usage, value))
298 return 1;
301 return 0;
305 * MacBook JIS keyboard has wrong logical maximum
307 static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
308 unsigned int *rsize)
310 struct apple_sc *asc = hid_get_drvdata(hdev);
312 if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 &&
313 rdesc[53] == 0x65 && rdesc[59] == 0x65) {
314 hid_info(hdev,
315 "fixing up MacBook JIS keyboard report descriptor\n");
316 rdesc[53] = rdesc[59] = 0xe7;
318 return rdesc;
321 static void apple_setup_input(struct input_dev *input)
323 const struct apple_key_translation *trans;
325 set_bit(KEY_NUMLOCK, input->keybit);
327 /* Enable all needed keys */
328 for (trans = apple_fn_keys; trans->from; trans++)
329 set_bit(trans->to, input->keybit);
331 for (trans = powerbook_fn_keys; trans->from; trans++)
332 set_bit(trans->to, input->keybit);
334 for (trans = powerbook_numlock_keys; trans->from; trans++)
335 set_bit(trans->to, input->keybit);
337 for (trans = apple_iso_keyboard; trans->from; trans++)
338 set_bit(trans->to, input->keybit);
341 static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
342 struct hid_field *field, struct hid_usage *usage,
343 unsigned long **bit, int *max)
345 if (usage->hid == (HID_UP_CUSTOM | 0x0003) ||
346 usage->hid == (HID_UP_MSVENDOR | 0x0003) ||
347 usage->hid == (HID_UP_HPVENDOR2 | 0x0003)) {
348 /* The fn key on Apple USB keyboards */
349 set_bit(EV_REP, hi->input->evbit);
350 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN);
351 apple_setup_input(hi->input);
352 return 1;
355 /* we want the hid layer to go through standard path (set and ignore) */
356 return 0;
359 static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi,
360 struct hid_field *field, struct hid_usage *usage,
361 unsigned long **bit, int *max)
363 struct apple_sc *asc = hid_get_drvdata(hdev);
365 if (asc->quirks & APPLE_MIGHTYMOUSE) {
366 if (usage->hid == HID_GD_Z)
367 hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL);
368 else if (usage->code == BTN_1)
369 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2);
370 else if (usage->code == BTN_2)
371 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1);
374 return 0;
377 static int apple_probe(struct hid_device *hdev,
378 const struct hid_device_id *id)
380 unsigned long quirks = id->driver_data;
381 struct apple_sc *asc;
382 unsigned int connect_mask = HID_CONNECT_DEFAULT;
383 int ret;
385 asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL);
386 if (asc == NULL) {
387 hid_err(hdev, "can't alloc apple descriptor\n");
388 return -ENOMEM;
391 asc->quirks = quirks;
393 hid_set_drvdata(hdev, asc);
395 ret = hid_parse(hdev);
396 if (ret) {
397 hid_err(hdev, "parse failed\n");
398 return ret;
401 if (quirks & APPLE_HIDDEV)
402 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
403 if (quirks & APPLE_IGNORE_HIDINPUT)
404 connect_mask &= ~HID_CONNECT_HIDINPUT;
406 ret = hid_hw_start(hdev, connect_mask);
407 if (ret) {
408 hid_err(hdev, "hw start failed\n");
409 return ret;
412 return 0;
415 static const struct hid_device_id apple_devices[] = {
416 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
417 .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
419 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI),
420 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
421 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO),
422 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
423 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI),
424 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
425 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO),
426 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
427 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS),
428 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
429 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI),
430 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
431 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO),
432 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
433 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS),
434 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
435 APPLE_RDESC_JIS },
436 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI),
437 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
438 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO),
439 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
440 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS),
441 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
442 APPLE_RDESC_JIS },
443 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI),
444 .driver_data = APPLE_HAS_FN },
445 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO),
446 .driver_data = APPLE_HAS_FN },
447 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS),
448 .driver_data = APPLE_HAS_FN },
449 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI),
450 .driver_data = APPLE_HAS_FN },
451 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO),
452 .driver_data = APPLE_HAS_FN },
453 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS),
454 .driver_data = APPLE_HAS_FN },
455 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI),
456 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
457 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO),
458 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
459 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
460 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
461 APPLE_RDESC_JIS },
462 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI),
463 .driver_data = APPLE_HAS_FN },
464 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO),
465 .driver_data = APPLE_HAS_FN },
466 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS),
467 .driver_data = APPLE_HAS_FN },
468 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
469 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
470 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
471 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
472 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
473 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
474 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
475 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
476 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
477 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
478 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS),
479 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
480 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
481 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
482 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI),
483 .driver_data = APPLE_HAS_FN },
484 { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI),
485 .driver_data = APPLE_HAS_FN },
486 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI),
487 .driver_data = APPLE_HAS_FN },
488 { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI),
489 .driver_data = APPLE_HAS_FN },
490 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
491 .driver_data = APPLE_HAS_FN },
492 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
493 .driver_data = APPLE_HAS_FN },
494 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
495 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
496 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
497 .driver_data = APPLE_HAS_FN },
498 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
499 .driver_data = APPLE_HAS_FN },
500 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
501 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
502 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
503 .driver_data = APPLE_HAS_FN },
504 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
505 .driver_data = APPLE_HAS_FN },
506 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
507 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
508 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI),
509 .driver_data = APPLE_HAS_FN },
510 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO),
511 .driver_data = APPLE_HAS_FN },
512 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS),
513 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
514 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
515 .driver_data = APPLE_HAS_FN },
516 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
517 .driver_data = APPLE_HAS_FN },
518 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
519 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
520 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
521 .driver_data = APPLE_HAS_FN },
522 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
523 .driver_data = APPLE_HAS_FN },
524 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
525 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
526 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
527 .driver_data = APPLE_HAS_FN },
528 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
529 .driver_data = APPLE_HAS_FN },
530 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
531 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
532 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
533 .driver_data = APPLE_HAS_FN },
534 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
535 .driver_data = APPLE_HAS_FN },
536 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
537 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
538 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
539 .driver_data = APPLE_HAS_FN },
540 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
541 .driver_data = APPLE_HAS_FN },
542 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
543 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
544 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
545 .driver_data = APPLE_HAS_FN },
546 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
547 .driver_data = APPLE_HAS_FN },
548 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
549 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
550 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI),
551 .driver_data = APPLE_HAS_FN },
552 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO),
553 .driver_data = APPLE_HAS_FN },
554 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
555 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
556 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
557 .driver_data = APPLE_HAS_FN },
558 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
559 .driver_data = APPLE_HAS_FN },
560 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
561 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
562 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
563 .driver_data = APPLE_HAS_FN },
564 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
565 .driver_data = APPLE_HAS_FN },
566 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
567 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
568 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
569 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
570 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
571 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
572 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
573 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
574 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
575 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
576 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
577 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
581 MODULE_DEVICE_TABLE(hid, apple_devices);
583 static struct hid_driver apple_driver = {
584 .name = "apple",
585 .id_table = apple_devices,
586 .report_fixup = apple_report_fixup,
587 .probe = apple_probe,
588 .event = apple_event,
589 .input_mapping = apple_input_mapping,
590 .input_mapped = apple_input_mapped,
592 module_hid_driver(apple_driver);
594 MODULE_LICENSE("GPL");