blob: c7710b5c69afbf009d0e9f2d727668e6cdae5045 [file] [log] [blame]
Jiri Slaby8c19a512008-06-18 23:36:49 +02001/*
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
Jiri Slaby8c19a512008-06-18 23:36:49 +02008 * 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
Joe Perches4291ee32010-12-09 19:29:03 -080018#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19
Jiri Slaby8c19a512008-06-18 23:36:49 +020020#include <linux/device.h>
21#include <linux/hid.h>
22#include <linux/module.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090023#include <linux/slab.h>
Jiri Slaby8c19a512008-06-18 23:36:49 +020024
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#define APPLE_ISO_KEYBOARD 0x0010
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
39static unsigned int fnmode = 1;
40module_param(fnmode, uint, 0644);
41MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
42 "[1] = fkeyslast, 2 = fkeysfirst)");
43
Stefan Glasenhardt54a65932010-01-05 23:30:30 +010044static unsigned int iso_layout = 1;
45module_param(iso_layout, uint, 0644);
46MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. "
47 "(0 = disabled, [1] = enabled)");
48
Jiri Slaby8c19a512008-06-18 23:36:49 +020049struct apple_sc {
50 unsigned long quirks;
51 unsigned int fn_on;
52 DECLARE_BITMAP(pressed_fn, KEY_CNT);
53 DECLARE_BITMAP(pressed_numlock, KEY_CNT);
54};
55
56struct apple_key_translation {
57 u16 from;
58 u16 to;
59 u8 flags;
60};
61
Edgar (gimli) Hucek99b9f752010-11-03 10:36:18 -040062static const struct apple_key_translation macbookair_fn_keys[] = {
63 { KEY_BACKSPACE, KEY_DELETE },
64 { KEY_ENTER, KEY_INSERT },
65 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
66 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
67 { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
68 { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
69 { KEY_F6, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
70 { KEY_F7, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
71 { KEY_F8, KEY_NEXTSONG, APPLE_FLAG_FKEY },
72 { KEY_F9, KEY_MUTE, APPLE_FLAG_FKEY },
73 { KEY_F10, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
74 { KEY_F11, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
75 { KEY_F12, KEY_EJECTCD, APPLE_FLAG_FKEY },
76 { KEY_UP, KEY_PAGEUP },
77 { KEY_DOWN, KEY_PAGEDOWN },
78 { KEY_LEFT, KEY_HOME },
79 { KEY_RIGHT, KEY_END },
80 { }
81};
82
Paul Collinsb2ddd542009-03-07 17:07:15 +130083static const struct apple_key_translation apple_fn_keys[] = {
Jiri Slaby8c19a512008-06-18 23:36:49 +020084 { KEY_BACKSPACE, KEY_DELETE },
Henrik Rydberg437184a2008-11-04 13:31:38 +010085 { KEY_ENTER, KEY_INSERT },
Jiri Slaby8c19a512008-06-18 23:36:49 +020086 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
87 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
Henrik Rydberg437184a2008-11-04 13:31:38 +010088 { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
89 { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
Jiri Slaby8c19a512008-06-18 23:36:49 +020090 { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
91 { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
92 { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
93 { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
94 { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
95 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
96 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
97 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
98 { KEY_UP, KEY_PAGEUP },
99 { KEY_DOWN, KEY_PAGEDOWN },
100 { KEY_LEFT, KEY_HOME },
101 { KEY_RIGHT, KEY_END },
102 { }
103};
104
Paul Collinsb2ddd542009-03-07 17:07:15 +1300105static const struct apple_key_translation powerbook_fn_keys[] = {
Jiri Slaby8c19a512008-06-18 23:36:49 +0200106 { KEY_BACKSPACE, KEY_DELETE },
107 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
108 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
109 { KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY },
110 { KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
111 { KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
112 { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY },
113 { KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY },
114 { KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY },
115 { KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
116 { KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
117 { KEY_UP, KEY_PAGEUP },
118 { KEY_DOWN, KEY_PAGEDOWN },
119 { KEY_LEFT, KEY_HOME },
120 { KEY_RIGHT, KEY_END },
121 { }
122};
123
Paul Collinsb2ddd542009-03-07 17:07:15 +1300124static const struct apple_key_translation powerbook_numlock_keys[] = {
Jiri Slaby8c19a512008-06-18 23:36:49 +0200125 { KEY_J, KEY_KP1 },
126 { KEY_K, KEY_KP2 },
127 { KEY_L, KEY_KP3 },
128 { KEY_U, KEY_KP4 },
129 { KEY_I, KEY_KP5 },
130 { KEY_O, KEY_KP6 },
131 { KEY_7, KEY_KP7 },
132 { KEY_8, KEY_KP8 },
133 { KEY_9, KEY_KP9 },
134 { KEY_M, KEY_KP0 },
135 { KEY_DOT, KEY_KPDOT },
136 { KEY_SLASH, KEY_KPPLUS },
137 { KEY_SEMICOLON, KEY_KPMINUS },
138 { KEY_P, KEY_KPASTERISK },
139 { KEY_MINUS, KEY_KPEQUAL },
140 { KEY_0, KEY_KPSLASH },
141 { KEY_F6, KEY_NUMLOCK },
142 { KEY_KPENTER, KEY_KPENTER },
143 { KEY_BACKSPACE, KEY_BACKSPACE },
144 { }
145};
146
Paul Collinsb2ddd542009-03-07 17:07:15 +1300147static const struct apple_key_translation apple_iso_keyboard[] = {
Jiri Slaby8c19a512008-06-18 23:36:49 +0200148 { KEY_GRAVE, KEY_102ND },
149 { KEY_102ND, KEY_GRAVE },
150 { }
151};
152
Paul Collinsb2ddd542009-03-07 17:07:15 +1300153static const struct apple_key_translation *apple_find_translation(
154 const struct apple_key_translation *table, u16 from)
Jiri Slaby8c19a512008-06-18 23:36:49 +0200155{
Paul Collinsb2ddd542009-03-07 17:07:15 +1300156 const struct apple_key_translation *trans;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200157
158 /* Look for the translation */
159 for (trans = table; trans->from; trans++)
160 if (trans->from == from)
161 return trans;
162
163 return NULL;
164}
165
166static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
167 struct hid_usage *usage, __s32 value)
168{
169 struct apple_sc *asc = hid_get_drvdata(hid);
Jiri Kosinaa4bc6922010-11-03 10:42:02 -0400170 const struct apple_key_translation *trans, *table;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200171
172 if (usage->code == KEY_FN) {
173 asc->fn_on = !!value;
174 input_event(input, usage->type, usage->code, value);
175 return 1;
176 }
177
178 if (fnmode) {
179 int do_translate;
180
Jiri Kosinaa4bc6922010-11-03 10:42:02 -0400181 if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
182 hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
183 table = macbookair_fn_keys;
184 else if (hid->product < 0x21d || hid->product >= 0x300)
185 table = powerbook_fn_keys;
186 else
187 table = apple_fn_keys;
188
189 trans = apple_find_translation (table, usage->code);
Edgar (gimli) Hucek99b9f752010-11-03 10:36:18 -0400190
Jiri Slaby8c19a512008-06-18 23:36:49 +0200191 if (trans) {
192 if (test_bit(usage->code, asc->pressed_fn))
193 do_translate = 1;
194 else if (trans->flags & APPLE_FLAG_FKEY)
195 do_translate = (fnmode == 2 && asc->fn_on) ||
196 (fnmode == 1 && !asc->fn_on);
197 else
198 do_translate = asc->fn_on;
199
200 if (do_translate) {
201 if (value)
202 set_bit(usage->code, asc->pressed_fn);
203 else
204 clear_bit(usage->code, asc->pressed_fn);
205
206 input_event(input, usage->type, trans->to,
207 value);
208
209 return 1;
210 }
211 }
212
213 if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
214 (test_bit(usage->code, asc->pressed_numlock) ||
215 test_bit(LED_NUML, input->led))) {
216 trans = apple_find_translation(powerbook_numlock_keys,
217 usage->code);
218
219 if (trans) {
220 if (value)
221 set_bit(usage->code,
222 asc->pressed_numlock);
223 else
224 clear_bit(usage->code,
225 asc->pressed_numlock);
226
227 input_event(input, usage->type, trans->to,
228 value);
229 }
230
231 return 1;
232 }
233 }
234
Benedikt Bergenthal9f1f4632012-04-18 12:22:40 +0200235 if (iso_layout) {
Stefan Glasenhardt54a65932010-01-05 23:30:30 +0100236 if (asc->quirks & APPLE_ISO_KEYBOARD) {
237 trans = apple_find_translation(apple_iso_keyboard, usage->code);
238 if (trans) {
239 input_event(input, usage->type, trans->to, value);
240 return 1;
241 }
Jiri Slaby8c19a512008-06-18 23:36:49 +0200242 }
243 }
244
245 return 0;
246}
247
248static int apple_event(struct hid_device *hdev, struct hid_field *field,
249 struct hid_usage *usage, __s32 value)
250{
251 struct apple_sc *asc = hid_get_drvdata(hdev);
252
253 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
254 !usage->type)
255 return 0;
256
257 if ((asc->quirks & APPLE_INVERT_HWHEEL) &&
258 usage->code == REL_HWHEEL) {
259 input_event(field->hidinput->input, usage->type, usage->code,
260 -value);
261 return 1;
262 }
263
264 if ((asc->quirks & APPLE_HAS_FN) &&
265 hidinput_apple_event(hdev, field->hidinput->input,
266 usage, value))
267 return 1;
268
269
270 return 0;
271}
272
273/*
274 * MacBook JIS keyboard has wrong logical maximum
275 */
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400276static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
277 unsigned int *rsize)
Jiri Slaby8c19a512008-06-18 23:36:49 +0200278{
279 struct apple_sc *asc = hid_get_drvdata(hdev);
280
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400281 if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 &&
Jiri Slaby8c19a512008-06-18 23:36:49 +0200282 rdesc[53] == 0x65 && rdesc[59] == 0x65) {
Joe Perches4291ee32010-12-09 19:29:03 -0800283 hid_info(hdev,
284 "fixing up MacBook JIS keyboard report descriptor\n");
Jiri Slaby8c19a512008-06-18 23:36:49 +0200285 rdesc[53] = rdesc[59] = 0xe7;
286 }
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400287 return rdesc;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200288}
289
290static void apple_setup_input(struct input_dev *input)
291{
Paul Collinsb2ddd542009-03-07 17:07:15 +1300292 const struct apple_key_translation *trans;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200293
294 set_bit(KEY_NUMLOCK, input->keybit);
295
296 /* Enable all needed keys */
297 for (trans = apple_fn_keys; trans->from; trans++)
298 set_bit(trans->to, input->keybit);
299
300 for (trans = powerbook_fn_keys; trans->from; trans++)
301 set_bit(trans->to, input->keybit);
302
303 for (trans = powerbook_numlock_keys; trans->from; trans++)
304 set_bit(trans->to, input->keybit);
305
306 for (trans = apple_iso_keyboard; trans->from; trans++)
307 set_bit(trans->to, input->keybit);
308}
309
310static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
311 struct hid_field *field, struct hid_usage *usage,
312 unsigned long **bit, int *max)
313{
314 if (usage->hid == (HID_UP_CUSTOM | 0x0003)) {
315 /* The fn key on Apple USB keyboards */
316 set_bit(EV_REP, hi->input->evbit);
317 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN);
318 apple_setup_input(hi->input);
319 return 1;
320 }
321
322 /* we want the hid layer to go through standard path (set and ignore) */
323 return 0;
324}
325
326static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi,
327 struct hid_field *field, struct hid_usage *usage,
328 unsigned long **bit, int *max)
329{
330 struct apple_sc *asc = hid_get_drvdata(hdev);
331
332 if (asc->quirks & APPLE_MIGHTYMOUSE) {
333 if (usage->hid == HID_GD_Z)
334 hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL);
335 else if (usage->code == BTN_1)
336 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2);
337 else if (usage->code == BTN_2)
338 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1);
339 }
340
341 return 0;
342}
343
344static int apple_probe(struct hid_device *hdev,
345 const struct hid_device_id *id)
346{
347 unsigned long quirks = id->driver_data;
348 struct apple_sc *asc;
Jiri Slaby93c10132008-06-27 00:04:24 +0200349 unsigned int connect_mask = HID_CONNECT_DEFAULT;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200350 int ret;
351
Jiri Slaby8c19a512008-06-18 23:36:49 +0200352 asc = kzalloc(sizeof(*asc), GFP_KERNEL);
353 if (asc == NULL) {
Joe Perches4291ee32010-12-09 19:29:03 -0800354 hid_err(hdev, "can't alloc apple descriptor\n");
Jiri Slaby8c19a512008-06-18 23:36:49 +0200355 return -ENOMEM;
356 }
357
358 asc->quirks = quirks;
359
360 hid_set_drvdata(hdev, asc);
361
Jiri Slaby8c19a512008-06-18 23:36:49 +0200362 ret = hid_parse(hdev);
363 if (ret) {
Joe Perches4291ee32010-12-09 19:29:03 -0800364 hid_err(hdev, "parse failed\n");
Jiri Slaby8c19a512008-06-18 23:36:49 +0200365 goto err_free;
366 }
367
Jiri Slaby93c10132008-06-27 00:04:24 +0200368 if (quirks & APPLE_HIDDEV)
369 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
370 if (quirks & APPLE_IGNORE_HIDINPUT)
371 connect_mask &= ~HID_CONNECT_HIDINPUT;
372
373 ret = hid_hw_start(hdev, connect_mask);
Jiri Slaby8c19a512008-06-18 23:36:49 +0200374 if (ret) {
Joe Perches4291ee32010-12-09 19:29:03 -0800375 hid_err(hdev, "hw start failed\n");
Jiri Slaby8c19a512008-06-18 23:36:49 +0200376 goto err_free;
377 }
378
379 return 0;
380err_free:
381 kfree(asc);
382 return ret;
383}
384
385static void apple_remove(struct hid_device *hdev)
386{
387 hid_hw_stop(hdev);
388 kfree(hid_get_drvdata(hdev));
389}
390
391static const struct hid_device_id apple_devices[] = {
Jiri Slaby8c19a512008-06-18 23:36:49 +0200392 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
393 .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
394
395 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200396 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200397 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200398 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200399 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200400 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200401 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO),
402 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200403 APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200404 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200405 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200406 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200407 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200408 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO),
409 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200410 APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200411 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS),
412 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200413 APPLE_RDESC_JIS },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200414 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200415 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200416 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO),
417 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200418 APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200419 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS),
420 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200421 APPLE_RDESC_JIS },
Ryan Finniefef3f572009-03-05 10:18:01 +0100422 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI),
423 .driver_data = APPLE_HAS_FN },
424 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO),
425 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
426 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS),
427 .driver_data = APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200428 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI),
429 .driver_data = APPLE_HAS_FN },
430 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO),
431 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
432 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS),
433 .driver_data = APPLE_HAS_FN },
434 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200435 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200436 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO),
Johannes Thumshirn537b6642012-11-03 10:43:31 +0100437 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
438 APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200439 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
440 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200441 APPLE_RDESC_JIS },
Dan Bastone4a4c8792011-07-31 07:40:49 -0400442 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI),
443 .driver_data = APPLE_HAS_FN },
444 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO),
445 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
446 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS),
447 .driver_data = APPLE_HAS_FN },
Jan Scholzee8a1a02008-11-26 15:33:45 +0100448 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
Jiri Slaby8c19a512008-06-18 23:36:49 +0200449 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jan Scholzee8a1a02008-11-26 15:33:45 +0100450 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
Jiri Slaby8c19a512008-06-18 23:36:49 +0200451 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
452 APPLE_ISO_KEYBOARD },
Andreas Kristad734bc2011-10-28 18:50:39 +0200453 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
454 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
455 APPLE_ISO_KEYBOARD },
Alexey Kaminsky0a97e1e2012-04-23 18:02:18 +0200456 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
457 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
458 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jan Scholzee8a1a02008-11-26 15:33:45 +0100459 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
Jiri Slaby8c19a512008-06-18 23:36:49 +0200460 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
461 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200462 .driver_data = APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200463 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200464 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200465 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200466 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200467 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200468 .driver_data = APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200469 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200470 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200471 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200472 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Henrik Rydberga96d6ef2008-11-04 20:03:45 +0100473 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
474 .driver_data = APPLE_HAS_FN },
475 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
476 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
477 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
478 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Edgar (gimli) Hucek99b9f752010-11-03 10:36:18 -0400479 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI),
480 .driver_data = APPLE_HAS_FN },
481 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO),
482 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
483 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS),
484 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
485 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
486 .driver_data = APPLE_HAS_FN },
487 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
488 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
489 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
490 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Andy Botting47340bd2011-03-12 20:27:22 -0800491 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
492 .driver_data = APPLE_HAS_FN },
493 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
494 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
495 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
496 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Joshua V. Dillon5d922ba2011-08-05 12:05:22 -0700497 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
498 .driver_data = APPLE_HAS_FN },
499 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
500 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
501 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
502 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Nobuhiro Iwamatsud762cc22011-10-01 15:54:53 +0900503 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
504 .driver_data = APPLE_HAS_FN },
505 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
506 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
507 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
508 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Gökçen Eraslan213f9da2011-10-22 22:39:06 +0300509 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
510 .driver_data = APPLE_HAS_FN },
511 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
512 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
513 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
514 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Ryan Bourgeoisb2e6ad72012-07-10 09:43:33 -0700515 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
516 .driver_data = APPLE_HAS_FN },
517 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
518 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
519 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
520 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Dirk Hohndel8d80da92012-10-30 11:11:48 -0700521 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI),
522 .driver_data = APPLE_HAS_FN },
523 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO),
524 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
525 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
526 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Dmitry Torokhov9d9a04e2013-07-01 11:46:27 -0700527 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
528 .driver_data = APPLE_HAS_FN },
529 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
530 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
531 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
532 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Christian Schuerer-Waldheim23aeb612010-01-06 14:49:57 +0100533 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
534 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
535 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
536 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
537 APPLE_ISO_KEYBOARD },
538 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
539 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200540 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200541 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200542 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200543 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200544
Jiri Slaby8c19a512008-06-18 23:36:49 +0200545 { }
546};
547MODULE_DEVICE_TABLE(hid, apple_devices);
548
549static struct hid_driver apple_driver = {
550 .name = "apple",
551 .id_table = apple_devices,
552 .report_fixup = apple_report_fixup,
553 .probe = apple_probe,
554 .remove = apple_remove,
555 .event = apple_event,
556 .input_mapping = apple_input_mapping,
557 .input_mapped = apple_input_mapped,
558};
H Hartley Sweetenf4254582012-12-17 15:28:26 -0700559module_hid_driver(apple_driver);
Jiri Slaby8c19a512008-06-18 23:36:49 +0200560
Jiri Slaby8c19a512008-06-18 23:36:49 +0200561MODULE_LICENSE("GPL");