Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1 | /* |
| 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 Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 22 | #include <linux/slab.h> |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 23 | #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 | |
| 39 | static unsigned int fnmode = 1; |
| 40 | module_param(fnmode, uint, 0644); |
| 41 | MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, " |
| 42 | "[1] = fkeyslast, 2 = fkeysfirst)"); |
| 43 | |
Stefan Glasenhardt | 54a6593 | 2010-01-05 23:30:30 +0100 | [diff] [blame] | 44 | static unsigned int iso_layout = 1; |
| 45 | module_param(iso_layout, uint, 0644); |
| 46 | MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. " |
| 47 | "(0 = disabled, [1] = enabled)"); |
| 48 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 49 | struct 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 | |
| 56 | struct apple_key_translation { |
| 57 | u16 from; |
| 58 | u16 to; |
| 59 | u8 flags; |
| 60 | }; |
| 61 | |
Edgar (gimli) Hucek | 99b9f75 | 2010-11-03 10:36:18 -0400 | [diff] [blame^] | 62 | static 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 Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 83 | static const struct apple_key_translation apple_fn_keys[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 84 | { KEY_BACKSPACE, KEY_DELETE }, |
Henrik Rydberg | 437184a | 2008-11-04 13:31:38 +0100 | [diff] [blame] | 85 | { KEY_ENTER, KEY_INSERT }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 86 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, |
| 87 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, |
Henrik Rydberg | 437184a | 2008-11-04 13:31:38 +0100 | [diff] [blame] | 88 | { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY }, |
| 89 | { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 90 | { 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 Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 105 | static const struct apple_key_translation powerbook_fn_keys[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 106 | { 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 Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 124 | static const struct apple_key_translation powerbook_numlock_keys[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 125 | { 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 Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 147 | static const struct apple_key_translation apple_iso_keyboard[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 148 | { KEY_GRAVE, KEY_102ND }, |
| 149 | { KEY_102ND, KEY_GRAVE }, |
| 150 | { } |
| 151 | }; |
| 152 | |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 153 | static const struct apple_key_translation *apple_find_translation( |
| 154 | const struct apple_key_translation *table, u16 from) |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 155 | { |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 156 | const struct apple_key_translation *trans; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 157 | |
| 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 | |
| 166 | static 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); |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 170 | const struct apple_key_translation *trans; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 171 | |
| 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 | |
Edgar (gimli) Hucek | 99b9f75 | 2010-11-03 10:36:18 -0400 | [diff] [blame^] | 181 | if(hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI && |
| 182 | hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) { |
| 183 | trans = apple_find_translation(macbookair_fn_keys, usage->code); |
| 184 | } else if (hid->product < 0x21d || hid->product >= 0x300) { |
| 185 | trans = apple_find_translation(powerbook_fn_keys, usage->code); |
| 186 | } else { |
| 187 | trans = apple_find_translation(apple_fn_keys, usage->code); |
| 188 | } |
| 189 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 190 | if (trans) { |
| 191 | if (test_bit(usage->code, asc->pressed_fn)) |
| 192 | do_translate = 1; |
| 193 | else if (trans->flags & APPLE_FLAG_FKEY) |
| 194 | do_translate = (fnmode == 2 && asc->fn_on) || |
| 195 | (fnmode == 1 && !asc->fn_on); |
| 196 | else |
| 197 | do_translate = asc->fn_on; |
| 198 | |
| 199 | if (do_translate) { |
| 200 | if (value) |
| 201 | set_bit(usage->code, asc->pressed_fn); |
| 202 | else |
| 203 | clear_bit(usage->code, asc->pressed_fn); |
| 204 | |
| 205 | input_event(input, usage->type, trans->to, |
| 206 | value); |
| 207 | |
| 208 | return 1; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | if (asc->quirks & APPLE_NUMLOCK_EMULATION && |
| 213 | (test_bit(usage->code, asc->pressed_numlock) || |
| 214 | test_bit(LED_NUML, input->led))) { |
| 215 | trans = apple_find_translation(powerbook_numlock_keys, |
| 216 | usage->code); |
| 217 | |
| 218 | if (trans) { |
| 219 | if (value) |
| 220 | set_bit(usage->code, |
| 221 | asc->pressed_numlock); |
| 222 | else |
| 223 | clear_bit(usage->code, |
| 224 | asc->pressed_numlock); |
| 225 | |
| 226 | input_event(input, usage->type, trans->to, |
| 227 | value); |
| 228 | } |
| 229 | |
| 230 | return 1; |
| 231 | } |
| 232 | } |
| 233 | |
Stefan Glasenhardt | 54a6593 | 2010-01-05 23:30:30 +0100 | [diff] [blame] | 234 | if (iso_layout) { |
| 235 | if (asc->quirks & APPLE_ISO_KEYBOARD) { |
| 236 | trans = apple_find_translation(apple_iso_keyboard, usage->code); |
| 237 | if (trans) { |
| 238 | input_event(input, usage->type, trans->to, value); |
| 239 | return 1; |
| 240 | } |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 241 | } |
| 242 | } |
| 243 | |
| 244 | return 0; |
| 245 | } |
| 246 | |
| 247 | static int apple_event(struct hid_device *hdev, struct hid_field *field, |
| 248 | struct hid_usage *usage, __s32 value) |
| 249 | { |
| 250 | struct apple_sc *asc = hid_get_drvdata(hdev); |
| 251 | |
| 252 | if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput || |
| 253 | !usage->type) |
| 254 | return 0; |
| 255 | |
| 256 | if ((asc->quirks & APPLE_INVERT_HWHEEL) && |
| 257 | usage->code == REL_HWHEEL) { |
| 258 | input_event(field->hidinput->input, usage->type, usage->code, |
| 259 | -value); |
| 260 | return 1; |
| 261 | } |
| 262 | |
| 263 | if ((asc->quirks & APPLE_HAS_FN) && |
| 264 | hidinput_apple_event(hdev, field->hidinput->input, |
| 265 | usage, value)) |
| 266 | return 1; |
| 267 | |
| 268 | |
| 269 | return 0; |
| 270 | } |
| 271 | |
| 272 | /* |
| 273 | * MacBook JIS keyboard has wrong logical maximum |
| 274 | */ |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 275 | static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
| 276 | unsigned int *rsize) |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 277 | { |
| 278 | struct apple_sc *asc = hid_get_drvdata(hdev); |
| 279 | |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 280 | if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 && |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 281 | rdesc[53] == 0x65 && rdesc[59] == 0x65) { |
| 282 | dev_info(&hdev->dev, "fixing up MacBook JIS keyboard report " |
| 283 | "descriptor\n"); |
| 284 | rdesc[53] = rdesc[59] = 0xe7; |
| 285 | } |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 286 | return rdesc; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | static void apple_setup_input(struct input_dev *input) |
| 290 | { |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 291 | const struct apple_key_translation *trans; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 292 | |
| 293 | set_bit(KEY_NUMLOCK, input->keybit); |
| 294 | |
| 295 | /* Enable all needed keys */ |
| 296 | for (trans = apple_fn_keys; trans->from; trans++) |
| 297 | set_bit(trans->to, input->keybit); |
| 298 | |
| 299 | for (trans = powerbook_fn_keys; trans->from; trans++) |
| 300 | set_bit(trans->to, input->keybit); |
| 301 | |
| 302 | for (trans = powerbook_numlock_keys; trans->from; trans++) |
| 303 | set_bit(trans->to, input->keybit); |
| 304 | |
| 305 | for (trans = apple_iso_keyboard; trans->from; trans++) |
| 306 | set_bit(trans->to, input->keybit); |
| 307 | } |
| 308 | |
| 309 | static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 310 | struct hid_field *field, struct hid_usage *usage, |
| 311 | unsigned long **bit, int *max) |
| 312 | { |
| 313 | if (usage->hid == (HID_UP_CUSTOM | 0x0003)) { |
| 314 | /* The fn key on Apple USB keyboards */ |
| 315 | set_bit(EV_REP, hi->input->evbit); |
| 316 | hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN); |
| 317 | apple_setup_input(hi->input); |
| 318 | return 1; |
| 319 | } |
| 320 | |
| 321 | /* we want the hid layer to go through standard path (set and ignore) */ |
| 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi, |
| 326 | struct hid_field *field, struct hid_usage *usage, |
| 327 | unsigned long **bit, int *max) |
| 328 | { |
| 329 | struct apple_sc *asc = hid_get_drvdata(hdev); |
| 330 | |
| 331 | if (asc->quirks & APPLE_MIGHTYMOUSE) { |
| 332 | if (usage->hid == HID_GD_Z) |
| 333 | hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL); |
| 334 | else if (usage->code == BTN_1) |
| 335 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2); |
| 336 | else if (usage->code == BTN_2) |
| 337 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1); |
| 338 | } |
| 339 | |
| 340 | return 0; |
| 341 | } |
| 342 | |
| 343 | static int apple_probe(struct hid_device *hdev, |
| 344 | const struct hid_device_id *id) |
| 345 | { |
| 346 | unsigned long quirks = id->driver_data; |
| 347 | struct apple_sc *asc; |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 348 | unsigned int connect_mask = HID_CONNECT_DEFAULT; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 349 | int ret; |
| 350 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 351 | asc = kzalloc(sizeof(*asc), GFP_KERNEL); |
| 352 | if (asc == NULL) { |
| 353 | dev_err(&hdev->dev, "can't alloc apple descriptor\n"); |
| 354 | return -ENOMEM; |
| 355 | } |
| 356 | |
| 357 | asc->quirks = quirks; |
| 358 | |
| 359 | hid_set_drvdata(hdev, asc); |
| 360 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 361 | ret = hid_parse(hdev); |
| 362 | if (ret) { |
| 363 | dev_err(&hdev->dev, "parse failed\n"); |
| 364 | goto err_free; |
| 365 | } |
| 366 | |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 367 | if (quirks & APPLE_HIDDEV) |
| 368 | connect_mask |= HID_CONNECT_HIDDEV_FORCE; |
| 369 | if (quirks & APPLE_IGNORE_HIDINPUT) |
| 370 | connect_mask &= ~HID_CONNECT_HIDINPUT; |
| 371 | |
| 372 | ret = hid_hw_start(hdev, connect_mask); |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 373 | if (ret) { |
| 374 | dev_err(&hdev->dev, "hw start failed\n"); |
| 375 | goto err_free; |
| 376 | } |
| 377 | |
| 378 | return 0; |
| 379 | err_free: |
| 380 | kfree(asc); |
| 381 | return ret; |
| 382 | } |
| 383 | |
| 384 | static void apple_remove(struct hid_device *hdev) |
| 385 | { |
| 386 | hid_hw_stop(hdev); |
| 387 | kfree(hid_get_drvdata(hdev)); |
| 388 | } |
| 389 | |
| 390 | static const struct hid_device_id apple_devices[] = { |
Peter Korsgaard | 0f492f2 | 2008-10-06 11:15:34 +0200 | [diff] [blame] | 391 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL), |
| 392 | .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 393 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4), |
| 394 | .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT }, |
| 395 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE), |
| 396 | .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL }, |
| 397 | |
| 398 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 399 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 400 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 401 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 402 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 403 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 404 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO), |
| 405 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 406 | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 407 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 408 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 409 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 410 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 411 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO), |
| 412 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 413 | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 414 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS), |
| 415 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 416 | APPLE_RDESC_JIS }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 417 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 418 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 419 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO), |
| 420 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 421 | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 422 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS), |
| 423 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 424 | APPLE_RDESC_JIS }, |
Ryan Finnie | fef3f57 | 2009-03-05 10:18:01 +0100 | [diff] [blame] | 425 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI), |
| 426 | .driver_data = APPLE_HAS_FN }, |
| 427 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO), |
| 428 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 429 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS), |
| 430 | .driver_data = APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 431 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI), |
| 432 | .driver_data = APPLE_HAS_FN }, |
| 433 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO), |
| 434 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 435 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS), |
| 436 | .driver_data = APPLE_HAS_FN }, |
| 437 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 438 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 439 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 440 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 441 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS), |
| 442 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 443 | APPLE_RDESC_JIS }, |
Jan Scholz | ee8a1a0 | 2008-11-26 15:33:45 +0100 | [diff] [blame] | 444 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 445 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jan Scholz | ee8a1a0 | 2008-11-26 15:33:45 +0100 | [diff] [blame] | 446 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO), |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 447 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
| 448 | APPLE_ISO_KEYBOARD }, |
Jan Scholz | ee8a1a0 | 2008-11-26 15:33:45 +0100 | [diff] [blame] | 449 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS), |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 450 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
| 451 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 452 | .driver_data = APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 453 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 454 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 455 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 456 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 457 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 458 | .driver_data = APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 459 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 460 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 461 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 462 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Henrik Rydberg | a96d6ef | 2008-11-04 20:03:45 +0100 | [diff] [blame] | 463 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), |
| 464 | .driver_data = APPLE_HAS_FN }, |
| 465 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), |
| 466 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 467 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), |
| 468 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Edgar (gimli) Hucek | 99b9f75 | 2010-11-03 10:36:18 -0400 | [diff] [blame^] | 469 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI), |
| 470 | .driver_data = APPLE_HAS_FN }, |
| 471 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO), |
| 472 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 473 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS), |
| 474 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
| 475 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI), |
| 476 | .driver_data = APPLE_HAS_FN }, |
| 477 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO), |
| 478 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 479 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), |
| 480 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Christian Schuerer-Waldheim | 23aeb61 | 2010-01-06 14:49:57 +0100 | [diff] [blame] | 481 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), |
| 482 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
| 483 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), |
| 484 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
| 485 | APPLE_ISO_KEYBOARD }, |
| 486 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS), |
| 487 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 488 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 489 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 490 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 491 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 492 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 493 | { } |
| 494 | }; |
| 495 | MODULE_DEVICE_TABLE(hid, apple_devices); |
| 496 | |
| 497 | static struct hid_driver apple_driver = { |
| 498 | .name = "apple", |
| 499 | .id_table = apple_devices, |
| 500 | .report_fixup = apple_report_fixup, |
| 501 | .probe = apple_probe, |
| 502 | .remove = apple_remove, |
| 503 | .event = apple_event, |
| 504 | .input_mapping = apple_input_mapping, |
| 505 | .input_mapped = apple_input_mapped, |
| 506 | }; |
| 507 | |
Peter Huewe | a24f423b | 2009-07-02 19:08:38 +0200 | [diff] [blame] | 508 | static int __init apple_init(void) |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 509 | { |
| 510 | int ret; |
| 511 | |
| 512 | ret = hid_register_driver(&apple_driver); |
| 513 | if (ret) |
| 514 | printk(KERN_ERR "can't register apple driver\n"); |
| 515 | |
| 516 | return ret; |
| 517 | } |
| 518 | |
Peter Huewe | a24f423b | 2009-07-02 19:08:38 +0200 | [diff] [blame] | 519 | static void __exit apple_exit(void) |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 520 | { |
| 521 | hid_unregister_driver(&apple_driver); |
| 522 | } |
| 523 | |
| 524 | module_init(apple_init); |
| 525 | module_exit(apple_exit); |
| 526 | MODULE_LICENSE("GPL"); |