hid-uclogic.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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 PF1209 report descriptor.
  338. *
  339. * The descriptor is similar to WPXXXXU descriptors, with an addition of a
  340. * feature report (ID 4) of unknown purpose.
  341. *
  342. * Although the advertised resolution is 4000 LPI the unused report ID
  343. * (taken from WPXXXXU, it seems) states 2000 LPI, but it is probably
  344. * incorrect and is a result of blind copying without understanding. Anyway
  345. * the real logical extents are always scaled to 0..32767, which IMHO spoils
  346. * the precision.
  347. *
  348. * Usage Page (Digitizer), ; Digitizer (0Dh)
  349. * Usage (Pen), ; Pen (02h, application collection)
  350. * Collection (Application),
  351. * Report ID (7),
  352. * Usage (Stylus), ; Stylus (20h, logical collection)
  353. * Collection (Physical),
  354. * Usage (Tip Switch), ; Tip switch (42h, momentary control)
  355. * Usage (Barrel Switch), ; Barrel switch (44h, momentary control)
  356. * Usage (Eraser), ; Eraser (45h, momentary control)
  357. * Logical Minimum (0),
  358. * Logical Maximum (1),
  359. * Report Size (1),
  360. * Report Count (3),
  361. * Input (Variable),
  362. * Report Count (3),
  363. * Input (Constant, Variable),
  364. * Usage (In Range), ; In range (32h, momentary control)
  365. * Report Count (1),
  366. * Input (Variable),
  367. * Report Count (1),
  368. * Input (Constant, Variable),
  369. * Usage Page (Desktop), ; Generic desktop controls (01h)
  370. * Usage (X), ; X (30h, dynamic value)
  371. * Report Size (16),
  372. * Report Count (1),
  373. * Push,
  374. * Unit Exponent (13),
  375. * Unit (Inch^3),
  376. * Physical Minimum (0),
  377. * Physical Maximum (12000),
  378. * Logical Maximum (24000),
  379. * Input (Variable),
  380. * Usage (Y), ; Y (31h, dynamic value)
  381. * Physical Maximum (9000),
  382. * Logical Maximum (18000),
  383. * Input (Variable),
  384. * Pop,
  385. * Usage Page (Digitizer), ; Digitizer (0Dh)
  386. * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
  387. * Logical Maximum (1023),
  388. * Input (Variable),
  389. * Report Size (16),
  390. * End Collection,
  391. * End Collection,
  392. * Usage Page (Desktop), ; Generic desktop controls (01h)
  393. * Usage (Mouse), ; Mouse (02h, application collection)
  394. * Collection (Application),
  395. * Report ID (8),
  396. * Usage (Pointer), ; Pointer (01h, physical collection)
  397. * Collection (Physical),
  398. * Usage Page (Button), ; Button (09h)
  399. * Usage Minimum (01h),
  400. * Usage Maximum (03h),
  401. * Logical Minimum (0),
  402. * Logical Maximum (1),
  403. * Report Count (3),
  404. * Report Size (1),
  405. * Input (Variable),
  406. * Report Count (5),
  407. * Input (Constant),
  408. * Usage Page (Desktop), ; Generic desktop controls (01h)
  409. * Usage (X), ; X (30h, dynamic value)
  410. * Usage (Y), ; Y (31h, dynamic value)
  411. * Usage (Wheel), ; Wheel (38h, dynamic value)
  412. * Usage (00h),
  413. * Logical Minimum (-127),
  414. * Logical Maximum (127),
  415. * Report Size (8),
  416. * Report Count (4),
  417. * Input (Variable, Relative),
  418. * End Collection,
  419. * End Collection,
  420. * Usage Page (Desktop), ; Generic desktop controls (01h)
  421. * Usage (Mouse), ; Mouse (02h, application collection)
  422. * Collection (Application),
  423. * Report ID (9),
  424. * Usage (Pointer), ; Pointer (01h, physical collection)
  425. * Collection (Physical),
  426. * Usage Page (Button), ; Button (09h)
  427. * Usage Minimum (01h),
  428. * Usage Maximum (03h),
  429. * Logical Minimum (0),
  430. * Logical Maximum (1),
  431. * Report Count (3),
  432. * Report Size (1),
  433. * Input (Variable),
  434. * Report Count (5),
  435. * Input (Constant),
  436. * Usage Page (Desktop), ; Generic desktop controls (01h)
  437. * Usage (X), ; X (30h, dynamic value)
  438. * Usage (Y), ; Y (31h, dynamic value)
  439. * Logical Minimum (0),
  440. * Logical Maximum (32767),
  441. * Physical Minimum (0),
  442. * Physical Maximum (32767),
  443. * Report Count (2),
  444. * Report Size (16),
  445. * Input (Variable),
  446. * Usage Page (Digitizer), ; Digitizer (0Dh)
  447. * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
  448. * Logical Maximum (1023),
  449. * Report Count (1),
  450. * Report Size (16),
  451. * Input (Variable),
  452. * End Collection,
  453. * End Collection,
  454. * Usage Page (Desktop), ; Generic desktop controls (01h)
  455. * Usage (00h),
  456. * Collection (Application),
  457. * Report ID (4),
  458. * Logical Minimum (0),
  459. * Logical Maximum (255),
  460. * Usage (00h),
  461. * Report Size (8),
  462. * Report Count (3),
  463. * Feature (Variable),
  464. * End Collection
  465. */
  466. /* Size of the original descriptor of PF1209 tablet */
  467. #define PF1209_RDESC_ORIG_SIZE 234
  468. /*
  469. * Fixed PF1209 report descriptor
  470. *
  471. * The descriptor is fixed similarly to WP5540U and WP8060U, plus the
  472. * feature report is removed, because its purpose is unknown and it is of no
  473. * use to the generic HID driver anyway for now.
  474. */
  475. static __u8 pf1209_rdesc_fixed[] = {
  476. 0x05, 0x0D, /* Usage Page (Digitizer), */
  477. 0x09, 0x02, /* Usage (Pen), */
  478. 0xA1, 0x01, /* Collection (Application), */
  479. 0x85, 0x09, /* Report ID (9), */
  480. 0x09, 0x20, /* Usage (Stylus), */
  481. 0xA0, /* Collection (Physical), */
  482. 0x75, 0x01, /* Report Size (1), */
  483. 0x09, 0x42, /* Usage (Tip Switch), */
  484. 0x09, 0x44, /* Usage (Barrel Switch), */
  485. 0x09, 0x46, /* Usage (Tablet Pick), */
  486. 0x14, /* Logical Minimum (0), */
  487. 0x25, 0x01, /* Logical Maximum (1), */
  488. 0x95, 0x03, /* Report Count (3), */
  489. 0x81, 0x02, /* Input (Variable), */
  490. 0x95, 0x05, /* Report Count (5), */
  491. 0x81, 0x01, /* Input (Constant), */
  492. 0x75, 0x10, /* Report Size (16), */
  493. 0x95, 0x01, /* Report Count (1), */
  494. 0x14, /* Logical Minimum (0), */
  495. 0xA4, /* Push, */
  496. 0x05, 0x01, /* Usage Page (Desktop), */
  497. 0x55, 0xFD, /* Unit Exponent (-3), */
  498. 0x65, 0x13, /* Unit (Inch), */
  499. 0x34, /* Physical Minimum (0), */
  500. 0x09, 0x30, /* Usage (X), */
  501. 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */
  502. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  503. 0x81, 0x02, /* Input (Variable), */
  504. 0x09, 0x31, /* Usage (Y), */
  505. 0x46, 0x28, 0x23, /* Physical Maximum (9000), */
  506. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  507. 0x81, 0x02, /* Input (Variable), */
  508. 0xB4, /* Pop, */
  509. 0x09, 0x30, /* Usage (Tip Pressure), */
  510. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  511. 0x81, 0x02, /* Input (Variable), */
  512. 0xC0, /* End Collection, */
  513. 0xC0, /* End Collection, */
  514. 0x05, 0x01, /* Usage Page (Desktop), */
  515. 0x09, 0x02, /* Usage (Mouse), */
  516. 0xA1, 0x01, /* Collection (Application), */
  517. 0x85, 0x08, /* Report ID (8), */
  518. 0x09, 0x01, /* Usage (Pointer), */
  519. 0xA0, /* Collection (Physical), */
  520. 0x75, 0x01, /* Report Size (1), */
  521. 0x05, 0x09, /* Usage Page (Button), */
  522. 0x19, 0x01, /* Usage Minimum (01h), */
  523. 0x29, 0x03, /* Usage Maximum (03h), */
  524. 0x14, /* Logical Minimum (0), */
  525. 0x25, 0x01, /* Logical Maximum (1), */
  526. 0x95, 0x03, /* Report Count (3), */
  527. 0x81, 0x02, /* Input (Variable), */
  528. 0x95, 0x05, /* Report Count (5), */
  529. 0x81, 0x01, /* Input (Constant), */
  530. 0x05, 0x01, /* Usage Page (Desktop), */
  531. 0x75, 0x08, /* Report Size (8), */
  532. 0x09, 0x30, /* Usage (X), */
  533. 0x09, 0x31, /* Usage (Y), */
  534. 0x15, 0x81, /* Logical Minimum (-127), */
  535. 0x25, 0x7F, /* Logical Maximum (127), */
  536. 0x95, 0x02, /* Report Count (2), */
  537. 0x81, 0x06, /* Input (Variable, Relative), */
  538. 0x09, 0x38, /* Usage (Wheel), */
  539. 0x15, 0xFF, /* Logical Minimum (-1), */
  540. 0x25, 0x01, /* Logical Maximum (1), */
  541. 0x95, 0x01, /* Report Count (1), */
  542. 0x81, 0x06, /* Input (Variable, Relative), */
  543. 0x81, 0x01, /* Input (Constant), */
  544. 0xC0, /* End Collection, */
  545. 0xC0 /* End Collection */
  546. };
  547. static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  548. unsigned int *rsize)
  549. {
  550. switch (hdev->product) {
  551. case USB_DEVICE_ID_UCLOGIC_TABLET_PF1209:
  552. if (*rsize == PF1209_RDESC_ORIG_SIZE) {
  553. rdesc = pf1209_rdesc_fixed;
  554. *rsize = sizeof(pf1209_rdesc_fixed);
  555. }
  556. break;
  557. case USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U:
  558. if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
  559. rdesc = wp4030u_rdesc_fixed;
  560. *rsize = sizeof(wp4030u_rdesc_fixed);
  561. }
  562. break;
  563. case USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U:
  564. if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
  565. rdesc = wp5540u_rdesc_fixed;
  566. *rsize = sizeof(wp5540u_rdesc_fixed);
  567. }
  568. break;
  569. case USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U:
  570. if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
  571. rdesc = wp8060u_rdesc_fixed;
  572. *rsize = sizeof(wp8060u_rdesc_fixed);
  573. }
  574. break;
  575. }
  576. return rdesc;
  577. }
  578. static const struct hid_device_id uclogic_devices[] = {
  579. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  580. USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) },
  581. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  582. USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) },
  583. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  584. USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) },
  585. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
  586. USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) },
  587. { }
  588. };
  589. MODULE_DEVICE_TABLE(hid, uclogic_devices);
  590. static struct hid_driver uclogic_driver = {
  591. .name = "uclogic",
  592. .id_table = uclogic_devices,
  593. .report_fixup = uclogic_report_fixup,
  594. };
  595. static int __init uclogic_init(void)
  596. {
  597. return hid_register_driver(&uclogic_driver);
  598. }
  599. static void __exit uclogic_exit(void)
  600. {
  601. hid_unregister_driver(&uclogic_driver);
  602. }
  603. module_init(uclogic_init);
  604. module_exit(uclogic_exit);
  605. MODULE_LICENSE("GPL");