hid-waltop.c 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. /*
  2. * HID driver for Waltop 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 "hid-ids.h"
  16. /*
  17. * There exists an official driver on the manufacturer's website, which
  18. * wasn't submitted to the kernel, for some reason. The official driver
  19. * doesn't seem to support extra features of some tablets, like wheels.
  20. *
  21. * It shows that the feature report ID 2 could be used to control any waltop
  22. * tablet input mode, switching it between "default", "tablet" and "ink".
  23. *
  24. * This driver only uses "default" mode for all the supported tablets. This
  25. * mode tries to be HID-compatible (not very successfully), but cripples the
  26. * resolution of some tablets.
  27. *
  28. * The "tablet" mode uses some proprietary, yet decipherable protocol, which
  29. * represents the correct resolution, but is possibly HID-incompatible (i.e.
  30. * indescribable by a report descriptor).
  31. *
  32. * The purpose of the "ink" mode is unknown.
  33. *
  34. * The feature reports needed for switching to each mode are these:
  35. *
  36. * 02 16 00 default
  37. * 02 16 01 tablet
  38. * 02 16 02 ink
  39. */
  40. /*
  41. * See Slim Tablet 5.8 inch description, device and HID report descriptors at
  42. * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Slim_Tablet_5.8%22
  43. */
  44. /* Size of the original report descriptor of Slim Tablet 5.8 inch */
  45. #define SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE 222
  46. /* Fixed Slim Tablet 5.8 inch descriptor */
  47. static __u8 slim_tablet_5_8_inch_rdesc_fixed[] = {
  48. 0x05, 0x0D, /* Usage Page (Digitizer), */
  49. 0x09, 0x02, /* Usage (Pen), */
  50. 0xA1, 0x01, /* Collection (Application), */
  51. 0x85, 0x10, /* Report ID (16), */
  52. 0x09, 0x20, /* Usage (Stylus), */
  53. 0xA0, /* Collection (Physical), */
  54. 0x09, 0x42, /* Usage (Tip Switch), */
  55. 0x09, 0x44, /* Usage (Barrel Switch), */
  56. 0x09, 0x46, /* Usage (Tablet Pick), */
  57. 0x15, 0x01, /* Logical Minimum (1), */
  58. 0x25, 0x03, /* Logical Maximum (3), */
  59. 0x75, 0x04, /* Report Size (4), */
  60. 0x95, 0x01, /* Report Count (1), */
  61. 0x80, /* Input, */
  62. 0x09, 0x32, /* Usage (In Range), */
  63. 0x14, /* Logical Minimum (0), */
  64. 0x25, 0x01, /* Logical Maximum (1), */
  65. 0x75, 0x01, /* Report Size (1), */
  66. 0x95, 0x01, /* Report Count (1), */
  67. 0x81, 0x02, /* Input (Variable), */
  68. 0x95, 0x03, /* Report Count (3), */
  69. 0x81, 0x03, /* Input (Constant, Variable), */
  70. 0x75, 0x10, /* Report Size (16), */
  71. 0x95, 0x01, /* Report Count (1), */
  72. 0x14, /* Logical Minimum (0), */
  73. 0xA4, /* Push, */
  74. 0x05, 0x01, /* Usage Page (Desktop), */
  75. 0x65, 0x13, /* Unit (Inch), */
  76. 0x55, 0xFD, /* Unit Exponent (-3), */
  77. 0x34, /* Physical Minimum (0), */
  78. 0x09, 0x30, /* Usage (X), */
  79. 0x46, 0x88, 0x13, /* Physical Maximum (5000), */
  80. 0x26, 0x10, 0x27, /* Logical Maximum (10000), */
  81. 0x81, 0x02, /* Input (Variable), */
  82. 0x09, 0x31, /* Usage (Y), */
  83. 0x46, 0xB8, 0x0B, /* Physical Maximum (3000), */
  84. 0x26, 0x70, 0x17, /* Logical Maximum (6000), */
  85. 0x81, 0x02, /* Input (Variable), */
  86. 0xB4, /* Pop, */
  87. 0x09, 0x30, /* Usage (Tip Pressure), */
  88. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  89. 0x81, 0x02, /* Input (Variable), */
  90. 0xC0, /* End Collection, */
  91. 0xC0 /* End Collection */
  92. };
  93. /*
  94. * See Slim Tablet 12.1 inch description, device and HID report descriptors at
  95. * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Slim_Tablet_12.1%22
  96. */
  97. /* Size of the original report descriptor of Slim Tablet 12.1 inch */
  98. #define SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE 269
  99. /* Fixed Slim Tablet 12.1 inch descriptor */
  100. static __u8 slim_tablet_12_1_inch_rdesc_fixed[] = {
  101. 0x05, 0x0D, /* Usage Page (Digitizer), */
  102. 0x09, 0x02, /* Usage (Pen), */
  103. 0xA1, 0x01, /* Collection (Application), */
  104. 0x85, 0x10, /* Report ID (16), */
  105. 0x09, 0x20, /* Usage (Stylus), */
  106. 0xA0, /* Collection (Physical), */
  107. 0x09, 0x42, /* Usage (Tip Switch), */
  108. 0x09, 0x44, /* Usage (Barrel Switch), */
  109. 0x09, 0x46, /* Usage (Tablet Pick), */
  110. 0x15, 0x01, /* Logical Minimum (1), */
  111. 0x25, 0x03, /* Logical Maximum (3), */
  112. 0x75, 0x04, /* Report Size (4), */
  113. 0x95, 0x01, /* Report Count (1), */
  114. 0x80, /* Input, */
  115. 0x09, 0x32, /* Usage (In Range), */
  116. 0x14, /* Logical Minimum (0), */
  117. 0x25, 0x01, /* Logical Maximum (1), */
  118. 0x75, 0x01, /* Report Size (1), */
  119. 0x95, 0x01, /* Report Count (1), */
  120. 0x81, 0x02, /* Input (Variable), */
  121. 0x95, 0x03, /* Report Count (3), */
  122. 0x81, 0x03, /* Input (Constant, Variable), */
  123. 0x75, 0x10, /* Report Size (16), */
  124. 0x95, 0x01, /* Report Count (1), */
  125. 0x14, /* Logical Minimum (0), */
  126. 0xA4, /* Push, */
  127. 0x05, 0x01, /* Usage Page (Desktop), */
  128. 0x65, 0x13, /* Unit (Inch), */
  129. 0x55, 0xFD, /* Unit Exponent (-3), */
  130. 0x34, /* Physical Minimum (0), */
  131. 0x09, 0x30, /* Usage (X), */
  132. 0x46, 0x10, 0x27, /* Physical Maximum (10000), */
  133. 0x26, 0x20, 0x4E, /* Logical Maximum (20000), */
  134. 0x81, 0x02, /* Input (Variable), */
  135. 0x09, 0x31, /* Usage (Y), */
  136. 0x46, 0x6A, 0x18, /* Physical Maximum (6250), */
  137. 0x26, 0xD4, 0x30, /* Logical Maximum (12500), */
  138. 0x81, 0x02, /* Input (Variable), */
  139. 0xB4, /* Pop, */
  140. 0x09, 0x30, /* Usage (Tip Pressure), */
  141. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  142. 0x81, 0x02, /* Input (Variable), */
  143. 0xC0, /* End Collection, */
  144. 0xC0 /* End Collection */
  145. };
  146. /*
  147. * See Q Pad description, device and HID report descriptors at
  148. * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Q_Pad
  149. */
  150. /* Size of the original report descriptor of Q Pad */
  151. #define Q_PAD_RDESC_ORIG_SIZE 241
  152. /* Fixed Q Pad descriptor */
  153. static __u8 q_pad_rdesc_fixed[] = {
  154. 0x05, 0x0D, /* Usage Page (Digitizer), */
  155. 0x09, 0x02, /* Usage (Pen), */
  156. 0xA1, 0x01, /* Collection (Application), */
  157. 0x85, 0x10, /* Report ID (16), */
  158. 0x09, 0x20, /* Usage (Stylus), */
  159. 0xA0, /* Collection (Physical), */
  160. 0x09, 0x42, /* Usage (Tip Switch), */
  161. 0x09, 0x44, /* Usage (Barrel Switch), */
  162. 0x09, 0x46, /* Usage (Tablet Pick), */
  163. 0x15, 0x01, /* Logical Minimum (1), */
  164. 0x25, 0x03, /* Logical Maximum (3), */
  165. 0x75, 0x04, /* Report Size (4), */
  166. 0x95, 0x01, /* Report Count (1), */
  167. 0x80, /* Input, */
  168. 0x09, 0x32, /* Usage (In Range), */
  169. 0x14, /* Logical Minimum (0), */
  170. 0x25, 0x01, /* Logical Maximum (1), */
  171. 0x75, 0x01, /* Report Size (1), */
  172. 0x95, 0x01, /* Report Count (1), */
  173. 0x81, 0x02, /* Input (Variable), */
  174. 0x95, 0x03, /* Report Count (3), */
  175. 0x81, 0x03, /* Input (Constant, Variable), */
  176. 0x75, 0x10, /* Report Size (16), */
  177. 0x95, 0x01, /* Report Count (1), */
  178. 0x14, /* Logical Minimum (0), */
  179. 0xA4, /* Push, */
  180. 0x05, 0x01, /* Usage Page (Desktop), */
  181. 0x65, 0x13, /* Unit (Inch), */
  182. 0x55, 0xFD, /* Unit Exponent (-3), */
  183. 0x34, /* Physical Minimum (0), */
  184. 0x09, 0x30, /* Usage (X), */
  185. 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
  186. 0x26, 0x00, 0x30, /* Logical Maximum (12288), */
  187. 0x81, 0x02, /* Input (Variable), */
  188. 0x09, 0x31, /* Usage (Y), */
  189. 0x46, 0x94, 0x11, /* Physical Maximum (4500), */
  190. 0x26, 0x00, 0x24, /* Logical Maximum (9216), */
  191. 0x81, 0x02, /* Input (Variable), */
  192. 0xB4, /* Pop, */
  193. 0x09, 0x30, /* Usage (Tip Pressure), */
  194. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  195. 0x81, 0x02, /* Input (Variable), */
  196. 0xC0, /* End Collection, */
  197. 0xC0 /* End Collection */
  198. };
  199. /*
  200. * See description, device and HID report descriptors of tablet with PID 0038 at
  201. * http://sf.net/apps/mediawiki/digimend/?title=Waltop_PID_0038
  202. */
  203. /* Size of the original report descriptor of tablet with PID 0038 */
  204. #define PID_0038_RDESC_ORIG_SIZE 241
  205. /*
  206. * Fixed report descriptor for tablet with PID 0038.
  207. */
  208. static __u8 pid_0038_rdesc_fixed[] = {
  209. 0x05, 0x0D, /* Usage Page (Digitizer), */
  210. 0x09, 0x02, /* Usage (Pen), */
  211. 0xA1, 0x01, /* Collection (Application), */
  212. 0x85, 0x10, /* Report ID (16), */
  213. 0x09, 0x20, /* Usage (Stylus), */
  214. 0xA0, /* Collection (Physical), */
  215. 0x09, 0x42, /* Usage (Tip Switch), */
  216. 0x09, 0x44, /* Usage (Barrel Switch), */
  217. 0x09, 0x46, /* Usage (Tablet Pick), */
  218. 0x15, 0x01, /* Logical Minimum (1), */
  219. 0x25, 0x03, /* Logical Maximum (3), */
  220. 0x75, 0x04, /* Report Size (4), */
  221. 0x95, 0x01, /* Report Count (1), */
  222. 0x80, /* Input, */
  223. 0x09, 0x32, /* Usage (In Range), */
  224. 0x14, /* Logical Minimum (0), */
  225. 0x25, 0x01, /* Logical Maximum (1), */
  226. 0x75, 0x01, /* Report Size (1), */
  227. 0x95, 0x01, /* Report Count (1), */
  228. 0x81, 0x02, /* Input (Variable), */
  229. 0x95, 0x03, /* Report Count (3), */
  230. 0x81, 0x03, /* Input (Constant, Variable), */
  231. 0x75, 0x10, /* Report Size (16), */
  232. 0x95, 0x01, /* Report Count (1), */
  233. 0x14, /* Logical Minimum (0), */
  234. 0xA4, /* Push, */
  235. 0x05, 0x01, /* Usage Page (Desktop), */
  236. 0x65, 0x13, /* Unit (Inch), */
  237. 0x55, 0xFD, /* Unit Exponent (-3), */
  238. 0x34, /* Physical Minimum (0), */
  239. 0x09, 0x30, /* Usage (X), */
  240. 0x46, 0x2E, 0x22, /* Physical Maximum (8750), */
  241. 0x26, 0x00, 0x46, /* Logical Maximum (17920), */
  242. 0x81, 0x02, /* Input (Variable), */
  243. 0x09, 0x31, /* Usage (Y), */
  244. 0x46, 0x82, 0x14, /* Physical Maximum (5250), */
  245. 0x26, 0x00, 0x2A, /* Logical Maximum (10752), */
  246. 0x81, 0x02, /* Input (Variable), */
  247. 0xB4, /* Pop, */
  248. 0x09, 0x30, /* Usage (Tip Pressure), */
  249. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  250. 0x81, 0x02, /* Input (Variable), */
  251. 0xC0, /* End Collection, */
  252. 0xC0 /* End Collection */
  253. };
  254. /*
  255. * See Media Tablet 10.6 inch description, device and HID report descriptors at
  256. * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Media_Tablet_10.6%22
  257. */
  258. /* Size of the original report descriptor of Media Tablet 10.6 inch */
  259. #define MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE 300
  260. /* Fixed Media Tablet 10.6 inch descriptor */
  261. static __u8 media_tablet_10_6_inch_rdesc_fixed[] = {
  262. 0x05, 0x0D, /* Usage Page (Digitizer), */
  263. 0x09, 0x02, /* Usage (Pen), */
  264. 0xA1, 0x01, /* Collection (Application), */
  265. 0x85, 0x10, /* Report ID (16), */
  266. 0x09, 0x20, /* Usage (Stylus), */
  267. 0xA0, /* Collection (Physical), */
  268. 0x09, 0x42, /* Usage (Tip Switch), */
  269. 0x09, 0x44, /* Usage (Barrel Switch), */
  270. 0x09, 0x46, /* Usage (Tablet Pick), */
  271. 0x15, 0x01, /* Logical Minimum (1), */
  272. 0x25, 0x03, /* Logical Maximum (3), */
  273. 0x75, 0x04, /* Report Size (4), */
  274. 0x95, 0x01, /* Report Count (1), */
  275. 0x80, /* Input, */
  276. 0x75, 0x01, /* Report Size (1), */
  277. 0x09, 0x32, /* Usage (In Range), */
  278. 0x14, /* Logical Minimum (0), */
  279. 0x25, 0x01, /* Logical Maximum (1), */
  280. 0x95, 0x01, /* Report Count (1), */
  281. 0x81, 0x02, /* Input (Variable), */
  282. 0x95, 0x03, /* Report Count (3), */
  283. 0x81, 0x03, /* Input (Constant, Variable), */
  284. 0x75, 0x10, /* Report Size (16), */
  285. 0x95, 0x01, /* Report Count (1), */
  286. 0x14, /* Logical Minimum (0), */
  287. 0xA4, /* Push, */
  288. 0x05, 0x01, /* Usage Page (Desktop), */
  289. 0x65, 0x13, /* Unit (Inch), */
  290. 0x55, 0xFD, /* Unit Exponent (-3), */
  291. 0x34, /* Physical Minimum (0), */
  292. 0x09, 0x30, /* Usage (X), */
  293. 0x46, 0x28, 0x23, /* Physical Maximum (9000), */
  294. 0x26, 0x50, 0x46, /* Logical Maximum (18000), */
  295. 0x81, 0x02, /* Input (Variable), */
  296. 0x09, 0x31, /* Usage (Y), */
  297. 0x46, 0x7C, 0x15, /* Physical Maximum (5500), */
  298. 0x26, 0xF8, 0x2A, /* Logical Maximum (11000), */
  299. 0x81, 0x02, /* Input (Variable), */
  300. 0xB4, /* Pop, */
  301. 0x09, 0x30, /* Usage (Tip Pressure), */
  302. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  303. 0x81, 0x02, /* Input (Variable), */
  304. 0xC0, /* End Collection, */
  305. 0xC0, /* End Collection, */
  306. 0x05, 0x01, /* Usage Page (Desktop), */
  307. 0x09, 0x02, /* Usage (Mouse), */
  308. 0xA1, 0x01, /* Collection (Application), */
  309. 0x85, 0x01, /* Report ID (1), */
  310. 0x09, 0x01, /* Usage (Pointer), */
  311. 0xA0, /* Collection (Physical), */
  312. 0x75, 0x08, /* Report Size (8), */
  313. 0x95, 0x03, /* Report Count (3), */
  314. 0x81, 0x03, /* Input (Constant, Variable), */
  315. 0x95, 0x02, /* Report Count (2), */
  316. 0x15, 0xFF, /* Logical Minimum (-1), */
  317. 0x25, 0x01, /* Logical Maximum (1), */
  318. 0x09, 0x38, /* Usage (Wheel), */
  319. 0x0B, 0x38, 0x02, /* Usage (Consumer AC Pan), */
  320. 0x0C, 0x00,
  321. 0x81, 0x06, /* Input (Variable, Relative), */
  322. 0x95, 0x02, /* Report Count (2), */
  323. 0x81, 0x03, /* Input (Constant, Variable), */
  324. 0xC0, /* End Collection, */
  325. 0xC0, /* End Collection, */
  326. 0x05, 0x0C, /* Usage Page (Consumer), */
  327. 0x09, 0x01, /* Usage (Consumer Control), */
  328. 0xA1, 0x01, /* Collection (Application), */
  329. 0x85, 0x0D, /* Report ID (13), */
  330. 0x95, 0x01, /* Report Count (1), */
  331. 0x75, 0x10, /* Report Size (16), */
  332. 0x81, 0x03, /* Input (Constant, Variable), */
  333. 0x0A, 0x2F, 0x02, /* Usage (AC Zoom), */
  334. 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
  335. 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
  336. 0x09, 0xB6, /* Usage (Scan Previous Track), */
  337. 0x09, 0xB5, /* Usage (Scan Next Track), */
  338. 0x08, /* Usage (00h), */
  339. 0x08, /* Usage (00h), */
  340. 0x08, /* Usage (00h), */
  341. 0x08, /* Usage (00h), */
  342. 0x08, /* Usage (00h), */
  343. 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
  344. 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
  345. 0x15, 0x0C, /* Logical Minimum (12), */
  346. 0x25, 0x17, /* Logical Maximum (23), */
  347. 0x75, 0x05, /* Report Size (5), */
  348. 0x80, /* Input, */
  349. 0x75, 0x03, /* Report Size (3), */
  350. 0x81, 0x03, /* Input (Constant, Variable), */
  351. 0x75, 0x20, /* Report Size (32), */
  352. 0x81, 0x03, /* Input (Constant, Variable), */
  353. 0xC0, /* End Collection, */
  354. 0x09, 0x01, /* Usage (Consumer Control), */
  355. 0xA1, 0x01, /* Collection (Application), */
  356. 0x85, 0x0C, /* Report ID (12), */
  357. 0x75, 0x01, /* Report Size (1), */
  358. 0x09, 0xE9, /* Usage (Volume Inc), */
  359. 0x09, 0xEA, /* Usage (Volume Dec), */
  360. 0x09, 0xE2, /* Usage (Mute), */
  361. 0x14, /* Logical Minimum (0), */
  362. 0x25, 0x01, /* Logical Maximum (1), */
  363. 0x95, 0x03, /* Report Count (3), */
  364. 0x81, 0x06, /* Input (Variable, Relative), */
  365. 0x95, 0x35, /* Report Count (53), */
  366. 0x81, 0x03, /* Input (Constant, Variable), */
  367. 0xC0 /* End Collection */
  368. };
  369. /*
  370. * See Media Tablet 14.1 inch description, device and HID report descriptors at
  371. * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Media_Tablet_14.1%22
  372. */
  373. /* Size of the original report descriptor of Media Tablet 14.1 inch */
  374. #define MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE 309
  375. /* Fixed Media Tablet 14.1 inch descriptor */
  376. static __u8 media_tablet_14_1_inch_rdesc_fixed[] = {
  377. 0x05, 0x0D, /* Usage Page (Digitizer), */
  378. 0x09, 0x02, /* Usage (Pen), */
  379. 0xA1, 0x01, /* Collection (Application), */
  380. 0x85, 0x10, /* Report ID (16), */
  381. 0x09, 0x20, /* Usage (Stylus), */
  382. 0xA0, /* Collection (Physical), */
  383. 0x09, 0x42, /* Usage (Tip Switch), */
  384. 0x09, 0x44, /* Usage (Barrel Switch), */
  385. 0x09, 0x46, /* Usage (Tablet Pick), */
  386. 0x15, 0x01, /* Logical Minimum (1), */
  387. 0x25, 0x03, /* Logical Maximum (3), */
  388. 0x75, 0x04, /* Report Size (4), */
  389. 0x95, 0x01, /* Report Count (1), */
  390. 0x80, /* Input, */
  391. 0x75, 0x01, /* Report Size (1), */
  392. 0x09, 0x32, /* Usage (In Range), */
  393. 0x14, /* Logical Minimum (0), */
  394. 0x25, 0x01, /* Logical Maximum (1), */
  395. 0x95, 0x01, /* Report Count (1), */
  396. 0x81, 0x02, /* Input (Variable), */
  397. 0x95, 0x03, /* Report Count (3), */
  398. 0x81, 0x03, /* Input (Constant, Variable), */
  399. 0x75, 0x10, /* Report Size (16), */
  400. 0x95, 0x01, /* Report Count (1), */
  401. 0x14, /* Logical Minimum (0), */
  402. 0xA4, /* Push, */
  403. 0x05, 0x01, /* Usage Page (Desktop), */
  404. 0x65, 0x13, /* Unit (Inch), */
  405. 0x55, 0xFD, /* Unit Exponent (-3), */
  406. 0x34, /* Physical Minimum (0), */
  407. 0x09, 0x30, /* Usage (X), */
  408. 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */
  409. 0x26, 0xFF, 0x3F, /* Logical Maximum (16383), */
  410. 0x81, 0x02, /* Input (Variable), */
  411. 0x09, 0x31, /* Usage (Y), */
  412. 0x46, 0x52, 0x1C, /* Physical Maximum (7250), */
  413. 0x26, 0xFF, 0x3F, /* Logical Maximum (16383), */
  414. 0x81, 0x02, /* Input (Variable), */
  415. 0xB4, /* Pop, */
  416. 0x09, 0x30, /* Usage (Tip Pressure), */
  417. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  418. 0x81, 0x02, /* Input (Variable), */
  419. 0xC0, /* End Collection, */
  420. 0xC0, /* End Collection, */
  421. 0x05, 0x01, /* Usage Page (Desktop), */
  422. 0x09, 0x02, /* Usage (Mouse), */
  423. 0xA1, 0x01, /* Collection (Application), */
  424. 0x85, 0x01, /* Report ID (1), */
  425. 0x09, 0x01, /* Usage (Pointer), */
  426. 0xA0, /* Collection (Physical), */
  427. 0x75, 0x08, /* Report Size (8), */
  428. 0x95, 0x03, /* Report Count (3), */
  429. 0x81, 0x03, /* Input (Constant, Variable), */
  430. 0x95, 0x02, /* Report Count (2), */
  431. 0x15, 0xFF, /* Logical Minimum (-1), */
  432. 0x25, 0x01, /* Logical Maximum (1), */
  433. 0x09, 0x38, /* Usage (Wheel), */
  434. 0x0B, 0x38, 0x02, /* Usage (Consumer AC Pan), */
  435. 0x0C, 0x00,
  436. 0x81, 0x06, /* Input (Variable, Relative), */
  437. 0xC0, /* End Collection, */
  438. 0xC0, /* End Collection, */
  439. 0x05, 0x0C, /* Usage Page (Consumer), */
  440. 0x09, 0x01, /* Usage (Consumer Control), */
  441. 0xA1, 0x01, /* Collection (Application), */
  442. 0x85, 0x0D, /* Report ID (13), */
  443. 0x95, 0x01, /* Report Count (1), */
  444. 0x75, 0x10, /* Report Size (16), */
  445. 0x81, 0x03, /* Input (Constant, Variable), */
  446. 0x0A, 0x2F, 0x02, /* Usage (AC Zoom), */
  447. 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
  448. 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
  449. 0x09, 0xB6, /* Usage (Scan Previous Track), */
  450. 0x09, 0xB5, /* Usage (Scan Next Track), */
  451. 0x08, /* Usage (00h), */
  452. 0x08, /* Usage (00h), */
  453. 0x08, /* Usage (00h), */
  454. 0x08, /* Usage (00h), */
  455. 0x08, /* Usage (00h), */
  456. 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
  457. 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
  458. 0x15, 0x0C, /* Logical Minimum (12), */
  459. 0x25, 0x17, /* Logical Maximum (23), */
  460. 0x75, 0x05, /* Report Size (5), */
  461. 0x80, /* Input, */
  462. 0x75, 0x03, /* Report Size (3), */
  463. 0x81, 0x03, /* Input (Constant, Variable), */
  464. 0x75, 0x20, /* Report Size (32), */
  465. 0x81, 0x03, /* Input (Constant, Variable), */
  466. 0xC0, /* End Collection, */
  467. 0x09, 0x01, /* Usage (Consumer Control), */
  468. 0xA1, 0x01, /* Collection (Application), */
  469. 0x85, 0x0C, /* Report ID (12), */
  470. 0x75, 0x01, /* Report Size (1), */
  471. 0x09, 0xE9, /* Usage (Volume Inc), */
  472. 0x09, 0xEA, /* Usage (Volume Dec), */
  473. 0x09, 0xE2, /* Usage (Mute), */
  474. 0x14, /* Logical Minimum (0), */
  475. 0x25, 0x01, /* Logical Maximum (1), */
  476. 0x95, 0x03, /* Report Count (3), */
  477. 0x81, 0x06, /* Input (Variable, Relative), */
  478. 0x75, 0x05, /* Report Size (5), */
  479. 0x81, 0x03, /* Input (Constant, Variable), */
  480. 0xC0 /* End Collection */
  481. };
  482. /*
  483. * See Sirius Battery Free Tablet description, device and HID report descriptors
  484. * at
  485. * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Sirius_Battery_Free_Tablet
  486. */
  487. /* Size of the original report descriptor of Sirius Battery Free Tablet */
  488. #define SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE 335
  489. /* Fixed Sirius Battery Free Tablet descriptor */
  490. static __u8 sirius_battery_free_tablet_rdesc_fixed[] = {
  491. 0x05, 0x0D, /* Usage Page (Digitizer), */
  492. 0x09, 0x02, /* Usage (Pen), */
  493. 0xA1, 0x01, /* Collection (Application), */
  494. 0x85, 0x10, /* Report ID (16), */
  495. 0x09, 0x20, /* Usage (Stylus), */
  496. 0xA0, /* Collection (Physical), */
  497. 0x95, 0x01, /* Report Count (1), */
  498. 0x15, 0x01, /* Logical Minimum (1), */
  499. 0x25, 0x03, /* Logical Maximum (3), */
  500. 0x75, 0x02, /* Report Size (2), */
  501. 0x09, 0x42, /* Usage (Tip Switch), */
  502. 0x09, 0x44, /* Usage (Barrel Switch), */
  503. 0x09, 0x46, /* Usage (Tablet Pick), */
  504. 0x80, /* Input, */
  505. 0x14, /* Logical Minimum (0), */
  506. 0x25, 0x01, /* Logical Maximum (1), */
  507. 0x75, 0x01, /* Report Size (1), */
  508. 0x09, 0x3C, /* Usage (Invert), */
  509. 0x81, 0x02, /* Input (Variable), */
  510. 0x81, 0x03, /* Input (Constant, Variable), */
  511. 0x09, 0x32, /* Usage (In Range), */
  512. 0x81, 0x02, /* Input (Variable), */
  513. 0x95, 0x03, /* Report Count (3), */
  514. 0x81, 0x03, /* Input (Constant, Variable), */
  515. 0xA4, /* Push, */
  516. 0x05, 0x01, /* Usage Page (Desktop), */
  517. 0x55, 0xFD, /* Unit Exponent (-3), */
  518. 0x65, 0x13, /* Unit (Inch), */
  519. 0x34, /* Physical Minimum (0), */
  520. 0x14, /* Logical Minimum (0), */
  521. 0x75, 0x10, /* Report Size (16), */
  522. 0x95, 0x01, /* Report Count (1), */
  523. 0x46, 0x10, 0x27, /* Physical Maximum (10000), */
  524. 0x26, 0x20, 0x4E, /* Logical Maximum (20000), */
  525. 0x09, 0x30, /* Usage (X), */
  526. 0x81, 0x02, /* Input (Variable), */
  527. 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
  528. 0x26, 0xE0, 0x2E, /* Logical Maximum (12000), */
  529. 0x09, 0x31, /* Usage (Y), */
  530. 0x81, 0x02, /* Input (Variable), */
  531. 0xB4, /* Pop, */
  532. 0x75, 0x10, /* Report Size (16), */
  533. 0x95, 0x01, /* Report Count (1), */
  534. 0x14, /* Logical Minimum (0), */
  535. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  536. 0x09, 0x30, /* Usage (Tip Pressure), */
  537. 0x81, 0x02, /* Input (Variable), */
  538. 0xA4, /* Push, */
  539. 0x55, 0xFE, /* Unit Exponent (-2), */
  540. 0x65, 0x12, /* Unit (Radians), */
  541. 0x35, 0x97, /* Physical Minimum (-105), */
  542. 0x45, 0x69, /* Physical Maximum (105), */
  543. 0x15, 0x97, /* Logical Minimum (-105), */
  544. 0x25, 0x69, /* Logical Maximum (105), */
  545. 0x75, 0x08, /* Report Size (8), */
  546. 0x95, 0x02, /* Report Count (2), */
  547. 0x09, 0x3D, /* Usage (X Tilt), */
  548. 0x09, 0x3E, /* Usage (Y Tilt), */
  549. 0x81, 0x02, /* Input (Variable), */
  550. 0xB4, /* Pop, */
  551. 0xC0, /* End Collection, */
  552. 0xC0, /* End Collection, */
  553. 0x05, 0x01, /* Usage Page (Desktop), */
  554. 0x09, 0x02, /* Usage (Mouse), */
  555. 0xA1, 0x01, /* Collection (Application), */
  556. 0x85, 0x01, /* Report ID (1), */
  557. 0x09, 0x01, /* Usage (Pointer), */
  558. 0xA0, /* Collection (Physical), */
  559. 0x75, 0x08, /* Report Size (8), */
  560. 0x95, 0x03, /* Report Count (3), */
  561. 0x81, 0x03, /* Input (Constant, Variable), */
  562. 0x09, 0x38, /* Usage (Wheel), */
  563. 0x15, 0xFF, /* Logical Minimum (-1), */
  564. 0x25, 0x01, /* Logical Maximum (1), */
  565. 0x75, 0x08, /* Report Size (8), */
  566. 0x95, 0x01, /* Report Count (1), */
  567. 0x81, 0x06, /* Input (Variable, Relative), */
  568. 0x75, 0x08, /* Report Size (8), */
  569. 0x95, 0x03, /* Report Count (3), */
  570. 0x81, 0x03, /* Input (Constant, Variable), */
  571. 0xC0, /* End Collection, */
  572. 0xC0, /* End Collection, */
  573. 0x05, 0x01, /* Usage Page (Desktop), */
  574. 0x09, 0x06, /* Usage (Keyboard), */
  575. 0xA1, 0x01, /* Collection (Application), */
  576. 0x85, 0x0D, /* Report ID (13), */
  577. 0x05, 0x07, /* Usage Page (Keyboard), */
  578. 0x19, 0xE0, /* Usage Minimum (KB Leftcontrol), */
  579. 0x29, 0xE7, /* Usage Maximum (KB Right GUI), */
  580. 0x14, /* Logical Minimum (0), */
  581. 0x25, 0x01, /* Logical Maximum (1), */
  582. 0x75, 0x01, /* Report Size (1), */
  583. 0x95, 0x08, /* Report Count (8), */
  584. 0x81, 0x02, /* Input (Variable), */
  585. 0x75, 0x08, /* Report Size (8), */
  586. 0x95, 0x01, /* Report Count (1), */
  587. 0x81, 0x01, /* Input (Constant), */
  588. 0x18, /* Usage Minimum (None), */
  589. 0x29, 0x65, /* Usage Maximum (KB Application), */
  590. 0x14, /* Logical Minimum (0), */
  591. 0x25, 0x65, /* Logical Maximum (101), */
  592. 0x75, 0x08, /* Report Size (8), */
  593. 0x95, 0x05, /* Report Count (5), */
  594. 0x80, /* Input, */
  595. 0xC0, /* End Collection, */
  596. 0x05, 0x0C, /* Usage Page (Consumer), */
  597. 0x09, 0x01, /* Usage (Consumer Control), */
  598. 0xA1, 0x01, /* Collection (Application), */
  599. 0x85, 0x0C, /* Report ID (12), */
  600. 0x09, 0xE9, /* Usage (Volume Inc), */
  601. 0x09, 0xEA, /* Usage (Volume Dec), */
  602. 0x14, /* Logical Minimum (0), */
  603. 0x25, 0x01, /* Logical Maximum (1), */
  604. 0x75, 0x01, /* Report Size (1), */
  605. 0x95, 0x02, /* Report Count (2), */
  606. 0x81, 0x02, /* Input (Variable), */
  607. 0x75, 0x06, /* Report Size (6), */
  608. 0x95, 0x01, /* Report Count (1), */
  609. 0x81, 0x03, /* Input (Constant, Variable), */
  610. 0x75, 0x10, /* Report Size (16), */
  611. 0x95, 0x03, /* Report Count (3), */
  612. 0x81, 0x03, /* Input (Constant, Variable), */
  613. 0xC0 /* End Collection */
  614. };
  615. static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  616. unsigned int *rsize)
  617. {
  618. switch (hdev->product) {
  619. case USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH:
  620. if (*rsize == SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE) {
  621. rdesc = slim_tablet_5_8_inch_rdesc_fixed;
  622. *rsize = sizeof(slim_tablet_5_8_inch_rdesc_fixed);
  623. }
  624. break;
  625. case USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH:
  626. if (*rsize == SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE) {
  627. rdesc = slim_tablet_12_1_inch_rdesc_fixed;
  628. *rsize = sizeof(slim_tablet_12_1_inch_rdesc_fixed);
  629. }
  630. break;
  631. case USB_DEVICE_ID_WALTOP_Q_PAD:
  632. if (*rsize == Q_PAD_RDESC_ORIG_SIZE) {
  633. rdesc = q_pad_rdesc_fixed;
  634. *rsize = sizeof(q_pad_rdesc_fixed);
  635. }
  636. break;
  637. case USB_DEVICE_ID_WALTOP_PID_0038:
  638. if (*rsize == PID_0038_RDESC_ORIG_SIZE) {
  639. rdesc = pid_0038_rdesc_fixed;
  640. *rsize = sizeof(pid_0038_rdesc_fixed);
  641. }
  642. break;
  643. case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH:
  644. if (*rsize == MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE) {
  645. rdesc = media_tablet_10_6_inch_rdesc_fixed;
  646. *rsize = sizeof(media_tablet_10_6_inch_rdesc_fixed);
  647. }
  648. break;
  649. case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH:
  650. if (*rsize == MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE) {
  651. rdesc = media_tablet_14_1_inch_rdesc_fixed;
  652. *rsize = sizeof(media_tablet_14_1_inch_rdesc_fixed);
  653. }
  654. break;
  655. case USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET:
  656. if (*rsize == SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE) {
  657. rdesc = sirius_battery_free_tablet_rdesc_fixed;
  658. *rsize = sizeof(sirius_battery_free_tablet_rdesc_fixed);
  659. }
  660. break;
  661. }
  662. return rdesc;
  663. }
  664. static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report,
  665. u8 *data, int size)
  666. {
  667. /* If this is a pen input report */
  668. if (report->type == HID_INPUT_REPORT && report->id == 16 && size >= 8) {
  669. /*
  670. * Ignore reported pressure when a barrel button is pressed,
  671. * because it is rarely correct.
  672. */
  673. /* If a barrel button is pressed */
  674. if ((data[1] & 0xF) > 1) {
  675. /* Report zero pressure */
  676. data[6] = 0;
  677. data[7] = 0;
  678. }
  679. }
  680. /* If this is a pen input report of Sirius Battery Free Tablet */
  681. if (hdev->product == USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET &&
  682. report->type == HID_INPUT_REPORT &&
  683. report->id == 16 &&
  684. size == 10) {
  685. /*
  686. * The tablet reports tilt as roughly sin(a)*21 (18 means 60
  687. * degrees).
  688. *
  689. * This array stores angles as radians * 100, corresponding to
  690. * reported values up to 60 degrees, as expected by userspace.
  691. */
  692. static const s8 tilt_to_radians[] = {
  693. 0, 5, 10, 14, 19, 24, 29, 34, 40, 45,
  694. 50, 56, 62, 68, 74, 81, 88, 96, 105
  695. };
  696. s8 tilt_x = (s8)data[8];
  697. s8 tilt_y = (s8)data[9];
  698. s8 sign_x = tilt_x >= 0 ? 1 : -1;
  699. s8 sign_y = tilt_y >= 0 ? 1 : -1;
  700. tilt_x *= sign_x;
  701. tilt_y *= sign_y;
  702. /*
  703. * Reverse the Y Tilt direction to match the HID standard and
  704. * userspace expectations. See HID Usage Tables v1.12 16.3.2
  705. * Tilt Orientation.
  706. */
  707. sign_y *= -1;
  708. /*
  709. * This effectively clamps reported tilt to 60 degrees - the
  710. * range expected by userspace
  711. */
  712. if (tilt_x > ARRAY_SIZE(tilt_to_radians) - 1)
  713. tilt_x = ARRAY_SIZE(tilt_to_radians) - 1;
  714. if (tilt_y > ARRAY_SIZE(tilt_to_radians) - 1)
  715. tilt_y = ARRAY_SIZE(tilt_to_radians) - 1;
  716. data[8] = tilt_to_radians[tilt_x] * sign_x;
  717. data[9] = tilt_to_radians[tilt_y] * sign_y;
  718. }
  719. return 0;
  720. }
  721. static const struct hid_device_id waltop_devices[] = {
  722. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
  723. USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
  724. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
  725. USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
  726. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
  727. USB_DEVICE_ID_WALTOP_Q_PAD) },
  728. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
  729. USB_DEVICE_ID_WALTOP_PID_0038) },
  730. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
  731. USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
  732. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
  733. USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
  734. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
  735. USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) },
  736. { }
  737. };
  738. MODULE_DEVICE_TABLE(hid, waltop_devices);
  739. static struct hid_driver waltop_driver = {
  740. .name = "waltop",
  741. .id_table = waltop_devices,
  742. .report_fixup = waltop_report_fixup,
  743. .raw_event = waltop_raw_event,
  744. };
  745. module_hid_driver(waltop_driver);
  746. MODULE_LICENSE("GPL");