blob: eaeca564a8d3e6643f1222f9be032740a158ee0a [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
8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com>
10 */
11
12/*
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the Free
15 * Software Foundation; either version 2 of the License, or (at your option)
16 * any later version.
17 */
18
19#include <linux/device.h>
20#include <linux/hid.h>
21#include <linux/module.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090022#include <linux/slab.h>
Jiri Slaby8c19a512008-06-18 23:36:49 +020023#include <linux/usb.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#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
Paul Collinsb2ddd542009-03-07 17:07:15 +130062static const struct apple_key_translation apple_fn_keys[] = {
Jiri Slaby8c19a512008-06-18 23:36:49 +020063 { KEY_BACKSPACE, KEY_DELETE },
Henrik Rydberg437184a2008-11-04 13:31:38 +010064 { KEY_ENTER, KEY_INSERT },
Jiri Slaby8c19a512008-06-18 23:36:49 +020065 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
66 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
Henrik Rydberg437184a2008-11-04 13:31:38 +010067 { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
68 { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
Jiri Slaby8c19a512008-06-18 23:36:49 +020069 { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
70 { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
71 { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
72 { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
73 { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
74 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
75 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
76 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
77 { KEY_UP, KEY_PAGEUP },
78 { KEY_DOWN, KEY_PAGEDOWN },
79 { KEY_LEFT, KEY_HOME },
80 { KEY_RIGHT, KEY_END },
81 { }
82};
83
Paul Collinsb2ddd542009-03-07 17:07:15 +130084static const struct apple_key_translation powerbook_fn_keys[] = {
Jiri Slaby8c19a512008-06-18 23:36:49 +020085 { KEY_BACKSPACE, KEY_DELETE },
86 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
87 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
88 { KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY },
89 { KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
90 { KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
91 { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY },
92 { KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY },
93 { KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY },
94 { KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
95 { KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
96 { KEY_UP, KEY_PAGEUP },
97 { KEY_DOWN, KEY_PAGEDOWN },
98 { KEY_LEFT, KEY_HOME },
99 { KEY_RIGHT, KEY_END },
100 { }
101};
102
Paul Collinsb2ddd542009-03-07 17:07:15 +1300103static const struct apple_key_translation powerbook_numlock_keys[] = {
Jiri Slaby8c19a512008-06-18 23:36:49 +0200104 { KEY_J, KEY_KP1 },
105 { KEY_K, KEY_KP2 },
106 { KEY_L, KEY_KP3 },
107 { KEY_U, KEY_KP4 },
108 { KEY_I, KEY_KP5 },
109 { KEY_O, KEY_KP6 },
110 { KEY_7, KEY_KP7 },
111 { KEY_8, KEY_KP8 },
112 { KEY_9, KEY_KP9 },
113 { KEY_M, KEY_KP0 },
114 { KEY_DOT, KEY_KPDOT },
115 { KEY_SLASH, KEY_KPPLUS },
116 { KEY_SEMICOLON, KEY_KPMINUS },
117 { KEY_P, KEY_KPASTERISK },
118 { KEY_MINUS, KEY_KPEQUAL },
119 { KEY_0, KEY_KPSLASH },
120 { KEY_F6, KEY_NUMLOCK },
121 { KEY_KPENTER, KEY_KPENTER },
122 { KEY_BACKSPACE, KEY_BACKSPACE },
123 { }
124};
125
Paul Collinsb2ddd542009-03-07 17:07:15 +1300126static const struct apple_key_translation apple_iso_keyboard[] = {
Jiri Slaby8c19a512008-06-18 23:36:49 +0200127 { KEY_GRAVE, KEY_102ND },
128 { KEY_102ND, KEY_GRAVE },
129 { }
130};
131
Paul Collinsb2ddd542009-03-07 17:07:15 +1300132static const struct apple_key_translation *apple_find_translation(
133 const struct apple_key_translation *table, u16 from)
Jiri Slaby8c19a512008-06-18 23:36:49 +0200134{
Paul Collinsb2ddd542009-03-07 17:07:15 +1300135 const struct apple_key_translation *trans;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200136
137 /* Look for the translation */
138 for (trans = table; trans->from; trans++)
139 if (trans->from == from)
140 return trans;
141
142 return NULL;
143}
144
145static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
146 struct hid_usage *usage, __s32 value)
147{
148 struct apple_sc *asc = hid_get_drvdata(hid);
Paul Collinsb2ddd542009-03-07 17:07:15 +1300149 const struct apple_key_translation *trans;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200150
151 if (usage->code == KEY_FN) {
152 asc->fn_on = !!value;
153 input_event(input, usage->type, usage->code, value);
154 return 1;
155 }
156
157 if (fnmode) {
158 int do_translate;
159
Ulrich Dangel2feaace2009-04-28 16:23:51 +0200160 trans = apple_find_translation((hid->product < 0x21d ||
Jiri Slaby8c19a512008-06-18 23:36:49 +0200161 hid->product >= 0x300) ?
162 powerbook_fn_keys : apple_fn_keys,
163 usage->code);
164 if (trans) {
165 if (test_bit(usage->code, asc->pressed_fn))
166 do_translate = 1;
167 else if (trans->flags & APPLE_FLAG_FKEY)
168 do_translate = (fnmode == 2 && asc->fn_on) ||
169 (fnmode == 1 && !asc->fn_on);
170 else
171 do_translate = asc->fn_on;
172
173 if (do_translate) {
174 if (value)
175 set_bit(usage->code, asc->pressed_fn);
176 else
177 clear_bit(usage->code, asc->pressed_fn);
178
179 input_event(input, usage->type, trans->to,
180 value);
181
182 return 1;
183 }
184 }
185
186 if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
187 (test_bit(usage->code, asc->pressed_numlock) ||
188 test_bit(LED_NUML, input->led))) {
189 trans = apple_find_translation(powerbook_numlock_keys,
190 usage->code);
191
192 if (trans) {
193 if (value)
194 set_bit(usage->code,
195 asc->pressed_numlock);
196 else
197 clear_bit(usage->code,
198 asc->pressed_numlock);
199
200 input_event(input, usage->type, trans->to,
201 value);
202 }
203
204 return 1;
205 }
206 }
207
Stefan Glasenhardt54a65932010-01-05 23:30:30 +0100208 if (iso_layout) {
209 if (asc->quirks & APPLE_ISO_KEYBOARD) {
210 trans = apple_find_translation(apple_iso_keyboard, usage->code);
211 if (trans) {
212 input_event(input, usage->type, trans->to, value);
213 return 1;
214 }
Jiri Slaby8c19a512008-06-18 23:36:49 +0200215 }
216 }
217
218 return 0;
219}
220
221static int apple_event(struct hid_device *hdev, struct hid_field *field,
222 struct hid_usage *usage, __s32 value)
223{
224 struct apple_sc *asc = hid_get_drvdata(hdev);
225
226 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
227 !usage->type)
228 return 0;
229
230 if ((asc->quirks & APPLE_INVERT_HWHEEL) &&
231 usage->code == REL_HWHEEL) {
232 input_event(field->hidinput->input, usage->type, usage->code,
233 -value);
234 return 1;
235 }
236
237 if ((asc->quirks & APPLE_HAS_FN) &&
238 hidinput_apple_event(hdev, field->hidinput->input,
239 usage, value))
240 return 1;
241
242
243 return 0;
244}
245
246/*
247 * MacBook JIS keyboard has wrong logical maximum
248 */
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400249static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
250 unsigned int *rsize)
Jiri Slaby8c19a512008-06-18 23:36:49 +0200251{
252 struct apple_sc *asc = hid_get_drvdata(hdev);
253
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400254 if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 &&
Jiri Slaby8c19a512008-06-18 23:36:49 +0200255 rdesc[53] == 0x65 && rdesc[59] == 0x65) {
256 dev_info(&hdev->dev, "fixing up MacBook JIS keyboard report "
257 "descriptor\n");
258 rdesc[53] = rdesc[59] = 0xe7;
259 }
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400260 return rdesc;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200261}
262
263static void apple_setup_input(struct input_dev *input)
264{
Paul Collinsb2ddd542009-03-07 17:07:15 +1300265 const struct apple_key_translation *trans;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200266
267 set_bit(KEY_NUMLOCK, input->keybit);
268
269 /* Enable all needed keys */
270 for (trans = apple_fn_keys; trans->from; trans++)
271 set_bit(trans->to, input->keybit);
272
273 for (trans = powerbook_fn_keys; trans->from; trans++)
274 set_bit(trans->to, input->keybit);
275
276 for (trans = powerbook_numlock_keys; trans->from; trans++)
277 set_bit(trans->to, input->keybit);
278
279 for (trans = apple_iso_keyboard; trans->from; trans++)
280 set_bit(trans->to, input->keybit);
281}
282
283static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
284 struct hid_field *field, struct hid_usage *usage,
285 unsigned long **bit, int *max)
286{
287 if (usage->hid == (HID_UP_CUSTOM | 0x0003)) {
288 /* The fn key on Apple USB keyboards */
289 set_bit(EV_REP, hi->input->evbit);
290 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN);
291 apple_setup_input(hi->input);
292 return 1;
293 }
294
295 /* we want the hid layer to go through standard path (set and ignore) */
296 return 0;
297}
298
299static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi,
300 struct hid_field *field, struct hid_usage *usage,
301 unsigned long **bit, int *max)
302{
303 struct apple_sc *asc = hid_get_drvdata(hdev);
304
305 if (asc->quirks & APPLE_MIGHTYMOUSE) {
306 if (usage->hid == HID_GD_Z)
307 hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL);
308 else if (usage->code == BTN_1)
309 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2);
310 else if (usage->code == BTN_2)
311 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1);
312 }
313
314 return 0;
315}
316
317static int apple_probe(struct hid_device *hdev,
318 const struct hid_device_id *id)
319{
320 unsigned long quirks = id->driver_data;
321 struct apple_sc *asc;
Jiri Slaby93c10132008-06-27 00:04:24 +0200322 unsigned int connect_mask = HID_CONNECT_DEFAULT;
Jiri Slaby8c19a512008-06-18 23:36:49 +0200323 int ret;
324
Jiri Slaby8c19a512008-06-18 23:36:49 +0200325 asc = kzalloc(sizeof(*asc), GFP_KERNEL);
326 if (asc == NULL) {
327 dev_err(&hdev->dev, "can't alloc apple descriptor\n");
328 return -ENOMEM;
329 }
330
331 asc->quirks = quirks;
332
333 hid_set_drvdata(hdev, asc);
334
Jiri Slaby8c19a512008-06-18 23:36:49 +0200335 ret = hid_parse(hdev);
336 if (ret) {
337 dev_err(&hdev->dev, "parse failed\n");
338 goto err_free;
339 }
340
Jiri Slaby93c10132008-06-27 00:04:24 +0200341 if (quirks & APPLE_HIDDEV)
342 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
343 if (quirks & APPLE_IGNORE_HIDINPUT)
344 connect_mask &= ~HID_CONNECT_HIDINPUT;
345
346 ret = hid_hw_start(hdev, connect_mask);
Jiri Slaby8c19a512008-06-18 23:36:49 +0200347 if (ret) {
348 dev_err(&hdev->dev, "hw start failed\n");
349 goto err_free;
350 }
351
352 return 0;
353err_free:
354 kfree(asc);
355 return ret;
356}
357
358static void apple_remove(struct hid_device *hdev)
359{
360 hid_hw_stop(hdev);
361 kfree(hid_get_drvdata(hdev));
362}
363
364static const struct hid_device_id apple_devices[] = {
Peter Korsgaard0f492f22008-10-06 11:15:34 +0200365 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL),
366 .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200367 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4),
368 .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT },
369 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
370 .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
371
372 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200373 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200374 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200375 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200376 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200377 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200378 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO),
379 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200380 APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200381 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200382 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200383 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200384 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200385 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO),
386 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200387 APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200388 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS),
389 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200390 APPLE_RDESC_JIS },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200391 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200392 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200393 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO),
394 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200395 APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200396 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS),
397 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200398 APPLE_RDESC_JIS },
Ryan Finniefef3f572009-03-05 10:18:01 +0100399 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI),
400 .driver_data = APPLE_HAS_FN },
401 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO),
402 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
403 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS),
404 .driver_data = APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200405 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI),
406 .driver_data = APPLE_HAS_FN },
407 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO),
408 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
409 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS),
410 .driver_data = APPLE_HAS_FN },
411 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200412 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200413 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200414 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200415 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
416 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200417 APPLE_RDESC_JIS },
Jan Scholzee8a1a02008-11-26 15:33:45 +0100418 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
Jiri Slaby8c19a512008-06-18 23:36:49 +0200419 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jan Scholzee8a1a02008-11-26 15:33:45 +0100420 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
Jiri Slaby8c19a512008-06-18 23:36:49 +0200421 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
422 APPLE_ISO_KEYBOARD },
Jan Scholzee8a1a02008-11-26 15:33:45 +0100423 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
Jiri Slaby8c19a512008-06-18 23:36:49 +0200424 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
425 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200426 .driver_data = APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200427 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200428 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200429 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200430 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200431 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200432 .driver_data = APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200433 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200434 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200435 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200436 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Henrik Rydberga96d6ef2008-11-04 20:03:45 +0100437 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
438 .driver_data = APPLE_HAS_FN },
439 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
440 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
441 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
442 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
Christian Schuerer-Waldheim23aeb612010-01-06 14:49:57 +0100443 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
444 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
445 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
446 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
447 APPLE_ISO_KEYBOARD },
448 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
449 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200450 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200451 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200452 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
Jiri Slabyb4d8e472008-10-22 14:47:18 +0200453 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Jiri Slaby8c19a512008-06-18 23:36:49 +0200454
Jiri Slaby8c19a512008-06-18 23:36:49 +0200455 { }
456};
457MODULE_DEVICE_TABLE(hid, apple_devices);
458
459static struct hid_driver apple_driver = {
460 .name = "apple",
461 .id_table = apple_devices,
462 .report_fixup = apple_report_fixup,
463 .probe = apple_probe,
464 .remove = apple_remove,
465 .event = apple_event,
466 .input_mapping = apple_input_mapping,
467 .input_mapped = apple_input_mapped,
468};
469
Peter Huewea24f423b2009-07-02 19:08:38 +0200470static int __init apple_init(void)
Jiri Slaby8c19a512008-06-18 23:36:49 +0200471{
472 int ret;
473
474 ret = hid_register_driver(&apple_driver);
475 if (ret)
476 printk(KERN_ERR "can't register apple driver\n");
477
478 return ret;
479}
480
Peter Huewea24f423b2009-07-02 19:08:38 +0200481static void __exit apple_exit(void)
Jiri Slaby8c19a512008-06-18 23:36:49 +0200482{
483 hid_unregister_driver(&apple_driver);
484}
485
486module_init(apple_init);
487module_exit(apple_exit);
488MODULE_LICENSE("GPL");