hid-uclogic.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. /*
  2. * HID driver for UC-Logic devices not fully compliant with HID standard
  3. *
  4. * Copyright (c) 2010 Nikolai Kondrashov
  5. */
  6. /*
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the Free
  9. * Software Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. */
  12. #include <linux/device.h>
  13. #include <linux/hid.h>
  14. #include <linux/module.h>
  15. #include <linux/usb.h>
  16. #include "hid-ids.h"
  17. /*
  18. * See WPXXXXU model descriptions, device and HID report descriptors at
  19. * http://sf.net/apps/mediawiki/digimend/?title=UC-Logic_Tablet_WP4030U
  20. * http://sf.net/apps/mediawiki/digimend/?title=UC-Logic_Tablet_WP5540U
  21. * http://sf.net/apps/mediawiki/digimend/?title=UC-Logic_Tablet_WP8060U
  22. */
  23. /* Size of the original descriptor of WPXXXXU tablets */
  24. #define WPXXXXU_RDESC_ORIG_SIZE 212
  25. /* Fixed WP4030U report descriptor */
  26. static __u8 wp4030u_rdesc_fixed[] = {
  27. 0x05, 0x0D, /* Usage Page (Digitizer), */
  28. 0x09, 0x02, /* Usage (Pen), */
  29. 0xA1, 0x01, /* Collection (Application), */
  30. 0x85, 0x09, /* Report ID (9), */
  31. 0x09, 0x20, /* Usage (Stylus), */
  32. 0xA0, /* Collection (Physical), */
  33. 0x75, 0x01, /* Report Size (1), */
  34. 0x09, 0x42, /* Usage (Tip Switch), */
  35. 0x09, 0x44, /* Usage (Barrel Switch), */
  36. 0x09, 0x46, /* Usage (Tablet Pick), */
  37. 0x14, /* Logical Minimum (0), */
  38. 0x25, 0x01, /* Logical Maximum (1), */
  39. 0x95, 0x03, /* Report Count (3), */
  40. 0x81, 0x02, /* Input (Variable), */
  41. 0x95, 0x05, /* Report Count (5), */
  42. 0x81, 0x01, /* Input (Constant), */
  43. 0x75, 0x10, /* Report Size (16), */
  44. 0x95, 0x01, /* Report Count (1), */
  45. 0x14, /* Logical Minimum (0), */
  46. 0xA4, /* Push, */
  47. 0x05, 0x01, /* Usage Page (Desktop), */
  48. 0x55, 0xFD, /* Unit Exponent (-3), */
  49. 0x65, 0x13, /* Unit (Inch), */
  50. 0x34, /* Physical Minimum (0), */
  51. 0x09, 0x30, /* Usage (X), */
  52. 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */
  53. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  54. 0x81, 0x02, /* Input (Variable), */
  55. 0x09, 0x31, /* Usage (Y), */
  56. 0x46, 0xB8, 0x0B, /* Physical Maximum (3000), */
  57. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  58. 0x81, 0x02, /* Input (Variable), */
  59. 0xB4, /* Pop, */
  60. 0x09, 0x30, /* Usage (Tip Pressure), */
  61. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  62. 0x81, 0x02, /* Input (Variable), */
  63. 0xC0, /* End Collection, */
  64. 0xC0 /* End Collection */
  65. };
  66. /* Fixed WP5540U report descriptor */
  67. static __u8 wp5540u_rdesc_fixed[] = {
  68. 0x05, 0x0D, /* Usage Page (Digitizer), */
  69. 0x09, 0x02, /* Usage (Pen), */
  70. 0xA1, 0x01, /* Collection (Application), */
  71. 0x85, 0x09, /* Report ID (9), */
  72. 0x09, 0x20, /* Usage (Stylus), */
  73. 0xA0, /* Collection (Physical), */
  74. 0x75, 0x01, /* Report Size (1), */
  75. 0x09, 0x42, /* Usage (Tip Switch), */
  76. 0x09, 0x44, /* Usage (Barrel Switch), */
  77. 0x09, 0x46, /* Usage (Tablet Pick), */
  78. 0x14, /* Logical Minimum (0), */
  79. 0x25, 0x01, /* Logical Maximum (1), */
  80. 0x95, 0x03, /* Report Count (3), */
  81. 0x81, 0x02, /* Input (Variable), */
  82. 0x95, 0x05, /* Report Count (5), */
  83. 0x81, 0x01, /* Input (Constant), */
  84. 0x75, 0x10, /* Report Size (16), */
  85. 0x95, 0x01, /* Report Count (1), */
  86. 0x14, /* Logical Minimum (0), */
  87. 0xA4, /* Push, */
  88. 0x05, 0x01, /* Usage Page (Desktop), */
  89. 0x55, 0xFD, /* Unit Exponent (-3), */
  90. 0x65, 0x13, /* Unit (Inch), */
  91. 0x34, /* Physical Minimum (0), */
  92. 0x09, 0x30, /* Usage (X), */
  93. 0x46, 0x7C, 0x15, /* Physical Maximum (5500), */
  94. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  95. 0x81, 0x02, /* Input (Variable), */
  96. 0x09, 0x31, /* Usage (Y), */
  97. 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */
  98. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  99. 0x81, 0x02, /* Input (Variable), */
  100. 0xB4, /* Pop, */
  101. 0x09, 0x30, /* Usage (Tip Pressure), */
  102. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  103. 0x81, 0x02, /* Input (Variable), */
  104. 0xC0, /* End Collection, */
  105. 0xC0, /* End Collection, */
  106. 0x05, 0x01, /* Usage Page (Desktop), */
  107. 0x09, 0x02, /* Usage (Mouse), */
  108. 0xA1, 0x01, /* Collection (Application), */
  109. 0x85, 0x08, /* Report ID (8), */
  110. 0x09, 0x01, /* Usage (Pointer), */
  111. 0xA0, /* Collection (Physical), */
  112. 0x75, 0x01, /* Report Size (1), */
  113. 0x05, 0x09, /* Usage Page (Button), */
  114. 0x19, 0x01, /* Usage Minimum (01h), */
  115. 0x29, 0x03, /* Usage Maximum (03h), */
  116. 0x14, /* Logical Minimum (0), */
  117. 0x25, 0x01, /* Logical Maximum (1), */
  118. 0x95, 0x03, /* Report Count (3), */
  119. 0x81, 0x02, /* Input (Variable), */
  120. 0x95, 0x05, /* Report Count (5), */
  121. 0x81, 0x01, /* Input (Constant), */
  122. 0x05, 0x01, /* Usage Page (Desktop), */
  123. 0x75, 0x08, /* Report Size (8), */
  124. 0x09, 0x30, /* Usage (X), */
  125. 0x09, 0x31, /* Usage (Y), */
  126. 0x15, 0x81, /* Logical Minimum (-127), */
  127. 0x25, 0x7F, /* Logical Maximum (127), */
  128. 0x95, 0x02, /* Report Count (2), */
  129. 0x81, 0x06, /* Input (Variable, Relative), */
  130. 0x09, 0x38, /* Usage (Wheel), */
  131. 0x15, 0xFF, /* Logical Minimum (-1), */
  132. 0x25, 0x01, /* Logical Maximum (1), */
  133. 0x95, 0x01, /* Report Count (1), */
  134. 0x81, 0x06, /* Input (Variable, Relative), */
  135. 0x81, 0x01, /* Input (Constant), */
  136. 0xC0, /* End Collection, */
  137. 0xC0 /* End Collection */
  138. };
  139. /* Fixed WP8060U report descriptor */
  140. static __u8 wp8060u_rdesc_fixed[] = {
  141. 0x05, 0x0D, /* Usage Page (Digitizer), */
  142. 0x09, 0x02, /* Usage (Pen), */
  143. 0xA1, 0x01, /* Collection (Application), */
  144. 0x85, 0x09, /* Report ID (9), */
  145. 0x09, 0x20, /* Usage (Stylus), */
  146. 0xA0, /* Collection (Physical), */
  147. 0x75, 0x01, /* Report Size (1), */
  148. 0x09, 0x42, /* Usage (Tip Switch), */
  149. 0x09, 0x44, /* Usage (Barrel Switch), */
  150. 0x09, 0x46, /* Usage (Tablet Pick), */
  151. 0x14, /* Logical Minimum (0), */
  152. 0x25, 0x01, /* Logical Maximum (1), */
  153. 0x95, 0x03, /* Report Count (3), */
  154. 0x81, 0x02, /* Input (Variable), */
  155. 0x95, 0x05, /* Report Count (5), */
  156. 0x81, 0x01, /* Input (Constant), */
  157. 0x75, 0x10, /* Report Size (16), */
  158. 0x95, 0x01, /* Report Count (1), */
  159. 0x14, /* Logical Minimum (0), */
  160. 0xA4, /* Push, */
  161. 0x05, 0x01, /* Usage Page (Desktop), */
  162. 0x55, 0xFD, /* Unit Exponent (-3), */
  163. 0x65, 0x13, /* Unit (Inch), */
  164. 0x34, /* Physical Minimum (0), */
  165. 0x09, 0x30, /* Usage (X), */
  166. 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
  167. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  168. 0x81, 0x02, /* Input (Variable), */
  169. 0x09, 0x31, /* Usage (Y), */
  170. 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
  171. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  172. 0x81, 0x02, /* Input (Variable), */
  173. 0xB4, /* Pop, */
  174. 0x09, 0x30, /* Usage (Tip Pressure), */
  175. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  176. 0x81, 0x02, /* Input (Variable), */
  177. 0xC0, /* End Collection, */
  178. 0xC0, /* End Collection, */
  179. 0x05, 0x01, /* Usage Page (Desktop), */
  180. 0x09, 0x02, /* Usage (Mouse), */
  181. 0xA1, 0x01, /* Collection (Application), */
  182. 0x85, 0x08, /* Report ID (8), */
  183. 0x09, 0x01, /* Usage (Pointer), */
  184. 0xA0, /* Collection (Physical), */
  185. 0x75, 0x01, /* Report Size (1), */
  186. 0x05, 0x09, /* Usage Page (Button), */
  187. 0x19, 0x01, /* Usage Minimum (01h), */
  188. 0x29, 0x03, /* Usage Maximum (03h), */
  189. 0x14, /* Logical Minimum (0), */
  190. 0x25, 0x01, /* Logical Maximum (1), */
  191. 0x95, 0x03, /* Report Count (3), */
  192. 0x81, 0x02, /* Input (Variable), */
  193. 0x95, 0x05, /* Report Count (5), */
  194. 0x81, 0x01, /* Input (Constant), */
  195. 0x05, 0x01, /* Usage Page (Desktop), */
  196. 0x75, 0x08, /* Report Size (8), */
  197. 0x09, 0x30, /* Usage (X), */
  198. 0x09, 0x31, /* Usage (Y), */
  199. 0x15, 0x81, /* Logical Minimum (-127), */
  200. 0x25, 0x7F, /* Logical Maximum (127), */
  201. 0x95, 0x02, /* Report Count (2), */
  202. 0x81, 0x06, /* Input (Variable, Relative), */
  203. 0x09, 0x38, /* Usage (Wheel), */
  204. 0x15, 0xFF, /* Logical Minimum (-1), */
  205. 0x25, 0x01, /* Logical Maximum (1), */
  206. 0x95, 0x01, /* Report Count (1), */
  207. 0x81, 0x06, /* Input (Variable, Relative), */
  208. 0x81, 0x01, /* Input (Constant), */
  209. 0xC0, /* End Collection, */
  210. 0xC0 /* End Collection */
  211. };
  212. /*
  213. * See WP1062 description, device and HID report descriptors at
  214. * http://sf.net/apps/mediawiki/digimend/?title=UC-Logic_Tablet_WP1062
  215. */
  216. /* Size of the original descriptor of WP1062 tablet */
  217. #define WP1062_RDESC_ORIG_SIZE 254
  218. /* Fixed WP1062 report descriptor */
  219. static __u8 wp1062_rdesc_fixed[] = {
  220. 0x05, 0x0D, /* Usage Page (Digitizer), */
  221. 0x09, 0x02, /* Usage (Pen), */
  222. 0xA1, 0x01, /* Collection (Application), */
  223. 0x85, 0x09, /* Report ID (9), */
  224. 0x09, 0x20, /* Usage (Stylus), */
  225. 0xA0, /* Collection (Physical), */
  226. 0x75, 0x01, /* Report Size (1), */
  227. 0x09, 0x42, /* Usage (Tip Switch), */
  228. 0x09, 0x44, /* Usage (Barrel Switch), */
  229. 0x09, 0x46, /* Usage (Tablet Pick), */
  230. 0x14, /* Logical Minimum (0), */
  231. 0x25, 0x01, /* Logical Maximum (1), */
  232. 0x95, 0x03, /* Report Count (3), */
  233. 0x81, 0x02, /* Input (Variable), */
  234. 0x95, 0x04, /* Report Count (4), */
  235. 0x81, 0x01, /* Input (Constant), */
  236. 0x09, 0x32, /* Usage (In Range), */
  237. 0x95, 0x01, /* Report Count (1), */
  238. 0x81, 0x02, /* Input (Variable), */
  239. 0x75, 0x10, /* Report Size (16), */
  240. 0x95, 0x01, /* Report Count (1), */
  241. 0x14, /* Logical Minimum (0), */
  242. 0xA4, /* Push, */
  243. 0x05, 0x01, /* Usage Page (Desktop), */
  244. 0x55, 0xFD, /* Unit Exponent (-3), */
  245. 0x65, 0x13, /* Unit (Inch), */
  246. 0x34, /* Physical Minimum (0), */
  247. 0x09, 0x30, /* Usage (X), */
  248. 0x46, 0x10, 0x27, /* Physical Maximum (10000), */
  249. 0x26, 0x20, 0x4E, /* Logical Maximum (20000), */
  250. 0x81, 0x02, /* Input (Variable), */
  251. 0x09, 0x31, /* Usage (Y), */
  252. 0x46, 0xB7, 0x19, /* Physical Maximum (6583), */
  253. 0x26, 0x6E, 0x33, /* Logical Maximum (13166), */
  254. 0x81, 0x02, /* Input (Variable), */
  255. 0xB4, /* Pop, */
  256. 0x09, 0x30, /* Usage (Tip Pressure), */
  257. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  258. 0x81, 0x02, /* Input (Variable), */
  259. 0xC0, /* End Collection, */
  260. 0xC0 /* End Collection */
  261. };
  262. /*
  263. * See PF1209 description, device and HID report descriptors at
  264. * http://sf.net/apps/mediawiki/digimend/?title=UC-Logic_Tablet_PF1209
  265. */
  266. /* Size of the original descriptor of PF1209 tablet */
  267. #define PF1209_RDESC_ORIG_SIZE 234
  268. /* Fixed PF1209 report descriptor */
  269. static __u8 pf1209_rdesc_fixed[] = {
  270. 0x05, 0x0D, /* Usage Page (Digitizer), */
  271. 0x09, 0x02, /* Usage (Pen), */
  272. 0xA1, 0x01, /* Collection (Application), */
  273. 0x85, 0x09, /* Report ID (9), */
  274. 0x09, 0x20, /* Usage (Stylus), */
  275. 0xA0, /* Collection (Physical), */
  276. 0x75, 0x01, /* Report Size (1), */
  277. 0x09, 0x42, /* Usage (Tip Switch), */
  278. 0x09, 0x44, /* Usage (Barrel Switch), */
  279. 0x09, 0x46, /* Usage (Tablet Pick), */
  280. 0x14, /* Logical Minimum (0), */
  281. 0x25, 0x01, /* Logical Maximum (1), */
  282. 0x95, 0x03, /* Report Count (3), */
  283. 0x81, 0x02, /* Input (Variable), */
  284. 0x95, 0x05, /* Report Count (5), */
  285. 0x81, 0x01, /* Input (Constant), */
  286. 0x75, 0x10, /* Report Size (16), */
  287. 0x95, 0x01, /* Report Count (1), */
  288. 0x14, /* Logical Minimum (0), */
  289. 0xA4, /* Push, */
  290. 0x05, 0x01, /* Usage Page (Desktop), */
  291. 0x55, 0xFD, /* Unit Exponent (-3), */
  292. 0x65, 0x13, /* Unit (Inch), */
  293. 0x34, /* Physical Minimum (0), */
  294. 0x09, 0x30, /* Usage (X), */
  295. 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */
  296. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  297. 0x81, 0x02, /* Input (Variable), */
  298. 0x09, 0x31, /* Usage (Y), */
  299. 0x46, 0x28, 0x23, /* Physical Maximum (9000), */
  300. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  301. 0x81, 0x02, /* Input (Variable), */
  302. 0xB4, /* Pop, */
  303. 0x09, 0x30, /* Usage (Tip Pressure), */
  304. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  305. 0x81, 0x02, /* Input (Variable), */
  306. 0xC0, /* End Collection, */
  307. 0xC0, /* End Collection, */
  308. 0x05, 0x01, /* Usage Page (Desktop), */
  309. 0x09, 0x02, /* Usage (Mouse), */
  310. 0xA1, 0x01, /* Collection (Application), */
  311. 0x85, 0x08, /* Report ID (8), */
  312. 0x09, 0x01, /* Usage (Pointer), */
  313. 0xA0, /* Collection (Physical), */
  314. 0x75, 0x01, /* Report Size (1), */
  315. 0x05, 0x09, /* Usage Page (Button), */
  316. 0x19, 0x01, /* Usage Minimum (01h), */
  317. 0x29, 0x03, /* Usage Maximum (03h), */
  318. 0x14, /* Logical Minimum (0), */
  319. 0x25, 0x01, /* Logical Maximum (1), */
  320. 0x95, 0x03, /* Report Count (3), */
  321. 0x81, 0x02, /* Input (Variable), */
  322. 0x95, 0x05, /* Report Count (5), */
  323. 0x81, 0x01, /* Input (Constant), */
  324. 0x05, 0x01, /* Usage Page (Desktop), */
  325. 0x75, 0x08, /* Report Size (8), */
  326. 0x09, 0x30, /* Usage (X), */
  327. 0x09, 0x31, /* Usage (Y), */
  328. 0x15, 0x81, /* Logical Minimum (-127), */
  329. 0x25, 0x7F, /* Logical Maximum (127), */
  330. 0x95, 0x02, /* Report Count (2), */
  331. 0x81, 0x06, /* Input (Variable, Relative), */
  332. 0x09, 0x38, /* Usage (Wheel), */
  333. 0x15, 0xFF, /* Logical Minimum (-1), */
  334. 0x25, 0x01, /* Logical Maximum (1), */
  335. 0x95, 0x01, /* Report Count (1), */
  336. 0x81, 0x06, /* Input (Variable, Relative), */
  337. 0x81, 0x01, /* Input (Constant), */
  338. 0xC0, /* End Collection, */
  339. 0xC0 /* End Collection */
  340. };
  341. /*
  342. * See TWHL850 description, device and HID report descriptors at
  343. * http://sf.net/apps/mediawiki/digimend/?title=UC-Logic_Wireless_Tablet_TWHL850
  344. */
  345. /* Size of the original descriptors of TWHL850 tablet */
  346. #define TWHL850_RDESC_ORIG_SIZE0 182
  347. #define TWHL850_RDESC_ORIG_SIZE1 161
  348. #define TWHL850_RDESC_ORIG_SIZE2 92
  349. /* Fixed PID 0522 tablet report descriptor, interface 0 (stylus) */
  350. static __u8 twhl850_rdesc_fixed0[] = {
  351. 0x05, 0x0D, /* Usage Page (Digitizer), */
  352. 0x09, 0x02, /* Usage (Pen), */
  353. 0xA1, 0x01, /* Collection (Application), */
  354. 0x85, 0x09, /* Report ID (9), */
  355. 0x09, 0x20, /* Usage (Stylus), */
  356. 0xA0, /* Collection (Physical), */
  357. 0x14, /* Logical Minimum (0), */
  358. 0x25, 0x01, /* Logical Maximum (1), */
  359. 0x75, 0x01, /* Report Size (1), */
  360. 0x95, 0x03, /* Report Count (3), */
  361. 0x09, 0x42, /* Usage (Tip Switch), */
  362. 0x09, 0x44, /* Usage (Barrel Switch), */
  363. 0x09, 0x46, /* Usage (Tablet Pick), */
  364. 0x81, 0x02, /* Input (Variable), */
  365. 0x81, 0x03, /* Input (Constant, Variable), */
  366. 0x95, 0x01, /* Report Count (1), */
  367. 0x09, 0x32, /* Usage (In Range), */
  368. 0x81, 0x02, /* Input (Variable), */
  369. 0x81, 0x03, /* Input (Constant, Variable), */
  370. 0x75, 0x10, /* Report Size (16), */
  371. 0xA4, /* Push, */
  372. 0x05, 0x01, /* Usage Page (Desktop), */
  373. 0x65, 0x13, /* Unit (Inch), */
  374. 0x55, 0xFD, /* Unit Exponent (-3), */
  375. 0x34, /* Physical Minimum (0), */
  376. 0x09, 0x30, /* Usage (X), */
  377. 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
  378. 0x26, 0x00, 0x7D, /* Logical Maximum (32000), */
  379. 0x81, 0x02, /* Input (Variable), */
  380. 0x09, 0x31, /* Usage (Y), */
  381. 0x46, 0x88, 0x13, /* Physical Maximum (5000), */
  382. 0x26, 0x20, 0x4E, /* Logical Maximum (20000), */
  383. 0x81, 0x02, /* Input (Variable), */
  384. 0xB4, /* Pop, */
  385. 0x09, 0x30, /* Usage (Tip Pressure), */
  386. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  387. 0x81, 0x02, /* Input (Variable), */
  388. 0xC0, /* End Collection, */
  389. 0xC0 /* End Collection */
  390. };
  391. /* Fixed PID 0522 tablet report descriptor, interface 1 (mouse) */
  392. static __u8 twhl850_rdesc_fixed1[] = {
  393. 0x05, 0x01, /* Usage Page (Desktop), */
  394. 0x09, 0x02, /* Usage (Mouse), */
  395. 0xA1, 0x01, /* Collection (Application), */
  396. 0x85, 0x01, /* Report ID (1), */
  397. 0x09, 0x01, /* Usage (Pointer), */
  398. 0xA0, /* Collection (Physical), */
  399. 0x05, 0x09, /* Usage Page (Button), */
  400. 0x75, 0x01, /* Report Size (1), */
  401. 0x95, 0x03, /* Report Count (3), */
  402. 0x19, 0x01, /* Usage Minimum (01h), */
  403. 0x29, 0x03, /* Usage Maximum (03h), */
  404. 0x14, /* Logical Minimum (0), */
  405. 0x25, 0x01, /* Logical Maximum (1), */
  406. 0x81, 0x02, /* Input (Variable), */
  407. 0x95, 0x05, /* Report Count (5), */
  408. 0x81, 0x03, /* Input (Constant, Variable), */
  409. 0x05, 0x01, /* Usage Page (Desktop), */
  410. 0x09, 0x30, /* Usage (X), */
  411. 0x09, 0x31, /* Usage (Y), */
  412. 0x16, 0x00, 0x80, /* Logical Minimum (-32768), */
  413. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  414. 0x75, 0x10, /* Report Size (16), */
  415. 0x95, 0x02, /* Report Count (2), */
  416. 0x81, 0x06, /* Input (Variable, Relative), */
  417. 0x09, 0x38, /* Usage (Wheel), */
  418. 0x15, 0xFF, /* Logical Minimum (-1), */
  419. 0x25, 0x01, /* Logical Maximum (1), */
  420. 0x95, 0x01, /* Report Count (1), */
  421. 0x75, 0x08, /* Report Size (8), */
  422. 0x81, 0x06, /* Input (Variable, Relative), */
  423. 0x81, 0x03, /* Input (Constant, Variable), */
  424. 0xC0, /* End Collection, */
  425. 0xC0 /* End Collection */
  426. };
  427. /* Fixed PID 0522 tablet report descriptor, interface 2 (frame buttons) */
  428. static __u8 twhl850_rdesc_fixed2[] = {
  429. 0x05, 0x01, /* Usage Page (Desktop), */
  430. 0x09, 0x06, /* Usage (Keyboard), */
  431. 0xA1, 0x01, /* Collection (Application), */
  432. 0x85, 0x03, /* Report ID (3), */
  433. 0x05, 0x07, /* Usage Page (Keyboard), */
  434. 0x14, /* Logical Minimum (0), */
  435. 0x19, 0xE0, /* Usage Minimum (KB Leftcontrol), */
  436. 0x29, 0xE7, /* Usage Maximum (KB Right GUI), */
  437. 0x25, 0x01, /* Logical Maximum (1), */
  438. 0x75, 0x01, /* Report Size (1), */
  439. 0x95, 0x08, /* Report Count (8), */
  440. 0x81, 0x02, /* Input (Variable), */
  441. 0x18, /* Usage Minimum (None), */
  442. 0x29, 0xFF, /* Usage Maximum (FFh), */
  443. 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
  444. 0x75, 0x08, /* Report Size (8), */
  445. 0x95, 0x06, /* Report Count (6), */
  446. 0x80, /* Input, */
  447. 0xC0 /* End Collection */
  448. };
  449. /*
  450. * See TWHA60 description, device and HID report descriptors at
  451. * http://sf.net/apps/mediawiki/digimend/?title=UC-Logic_Tablet_TWHA60
  452. */
  453. /* Size of the original descriptors of TWHA60 tablet */
  454. #define TWHA60_RDESC_ORIG_SIZE0 254
  455. #define TWHA60_RDESC_ORIG_SIZE1 139
  456. /* Fixed TWHA60 report descriptor, interface 0 (stylus) */
  457. static __u8 twha60_rdesc_fixed0[] = {
  458. 0x05, 0x0D, /* Usage Page (Digitizer), */
  459. 0x09, 0x02, /* Usage (Pen), */
  460. 0xA1, 0x01, /* Collection (Application), */
  461. 0x85, 0x09, /* Report ID (9), */
  462. 0x09, 0x20, /* Usage (Stylus), */
  463. 0xA0, /* Collection (Physical), */
  464. 0x75, 0x01, /* Report Size (1), */
  465. 0x09, 0x42, /* Usage (Tip Switch), */
  466. 0x09, 0x44, /* Usage (Barrel Switch), */
  467. 0x09, 0x46, /* Usage (Tablet Pick), */
  468. 0x14, /* Logical Minimum (0), */
  469. 0x25, 0x01, /* Logical Maximum (1), */
  470. 0x95, 0x03, /* Report Count (3), */
  471. 0x81, 0x02, /* Input (Variable), */
  472. 0x95, 0x04, /* Report Count (4), */
  473. 0x81, 0x01, /* Input (Constant), */
  474. 0x09, 0x32, /* Usage (In Range), */
  475. 0x95, 0x01, /* Report Count (1), */
  476. 0x81, 0x02, /* Input (Variable), */
  477. 0x75, 0x10, /* Report Size (16), */
  478. 0x95, 0x01, /* Report Count (1), */
  479. 0x14, /* Logical Minimum (0), */
  480. 0xA4, /* Push, */
  481. 0x05, 0x01, /* Usage Page (Desktop), */
  482. 0x55, 0xFD, /* Unit Exponent (-3), */
  483. 0x65, 0x13, /* Unit (Inch), */
  484. 0x34, /* Physical Minimum (0), */
  485. 0x09, 0x30, /* Usage (X), */
  486. 0x46, 0x10, 0x27, /* Physical Maximum (10000), */
  487. 0x27, 0x3F, 0x9C,
  488. 0x00, 0x00, /* Logical Maximum (39999), */
  489. 0x81, 0x02, /* Input (Variable), */
  490. 0x09, 0x31, /* Usage (Y), */
  491. 0x46, 0x6A, 0x18, /* Physical Maximum (6250), */
  492. 0x26, 0xA7, 0x61, /* Logical Maximum (24999), */
  493. 0x81, 0x02, /* Input (Variable), */
  494. 0xB4, /* Pop, */
  495. 0x09, 0x30, /* Usage (Tip Pressure), */
  496. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  497. 0x81, 0x02, /* Input (Variable), */
  498. 0xC0, /* End Collection, */
  499. 0xC0 /* End Collection */
  500. };
  501. /* Fixed TWHA60 report descriptor, interface 1 (frame buttons) */
  502. static __u8 twha60_rdesc_fixed1[] = {
  503. 0x05, 0x01, /* Usage Page (Desktop), */
  504. 0x09, 0x06, /* Usage (Keyboard), */
  505. 0xA1, 0x01, /* Collection (Application), */
  506. 0x85, 0x05, /* Report ID (5), */
  507. 0x05, 0x07, /* Usage Page (Keyboard), */
  508. 0x14, /* Logical Minimum (0), */
  509. 0x25, 0x01, /* Logical Maximum (1), */
  510. 0x75, 0x01, /* Report Size (1), */
  511. 0x95, 0x08, /* Report Count (8), */
  512. 0x81, 0x01, /* Input (Constant), */
  513. 0x95, 0x0C, /* Report Count (12), */
  514. 0x19, 0x3A, /* Usage Minimum (KB F1), */
  515. 0x29, 0x45, /* Usage Maximum (KB F12), */
  516. 0x81, 0x02, /* Input (Variable), */
  517. 0x95, 0x0C, /* Report Count (12), */
  518. 0x19, 0x68, /* Usage Minimum (KB F13), */
  519. 0x29, 0x73, /* Usage Maximum (KB F24), */
  520. 0x81, 0x02, /* Input (Variable), */
  521. 0x95, 0x08, /* Report Count (8), */
  522. 0x81, 0x01, /* Input (Constant), */
  523. 0xC0 /* End Collection */
  524. };
  525. static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  526. unsigned int *rsize)
  527. {
  528. struct usb_interface *iface = to_usb_interface(hdev->dev.parent);
  529. __u8 iface_num = iface->cur_altsetting->desc.bInterfaceNumber;
  530. switch (hdev->product) {
  531. case USB_DEVICE_ID_UCLOGIC_TABLET_PF1209:
  532. if (*rsize == PF1209_RDESC_ORIG_SIZE) {
  533. rdesc = pf1209_rdesc_fixed;
  534. *rsize = sizeof(pf1209_rdesc_fixed);
  535. }
  536. break;
  537. case USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U:
  538. if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
  539. rdesc = wp4030u_rdesc_fixed;
  540. *rsize = sizeof(wp4030u_rdesc_fixed);
  541. }
  542. break;
  543. case USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U:
  544. if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
  545. rdesc = wp5540u_rdesc_fixed;
  546. *rsize = sizeof(wp5540u_rdesc_fixed);
  547. }
  548. break;
  549. case USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U:
  550. if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
  551. rdesc = wp8060u_rdesc_fixed;
  552. *rsize = sizeof(wp8060u_rdesc_fixed);
  553. }
  554. break;
  555. case USB_DEVICE_ID_UCLOGIC_TABLET_WP1062:
  556. if (*rsize == WP1062_RDESC_ORIG_SIZE) {
  557. rdesc = wp1062_rdesc_fixed;
  558. *rsize = sizeof(wp1062_rdesc_fixed);
  559. }
  560. break;
  561. case USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850:
  562. switch (iface_num) {
  563. case 0:
  564. if (*rsize == TWHL850_RDESC_ORIG_SIZE0) {
  565. rdesc = twhl850_rdesc_fixed0;
  566. *rsize = sizeof(twhl850_rdesc_fixed0);
  567. }
  568. break;
  569. case 1:
  570. if (*rsize == TWHL850_RDESC_ORIG_SIZE1) {
  571. rdesc = twhl850_rdesc_fixed1;
  572. *rsize = sizeof(twhl850_rdesc_fixed1);
  573. }
  574. break;
  575. case 2:
  576. if (*rsize == TWHL850_RDESC_ORIG_SIZE2) {
  577. rdesc = twhl850_rdesc_fixed2;
  578. *rsize = sizeof(twhl850_rdesc_fixed2);
  579. }
  580. break;
  581. }
  582. break;
  583. case USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60:
  584. switch (iface_num) {
  585. case 0:
  586. if (*rsize == TWHA60_RDESC_ORIG_SIZE0) {
  587. rdesc = twha60_rdesc_fixed0;
  588. *rsize = sizeof(twha60_rdesc_fixed0);
  589. }
  590. break;
  591. case 1:
  592. if (*rsize == TWHA60_RDESC_ORIG_SIZE1) {
  593. rdesc = twha60_rdesc_fixed1;
  594. *rsize = sizeof(twha60_rdesc_fixed1);
  595. }
  596. break;
  597. }
  598. break;
  599. }
  600. return rdesc;
  601. }
  602. static const struct hid_device_id uclogic_devices[] = {
  603. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  604. USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) },
  605. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  606. USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) },
  607. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  608. USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) },
  609. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  610. USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) },
  611. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  612. USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) },
  613. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  614. USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850) },
  615. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  616. USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60) },
  617. { }
  618. };
  619. MODULE_DEVICE_TABLE(hid, uclogic_devices);
  620. static struct hid_driver uclogic_driver = {
  621. .name = "uclogic",
  622. .id_table = uclogic_devices,
  623. .report_fixup = uclogic_report_fixup,
  624. };
  625. module_hid_driver(uclogic_driver);
  626. MODULE_LICENSE("GPL");