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> |
| 22 | #include <linux/usb.h> |
| 23 | |
| 24 | #include "hid-ids.h" |
| 25 | |
| 26 | #define APPLE_RDESC_JIS 0x0001 |
| 27 | #define APPLE_IGNORE_MOUSE 0x0002 |
| 28 | #define APPLE_HAS_FN 0x0004 |
| 29 | #define APPLE_HIDDEV 0x0008 |
| 30 | #define APPLE_ISO_KEYBOARD 0x0010 |
| 31 | #define APPLE_MIGHTYMOUSE 0x0020 |
| 32 | #define APPLE_INVERT_HWHEEL 0x0040 |
| 33 | #define APPLE_IGNORE_HIDINPUT 0x0080 |
| 34 | #define APPLE_NUMLOCK_EMULATION 0x0100 |
| 35 | |
| 36 | #define APPLE_FLAG_FKEY 0x01 |
| 37 | |
| 38 | static unsigned int fnmode = 1; |
| 39 | module_param(fnmode, uint, 0644); |
| 40 | MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, " |
| 41 | "[1] = fkeyslast, 2 = fkeysfirst)"); |
| 42 | |
Stefan Glasenhardt | 54a6593 | 2010-01-05 23:30:30 +0100 | [diff] [blame^] | 43 | static unsigned int iso_layout = 1; |
| 44 | module_param(iso_layout, uint, 0644); |
| 45 | MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. " |
| 46 | "(0 = disabled, [1] = enabled)"); |
| 47 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 48 | struct apple_sc { |
| 49 | unsigned long quirks; |
| 50 | unsigned int fn_on; |
| 51 | DECLARE_BITMAP(pressed_fn, KEY_CNT); |
| 52 | DECLARE_BITMAP(pressed_numlock, KEY_CNT); |
| 53 | }; |
| 54 | |
| 55 | struct apple_key_translation { |
| 56 | u16 from; |
| 57 | u16 to; |
| 58 | u8 flags; |
| 59 | }; |
| 60 | |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 61 | static const struct apple_key_translation apple_fn_keys[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 62 | { KEY_BACKSPACE, KEY_DELETE }, |
Henrik Rydberg | 437184a | 2008-11-04 13:31:38 +0100 | [diff] [blame] | 63 | { KEY_ENTER, KEY_INSERT }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 64 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, |
| 65 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, |
Henrik Rydberg | 437184a | 2008-11-04 13:31:38 +0100 | [diff] [blame] | 66 | { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY }, |
| 67 | { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 68 | { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, |
| 69 | { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, |
| 70 | { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, |
| 71 | { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY }, |
| 72 | { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY }, |
| 73 | { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY }, |
| 74 | { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, |
| 75 | { KEY_F12, KEY_VOLUMEUP, 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 powerbook_fn_keys[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 84 | { KEY_BACKSPACE, KEY_DELETE }, |
| 85 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, |
| 86 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, |
| 87 | { KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY }, |
| 88 | { KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, |
| 89 | { KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, |
| 90 | { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY }, |
| 91 | { KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY }, |
| 92 | { KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY }, |
| 93 | { KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, |
| 94 | { KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, |
| 95 | { KEY_UP, KEY_PAGEUP }, |
| 96 | { KEY_DOWN, KEY_PAGEDOWN }, |
| 97 | { KEY_LEFT, KEY_HOME }, |
| 98 | { KEY_RIGHT, KEY_END }, |
| 99 | { } |
| 100 | }; |
| 101 | |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 102 | static const struct apple_key_translation powerbook_numlock_keys[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 103 | { KEY_J, KEY_KP1 }, |
| 104 | { KEY_K, KEY_KP2 }, |
| 105 | { KEY_L, KEY_KP3 }, |
| 106 | { KEY_U, KEY_KP4 }, |
| 107 | { KEY_I, KEY_KP5 }, |
| 108 | { KEY_O, KEY_KP6 }, |
| 109 | { KEY_7, KEY_KP7 }, |
| 110 | { KEY_8, KEY_KP8 }, |
| 111 | { KEY_9, KEY_KP9 }, |
| 112 | { KEY_M, KEY_KP0 }, |
| 113 | { KEY_DOT, KEY_KPDOT }, |
| 114 | { KEY_SLASH, KEY_KPPLUS }, |
| 115 | { KEY_SEMICOLON, KEY_KPMINUS }, |
| 116 | { KEY_P, KEY_KPASTERISK }, |
| 117 | { KEY_MINUS, KEY_KPEQUAL }, |
| 118 | { KEY_0, KEY_KPSLASH }, |
| 119 | { KEY_F6, KEY_NUMLOCK }, |
| 120 | { KEY_KPENTER, KEY_KPENTER }, |
| 121 | { KEY_BACKSPACE, KEY_BACKSPACE }, |
| 122 | { } |
| 123 | }; |
| 124 | |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 125 | static const struct apple_key_translation apple_iso_keyboard[] = { |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 126 | { KEY_GRAVE, KEY_102ND }, |
| 127 | { KEY_102ND, KEY_GRAVE }, |
| 128 | { } |
| 129 | }; |
| 130 | |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 131 | static const struct apple_key_translation *apple_find_translation( |
| 132 | const struct apple_key_translation *table, u16 from) |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 133 | { |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 134 | const struct apple_key_translation *trans; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 135 | |
| 136 | /* Look for the translation */ |
| 137 | for (trans = table; trans->from; trans++) |
| 138 | if (trans->from == from) |
| 139 | return trans; |
| 140 | |
| 141 | return NULL; |
| 142 | } |
| 143 | |
| 144 | static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, |
| 145 | struct hid_usage *usage, __s32 value) |
| 146 | { |
| 147 | struct apple_sc *asc = hid_get_drvdata(hid); |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 148 | const struct apple_key_translation *trans; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 149 | |
| 150 | if (usage->code == KEY_FN) { |
| 151 | asc->fn_on = !!value; |
| 152 | input_event(input, usage->type, usage->code, value); |
| 153 | return 1; |
| 154 | } |
| 155 | |
| 156 | if (fnmode) { |
| 157 | int do_translate; |
| 158 | |
Ulrich Dangel | 2feaace | 2009-04-28 16:23:51 +0200 | [diff] [blame] | 159 | trans = apple_find_translation((hid->product < 0x21d || |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 160 | hid->product >= 0x300) ? |
| 161 | powerbook_fn_keys : apple_fn_keys, |
| 162 | usage->code); |
| 163 | if (trans) { |
| 164 | if (test_bit(usage->code, asc->pressed_fn)) |
| 165 | do_translate = 1; |
| 166 | else if (trans->flags & APPLE_FLAG_FKEY) |
| 167 | do_translate = (fnmode == 2 && asc->fn_on) || |
| 168 | (fnmode == 1 && !asc->fn_on); |
| 169 | else |
| 170 | do_translate = asc->fn_on; |
| 171 | |
| 172 | if (do_translate) { |
| 173 | if (value) |
| 174 | set_bit(usage->code, asc->pressed_fn); |
| 175 | else |
| 176 | clear_bit(usage->code, asc->pressed_fn); |
| 177 | |
| 178 | input_event(input, usage->type, trans->to, |
| 179 | value); |
| 180 | |
| 181 | return 1; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | if (asc->quirks & APPLE_NUMLOCK_EMULATION && |
| 186 | (test_bit(usage->code, asc->pressed_numlock) || |
| 187 | test_bit(LED_NUML, input->led))) { |
| 188 | trans = apple_find_translation(powerbook_numlock_keys, |
| 189 | usage->code); |
| 190 | |
| 191 | if (trans) { |
| 192 | if (value) |
| 193 | set_bit(usage->code, |
| 194 | asc->pressed_numlock); |
| 195 | else |
| 196 | clear_bit(usage->code, |
| 197 | asc->pressed_numlock); |
| 198 | |
| 199 | input_event(input, usage->type, trans->to, |
| 200 | value); |
| 201 | } |
| 202 | |
| 203 | return 1; |
| 204 | } |
| 205 | } |
| 206 | |
Stefan Glasenhardt | 54a6593 | 2010-01-05 23:30:30 +0100 | [diff] [blame^] | 207 | if (iso_layout) { |
| 208 | if (asc->quirks & APPLE_ISO_KEYBOARD) { |
| 209 | trans = apple_find_translation(apple_iso_keyboard, usage->code); |
| 210 | if (trans) { |
| 211 | input_event(input, usage->type, trans->to, value); |
| 212 | return 1; |
| 213 | } |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 214 | } |
| 215 | } |
| 216 | |
| 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | static int apple_event(struct hid_device *hdev, struct hid_field *field, |
| 221 | struct hid_usage *usage, __s32 value) |
| 222 | { |
| 223 | struct apple_sc *asc = hid_get_drvdata(hdev); |
| 224 | |
| 225 | if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput || |
| 226 | !usage->type) |
| 227 | return 0; |
| 228 | |
| 229 | if ((asc->quirks & APPLE_INVERT_HWHEEL) && |
| 230 | usage->code == REL_HWHEEL) { |
| 231 | input_event(field->hidinput->input, usage->type, usage->code, |
| 232 | -value); |
| 233 | return 1; |
| 234 | } |
| 235 | |
| 236 | if ((asc->quirks & APPLE_HAS_FN) && |
| 237 | hidinput_apple_event(hdev, field->hidinput->input, |
| 238 | usage, value)) |
| 239 | return 1; |
| 240 | |
| 241 | |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | /* |
| 246 | * MacBook JIS keyboard has wrong logical maximum |
| 247 | */ |
| 248 | static void apple_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
| 249 | unsigned int rsize) |
| 250 | { |
| 251 | struct apple_sc *asc = hid_get_drvdata(hdev); |
| 252 | |
| 253 | if ((asc->quirks & APPLE_RDESC_JIS) && rsize >= 60 && |
| 254 | rdesc[53] == 0x65 && rdesc[59] == 0x65) { |
| 255 | dev_info(&hdev->dev, "fixing up MacBook JIS keyboard report " |
| 256 | "descriptor\n"); |
| 257 | rdesc[53] = rdesc[59] = 0xe7; |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | static void apple_setup_input(struct input_dev *input) |
| 262 | { |
Paul Collins | b2ddd54 | 2009-03-07 17:07:15 +1300 | [diff] [blame] | 263 | const struct apple_key_translation *trans; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 264 | |
| 265 | set_bit(KEY_NUMLOCK, input->keybit); |
| 266 | |
| 267 | /* Enable all needed keys */ |
| 268 | for (trans = apple_fn_keys; trans->from; trans++) |
| 269 | set_bit(trans->to, input->keybit); |
| 270 | |
| 271 | for (trans = powerbook_fn_keys; trans->from; trans++) |
| 272 | set_bit(trans->to, input->keybit); |
| 273 | |
| 274 | for (trans = powerbook_numlock_keys; trans->from; trans++) |
| 275 | set_bit(trans->to, input->keybit); |
| 276 | |
| 277 | for (trans = apple_iso_keyboard; trans->from; trans++) |
| 278 | set_bit(trans->to, input->keybit); |
| 279 | } |
| 280 | |
| 281 | static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 282 | struct hid_field *field, struct hid_usage *usage, |
| 283 | unsigned long **bit, int *max) |
| 284 | { |
| 285 | if (usage->hid == (HID_UP_CUSTOM | 0x0003)) { |
| 286 | /* The fn key on Apple USB keyboards */ |
| 287 | set_bit(EV_REP, hi->input->evbit); |
| 288 | hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN); |
| 289 | apple_setup_input(hi->input); |
| 290 | return 1; |
| 291 | } |
| 292 | |
| 293 | /* we want the hid layer to go through standard path (set and ignore) */ |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi, |
| 298 | struct hid_field *field, struct hid_usage *usage, |
| 299 | unsigned long **bit, int *max) |
| 300 | { |
| 301 | struct apple_sc *asc = hid_get_drvdata(hdev); |
| 302 | |
| 303 | if (asc->quirks & APPLE_MIGHTYMOUSE) { |
| 304 | if (usage->hid == HID_GD_Z) |
| 305 | hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL); |
| 306 | else if (usage->code == BTN_1) |
| 307 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2); |
| 308 | else if (usage->code == BTN_2) |
| 309 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1); |
| 310 | } |
| 311 | |
| 312 | return 0; |
| 313 | } |
| 314 | |
| 315 | static int apple_probe(struct hid_device *hdev, |
| 316 | const struct hid_device_id *id) |
| 317 | { |
| 318 | unsigned long quirks = id->driver_data; |
| 319 | struct apple_sc *asc; |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 320 | unsigned int connect_mask = HID_CONNECT_DEFAULT; |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 321 | int ret; |
| 322 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 323 | asc = kzalloc(sizeof(*asc), GFP_KERNEL); |
| 324 | if (asc == NULL) { |
| 325 | dev_err(&hdev->dev, "can't alloc apple descriptor\n"); |
| 326 | return -ENOMEM; |
| 327 | } |
| 328 | |
| 329 | asc->quirks = quirks; |
| 330 | |
| 331 | hid_set_drvdata(hdev, asc); |
| 332 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 333 | ret = hid_parse(hdev); |
| 334 | if (ret) { |
| 335 | dev_err(&hdev->dev, "parse failed\n"); |
| 336 | goto err_free; |
| 337 | } |
| 338 | |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 339 | if (quirks & APPLE_HIDDEV) |
| 340 | connect_mask |= HID_CONNECT_HIDDEV_FORCE; |
| 341 | if (quirks & APPLE_IGNORE_HIDINPUT) |
| 342 | connect_mask &= ~HID_CONNECT_HIDINPUT; |
| 343 | |
| 344 | ret = hid_hw_start(hdev, connect_mask); |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 345 | if (ret) { |
| 346 | dev_err(&hdev->dev, "hw start failed\n"); |
| 347 | goto err_free; |
| 348 | } |
| 349 | |
| 350 | return 0; |
| 351 | err_free: |
| 352 | kfree(asc); |
| 353 | return ret; |
| 354 | } |
| 355 | |
| 356 | static void apple_remove(struct hid_device *hdev) |
| 357 | { |
| 358 | hid_hw_stop(hdev); |
| 359 | kfree(hid_get_drvdata(hdev)); |
| 360 | } |
| 361 | |
| 362 | static const struct hid_device_id apple_devices[] = { |
Peter Korsgaard | 0f492f2 | 2008-10-06 11:15:34 +0200 | [diff] [blame] | 363 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL), |
| 364 | .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 365 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4), |
| 366 | .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT }, |
| 367 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE), |
| 368 | .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL }, |
| 369 | |
| 370 | { 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] | 371 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 372 | { 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] | 373 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 374 | { 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] | 375 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 376 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO), |
| 377 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 378 | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 379 | { 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] | 380 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 381 | { 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] | 382 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 383 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO), |
| 384 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 385 | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 386 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS), |
| 387 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 388 | APPLE_RDESC_JIS }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 389 | { 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] | 390 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 391 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO), |
| 392 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 393 | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 394 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS), |
| 395 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 396 | APPLE_RDESC_JIS }, |
Ryan Finnie | fef3f57 | 2009-03-05 10:18:01 +0100 | [diff] [blame] | 397 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI), |
| 398 | .driver_data = APPLE_HAS_FN }, |
| 399 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO), |
| 400 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 401 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS), |
| 402 | .driver_data = APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 403 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI), |
| 404 | .driver_data = APPLE_HAS_FN }, |
| 405 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO), |
| 406 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 407 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS), |
| 408 | .driver_data = APPLE_HAS_FN }, |
| 409 | { 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] | 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_GEYSER4_HF_ISO), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 412 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 413 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS), |
| 414 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 415 | APPLE_RDESC_JIS }, |
Jan Scholz | ee8a1a0 | 2008-11-26 15:33:45 +0100 | [diff] [blame] | 416 | { 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] | 417 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jan Scholz | ee8a1a0 | 2008-11-26 15:33:45 +0100 | [diff] [blame] | 418 | { 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] | 419 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | |
| 420 | APPLE_ISO_KEYBOARD }, |
Jan Scholz | ee8a1a0 | 2008-11-26 15:33:45 +0100 | [diff] [blame] | 421 | { 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] | 422 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
| 423 | { 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] | 424 | .driver_data = APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 425 | { 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] | 426 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 427 | { 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] | 428 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 429 | { 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] | 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_WELLSPRING2_ISO), |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 432 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 433 | { 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] | 434 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Henrik Rydberg | a96d6ef | 2008-11-04 20:03:45 +0100 | [diff] [blame] | 435 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), |
| 436 | .driver_data = APPLE_HAS_FN }, |
| 437 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), |
| 438 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
| 439 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), |
| 440 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 441 | { 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] | 442 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 443 | { 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] | 444 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 445 | |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 446 | { } |
| 447 | }; |
| 448 | MODULE_DEVICE_TABLE(hid, apple_devices); |
| 449 | |
| 450 | static struct hid_driver apple_driver = { |
| 451 | .name = "apple", |
| 452 | .id_table = apple_devices, |
| 453 | .report_fixup = apple_report_fixup, |
| 454 | .probe = apple_probe, |
| 455 | .remove = apple_remove, |
| 456 | .event = apple_event, |
| 457 | .input_mapping = apple_input_mapping, |
| 458 | .input_mapped = apple_input_mapped, |
| 459 | }; |
| 460 | |
Peter Huewe | a24f423 | 2009-07-02 19:08:38 +0200 | [diff] [blame] | 461 | static int __init apple_init(void) |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 462 | { |
| 463 | int ret; |
| 464 | |
| 465 | ret = hid_register_driver(&apple_driver); |
| 466 | if (ret) |
| 467 | printk(KERN_ERR "can't register apple driver\n"); |
| 468 | |
| 469 | return ret; |
| 470 | } |
| 471 | |
Peter Huewe | a24f423 | 2009-07-02 19:08:38 +0200 | [diff] [blame] | 472 | static void __exit apple_exit(void) |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 473 | { |
| 474 | hid_unregister_driver(&apple_driver); |
| 475 | } |
| 476 | |
| 477 | module_init(apple_init); |
| 478 | module_exit(apple_exit); |
| 479 | MODULE_LICENSE("GPL"); |