hid-lenovo.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * HID driver for Lenovo:
  4. * - ThinkPad USB Keyboard with TrackPoint (tpkbd)
  5. * - ThinkPad Compact Bluetooth Keyboard with TrackPoint (cptkbd)
  6. * - ThinkPad Compact USB Keyboard with TrackPoint (cptkbd)
  7. *
  8. * Copyright (c) 2012 Bernhard Seibold
  9. * Copyright (c) 2014 Jamie Lentin <jm@lentin.co.uk>
  10. *
  11. * Linux IBM/Lenovo Scrollpoint mouse driver:
  12. * - IBM Scrollpoint III
  13. * - IBM Scrollpoint Pro
  14. * - IBM Scrollpoint Optical
  15. * - IBM Scrollpoint Optical 800dpi
  16. * - IBM Scrollpoint Optical 800dpi Pro
  17. * - Lenovo Scrollpoint Optical
  18. *
  19. * Copyright (c) 2012 Peter De Wachter <pdewacht@gmail.com>
  20. * Copyright (c) 2018 Peter Ganzhorn <peter.ganzhorn@gmail.com>
  21. */
  22. /*
  23. */
  24. #include <linux/module.h>
  25. #include <linux/sysfs.h>
  26. #include <linux/device.h>
  27. #include <linux/hid.h>
  28. #include <linux/input.h>
  29. #include <linux/leds.h>
  30. #include <linux/workqueue.h>
  31. #include "hid-ids.h"
  32. /* Userspace expects F20 for mic-mute KEY_MICMUTE does not work */
  33. #define LENOVO_KEY_MICMUTE KEY_F20
  34. struct lenovo_drvdata {
  35. u8 led_report[3]; /* Must be first for proper alignment */
  36. int led_state;
  37. struct mutex led_report_mutex;
  38. struct led_classdev led_mute;
  39. struct led_classdev led_micmute;
  40. struct work_struct fn_lock_sync_work;
  41. struct hid_device *hdev;
  42. int press_to_select;
  43. int dragging;
  44. int release_to_select;
  45. int select_right;
  46. int sensitivity;
  47. int press_speed;
  48. u8 middlebutton_state; /* 0:Up, 1:Down (undecided), 2:Scrolling */
  49. bool fn_lock;
  50. };
  51. #define map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, EV_KEY, (c))
  52. #define TP10UBKBD_LED_OUTPUT_REPORT 9
  53. #define TP10UBKBD_FN_LOCK_LED 0x54
  54. #define TP10UBKBD_MUTE_LED 0x64
  55. #define TP10UBKBD_MICMUTE_LED 0x74
  56. #define TP10UBKBD_LED_OFF 1
  57. #define TP10UBKBD_LED_ON 2
  58. static int lenovo_led_set_tp10ubkbd(struct hid_device *hdev, u8 led_code,
  59. enum led_brightness value)
  60. {
  61. struct lenovo_drvdata *data = hid_get_drvdata(hdev);
  62. int ret;
  63. mutex_lock(&data->led_report_mutex);
  64. data->led_report[0] = TP10UBKBD_LED_OUTPUT_REPORT;
  65. data->led_report[1] = led_code;
  66. data->led_report[2] = value ? TP10UBKBD_LED_ON : TP10UBKBD_LED_OFF;
  67. ret = hid_hw_raw_request(hdev, data->led_report[0], data->led_report, 3,
  68. HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
  69. if (ret != 3) {
  70. if (ret != -ENODEV)
  71. hid_err(hdev, "Set LED output report error: %d\n", ret);
  72. ret = ret < 0 ? ret : -EIO;
  73. } else {
  74. ret = 0;
  75. }
  76. mutex_unlock(&data->led_report_mutex);
  77. return ret;
  78. }
  79. static void lenovo_tp10ubkbd_sync_fn_lock(struct work_struct *work)
  80. {
  81. struct lenovo_drvdata *data =
  82. container_of(work, struct lenovo_drvdata, fn_lock_sync_work);
  83. lenovo_led_set_tp10ubkbd(data->hdev, TP10UBKBD_FN_LOCK_LED,
  84. data->fn_lock);
  85. }
  86. static const __u8 lenovo_pro_dock_need_fixup_collection[] = {
  87. 0x05, 0x88, /* Usage Page (Vendor Usage Page 0x88) */
  88. 0x09, 0x01, /* Usage (Vendor Usage 0x01) */
  89. 0xa1, 0x01, /* Collection (Application) */
  90. 0x85, 0x04, /* Report ID (4) */
  91. 0x19, 0x00, /* Usage Minimum (0) */
  92. 0x2a, 0xff, 0xff, /* Usage Maximum (65535) */
  93. };
  94. static __u8 *lenovo_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  95. unsigned int *rsize)
  96. {
  97. switch (hdev->product) {
  98. case USB_DEVICE_ID_LENOVO_TPPRODOCK:
  99. /* the fixups that need to be done:
  100. * - get a reasonable usage max for the vendor collection
  101. * 0x8801 from the report ID 4
  102. */
  103. if (*rsize >= 153 &&
  104. memcmp(&rdesc[140], lenovo_pro_dock_need_fixup_collection,
  105. sizeof(lenovo_pro_dock_need_fixup_collection)) == 0) {
  106. rdesc[151] = 0x01;
  107. rdesc[152] = 0x00;
  108. }
  109. break;
  110. }
  111. return rdesc;
  112. }
  113. static int lenovo_input_mapping_tpkbd(struct hid_device *hdev,
  114. struct hid_input *hi, struct hid_field *field,
  115. struct hid_usage *usage, unsigned long **bit, int *max)
  116. {
  117. if (usage->hid == (HID_UP_BUTTON | 0x0010)) {
  118. /* This sub-device contains trackpoint, mark it */
  119. hid_set_drvdata(hdev, (void *)1);
  120. map_key_clear(LENOVO_KEY_MICMUTE);
  121. return 1;
  122. }
  123. return 0;
  124. }
  125. static int lenovo_input_mapping_cptkbd(struct hid_device *hdev,
  126. struct hid_input *hi, struct hid_field *field,
  127. struct hid_usage *usage, unsigned long **bit, int *max)
  128. {
  129. /* HID_UP_LNVENDOR = USB, HID_UP_MSVENDOR = BT */
  130. if ((usage->hid & HID_USAGE_PAGE) == HID_UP_MSVENDOR ||
  131. (usage->hid & HID_USAGE_PAGE) == HID_UP_LNVENDOR) {
  132. switch (usage->hid & HID_USAGE) {
  133. case 0x00f1: /* Fn-F4: Mic mute */
  134. map_key_clear(LENOVO_KEY_MICMUTE);
  135. return 1;
  136. case 0x00f2: /* Fn-F5: Brightness down */
  137. map_key_clear(KEY_BRIGHTNESSDOWN);
  138. return 1;
  139. case 0x00f3: /* Fn-F6: Brightness up */
  140. map_key_clear(KEY_BRIGHTNESSUP);
  141. return 1;
  142. case 0x00f4: /* Fn-F7: External display (projector) */
  143. map_key_clear(KEY_SWITCHVIDEOMODE);
  144. return 1;
  145. case 0x00f5: /* Fn-F8: Wireless */
  146. map_key_clear(KEY_WLAN);
  147. return 1;
  148. case 0x00f6: /* Fn-F9: Control panel */
  149. map_key_clear(KEY_CONFIG);
  150. return 1;
  151. case 0x00f8: /* Fn-F11: View open applications (3 boxes) */
  152. map_key_clear(KEY_SCALE);
  153. return 1;
  154. case 0x00f9: /* Fn-F12: Open My computer (6 boxes) USB-only */
  155. /* NB: This mapping is invented in raw_event below */
  156. map_key_clear(KEY_FILE);
  157. return 1;
  158. case 0x00fa: /* Fn-Esc: Fn-lock toggle */
  159. map_key_clear(KEY_FN_ESC);
  160. return 1;
  161. case 0x00fb: /* Middle mouse button (in native mode) */
  162. map_key_clear(BTN_MIDDLE);
  163. return 1;
  164. }
  165. }
  166. /* Compatibility middle/wheel mappings should be ignored */
  167. if (usage->hid == HID_GD_WHEEL)
  168. return -1;
  169. if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON &&
  170. (usage->hid & HID_USAGE) == 0x003)
  171. return -1;
  172. if ((usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER &&
  173. (usage->hid & HID_USAGE) == 0x238)
  174. return -1;
  175. /* Map wheel emulation reports: 0xffa1 = USB, 0xff10 = BT */
  176. if ((usage->hid & HID_USAGE_PAGE) == 0xff100000 ||
  177. (usage->hid & HID_USAGE_PAGE) == 0xffa10000) {
  178. field->flags |= HID_MAIN_ITEM_RELATIVE | HID_MAIN_ITEM_VARIABLE;
  179. field->logical_minimum = -127;
  180. field->logical_maximum = 127;
  181. switch (usage->hid & HID_USAGE) {
  182. case 0x0000:
  183. hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL);
  184. return 1;
  185. case 0x0001:
  186. hid_map_usage(hi, usage, bit, max, EV_REL, REL_WHEEL);
  187. return 1;
  188. default:
  189. return -1;
  190. }
  191. }
  192. return 0;
  193. }
  194. static int lenovo_input_mapping_scrollpoint(struct hid_device *hdev,
  195. struct hid_input *hi, struct hid_field *field,
  196. struct hid_usage *usage, unsigned long **bit, int *max)
  197. {
  198. if (usage->hid == HID_GD_Z) {
  199. hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL);
  200. return 1;
  201. }
  202. return 0;
  203. }
  204. static int lenovo_input_mapping_tp10_ultrabook_kbd(struct hid_device *hdev,
  205. struct hid_input *hi, struct hid_field *field,
  206. struct hid_usage *usage, unsigned long **bit, int *max)
  207. {
  208. /*
  209. * The ThinkPad 10 Ultrabook Keyboard uses 0x000c0001 usage for
  210. * a bunch of keys which have no standard consumer page code.
  211. */
  212. if (usage->hid == 0x000c0001) {
  213. switch (usage->usage_index) {
  214. case 8: /* Fn-Esc: Fn-lock toggle */
  215. map_key_clear(KEY_FN_ESC);
  216. return 1;
  217. case 9: /* Fn-F4: Mic mute */
  218. map_key_clear(LENOVO_KEY_MICMUTE);
  219. return 1;
  220. case 10: /* Fn-F7: Control panel */
  221. map_key_clear(KEY_CONFIG);
  222. return 1;
  223. case 11: /* Fn-F8: Search (magnifier glass) */
  224. map_key_clear(KEY_SEARCH);
  225. return 1;
  226. case 12: /* Fn-F10: Open My computer (6 boxes) */
  227. map_key_clear(KEY_FILE);
  228. return 1;
  229. }
  230. }
  231. /*
  232. * The Ultrabook Keyboard sends a spurious F23 key-press when resuming
  233. * from suspend and it does not actually have a F23 key, ignore it.
  234. */
  235. if (usage->hid == 0x00070072)
  236. return -1;
  237. return 0;
  238. }
  239. static int lenovo_input_mapping(struct hid_device *hdev,
  240. struct hid_input *hi, struct hid_field *field,
  241. struct hid_usage *usage, unsigned long **bit, int *max)
  242. {
  243. switch (hdev->product) {
  244. case USB_DEVICE_ID_LENOVO_TPKBD:
  245. return lenovo_input_mapping_tpkbd(hdev, hi, field,
  246. usage, bit, max);
  247. case USB_DEVICE_ID_LENOVO_CUSBKBD:
  248. case USB_DEVICE_ID_LENOVO_CBTKBD:
  249. return lenovo_input_mapping_cptkbd(hdev, hi, field,
  250. usage, bit, max);
  251. case USB_DEVICE_ID_IBM_SCROLLPOINT_III:
  252. case USB_DEVICE_ID_IBM_SCROLLPOINT_PRO:
  253. case USB_DEVICE_ID_IBM_SCROLLPOINT_OPTICAL:
  254. case USB_DEVICE_ID_IBM_SCROLLPOINT_800DPI_OPTICAL:
  255. case USB_DEVICE_ID_IBM_SCROLLPOINT_800DPI_OPTICAL_PRO:
  256. case USB_DEVICE_ID_LENOVO_SCROLLPOINT_OPTICAL:
  257. return lenovo_input_mapping_scrollpoint(hdev, hi, field,
  258. usage, bit, max);
  259. case USB_DEVICE_ID_LENOVO_TP10UBKBD:
  260. return lenovo_input_mapping_tp10_ultrabook_kbd(hdev, hi, field,
  261. usage, bit, max);
  262. default:
  263. return 0;
  264. }
  265. }
  266. #undef map_key_clear
  267. /* Send a config command to the keyboard */
  268. static int lenovo_send_cmd_cptkbd(struct hid_device *hdev,
  269. unsigned char byte2, unsigned char byte3)
  270. {
  271. int ret;
  272. unsigned char *buf;
  273. buf = kzalloc(3, GFP_KERNEL);
  274. if (!buf)
  275. return -ENOMEM;
  276. buf[0] = 0x18;
  277. buf[1] = byte2;
  278. buf[2] = byte3;
  279. switch (hdev->product) {
  280. case USB_DEVICE_ID_LENOVO_CUSBKBD:
  281. ret = hid_hw_raw_request(hdev, 0x13, buf, 3,
  282. HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
  283. break;
  284. case USB_DEVICE_ID_LENOVO_CBTKBD:
  285. ret = hid_hw_output_report(hdev, buf, 3);
  286. break;
  287. default:
  288. ret = -EINVAL;
  289. break;
  290. }
  291. kfree(buf);
  292. return ret < 0 ? ret : 0; /* BT returns 0, USB returns sizeof(buf) */
  293. }
  294. static void lenovo_features_set_cptkbd(struct hid_device *hdev)
  295. {
  296. int ret;
  297. struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
  298. ret = lenovo_send_cmd_cptkbd(hdev, 0x05, cptkbd_data->fn_lock);
  299. if (ret)
  300. hid_err(hdev, "Fn-lock setting failed: %d\n", ret);
  301. ret = lenovo_send_cmd_cptkbd(hdev, 0x02, cptkbd_data->sensitivity);
  302. if (ret)
  303. hid_err(hdev, "Sensitivity setting failed: %d\n", ret);
  304. }
  305. static ssize_t attr_fn_lock_show(struct device *dev,
  306. struct device_attribute *attr,
  307. char *buf)
  308. {
  309. struct hid_device *hdev = to_hid_device(dev);
  310. struct lenovo_drvdata *data = hid_get_drvdata(hdev);
  311. return snprintf(buf, PAGE_SIZE, "%u\n", data->fn_lock);
  312. }
  313. static ssize_t attr_fn_lock_store(struct device *dev,
  314. struct device_attribute *attr,
  315. const char *buf,
  316. size_t count)
  317. {
  318. struct hid_device *hdev = to_hid_device(dev);
  319. struct lenovo_drvdata *data = hid_get_drvdata(hdev);
  320. int value, ret;
  321. if (kstrtoint(buf, 10, &value))
  322. return -EINVAL;
  323. if (value < 0 || value > 1)
  324. return -EINVAL;
  325. data->fn_lock = !!value;
  326. switch (hdev->product) {
  327. case USB_DEVICE_ID_LENOVO_CUSBKBD:
  328. case USB_DEVICE_ID_LENOVO_CBTKBD:
  329. lenovo_features_set_cptkbd(hdev);
  330. break;
  331. case USB_DEVICE_ID_LENOVO_TP10UBKBD:
  332. ret = lenovo_led_set_tp10ubkbd(hdev, TP10UBKBD_FN_LOCK_LED, value);
  333. if (ret)
  334. return ret;
  335. break;
  336. }
  337. return count;
  338. }
  339. static ssize_t attr_sensitivity_show_cptkbd(struct device *dev,
  340. struct device_attribute *attr,
  341. char *buf)
  342. {
  343. struct hid_device *hdev = to_hid_device(dev);
  344. struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
  345. return snprintf(buf, PAGE_SIZE, "%u\n",
  346. cptkbd_data->sensitivity);
  347. }
  348. static ssize_t attr_sensitivity_store_cptkbd(struct device *dev,
  349. struct device_attribute *attr,
  350. const char *buf,
  351. size_t count)
  352. {
  353. struct hid_device *hdev = to_hid_device(dev);
  354. struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
  355. int value;
  356. if (kstrtoint(buf, 10, &value) || value < 1 || value > 255)
  357. return -EINVAL;
  358. cptkbd_data->sensitivity = value;
  359. lenovo_features_set_cptkbd(hdev);
  360. return count;
  361. }
  362. static struct device_attribute dev_attr_fn_lock =
  363. __ATTR(fn_lock, S_IWUSR | S_IRUGO,
  364. attr_fn_lock_show,
  365. attr_fn_lock_store);
  366. static struct device_attribute dev_attr_sensitivity_cptkbd =
  367. __ATTR(sensitivity, S_IWUSR | S_IRUGO,
  368. attr_sensitivity_show_cptkbd,
  369. attr_sensitivity_store_cptkbd);
  370. static struct attribute *lenovo_attributes_cptkbd[] = {
  371. &dev_attr_fn_lock.attr,
  372. &dev_attr_sensitivity_cptkbd.attr,
  373. NULL
  374. };
  375. static const struct attribute_group lenovo_attr_group_cptkbd = {
  376. .attrs = lenovo_attributes_cptkbd,
  377. };
  378. static int lenovo_raw_event(struct hid_device *hdev,
  379. struct hid_report *report, u8 *data, int size)
  380. {
  381. /*
  382. * Compact USB keyboard's Fn-F12 report holds down many other keys, and
  383. * its own key is outside the usage page range. Remove extra
  384. * keypresses and remap to inside usage page.
  385. */
  386. if (unlikely(hdev->product == USB_DEVICE_ID_LENOVO_CUSBKBD
  387. && size == 3
  388. && data[0] == 0x15
  389. && data[1] == 0x94
  390. && data[2] == 0x01)) {
  391. data[1] = 0x00;
  392. data[2] = 0x01;
  393. }
  394. return 0;
  395. }
  396. static int lenovo_event_tp10ubkbd(struct hid_device *hdev,
  397. struct hid_field *field, struct hid_usage *usage, __s32 value)
  398. {
  399. struct lenovo_drvdata *data = hid_get_drvdata(hdev);
  400. if (usage->type == EV_KEY && usage->code == KEY_FN_ESC && value == 1) {
  401. /*
  402. * The user has toggled the Fn-lock state. Toggle our own
  403. * cached value of it and sync our value to the keyboard to
  404. * ensure things are in sync (the sycning should be a no-op).
  405. */
  406. data->fn_lock = !data->fn_lock;
  407. schedule_work(&data->fn_lock_sync_work);
  408. }
  409. return 0;
  410. }
  411. static int lenovo_event_cptkbd(struct hid_device *hdev,
  412. struct hid_field *field, struct hid_usage *usage, __s32 value)
  413. {
  414. struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
  415. /* "wheel" scroll events */
  416. if (usage->type == EV_REL && (usage->code == REL_WHEEL ||
  417. usage->code == REL_HWHEEL)) {
  418. /* Scroll events disable middle-click event */
  419. cptkbd_data->middlebutton_state = 2;
  420. return 0;
  421. }
  422. /* Middle click events */
  423. if (usage->type == EV_KEY && usage->code == BTN_MIDDLE) {
  424. if (value == 1) {
  425. cptkbd_data->middlebutton_state = 1;
  426. } else if (value == 0) {
  427. if (cptkbd_data->middlebutton_state == 1) {
  428. /* No scrolling inbetween, send middle-click */
  429. input_event(field->hidinput->input,
  430. EV_KEY, BTN_MIDDLE, 1);
  431. input_sync(field->hidinput->input);
  432. input_event(field->hidinput->input,
  433. EV_KEY, BTN_MIDDLE, 0);
  434. input_sync(field->hidinput->input);
  435. }
  436. cptkbd_data->middlebutton_state = 0;
  437. }
  438. return 1;
  439. }
  440. return 0;
  441. }
  442. static int lenovo_event(struct hid_device *hdev, struct hid_field *field,
  443. struct hid_usage *usage, __s32 value)
  444. {
  445. if (!hid_get_drvdata(hdev))
  446. return 0;
  447. switch (hdev->product) {
  448. case USB_DEVICE_ID_LENOVO_CUSBKBD:
  449. case USB_DEVICE_ID_LENOVO_CBTKBD:
  450. return lenovo_event_cptkbd(hdev, field, usage, value);
  451. case USB_DEVICE_ID_LENOVO_TP10UBKBD:
  452. return lenovo_event_tp10ubkbd(hdev, field, usage, value);
  453. default:
  454. return 0;
  455. }
  456. }
  457. static int lenovo_features_set_tpkbd(struct hid_device *hdev)
  458. {
  459. struct hid_report *report;
  460. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  461. report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[4];
  462. report->field[0]->value[0] = data_pointer->press_to_select ? 0x01 : 0x02;
  463. report->field[0]->value[0] |= data_pointer->dragging ? 0x04 : 0x08;
  464. report->field[0]->value[0] |= data_pointer->release_to_select ? 0x10 : 0x20;
  465. report->field[0]->value[0] |= data_pointer->select_right ? 0x80 : 0x40;
  466. report->field[1]->value[0] = 0x03; // unknown setting, imitate windows driver
  467. report->field[2]->value[0] = data_pointer->sensitivity;
  468. report->field[3]->value[0] = data_pointer->press_speed;
  469. hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
  470. return 0;
  471. }
  472. static ssize_t attr_press_to_select_show_tpkbd(struct device *dev,
  473. struct device_attribute *attr,
  474. char *buf)
  475. {
  476. struct hid_device *hdev = to_hid_device(dev);
  477. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  478. return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select);
  479. }
  480. static ssize_t attr_press_to_select_store_tpkbd(struct device *dev,
  481. struct device_attribute *attr,
  482. const char *buf,
  483. size_t count)
  484. {
  485. struct hid_device *hdev = to_hid_device(dev);
  486. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  487. int value;
  488. if (kstrtoint(buf, 10, &value))
  489. return -EINVAL;
  490. if (value < 0 || value > 1)
  491. return -EINVAL;
  492. data_pointer->press_to_select = value;
  493. lenovo_features_set_tpkbd(hdev);
  494. return count;
  495. }
  496. static ssize_t attr_dragging_show_tpkbd(struct device *dev,
  497. struct device_attribute *attr,
  498. char *buf)
  499. {
  500. struct hid_device *hdev = to_hid_device(dev);
  501. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  502. return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging);
  503. }
  504. static ssize_t attr_dragging_store_tpkbd(struct device *dev,
  505. struct device_attribute *attr,
  506. const char *buf,
  507. size_t count)
  508. {
  509. struct hid_device *hdev = to_hid_device(dev);
  510. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  511. int value;
  512. if (kstrtoint(buf, 10, &value))
  513. return -EINVAL;
  514. if (value < 0 || value > 1)
  515. return -EINVAL;
  516. data_pointer->dragging = value;
  517. lenovo_features_set_tpkbd(hdev);
  518. return count;
  519. }
  520. static ssize_t attr_release_to_select_show_tpkbd(struct device *dev,
  521. struct device_attribute *attr,
  522. char *buf)
  523. {
  524. struct hid_device *hdev = to_hid_device(dev);
  525. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  526. return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select);
  527. }
  528. static ssize_t attr_release_to_select_store_tpkbd(struct device *dev,
  529. struct device_attribute *attr,
  530. const char *buf,
  531. size_t count)
  532. {
  533. struct hid_device *hdev = to_hid_device(dev);
  534. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  535. int value;
  536. if (kstrtoint(buf, 10, &value))
  537. return -EINVAL;
  538. if (value < 0 || value > 1)
  539. return -EINVAL;
  540. data_pointer->release_to_select = value;
  541. lenovo_features_set_tpkbd(hdev);
  542. return count;
  543. }
  544. static ssize_t attr_select_right_show_tpkbd(struct device *dev,
  545. struct device_attribute *attr,
  546. char *buf)
  547. {
  548. struct hid_device *hdev = to_hid_device(dev);
  549. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  550. return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right);
  551. }
  552. static ssize_t attr_select_right_store_tpkbd(struct device *dev,
  553. struct device_attribute *attr,
  554. const char *buf,
  555. size_t count)
  556. {
  557. struct hid_device *hdev = to_hid_device(dev);
  558. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  559. int value;
  560. if (kstrtoint(buf, 10, &value))
  561. return -EINVAL;
  562. if (value < 0 || value > 1)
  563. return -EINVAL;
  564. data_pointer->select_right = value;
  565. lenovo_features_set_tpkbd(hdev);
  566. return count;
  567. }
  568. static ssize_t attr_sensitivity_show_tpkbd(struct device *dev,
  569. struct device_attribute *attr,
  570. char *buf)
  571. {
  572. struct hid_device *hdev = to_hid_device(dev);
  573. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  574. return snprintf(buf, PAGE_SIZE, "%u\n",
  575. data_pointer->sensitivity);
  576. }
  577. static ssize_t attr_sensitivity_store_tpkbd(struct device *dev,
  578. struct device_attribute *attr,
  579. const char *buf,
  580. size_t count)
  581. {
  582. struct hid_device *hdev = to_hid_device(dev);
  583. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  584. int value;
  585. if (kstrtoint(buf, 10, &value) || value < 1 || value > 255)
  586. return -EINVAL;
  587. data_pointer->sensitivity = value;
  588. lenovo_features_set_tpkbd(hdev);
  589. return count;
  590. }
  591. static ssize_t attr_press_speed_show_tpkbd(struct device *dev,
  592. struct device_attribute *attr,
  593. char *buf)
  594. {
  595. struct hid_device *hdev = to_hid_device(dev);
  596. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  597. return snprintf(buf, PAGE_SIZE, "%u\n",
  598. data_pointer->press_speed);
  599. }
  600. static ssize_t attr_press_speed_store_tpkbd(struct device *dev,
  601. struct device_attribute *attr,
  602. const char *buf,
  603. size_t count)
  604. {
  605. struct hid_device *hdev = to_hid_device(dev);
  606. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  607. int value;
  608. if (kstrtoint(buf, 10, &value) || value < 1 || value > 255)
  609. return -EINVAL;
  610. data_pointer->press_speed = value;
  611. lenovo_features_set_tpkbd(hdev);
  612. return count;
  613. }
  614. static struct device_attribute dev_attr_press_to_select_tpkbd =
  615. __ATTR(press_to_select, S_IWUSR | S_IRUGO,
  616. attr_press_to_select_show_tpkbd,
  617. attr_press_to_select_store_tpkbd);
  618. static struct device_attribute dev_attr_dragging_tpkbd =
  619. __ATTR(dragging, S_IWUSR | S_IRUGO,
  620. attr_dragging_show_tpkbd,
  621. attr_dragging_store_tpkbd);
  622. static struct device_attribute dev_attr_release_to_select_tpkbd =
  623. __ATTR(release_to_select, S_IWUSR | S_IRUGO,
  624. attr_release_to_select_show_tpkbd,
  625. attr_release_to_select_store_tpkbd);
  626. static struct device_attribute dev_attr_select_right_tpkbd =
  627. __ATTR(select_right, S_IWUSR | S_IRUGO,
  628. attr_select_right_show_tpkbd,
  629. attr_select_right_store_tpkbd);
  630. static struct device_attribute dev_attr_sensitivity_tpkbd =
  631. __ATTR(sensitivity, S_IWUSR | S_IRUGO,
  632. attr_sensitivity_show_tpkbd,
  633. attr_sensitivity_store_tpkbd);
  634. static struct device_attribute dev_attr_press_speed_tpkbd =
  635. __ATTR(press_speed, S_IWUSR | S_IRUGO,
  636. attr_press_speed_show_tpkbd,
  637. attr_press_speed_store_tpkbd);
  638. static struct attribute *lenovo_attributes_tpkbd[] = {
  639. &dev_attr_press_to_select_tpkbd.attr,
  640. &dev_attr_dragging_tpkbd.attr,
  641. &dev_attr_release_to_select_tpkbd.attr,
  642. &dev_attr_select_right_tpkbd.attr,
  643. &dev_attr_sensitivity_tpkbd.attr,
  644. &dev_attr_press_speed_tpkbd.attr,
  645. NULL
  646. };
  647. static const struct attribute_group lenovo_attr_group_tpkbd = {
  648. .attrs = lenovo_attributes_tpkbd,
  649. };
  650. static void lenovo_led_set_tpkbd(struct hid_device *hdev)
  651. {
  652. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  653. struct hid_report *report;
  654. report = hdev->report_enum[HID_OUTPUT_REPORT].report_id_hash[3];
  655. report->field[0]->value[0] = (data_pointer->led_state >> 0) & 1;
  656. report->field[0]->value[1] = (data_pointer->led_state >> 1) & 1;
  657. hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
  658. }
  659. static enum led_brightness lenovo_led_brightness_get(
  660. struct led_classdev *led_cdev)
  661. {
  662. struct device *dev = led_cdev->dev->parent;
  663. struct hid_device *hdev = to_hid_device(dev);
  664. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  665. int led_nr = 0;
  666. if (led_cdev == &data_pointer->led_micmute)
  667. led_nr = 1;
  668. return data_pointer->led_state & (1 << led_nr)
  669. ? LED_FULL
  670. : LED_OFF;
  671. }
  672. static int lenovo_led_brightness_set(struct led_classdev *led_cdev,
  673. enum led_brightness value)
  674. {
  675. struct device *dev = led_cdev->dev->parent;
  676. struct hid_device *hdev = to_hid_device(dev);
  677. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  678. u8 tp10ubkbd_led[] = { TP10UBKBD_MUTE_LED, TP10UBKBD_MICMUTE_LED };
  679. int led_nr = 0;
  680. int ret = 0;
  681. if (led_cdev == &data_pointer->led_micmute)
  682. led_nr = 1;
  683. if (value == LED_OFF)
  684. data_pointer->led_state &= ~(1 << led_nr);
  685. else
  686. data_pointer->led_state |= 1 << led_nr;
  687. switch (hdev->product) {
  688. case USB_DEVICE_ID_LENOVO_TPKBD:
  689. lenovo_led_set_tpkbd(hdev);
  690. break;
  691. case USB_DEVICE_ID_LENOVO_TP10UBKBD:
  692. ret = lenovo_led_set_tp10ubkbd(hdev, tp10ubkbd_led[led_nr], value);
  693. break;
  694. }
  695. return ret;
  696. }
  697. static int lenovo_register_leds(struct hid_device *hdev)
  698. {
  699. struct lenovo_drvdata *data = hid_get_drvdata(hdev);
  700. size_t name_sz = strlen(dev_name(&hdev->dev)) + 16;
  701. char *name_mute, *name_micm;
  702. int ret;
  703. name_mute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL);
  704. name_micm = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL);
  705. if (name_mute == NULL || name_micm == NULL) {
  706. hid_err(hdev, "Could not allocate memory for led data\n");
  707. return -ENOMEM;
  708. }
  709. snprintf(name_mute, name_sz, "%s:amber:mute", dev_name(&hdev->dev));
  710. snprintf(name_micm, name_sz, "%s:amber:micmute", dev_name(&hdev->dev));
  711. data->led_mute.name = name_mute;
  712. data->led_mute.brightness_get = lenovo_led_brightness_get;
  713. data->led_mute.brightness_set_blocking = lenovo_led_brightness_set;
  714. data->led_mute.flags = LED_HW_PLUGGABLE;
  715. data->led_mute.dev = &hdev->dev;
  716. ret = led_classdev_register(&hdev->dev, &data->led_mute);
  717. if (ret < 0)
  718. return ret;
  719. data->led_micmute.name = name_micm;
  720. data->led_micmute.brightness_get = lenovo_led_brightness_get;
  721. data->led_micmute.brightness_set_blocking = lenovo_led_brightness_set;
  722. data->led_micmute.flags = LED_HW_PLUGGABLE;
  723. data->led_micmute.dev = &hdev->dev;
  724. ret = led_classdev_register(&hdev->dev, &data->led_micmute);
  725. if (ret < 0) {
  726. led_classdev_unregister(&data->led_mute);
  727. return ret;
  728. }
  729. return 0;
  730. }
  731. static int lenovo_probe_tpkbd(struct hid_device *hdev)
  732. {
  733. struct lenovo_drvdata *data_pointer;
  734. int i, ret;
  735. /*
  736. * Only register extra settings against subdevice where input_mapping
  737. * set drvdata to 1, i.e. the trackpoint.
  738. */
  739. if (!hid_get_drvdata(hdev))
  740. return 0;
  741. hid_set_drvdata(hdev, NULL);
  742. /* Validate required reports. */
  743. for (i = 0; i < 4; i++) {
  744. if (!hid_validate_values(hdev, HID_FEATURE_REPORT, 4, i, 1))
  745. return -ENODEV;
  746. }
  747. if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 3, 0, 2))
  748. return -ENODEV;
  749. ret = sysfs_create_group(&hdev->dev.kobj, &lenovo_attr_group_tpkbd);
  750. if (ret)
  751. hid_warn(hdev, "Could not create sysfs group: %d\n", ret);
  752. data_pointer = devm_kzalloc(&hdev->dev,
  753. sizeof(struct lenovo_drvdata),
  754. GFP_KERNEL);
  755. if (data_pointer == NULL) {
  756. hid_err(hdev, "Could not allocate memory for driver data\n");
  757. ret = -ENOMEM;
  758. goto err;
  759. }
  760. // set same default values as windows driver
  761. data_pointer->sensitivity = 0xa0;
  762. data_pointer->press_speed = 0x38;
  763. hid_set_drvdata(hdev, data_pointer);
  764. ret = lenovo_register_leds(hdev);
  765. if (ret)
  766. goto err;
  767. lenovo_features_set_tpkbd(hdev);
  768. return 0;
  769. err:
  770. sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tpkbd);
  771. return ret;
  772. }
  773. static int lenovo_probe_cptkbd(struct hid_device *hdev)
  774. {
  775. int ret;
  776. struct lenovo_drvdata *cptkbd_data;
  777. /* All the custom action happens on the USBMOUSE device for USB */
  778. if (hdev->product == USB_DEVICE_ID_LENOVO_CUSBKBD
  779. && hdev->type != HID_TYPE_USBMOUSE) {
  780. hid_dbg(hdev, "Ignoring keyboard half of device\n");
  781. return 0;
  782. }
  783. cptkbd_data = devm_kzalloc(&hdev->dev,
  784. sizeof(*cptkbd_data),
  785. GFP_KERNEL);
  786. if (cptkbd_data == NULL) {
  787. hid_err(hdev, "can't alloc keyboard descriptor\n");
  788. return -ENOMEM;
  789. }
  790. hid_set_drvdata(hdev, cptkbd_data);
  791. /*
  792. * Tell the keyboard a driver understands it, and turn F7, F9, F11 into
  793. * regular keys
  794. */
  795. ret = lenovo_send_cmd_cptkbd(hdev, 0x01, 0x03);
  796. if (ret)
  797. hid_warn(hdev, "Failed to switch F7/9/11 mode: %d\n", ret);
  798. /* Switch middle button to native mode */
  799. ret = lenovo_send_cmd_cptkbd(hdev, 0x09, 0x01);
  800. if (ret)
  801. hid_warn(hdev, "Failed to switch middle button: %d\n", ret);
  802. /* Set keyboard settings to known state */
  803. cptkbd_data->middlebutton_state = 0;
  804. cptkbd_data->fn_lock = true;
  805. cptkbd_data->sensitivity = 0x05;
  806. lenovo_features_set_cptkbd(hdev);
  807. ret = sysfs_create_group(&hdev->dev.kobj, &lenovo_attr_group_cptkbd);
  808. if (ret)
  809. hid_warn(hdev, "Could not create sysfs group: %d\n", ret);
  810. return 0;
  811. }
  812. static struct attribute *lenovo_attributes_tp10ubkbd[] = {
  813. &dev_attr_fn_lock.attr,
  814. NULL
  815. };
  816. static const struct attribute_group lenovo_attr_group_tp10ubkbd = {
  817. .attrs = lenovo_attributes_tp10ubkbd,
  818. };
  819. static int lenovo_probe_tp10ubkbd(struct hid_device *hdev)
  820. {
  821. struct lenovo_drvdata *data;
  822. int ret;
  823. /* All the custom action happens on the USBMOUSE device for USB */
  824. if (hdev->type != HID_TYPE_USBMOUSE)
  825. return 0;
  826. data = devm_kzalloc(&hdev->dev, sizeof(*data), GFP_KERNEL);
  827. if (!data)
  828. return -ENOMEM;
  829. mutex_init(&data->led_report_mutex);
  830. INIT_WORK(&data->fn_lock_sync_work, lenovo_tp10ubkbd_sync_fn_lock);
  831. data->hdev = hdev;
  832. hid_set_drvdata(hdev, data);
  833. /*
  834. * The Thinkpad 10 ultrabook USB kbd dock's Fn-lock defaults to on.
  835. * We cannot read the state, only set it, so we force it to on here
  836. * (which should be a no-op) to make sure that our state matches the
  837. * keyboard's FN-lock state. This is the same as what Windows does.
  838. */
  839. data->fn_lock = true;
  840. lenovo_led_set_tp10ubkbd(hdev, TP10UBKBD_FN_LOCK_LED, data->fn_lock);
  841. ret = sysfs_create_group(&hdev->dev.kobj, &lenovo_attr_group_tp10ubkbd);
  842. if (ret)
  843. return ret;
  844. ret = lenovo_register_leds(hdev);
  845. if (ret)
  846. goto err;
  847. return 0;
  848. err:
  849. sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tp10ubkbd);
  850. return ret;
  851. }
  852. static int lenovo_probe(struct hid_device *hdev,
  853. const struct hid_device_id *id)
  854. {
  855. int ret;
  856. ret = hid_parse(hdev);
  857. if (ret) {
  858. hid_err(hdev, "hid_parse failed\n");
  859. goto err;
  860. }
  861. ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  862. if (ret) {
  863. hid_err(hdev, "hid_hw_start failed\n");
  864. goto err;
  865. }
  866. switch (hdev->product) {
  867. case USB_DEVICE_ID_LENOVO_TPKBD:
  868. ret = lenovo_probe_tpkbd(hdev);
  869. break;
  870. case USB_DEVICE_ID_LENOVO_CUSBKBD:
  871. case USB_DEVICE_ID_LENOVO_CBTKBD:
  872. ret = lenovo_probe_cptkbd(hdev);
  873. break;
  874. case USB_DEVICE_ID_LENOVO_TP10UBKBD:
  875. ret = lenovo_probe_tp10ubkbd(hdev);
  876. break;
  877. default:
  878. ret = 0;
  879. break;
  880. }
  881. if (ret)
  882. goto err_hid;
  883. return 0;
  884. err_hid:
  885. hid_hw_stop(hdev);
  886. err:
  887. return ret;
  888. }
  889. static void lenovo_remove_tpkbd(struct hid_device *hdev)
  890. {
  891. struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
  892. /*
  893. * Only the trackpoint half of the keyboard has drvdata and stuff that
  894. * needs unregistering.
  895. */
  896. if (data_pointer == NULL)
  897. return;
  898. sysfs_remove_group(&hdev->dev.kobj,
  899. &lenovo_attr_group_tpkbd);
  900. led_classdev_unregister(&data_pointer->led_micmute);
  901. led_classdev_unregister(&data_pointer->led_mute);
  902. }
  903. static void lenovo_remove_cptkbd(struct hid_device *hdev)
  904. {
  905. sysfs_remove_group(&hdev->dev.kobj,
  906. &lenovo_attr_group_cptkbd);
  907. }
  908. static void lenovo_remove_tp10ubkbd(struct hid_device *hdev)
  909. {
  910. struct lenovo_drvdata *data = hid_get_drvdata(hdev);
  911. if (data == NULL)
  912. return;
  913. led_classdev_unregister(&data->led_micmute);
  914. led_classdev_unregister(&data->led_mute);
  915. sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tp10ubkbd);
  916. cancel_work_sync(&data->fn_lock_sync_work);
  917. }
  918. static void lenovo_remove(struct hid_device *hdev)
  919. {
  920. switch (hdev->product) {
  921. case USB_DEVICE_ID_LENOVO_TPKBD:
  922. lenovo_remove_tpkbd(hdev);
  923. break;
  924. case USB_DEVICE_ID_LENOVO_CUSBKBD:
  925. case USB_DEVICE_ID_LENOVO_CBTKBD:
  926. lenovo_remove_cptkbd(hdev);
  927. break;
  928. case USB_DEVICE_ID_LENOVO_TP10UBKBD:
  929. lenovo_remove_tp10ubkbd(hdev);
  930. break;
  931. }
  932. hid_hw_stop(hdev);
  933. }
  934. static int lenovo_input_configured(struct hid_device *hdev,
  935. struct hid_input *hi)
  936. {
  937. switch (hdev->product) {
  938. case USB_DEVICE_ID_LENOVO_TPKBD:
  939. case USB_DEVICE_ID_LENOVO_CUSBKBD:
  940. case USB_DEVICE_ID_LENOVO_CBTKBD:
  941. if (test_bit(EV_REL, hi->input->evbit)) {
  942. /* set only for trackpoint device */
  943. __set_bit(INPUT_PROP_POINTER, hi->input->propbit);
  944. __set_bit(INPUT_PROP_POINTING_STICK,
  945. hi->input->propbit);
  946. }
  947. break;
  948. }
  949. return 0;
  950. }
  951. static const struct hid_device_id lenovo_devices[] = {
  952. { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) },
  953. { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CUSBKBD) },
  954. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CBTKBD) },
  955. { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPPRODOCK) },
  956. { HID_USB_DEVICE(USB_VENDOR_ID_IBM, USB_DEVICE_ID_IBM_SCROLLPOINT_III) },
  957. { HID_USB_DEVICE(USB_VENDOR_ID_IBM, USB_DEVICE_ID_IBM_SCROLLPOINT_PRO) },
  958. { HID_USB_DEVICE(USB_VENDOR_ID_IBM, USB_DEVICE_ID_IBM_SCROLLPOINT_OPTICAL) },
  959. { HID_USB_DEVICE(USB_VENDOR_ID_IBM, USB_DEVICE_ID_IBM_SCROLLPOINT_800DPI_OPTICAL) },
  960. { HID_USB_DEVICE(USB_VENDOR_ID_IBM, USB_DEVICE_ID_IBM_SCROLLPOINT_800DPI_OPTICAL_PRO) },
  961. { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_SCROLLPOINT_OPTICAL) },
  962. { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TP10UBKBD) },
  963. { }
  964. };
  965. MODULE_DEVICE_TABLE(hid, lenovo_devices);
  966. static struct hid_driver lenovo_driver = {
  967. .name = "lenovo",
  968. .id_table = lenovo_devices,
  969. .input_configured = lenovo_input_configured,
  970. .input_mapping = lenovo_input_mapping,
  971. .probe = lenovo_probe,
  972. .remove = lenovo_remove,
  973. .raw_event = lenovo_raw_event,
  974. .event = lenovo_event,
  975. .report_fixup = lenovo_report_fixup,
  976. };
  977. module_hid_driver(lenovo_driver);
  978. MODULE_LICENSE("GPL");