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