hid-kye.c 35 KB

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