hid-kye.c 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * HID driver for Kye/Genius devices not fully compliant with HID standard
  4. *
  5. * Copyright (c) 2009 Jiri Kosina
  6. * Copyright (c) 2009 Tomas Hanak
  7. * Copyright (c) 2012 Nikolai Kondrashov
  8. */
  9. /*
  10. */
  11. #include <linux/device.h>
  12. #include <linux/hid.h>
  13. #include <linux/module.h>
  14. #include "hid-ids.h"
  15. /* Original EasyPen i405X report descriptor size */
  16. #define EASYPEN_I405X_RDESC_ORIG_SIZE 476
  17. /* Fixed EasyPen i405X report descriptor */
  18. static __u8 easypen_i405x_rdesc_fixed[] = {
  19. 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
  20. 0x09, 0x01, /* Usage (01h), */
  21. 0xA1, 0x01, /* Collection (Application), */
  22. 0x85, 0x05, /* Report ID (5), */
  23. 0x09, 0x01, /* Usage (01h), */
  24. 0x15, 0x80, /* Logical Minimum (-128), */
  25. 0x25, 0x7F, /* Logical Maximum (127), */
  26. 0x75, 0x08, /* Report Size (8), */
  27. 0x95, 0x07, /* Report Count (7), */
  28. 0xB1, 0x02, /* Feature (Variable), */
  29. 0xC0, /* End Collection, */
  30. 0x05, 0x0D, /* Usage Page (Digitizer), */
  31. 0x09, 0x01, /* Usage (Digitizer), */
  32. 0xA1, 0x01, /* Collection (Application), */
  33. 0x85, 0x10, /* Report ID (16), */
  34. 0x09, 0x20, /* Usage (Stylus), */
  35. 0xA0, /* Collection (Physical), */
  36. 0x14, /* Logical Minimum (0), */
  37. 0x25, 0x01, /* Logical Maximum (1), */
  38. 0x75, 0x01, /* Report Size (1), */
  39. 0x09, 0x42, /* Usage (Tip Switch), */
  40. 0x09, 0x44, /* Usage (Barrel Switch), */
  41. 0x09, 0x46, /* Usage (Tablet Pick), */
  42. 0x95, 0x03, /* Report Count (3), */
  43. 0x81, 0x02, /* Input (Variable), */
  44. 0x95, 0x04, /* Report Count (4), */
  45. 0x81, 0x03, /* Input (Constant, Variable), */
  46. 0x09, 0x32, /* Usage (In Range), */
  47. 0x95, 0x01, /* Report Count (1), */
  48. 0x81, 0x02, /* Input (Variable), */
  49. 0x75, 0x10, /* Report Size (16), */
  50. 0x95, 0x01, /* Report Count (1), */
  51. 0xA4, /* Push, */
  52. 0x05, 0x01, /* Usage Page (Desktop), */
  53. 0x55, 0xFD, /* Unit Exponent (-3), */
  54. 0x65, 0x13, /* Unit (Inch), */
  55. 0x34, /* Physical Minimum (0), */
  56. 0x09, 0x30, /* Usage (X), */
  57. 0x46, 0x7C, 0x15, /* Physical Maximum (5500), */
  58. 0x26, 0x00, 0x37, /* Logical Maximum (14080), */
  59. 0x81, 0x02, /* Input (Variable), */
  60. 0x09, 0x31, /* Usage (Y), */
  61. 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */
  62. 0x26, 0x00, 0x28, /* Logical Maximum (10240), */
  63. 0x81, 0x02, /* Input (Variable), */
  64. 0xB4, /* Pop, */
  65. 0x09, 0x30, /* Usage (Tip Pressure), */
  66. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  67. 0x81, 0x02, /* Input (Variable), */
  68. 0xC0, /* End Collection, */
  69. 0xC0 /* End Collection */
  70. };
  71. /* Original MousePen i608X report descriptor size */
  72. #define MOUSEPEN_I608X_RDESC_ORIG_SIZE 476
  73. /* Fixed MousePen i608X report descriptor */
  74. static __u8 mousepen_i608x_rdesc_fixed[] = {
  75. 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
  76. 0x09, 0x01, /* Usage (01h), */
  77. 0xA1, 0x01, /* Collection (Application), */
  78. 0x85, 0x05, /* Report ID (5), */
  79. 0x09, 0x01, /* Usage (01h), */
  80. 0x15, 0x80, /* Logical Minimum (-128), */
  81. 0x25, 0x7F, /* Logical Maximum (127), */
  82. 0x75, 0x08, /* Report Size (8), */
  83. 0x95, 0x07, /* Report Count (7), */
  84. 0xB1, 0x02, /* Feature (Variable), */
  85. 0xC0, /* End Collection, */
  86. 0x05, 0x0D, /* Usage Page (Digitizer), */
  87. 0x09, 0x01, /* Usage (Digitizer), */
  88. 0xA1, 0x01, /* Collection (Application), */
  89. 0x85, 0x10, /* Report ID (16), */
  90. 0x09, 0x20, /* Usage (Stylus), */
  91. 0xA0, /* Collection (Physical), */
  92. 0x14, /* Logical Minimum (0), */
  93. 0x25, 0x01, /* Logical Maximum (1), */
  94. 0x75, 0x01, /* Report Size (1), */
  95. 0x09, 0x42, /* Usage (Tip Switch), */
  96. 0x09, 0x44, /* Usage (Barrel Switch), */
  97. 0x09, 0x46, /* Usage (Tablet Pick), */
  98. 0x95, 0x03, /* Report Count (3), */
  99. 0x81, 0x02, /* Input (Variable), */
  100. 0x95, 0x04, /* Report Count (4), */
  101. 0x81, 0x03, /* Input (Constant, Variable), */
  102. 0x09, 0x32, /* Usage (In Range), */
  103. 0x95, 0x01, /* Report Count (1), */
  104. 0x81, 0x02, /* Input (Variable), */
  105. 0x75, 0x10, /* Report Size (16), */
  106. 0x95, 0x01, /* Report Count (1), */
  107. 0xA4, /* Push, */
  108. 0x05, 0x01, /* Usage Page (Desktop), */
  109. 0x55, 0xFD, /* Unit Exponent (-3), */
  110. 0x65, 0x13, /* Unit (Inch), */
  111. 0x34, /* Physical Minimum (0), */
  112. 0x09, 0x30, /* Usage (X), */
  113. 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
  114. 0x26, 0x00, 0x50, /* Logical Maximum (20480), */
  115. 0x81, 0x02, /* Input (Variable), */
  116. 0x09, 0x31, /* Usage (Y), */
  117. 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
  118. 0x26, 0x00, 0x3C, /* Logical Maximum (15360), */
  119. 0x81, 0x02, /* Input (Variable), */
  120. 0xB4, /* Pop, */
  121. 0x09, 0x30, /* Usage (Tip Pressure), */
  122. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  123. 0x81, 0x02, /* Input (Variable), */
  124. 0xC0, /* End Collection, */
  125. 0xC0, /* End Collection, */
  126. 0x05, 0x01, /* Usage Page (Desktop), */
  127. 0x09, 0x02, /* Usage (Mouse), */
  128. 0xA1, 0x01, /* Collection (Application), */
  129. 0x85, 0x11, /* Report ID (17), */
  130. 0x09, 0x01, /* Usage (Pointer), */
  131. 0xA0, /* Collection (Physical), */
  132. 0x14, /* Logical Minimum (0), */
  133. 0xA4, /* Push, */
  134. 0x05, 0x09, /* Usage Page (Button), */
  135. 0x75, 0x01, /* Report Size (1), */
  136. 0x19, 0x01, /* Usage Minimum (01h), */
  137. 0x29, 0x03, /* Usage Maximum (03h), */
  138. 0x25, 0x01, /* Logical Maximum (1), */
  139. 0x95, 0x03, /* Report Count (3), */
  140. 0x81, 0x02, /* Input (Variable), */
  141. 0x95, 0x05, /* Report Count (5), */
  142. 0x81, 0x01, /* Input (Constant), */
  143. 0xB4, /* Pop, */
  144. 0x95, 0x01, /* Report Count (1), */
  145. 0xA4, /* Push, */
  146. 0x55, 0xFD, /* Unit Exponent (-3), */
  147. 0x65, 0x13, /* Unit (Inch), */
  148. 0x34, /* Physical Minimum (0), */
  149. 0x75, 0x10, /* Report Size (16), */
  150. 0x09, 0x30, /* Usage (X), */
  151. 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
  152. 0x26, 0x00, 0x50, /* Logical Maximum (20480), */
  153. 0x81, 0x02, /* Input (Variable), */
  154. 0x09, 0x31, /* Usage (Y), */
  155. 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
  156. 0x26, 0x00, 0x3C, /* Logical Maximum (15360), */
  157. 0x81, 0x02, /* Input (Variable), */
  158. 0xB4, /* Pop, */
  159. 0x75, 0x08, /* Report Size (8), */
  160. 0x09, 0x38, /* Usage (Wheel), */
  161. 0x15, 0xFF, /* Logical Minimum (-1), */
  162. 0x25, 0x01, /* Logical Maximum (1), */
  163. 0x81, 0x06, /* Input (Variable, Relative), */
  164. 0x81, 0x01, /* Input (Constant), */
  165. 0xC0, /* End Collection, */
  166. 0xC0 /* End Collection */
  167. };
  168. /* Original MousePen i608X v2 report descriptor size */
  169. #define MOUSEPEN_I608X_V2_RDESC_ORIG_SIZE 482
  170. /* Fixed MousePen i608X v2 report descriptor */
  171. static __u8 mousepen_i608x_v2_rdesc_fixed[] = {
  172. 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
  173. 0x09, 0x01, /* Usage (01h), */
  174. 0xA1, 0x01, /* Collection (Application), */
  175. 0x85, 0x05, /* Report ID (5), */
  176. 0x09, 0x01, /* Usage (01h), */
  177. 0x15, 0x80, /* Logical Minimum (-128), */
  178. 0x25, 0x7F, /* Logical Maximum (127), */
  179. 0x75, 0x08, /* Report Size (8), */
  180. 0x95, 0x07, /* Report Count (7), */
  181. 0xB1, 0x02, /* Feature (Variable), */
  182. 0xC0, /* End Collection, */
  183. 0x05, 0x0D, /* Usage Page (Digitizer), */
  184. 0x09, 0x01, /* Usage (Digitizer), */
  185. 0xA1, 0x01, /* Collection (Application), */
  186. 0x85, 0x10, /* Report ID (16), */
  187. 0x09, 0x20, /* Usage (Stylus), */
  188. 0xA0, /* Collection (Physical), */
  189. 0x14, /* Logical Minimum (0), */
  190. 0x25, 0x01, /* Logical Maximum (1), */
  191. 0x75, 0x01, /* Report Size (1), */
  192. 0x09, 0x42, /* Usage (Tip Switch), */
  193. 0x09, 0x44, /* Usage (Barrel Switch), */
  194. 0x09, 0x46, /* Usage (Tablet Pick), */
  195. 0x95, 0x03, /* Report Count (3), */
  196. 0x81, 0x02, /* Input (Variable), */
  197. 0x95, 0x04, /* Report Count (4), */
  198. 0x81, 0x03, /* Input (Constant, Variable), */
  199. 0x09, 0x32, /* Usage (In Range), */
  200. 0x95, 0x01, /* Report Count (1), */
  201. 0x81, 0x02, /* Input (Variable), */
  202. 0x75, 0x10, /* Report Size (16), */
  203. 0x95, 0x01, /* Report Count (1), */
  204. 0xA4, /* Push, */
  205. 0x05, 0x01, /* Usage Page (Desktop), */
  206. 0x55, 0xFD, /* Unit Exponent (-3), */
  207. 0x65, 0x13, /* Unit (Inch), */
  208. 0x34, /* Physical Minimum (0), */
  209. 0x09, 0x30, /* Usage (X), */
  210. 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
  211. 0x27, 0x00, 0xA0, 0x00, 0x00, /* Logical Maximum (40960), */
  212. 0x81, 0x02, /* Input (Variable), */
  213. 0x09, 0x31, /* Usage (Y), */
  214. 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
  215. 0x26, 0x00, 0x78, /* Logical Maximum (30720), */
  216. 0x81, 0x02, /* Input (Variable), */
  217. 0xB4, /* Pop, */
  218. 0x09, 0x30, /* Usage (Tip Pressure), */
  219. 0x26, 0xFF, 0x07, /* Logical Maximum (2047), */
  220. 0x81, 0x02, /* Input (Variable), */
  221. 0xC0, /* End Collection, */
  222. 0xC0, /* End Collection, */
  223. 0x05, 0x01, /* Usage Page (Desktop), */
  224. 0x09, 0x02, /* Usage (Mouse), */
  225. 0xA1, 0x01, /* Collection (Application), */
  226. 0x85, 0x11, /* Report ID (17), */
  227. 0x09, 0x01, /* Usage (Pointer), */
  228. 0xA0, /* Collection (Physical), */
  229. 0x14, /* Logical Minimum (0), */
  230. 0xA4, /* Push, */
  231. 0x05, 0x09, /* Usage Page (Button), */
  232. 0x75, 0x01, /* Report Size (1), */
  233. 0x19, 0x01, /* Usage Minimum (01h), */
  234. 0x29, 0x03, /* Usage Maximum (03h), */
  235. 0x25, 0x01, /* Logical Maximum (1), */
  236. 0x95, 0x03, /* Report Count (3), */
  237. 0x81, 0x02, /* Input (Variable), */
  238. 0x95, 0x05, /* Report Count (5), */
  239. 0x81, 0x01, /* Input (Constant), */
  240. 0xB4, /* Pop, */
  241. 0x95, 0x01, /* Report Count (1), */
  242. 0xA4, /* Push, */
  243. 0x55, 0xFD, /* Unit Exponent (-3), */
  244. 0x65, 0x13, /* Unit (Inch), */
  245. 0x34, /* Physical Minimum (0), */
  246. 0x75, 0x10, /* Report Size (16), */
  247. 0x09, 0x30, /* Usage (X), */
  248. 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
  249. 0x27, 0x00, 0xA0, 0x00, 0x00, /* Logical Maximum (40960), */
  250. 0x81, 0x02, /* Input (Variable), */
  251. 0x09, 0x31, /* Usage (Y), */
  252. 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
  253. 0x26, 0x00, 0x78, /* Logical Maximum (30720), */
  254. 0x81, 0x02, /* Input (Variable), */
  255. 0xB4, /* Pop, */
  256. 0x75, 0x08, /* Report Size (8), */
  257. 0x09, 0x38, /* Usage (Wheel), */
  258. 0x15, 0xFF, /* Logical Minimum (-1), */
  259. 0x25, 0x01, /* Logical Maximum (1), */
  260. 0x81, 0x06, /* Input (Variable, Relative), */
  261. 0x81, 0x01, /* Input (Constant), */
  262. 0xC0, /* End Collection, */
  263. 0xC0 /* End Collection */
  264. };
  265. /* Original EasyPen M610X report descriptor size */
  266. #define EASYPEN_M610X_RDESC_ORIG_SIZE 476
  267. /* Fixed EasyPen M610X report descriptor */
  268. static __u8 easypen_m610x_rdesc_fixed[] = {
  269. 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
  270. 0x09, 0x01, /* Usage (01h), */
  271. 0xA1, 0x01, /* Collection (Application), */
  272. 0x85, 0x05, /* Report ID (5), */
  273. 0x09, 0x01, /* Usage (01h), */
  274. 0x15, 0x80, /* Logical Minimum (-128), */
  275. 0x25, 0x7F, /* Logical Maximum (127), */
  276. 0x75, 0x08, /* Report Size (8), */
  277. 0x95, 0x07, /* Report Count (7), */
  278. 0xB1, 0x02, /* Feature (Variable), */
  279. 0xC0, /* End Collection, */
  280. 0x05, 0x0D, /* Usage Page (Digitizer), */
  281. 0x09, 0x01, /* Usage (Digitizer), */
  282. 0xA1, 0x01, /* Collection (Application), */
  283. 0x85, 0x10, /* Report ID (16), */
  284. 0x09, 0x20, /* Usage (Stylus), */
  285. 0xA0, /* Collection (Physical), */
  286. 0x14, /* Logical Minimum (0), */
  287. 0x25, 0x01, /* Logical Maximum (1), */
  288. 0x75, 0x01, /* Report Size (1), */
  289. 0x09, 0x42, /* Usage (Tip Switch), */
  290. 0x09, 0x44, /* Usage (Barrel Switch), */
  291. 0x09, 0x46, /* Usage (Tablet Pick), */
  292. 0x95, 0x03, /* Report Count (3), */
  293. 0x81, 0x02, /* Input (Variable), */
  294. 0x95, 0x04, /* Report Count (4), */
  295. 0x81, 0x03, /* Input (Constant, Variable), */
  296. 0x09, 0x32, /* Usage (In Range), */
  297. 0x95, 0x01, /* Report Count (1), */
  298. 0x81, 0x02, /* Input (Variable), */
  299. 0x75, 0x10, /* Report Size (16), */
  300. 0x95, 0x01, /* Report Count (1), */
  301. 0xA4, /* Push, */
  302. 0x05, 0x01, /* Usage Page (Desktop), */
  303. 0x55, 0xFD, /* Unit Exponent (-3), */
  304. 0x65, 0x13, /* Unit (Inch), */
  305. 0x34, /* Physical Minimum (0), */
  306. 0x09, 0x30, /* Usage (X), */
  307. 0x46, 0x10, 0x27, /* Physical Maximum (10000), */
  308. 0x27, 0x00, 0xA0, 0x00, 0x00, /* Logical Maximum (40960), */
  309. 0x81, 0x02, /* Input (Variable), */
  310. 0x09, 0x31, /* Usage (Y), */
  311. 0x46, 0x6A, 0x18, /* Physical Maximum (6250), */
  312. 0x26, 0x00, 0x64, /* Logical Maximum (25600), */
  313. 0x81, 0x02, /* Input (Variable), */
  314. 0xB4, /* Pop, */
  315. 0x09, 0x30, /* Usage (Tip Pressure), */
  316. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  317. 0x81, 0x02, /* Input (Variable), */
  318. 0xC0, /* End Collection, */
  319. 0xC0, /* End Collection, */
  320. 0x05, 0x0C, /* Usage Page (Consumer), */
  321. 0x09, 0x01, /* Usage (Consumer Control), */
  322. 0xA1, 0x01, /* Collection (Application), */
  323. 0x85, 0x12, /* Report ID (18), */
  324. 0x14, /* Logical Minimum (0), */
  325. 0x25, 0x01, /* Logical Maximum (1), */
  326. 0x75, 0x01, /* Report Size (1), */
  327. 0x95, 0x04, /* Report Count (4), */
  328. 0x0A, 0x1A, 0x02, /* Usage (AC Undo), */
  329. 0x0A, 0x79, 0x02, /* Usage (AC Redo Or Repeat), */
  330. 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
  331. 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
  332. 0x81, 0x02, /* Input (Variable), */
  333. 0x95, 0x01, /* Report Count (1), */
  334. 0x75, 0x14, /* Report Size (20), */
  335. 0x81, 0x03, /* Input (Constant, Variable), */
  336. 0x75, 0x20, /* Report Size (32), */
  337. 0x81, 0x03, /* Input (Constant, Variable), */
  338. 0xC0 /* End Collection */
  339. };
  340. /* Original PenSketch M912 report descriptor size */
  341. #define PENSKETCH_M912_RDESC_ORIG_SIZE 482
  342. /* Fixed PenSketch M912 report descriptor */
  343. static __u8 pensketch_m912_rdesc_fixed[] = {
  344. 0x05, 0x01, /* Usage Page (Desktop), */
  345. 0x08, /* Usage (00h), */
  346. 0xA1, 0x01, /* Collection (Application), */
  347. 0x85, 0x05, /* Report ID (5), */
  348. 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
  349. 0x09, 0x01, /* Usage (01h), */
  350. 0x15, 0x81, /* Logical Minimum (-127), */
  351. 0x25, 0x7F, /* Logical Maximum (127), */
  352. 0x75, 0x08, /* Report Size (8), */
  353. 0x95, 0x07, /* Report Count (7), */
  354. 0xB1, 0x02, /* Feature (Variable), */
  355. 0xC0, /* End Collection, */
  356. 0x05, 0x0D, /* Usage Page (Digitizer), */
  357. 0x09, 0x01, /* Usage (Digitizer), */
  358. 0xA1, 0x01, /* Collection (Application), */
  359. 0x85, 0x10, /* Report ID (16), */
  360. 0x09, 0x20, /* Usage (Stylus), */
  361. 0xA0, /* Collection (Physical), */
  362. 0x09, 0x42, /* Usage (Tip Switch), */
  363. 0x09, 0x44, /* Usage (Barrel Switch), */
  364. 0x09, 0x46, /* Usage (Tablet Pick), */
  365. 0x14, /* Logical Minimum (0), */
  366. 0x25, 0x01, /* Logical Maximum (1), */
  367. 0x75, 0x01, /* Report Size (1), */
  368. 0x95, 0x03, /* Report Count (3), */
  369. 0x81, 0x02, /* Input (Variable), */
  370. 0x95, 0x04, /* Report Count (4), */
  371. 0x81, 0x03, /* Input (Constant, Variable), */
  372. 0x09, 0x32, /* Usage (In Range), */
  373. 0x95, 0x01, /* Report Count (1), */
  374. 0x81, 0x02, /* Input (Variable), */
  375. 0x75, 0x10, /* Report Size (16), */
  376. 0x95, 0x01, /* Report Count (1), */
  377. 0xA4, /* Push, */
  378. 0x05, 0x01, /* Usage Page (Desktop), */
  379. 0x55, 0xFD, /* Unit Exponent (-3), */
  380. 0x65, 0x13, /* Unit (Inch), */
  381. 0x14, /* Logical Minimum (0), */
  382. 0x34, /* Physical Minimum (0), */
  383. 0x09, 0x30, /* Usage (X), */
  384. 0x27, 0x00, 0xF0, 0x00, 0x00, /* Logical Maximum (61440), */
  385. 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */
  386. 0x81, 0x02, /* Input (Variable), */
  387. 0x09, 0x31, /* Usage (Y), */
  388. 0x27, 0x00, 0xB4, 0x00, 0x00, /* Logical Maximum (46080), */
  389. 0x46, 0x28, 0x23, /* Physical Maximum (9000), */
  390. 0x81, 0x02, /* Input (Variable), */
  391. 0xB4, /* Pop, */
  392. 0x09, 0x30, /* Usage (Tip Pressure), */
  393. 0x14, /* Logical Minimum (0), */
  394. 0x26, 0xFF, 0x07, /* Logical Maximum (2047), */
  395. 0x81, 0x02, /* Input (Variable), */
  396. 0xC0, /* End Collection, */
  397. 0xC0, /* End Collection, */
  398. 0x05, 0x0D, /* Usage Page (Digitizer), */
  399. 0x09, 0x21, /* Usage (Puck), */
  400. 0xA1, 0x01, /* Collection (Application), */
  401. 0x85, 0x11, /* Report ID (17), */
  402. 0x09, 0x21, /* Usage (Puck), */
  403. 0xA0, /* Collection (Physical), */
  404. 0x05, 0x09, /* Usage Page (Button), */
  405. 0x75, 0x01, /* Report Size (1), */
  406. 0x19, 0x01, /* Usage Minimum (01h), */
  407. 0x29, 0x03, /* Usage Maximum (03h), */
  408. 0x14, /* Logical Minimum (0), */
  409. 0x25, 0x01, /* Logical Maximum (1), */
  410. 0x95, 0x03, /* Report Count (3), */
  411. 0x81, 0x02, /* Input (Variable), */
  412. 0x95, 0x04, /* Report Count (4), */
  413. 0x81, 0x01, /* Input (Constant), */
  414. 0x95, 0x01, /* Report Count (1), */
  415. 0x0B, 0x32, 0x00, 0x0D, 0x00, /* Usage (Digitizer In Range), */
  416. 0x14, /* Logical Minimum (0), */
  417. 0x25, 0x01, /* Logical Maximum (1), */
  418. 0x81, 0x02, /* Input (Variable), */
  419. 0xA4, /* Push, */
  420. 0x05, 0x01, /* Usage Page (Desktop), */
  421. 0x75, 0x10, /* Report Size (16), */
  422. 0x95, 0x01, /* Report Count (1), */
  423. 0x55, 0xFD, /* Unit Exponent (-3), */
  424. 0x65, 0x13, /* Unit (Inch), */
  425. 0x14, /* Logical Minimum (0), */
  426. 0x34, /* Physical Minimum (0), */
  427. 0x09, 0x30, /* Usage (X), */
  428. 0x27, 0x00, 0xF0, 0x00, 0x00, /* Logical Maximum (61440), */
  429. 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */
  430. 0x81, 0x02, /* Input (Variable), */
  431. 0x09, 0x31, /* Usage (Y), */
  432. 0x27, 0x00, 0xB4, 0x00, 0x00, /* Logical Maximum (46080), */
  433. 0x46, 0x28, 0x23, /* Physical Maximum (9000), */
  434. 0x81, 0x02, /* Input (Variable), */
  435. 0x09, 0x38, /* Usage (Wheel), */
  436. 0x75, 0x08, /* Report Size (8), */
  437. 0x95, 0x01, /* Report Count (1), */
  438. 0x15, 0xFF, /* Logical Minimum (-1), */
  439. 0x25, 0x01, /* Logical Maximum (1), */
  440. 0x34, /* Physical Minimum (0), */
  441. 0x44, /* Physical Maximum (0), */
  442. 0x81, 0x06, /* Input (Variable, Relative), */
  443. 0xB4, /* Pop, */
  444. 0xC0, /* End Collection, */
  445. 0xC0, /* End Collection, */
  446. 0x05, 0x0C, /* Usage Page (Consumer), */
  447. 0x09, 0x01, /* Usage (Consumer Control), */
  448. 0xA1, 0x01, /* Collection (Application), */
  449. 0x85, 0x12, /* Report ID (18), */
  450. 0x14, /* Logical Minimum (0), */
  451. 0x25, 0x01, /* Logical Maximum (1), */
  452. 0x75, 0x01, /* Report Size (1), */
  453. 0x95, 0x08, /* Report Count (8), */
  454. 0x05, 0x0C, /* Usage Page (Consumer), */
  455. 0x0A, 0x6A, 0x02, /* Usage (AC Delete), */
  456. 0x0A, 0x1A, 0x02, /* Usage (AC Undo), */
  457. 0x0A, 0x01, 0x02, /* Usage (AC New), */
  458. 0x0A, 0x2F, 0x02, /* Usage (AC Zoom), */
  459. 0x0A, 0x25, 0x02, /* Usage (AC Forward), */
  460. 0x0A, 0x24, 0x02, /* Usage (AC Back), */
  461. 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
  462. 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
  463. 0x81, 0x02, /* Input (Variable), */
  464. 0x95, 0x30, /* Report Count (48), */
  465. 0x81, 0x03, /* Input (Constant, Variable), */
  466. 0xC0 /* End Collection */
  467. };
  468. /* Original EasyPen M406XE report descriptor size */
  469. #define EASYPEN_M406XE_RDESC_ORIG_SIZE 476
  470. /* Fixed EasyPen M406XE report descriptor */
  471. static __u8 easypen_m406xe_rdesc_fixed[] = {
  472. 0x05, 0x01, /* Usage Page (Desktop), */
  473. 0x09, 0x01, /* Usage (01h), */
  474. 0xA1, 0x01, /* Collection (Application), */
  475. 0x85, 0x05, /* Report ID (5), */
  476. 0x09, 0x01, /* Usage (01h), */
  477. 0x15, 0x80, /* Logical Minimum (-128), */
  478. 0x25, 0x7F, /* Logical Maximum (127), */
  479. 0x75, 0x08, /* Report Size (8), */
  480. 0x95, 0x07, /* Report Count (7), */
  481. 0xB1, 0x02, /* Feature (Variable), */
  482. 0xC0, /* End Collection, */
  483. 0x05, 0x0D, /* Usage Page (Digitizer), */
  484. 0x09, 0x01, /* Usage (Digitizer), */
  485. 0xA1, 0x01, /* Collection (Application), */
  486. 0x85, 0x10, /* Report ID (16), */
  487. 0x09, 0x20, /* Usage (Stylus), */
  488. 0xA0, /* Collection (Physical), */
  489. 0x14, /* Logical Minimum (0), */
  490. 0x25, 0x01, /* Logical Maximum (1), */
  491. 0x75, 0x01, /* Report Size (1), */
  492. 0x09, 0x42, /* Usage (Tip Switch), */
  493. 0x09, 0x44, /* Usage (Barrel Switch), */
  494. 0x09, 0x46, /* Usage (Tablet Pick), */
  495. 0x95, 0x03, /* Report Count (3), */
  496. 0x81, 0x02, /* Input (Variable), */
  497. 0x95, 0x04, /* Report Count (4), */
  498. 0x81, 0x03, /* Input (Constant, Variable), */
  499. 0x09, 0x32, /* Usage (In Range), */
  500. 0x95, 0x01, /* Report Count (1), */
  501. 0x81, 0x02, /* Input (Variable), */
  502. 0x75, 0x10, /* Report Size (16), */
  503. 0x95, 0x01, /* Report Count (1), */
  504. 0xA4, /* Push, */
  505. 0x05, 0x01, /* Usage Page (Desktop), */
  506. 0x55, 0xFD, /* Unit Exponent (-3), */
  507. 0x65, 0x13, /* Unit (Inch), */
  508. 0x34, /* Physical Minimum (0), */
  509. 0x09, 0x30, /* Usage (X), */
  510. 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
  511. 0x26, 0x00, 0x3C, /* Logical Maximum (15360), */
  512. 0x81, 0x02, /* Input (Variable), */
  513. 0x09, 0x31, /* Usage (Y), */
  514. 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */
  515. 0x26, 0x00, 0x28, /* Logical Maximum (10240), */
  516. 0x81, 0x02, /* Input (Variable), */
  517. 0xB4, /* Pop, */
  518. 0x09, 0x30, /* Usage (Tip Pressure), */
  519. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  520. 0x81, 0x02, /* Input (Variable), */
  521. 0xC0, /* End Collection, */
  522. 0xC0, /* End Collection */
  523. 0x05, 0x0C, /* Usage Page (Consumer), */
  524. 0x09, 0x01, /* Usage (Consumer Control), */
  525. 0xA1, 0x01, /* Collection (Application), */
  526. 0x85, 0x12, /* Report ID (18), */
  527. 0x14, /* Logical Minimum (0), */
  528. 0x25, 0x01, /* Logical Maximum (1), */
  529. 0x75, 0x01, /* Report Size (1), */
  530. 0x95, 0x04, /* Report Count (4), */
  531. 0x0A, 0x79, 0x02, /* Usage (AC Redo Or Repeat), */
  532. 0x0A, 0x1A, 0x02, /* Usage (AC Undo), */
  533. 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
  534. 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
  535. 0x81, 0x02, /* Input (Variable), */
  536. 0x95, 0x34, /* Report Count (52), */
  537. 0x81, 0x03, /* Input (Constant, Variable), */
  538. 0xC0 /* End Collection */
  539. };
  540. static __u8 *kye_consumer_control_fixup(struct hid_device *hdev, __u8 *rdesc,
  541. unsigned int *rsize, int offset, const char *device_name) {
  542. /*
  543. * the fixup that need to be done:
  544. * - change Usage Maximum in the Consumer Control
  545. * (report ID 3) to a reasonable value
  546. */
  547. if (*rsize >= offset + 31 &&
  548. /* Usage Page (Consumer Devices) */
  549. rdesc[offset] == 0x05 && rdesc[offset + 1] == 0x0c &&
  550. /* Usage (Consumer Control) */
  551. rdesc[offset + 2] == 0x09 && rdesc[offset + 3] == 0x01 &&
  552. /* Usage Maximum > 12287 */
  553. rdesc[offset + 10] == 0x2a && rdesc[offset + 12] > 0x2f) {
  554. hid_info(hdev, "fixing up %s report descriptor\n", device_name);
  555. rdesc[offset + 12] = 0x2f;
  556. }
  557. return rdesc;
  558. }
  559. static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  560. unsigned int *rsize)
  561. {
  562. switch (hdev->product) {
  563. case USB_DEVICE_ID_KYE_ERGO_525V:
  564. /* the fixups that need to be done:
  565. * - change led usage page to button for extra buttons
  566. * - report size 8 count 1 must be size 1 count 8 for button
  567. * bitfield
  568. * - change the button usage range to 4-7 for the extra
  569. * buttons
  570. */
  571. if (*rsize >= 75 &&
  572. rdesc[61] == 0x05 && rdesc[62] == 0x08 &&
  573. rdesc[63] == 0x19 && rdesc[64] == 0x08 &&
  574. rdesc[65] == 0x29 && rdesc[66] == 0x0f &&
  575. rdesc[71] == 0x75 && rdesc[72] == 0x08 &&
  576. rdesc[73] == 0x95 && rdesc[74] == 0x01) {
  577. hid_info(hdev,
  578. "fixing up Kye/Genius Ergo Mouse "
  579. "report descriptor\n");
  580. rdesc[62] = 0x09;
  581. rdesc[64] = 0x04;
  582. rdesc[66] = 0x07;
  583. rdesc[72] = 0x01;
  584. rdesc[74] = 0x08;
  585. }
  586. break;
  587. case USB_DEVICE_ID_KYE_EASYPEN_I405X:
  588. if (*rsize == EASYPEN_I405X_RDESC_ORIG_SIZE) {
  589. rdesc = easypen_i405x_rdesc_fixed;
  590. *rsize = sizeof(easypen_i405x_rdesc_fixed);
  591. }
  592. break;
  593. case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
  594. if (*rsize == MOUSEPEN_I608X_RDESC_ORIG_SIZE) {
  595. rdesc = mousepen_i608x_rdesc_fixed;
  596. *rsize = sizeof(mousepen_i608x_rdesc_fixed);
  597. }
  598. break;
  599. case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2:
  600. if (*rsize == MOUSEPEN_I608X_V2_RDESC_ORIG_SIZE) {
  601. rdesc = mousepen_i608x_v2_rdesc_fixed;
  602. *rsize = sizeof(mousepen_i608x_v2_rdesc_fixed);
  603. }
  604. break;
  605. case USB_DEVICE_ID_KYE_EASYPEN_M610X:
  606. if (*rsize == EASYPEN_M610X_RDESC_ORIG_SIZE) {
  607. rdesc = easypen_m610x_rdesc_fixed;
  608. *rsize = sizeof(easypen_m610x_rdesc_fixed);
  609. }
  610. break;
  611. case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
  612. if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
  613. rdesc = easypen_m406xe_rdesc_fixed;
  614. *rsize = sizeof(easypen_m406xe_rdesc_fixed);
  615. }
  616. break;
  617. case USB_DEVICE_ID_KYE_PENSKETCH_M912:
  618. if (*rsize == PENSKETCH_M912_RDESC_ORIG_SIZE) {
  619. rdesc = pensketch_m912_rdesc_fixed;
  620. *rsize = sizeof(pensketch_m912_rdesc_fixed);
  621. }
  622. break;
  623. case USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE:
  624. rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104,
  625. "Genius Gila Gaming Mouse");
  626. break;
  627. case USB_DEVICE_ID_GENIUS_GX_IMPERATOR:
  628. rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 83,
  629. "Genius Gx Imperator Keyboard");
  630. break;
  631. case USB_DEVICE_ID_GENIUS_MANTICORE:
  632. rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104,
  633. "Genius Manticore Keyboard");
  634. break;
  635. }
  636. return rdesc;
  637. }
  638. /**
  639. * kye_tablet_enable() - Enable fully-functional tablet mode by setting a special feature report.
  640. *
  641. * @hdev: HID device
  642. *
  643. * The specific report ID and data were discovered by sniffing the
  644. * Windows driver traffic.
  645. */
  646. static int kye_tablet_enable(struct hid_device *hdev)
  647. {
  648. struct list_head *list;
  649. struct list_head *head;
  650. struct hid_report *report;
  651. __s32 *value;
  652. list = &hdev->report_enum[HID_FEATURE_REPORT].report_list;
  653. list_for_each(head, list) {
  654. report = list_entry(head, struct hid_report, list);
  655. if (report->id == 5)
  656. break;
  657. }
  658. if (head == list) {
  659. hid_err(hdev, "tablet-enabling feature report not found\n");
  660. return -ENODEV;
  661. }
  662. if (report->maxfield < 1 || report->field[0]->report_count < 7) {
  663. hid_err(hdev, "invalid tablet-enabling feature report\n");
  664. return -ENODEV;
  665. }
  666. value = report->field[0]->value;
  667. value[0] = 0x12;
  668. value[1] = 0x10;
  669. value[2] = 0x11;
  670. value[3] = 0x12;
  671. value[4] = 0x00;
  672. value[5] = 0x00;
  673. value[6] = 0x00;
  674. hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
  675. return 0;
  676. }
  677. static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id)
  678. {
  679. int ret;
  680. ret = hid_parse(hdev);
  681. if (ret) {
  682. hid_err(hdev, "parse failed\n");
  683. goto err;
  684. }
  685. ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  686. if (ret) {
  687. hid_err(hdev, "hw start failed\n");
  688. goto err;
  689. }
  690. switch (id->product) {
  691. case USB_DEVICE_ID_KYE_EASYPEN_I405X:
  692. case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
  693. case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2:
  694. case USB_DEVICE_ID_KYE_EASYPEN_M610X:
  695. case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
  696. case USB_DEVICE_ID_KYE_PENSKETCH_M912:
  697. ret = kye_tablet_enable(hdev);
  698. if (ret) {
  699. hid_err(hdev, "tablet enabling failed\n");
  700. goto enabling_err;
  701. }
  702. break;
  703. case USB_DEVICE_ID_GENIUS_MANTICORE:
  704. /*
  705. * The manticore keyboard needs to have all the interfaces
  706. * opened at least once to be fully functional.
  707. */
  708. if (hid_hw_open(hdev))
  709. hid_hw_close(hdev);
  710. break;
  711. }
  712. return 0;
  713. enabling_err:
  714. hid_hw_stop(hdev);
  715. err:
  716. return ret;
  717. }
  718. static const struct hid_device_id kye_devices[] = {
  719. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) },
  720. { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
  721. USB_DEVICE_ID_KYE_EASYPEN_I405X) },
  722. { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
  723. USB_DEVICE_ID_KYE_MOUSEPEN_I608X) },
  724. { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
  725. USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) },
  726. { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
  727. USB_DEVICE_ID_KYE_EASYPEN_M610X) },
  728. { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
  729. USB_DEVICE_ID_KYE_EASYPEN_M406XE) },
  730. { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
  731. USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) },
  732. { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
  733. USB_DEVICE_ID_GENIUS_GX_IMPERATOR) },
  734. { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
  735. USB_DEVICE_ID_GENIUS_MANTICORE) },
  736. { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
  737. USB_DEVICE_ID_KYE_PENSKETCH_M912) },
  738. { }
  739. };
  740. MODULE_DEVICE_TABLE(hid, kye_devices);
  741. static struct hid_driver kye_driver = {
  742. .name = "kye",
  743. .id_table = kye_devices,
  744. .probe = kye_probe,
  745. .report_fixup = kye_report_fixup,
  746. };
  747. module_hid_driver(kye_driver);
  748. MODULE_LICENSE("GPL");