hid-uclogic-rdesc.c 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * HID driver for UC-Logic devices not fully compliant with HID standard
  4. * - original and fixed report descriptors
  5. *
  6. * Copyright (c) 2010-2017 Nikolai Kondrashov
  7. * Copyright (c) 2013 Martin Rusko
  8. */
  9. /*
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the Free
  12. * Software Foundation; either version 2 of the License, or (at your option)
  13. * any later version.
  14. */
  15. #include "hid-uclogic-rdesc.h"
  16. #include <linux/slab.h>
  17. #include <asm/unaligned.h>
  18. /* Fixed WP4030U report descriptor */
  19. __u8 uclogic_rdesc_wp4030u_fixed_arr[] = {
  20. 0x05, 0x0D, /* Usage Page (Digitizer), */
  21. 0x09, 0x02, /* Usage (Pen), */
  22. 0xA1, 0x01, /* Collection (Application), */
  23. 0x85, 0x09, /* Report ID (9), */
  24. 0x09, 0x20, /* Usage (Stylus), */
  25. 0xA0, /* Collection (Physical), */
  26. 0x75, 0x01, /* Report Size (1), */
  27. 0x09, 0x42, /* Usage (Tip Switch), */
  28. 0x09, 0x44, /* Usage (Barrel Switch), */
  29. 0x09, 0x46, /* Usage (Tablet Pick), */
  30. 0x14, /* Logical Minimum (0), */
  31. 0x25, 0x01, /* Logical Maximum (1), */
  32. 0x95, 0x03, /* Report Count (3), */
  33. 0x81, 0x02, /* Input (Variable), */
  34. 0x95, 0x05, /* Report Count (5), */
  35. 0x81, 0x01, /* Input (Constant), */
  36. 0x75, 0x10, /* Report Size (16), */
  37. 0x95, 0x01, /* Report Count (1), */
  38. 0x14, /* Logical Minimum (0), */
  39. 0xA4, /* Push, */
  40. 0x05, 0x01, /* Usage Page (Desktop), */
  41. 0x55, 0xFD, /* Unit Exponent (-3), */
  42. 0x65, 0x13, /* Unit (Inch), */
  43. 0x34, /* Physical Minimum (0), */
  44. 0x09, 0x30, /* Usage (X), */
  45. 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */
  46. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  47. 0x81, 0x02, /* Input (Variable), */
  48. 0x09, 0x31, /* Usage (Y), */
  49. 0x46, 0xB8, 0x0B, /* Physical Maximum (3000), */
  50. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  51. 0x81, 0x02, /* Input (Variable), */
  52. 0xB4, /* Pop, */
  53. 0x09, 0x30, /* Usage (Tip Pressure), */
  54. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  55. 0x81, 0x02, /* Input (Variable), */
  56. 0xC0, /* End Collection, */
  57. 0xC0 /* End Collection */
  58. };
  59. const size_t uclogic_rdesc_wp4030u_fixed_size =
  60. sizeof(uclogic_rdesc_wp4030u_fixed_arr);
  61. /* Fixed WP5540U report descriptor */
  62. __u8 uclogic_rdesc_wp5540u_fixed_arr[] = {
  63. 0x05, 0x0D, /* Usage Page (Digitizer), */
  64. 0x09, 0x02, /* Usage (Pen), */
  65. 0xA1, 0x01, /* Collection (Application), */
  66. 0x85, 0x09, /* Report ID (9), */
  67. 0x09, 0x20, /* Usage (Stylus), */
  68. 0xA0, /* Collection (Physical), */
  69. 0x75, 0x01, /* Report Size (1), */
  70. 0x09, 0x42, /* Usage (Tip Switch), */
  71. 0x09, 0x44, /* Usage (Barrel Switch), */
  72. 0x09, 0x46, /* Usage (Tablet Pick), */
  73. 0x14, /* Logical Minimum (0), */
  74. 0x25, 0x01, /* Logical Maximum (1), */
  75. 0x95, 0x03, /* Report Count (3), */
  76. 0x81, 0x02, /* Input (Variable), */
  77. 0x95, 0x05, /* Report Count (5), */
  78. 0x81, 0x01, /* Input (Constant), */
  79. 0x75, 0x10, /* Report Size (16), */
  80. 0x95, 0x01, /* Report Count (1), */
  81. 0x14, /* Logical Minimum (0), */
  82. 0xA4, /* Push, */
  83. 0x05, 0x01, /* Usage Page (Desktop), */
  84. 0x55, 0xFD, /* Unit Exponent (-3), */
  85. 0x65, 0x13, /* Unit (Inch), */
  86. 0x34, /* Physical Minimum (0), */
  87. 0x09, 0x30, /* Usage (X), */
  88. 0x46, 0x7C, 0x15, /* Physical Maximum (5500), */
  89. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  90. 0x81, 0x02, /* Input (Variable), */
  91. 0x09, 0x31, /* Usage (Y), */
  92. 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */
  93. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  94. 0x81, 0x02, /* Input (Variable), */
  95. 0xB4, /* Pop, */
  96. 0x09, 0x30, /* Usage (Tip Pressure), */
  97. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  98. 0x81, 0x02, /* Input (Variable), */
  99. 0xC0, /* End Collection, */
  100. 0xC0, /* End Collection, */
  101. 0x05, 0x01, /* Usage Page (Desktop), */
  102. 0x09, 0x02, /* Usage (Mouse), */
  103. 0xA1, 0x01, /* Collection (Application), */
  104. 0x85, 0x08, /* Report ID (8), */
  105. 0x09, 0x01, /* Usage (Pointer), */
  106. 0xA0, /* Collection (Physical), */
  107. 0x75, 0x01, /* Report Size (1), */
  108. 0x05, 0x09, /* Usage Page (Button), */
  109. 0x19, 0x01, /* Usage Minimum (01h), */
  110. 0x29, 0x03, /* Usage Maximum (03h), */
  111. 0x14, /* Logical Minimum (0), */
  112. 0x25, 0x01, /* Logical Maximum (1), */
  113. 0x95, 0x03, /* Report Count (3), */
  114. 0x81, 0x02, /* Input (Variable), */
  115. 0x95, 0x05, /* Report Count (5), */
  116. 0x81, 0x01, /* Input (Constant), */
  117. 0x05, 0x01, /* Usage Page (Desktop), */
  118. 0x75, 0x08, /* Report Size (8), */
  119. 0x09, 0x30, /* Usage (X), */
  120. 0x09, 0x31, /* Usage (Y), */
  121. 0x15, 0x81, /* Logical Minimum (-127), */
  122. 0x25, 0x7F, /* Logical Maximum (127), */
  123. 0x95, 0x02, /* Report Count (2), */
  124. 0x81, 0x06, /* Input (Variable, Relative), */
  125. 0x09, 0x38, /* Usage (Wheel), */
  126. 0x15, 0xFF, /* Logical Minimum (-1), */
  127. 0x25, 0x01, /* Logical Maximum (1), */
  128. 0x95, 0x01, /* Report Count (1), */
  129. 0x81, 0x06, /* Input (Variable, Relative), */
  130. 0x81, 0x01, /* Input (Constant), */
  131. 0xC0, /* End Collection, */
  132. 0xC0 /* End Collection */
  133. };
  134. const size_t uclogic_rdesc_wp5540u_fixed_size =
  135. sizeof(uclogic_rdesc_wp5540u_fixed_arr);
  136. /* Fixed WP8060U report descriptor */
  137. __u8 uclogic_rdesc_wp8060u_fixed_arr[] = {
  138. 0x05, 0x0D, /* Usage Page (Digitizer), */
  139. 0x09, 0x02, /* Usage (Pen), */
  140. 0xA1, 0x01, /* Collection (Application), */
  141. 0x85, 0x09, /* Report ID (9), */
  142. 0x09, 0x20, /* Usage (Stylus), */
  143. 0xA0, /* Collection (Physical), */
  144. 0x75, 0x01, /* Report Size (1), */
  145. 0x09, 0x42, /* Usage (Tip Switch), */
  146. 0x09, 0x44, /* Usage (Barrel Switch), */
  147. 0x09, 0x46, /* Usage (Tablet Pick), */
  148. 0x14, /* Logical Minimum (0), */
  149. 0x25, 0x01, /* Logical Maximum (1), */
  150. 0x95, 0x03, /* Report Count (3), */
  151. 0x81, 0x02, /* Input (Variable), */
  152. 0x95, 0x05, /* Report Count (5), */
  153. 0x81, 0x01, /* Input (Constant), */
  154. 0x75, 0x10, /* Report Size (16), */
  155. 0x95, 0x01, /* Report Count (1), */
  156. 0x14, /* Logical Minimum (0), */
  157. 0xA4, /* Push, */
  158. 0x05, 0x01, /* Usage Page (Desktop), */
  159. 0x55, 0xFD, /* Unit Exponent (-3), */
  160. 0x65, 0x13, /* Unit (Inch), */
  161. 0x34, /* Physical Minimum (0), */
  162. 0x09, 0x30, /* Usage (X), */
  163. 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
  164. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  165. 0x81, 0x02, /* Input (Variable), */
  166. 0x09, 0x31, /* Usage (Y), */
  167. 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
  168. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  169. 0x81, 0x02, /* Input (Variable), */
  170. 0xB4, /* Pop, */
  171. 0x09, 0x30, /* Usage (Tip Pressure), */
  172. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  173. 0x81, 0x02, /* Input (Variable), */
  174. 0xC0, /* End Collection, */
  175. 0xC0, /* End Collection, */
  176. 0x05, 0x01, /* Usage Page (Desktop), */
  177. 0x09, 0x02, /* Usage (Mouse), */
  178. 0xA1, 0x01, /* Collection (Application), */
  179. 0x85, 0x08, /* Report ID (8), */
  180. 0x09, 0x01, /* Usage (Pointer), */
  181. 0xA0, /* Collection (Physical), */
  182. 0x75, 0x01, /* Report Size (1), */
  183. 0x05, 0x09, /* Usage Page (Button), */
  184. 0x19, 0x01, /* Usage Minimum (01h), */
  185. 0x29, 0x03, /* Usage Maximum (03h), */
  186. 0x14, /* Logical Minimum (0), */
  187. 0x25, 0x01, /* Logical Maximum (1), */
  188. 0x95, 0x03, /* Report Count (3), */
  189. 0x81, 0x02, /* Input (Variable), */
  190. 0x95, 0x05, /* Report Count (5), */
  191. 0x81, 0x01, /* Input (Constant), */
  192. 0x05, 0x01, /* Usage Page (Desktop), */
  193. 0x75, 0x08, /* Report Size (8), */
  194. 0x09, 0x30, /* Usage (X), */
  195. 0x09, 0x31, /* Usage (Y), */
  196. 0x15, 0x81, /* Logical Minimum (-127), */
  197. 0x25, 0x7F, /* Logical Maximum (127), */
  198. 0x95, 0x02, /* Report Count (2), */
  199. 0x81, 0x06, /* Input (Variable, Relative), */
  200. 0x09, 0x38, /* Usage (Wheel), */
  201. 0x15, 0xFF, /* Logical Minimum (-1), */
  202. 0x25, 0x01, /* Logical Maximum (1), */
  203. 0x95, 0x01, /* Report Count (1), */
  204. 0x81, 0x06, /* Input (Variable, Relative), */
  205. 0x81, 0x01, /* Input (Constant), */
  206. 0xC0, /* End Collection, */
  207. 0xC0 /* End Collection */
  208. };
  209. const size_t uclogic_rdesc_wp8060u_fixed_size =
  210. sizeof(uclogic_rdesc_wp8060u_fixed_arr);
  211. /* Fixed WP1062 report descriptor */
  212. __u8 uclogic_rdesc_wp1062_fixed_arr[] = {
  213. 0x05, 0x0D, /* Usage Page (Digitizer), */
  214. 0x09, 0x02, /* Usage (Pen), */
  215. 0xA1, 0x01, /* Collection (Application), */
  216. 0x85, 0x09, /* Report ID (9), */
  217. 0x09, 0x20, /* Usage (Stylus), */
  218. 0xA0, /* Collection (Physical), */
  219. 0x75, 0x01, /* Report Size (1), */
  220. 0x09, 0x42, /* Usage (Tip Switch), */
  221. 0x09, 0x44, /* Usage (Barrel Switch), */
  222. 0x09, 0x46, /* Usage (Tablet Pick), */
  223. 0x14, /* Logical Minimum (0), */
  224. 0x25, 0x01, /* Logical Maximum (1), */
  225. 0x95, 0x03, /* Report Count (3), */
  226. 0x81, 0x02, /* Input (Variable), */
  227. 0x95, 0x04, /* Report Count (4), */
  228. 0x81, 0x01, /* Input (Constant), */
  229. 0x09, 0x32, /* Usage (In Range), */
  230. 0x95, 0x01, /* Report Count (1), */
  231. 0x81, 0x02, /* Input (Variable), */
  232. 0x75, 0x10, /* Report Size (16), */
  233. 0x95, 0x01, /* Report Count (1), */
  234. 0x14, /* Logical Minimum (0), */
  235. 0xA4, /* Push, */
  236. 0x05, 0x01, /* Usage Page (Desktop), */
  237. 0x55, 0xFD, /* Unit Exponent (-3), */
  238. 0x65, 0x13, /* Unit (Inch), */
  239. 0x34, /* Physical Minimum (0), */
  240. 0x09, 0x30, /* Usage (X), */
  241. 0x46, 0x10, 0x27, /* Physical Maximum (10000), */
  242. 0x26, 0x20, 0x4E, /* Logical Maximum (20000), */
  243. 0x81, 0x02, /* Input (Variable), */
  244. 0x09, 0x31, /* Usage (Y), */
  245. 0x46, 0xB7, 0x19, /* Physical Maximum (6583), */
  246. 0x26, 0x6E, 0x33, /* Logical Maximum (13166), */
  247. 0x81, 0x02, /* Input (Variable), */
  248. 0xB4, /* Pop, */
  249. 0x09, 0x30, /* Usage (Tip Pressure), */
  250. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  251. 0x81, 0x02, /* Input (Variable), */
  252. 0xC0, /* End Collection, */
  253. 0xC0 /* End Collection */
  254. };
  255. const size_t uclogic_rdesc_wp1062_fixed_size =
  256. sizeof(uclogic_rdesc_wp1062_fixed_arr);
  257. /* Fixed PF1209 report descriptor */
  258. __u8 uclogic_rdesc_pf1209_fixed_arr[] = {
  259. 0x05, 0x0D, /* Usage Page (Digitizer), */
  260. 0x09, 0x02, /* Usage (Pen), */
  261. 0xA1, 0x01, /* Collection (Application), */
  262. 0x85, 0x09, /* Report ID (9), */
  263. 0x09, 0x20, /* Usage (Stylus), */
  264. 0xA0, /* Collection (Physical), */
  265. 0x75, 0x01, /* Report Size (1), */
  266. 0x09, 0x42, /* Usage (Tip Switch), */
  267. 0x09, 0x44, /* Usage (Barrel Switch), */
  268. 0x09, 0x46, /* Usage (Tablet Pick), */
  269. 0x14, /* Logical Minimum (0), */
  270. 0x25, 0x01, /* Logical Maximum (1), */
  271. 0x95, 0x03, /* Report Count (3), */
  272. 0x81, 0x02, /* Input (Variable), */
  273. 0x95, 0x05, /* Report Count (5), */
  274. 0x81, 0x01, /* Input (Constant), */
  275. 0x75, 0x10, /* Report Size (16), */
  276. 0x95, 0x01, /* Report Count (1), */
  277. 0x14, /* Logical Minimum (0), */
  278. 0xA4, /* Push, */
  279. 0x05, 0x01, /* Usage Page (Desktop), */
  280. 0x55, 0xFD, /* Unit Exponent (-3), */
  281. 0x65, 0x13, /* Unit (Inch), */
  282. 0x34, /* Physical Minimum (0), */
  283. 0x09, 0x30, /* Usage (X), */
  284. 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */
  285. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  286. 0x81, 0x02, /* Input (Variable), */
  287. 0x09, 0x31, /* Usage (Y), */
  288. 0x46, 0x28, 0x23, /* Physical Maximum (9000), */
  289. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  290. 0x81, 0x02, /* Input (Variable), */
  291. 0xB4, /* Pop, */
  292. 0x09, 0x30, /* Usage (Tip Pressure), */
  293. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  294. 0x81, 0x02, /* Input (Variable), */
  295. 0xC0, /* End Collection, */
  296. 0xC0, /* End Collection, */
  297. 0x05, 0x01, /* Usage Page (Desktop), */
  298. 0x09, 0x02, /* Usage (Mouse), */
  299. 0xA1, 0x01, /* Collection (Application), */
  300. 0x85, 0x08, /* Report ID (8), */
  301. 0x09, 0x01, /* Usage (Pointer), */
  302. 0xA0, /* Collection (Physical), */
  303. 0x75, 0x01, /* Report Size (1), */
  304. 0x05, 0x09, /* Usage Page (Button), */
  305. 0x19, 0x01, /* Usage Minimum (01h), */
  306. 0x29, 0x03, /* Usage Maximum (03h), */
  307. 0x14, /* Logical Minimum (0), */
  308. 0x25, 0x01, /* Logical Maximum (1), */
  309. 0x95, 0x03, /* Report Count (3), */
  310. 0x81, 0x02, /* Input (Variable), */
  311. 0x95, 0x05, /* Report Count (5), */
  312. 0x81, 0x01, /* Input (Constant), */
  313. 0x05, 0x01, /* Usage Page (Desktop), */
  314. 0x75, 0x08, /* Report Size (8), */
  315. 0x09, 0x30, /* Usage (X), */
  316. 0x09, 0x31, /* Usage (Y), */
  317. 0x15, 0x81, /* Logical Minimum (-127), */
  318. 0x25, 0x7F, /* Logical Maximum (127), */
  319. 0x95, 0x02, /* Report Count (2), */
  320. 0x81, 0x06, /* Input (Variable, Relative), */
  321. 0x09, 0x38, /* Usage (Wheel), */
  322. 0x15, 0xFF, /* Logical Minimum (-1), */
  323. 0x25, 0x01, /* Logical Maximum (1), */
  324. 0x95, 0x01, /* Report Count (1), */
  325. 0x81, 0x06, /* Input (Variable, Relative), */
  326. 0x81, 0x01, /* Input (Constant), */
  327. 0xC0, /* End Collection, */
  328. 0xC0 /* End Collection */
  329. };
  330. const size_t uclogic_rdesc_pf1209_fixed_size =
  331. sizeof(uclogic_rdesc_pf1209_fixed_arr);
  332. /* Fixed PID 0522 tablet report descriptor, interface 0 (stylus) */
  333. __u8 uclogic_rdesc_twhl850_fixed0_arr[] = {
  334. 0x05, 0x0D, /* Usage Page (Digitizer), */
  335. 0x09, 0x02, /* Usage (Pen), */
  336. 0xA1, 0x01, /* Collection (Application), */
  337. 0x85, 0x09, /* Report ID (9), */
  338. 0x09, 0x20, /* Usage (Stylus), */
  339. 0xA0, /* Collection (Physical), */
  340. 0x14, /* Logical Minimum (0), */
  341. 0x25, 0x01, /* Logical Maximum (1), */
  342. 0x75, 0x01, /* Report Size (1), */
  343. 0x95, 0x03, /* Report Count (3), */
  344. 0x09, 0x42, /* Usage (Tip Switch), */
  345. 0x09, 0x44, /* Usage (Barrel Switch), */
  346. 0x09, 0x46, /* Usage (Tablet Pick), */
  347. 0x81, 0x02, /* Input (Variable), */
  348. 0x81, 0x03, /* Input (Constant, Variable), */
  349. 0x95, 0x01, /* Report Count (1), */
  350. 0x09, 0x32, /* Usage (In Range), */
  351. 0x81, 0x02, /* Input (Variable), */
  352. 0x81, 0x03, /* Input (Constant, Variable), */
  353. 0x75, 0x10, /* Report Size (16), */
  354. 0xA4, /* Push, */
  355. 0x05, 0x01, /* Usage Page (Desktop), */
  356. 0x65, 0x13, /* Unit (Inch), */
  357. 0x55, 0xFD, /* Unit Exponent (-3), */
  358. 0x34, /* Physical Minimum (0), */
  359. 0x09, 0x30, /* Usage (X), */
  360. 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
  361. 0x26, 0x00, 0x7D, /* Logical Maximum (32000), */
  362. 0x81, 0x02, /* Input (Variable), */
  363. 0x09, 0x31, /* Usage (Y), */
  364. 0x46, 0x88, 0x13, /* Physical Maximum (5000), */
  365. 0x26, 0x20, 0x4E, /* Logical Maximum (20000), */
  366. 0x81, 0x02, /* Input (Variable), */
  367. 0xB4, /* Pop, */
  368. 0x09, 0x30, /* Usage (Tip Pressure), */
  369. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  370. 0x81, 0x02, /* Input (Variable), */
  371. 0xC0, /* End Collection, */
  372. 0xC0 /* End Collection */
  373. };
  374. const size_t uclogic_rdesc_twhl850_fixed0_size =
  375. sizeof(uclogic_rdesc_twhl850_fixed0_arr);
  376. /* Fixed PID 0522 tablet report descriptor, interface 1 (mouse) */
  377. __u8 uclogic_rdesc_twhl850_fixed1_arr[] = {
  378. 0x05, 0x01, /* Usage Page (Desktop), */
  379. 0x09, 0x02, /* Usage (Mouse), */
  380. 0xA1, 0x01, /* Collection (Application), */
  381. 0x85, 0x01, /* Report ID (1), */
  382. 0x09, 0x01, /* Usage (Pointer), */
  383. 0xA0, /* Collection (Physical), */
  384. 0x05, 0x09, /* Usage Page (Button), */
  385. 0x75, 0x01, /* Report Size (1), */
  386. 0x95, 0x03, /* Report Count (3), */
  387. 0x19, 0x01, /* Usage Minimum (01h), */
  388. 0x29, 0x03, /* Usage Maximum (03h), */
  389. 0x14, /* Logical Minimum (0), */
  390. 0x25, 0x01, /* Logical Maximum (1), */
  391. 0x81, 0x02, /* Input (Variable), */
  392. 0x95, 0x05, /* Report Count (5), */
  393. 0x81, 0x03, /* Input (Constant, Variable), */
  394. 0x05, 0x01, /* Usage Page (Desktop), */
  395. 0x09, 0x30, /* Usage (X), */
  396. 0x09, 0x31, /* Usage (Y), */
  397. 0x16, 0x00, 0x80, /* Logical Minimum (-32768), */
  398. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  399. 0x75, 0x10, /* Report Size (16), */
  400. 0x95, 0x02, /* Report Count (2), */
  401. 0x81, 0x06, /* Input (Variable, Relative), */
  402. 0x09, 0x38, /* Usage (Wheel), */
  403. 0x15, 0xFF, /* Logical Minimum (-1), */
  404. 0x25, 0x01, /* Logical Maximum (1), */
  405. 0x95, 0x01, /* Report Count (1), */
  406. 0x75, 0x08, /* Report Size (8), */
  407. 0x81, 0x06, /* Input (Variable, Relative), */
  408. 0x81, 0x03, /* Input (Constant, Variable), */
  409. 0xC0, /* End Collection, */
  410. 0xC0 /* End Collection */
  411. };
  412. const size_t uclogic_rdesc_twhl850_fixed1_size =
  413. sizeof(uclogic_rdesc_twhl850_fixed1_arr);
  414. /* Fixed PID 0522 tablet report descriptor, interface 2 (frame buttons) */
  415. __u8 uclogic_rdesc_twhl850_fixed2_arr[] = {
  416. 0x05, 0x01, /* Usage Page (Desktop), */
  417. 0x09, 0x06, /* Usage (Keyboard), */
  418. 0xA1, 0x01, /* Collection (Application), */
  419. 0x85, 0x03, /* Report ID (3), */
  420. 0x05, 0x07, /* Usage Page (Keyboard), */
  421. 0x14, /* Logical Minimum (0), */
  422. 0x19, 0xE0, /* Usage Minimum (KB Leftcontrol), */
  423. 0x29, 0xE7, /* Usage Maximum (KB Right GUI), */
  424. 0x25, 0x01, /* Logical Maximum (1), */
  425. 0x75, 0x01, /* Report Size (1), */
  426. 0x95, 0x08, /* Report Count (8), */
  427. 0x81, 0x02, /* Input (Variable), */
  428. 0x18, /* Usage Minimum (None), */
  429. 0x29, 0xFF, /* Usage Maximum (FFh), */
  430. 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
  431. 0x75, 0x08, /* Report Size (8), */
  432. 0x95, 0x06, /* Report Count (6), */
  433. 0x80, /* Input, */
  434. 0xC0 /* End Collection */
  435. };
  436. const size_t uclogic_rdesc_twhl850_fixed2_size =
  437. sizeof(uclogic_rdesc_twhl850_fixed2_arr);
  438. /* Fixed TWHA60 report descriptor, interface 0 (stylus) */
  439. __u8 uclogic_rdesc_twha60_fixed0_arr[] = {
  440. 0x05, 0x0D, /* Usage Page (Digitizer), */
  441. 0x09, 0x02, /* Usage (Pen), */
  442. 0xA1, 0x01, /* Collection (Application), */
  443. 0x85, 0x09, /* Report ID (9), */
  444. 0x09, 0x20, /* Usage (Stylus), */
  445. 0xA0, /* Collection (Physical), */
  446. 0x75, 0x01, /* Report Size (1), */
  447. 0x09, 0x42, /* Usage (Tip Switch), */
  448. 0x09, 0x44, /* Usage (Barrel Switch), */
  449. 0x09, 0x46, /* Usage (Tablet Pick), */
  450. 0x14, /* Logical Minimum (0), */
  451. 0x25, 0x01, /* Logical Maximum (1), */
  452. 0x95, 0x03, /* Report Count (3), */
  453. 0x81, 0x02, /* Input (Variable), */
  454. 0x95, 0x04, /* Report Count (4), */
  455. 0x81, 0x01, /* Input (Constant), */
  456. 0x09, 0x32, /* Usage (In Range), */
  457. 0x95, 0x01, /* Report Count (1), */
  458. 0x81, 0x02, /* Input (Variable), */
  459. 0x75, 0x10, /* Report Size (16), */
  460. 0x95, 0x01, /* Report Count (1), */
  461. 0x14, /* Logical Minimum (0), */
  462. 0xA4, /* Push, */
  463. 0x05, 0x01, /* Usage Page (Desktop), */
  464. 0x55, 0xFD, /* Unit Exponent (-3), */
  465. 0x65, 0x13, /* Unit (Inch), */
  466. 0x34, /* Physical Minimum (0), */
  467. 0x09, 0x30, /* Usage (X), */
  468. 0x46, 0x10, 0x27, /* Physical Maximum (10000), */
  469. 0x27, 0x3F, 0x9C,
  470. 0x00, 0x00, /* Logical Maximum (39999), */
  471. 0x81, 0x02, /* Input (Variable), */
  472. 0x09, 0x31, /* Usage (Y), */
  473. 0x46, 0x6A, 0x18, /* Physical Maximum (6250), */
  474. 0x26, 0xA7, 0x61, /* Logical Maximum (24999), */
  475. 0x81, 0x02, /* Input (Variable), */
  476. 0xB4, /* Pop, */
  477. 0x09, 0x30, /* Usage (Tip Pressure), */
  478. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  479. 0x81, 0x02, /* Input (Variable), */
  480. 0xC0, /* End Collection, */
  481. 0xC0 /* End Collection */
  482. };
  483. const size_t uclogic_rdesc_twha60_fixed0_size =
  484. sizeof(uclogic_rdesc_twha60_fixed0_arr);
  485. /* Fixed TWHA60 report descriptor, interface 1 (frame buttons) */
  486. __u8 uclogic_rdesc_twha60_fixed1_arr[] = {
  487. 0x05, 0x01, /* Usage Page (Desktop), */
  488. 0x09, 0x06, /* Usage (Keyboard), */
  489. 0xA1, 0x01, /* Collection (Application), */
  490. 0x85, 0x05, /* Report ID (5), */
  491. 0x05, 0x07, /* Usage Page (Keyboard), */
  492. 0x14, /* Logical Minimum (0), */
  493. 0x25, 0x01, /* Logical Maximum (1), */
  494. 0x75, 0x01, /* Report Size (1), */
  495. 0x95, 0x08, /* Report Count (8), */
  496. 0x81, 0x01, /* Input (Constant), */
  497. 0x95, 0x0C, /* Report Count (12), */
  498. 0x19, 0x3A, /* Usage Minimum (KB F1), */
  499. 0x29, 0x45, /* Usage Maximum (KB F12), */
  500. 0x81, 0x02, /* Input (Variable), */
  501. 0x95, 0x0C, /* Report Count (12), */
  502. 0x19, 0x68, /* Usage Minimum (KB F13), */
  503. 0x29, 0x73, /* Usage Maximum (KB F24), */
  504. 0x81, 0x02, /* Input (Variable), */
  505. 0x95, 0x08, /* Report Count (8), */
  506. 0x81, 0x01, /* Input (Constant), */
  507. 0xC0 /* End Collection */
  508. };
  509. const size_t uclogic_rdesc_twha60_fixed1_size =
  510. sizeof(uclogic_rdesc_twha60_fixed1_arr);
  511. /* Fixed report descriptor template for (tweaked) v1 pen reports */
  512. const __u8 uclogic_rdesc_pen_v1_template_arr[] = {
  513. 0x05, 0x0D, /* Usage Page (Digitizer), */
  514. 0x09, 0x02, /* Usage (Pen), */
  515. 0xA1, 0x01, /* Collection (Application), */
  516. 0x85, 0x07, /* Report ID (7), */
  517. 0x09, 0x20, /* Usage (Stylus), */
  518. 0xA0, /* Collection (Physical), */
  519. 0x14, /* Logical Minimum (0), */
  520. 0x25, 0x01, /* Logical Maximum (1), */
  521. 0x75, 0x01, /* Report Size (1), */
  522. 0x09, 0x42, /* Usage (Tip Switch), */
  523. 0x09, 0x44, /* Usage (Barrel Switch), */
  524. 0x09, 0x46, /* Usage (Tablet Pick), */
  525. 0x95, 0x03, /* Report Count (3), */
  526. 0x81, 0x02, /* Input (Variable), */
  527. 0x95, 0x03, /* Report Count (3), */
  528. 0x81, 0x03, /* Input (Constant, Variable), */
  529. 0x09, 0x32, /* Usage (In Range), */
  530. 0x95, 0x01, /* Report Count (1), */
  531. 0x81, 0x02, /* Input (Variable), */
  532. 0x95, 0x01, /* Report Count (1), */
  533. 0x81, 0x03, /* Input (Constant, Variable), */
  534. 0x75, 0x10, /* Report Size (16), */
  535. 0x95, 0x01, /* Report Count (1), */
  536. 0xA4, /* Push, */
  537. 0x05, 0x01, /* Usage Page (Desktop), */
  538. 0x65, 0x13, /* Unit (Inch), */
  539. 0x55, 0xFD, /* Unit Exponent (-3), */
  540. 0x34, /* Physical Minimum (0), */
  541. 0x09, 0x30, /* Usage (X), */
  542. 0x27, UCLOGIC_RDESC_PEN_PH(X_LM),
  543. /* Logical Maximum (PLACEHOLDER), */
  544. 0x47, UCLOGIC_RDESC_PEN_PH(X_PM),
  545. /* Physical Maximum (PLACEHOLDER), */
  546. 0x81, 0x02, /* Input (Variable), */
  547. 0x09, 0x31, /* Usage (Y), */
  548. 0x27, UCLOGIC_RDESC_PEN_PH(Y_LM),
  549. /* Logical Maximum (PLACEHOLDER), */
  550. 0x47, UCLOGIC_RDESC_PEN_PH(Y_PM),
  551. /* Physical Maximum (PLACEHOLDER), */
  552. 0x81, 0x02, /* Input (Variable), */
  553. 0xB4, /* Pop, */
  554. 0x09, 0x30, /* Usage (Tip Pressure), */
  555. 0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM),
  556. /* Logical Maximum (PLACEHOLDER), */
  557. 0x81, 0x02, /* Input (Variable), */
  558. 0xC0, /* End Collection, */
  559. 0xC0 /* End Collection */
  560. };
  561. const size_t uclogic_rdesc_pen_v1_template_size =
  562. sizeof(uclogic_rdesc_pen_v1_template_arr);
  563. /* Fixed report descriptor template for (tweaked) v2 pen reports */
  564. const __u8 uclogic_rdesc_pen_v2_template_arr[] = {
  565. 0x05, 0x0D, /* Usage Page (Digitizer), */
  566. 0x09, 0x02, /* Usage (Pen), */
  567. 0xA1, 0x01, /* Collection (Application), */
  568. 0x85, 0x08, /* Report ID (8), */
  569. 0x09, 0x20, /* Usage (Stylus), */
  570. 0xA0, /* Collection (Physical), */
  571. 0x14, /* Logical Minimum (0), */
  572. 0x25, 0x01, /* Logical Maximum (1), */
  573. 0x75, 0x01, /* Report Size (1), */
  574. 0x09, 0x42, /* Usage (Tip Switch), */
  575. 0x09, 0x44, /* Usage (Barrel Switch), */
  576. 0x09, 0x46, /* Usage (Tablet Pick), */
  577. 0x95, 0x03, /* Report Count (3), */
  578. 0x81, 0x02, /* Input (Variable), */
  579. 0x95, 0x03, /* Report Count (3), */
  580. 0x81, 0x03, /* Input (Constant, Variable), */
  581. 0x09, 0x32, /* Usage (In Range), */
  582. 0x95, 0x01, /* Report Count (1), */
  583. 0x81, 0x02, /* Input (Variable), */
  584. 0x95, 0x01, /* Report Count (1), */
  585. 0x81, 0x03, /* Input (Constant, Variable), */
  586. 0x95, 0x01, /* Report Count (1), */
  587. 0xA4, /* Push, */
  588. 0x05, 0x01, /* Usage Page (Desktop), */
  589. 0x65, 0x13, /* Unit (Inch), */
  590. 0x55, 0xFD, /* Unit Exponent (-3), */
  591. 0x75, 0x18, /* Report Size (24), */
  592. 0x34, /* Physical Minimum (0), */
  593. 0x09, 0x30, /* Usage (X), */
  594. 0x27, UCLOGIC_RDESC_PEN_PH(X_LM),
  595. /* Logical Maximum (PLACEHOLDER), */
  596. 0x47, UCLOGIC_RDESC_PEN_PH(X_PM),
  597. /* Physical Maximum (PLACEHOLDER), */
  598. 0x81, 0x02, /* Input (Variable), */
  599. 0x09, 0x31, /* Usage (Y), */
  600. 0x27, UCLOGIC_RDESC_PEN_PH(Y_LM),
  601. /* Logical Maximum (PLACEHOLDER), */
  602. 0x47, UCLOGIC_RDESC_PEN_PH(Y_PM),
  603. /* Physical Maximum (PLACEHOLDER), */
  604. 0x81, 0x02, /* Input (Variable), */
  605. 0xB4, /* Pop, */
  606. 0x09, 0x30, /* Usage (Tip Pressure), */
  607. 0x75, 0x10, /* Report Size (16), */
  608. 0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM),
  609. /* Logical Maximum (PLACEHOLDER), */
  610. 0x81, 0x02, /* Input (Variable), */
  611. 0x81, 0x03, /* Input (Constant, Variable), */
  612. 0xC0, /* End Collection, */
  613. 0xC0 /* End Collection */
  614. };
  615. const size_t uclogic_rdesc_pen_v2_template_size =
  616. sizeof(uclogic_rdesc_pen_v2_template_arr);
  617. /**
  618. * Expand to the contents of a generic buttonpad report descriptor.
  619. *
  620. * @_padding: Padding from the end of button bits at bit 44, until
  621. * the end of the report, in bits.
  622. */
  623. #define UCLOGIC_RDESC_BUTTONPAD_BYTES(_padding) \
  624. 0x05, 0x01, /* Usage Page (Desktop), */ \
  625. 0x09, 0x07, /* Usage (Keypad), */ \
  626. 0xA1, 0x01, /* Collection (Application), */ \
  627. 0x85, 0xF7, /* Report ID (247), */ \
  628. 0x14, /* Logical Minimum (0), */ \
  629. 0x25, 0x01, /* Logical Maximum (1), */ \
  630. 0x75, 0x01, /* Report Size (1), */ \
  631. 0x05, 0x0D, /* Usage Page (Digitizer), */ \
  632. 0x09, 0x39, /* Usage (Tablet Function Keys), */ \
  633. 0xA0, /* Collection (Physical), */ \
  634. 0x09, 0x44, /* Usage (Barrel Switch), */ \
  635. 0x95, 0x01, /* Report Count (1), */ \
  636. 0x81, 0x02, /* Input (Variable), */ \
  637. 0x05, 0x01, /* Usage Page (Desktop), */ \
  638. 0x09, 0x30, /* Usage (X), */ \
  639. 0x09, 0x31, /* Usage (Y), */ \
  640. 0x95, 0x02, /* Report Count (2), */ \
  641. 0x81, 0x02, /* Input (Variable), */ \
  642. 0x95, 0x15, /* Report Count (21), */ \
  643. 0x81, 0x01, /* Input (Constant), */ \
  644. 0x05, 0x09, /* Usage Page (Button), */ \
  645. 0x19, 0x01, /* Usage Minimum (01h), */ \
  646. 0x29, 0x0A, /* Usage Maximum (0Ah), */ \
  647. 0x95, 0x0A, /* Report Count (10), */ \
  648. 0x81, 0x02, /* Input (Variable), */ \
  649. 0xC0, /* End Collection, */ \
  650. 0x05, 0x01, /* Usage Page (Desktop), */ \
  651. 0x09, 0x05, /* Usage (Gamepad), */ \
  652. 0xA0, /* Collection (Physical), */ \
  653. 0x05, 0x09, /* Usage Page (Button), */ \
  654. 0x19, 0x01, /* Usage Minimum (01h), */ \
  655. 0x29, 0x02, /* Usage Maximum (02h), */ \
  656. 0x95, 0x02, /* Report Count (2), */ \
  657. 0x81, 0x02, /* Input (Variable), */ \
  658. 0x95, _padding, /* Report Count (_padding), */ \
  659. 0x81, 0x01, /* Input (Constant), */ \
  660. 0xC0, /* End Collection, */ \
  661. 0xC0 /* End Collection */
  662. /* Fixed report descriptor for (tweaked) v1 buttonpad reports */
  663. const __u8 uclogic_rdesc_buttonpad_v1_arr[] = {
  664. UCLOGIC_RDESC_BUTTONPAD_BYTES(20)
  665. };
  666. const size_t uclogic_rdesc_buttonpad_v1_size =
  667. sizeof(uclogic_rdesc_buttonpad_v1_arr);
  668. /* Fixed report descriptor for (tweaked) v2 buttonpad reports */
  669. const __u8 uclogic_rdesc_buttonpad_v2_arr[] = {
  670. UCLOGIC_RDESC_BUTTONPAD_BYTES(52)
  671. };
  672. const size_t uclogic_rdesc_buttonpad_v2_size =
  673. sizeof(uclogic_rdesc_buttonpad_v2_arr);
  674. /* Fixed report descriptor for Ugee EX07 buttonpad */
  675. const __u8 uclogic_rdesc_ugee_ex07_buttonpad_arr[] = {
  676. 0x05, 0x01, /* Usage Page (Desktop), */
  677. 0x09, 0x07, /* Usage (Keypad), */
  678. 0xA1, 0x01, /* Collection (Application), */
  679. 0x85, 0x06, /* Report ID (6), */
  680. 0x05, 0x0D, /* Usage Page (Digitizer), */
  681. 0x09, 0x39, /* Usage (Tablet Function Keys), */
  682. 0xA0, /* Collection (Physical), */
  683. 0x05, 0x09, /* Usage Page (Button), */
  684. 0x75, 0x01, /* Report Size (1), */
  685. 0x19, 0x03, /* Usage Minimum (03h), */
  686. 0x29, 0x06, /* Usage Maximum (06h), */
  687. 0x95, 0x04, /* Report Count (4), */
  688. 0x81, 0x02, /* Input (Variable), */
  689. 0x95, 0x1A, /* Report Count (26), */
  690. 0x81, 0x03, /* Input (Constant, Variable), */
  691. 0x19, 0x01, /* Usage Minimum (01h), */
  692. 0x29, 0x02, /* Usage Maximum (02h), */
  693. 0x95, 0x02, /* Report Count (2), */
  694. 0x81, 0x02, /* Input (Variable), */
  695. 0xC0, /* End Collection, */
  696. 0xC0 /* End Collection */
  697. };
  698. const size_t uclogic_rdesc_ugee_ex07_buttonpad_size =
  699. sizeof(uclogic_rdesc_ugee_ex07_buttonpad_arr);
  700. /* Fixed report descriptor for Ugee G5 frame controls */
  701. const __u8 uclogic_rdesc_ugee_g5_frame_arr[] = {
  702. 0x05, 0x01, /* Usage Page (Desktop), */
  703. 0x09, 0x07, /* Usage (Keypad), */
  704. 0xA1, 0x01, /* Collection (Application), */
  705. 0x85, 0x06, /* Report ID (6), */
  706. 0x05, 0x0D, /* Usage Page (Digitizer), */
  707. 0x09, 0x39, /* Usage (Tablet Function Keys), */
  708. 0xA0, /* Collection (Physical), */
  709. 0x14, /* Logical Minimum (0), */
  710. 0x25, 0x01, /* Logical Maximum (1), */
  711. 0x05, 0x01, /* Usage Page (Desktop), */
  712. 0x05, 0x09, /* Usage Page (Button), */
  713. 0x19, 0x01, /* Usage Minimum (01h), */
  714. 0x29, 0x05, /* Usage Maximum (05h), */
  715. 0x75, 0x01, /* Report Size (1), */
  716. 0x95, 0x05, /* Report Count (5), */
  717. 0x81, 0x02, /* Input (Variable), */
  718. 0x75, 0x01, /* Report Size (1), */
  719. 0x95, 0x03, /* Report Count (3), */
  720. 0x81, 0x01, /* Input (Constant), */
  721. 0x05, 0x0D, /* Usage Page (Digitizer), */
  722. 0x0A, 0xFF, 0xFF, /* Usage (FFFFh), */
  723. 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
  724. 0x75, 0x08, /* Report Size (8), */
  725. 0x95, 0x01, /* Report Count (1), */
  726. 0x81, 0x02, /* Input (Variable), */
  727. 0x25, 0x01, /* Logical Maximum (1), */
  728. 0x09, 0x44, /* Usage (Barrel Switch), */
  729. 0x75, 0x01, /* Report Size (1), */
  730. 0x95, 0x01, /* Report Count (1), */
  731. 0x81, 0x02, /* Input (Variable), */
  732. 0x05, 0x01, /* Usage Page (Desktop), */
  733. 0x09, 0x30, /* Usage (X), */
  734. 0x09, 0x31, /* Usage (Y), */
  735. 0x75, 0x01, /* Report Size (1), */
  736. 0x95, 0x02, /* Report Count (2), */
  737. 0x81, 0x02, /* Input (Variable), */
  738. 0x75, 0x01, /* Report Size (1), */
  739. 0x95, 0x0B, /* Report Count (11), */
  740. 0x81, 0x01, /* Input (Constant), */
  741. 0x05, 0x01, /* Usage Page (Desktop), */
  742. 0x09, 0x38, /* Usage (Wheel), */
  743. 0x15, 0xFF, /* Logical Minimum (-1), */
  744. 0x25, 0x01, /* Logical Maximum (1), */
  745. 0x75, 0x02, /* Report Size (2), */
  746. 0x95, 0x01, /* Report Count (1), */
  747. 0x81, 0x06, /* Input (Variable, Relative), */
  748. 0xC0, /* End Collection, */
  749. 0xC0 /* End Collection */
  750. };
  751. const size_t uclogic_rdesc_ugee_g5_frame_size =
  752. sizeof(uclogic_rdesc_ugee_g5_frame_arr);
  753. /* Fixed report descriptor for XP-Pen Deco 01 frame controls */
  754. const __u8 uclogic_rdesc_xppen_deco01_frame_arr[] = {
  755. 0x05, 0x01, /* Usage Page (Desktop), */
  756. 0x09, 0x07, /* Usage (Keypad), */
  757. 0xA1, 0x01, /* Collection (Application), */
  758. 0x85, 0x06, /* Report ID (6), */
  759. 0x14, /* Logical Minimum (0), */
  760. 0x25, 0x01, /* Logical Maximum (1), */
  761. 0x75, 0x01, /* Report Size (1), */
  762. 0x05, 0x0D, /* Usage Page (Digitizer), */
  763. 0x09, 0x39, /* Usage (Tablet Function Keys), */
  764. 0xA0, /* Collection (Physical), */
  765. 0x05, 0x09, /* Usage Page (Button), */
  766. 0x19, 0x01, /* Usage Minimum (01h), */
  767. 0x29, 0x08, /* Usage Maximum (08h), */
  768. 0x95, 0x08, /* Report Count (8), */
  769. 0x81, 0x02, /* Input (Variable), */
  770. 0x05, 0x0D, /* Usage Page (Digitizer), */
  771. 0x09, 0x44, /* Usage (Barrel Switch), */
  772. 0x95, 0x01, /* Report Count (1), */
  773. 0x81, 0x02, /* Input (Variable), */
  774. 0x05, 0x01, /* Usage Page (Desktop), */
  775. 0x09, 0x30, /* Usage (X), */
  776. 0x09, 0x31, /* Usage (Y), */
  777. 0x95, 0x02, /* Report Count (2), */
  778. 0x81, 0x02, /* Input (Variable), */
  779. 0x95, 0x15, /* Report Count (21), */
  780. 0x81, 0x01, /* Input (Constant), */
  781. 0xC0, /* End Collection, */
  782. 0xC0 /* End Collection */
  783. };
  784. const size_t uclogic_rdesc_xppen_deco01_frame_size =
  785. sizeof(uclogic_rdesc_xppen_deco01_frame_arr);
  786. /**
  787. * uclogic_rdesc_template_apply() - apply report descriptor parameters to a
  788. * report descriptor template, creating a report descriptor. Copies the
  789. * template over to the new report descriptor and replaces every occurrence of
  790. * UCLOGIC_RDESC_PH_HEAD, followed by an index byte, with the value from the
  791. * parameter list at that index.
  792. *
  793. * @template_ptr: Pointer to the template buffer.
  794. * @template_size: Size of the template buffer.
  795. * @param_list: List of template parameters.
  796. * @param_num: Number of parameters in the list.
  797. *
  798. * Returns:
  799. * Kmalloc-allocated pointer to the created report descriptor,
  800. * or NULL if allocation failed.
  801. */
  802. __u8 *uclogic_rdesc_template_apply(const __u8 *template_ptr,
  803. size_t template_size,
  804. const s32 *param_list,
  805. size_t param_num)
  806. {
  807. static const __u8 head[] = {UCLOGIC_RDESC_PH_HEAD};
  808. __u8 *rdesc_ptr;
  809. __u8 *p;
  810. s32 v;
  811. rdesc_ptr = kmemdup(template_ptr, template_size, GFP_KERNEL);
  812. if (rdesc_ptr == NULL)
  813. return NULL;
  814. for (p = rdesc_ptr; p + sizeof(head) < rdesc_ptr + template_size;) {
  815. if (memcmp(p, head, sizeof(head)) == 0 &&
  816. p[sizeof(head)] < param_num) {
  817. v = param_list[p[sizeof(head)]];
  818. put_unaligned(cpu_to_le32(v), (s32 *)p);
  819. p += sizeof(head) + 1;
  820. } else {
  821. p++;
  822. }
  823. }
  824. return rdesc_ptr;
  825. }