diff options
Diffstat (limited to 'drivers/hid/hid-apple.c')
| -rw-r--r-- | drivers/hid/hid-apple.c | 484 |
1 files changed, 484 insertions, 0 deletions
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c new file mode 100644 index 00000000000..fd7f896b34f --- /dev/null +++ b/drivers/hid/hid-apple.c | |||
| @@ -0,0 +1,484 @@ | |||
| 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 | |||
| 43 | struct apple_sc { | ||
| 44 | unsigned long quirks; | ||
| 45 | unsigned int fn_on; | ||
| 46 | DECLARE_BITMAP(pressed_fn, KEY_CNT); | ||
| 47 | DECLARE_BITMAP(pressed_numlock, KEY_CNT); | ||
| 48 | }; | ||
| 49 | |||
| 50 | struct apple_key_translation { | ||
| 51 | u16 from; | ||
| 52 | u16 to; | ||
| 53 | u8 flags; | ||
| 54 | }; | ||
| 55 | |||
| 56 | static struct apple_key_translation apple_fn_keys[] = { | ||
| 57 | { KEY_BACKSPACE, KEY_DELETE }, | ||
| 58 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, | ||
| 59 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, | ||
| 60 | { KEY_F3, KEY_FN_F5, APPLE_FLAG_FKEY }, /* Exposé */ | ||
| 61 | { KEY_F4, KEY_FN_F4, APPLE_FLAG_FKEY }, /* Dashboard */ | ||
| 62 | { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, | ||
| 63 | { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, | ||
| 64 | { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, | ||
| 65 | { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY }, | ||
| 66 | { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY }, | ||
| 67 | { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY }, | ||
| 68 | { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, | ||
| 69 | { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, | ||
| 70 | { KEY_UP, KEY_PAGEUP }, | ||
| 71 | { KEY_DOWN, KEY_PAGEDOWN }, | ||
| 72 | { KEY_LEFT, KEY_HOME }, | ||
| 73 | { KEY_RIGHT, KEY_END }, | ||
| 74 | { } | ||
| 75 | }; | ||
| 76 | |||
| 77 | static struct apple_key_translation powerbook_fn_keys[] = { | ||
| 78 | { KEY_BACKSPACE, KEY_DELETE }, | ||
| 79 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, | ||
| 80 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, | ||
| 81 | { KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY }, | ||
| 82 | { KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, | ||
| 83 | { KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, | ||
| 84 | { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY }, | ||
| 85 | { KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY }, | ||
| 86 | { KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY }, | ||
| 87 | { KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, | ||
| 88 | { KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, | ||
| 89 | { KEY_UP, KEY_PAGEUP }, | ||
| 90 | { KEY_DOWN, KEY_PAGEDOWN }, | ||
| 91 | { KEY_LEFT, KEY_HOME }, | ||
| 92 | { KEY_RIGHT, KEY_END }, | ||
| 93 | { } | ||
| 94 | }; | ||
| 95 | |||
| 96 | static struct apple_key_translation powerbook_numlock_keys[] = { | ||
| 97 | { KEY_J, KEY_KP1 }, | ||
| 98 | { KEY_K, KEY_KP2 }, | ||
| 99 | { KEY_L, KEY_KP3 }, | ||
| 100 | { KEY_U, KEY_KP4 }, | ||
| 101 | { KEY_I, KEY_KP5 }, | ||
| 102 | { KEY_O, KEY_KP6 }, | ||
| 103 | { KEY_7, KEY_KP7 }, | ||
| 104 | { KEY_8, KEY_KP8 }, | ||
| 105 | { KEY_9, KEY_KP9 }, | ||
| 106 | { KEY_M, KEY_KP0 }, | ||
| 107 | { KEY_DOT, KEY_KPDOT }, | ||
| 108 | { KEY_SLASH, KEY_KPPLUS }, | ||
| 109 | { KEY_SEMICOLON, KEY_KPMINUS }, | ||
| 110 | { KEY_P, KEY_KPASTERISK }, | ||
| 111 | { KEY_MINUS, KEY_KPEQUAL }, | ||
| 112 | { KEY_0, KEY_KPSLASH }, | ||
| 113 | { KEY_F6, KEY_NUMLOCK }, | ||
| 114 | { KEY_KPENTER, KEY_KPENTER }, | ||
| 115 | { KEY_BACKSPACE, KEY_BACKSPACE }, | ||
| 116 | { } | ||
| 117 | }; | ||
| 118 | |||
| 119 | static struct apple_key_translation apple_iso_keyboard[] = { | ||
| 120 | { KEY_GRAVE, KEY_102ND }, | ||
| 121 | { KEY_102ND, KEY_GRAVE }, | ||
| 122 | { } | ||
| 123 | }; | ||
| 124 | |||
| 125 | static struct apple_key_translation *apple_find_translation( | ||
| 126 | struct apple_key_translation *table, u16 from) | ||
| 127 | { | ||
| 128 | struct apple_key_translation *trans; | ||
| 129 | |||
| 130 | /* Look for the translation */ | ||
| 131 | for (trans = table; trans->from; trans++) | ||
| 132 | if (trans->from == from) | ||
| 133 | return trans; | ||
| 134 | |||
| 135 | return NULL; | ||
| 136 | } | ||
| 137 | |||
| 138 | static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, | ||
| 139 | struct hid_usage *usage, __s32 value) | ||
| 140 | { | ||
| 141 | struct apple_sc *asc = hid_get_drvdata(hid); | ||
| 142 | struct apple_key_translation *trans; | ||
| 143 | |||
| 144 | if (usage->code == KEY_FN) { | ||
| 145 | asc->fn_on = !!value; | ||
| 146 | input_event(input, usage->type, usage->code, value); | ||
| 147 | return 1; | ||
| 148 | } | ||
| 149 | |||
| 150 | if (fnmode) { | ||
| 151 | int do_translate; | ||
| 152 | |||
| 153 | trans = apple_find_translation((hid->product < 0x220 || | ||
| 154 | hid->product >= 0x300) ? | ||
| 155 | powerbook_fn_keys : apple_fn_keys, | ||
| 156 | usage->code); | ||
| 157 | if (trans) { | ||
| 158 | if (test_bit(usage->code, asc->pressed_fn)) | ||
| 159 | do_translate = 1; | ||
| 160 | else if (trans->flags & APPLE_FLAG_FKEY) | ||
| 161 | do_translate = (fnmode == 2 && asc->fn_on) || | ||
| 162 | (fnmode == 1 && !asc->fn_on); | ||
| 163 | else | ||
| 164 | do_translate = asc->fn_on; | ||
| 165 | |||
| 166 | if (do_translate) { | ||
| 167 | if (value) | ||
| 168 | set_bit(usage->code, asc->pressed_fn); | ||
| 169 | else | ||
| 170 | clear_bit(usage->code, asc->pressed_fn); | ||
| 171 | |||
| 172 | input_event(input, usage->type, trans->to, | ||
| 173 | value); | ||
| 174 | |||
| 175 | return 1; | ||
| 176 | } | ||
| 177 | } | ||
| 178 | |||
| 179 | if (asc->quirks & APPLE_NUMLOCK_EMULATION && | ||
| 180 | (test_bit(usage->code, asc->pressed_numlock) || | ||
| 181 | test_bit(LED_NUML, input->led))) { | ||
| 182 | trans = apple_find_translation(powerbook_numlock_keys, | ||
| 183 | usage->code); | ||
| 184 | |||
| 185 | if (trans) { | ||
| 186 | if (value) | ||
| 187 | set_bit(usage->code, | ||
| 188 | asc->pressed_numlock); | ||
| 189 | else | ||
| 190 | clear_bit(usage->code, | ||
| 191 | asc->pressed_numlock); | ||
| 192 | |||
| 193 | input_event(input, usage->type, trans->to, | ||
| 194 | value); | ||
| 195 | } | ||
| 196 | |||
| 197 | return 1; | ||
| 198 | } | ||
| 199 | } | ||
| 200 | |||
| 201 | if (asc->quirks & APPLE_ISO_KEYBOARD) { | ||
| 202 | trans = apple_find_translation(apple_iso_keyboard, usage->code); | ||
| 203 | if (trans) { | ||
| 204 | input_event(input, usage->type, trans->to, value); | ||
| 205 | return 1; | ||
| 206 | } | ||
| 207 | } | ||
| 208 | |||
| 209 | return 0; | ||
| 210 | } | ||
| 211 | |||
| 212 | static int apple_event(struct hid_device *hdev, struct hid_field *field, | ||
| 213 | struct hid_usage *usage, __s32 value) | ||
| 214 | { | ||
| 215 | struct apple_sc *asc = hid_get_drvdata(hdev); | ||
| 216 | |||
| 217 | if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput || | ||
| 218 | !usage->type) | ||
| 219 | return 0; | ||
| 220 | |||
| 221 | if ((asc->quirks & APPLE_INVERT_HWHEEL) && | ||
| 222 | usage->code == REL_HWHEEL) { | ||
| 223 | input_event(field->hidinput->input, usage->type, usage->code, | ||
| 224 | -value); | ||
| 225 | return 1; | ||
| 226 | } | ||
| 227 | |||
| 228 | if ((asc->quirks & APPLE_HAS_FN) && | ||
| 229 | hidinput_apple_event(hdev, field->hidinput->input, | ||
| 230 | usage, value)) | ||
| 231 | return 1; | ||
| 232 | |||
| 233 | |||
| 234 | return 0; | ||
| 235 | } | ||
| 236 | |||
| 237 | /* | ||
| 238 | * MacBook JIS keyboard has wrong logical maximum | ||
| 239 | */ | ||
| 240 | static void apple_report_fixup(struct hid_device *hdev, __u8 *rdesc, | ||
| 241 | unsigned int rsize) | ||
| 242 | { | ||
| 243 | struct apple_sc *asc = hid_get_drvdata(hdev); | ||
| 244 | |||
| 245 | if ((asc->quirks & APPLE_RDESC_JIS) && rsize >= 60 && | ||
| 246 | rdesc[53] == 0x65 && rdesc[59] == 0x65) { | ||
| 247 | dev_info(&hdev->dev, "fixing up MacBook JIS keyboard report " | ||
| 248 | "descriptor\n"); | ||
| 249 | rdesc[53] = rdesc[59] = 0xe7; | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | static void apple_setup_input(struct input_dev *input) | ||
| 254 | { | ||
| 255 | struct apple_key_translation *trans; | ||
| 256 | |||
| 257 | set_bit(KEY_NUMLOCK, input->keybit); | ||
| 258 | |||
| 259 | /* Enable all needed keys */ | ||
| 260 | for (trans = apple_fn_keys; trans->from; trans++) | ||
| 261 | set_bit(trans->to, input->keybit); | ||
| 262 | |||
| 263 | for (trans = powerbook_fn_keys; trans->from; trans++) | ||
| 264 | set_bit(trans->to, input->keybit); | ||
| 265 | |||
| 266 | for (trans = powerbook_numlock_keys; trans->from; trans++) | ||
| 267 | set_bit(trans->to, input->keybit); | ||
| 268 | |||
| 269 | for (trans = apple_iso_keyboard; trans->from; trans++) | ||
| 270 | set_bit(trans->to, input->keybit); | ||
| 271 | } | ||
| 272 | |||
| 273 | static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, | ||
| 274 | struct hid_field *field, struct hid_usage *usage, | ||
| 275 | unsigned long **bit, int *max) | ||
| 276 | { | ||
| 277 | if (usage->hid == (HID_UP_CUSTOM | 0x0003)) { | ||
| 278 | /* The fn key on Apple USB keyboards */ | ||
| 279 | set_bit(EV_REP, hi->input->evbit); | ||
| 280 | hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN); | ||
| 281 | apple_setup_input(hi->input); | ||
| 282 | return 1; | ||
| 283 | } | ||
| 284 | |||
| 285 | /* we want the hid layer to go through standard path (set and ignore) */ | ||
| 286 | return 0; | ||
| 287 | } | ||
| 288 | |||
| 289 | static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi, | ||
| 290 | struct hid_field *field, struct hid_usage *usage, | ||
| 291 | unsigned long **bit, int *max) | ||
| 292 | { | ||
| 293 | struct apple_sc *asc = hid_get_drvdata(hdev); | ||
| 294 | |||
| 295 | if (asc->quirks & APPLE_MIGHTYMOUSE) { | ||
| 296 | if (usage->hid == HID_GD_Z) | ||
| 297 | hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL); | ||
| 298 | else if (usage->code == BTN_1) | ||
| 299 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2); | ||
| 300 | else if (usage->code == BTN_2) | ||
| 301 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1); | ||
| 302 | } | ||
| 303 | |||
| 304 | return 0; | ||
| 305 | } | ||
| 306 | |||
| 307 | static int apple_probe(struct hid_device *hdev, | ||
| 308 | const struct hid_device_id *id) | ||
| 309 | { | ||
| 310 | unsigned long quirks = id->driver_data; | ||
| 311 | struct apple_sc *asc; | ||
| 312 | unsigned int connect_mask = HID_CONNECT_DEFAULT; | ||
| 313 | int ret; | ||
| 314 | |||
| 315 | /* return something else or move to hid layer? device will reside | ||
| 316 | allocated */ | ||
| 317 | if (id->bus == BUS_USB && (quirks & APPLE_IGNORE_MOUSE) && | ||
| 318 | to_usb_interface(hdev->dev.parent)->cur_altsetting-> | ||
| 319 | desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE) | ||
| 320 | return -ENODEV; | ||
| 321 | |||
| 322 | asc = kzalloc(sizeof(*asc), GFP_KERNEL); | ||
| 323 | if (asc == NULL) { | ||
| 324 | dev_err(&hdev->dev, "can't alloc apple descriptor\n"); | ||
| 325 | return -ENOMEM; | ||
| 326 | } | ||
| 327 | |||
| 328 | asc->quirks = quirks; | ||
| 329 | |||
| 330 | hid_set_drvdata(hdev, asc); | ||
| 331 | |||
| 332 | ret = hid_parse(hdev); | ||
| 333 | if (ret) { | ||
| 334 | dev_err(&hdev->dev, "parse failed\n"); | ||
| 335 | goto err_free; | ||
| 336 | } | ||
| 337 | |||
| 338 | if (quirks & APPLE_HIDDEV) | ||
| 339 | connect_mask |= HID_CONNECT_HIDDEV_FORCE; | ||
| 340 | if (quirks & APPLE_IGNORE_HIDINPUT) | ||
| 341 | connect_mask &= ~HID_CONNECT_HIDINPUT; | ||
| 342 | |||
| 343 | ret = hid_hw_start(hdev, connect_mask); | ||
| 344 | if (ret) { | ||
| 345 | dev_err(&hdev->dev, "hw start failed\n"); | ||
| 346 | goto err_free; | ||
| 347 | } | ||
| 348 | |||
| 349 | return 0; | ||
| 350 | err_free: | ||
| 351 | kfree(asc); | ||
| 352 | return ret; | ||
| 353 | } | ||
| 354 | |||
| 355 | static void apple_remove(struct hid_device *hdev) | ||
| 356 | { | ||
| 357 | hid_hw_stop(hdev); | ||
| 358 | kfree(hid_get_drvdata(hdev)); | ||
| 359 | } | ||
| 360 | |||
| 361 | static const struct hid_device_id apple_devices[] = { | ||
| 362 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL), | ||
| 363 | .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT }, | ||
| 364 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4), | ||
| 365 | .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT }, | ||
| 366 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE), | ||
| 367 | .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL }, | ||
| 368 | |||
| 369 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI), | ||
| 370 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 371 | APPLE_IGNORE_MOUSE }, | ||
| 372 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO), | ||
| 373 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 374 | APPLE_IGNORE_MOUSE }, | ||
| 375 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI), | ||
| 376 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 377 | APPLE_IGNORE_MOUSE }, | ||
| 378 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO), | ||
| 379 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 380 | APPLE_IGNORE_MOUSE | APPLE_ISO_KEYBOARD }, | ||
| 381 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS), | ||
| 382 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 383 | APPLE_IGNORE_MOUSE }, | ||
| 384 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI), | ||
| 385 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 386 | APPLE_IGNORE_MOUSE }, | ||
| 387 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO), | ||
| 388 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 389 | APPLE_IGNORE_MOUSE | APPLE_ISO_KEYBOARD }, | ||
| 390 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS), | ||
| 391 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 392 | APPLE_IGNORE_MOUSE | APPLE_RDESC_JIS }, | ||
| 393 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI), | ||
| 394 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 395 | APPLE_IGNORE_MOUSE }, | ||
| 396 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO), | ||
| 397 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 398 | APPLE_IGNORE_MOUSE | APPLE_ISO_KEYBOARD }, | ||
| 399 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS), | ||
| 400 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 401 | APPLE_IGNORE_MOUSE | APPLE_RDESC_JIS}, | ||
| 402 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI), | ||
| 403 | .driver_data = APPLE_HAS_FN }, | ||
| 404 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO), | ||
| 405 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, | ||
| 406 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS), | ||
| 407 | .driver_data = APPLE_HAS_FN }, | ||
| 408 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI), | ||
| 409 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 410 | APPLE_IGNORE_MOUSE }, | ||
| 411 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO), | ||
| 412 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 413 | APPLE_IGNORE_MOUSE }, | ||
| 414 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS), | ||
| 415 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 416 | APPLE_IGNORE_MOUSE | APPLE_RDESC_JIS }, | ||
| 417 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), | ||
| 418 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | ||
| 419 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO), | ||
| 420 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 421 | APPLE_ISO_KEYBOARD }, | ||
| 422 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS), | ||
| 423 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | ||
| 424 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), | ||
| 425 | .driver_data = APPLE_HAS_FN | APPLE_IGNORE_MOUSE }, | ||
| 426 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO), | ||
| 427 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD | | ||
| 428 | APPLE_IGNORE_MOUSE }, | ||
| 429 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS), | ||
| 430 | .driver_data = APPLE_HAS_FN | APPLE_IGNORE_MOUSE | APPLE_RDESC_JIS }, | ||
| 431 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI), | ||
| 432 | .driver_data = APPLE_HAS_FN | APPLE_IGNORE_MOUSE }, | ||
| 433 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO), | ||
| 434 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD | | ||
| 435 | APPLE_IGNORE_MOUSE }, | ||
| 436 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), | ||
| 437 | .driver_data = APPLE_HAS_FN | APPLE_IGNORE_MOUSE | APPLE_RDESC_JIS }, | ||
| 438 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY), | ||
| 439 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 440 | APPLE_IGNORE_MOUSE }, | ||
| 441 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), | ||
| 442 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | ||
| 443 | APPLE_IGNORE_MOUSE }, | ||
| 444 | |||
| 445 | /* Apple wireless Mighty Mouse */ | ||
| 446 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c), | ||
| 447 | .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL }, | ||
| 448 | |||
| 449 | { } | ||
| 450 | }; | ||
| 451 | MODULE_DEVICE_TABLE(hid, apple_devices); | ||
| 452 | |||
| 453 | static struct hid_driver apple_driver = { | ||
| 454 | .name = "apple", | ||
| 455 | .id_table = apple_devices, | ||
| 456 | .report_fixup = apple_report_fixup, | ||
| 457 | .probe = apple_probe, | ||
| 458 | .remove = apple_remove, | ||
| 459 | .event = apple_event, | ||
| 460 | .input_mapping = apple_input_mapping, | ||
| 461 | .input_mapped = apple_input_mapped, | ||
| 462 | }; | ||
| 463 | |||
| 464 | static int apple_init(void) | ||
| 465 | { | ||
| 466 | int ret; | ||
| 467 | |||
| 468 | ret = hid_register_driver(&apple_driver); | ||
| 469 | if (ret) | ||
| 470 | printk(KERN_ERR "can't register apple driver\n"); | ||
| 471 | |||
| 472 | return ret; | ||
| 473 | } | ||
| 474 | |||
| 475 | static void apple_exit(void) | ||
| 476 | { | ||
| 477 | hid_unregister_driver(&apple_driver); | ||
| 478 | } | ||
| 479 | |||
| 480 | module_init(apple_init); | ||
| 481 | module_exit(apple_exit); | ||
| 482 | MODULE_LICENSE("GPL"); | ||
| 483 | |||
| 484 | HID_COMPAT_LOAD_DRIVER(apple); | ||
