hid-waltop.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  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. * Original Slim Tablet 5.8 inch report descriptor.
  18. *
  19. * All the reports except the report with ID 16 (the stylus) are unused,
  20. * possibly because the tablet is not configured to, or because they were
  21. * just copied from a more capable model. The purpose of features described
  22. * for report ID 2 is unknown.
  23. *
  24. * The stylus buttons are described as three bit fields, whereas actually
  25. * it's an "array", i.e. they're reported as button numbers (1, 2 and 3).
  26. * The "eraser" field is not used. There is also a "push" without a "pop" in
  27. * the stylus description.
  28. *
  29. * Usage Page (Desktop), ; Generic desktop controls (01h)
  30. * Usage (Mouse), ; Mouse (02h, application collection)
  31. * Collection (Application),
  32. * Report ID (1),
  33. * Usage (Pointer), ; Pointer (01h, physical collection)
  34. * Collection (Physical),
  35. * Usage Page (Button), ; Button (09h)
  36. * Usage Minimum (01h),
  37. * Usage Maximum (05h),
  38. * Logical Minimum (0),
  39. * Logical Maximum (1),
  40. * Report Size (1),
  41. * Report Count (5),
  42. * Input (Variable),
  43. * Report Size (3),
  44. * Report Count (1),
  45. * Input (Constant, Variable),
  46. * Usage Page (Desktop), ; Generic desktop controls (01h)
  47. * Usage (X), ; X (30h, dynamic value)
  48. * Usage (Y), ; Y (31h, dynamic value)
  49. * Usage (Wheel), ; Wheel (38h, dynamic value)
  50. * Logical Minimum (-127),
  51. * Logical Maximum (127),
  52. * Report Size (8),
  53. * Report Count (3),
  54. * Input (Variable, Relative),
  55. * End Collection,
  56. * End Collection,
  57. * Usage Page (Digitizer), ; Digitizer (0Dh)
  58. * Usage (Pen), ; Pen (02h, application collection)
  59. * Collection (Application),
  60. * Report ID (2),
  61. * Usage (Stylus), ; Stylus (20h, logical collection)
  62. * Collection (Physical),
  63. * Usage (00h),
  64. * Logical Minimum (0),
  65. * Logical Maximum (255),
  66. * Report Size (8),
  67. * Report Count (7),
  68. * Input (Variable),
  69. * Usage (Azimuth), ; Azimuth (3Fh, dynamic value)
  70. * Usage (Altitude), ; Altitude (40h, dynamic value)
  71. * Logical Minimum (0),
  72. * Logical Maximum (255),
  73. * Report Size (8),
  74. * Report Count (2),
  75. * Feature (Variable),
  76. * End Collection,
  77. * Report ID (5),
  78. * Usage Page (Digitizer), ; Digitizer (0Dh)
  79. * Usage (Stylus), ; Stylus (20h, logical collection)
  80. * Collection (Physical),
  81. * Usage (00h),
  82. * Logical Minimum (0),
  83. * Logical Maximum (255),
  84. * Report Size (8),
  85. * Report Count (7),
  86. * Input (Variable),
  87. * End Collection,
  88. * Report ID (10),
  89. * Usage Page (Digitizer), ; Digitizer (0Dh)
  90. * Usage (Stylus), ; Stylus (20h, logical collection)
  91. * Collection (Physical),
  92. * Usage (00h),
  93. * Logical Minimum (0),
  94. * Logical Maximum (255),
  95. * Report Size (8),
  96. * Report Count (3),
  97. * Input (Variable),
  98. * End Collection,
  99. * Report ID (16),
  100. * Usage (Stylus), ; Stylus (20h, logical collection)
  101. * Collection (Physical),
  102. * Usage (Tip Switch), ; Tip switch (42h, momentary control)
  103. * Usage (Barrel Switch), ; Barrel switch (44h, momentary control)
  104. * Usage (Invert), ; Invert (3Ch, momentary control)
  105. * Usage (Eraser), ; Eraser (45h, momentary control)
  106. * Usage (In Range), ; In range (32h, momentary control)
  107. * Logical Minimum (0),
  108. * Logical Maximum (1),
  109. * Report Size (1),
  110. * Report Count (5),
  111. * Input (Variable),
  112. * Report Count (3),
  113. * Input (Constant, Variable),
  114. * Usage Page (Desktop), ; Generic desktop controls (01h)
  115. * Usage (X), ; X (30h, dynamic value)
  116. * Report Size (16),
  117. * Report Count (1),
  118. * Push,
  119. * Unit Exponent (13),
  120. * Unit (Inch^3),
  121. * Logical Minimum (0),
  122. * Logical Maximum (10000),
  123. * Physical Minimum (0),
  124. * Physical Maximum (10000),
  125. * Input (Variable),
  126. * Usage (Y), ; Y (31h, dynamic value)
  127. * Logical Maximum (6000),
  128. * Physical Maximum (6000),
  129. * Input (Variable),
  130. * Usage Page (Digitizer), ; Digitizer (0Dh)
  131. * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
  132. * Logical Minimum (0),
  133. * Logical Maximum (1023),
  134. * Physical Minimum (0),
  135. * Physical Maximum (1023),
  136. * Input (Variable),
  137. * End Collection,
  138. * End Collection
  139. */
  140. /* Size of the original report descriptor of Slim Tablet 5.8 inch */
  141. #define SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE 222
  142. /*
  143. * Fixed Slim Tablet 5.8 inch descriptor.
  144. *
  145. * All the reports except the stylus report (ID 16) were removed as unused.
  146. * The stylus buttons description was fixed.
  147. */
  148. static __u8 slim_tablet_5_8_inch_rdesc_fixed[] = {
  149. 0x05, 0x0D, /* Usage Page (Digitizer), */
  150. 0x09, 0x02, /* Usage (Pen), */
  151. 0xA1, 0x01, /* Collection (Application), */
  152. 0x85, 0x10, /* Report ID (16), */
  153. 0x09, 0x20, /* Usage (Stylus), */
  154. 0xA0, /* Collection (Physical), */
  155. 0x09, 0x42, /* Usage (Tip Switch), */
  156. 0x09, 0x44, /* Usage (Barrel Switch), */
  157. 0x09, 0x46, /* Usage (Tablet Pick), */
  158. 0x15, 0x01, /* Logical Minimum (1), */
  159. 0x25, 0x03, /* Logical Maximum (3), */
  160. 0x75, 0x04, /* Report Size (4), */
  161. 0x95, 0x01, /* Report Count (1), */
  162. 0x80, /* Input, */
  163. 0x09, 0x32, /* Usage (In Range), */
  164. 0x14, /* Logical Minimum (0), */
  165. 0x25, 0x01, /* Logical Maximum (1), */
  166. 0x75, 0x01, /* Report Size (1), */
  167. 0x95, 0x01, /* Report Count (1), */
  168. 0x81, 0x02, /* Input (Variable), */
  169. 0x95, 0x03, /* Report Count (3), */
  170. 0x81, 0x03, /* Input (Constant, Variable), */
  171. 0x75, 0x10, /* Report Size (16), */
  172. 0x95, 0x01, /* Report Count (1), */
  173. 0x14, /* Logical Minimum (0), */
  174. 0xA4, /* Push, */
  175. 0x05, 0x01, /* Usage Page (Desktop), */
  176. 0x65, 0x13, /* Unit (Inch), */
  177. 0x55, 0xFD, /* Unit Exponent (-3), */
  178. 0x34, /* Physical Minimum (0), */
  179. 0x09, 0x30, /* Usage (X), */
  180. 0x46, 0x88, 0x13, /* Physical Maximum (5000), */
  181. 0x26, 0x10, 0x27, /* Logical Maximum (10000), */
  182. 0x81, 0x02, /* Input (Variable), */
  183. 0x09, 0x31, /* Usage (Y), */
  184. 0x46, 0xB8, 0x0B, /* Physical Maximum (3000), */
  185. 0x26, 0x70, 0x17, /* Logical Maximum (6000), */
  186. 0x81, 0x02, /* Input (Variable), */
  187. 0xB4, /* Pop, */
  188. 0x09, 0x30, /* Usage (Tip Pressure), */
  189. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  190. 0x81, 0x02, /* Input (Variable), */
  191. 0xC0, /* End Collection, */
  192. 0xC0 /* End Collection */
  193. };
  194. /*
  195. * Original Media Tablet 10.6 inch report descriptor.
  196. *
  197. * There are at least two versions of this model in the wild. They are
  198. * represented by Genius G-Pen M609 (older version) and Genius G-Pen M609X
  199. * (newer version).
  200. *
  201. * Both versions have the usual pen with two barrel buttons and two
  202. * identical wheels with center buttons in the top corners of the tablet
  203. * base. They also have buttons on the top, between the wheels, for
  204. * selecting the wheels' functions and wide/standard mode. In the wide mode
  205. * the whole working surface is sensed, in the standard mode a narrower area
  206. * is sensed, but the logical report extents remain the same. These modes
  207. * correspond roughly to 16:9 and 4:3 aspect ratios respectively.
  208. *
  209. * The older version has three wheel function buttons ("scroll", "zoom" and
  210. * "volume") and two separate buttons for wide and standard mode. The newer
  211. * version has four wheel function buttons (plus "brush") and only one
  212. * button is used for selecting wide/standard mode. So, the total number of
  213. * buttons remains the same, but one of the mode buttons is repurposed as a
  214. * wheels' function button in the newer version.
  215. *
  216. * The wheel functions are:
  217. * scroll - the wheels act as scroll wheels, the center buttons switch
  218. * between vertical and horizontal scrolling;
  219. * zoom - the wheels zoom in/out, the buttons supposedly reset to 100%;
  220. * volume - the wheels control the sound volume, the buttons mute;
  221. * brush - the wheels are supposed to control brush width in a graphics
  222. * editor, the buttons do nothing.
  223. *
  224. * Below is the newer version's report descriptor. It may very well be that
  225. * the older version's descriptor is different and thus it won't be
  226. * supported.
  227. *
  228. * The mouse report (ID 1) only uses the wheel field for reporting the tablet
  229. * wheels' scroll mode. The keyboard report (ID 13) is used to report the
  230. * wheels' zoom and brush control functions as key presses. The report ID 12
  231. * is used to report the wheels' volume control functions. The stylus report
  232. * (ID 16) has the same problems as the Slim Tablet 5.8 inch report has.
  233. *
  234. * The rest of the reports are unused, at least in the default configuration.
  235. * The purpose of the features is unknown.
  236. *
  237. * Usage Page (Desktop),
  238. * Usage (Mouse),
  239. * Collection (Application),
  240. * Report ID (1),
  241. * Usage (Pointer),
  242. * Collection (Physical),
  243. * Usage Page (Button),
  244. * Usage Minimum (01h),
  245. * Usage Maximum (05h),
  246. * Logical Minimum (0),
  247. * Logical Maximum (1),
  248. * Report Size (1),
  249. * Report Count (5),
  250. * Input (Variable),
  251. * Report Size (3),
  252. * Report Count (1),
  253. * Input (Constant, Variable),
  254. * Usage Page (Desktop),
  255. * Usage (X),
  256. * Usage (Y),
  257. * Usage (Wheel),
  258. * Logical Minimum (-127),
  259. * Logical Maximum (127),
  260. * Report Size (8),
  261. * Report Count (3),
  262. * Input (Variable, Relative),
  263. * End Collection,
  264. * End Collection,
  265. * Usage Page (Digitizer),
  266. * Usage (Pen),
  267. * Collection (Application),
  268. * Report ID (2),
  269. * Usage (Stylus),
  270. * Collection (Physical),
  271. * Usage (00h),
  272. * Logical Minimum (0),
  273. * Logical Maximum (255),
  274. * Report Size (8),
  275. * Report Count (7),
  276. * Input (Variable),
  277. * Usage (Azimuth),
  278. * Usage (Altitude),
  279. * Logical Minimum (0),
  280. * Logical Maximum (255),
  281. * Report Size (8),
  282. * Report Count (2),
  283. * Feature (Variable),
  284. * End Collection,
  285. * Report ID (5),
  286. * Usage Page (Digitizer),
  287. * Usage (Stylus),
  288. * Collection (Physical),
  289. * Usage (00h),
  290. * Logical Minimum (0),
  291. * Logical Maximum (255),
  292. * Report Size (8),
  293. * Report Count (7),
  294. * Input (Variable),
  295. * End Collection,
  296. * Report ID (10),
  297. * Usage Page (Digitizer),
  298. * Usage (Stylus),
  299. * Collection (Physical),
  300. * Usage (00h),
  301. * Logical Minimum (0),
  302. * Logical Maximum (255),
  303. * Report Size (8),
  304. * Report Count (7),
  305. * Input (Variable),
  306. * End Collection,
  307. * Report ID (16),
  308. * Usage (Stylus),
  309. * Collection (Physical),
  310. * Usage (Tip Switch),
  311. * Usage (Barrel Switch),
  312. * Usage (Invert),
  313. * Usage (Eraser),
  314. * Usage (In Range),
  315. * Logical Minimum (0),
  316. * Logical Maximum (1),
  317. * Report Size (1),
  318. * Report Count (5),
  319. * Input (Variable),
  320. * Report Count (3),
  321. * Input (Constant, Variable),
  322. * Usage Page (Desktop),
  323. * Usage (X),
  324. * Report Size (16),
  325. * Report Count (1),
  326. * Push,
  327. * Unit Exponent (13),
  328. * Unit (Inch^3),
  329. * Logical Minimum (0),
  330. * Logical Maximum (18000),
  331. * Physical Minimum (0),
  332. * Physical Maximum (18000),
  333. * Input (Variable),
  334. * Usage (Y),
  335. * Logical Maximum (11000),
  336. * Physical Maximum (11000),
  337. * Input (Variable),
  338. * Usage Page (Digitizer),
  339. * Usage (Tip Pressure),
  340. * Logical Minimum (0),
  341. * Logical Maximum (1023),
  342. * Physical Minimum (0),
  343. * Physical Maximum (1023),
  344. * Input (Variable),
  345. * End Collection,
  346. * End Collection,
  347. * Usage Page (Desktop),
  348. * Usage (Keyboard),
  349. * Collection (Application),
  350. * Report ID (13),
  351. * Usage Page (Keyboard),
  352. * Usage Minimum (KB Leftcontrol),
  353. * Usage Maximum (KB Right GUI),
  354. * Logical Minimum (0),
  355. * Logical Maximum (1),
  356. * Report Size (1),
  357. * Report Count (8),
  358. * Input (Variable),
  359. * Report Size (8),
  360. * Report Count (1),
  361. * Input (Constant),
  362. * Usage Page (Keyboard),
  363. * Usage Minimum (None),
  364. * Usage Maximum (KB Application),
  365. * Logical Minimum (0),
  366. * Logical Maximum (101),
  367. * Report Size (8),
  368. * Report Count (5),
  369. * Input,
  370. * End Collection,
  371. * Usage Page (Consumer),
  372. * Usage (Consumer Control),
  373. * Collection (Application),
  374. * Report ID (12),
  375. * Usage (Volume Inc),
  376. * Usage (Volume Dec),
  377. * Usage (Mute),
  378. * Logical Minimum (0),
  379. * Logical Maximum (1),
  380. * Report Size (1),
  381. * Report Count (3),
  382. * Input (Variable, Relative),
  383. * Report Size (5),
  384. * Report Count (1),
  385. * Input (Constant, Variable, Relative),
  386. * End Collection
  387. */
  388. /* Size of the original report descriptor of Media Tablet 10.6 inch */
  389. #define MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE 300
  390. /*
  391. * Fixed Media Tablet 10.6 inch descriptor.
  392. *
  393. * The descriptions of reports unused in the default configuration are
  394. * removed. The stylus report (ID 16) is fixed similarly to Slim Tablet 5.8
  395. * inch. The unused mouse report (ID 1) fields are replaced with constant
  396. * padding.
  397. *
  398. * The keyboard report (ID 13) is hacked to instead have an "array" field
  399. * reporting consumer page controls, and all the unused bits are masked out
  400. * with constant padding. The "brush" wheels' function is represented as "Scan
  401. * Previous/Next Track" controls due to the lack of brush controls in the
  402. * usage tables specification.
  403. */
  404. static __u8 media_tablet_10_6_inch_rdesc_fixed[] = {
  405. 0x05, 0x0D, /* Usage Page (Digitizer), */
  406. 0x09, 0x02, /* Usage (Pen), */
  407. 0xA1, 0x01, /* Collection (Application), */
  408. 0x85, 0x10, /* Report ID (16), */
  409. 0x09, 0x20, /* Usage (Stylus), */
  410. 0xA0, /* Collection (Physical), */
  411. 0x09, 0x42, /* Usage (Tip Switch), */
  412. 0x09, 0x44, /* Usage (Barrel Switch), */
  413. 0x09, 0x46, /* Usage (Tablet Pick), */
  414. 0x15, 0x01, /* Logical Minimum (1), */
  415. 0x25, 0x03, /* Logical Maximum (3), */
  416. 0x75, 0x04, /* Report Size (4), */
  417. 0x95, 0x01, /* Report Count (1), */
  418. 0x80, /* Input, */
  419. 0x75, 0x01, /* Report Size (1), */
  420. 0x09, 0x32, /* Usage (In Range), */
  421. 0x14, /* Logical Minimum (0), */
  422. 0x25, 0x01, /* Logical Maximum (1), */
  423. 0x95, 0x01, /* Report Count (1), */
  424. 0x81, 0x02, /* Input (Variable), */
  425. 0x95, 0x03, /* Report Count (3), */
  426. 0x81, 0x03, /* Input (Constant, Variable), */
  427. 0x75, 0x10, /* Report Size (16), */
  428. 0x95, 0x01, /* Report Count (1), */
  429. 0x14, /* Logical Minimum (0), */
  430. 0xA4, /* Push, */
  431. 0x05, 0x01, /* Usage Page (Desktop), */
  432. 0x65, 0x13, /* Unit (Inch), */
  433. 0x55, 0xFD, /* Unit Exponent (-3), */
  434. 0x34, /* Physical Minimum (0), */
  435. 0x09, 0x30, /* Usage (X), */
  436. 0x46, 0x28, 0x23, /* Physical Maximum (9000), */
  437. 0x26, 0x50, 0x46, /* Logical Maximum (18000), */
  438. 0x81, 0x02, /* Input (Variable), */
  439. 0x09, 0x31, /* Usage (Y), */
  440. 0x46, 0x7C, 0x15, /* Physical Maximum (5500), */
  441. 0x26, 0xF8, 0x2A, /* Logical Maximum (11000), */
  442. 0x81, 0x02, /* Input (Variable), */
  443. 0xB4, /* Pop, */
  444. 0x09, 0x30, /* Usage (Tip Pressure), */
  445. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  446. 0x81, 0x02, /* Input (Variable), */
  447. 0xC0, /* End Collection, */
  448. 0xC0, /* End Collection, */
  449. 0x05, 0x01, /* Usage Page (Desktop), */
  450. 0x09, 0x02, /* Usage (Mouse), */
  451. 0xA1, 0x01, /* Collection (Application), */
  452. 0x85, 0x01, /* Report ID (1), */
  453. 0x09, 0x01, /* Usage (Pointer), */
  454. 0xA0, /* Collection (Physical), */
  455. 0x75, 0x08, /* Report Size (8), */
  456. 0x95, 0x03, /* Report Count (3), */
  457. 0x81, 0x03, /* Input (Constant, Variable), */
  458. 0x95, 0x02, /* Report Count (2), */
  459. 0x15, 0xFF, /* Logical Minimum (-1), */
  460. 0x25, 0x01, /* Logical Maximum (1), */
  461. 0x09, 0x38, /* Usage (Wheel), */
  462. 0x0B, 0x38, 0x02, /* Usage (Consumer AC Pan), */
  463. 0x0C, 0x00,
  464. 0x81, 0x06, /* Input (Variable, Relative), */
  465. 0x95, 0x02, /* Report Count (2), */
  466. 0x81, 0x03, /* Input (Constant, Variable), */
  467. 0xC0, /* End Collection, */
  468. 0xC0, /* End Collection, */
  469. 0x05, 0x0C, /* Usage Page (Consumer), */
  470. 0x09, 0x01, /* Usage (Consumer Control), */
  471. 0xA1, 0x01, /* Collection (Application), */
  472. 0x85, 0x0D, /* Report ID (13), */
  473. 0x95, 0x01, /* Report Count (1), */
  474. 0x75, 0x10, /* Report Size (16), */
  475. 0x81, 0x03, /* Input (Constant, Variable), */
  476. 0x0A, 0x2F, 0x02, /* Usage (AC Zoom), */
  477. 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
  478. 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
  479. 0x09, 0xB6, /* Usage (Scan Previous Track), */
  480. 0x09, 0xB5, /* Usage (Scan Next Track), */
  481. 0x08, /* Usage (00h), */
  482. 0x08, /* Usage (00h), */
  483. 0x08, /* Usage (00h), */
  484. 0x08, /* Usage (00h), */
  485. 0x08, /* Usage (00h), */
  486. 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
  487. 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
  488. 0x15, 0x0C, /* Logical Minimum (12), */
  489. 0x25, 0x17, /* Logical Maximum (23), */
  490. 0x75, 0x05, /* Report Size (5), */
  491. 0x80, /* Input, */
  492. 0x75, 0x03, /* Report Size (3), */
  493. 0x81, 0x03, /* Input (Constant, Variable), */
  494. 0x75, 0x20, /* Report Size (32), */
  495. 0x81, 0x03, /* Input (Constant, Variable), */
  496. 0xC0, /* End Collection, */
  497. 0x09, 0x01, /* Usage (Consumer Control), */
  498. 0xA1, 0x01, /* Collection (Application), */
  499. 0x85, 0x0C, /* Report ID (12), */
  500. 0x75, 0x01, /* Report Size (1), */
  501. 0x09, 0xE9, /* Usage (Volume Inc), */
  502. 0x09, 0xEA, /* Usage (Volume Dec), */
  503. 0x09, 0xE2, /* Usage (Mute), */
  504. 0x14, /* Logical Minimum (0), */
  505. 0x25, 0x01, /* Logical Maximum (1), */
  506. 0x95, 0x03, /* Report Count (3), */
  507. 0x81, 0x06, /* Input (Variable, Relative), */
  508. 0x95, 0x35, /* Report Count (53), */
  509. 0x81, 0x03, /* Input (Constant, Variable), */
  510. 0xC0 /* End Collection */
  511. };
  512. /*
  513. * Original Media Tablet 14.1 inch report descriptor.
  514. *
  515. * There are at least two versions of this model in the wild. They are
  516. * represented by Genius G-Pen M712 (older version) and Genius G-Pen M712X
  517. * (newer version). The hardware difference between these versions is the same
  518. * as between older and newer versions of Media Tablet 10.6 inch. The report
  519. * descriptors are identical for both versions.
  520. *
  521. * The function, behavior and report descriptor of this tablet is similar to
  522. * that of Media Tablet 10.6 inch. However, there is one more field (with
  523. * Consumer AC Pan usage) in the mouse description. Then the tablet X and Y
  524. * logical extents both get scaled to 0..16383 range (a hardware limit?),
  525. * which kind of defeats the advertised 4000 LPI resolution, considering the
  526. * physical extents of 12x7.25 inches. Plus, reports 5, 10 and 255 are used
  527. * sometimes (while moving the pen) with unknown purpose. Also, the key codes
  528. * generated for zoom in/out are different.
  529. *
  530. * Usage Page (Desktop),
  531. * Usage (Mouse),
  532. * Collection (Application),
  533. * Report ID (1),
  534. * Usage (Pointer),
  535. * Collection (Physical),
  536. * Usage Page (Button),
  537. * Usage Minimum (01h),
  538. * Usage Maximum (05h),
  539. * Logical Minimum (0),
  540. * Logical Maximum (1),
  541. * Report Size (1),
  542. * Report Count (5),
  543. * Input (Variable),
  544. * Report Size (3),
  545. * Report Count (1),
  546. * Input (Constant, Variable),
  547. * Usage Page (Desktop),
  548. * Usage (X),
  549. * Usage (Y),
  550. * Usage (Wheel),
  551. * Logical Minimum (-127),
  552. * Logical Maximum (127),
  553. * Report Size (8),
  554. * Report Count (3),
  555. * Input (Variable, Relative),
  556. * Usage Page (Consumer),
  557. * Logical Minimum (-127),
  558. * Logical Maximum (127),
  559. * Report Size (8),
  560. * Report Count (1),
  561. * Usage (AC Pan),
  562. * Input (Variable, Relative),
  563. * End Collection,
  564. * End Collection,
  565. * Usage Page (Digitizer),
  566. * Usage (Pen),
  567. * Collection (Application),
  568. * Report ID (2),
  569. * Usage (Stylus),
  570. * Collection (Physical),
  571. * Usage (00h),
  572. * Logical Minimum (0),
  573. * Logical Maximum (255),
  574. * Report Size (8),
  575. * Report Count (7),
  576. * Input (Variable),
  577. * Usage (Azimuth),
  578. * Usage (Altitude),
  579. * Logical Minimum (0),
  580. * Logical Maximum (255),
  581. * Report Size (8),
  582. * Report Count (2),
  583. * Feature (Variable),
  584. * End Collection,
  585. * Report ID (5),
  586. * Usage Page (Digitizer),
  587. * Usage (Stylus),
  588. * Collection (Physical),
  589. * Usage (00h),
  590. * Logical Minimum (0),
  591. * Logical Maximum (255),
  592. * Report Size (8),
  593. * Report Count (7),
  594. * Input (Variable),
  595. * End Collection,
  596. * Report ID (10),
  597. * Usage Page (Digitizer),
  598. * Usage (Stylus),
  599. * Collection (Physical),
  600. * Usage (00h),
  601. * Logical Minimum (0),
  602. * Logical Maximum (255),
  603. * Report Size (8),
  604. * Report Count (7),
  605. * Input (Variable),
  606. * End Collection,
  607. * Report ID (16),
  608. * Usage (Stylus),
  609. * Collection (Physical),
  610. * Usage (Tip Switch),
  611. * Usage (Barrel Switch),
  612. * Usage (Invert),
  613. * Usage (Eraser),
  614. * Usage (In Range),
  615. * Logical Minimum (0),
  616. * Logical Maximum (1),
  617. * Report Size (1),
  618. * Report Count (5),
  619. * Input (Variable),
  620. * Report Count (3),
  621. * Input (Constant, Variable),
  622. * Usage Page (Desktop),
  623. * Usage (X),
  624. * Report Size (16),
  625. * Report Count (1),
  626. * Push,
  627. * Unit Exponent (13),
  628. * Unit (Inch^3),
  629. * Logical Minimum (0),
  630. * Logical Maximum (16383),
  631. * Physical Minimum (0),
  632. * Physical Maximum (16383),
  633. * Input (Variable),
  634. * Usage (Y),
  635. * Input (Variable),
  636. * Usage Page (Digitizer),
  637. * Usage (Tip Pressure),
  638. * Logical Minimum (0),
  639. * Logical Maximum (1023),
  640. * Physical Minimum (0),
  641. * Physical Maximum (1023),
  642. * Input (Variable),
  643. * End Collection,
  644. * End Collection,
  645. * Usage Page (Desktop),
  646. * Usage (Keyboard),
  647. * Collection (Application),
  648. * Report ID (13),
  649. * Usage Page (Keyboard),
  650. * Usage Minimum (KB Leftcontrol),
  651. * Usage Maximum (KB Right GUI),
  652. * Logical Minimum (0),
  653. * Logical Maximum (1),
  654. * Report Size (1),
  655. * Report Count (8),
  656. * Input (Variable),
  657. * Report Size (8),
  658. * Report Count (1),
  659. * Input (Constant),
  660. * Usage Page (Keyboard),
  661. * Usage Minimum (None),
  662. * Usage Maximum (KB Application),
  663. * Logical Minimum (0),
  664. * Logical Maximum (101),
  665. * Report Size (8),
  666. * Report Count (5),
  667. * Input,
  668. * End Collection,
  669. * Usage Page (Consumer),
  670. * Usage (Consumer Control),
  671. * Collection (Application),
  672. * Report ID (12),
  673. * Usage (Volume Inc),
  674. * Usage (Volume Dec),
  675. * Usage (Mute),
  676. * Logical Minimum (0),
  677. * Logical Maximum (1),
  678. * Report Size (1),
  679. * Report Count (3),
  680. * Input (Variable, Relative),
  681. * Report Size (5),
  682. * Report Count (1),
  683. * Input (Constant, Variable, Relative),
  684. * End Collection
  685. */
  686. /* Size of the original report descriptor of Media Tablet 14.1 inch */
  687. #define MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE 309
  688. /*
  689. * Fixed Media Tablet 14.1 inch descriptor.
  690. * It is fixed similarly to the Media Tablet 10.6 inch descriptor.
  691. */
  692. static __u8 media_tablet_14_1_inch_rdesc_fixed[] = {
  693. 0x05, 0x0D, /* Usage Page (Digitizer), */
  694. 0x09, 0x02, /* Usage (Pen), */
  695. 0xA1, 0x01, /* Collection (Application), */
  696. 0x85, 0x10, /* Report ID (16), */
  697. 0x09, 0x20, /* Usage (Stylus), */
  698. 0xA0, /* Collection (Physical), */
  699. 0x09, 0x42, /* Usage (Tip Switch), */
  700. 0x09, 0x44, /* Usage (Barrel Switch), */
  701. 0x09, 0x46, /* Usage (Tablet Pick), */
  702. 0x15, 0x01, /* Logical Minimum (1), */
  703. 0x25, 0x03, /* Logical Maximum (3), */
  704. 0x75, 0x04, /* Report Size (4), */
  705. 0x95, 0x01, /* Report Count (1), */
  706. 0x80, /* Input, */
  707. 0x75, 0x01, /* Report Size (1), */
  708. 0x09, 0x32, /* Usage (In Range), */
  709. 0x14, /* Logical Minimum (0), */
  710. 0x25, 0x01, /* Logical Maximum (1), */
  711. 0x95, 0x01, /* Report Count (1), */
  712. 0x81, 0x02, /* Input (Variable), */
  713. 0x95, 0x03, /* Report Count (3), */
  714. 0x81, 0x03, /* Input (Constant, Variable), */
  715. 0x75, 0x10, /* Report Size (16), */
  716. 0x95, 0x01, /* Report Count (1), */
  717. 0x14, /* Logical Minimum (0), */
  718. 0xA4, /* Push, */
  719. 0x05, 0x01, /* Usage Page (Desktop), */
  720. 0x65, 0x13, /* Unit (Inch), */
  721. 0x55, 0xFD, /* Unit Exponent (-3), */
  722. 0x34, /* Physical Minimum (0), */
  723. 0x09, 0x30, /* Usage (X), */
  724. 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */
  725. 0x26, 0xFF, 0x3F, /* Logical Maximum (16383), */
  726. 0x81, 0x02, /* Input (Variable), */
  727. 0x09, 0x31, /* Usage (Y), */
  728. 0x46, 0x52, 0x1C, /* Physical Maximum (7250), */
  729. 0x26, 0xFF, 0x3F, /* Logical Maximum (16383), */
  730. 0x81, 0x02, /* Input (Variable), */
  731. 0xB4, /* Pop, */
  732. 0x09, 0x30, /* Usage (Tip Pressure), */
  733. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  734. 0x81, 0x02, /* Input (Variable), */
  735. 0xC0, /* End Collection, */
  736. 0xC0, /* End Collection, */
  737. 0x05, 0x01, /* Usage Page (Desktop), */
  738. 0x09, 0x02, /* Usage (Mouse), */
  739. 0xA1, 0x01, /* Collection (Application), */
  740. 0x85, 0x01, /* Report ID (1), */
  741. 0x09, 0x01, /* Usage (Pointer), */
  742. 0xA0, /* Collection (Physical), */
  743. 0x75, 0x08, /* Report Size (8), */
  744. 0x95, 0x03, /* Report Count (3), */
  745. 0x81, 0x03, /* Input (Constant, Variable), */
  746. 0x95, 0x02, /* Report Count (2), */
  747. 0x15, 0xFF, /* Logical Minimum (-1), */
  748. 0x25, 0x01, /* Logical Maximum (1), */
  749. 0x09, 0x38, /* Usage (Wheel), */
  750. 0x0B, 0x38, 0x02, /* Usage (Consumer AC Pan), */
  751. 0x0C, 0x00,
  752. 0x81, 0x06, /* Input (Variable, Relative), */
  753. 0xC0, /* End Collection, */
  754. 0xC0, /* End Collection, */
  755. 0x05, 0x0C, /* Usage Page (Consumer), */
  756. 0x09, 0x01, /* Usage (Consumer Control), */
  757. 0xA1, 0x01, /* Collection (Application), */
  758. 0x85, 0x0D, /* Report ID (13), */
  759. 0x95, 0x01, /* Report Count (1), */
  760. 0x75, 0x10, /* Report Size (16), */
  761. 0x81, 0x03, /* Input (Constant, Variable), */
  762. 0x0A, 0x2F, 0x02, /* Usage (AC Zoom), */
  763. 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
  764. 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
  765. 0x09, 0xB6, /* Usage (Scan Previous Track), */
  766. 0x09, 0xB5, /* Usage (Scan Next Track), */
  767. 0x08, /* Usage (00h), */
  768. 0x08, /* Usage (00h), */
  769. 0x08, /* Usage (00h), */
  770. 0x08, /* Usage (00h), */
  771. 0x08, /* Usage (00h), */
  772. 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
  773. 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
  774. 0x15, 0x0C, /* Logical Minimum (12), */
  775. 0x25, 0x17, /* Logical Maximum (23), */
  776. 0x75, 0x05, /* Report Size (5), */
  777. 0x80, /* Input, */
  778. 0x75, 0x03, /* Report Size (3), */
  779. 0x81, 0x03, /* Input (Constant, Variable), */
  780. 0x75, 0x20, /* Report Size (32), */
  781. 0x81, 0x03, /* Input (Constant, Variable), */
  782. 0xC0, /* End Collection, */
  783. 0x09, 0x01, /* Usage (Consumer Control), */
  784. 0xA1, 0x01, /* Collection (Application), */
  785. 0x85, 0x0C, /* Report ID (12), */
  786. 0x75, 0x01, /* Report Size (1), */
  787. 0x09, 0xE9, /* Usage (Volume Inc), */
  788. 0x09, 0xEA, /* Usage (Volume Dec), */
  789. 0x09, 0xE2, /* Usage (Mute), */
  790. 0x14, /* Logical Minimum (0), */
  791. 0x25, 0x01, /* Logical Maximum (1), */
  792. 0x95, 0x03, /* Report Count (3), */
  793. 0x81, 0x06, /* Input (Variable, Relative), */
  794. 0x75, 0x05, /* Report Size (5), */
  795. 0x81, 0x03, /* Input (Constant, Variable), */
  796. 0xC0 /* End Collection */
  797. };
  798. static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  799. unsigned int *rsize)
  800. {
  801. switch (hdev->product) {
  802. case USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH:
  803. if (*rsize == SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE) {
  804. rdesc = slim_tablet_5_8_inch_rdesc_fixed;
  805. *rsize = sizeof(slim_tablet_5_8_inch_rdesc_fixed);
  806. }
  807. break;
  808. case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH:
  809. if (*rsize == MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE) {
  810. rdesc = media_tablet_10_6_inch_rdesc_fixed;
  811. *rsize = sizeof(media_tablet_10_6_inch_rdesc_fixed);
  812. }
  813. break;
  814. case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH:
  815. if (*rsize == MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE) {
  816. rdesc = media_tablet_14_1_inch_rdesc_fixed;
  817. *rsize = sizeof(media_tablet_14_1_inch_rdesc_fixed);
  818. }
  819. break;
  820. }
  821. return rdesc;
  822. }
  823. static const struct hid_device_id waltop_devices[] = {
  824. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
  825. USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
  826. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
  827. USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
  828. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
  829. USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
  830. { }
  831. };
  832. MODULE_DEVICE_TABLE(hid, waltop_devices);
  833. static struct hid_driver waltop_driver = {
  834. .name = "waltop",
  835. .id_table = waltop_devices,
  836. .report_fixup = waltop_report_fixup,
  837. };
  838. static int __init waltop_init(void)
  839. {
  840. return hid_register_driver(&waltop_driver);
  841. }
  842. static void __exit waltop_exit(void)
  843. {
  844. hid_unregister_driver(&waltop_driver);
  845. }
  846. module_init(waltop_init);
  847. module_exit(waltop_exit);
  848. MODULE_LICENSE("GPL");