hid-uclogic.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  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 "hid-ids.h"
  16. /*
  17. * The original descriptors of WPXXXXU tablets have three report IDs, of
  18. * which only two are used (8 and 9), and the remaining (7) seems to have
  19. * the originally intended pen description which was abandoned for some
  20. * reason. From this unused description it is possible to extract the
  21. * actual physical extents and resolution. All the models use the same
  22. * descriptor with different extents for the unused report ID.
  23. *
  24. * Here it is:
  25. *
  26. * Usage Page (Digitizer), ; Digitizer (0Dh)
  27. * Usage (Pen), ; Pen (02h, application collection)
  28. * Collection (Application),
  29. * Report ID (7),
  30. * Usage (Stylus), ; Stylus (20h, logical collection)
  31. * Collection (Physical),
  32. * Usage (Tip Switch), ; Tip switch (42h, momentary control)
  33. * Usage (Barrel Switch), ; Barrel switch (44h, momentary control)
  34. * Usage (Eraser), ; Eraser (45h, momentary control)
  35. * Logical Minimum (0),
  36. * Logical Maximum (1),
  37. * Report Size (1),
  38. * Report Count (3),
  39. * Input (Variable),
  40. * Report Count (3),
  41. * Input (Constant, Variable),
  42. * Usage (In Range), ; In range (32h, momentary control)
  43. * Report Count (1),
  44. * Input (Variable),
  45. * Report Count (1),
  46. * Input (Constant, Variable),
  47. * Usage Page (Desktop), ; Generic desktop controls (01h)
  48. * Usage (X), ; X (30h, dynamic value)
  49. * Report Size (16),
  50. * Report Count (1),
  51. * Push,
  52. * Unit Exponent (13),
  53. * Unit (Inch^3),
  54. * Physical Minimum (0),
  55. * Physical Maximum (Xpm),
  56. * Logical Maximum (Xlm),
  57. * Input (Variable),
  58. * Usage (Y), ; Y (31h, dynamic value)
  59. * Physical Maximum (Ypm),
  60. * Logical Maximum (Ylm),
  61. * Input (Variable),
  62. * Pop,
  63. * Usage Page (Digitizer), ; Digitizer (0Dh)
  64. * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
  65. * Logical Maximum (1023),
  66. * Input (Variable),
  67. * Report Size (16),
  68. * End Collection,
  69. * End Collection,
  70. * Usage Page (Desktop), ; Generic desktop controls (01h)
  71. * Usage (Mouse), ; Mouse (02h, application collection)
  72. * Collection (Application),
  73. * Report ID (8),
  74. * Usage (Pointer), ; Pointer (01h, physical collection)
  75. * Collection (Physical),
  76. * Usage Page (Button), ; Button (09h)
  77. * Usage Minimum (01h),
  78. * Usage Maximum (03h),
  79. * Logical Minimum (0),
  80. * Logical Maximum (1),
  81. * Report Count (3),
  82. * Report Size (1),
  83. * Input (Variable),
  84. * Report Count (5),
  85. * Input (Constant),
  86. * Usage Page (Desktop), ; Generic desktop controls (01h)
  87. * Usage (X), ; X (30h, dynamic value)
  88. * Usage (Y), ; Y (31h, dynamic value)
  89. * Usage (Wheel), ; Wheel (38h, dynamic value)
  90. * Usage (00h),
  91. * Logical Minimum (-127),
  92. * Logical Maximum (127),
  93. * Report Size (8),
  94. * Report Count (4),
  95. * Input (Variable, Relative),
  96. * End Collection,
  97. * End Collection,
  98. * Usage Page (Desktop), ; Generic desktop controls (01h)
  99. * Usage (Mouse), ; Mouse (02h, application collection)
  100. * Collection (Application),
  101. * Report ID (9),
  102. * Usage (Pointer), ; Pointer (01h, physical collection)
  103. * Collection (Physical),
  104. * Usage Page (Button), ; Button (09h)
  105. * Usage Minimum (01h),
  106. * Usage Maximum (03h),
  107. * Logical Minimum (0),
  108. * Logical Maximum (1),
  109. * Report Count (3),
  110. * Report Size (1),
  111. * Input (Variable),
  112. * Report Count (5),
  113. * Input (Constant),
  114. * Usage Page (Desktop), ; Generic desktop controls (01h)
  115. * Usage (X), ; X (30h, dynamic value)
  116. * Usage (Y), ; Y (31h, dynamic value)
  117. * Logical Minimum (0),
  118. * Logical Maximum (32767),
  119. * Physical Minimum (0),
  120. * Physical Maximum (32767),
  121. * Report Count (2),
  122. * Report Size (16),
  123. * Input (Variable),
  124. * Usage Page (Digitizer), ; Digitizer (0Dh)
  125. * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
  126. * Logical Maximum (1023),
  127. * Report Count (1),
  128. * Report Size (16),
  129. * Input (Variable),
  130. * End Collection,
  131. * End Collection
  132. *
  133. * Here are the extents values for the WPXXXXU models:
  134. *
  135. * Xpm Xlm Ypm Ylm
  136. * WP4030U 4000 8000 3000 6000
  137. * WP5540U 5500 11000 4000 8000
  138. * WP8060U 8000 16000 6000 12000
  139. *
  140. * This suggests that all of them have 2000 LPI resolution, as advertised.
  141. */
  142. /* Size of the original descriptor of WPXXXXU tablets */
  143. #define WPXXXXU_RDESC_ORIG_SIZE 212
  144. /*
  145. * Fixed WP4030U report descriptor.
  146. * Although the hardware might actually support it, the mouse description
  147. * has been removed, since there seems to be no devices having one and it
  148. * wouldn't make much sense because of the working area size.
  149. */
  150. static __u8 wp4030u_rdesc_fixed[] = {
  151. 0x05, 0x0D, /* Usage Page (Digitizer), */
  152. 0x09, 0x02, /* Usage (Pen), */
  153. 0xA1, 0x01, /* Collection (Application), */
  154. 0x85, 0x09, /* Report ID (9), */
  155. 0x09, 0x20, /* Usage (Stylus), */
  156. 0xA0, /* Collection (Physical), */
  157. 0x75, 0x01, /* Report Size (1), */
  158. 0x09, 0x42, /* Usage (Tip Switch), */
  159. 0x09, 0x44, /* Usage (Barrel Switch), */
  160. 0x09, 0x46, /* Usage (Tablet Pick), */
  161. 0x14, /* Logical Minimum (0), */
  162. 0x25, 0x01, /* Logical Maximum (1), */
  163. 0x95, 0x03, /* Report Count (3), */
  164. 0x81, 0x02, /* Input (Variable), */
  165. 0x95, 0x05, /* Report Count (5), */
  166. 0x81, 0x01, /* Input (Constant), */
  167. 0x75, 0x10, /* Report Size (16), */
  168. 0x95, 0x01, /* Report Count (1), */
  169. 0x14, /* Logical Minimum (0), */
  170. 0xA4, /* Push, */
  171. 0x05, 0x01, /* Usage Page (Desktop), */
  172. 0x55, 0xFD, /* Unit Exponent (-3), */
  173. 0x65, 0x13, /* Unit (Inch), */
  174. 0x34, /* Physical Minimum (0), */
  175. 0x09, 0x30, /* Usage (X), */
  176. 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */
  177. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  178. 0x81, 0x02, /* Input (Variable), */
  179. 0x09, 0x31, /* Usage (Y), */
  180. 0x46, 0xB8, 0x0B, /* Physical Maximum (3000), */
  181. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  182. 0x81, 0x02, /* Input (Variable), */
  183. 0xB4, /* Pop, */
  184. 0x09, 0x30, /* Usage (Tip Pressure), */
  185. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  186. 0x81, 0x02, /* Input (Variable), */
  187. 0xC0, /* End Collection, */
  188. 0xC0 /* End Collection */
  189. };
  190. /* Fixed WP5540U report descriptor */
  191. static __u8 wp5540u_rdesc_fixed[] = {
  192. 0x05, 0x0D, /* Usage Page (Digitizer), */
  193. 0x09, 0x02, /* Usage (Pen), */
  194. 0xA1, 0x01, /* Collection (Application), */
  195. 0x85, 0x09, /* Report ID (9), */
  196. 0x09, 0x20, /* Usage (Stylus), */
  197. 0xA0, /* Collection (Physical), */
  198. 0x75, 0x01, /* Report Size (1), */
  199. 0x09, 0x42, /* Usage (Tip Switch), */
  200. 0x09, 0x44, /* Usage (Barrel Switch), */
  201. 0x09, 0x46, /* Usage (Tablet Pick), */
  202. 0x14, /* Logical Minimum (0), */
  203. 0x25, 0x01, /* Logical Maximum (1), */
  204. 0x95, 0x03, /* Report Count (3), */
  205. 0x81, 0x02, /* Input (Variable), */
  206. 0x95, 0x05, /* Report Count (5), */
  207. 0x81, 0x01, /* Input (Constant), */
  208. 0x75, 0x10, /* Report Size (16), */
  209. 0x95, 0x01, /* Report Count (1), */
  210. 0x14, /* Logical Minimum (0), */
  211. 0xA4, /* Push, */
  212. 0x05, 0x01, /* Usage Page (Desktop), */
  213. 0x55, 0xFD, /* Unit Exponent (-3), */
  214. 0x65, 0x13, /* Unit (Inch), */
  215. 0x34, /* Physical Minimum (0), */
  216. 0x09, 0x30, /* Usage (X), */
  217. 0x46, 0x7C, 0x15, /* Physical Maximum (5500), */
  218. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  219. 0x81, 0x02, /* Input (Variable), */
  220. 0x09, 0x31, /* Usage (Y), */
  221. 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */
  222. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  223. 0x81, 0x02, /* Input (Variable), */
  224. 0xB4, /* Pop, */
  225. 0x09, 0x30, /* Usage (Tip Pressure), */
  226. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  227. 0x81, 0x02, /* Input (Variable), */
  228. 0xC0, /* End Collection, */
  229. 0xC0, /* End Collection, */
  230. 0x05, 0x01, /* Usage Page (Desktop), */
  231. 0x09, 0x02, /* Usage (Mouse), */
  232. 0xA1, 0x01, /* Collection (Application), */
  233. 0x85, 0x08, /* Report ID (8), */
  234. 0x09, 0x01, /* Usage (Pointer), */
  235. 0xA0, /* Collection (Physical), */
  236. 0x75, 0x01, /* Report Size (1), */
  237. 0x05, 0x09, /* Usage Page (Button), */
  238. 0x19, 0x01, /* Usage Minimum (01h), */
  239. 0x29, 0x03, /* Usage Maximum (03h), */
  240. 0x14, /* Logical Minimum (0), */
  241. 0x25, 0x01, /* Logical Maximum (1), */
  242. 0x95, 0x03, /* Report Count (3), */
  243. 0x81, 0x02, /* Input (Variable), */
  244. 0x95, 0x05, /* Report Count (5), */
  245. 0x81, 0x01, /* Input (Constant), */
  246. 0x05, 0x01, /* Usage Page (Desktop), */
  247. 0x75, 0x08, /* Report Size (8), */
  248. 0x09, 0x30, /* Usage (X), */
  249. 0x09, 0x31, /* Usage (Y), */
  250. 0x15, 0x81, /* Logical Minimum (-127), */
  251. 0x25, 0x7F, /* Logical Maximum (127), */
  252. 0x95, 0x02, /* Report Count (2), */
  253. 0x81, 0x06, /* Input (Variable, Relative), */
  254. 0x09, 0x38, /* Usage (Wheel), */
  255. 0x15, 0xFF, /* Logical Minimum (-1), */
  256. 0x25, 0x01, /* Logical Maximum (1), */
  257. 0x95, 0x01, /* Report Count (1), */
  258. 0x81, 0x06, /* Input (Variable, Relative), */
  259. 0x81, 0x01, /* Input (Constant), */
  260. 0xC0, /* End Collection, */
  261. 0xC0 /* End Collection */
  262. };
  263. /* Fixed WP8060U report descriptor */
  264. static __u8 wp8060u_rdesc_fixed[] = {
  265. 0x05, 0x0D, /* Usage Page (Digitizer), */
  266. 0x09, 0x02, /* Usage (Pen), */
  267. 0xA1, 0x01, /* Collection (Application), */
  268. 0x85, 0x09, /* Report ID (9), */
  269. 0x09, 0x20, /* Usage (Stylus), */
  270. 0xA0, /* Collection (Physical), */
  271. 0x75, 0x01, /* Report Size (1), */
  272. 0x09, 0x42, /* Usage (Tip Switch), */
  273. 0x09, 0x44, /* Usage (Barrel Switch), */
  274. 0x09, 0x46, /* Usage (Tablet Pick), */
  275. 0x14, /* Logical Minimum (0), */
  276. 0x25, 0x01, /* Logical Maximum (1), */
  277. 0x95, 0x03, /* Report Count (3), */
  278. 0x81, 0x02, /* Input (Variable), */
  279. 0x95, 0x05, /* Report Count (5), */
  280. 0x81, 0x01, /* Input (Constant), */
  281. 0x75, 0x10, /* Report Size (16), */
  282. 0x95, 0x01, /* Report Count (1), */
  283. 0x14, /* Logical Minimum (0), */
  284. 0xA4, /* Push, */
  285. 0x05, 0x01, /* Usage Page (Desktop), */
  286. 0x55, 0xFD, /* Unit Exponent (-3), */
  287. 0x65, 0x13, /* Unit (Inch), */
  288. 0x34, /* Physical Minimum (0), */
  289. 0x09, 0x30, /* Usage (X), */
  290. 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
  291. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  292. 0x81, 0x02, /* Input (Variable), */
  293. 0x09, 0x31, /* Usage (Y), */
  294. 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
  295. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  296. 0x81, 0x02, /* Input (Variable), */
  297. 0xB4, /* Pop, */
  298. 0x09, 0x30, /* Usage (Tip Pressure), */
  299. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  300. 0x81, 0x02, /* Input (Variable), */
  301. 0xC0, /* End Collection, */
  302. 0xC0, /* End Collection, */
  303. 0x05, 0x01, /* Usage Page (Desktop), */
  304. 0x09, 0x02, /* Usage (Mouse), */
  305. 0xA1, 0x01, /* Collection (Application), */
  306. 0x85, 0x08, /* Report ID (8), */
  307. 0x09, 0x01, /* Usage (Pointer), */
  308. 0xA0, /* Collection (Physical), */
  309. 0x75, 0x01, /* Report Size (1), */
  310. 0x05, 0x09, /* Usage Page (Button), */
  311. 0x19, 0x01, /* Usage Minimum (01h), */
  312. 0x29, 0x03, /* Usage Maximum (03h), */
  313. 0x14, /* Logical Minimum (0), */
  314. 0x25, 0x01, /* Logical Maximum (1), */
  315. 0x95, 0x03, /* Report Count (3), */
  316. 0x81, 0x02, /* Input (Variable), */
  317. 0x95, 0x05, /* Report Count (5), */
  318. 0x81, 0x01, /* Input (Constant), */
  319. 0x05, 0x01, /* Usage Page (Desktop), */
  320. 0x75, 0x08, /* Report Size (8), */
  321. 0x09, 0x30, /* Usage (X), */
  322. 0x09, 0x31, /* Usage (Y), */
  323. 0x15, 0x81, /* Logical Minimum (-127), */
  324. 0x25, 0x7F, /* Logical Maximum (127), */
  325. 0x95, 0x02, /* Report Count (2), */
  326. 0x81, 0x06, /* Input (Variable, Relative), */
  327. 0x09, 0x38, /* Usage (Wheel), */
  328. 0x15, 0xFF, /* Logical Minimum (-1), */
  329. 0x25, 0x01, /* Logical Maximum (1), */
  330. 0x95, 0x01, /* Report Count (1), */
  331. 0x81, 0x06, /* Input (Variable, Relative), */
  332. 0x81, 0x01, /* Input (Constant), */
  333. 0xC0, /* End Collection, */
  334. 0xC0 /* End Collection */
  335. };
  336. /*
  337. * Original WP1062 report descriptor.
  338. *
  339. * Only report ID 9 is actually used.
  340. *
  341. * Usage Page (Digitizer), ; Digitizer (0Dh)
  342. * Usage (Pen), ; Pen (02h, application collection)
  343. * Collection (Application),
  344. * Report ID (7),
  345. * Usage (Stylus), ; Stylus (20h, logical collection)
  346. * Collection (Physical),
  347. * Usage (Tip Switch), ; Tip switch (42h, momentary control)
  348. * Usage (Barrel Switch), ; Barrel switch (44h, momentary control)
  349. * Usage (Eraser), ; Eraser (45h, momentary control)
  350. * Logical Minimum (0),
  351. * Logical Maximum (1),
  352. * Report Size (1),
  353. * Report Count (3),
  354. * Input (Variable),
  355. * Report Count (3),
  356. * Input (Constant, Variable),
  357. * Usage (In Range), ; In range (32h, momentary control)
  358. * Report Count (1),
  359. * Input (Variable),
  360. * Report Count (1),
  361. * Input (Constant, Variable),
  362. * Usage Page (Desktop), ; Generic desktop controls (01h)
  363. * Usage (X), ; X (30h, dynamic value)
  364. * Report Size (16),
  365. * Report Count (1),
  366. * Push,
  367. * Unit Exponent (13),
  368. * Unit (Inch),
  369. * Physical Minimum (0),
  370. * Physical Maximum (10000),
  371. * Logical Maximum (20000),
  372. * Input (Variable),
  373. * Usage (Y), ; Y (31h, dynamic value)
  374. * Physical Maximum (6583),
  375. * Logical Maximum (13166),
  376. * Input (Variable),
  377. * Pop,
  378. * Usage Page (Digitizer), ; Digitizer (0Dh)
  379. * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
  380. * Logical Maximum (1023),
  381. * Input (Variable),
  382. * Report Size (16),
  383. * End Collection,
  384. * End Collection,
  385. * Usage Page (Desktop), ; Generic desktop controls (01h)
  386. * Usage (Mouse), ; Mouse (02h, application collection)
  387. * Collection (Application),
  388. * Report ID (8),
  389. * Usage (Pointer), ; Pointer (01h, physical collection)
  390. * Collection (Physical),
  391. * Usage Page (Button), ; Button (09h)
  392. * Usage Minimum (01h),
  393. * Usage Maximum (03h),
  394. * Logical Minimum (0),
  395. * Logical Maximum (1),
  396. * Report Count (3),
  397. * Report Size (1),
  398. * Input (Variable),
  399. * Report Count (5),
  400. * Input (Constant),
  401. * Usage Page (Desktop), ; Generic desktop controls (01h)
  402. * Usage (X), ; X (30h, dynamic value)
  403. * Usage (Y), ; Y (31h, dynamic value)
  404. * Usage (Wheel), ; Wheel (38h, dynamic value)
  405. * Usage (00h),
  406. * Logical Minimum (-127),
  407. * Logical Maximum (127),
  408. * Report Size (8),
  409. * Report Count (4),
  410. * Input (Variable, Relative),
  411. * End Collection,
  412. * End Collection,
  413. * Usage Page (Desktop), ; Generic desktop controls (01h)
  414. * Usage (Mouse), ; Mouse (02h, application collection)
  415. * Collection (Application),
  416. * Report ID (9),
  417. * Usage (Pointer), ; Pointer (01h, physical collection)
  418. * Collection (Physical),
  419. * Usage Page (Button), ; Button (09h)
  420. * Usage Minimum (01h),
  421. * Usage Maximum (03h),
  422. * Logical Minimum (0),
  423. * Logical Maximum (1),
  424. * Report Count (3),
  425. * Report Size (1),
  426. * Input (Variable),
  427. * Report Count (4),
  428. * Input (Constant),
  429. * Usage Page (Digitizer), ; Digitizer (0Dh)
  430. * Usage (In Range), ; In range (32h, momentary control)
  431. * Report Count (1),
  432. * Input (Variable),
  433. * Usage Page (Desktop), ; Generic desktop controls (01h)
  434. * Usage (X), ; X (30h, dynamic value)
  435. * Report Size (16),
  436. * Report Count (1),
  437. * Push,
  438. * Unit Exponent (13),
  439. * Unit (Inch),
  440. * Physical Minimum (0),
  441. * Physical Maximum (10000),
  442. * Logical Maximum (20000),
  443. * Input (Variable),
  444. * Usage (Y), ; Y (31h, dynamic value)
  445. * Physical Maximum (6583),
  446. * Logical Maximum (13166),
  447. * Input (Variable),
  448. * Pop,
  449. * Usage Page (Digitizer), ; Digitizer (0Dh)
  450. * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
  451. * Logical Maximum (1023),
  452. * Report Count (1),
  453. * Report Size (16),
  454. * Input (Variable),
  455. * End Collection,
  456. * End Collection,
  457. * Usage Page (Desktop), ; Generic desktop controls (01h)
  458. * Usage (00h),
  459. * Collection (Application),
  460. * Report ID (4),
  461. * Logical Minimum (0),
  462. * Logical Maximum (255),
  463. * Usage (00h),
  464. * Report Size (8),
  465. * Report Count (3),
  466. * Feature (Variable),
  467. * End Collection
  468. */
  469. /* Size of the original descriptor of WP1062 tablet */
  470. #define WP1062_RDESC_ORIG_SIZE 254
  471. /*
  472. * Fixed WP1062 report descriptor.
  473. *
  474. * Removed unused reports, corrected second barrel button usage code, physical
  475. * units.
  476. */
  477. static __u8 wp1062_rdesc_fixed[] = {
  478. 0x05, 0x0D, /* Usage Page (Digitizer), */
  479. 0x09, 0x02, /* Usage (Pen), */
  480. 0xA1, 0x01, /* Collection (Application), */
  481. 0x85, 0x09, /* Report ID (9), */
  482. 0x09, 0x20, /* Usage (Stylus), */
  483. 0xA0, /* Collection (Physical), */
  484. 0x75, 0x01, /* Report Size (1), */
  485. 0x09, 0x42, /* Usage (Tip Switch), */
  486. 0x09, 0x44, /* Usage (Barrel Switch), */
  487. 0x09, 0x46, /* Usage (Tablet Pick), */
  488. 0x14, /* Logical Minimum (0), */
  489. 0x25, 0x01, /* Logical Maximum (1), */
  490. 0x95, 0x03, /* Report Count (3), */
  491. 0x81, 0x02, /* Input (Variable), */
  492. 0x95, 0x04, /* Report Count (4), */
  493. 0x81, 0x01, /* Input (Constant), */
  494. 0x09, 0x32, /* Usage (In Range), */
  495. 0x95, 0x01, /* Report Count (1), */
  496. 0x81, 0x02, /* Input (Variable), */
  497. 0x75, 0x10, /* Report Size (16), */
  498. 0x95, 0x01, /* Report Count (1), */
  499. 0x14, /* Logical Minimum (0), */
  500. 0xA4, /* Push, */
  501. 0x05, 0x01, /* Usage Page (Desktop), */
  502. 0x55, 0xFD, /* Unit Exponent (-3), */
  503. 0x65, 0x13, /* Unit (Inch), */
  504. 0x34, /* Physical Minimum (0), */
  505. 0x09, 0x30, /* Usage (X), */
  506. 0x46, 0x10, 0x27, /* Physical Maximum (10000), */
  507. 0x26, 0x20, 0x4E, /* Logical Maximum (20000), */
  508. 0x81, 0x02, /* Input (Variable), */
  509. 0x09, 0x31, /* Usage (Y), */
  510. 0x46, 0xB7, 0x19, /* Physical Maximum (6583), */
  511. 0x26, 0x6E, 0x33, /* Logical Maximum (13166), */
  512. 0x81, 0x02, /* Input (Variable), */
  513. 0xB4, /* Pop, */
  514. 0x09, 0x30, /* Usage (Tip Pressure), */
  515. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  516. 0x81, 0x02, /* Input (Variable), */
  517. 0xC0, /* End Collection, */
  518. 0xC0 /* End Collection */
  519. };
  520. /*
  521. * Original PF1209 report descriptor.
  522. *
  523. * The descriptor is similar to WPXXXXU descriptors, with an addition of a
  524. * feature report (ID 4) of unknown purpose.
  525. *
  526. * Although the advertised resolution is 4000 LPI the unused report ID
  527. * (taken from WPXXXXU, it seems) states 2000 LPI, but it is probably
  528. * incorrect and is a result of blind copying without understanding. Anyway
  529. * the real logical extents are always scaled to 0..32767, which IMHO spoils
  530. * the precision.
  531. *
  532. * Usage Page (Digitizer), ; Digitizer (0Dh)
  533. * Usage (Pen), ; Pen (02h, application collection)
  534. * Collection (Application),
  535. * Report ID (7),
  536. * Usage (Stylus), ; Stylus (20h, logical collection)
  537. * Collection (Physical),
  538. * Usage (Tip Switch), ; Tip switch (42h, momentary control)
  539. * Usage (Barrel Switch), ; Barrel switch (44h, momentary control)
  540. * Usage (Eraser), ; Eraser (45h, momentary control)
  541. * Logical Minimum (0),
  542. * Logical Maximum (1),
  543. * Report Size (1),
  544. * Report Count (3),
  545. * Input (Variable),
  546. * Report Count (3),
  547. * Input (Constant, Variable),
  548. * Usage (In Range), ; In range (32h, momentary control)
  549. * Report Count (1),
  550. * Input (Variable),
  551. * Report Count (1),
  552. * Input (Constant, Variable),
  553. * Usage Page (Desktop), ; Generic desktop controls (01h)
  554. * Usage (X), ; X (30h, dynamic value)
  555. * Report Size (16),
  556. * Report Count (1),
  557. * Push,
  558. * Unit Exponent (13),
  559. * Unit (Inch^3),
  560. * Physical Minimum (0),
  561. * Physical Maximum (12000),
  562. * Logical Maximum (24000),
  563. * Input (Variable),
  564. * Usage (Y), ; Y (31h, dynamic value)
  565. * Physical Maximum (9000),
  566. * Logical Maximum (18000),
  567. * Input (Variable),
  568. * Pop,
  569. * Usage Page (Digitizer), ; Digitizer (0Dh)
  570. * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
  571. * Logical Maximum (1023),
  572. * Input (Variable),
  573. * Report Size (16),
  574. * End Collection,
  575. * End Collection,
  576. * Usage Page (Desktop), ; Generic desktop controls (01h)
  577. * Usage (Mouse), ; Mouse (02h, application collection)
  578. * Collection (Application),
  579. * Report ID (8),
  580. * Usage (Pointer), ; Pointer (01h, physical collection)
  581. * Collection (Physical),
  582. * Usage Page (Button), ; Button (09h)
  583. * Usage Minimum (01h),
  584. * Usage Maximum (03h),
  585. * Logical Minimum (0),
  586. * Logical Maximum (1),
  587. * Report Count (3),
  588. * Report Size (1),
  589. * Input (Variable),
  590. * Report Count (5),
  591. * Input (Constant),
  592. * Usage Page (Desktop), ; Generic desktop controls (01h)
  593. * Usage (X), ; X (30h, dynamic value)
  594. * Usage (Y), ; Y (31h, dynamic value)
  595. * Usage (Wheel), ; Wheel (38h, dynamic value)
  596. * Usage (00h),
  597. * Logical Minimum (-127),
  598. * Logical Maximum (127),
  599. * Report Size (8),
  600. * Report Count (4),
  601. * Input (Variable, Relative),
  602. * End Collection,
  603. * End Collection,
  604. * Usage Page (Desktop), ; Generic desktop controls (01h)
  605. * Usage (Mouse), ; Mouse (02h, application collection)
  606. * Collection (Application),
  607. * Report ID (9),
  608. * Usage (Pointer), ; Pointer (01h, physical collection)
  609. * Collection (Physical),
  610. * Usage Page (Button), ; Button (09h)
  611. * Usage Minimum (01h),
  612. * Usage Maximum (03h),
  613. * Logical Minimum (0),
  614. * Logical Maximum (1),
  615. * Report Count (3),
  616. * Report Size (1),
  617. * Input (Variable),
  618. * Report Count (5),
  619. * Input (Constant),
  620. * Usage Page (Desktop), ; Generic desktop controls (01h)
  621. * Usage (X), ; X (30h, dynamic value)
  622. * Usage (Y), ; Y (31h, dynamic value)
  623. * Logical Minimum (0),
  624. * Logical Maximum (32767),
  625. * Physical Minimum (0),
  626. * Physical Maximum (32767),
  627. * Report Count (2),
  628. * Report Size (16),
  629. * Input (Variable),
  630. * Usage Page (Digitizer), ; Digitizer (0Dh)
  631. * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
  632. * Logical Maximum (1023),
  633. * Report Count (1),
  634. * Report Size (16),
  635. * Input (Variable),
  636. * End Collection,
  637. * End Collection,
  638. * Usage Page (Desktop), ; Generic desktop controls (01h)
  639. * Usage (00h),
  640. * Collection (Application),
  641. * Report ID (4),
  642. * Logical Minimum (0),
  643. * Logical Maximum (255),
  644. * Usage (00h),
  645. * Report Size (8),
  646. * Report Count (3),
  647. * Feature (Variable),
  648. * End Collection
  649. */
  650. /* Size of the original descriptor of PF1209 tablet */
  651. #define PF1209_RDESC_ORIG_SIZE 234
  652. /*
  653. * Fixed PF1209 report descriptor
  654. *
  655. * The descriptor is fixed similarly to WP5540U and WP8060U, plus the
  656. * feature report is removed, because its purpose is unknown and it is of no
  657. * use to the generic HID driver anyway for now.
  658. */
  659. static __u8 pf1209_rdesc_fixed[] = {
  660. 0x05, 0x0D, /* Usage Page (Digitizer), */
  661. 0x09, 0x02, /* Usage (Pen), */
  662. 0xA1, 0x01, /* Collection (Application), */
  663. 0x85, 0x09, /* Report ID (9), */
  664. 0x09, 0x20, /* Usage (Stylus), */
  665. 0xA0, /* Collection (Physical), */
  666. 0x75, 0x01, /* Report Size (1), */
  667. 0x09, 0x42, /* Usage (Tip Switch), */
  668. 0x09, 0x44, /* Usage (Barrel Switch), */
  669. 0x09, 0x46, /* Usage (Tablet Pick), */
  670. 0x14, /* Logical Minimum (0), */
  671. 0x25, 0x01, /* Logical Maximum (1), */
  672. 0x95, 0x03, /* Report Count (3), */
  673. 0x81, 0x02, /* Input (Variable), */
  674. 0x95, 0x05, /* Report Count (5), */
  675. 0x81, 0x01, /* Input (Constant), */
  676. 0x75, 0x10, /* Report Size (16), */
  677. 0x95, 0x01, /* Report Count (1), */
  678. 0x14, /* Logical Minimum (0), */
  679. 0xA4, /* Push, */
  680. 0x05, 0x01, /* Usage Page (Desktop), */
  681. 0x55, 0xFD, /* Unit Exponent (-3), */
  682. 0x65, 0x13, /* Unit (Inch), */
  683. 0x34, /* Physical Minimum (0), */
  684. 0x09, 0x30, /* Usage (X), */
  685. 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */
  686. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  687. 0x81, 0x02, /* Input (Variable), */
  688. 0x09, 0x31, /* Usage (Y), */
  689. 0x46, 0x28, 0x23, /* Physical Maximum (9000), */
  690. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  691. 0x81, 0x02, /* Input (Variable), */
  692. 0xB4, /* Pop, */
  693. 0x09, 0x30, /* Usage (Tip Pressure), */
  694. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  695. 0x81, 0x02, /* Input (Variable), */
  696. 0xC0, /* End Collection, */
  697. 0xC0, /* End Collection, */
  698. 0x05, 0x01, /* Usage Page (Desktop), */
  699. 0x09, 0x02, /* Usage (Mouse), */
  700. 0xA1, 0x01, /* Collection (Application), */
  701. 0x85, 0x08, /* Report ID (8), */
  702. 0x09, 0x01, /* Usage (Pointer), */
  703. 0xA0, /* Collection (Physical), */
  704. 0x75, 0x01, /* Report Size (1), */
  705. 0x05, 0x09, /* Usage Page (Button), */
  706. 0x19, 0x01, /* Usage Minimum (01h), */
  707. 0x29, 0x03, /* Usage Maximum (03h), */
  708. 0x14, /* Logical Minimum (0), */
  709. 0x25, 0x01, /* Logical Maximum (1), */
  710. 0x95, 0x03, /* Report Count (3), */
  711. 0x81, 0x02, /* Input (Variable), */
  712. 0x95, 0x05, /* Report Count (5), */
  713. 0x81, 0x01, /* Input (Constant), */
  714. 0x05, 0x01, /* Usage Page (Desktop), */
  715. 0x75, 0x08, /* Report Size (8), */
  716. 0x09, 0x30, /* Usage (X), */
  717. 0x09, 0x31, /* Usage (Y), */
  718. 0x15, 0x81, /* Logical Minimum (-127), */
  719. 0x25, 0x7F, /* Logical Maximum (127), */
  720. 0x95, 0x02, /* Report Count (2), */
  721. 0x81, 0x06, /* Input (Variable, Relative), */
  722. 0x09, 0x38, /* Usage (Wheel), */
  723. 0x15, 0xFF, /* Logical Minimum (-1), */
  724. 0x25, 0x01, /* Logical Maximum (1), */
  725. 0x95, 0x01, /* Report Count (1), */
  726. 0x81, 0x06, /* Input (Variable, Relative), */
  727. 0x81, 0x01, /* Input (Constant), */
  728. 0xC0, /* End Collection, */
  729. 0xC0 /* End Collection */
  730. };
  731. static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  732. unsigned int *rsize)
  733. {
  734. switch (hdev->product) {
  735. case USB_DEVICE_ID_UCLOGIC_TABLET_PF1209:
  736. if (*rsize == PF1209_RDESC_ORIG_SIZE) {
  737. rdesc = pf1209_rdesc_fixed;
  738. *rsize = sizeof(pf1209_rdesc_fixed);
  739. }
  740. break;
  741. case USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U:
  742. if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
  743. rdesc = wp4030u_rdesc_fixed;
  744. *rsize = sizeof(wp4030u_rdesc_fixed);
  745. }
  746. break;
  747. case USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U:
  748. if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
  749. rdesc = wp5540u_rdesc_fixed;
  750. *rsize = sizeof(wp5540u_rdesc_fixed);
  751. }
  752. break;
  753. case USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U:
  754. if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
  755. rdesc = wp8060u_rdesc_fixed;
  756. *rsize = sizeof(wp8060u_rdesc_fixed);
  757. }
  758. break;
  759. case USB_DEVICE_ID_UCLOGIC_TABLET_WP1062:
  760. if (*rsize == WP1062_RDESC_ORIG_SIZE) {
  761. rdesc = wp1062_rdesc_fixed;
  762. *rsize = sizeof(wp1062_rdesc_fixed);
  763. }
  764. break;
  765. }
  766. return rdesc;
  767. }
  768. static const struct hid_device_id uclogic_devices[] = {
  769. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  770. USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) },
  771. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  772. USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) },
  773. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  774. USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) },
  775. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  776. USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) },
  777. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  778. USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) },
  779. { }
  780. };
  781. MODULE_DEVICE_TABLE(hid, uclogic_devices);
  782. static struct hid_driver uclogic_driver = {
  783. .name = "uclogic",
  784. .id_table = uclogic_devices,
  785. .report_fixup = uclogic_report_fixup,
  786. };
  787. static int __init uclogic_init(void)
  788. {
  789. return hid_register_driver(&uclogic_driver);
  790. }
  791. static void __exit uclogic_exit(void)
  792. {
  793. hid_unregister_driver(&uclogic_driver);
  794. }
  795. module_init(uclogic_init);
  796. module_exit(uclogic_exit);
  797. MODULE_LICENSE("GPL");