hid-apple.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  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) 2008 Jiri Slaby <jirislaby@gmail.com>
  9. */
  10. /*
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License as published by the Free
  13. * Software Foundation; either version 2 of the License, or (at your option)
  14. * any later version.
  15. */
  16. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  17. #include <linux/device.h>
  18. #include <linux/hid.h>
  19. #include <linux/module.h>
  20. #include <linux/slab.h>
  21. #include "hid-ids.h"
  22. #define APPLE_RDESC_JIS 0x0001
  23. #define APPLE_IGNORE_MOUSE 0x0002
  24. #define APPLE_HAS_FN 0x0004
  25. #define APPLE_HIDDEV 0x0008
  26. #define APPLE_ISO_KEYBOARD 0x0010
  27. #define APPLE_MIGHTYMOUSE 0x0020
  28. #define APPLE_INVERT_HWHEEL 0x0040
  29. #define APPLE_IGNORE_HIDINPUT 0x0080
  30. #define APPLE_NUMLOCK_EMULATION 0x0100
  31. #define APPLE_FLAG_FKEY 0x01
  32. static unsigned int fnmode = 1;
  33. module_param(fnmode, uint, 0644);
  34. MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
  35. "[1] = fkeyslast, 2 = fkeysfirst)");
  36. static unsigned int iso_layout = 1;
  37. module_param(iso_layout, uint, 0644);
  38. MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. "
  39. "(0 = disabled, [1] = enabled)");
  40. static unsigned int swap_opt_cmd;
  41. module_param(swap_opt_cmd, uint, 0644);
  42. MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\") keys. "
  43. "(For people who want to keep Windows PC keyboard muscle memory. "
  44. "[0] = as-is, Mac layout. 1 = swapped, Windows layout.)");
  45. struct apple_sc {
  46. unsigned long quirks;
  47. unsigned int fn_on;
  48. DECLARE_BITMAP(pressed_fn, KEY_CNT);
  49. DECLARE_BITMAP(pressed_numlock, KEY_CNT);
  50. };
  51. struct apple_key_translation {
  52. u16 from;
  53. u16 to;
  54. u8 flags;
  55. };
  56. static const struct apple_key_translation macbookair_fn_keys[] = {
  57. { KEY_BACKSPACE, KEY_DELETE },
  58. { KEY_ENTER, KEY_INSERT },
  59. { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
  60. { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
  61. { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
  62. { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
  63. { KEY_F6, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
  64. { KEY_F7, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
  65. { KEY_F8, KEY_NEXTSONG, APPLE_FLAG_FKEY },
  66. { KEY_F9, KEY_MUTE, APPLE_FLAG_FKEY },
  67. { KEY_F10, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
  68. { KEY_F11, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
  69. { KEY_F12, KEY_EJECTCD, 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. static const struct apple_key_translation apple_fn_keys[] = {
  77. { KEY_BACKSPACE, KEY_DELETE },
  78. { KEY_ENTER, KEY_INSERT },
  79. { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
  80. { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
  81. { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
  82. { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
  83. { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
  84. { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
  85. { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
  86. { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
  87. { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
  88. { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
  89. { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
  90. { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
  91. { KEY_UP, KEY_PAGEUP },
  92. { KEY_DOWN, KEY_PAGEDOWN },
  93. { KEY_LEFT, KEY_HOME },
  94. { KEY_RIGHT, KEY_END },
  95. { }
  96. };
  97. static const struct apple_key_translation powerbook_fn_keys[] = {
  98. { KEY_BACKSPACE, KEY_DELETE },
  99. { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
  100. { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
  101. { KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY },
  102. { KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
  103. { KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
  104. { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY },
  105. { KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY },
  106. { KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY },
  107. { KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
  108. { KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
  109. { KEY_UP, KEY_PAGEUP },
  110. { KEY_DOWN, KEY_PAGEDOWN },
  111. { KEY_LEFT, KEY_HOME },
  112. { KEY_RIGHT, KEY_END },
  113. { }
  114. };
  115. static const struct apple_key_translation powerbook_numlock_keys[] = {
  116. { KEY_J, KEY_KP1 },
  117. { KEY_K, KEY_KP2 },
  118. { KEY_L, KEY_KP3 },
  119. { KEY_U, KEY_KP4 },
  120. { KEY_I, KEY_KP5 },
  121. { KEY_O, KEY_KP6 },
  122. { KEY_7, KEY_KP7 },
  123. { KEY_8, KEY_KP8 },
  124. { KEY_9, KEY_KP9 },
  125. { KEY_M, KEY_KP0 },
  126. { KEY_DOT, KEY_KPDOT },
  127. { KEY_SLASH, KEY_KPPLUS },
  128. { KEY_SEMICOLON, KEY_KPMINUS },
  129. { KEY_P, KEY_KPASTERISK },
  130. { KEY_MINUS, KEY_KPEQUAL },
  131. { KEY_0, KEY_KPSLASH },
  132. { KEY_F6, KEY_NUMLOCK },
  133. { KEY_KPENTER, KEY_KPENTER },
  134. { KEY_BACKSPACE, KEY_BACKSPACE },
  135. { }
  136. };
  137. static const struct apple_key_translation apple_iso_keyboard[] = {
  138. { KEY_GRAVE, KEY_102ND },
  139. { KEY_102ND, KEY_GRAVE },
  140. { }
  141. };
  142. static const struct apple_key_translation swapped_option_cmd_keys[] = {
  143. { KEY_LEFTALT, KEY_LEFTMETA },
  144. { KEY_LEFTMETA, KEY_LEFTALT },
  145. { KEY_RIGHTALT, KEY_RIGHTMETA },
  146. { KEY_RIGHTMETA,KEY_RIGHTALT },
  147. { }
  148. };
  149. static const struct apple_key_translation *apple_find_translation(
  150. const struct apple_key_translation *table, u16 from)
  151. {
  152. const struct apple_key_translation *trans;
  153. /* Look for the translation */
  154. for (trans = table; trans->from; trans++)
  155. if (trans->from == from)
  156. return trans;
  157. return NULL;
  158. }
  159. static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
  160. struct hid_usage *usage, __s32 value)
  161. {
  162. struct apple_sc *asc = hid_get_drvdata(hid);
  163. const struct apple_key_translation *trans, *table;
  164. if (usage->code == KEY_FN) {
  165. asc->fn_on = !!value;
  166. input_event(input, usage->type, usage->code, value);
  167. return 1;
  168. }
  169. if (fnmode) {
  170. int do_translate;
  171. if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
  172. hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
  173. table = macbookair_fn_keys;
  174. else if (hid->product < 0x21d || hid->product >= 0x300)
  175. table = powerbook_fn_keys;
  176. else
  177. table = apple_fn_keys;
  178. trans = apple_find_translation (table, usage->code);
  179. if (trans) {
  180. if (test_bit(usage->code, asc->pressed_fn))
  181. do_translate = 1;
  182. else if (trans->flags & APPLE_FLAG_FKEY)
  183. do_translate = (fnmode == 2 && asc->fn_on) ||
  184. (fnmode == 1 && !asc->fn_on);
  185. else
  186. do_translate = asc->fn_on;
  187. if (do_translate) {
  188. if (value)
  189. set_bit(usage->code, asc->pressed_fn);
  190. else
  191. clear_bit(usage->code, asc->pressed_fn);
  192. input_event(input, usage->type, trans->to,
  193. value);
  194. return 1;
  195. }
  196. }
  197. if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
  198. (test_bit(usage->code, asc->pressed_numlock) ||
  199. test_bit(LED_NUML, input->led))) {
  200. trans = apple_find_translation(powerbook_numlock_keys,
  201. usage->code);
  202. if (trans) {
  203. if (value)
  204. set_bit(usage->code,
  205. asc->pressed_numlock);
  206. else
  207. clear_bit(usage->code,
  208. asc->pressed_numlock);
  209. input_event(input, usage->type, trans->to,
  210. value);
  211. }
  212. return 1;
  213. }
  214. }
  215. if (iso_layout) {
  216. if (asc->quirks & APPLE_ISO_KEYBOARD) {
  217. trans = apple_find_translation(apple_iso_keyboard, usage->code);
  218. if (trans) {
  219. input_event(input, usage->type, trans->to, value);
  220. return 1;
  221. }
  222. }
  223. }
  224. if (swap_opt_cmd) {
  225. trans = apple_find_translation(swapped_option_cmd_keys, usage->code);
  226. if (trans) {
  227. input_event(input, usage->type, trans->to, value);
  228. return 1;
  229. }
  230. }
  231. return 0;
  232. }
  233. static int apple_event(struct hid_device *hdev, struct hid_field *field,
  234. struct hid_usage *usage, __s32 value)
  235. {
  236. struct apple_sc *asc = hid_get_drvdata(hdev);
  237. if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
  238. !usage->type)
  239. return 0;
  240. if ((asc->quirks & APPLE_INVERT_HWHEEL) &&
  241. usage->code == REL_HWHEEL) {
  242. input_event(field->hidinput->input, usage->type, usage->code,
  243. -value);
  244. return 1;
  245. }
  246. if ((asc->quirks & APPLE_HAS_FN) &&
  247. hidinput_apple_event(hdev, field->hidinput->input,
  248. usage, value))
  249. return 1;
  250. return 0;
  251. }
  252. /*
  253. * MacBook JIS keyboard has wrong logical maximum
  254. */
  255. static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  256. unsigned int *rsize)
  257. {
  258. struct apple_sc *asc = hid_get_drvdata(hdev);
  259. if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 &&
  260. rdesc[53] == 0x65 && rdesc[59] == 0x65) {
  261. hid_info(hdev,
  262. "fixing up MacBook JIS keyboard report descriptor\n");
  263. rdesc[53] = rdesc[59] = 0xe7;
  264. }
  265. return rdesc;
  266. }
  267. static void apple_setup_input(struct input_dev *input)
  268. {
  269. const struct apple_key_translation *trans;
  270. set_bit(KEY_NUMLOCK, input->keybit);
  271. /* Enable all needed keys */
  272. for (trans = apple_fn_keys; trans->from; trans++)
  273. set_bit(trans->to, input->keybit);
  274. for (trans = powerbook_fn_keys; trans->from; trans++)
  275. set_bit(trans->to, input->keybit);
  276. for (trans = powerbook_numlock_keys; trans->from; trans++)
  277. set_bit(trans->to, input->keybit);
  278. for (trans = apple_iso_keyboard; trans->from; trans++)
  279. set_bit(trans->to, input->keybit);
  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. /* we want the hid layer to go through standard path (set and ignore) */
  293. return 0;
  294. }
  295. static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi,
  296. struct hid_field *field, struct hid_usage *usage,
  297. unsigned long **bit, int *max)
  298. {
  299. struct apple_sc *asc = hid_get_drvdata(hdev);
  300. if (asc->quirks & APPLE_MIGHTYMOUSE) {
  301. if (usage->hid == HID_GD_Z)
  302. hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL);
  303. else if (usage->code == BTN_1)
  304. hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2);
  305. else if (usage->code == BTN_2)
  306. hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1);
  307. }
  308. return 0;
  309. }
  310. static int apple_probe(struct hid_device *hdev,
  311. const struct hid_device_id *id)
  312. {
  313. unsigned long quirks = id->driver_data;
  314. struct apple_sc *asc;
  315. unsigned int connect_mask = HID_CONNECT_DEFAULT;
  316. int ret;
  317. asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL);
  318. if (asc == NULL) {
  319. hid_err(hdev, "can't alloc apple descriptor\n");
  320. return -ENOMEM;
  321. }
  322. asc->quirks = quirks;
  323. hid_set_drvdata(hdev, asc);
  324. ret = hid_parse(hdev);
  325. if (ret) {
  326. hid_err(hdev, "parse failed\n");
  327. return ret;
  328. }
  329. if (quirks & APPLE_HIDDEV)
  330. connect_mask |= HID_CONNECT_HIDDEV_FORCE;
  331. if (quirks & APPLE_IGNORE_HIDINPUT)
  332. connect_mask &= ~HID_CONNECT_HIDINPUT;
  333. ret = hid_hw_start(hdev, connect_mask);
  334. if (ret) {
  335. hid_err(hdev, "hw start failed\n");
  336. return ret;
  337. }
  338. return 0;
  339. }
  340. static const struct hid_device_id apple_devices[] = {
  341. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
  342. .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
  343. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI),
  344. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  345. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO),
  346. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  347. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI),
  348. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  349. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO),
  350. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
  351. APPLE_ISO_KEYBOARD },
  352. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS),
  353. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  354. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI),
  355. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  356. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO),
  357. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
  358. APPLE_ISO_KEYBOARD },
  359. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS),
  360. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
  361. APPLE_RDESC_JIS },
  362. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI),
  363. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  364. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO),
  365. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
  366. APPLE_ISO_KEYBOARD },
  367. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS),
  368. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
  369. APPLE_RDESC_JIS },
  370. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI),
  371. .driver_data = APPLE_HAS_FN },
  372. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO),
  373. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  374. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS),
  375. .driver_data = APPLE_HAS_FN },
  376. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI),
  377. .driver_data = APPLE_HAS_FN },
  378. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO),
  379. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  380. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS),
  381. .driver_data = APPLE_HAS_FN },
  382. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI),
  383. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  384. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO),
  385. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
  386. APPLE_ISO_KEYBOARD },
  387. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
  388. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
  389. APPLE_RDESC_JIS },
  390. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI),
  391. .driver_data = APPLE_HAS_FN },
  392. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO),
  393. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  394. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS),
  395. .driver_data = APPLE_HAS_FN },
  396. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
  397. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  398. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
  399. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
  400. APPLE_ISO_KEYBOARD },
  401. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
  402. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
  403. APPLE_ISO_KEYBOARD },
  404. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
  405. USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
  406. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  407. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
  408. USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS),
  409. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  410. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
  411. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  412. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
  413. .driver_data = APPLE_HAS_FN },
  414. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
  415. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  416. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
  417. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  418. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
  419. .driver_data = APPLE_HAS_FN },
  420. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
  421. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  422. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
  423. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  424. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
  425. .driver_data = APPLE_HAS_FN },
  426. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
  427. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  428. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
  429. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  430. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI),
  431. .driver_data = APPLE_HAS_FN },
  432. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO),
  433. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  434. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS),
  435. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  436. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
  437. .driver_data = APPLE_HAS_FN },
  438. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
  439. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  440. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
  441. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  442. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
  443. .driver_data = APPLE_HAS_FN },
  444. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
  445. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  446. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
  447. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  448. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
  449. .driver_data = APPLE_HAS_FN },
  450. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
  451. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  452. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
  453. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  454. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
  455. .driver_data = APPLE_HAS_FN },
  456. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
  457. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  458. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
  459. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  460. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
  461. .driver_data = APPLE_HAS_FN },
  462. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
  463. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  464. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
  465. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  466. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
  467. .driver_data = APPLE_HAS_FN },
  468. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
  469. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  470. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
  471. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  472. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI),
  473. .driver_data = APPLE_HAS_FN },
  474. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO),
  475. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  476. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
  477. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  478. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
  479. .driver_data = APPLE_HAS_FN },
  480. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
  481. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  482. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
  483. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  484. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
  485. .driver_data = APPLE_HAS_FN },
  486. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
  487. .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
  488. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
  489. .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
  490. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
  491. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  492. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
  493. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
  494. APPLE_ISO_KEYBOARD },
  495. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
  496. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  497. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
  498. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  499. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
  500. .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
  501. { }
  502. };
  503. MODULE_DEVICE_TABLE(hid, apple_devices);
  504. static struct hid_driver apple_driver = {
  505. .name = "apple",
  506. .id_table = apple_devices,
  507. .report_fixup = apple_report_fixup,
  508. .probe = apple_probe,
  509. .event = apple_event,
  510. .input_mapping = apple_input_mapping,
  511. .input_mapped = apple_input_mapped,
  512. };
  513. module_hid_driver(apple_driver);
  514. MODULE_LICENSE("GPL");