blob: b58ab769aa7b3e6474c888c50ebeed3abe025afc [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
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) 2008 Jiri Slaby <jirislaby@gmail.com>
9 */
10
11/*
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.
16 */
17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19
20#include <linux/device.h>
21#include <linux/hid.h>
22#include <linux/module.h>
23#include <linux/slab.h>
24
25#include "hid-ids.h"
26
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
36
37#define APPLE_FLAG_FKEY 0x01
38
39#define HID_COUNTRY_INTERNATIONAL_ISO 13
40
41static unsigned int fnmode = 1;
42module_param(fnmode, uint, 0644);
43MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
44 "[1] = fkeyslast, 2 = fkeysfirst)");
45
46static unsigned int iso_layout = 1;
47module_param(iso_layout, uint, 0644);
48MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. "
49 "(0 = disabled, [1] = enabled)");
50
51static unsigned int swap_opt_cmd;
52module_param(swap_opt_cmd, uint, 0644);
53MODULE_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
57struct apple_sc {
58 unsigned long quirks;
59 unsigned int fn_on;
60 unsigned int fn_found;
61 DECLARE_BITMAP(pressed_numlock, KEY_CNT);
62};
63
64struct apple_key_translation {
65 u16 from;
66 u16 to;
67 u8 flags;
68};
69
70static 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
91static const struct apple_key_translation apple_fn_keys[] = {
92 { KEY_BACKSPACE, KEY_DELETE },
93 { KEY_ENTER, KEY_INSERT },
94 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
95 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
96 { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
97 { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
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
113static const struct apple_key_translation powerbook_fn_keys[] = {
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
132static const struct apple_key_translation powerbook_numlock_keys[] = {
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
155static const struct apple_key_translation apple_iso_keyboard[] = {
156 { KEY_GRAVE, KEY_102ND },
157 { KEY_102ND, KEY_GRAVE },
158 { }
159};
160
161static 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
169static const struct apple_key_translation *apple_find_translation(
170 const struct apple_key_translation *table, u16 from)
171{
172 const struct apple_key_translation *trans;
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
182static 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);
186 const struct apple_key_translation *trans, *table;
187 bool do_translate;
188 u16 code = 0;
189
190 if (usage->code == KEY_FN) {
191 asc->fn_on = !!value;
192 input_event(input, usage->type, usage->code, value);
193 return 1;
194 }
195
196 if (fnmode) {
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);
206
207 if (trans) {
208 if (test_bit(trans->from, input->key))
209 code = trans->from;
210 else if (test_bit(trans->to, input->key))
211 code = trans->to;
212
213 if (!code) {
214 if (trans->flags & APPLE_FLAG_FKEY) {
215 switch (fnmode) {
216 case 1:
217 do_translate = !asc->fn_on;
218 break;
219 case 2:
220 do_translate = asc->fn_on;
221 break;
222 default:
223 /* should never happen */
224 do_translate = false;
225 }
226 } else {
227 do_translate = asc->fn_on;
228 }
229
230 code = do_translate ? trans->to : trans->from;
231 }
232
233 input_event(input, usage->type, code, value);
234 return 1;
235 }
236
237 if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
238 (test_bit(usage->code, asc->pressed_numlock) ||
239 test_bit(LED_NUML, input->led))) {
240 trans = apple_find_translation(powerbook_numlock_keys,
241 usage->code);
242
243 if (trans) {
244 if (value)
245 set_bit(usage->code,
246 asc->pressed_numlock);
247 else
248 clear_bit(usage->code,
249 asc->pressed_numlock);
250
251 input_event(input, usage->type, trans->to,
252 value);
253 }
254
255 return 1;
256 }
257 }
258
259 if (iso_layout) {
260 if (hid->country == HID_COUNTRY_INTERNATIONAL_ISO) {
261 trans = apple_find_translation(apple_iso_keyboard, usage->code);
262 if (trans) {
263 input_event(input, usage->type, trans->to, value);
264 return 1;
265 }
266 }
267 }
268
269 if (swap_opt_cmd) {
270 trans = apple_find_translation(swapped_option_cmd_keys, usage->code);
271 if (trans) {
272 input_event(input, usage->type, trans->to, value);
273 return 1;
274 }
275 }
276
277 return 0;
278}
279
280static int apple_event(struct hid_device *hdev, struct hid_field *field,
281 struct hid_usage *usage, __s32 value)
282{
283 struct apple_sc *asc = hid_get_drvdata(hdev);
284
285 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
286 !usage->type)
287 return 0;
288
289 if ((asc->quirks & APPLE_INVERT_HWHEEL) &&
290 usage->code == REL_HWHEEL) {
291 input_event(field->hidinput->input, usage->type, usage->code,
292 -value);
293 return 1;
294 }
295
296 if ((asc->quirks & APPLE_HAS_FN) &&
297 hidinput_apple_event(hdev, field->hidinput->input,
298 usage, value))
299 return 1;
300
301
302 return 0;
303}
304
305/*
306 * MacBook JIS keyboard has wrong logical maximum
307 */
308static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
309 unsigned int *rsize)
310{
311 struct apple_sc *asc = hid_get_drvdata(hdev);
312
313 if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 &&
314 rdesc[53] == 0x65 && rdesc[59] == 0x65) {
315 hid_info(hdev,
316 "fixing up MacBook JIS keyboard report descriptor\n");
317 rdesc[53] = rdesc[59] = 0xe7;
318 }
319 return rdesc;
320}
321
322static void apple_setup_input(struct input_dev *input)
323{
324 const struct apple_key_translation *trans;
325
326 set_bit(KEY_NUMLOCK, input->keybit);
327
328 /* Enable all needed keys */
329 for (trans = apple_fn_keys; trans->from; trans++)
330 set_bit(trans->to, input->keybit);
331
332 for (trans = powerbook_fn_keys; trans->from; trans++)
333 set_bit(trans->to, input->keybit);
334
335 for (trans = powerbook_numlock_keys; trans->from; trans++)
336 set_bit(trans->to, input->keybit);
337
338 for (trans = apple_iso_keyboard; trans->from; trans++)
339 set_bit(trans->to, input->keybit);
340}
341
342static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
343 struct hid_field *field, struct hid_usage *usage,
344 unsigned long **bit, int *max)
345{
346 struct apple_sc *asc = hid_get_drvdata(hdev);
347
348 if (usage->hid == (HID_UP_CUSTOM | 0x0003) ||
349 usage->hid == (HID_UP_MSVENDOR | 0x0003) ||
350 usage->hid == (HID_UP_HPVENDOR2 | 0x0003)) {
351 /* The fn key on Apple USB keyboards */
352 set_bit(EV_REP, hi->input->evbit);
353 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN);
354 asc->fn_found = true;
355 apple_setup_input(hi->input);
356 return 1;
357 }
358
359 /* we want the hid layer to go through standard path (set and ignore) */
360 return 0;
361}
362
363static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi,
364 struct hid_field *field, struct hid_usage *usage,
365 unsigned long **bit, int *max)
366{
367 struct apple_sc *asc = hid_get_drvdata(hdev);
368
369 if (asc->quirks & APPLE_MIGHTYMOUSE) {
370 if (usage->hid == HID_GD_Z)
371 hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL);
372 else if (usage->code == BTN_1)
373 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2);
374 else if (usage->code == BTN_2)
375 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1);
376 }
377
378 return 0;
379}
380
381static int apple_input_configured(struct hid_device *hdev,
382 struct hid_input *hidinput)
383{
384 struct apple_sc *asc = hid_get_drvdata(hdev);
385
386 if ((asc->quirks & APPLE_HAS_FN) && !asc->fn_found) {
387 hid_info(hdev, "Fn key not found (Apple Wireless Keyboard clone?), disabling Fn key handling\n");
388 asc->quirks = 0;
389 }
390
391 return 0;
392}
393
394static int apple_probe(struct hid_device *hdev,
395 const struct hid_device_id *id)
396{
397 unsigned long quirks = id->driver_data;
398 struct apple_sc *asc;
399 unsigned int connect_mask = HID_CONNECT_DEFAULT;
400 int ret;
401
402 asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL);
403 if (asc == NULL) {
404 hid_err(hdev, "can't alloc apple descriptor\n");
405 return -ENOMEM;
406 }
407
408 asc->quirks = quirks;
409
410 hid_set_drvdata(hdev, asc);
411
412 ret = hid_parse(hdev);
413 if (ret) {
414 hid_err(hdev, "parse failed\n");
415 return ret;
416 }
417
418 if (quirks & APPLE_HIDDEV)
419 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
420 if (quirks & APPLE_IGNORE_HIDINPUT)
421 connect_mask &= ~HID_CONNECT_HIDINPUT;
422
423 ret = hid_hw_start(hdev, connect_mask);
424 if (ret) {
425 hid_err(hdev, "hw start failed\n");
426 return ret;
427 }
428
429 return 0;
430}
431
432static const struct hid_device_id apple_devices[] = {
433 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
434 .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
435
436 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI),
437 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
438 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO),
439 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
440 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI),
441 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
442 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO),
443 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
444 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS),
445 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
446 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI),
447 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
448 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO),
449 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
450 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS),
451 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
452 APPLE_RDESC_JIS },
453 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI),
454 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
455 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO),
456 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
457 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS),
458 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
459 APPLE_RDESC_JIS },
460 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI),
461 .driver_data = APPLE_HAS_FN },
462 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO),
463 .driver_data = APPLE_HAS_FN },
464 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS),
465 .driver_data = APPLE_HAS_FN },
466 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI),
467 .driver_data = APPLE_HAS_FN },
468 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO),
469 .driver_data = APPLE_HAS_FN },
470 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS),
471 .driver_data = APPLE_HAS_FN },
472 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI),
473 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
474 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO),
475 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
476 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
477 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
478 APPLE_RDESC_JIS },
479 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI),
480 .driver_data = APPLE_HAS_FN },
481 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO),
482 .driver_data = APPLE_HAS_FN },
483 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS),
484 .driver_data = APPLE_HAS_FN },
485 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
486 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
487 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
488 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
489 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
490 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
491 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
492 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
493 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
494 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
495 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS),
496 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
497 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
498 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
499 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI),
500 .driver_data = APPLE_HAS_FN },
501 { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI),
502 .driver_data = APPLE_HAS_FN },
503 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI),
504 .driver_data = APPLE_HAS_FN },
505 { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI),
506 .driver_data = APPLE_HAS_FN },
507 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
508 .driver_data = APPLE_HAS_FN },
509 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
510 .driver_data = APPLE_HAS_FN },
511 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
512 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
513 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
514 .driver_data = APPLE_HAS_FN },
515 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
516 .driver_data = APPLE_HAS_FN },
517 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
518 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
519 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
520 .driver_data = APPLE_HAS_FN },
521 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
522 .driver_data = APPLE_HAS_FN },
523 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
524 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
525 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI),
526 .driver_data = APPLE_HAS_FN },
527 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO),
528 .driver_data = APPLE_HAS_FN },
529 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS),
530 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
531 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
532 .driver_data = APPLE_HAS_FN },
533 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
534 .driver_data = APPLE_HAS_FN },
535 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
536 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
537 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
538 .driver_data = APPLE_HAS_FN },
539 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
540 .driver_data = APPLE_HAS_FN },
541 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
542 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
543 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
544 .driver_data = APPLE_HAS_FN },
545 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
546 .driver_data = APPLE_HAS_FN },
547 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
548 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
549 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
550 .driver_data = APPLE_HAS_FN },
551 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
552 .driver_data = APPLE_HAS_FN },
553 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
554 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
555 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
556 .driver_data = APPLE_HAS_FN },
557 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
558 .driver_data = APPLE_HAS_FN },
559 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
560 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
561 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
562 .driver_data = APPLE_HAS_FN },
563 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
564 .driver_data = APPLE_HAS_FN },
565 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
566 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
567 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI),
568 .driver_data = APPLE_HAS_FN },
569 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO),
570 .driver_data = APPLE_HAS_FN },
571 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
572 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
573 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
574 .driver_data = APPLE_HAS_FN },
575 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
576 .driver_data = APPLE_HAS_FN },
577 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
578 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
579 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
580 .driver_data = APPLE_HAS_FN },
581 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
582 .driver_data = APPLE_HAS_FN },
583 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
584 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
585 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
586 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
587 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
588 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
589 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
590 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
591 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
592 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
593 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
594 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
595
596 { }
597};
598MODULE_DEVICE_TABLE(hid, apple_devices);
599
600static struct hid_driver apple_driver = {
601 .name = "apple",
602 .id_table = apple_devices,
603 .report_fixup = apple_report_fixup,
604 .probe = apple_probe,
605 .event = apple_event,
606 .input_mapping = apple_input_mapping,
607 .input_mapped = apple_input_mapped,
608 .input_configured = apple_input_configured,
609};
610module_hid_driver(apple_driver);
611
612MODULE_LICENSE("GPL");