blob: 881cf7b4f9a433f8ae3e0f6721b3789aa66731f7 [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
Benjamin Tissoiresabf832b2013-07-24 19:38:04 +0200352 asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL);
Jiri Slaby8c19a512008-06-18 23:36:49 +0200353 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");
Benjamin Tissoiresabf832b2013-07-24 19:38:04 +0200365 return ret;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200366 }
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");
Benjamin Tissoiresabf832b2013-07-24 19:38:04 +0200376 return ret;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200377 }
378
379 return 0;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200380}
381
382static const struct hid_device_id apple_devices[] = {
Jiri Slaby8c19a512008-06-18 23:36:49 +0200383 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
384 .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
385
386 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200387 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200388 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200389 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200390 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200391 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200392 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO),
393 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200394 APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200395 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS),
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_GEYSER3_ANSI),
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_GEYSER3_ISO),
400 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200401 APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200402 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS),
403 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200404 APPLE_RDESC_JIS },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200405 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200406 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200407 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO),
408 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200409 APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200410 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS),
411 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200412 APPLE_RDESC_JIS },
Ryan Finniefef3f572009-03-05 10:18:01 +0100413 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI),
414 .driver_data = APPLE_HAS_FN },
415 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO),
416 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
417 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS),
418 .driver_data = APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200419 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI),
420 .driver_data = APPLE_HAS_FN },
421 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO),
422 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
423 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS),
424 .driver_data = APPLE_HAS_FN },
425 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200426 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200427 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO),
Johannes Thumshirn537b6642012-11-03 10:43:31 +0100428 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
429 APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200430 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
431 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200432 APPLE_RDESC_JIS },
Dan Bastone4a4c8792011-07-31 07:40:49 -0400433 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI),
434 .driver_data = APPLE_HAS_FN },
435 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO),
436 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
437 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS),
438 .driver_data = APPLE_HAS_FN },
Jan Scholzee8a1a02008-11-26 15:33:45 +0100439 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
Jiri Slaby8c19a512008-06-18 23:36:49 +0200440 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jan Scholzee8a1a02008-11-26 15:33:45 +0100441 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
Jiri Slaby8c19a512008-06-18 23:36:49 +0200442 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
443 APPLE_ISO_KEYBOARD },
Andreas Kristad734bc2011-10-28 18:50:39 +0200444 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
445 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
446 APPLE_ISO_KEYBOARD },
Alexey Kaminsky0a97e1e2012-04-23 18:02:18 +0200447 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
448 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
449 .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_JIS),
Jiri Slaby8c19a512008-06-18 23:36:49 +0200451 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
452 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200453 .driver_data = APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200454 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200455 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200456 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200457 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200458 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200459 .driver_data = APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200460 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200461 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200462 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200463 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Henrik Rydberga96d6ef2008-11-04 20:03:45 +0100464 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
465 .driver_data = APPLE_HAS_FN },
466 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
467 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
468 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
469 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Edgar (gimli) Hucek99b9f752010-11-03 10:36:18 -0400470 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI),
471 .driver_data = APPLE_HAS_FN },
472 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO),
473 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
474 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS),
475 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
476 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
477 .driver_data = APPLE_HAS_FN },
478 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
479 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
480 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
481 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Andy Botting47340bd2011-03-12 20:27:22 -0800482 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
483 .driver_data = APPLE_HAS_FN },
484 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
485 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
486 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
487 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Joshua V. Dillon5d922ba2011-08-05 12:05:22 -0700488 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
489 .driver_data = APPLE_HAS_FN },
490 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
491 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
492 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
493 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Nobuhiro Iwamatsud762cc22011-10-01 15:54:53 +0900494 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
495 .driver_data = APPLE_HAS_FN },
496 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
497 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
498 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
499 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Gökçen Eraslan213f9da2011-10-22 22:39:06 +0300500 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
501 .driver_data = APPLE_HAS_FN },
502 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
503 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
504 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
505 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Ryan Bourgeoisb2e6ad72012-07-10 09:43:33 -0700506 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
507 .driver_data = APPLE_HAS_FN },
508 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
509 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
510 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
511 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Dirk Hohndel8d80da92012-10-30 11:11:48 -0700512 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI),
513 .driver_data = APPLE_HAS_FN },
514 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO),
515 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
516 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
517 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Dmitry Torokhov9d9a04e2013-07-01 11:46:27 -0700518 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
519 .driver_data = APPLE_HAS_FN },
520 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
521 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
522 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
523 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Christian Schuerer-Waldheim23aeb612010-01-06 14:49:57 +0100524 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
525 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
526 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
527 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
528 APPLE_ISO_KEYBOARD },
529 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
530 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200531 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200532 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200533 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200534 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200535
Jiri Slaby8c19a512008-06-18 23:36:49 +0200536 { }
537};
538MODULE_DEVICE_TABLE(hid, apple_devices);
539
540static struct hid_driver apple_driver = {
541 .name = "apple",
542 .id_table = apple_devices,
543 .report_fixup = apple_report_fixup,
544 .probe = apple_probe,
Jiri Slaby8c19a512008-06-18 23:36:49 +0200545 .event = apple_event,
546 .input_mapping = apple_input_mapping,
547 .input_mapped = apple_input_mapped,
548};
H Hartley Sweetenf4254582012-12-17 15:28:26 -0700549module_hid_driver(apple_driver);
Jiri Slaby8c19a512008-06-18 23:36:49 +0200550
Jiri Slaby8c19a512008-06-18 23:36:49 +0200551MODULE_LICENSE("GPL");