hid-uclogic-rdesc.c 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238
  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, 0x01, /* Usage (Digitizer), */
  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, 0x01, /* Usage (Digitizer), */
  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, 0x01, /* Usage (Digitizer), */
  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, 0x01, /* Usage (Digitizer), */
  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, 0x01, /* Usage (Digitizer), */
  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, 0x01, /* Usage (Digitizer), */
  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, 0x01, /* Usage (Digitizer), */
  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_v1_pen_template_arr[] = {
  513. 0x05, 0x0D, /* Usage Page (Digitizer), */
  514. 0x09, 0x01, /* Usage (Digitizer), */
  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_v1_pen_template_size =
  562. sizeof(uclogic_rdesc_v1_pen_template_arr);
  563. /* Fixed report descriptor template for (tweaked) v2 pen reports */
  564. const __u8 uclogic_rdesc_v2_pen_template_arr[] = {
  565. 0x05, 0x0D, /* Usage Page (Digitizer), */
  566. 0x09, 0x01, /* Usage (Digitizer), */
  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. 0x54, /* Unit Exponent (0), */
  612. 0x65, 0x14, /* Unit (Degrees), */
  613. 0x35, 0xC4, /* Physical Minimum (-60), */
  614. 0x45, 0x3C, /* Physical Maximum (60), */
  615. 0x15, 0xC4, /* Logical Minimum (-60), */
  616. 0x25, 0x3C, /* Logical Maximum (60), */
  617. 0x75, 0x08, /* Report Size (8), */
  618. 0x95, 0x02, /* Report Count (2), */
  619. 0x09, 0x3D, /* Usage (X Tilt), */
  620. 0x09, 0x3E, /* Usage (Y Tilt), */
  621. 0x81, 0x02, /* Input (Variable), */
  622. 0xC0, /* End Collection, */
  623. 0xC0 /* End Collection */
  624. };
  625. const size_t uclogic_rdesc_v2_pen_template_size =
  626. sizeof(uclogic_rdesc_v2_pen_template_arr);
  627. /*
  628. * Expand to the contents of a generic frame buttons report descriptor.
  629. *
  630. * @_id: The report ID to use.
  631. * @_size: Size of the report to pad to, including report ID, bytes.
  632. */
  633. #define UCLOGIC_RDESC_FRAME_BUTTONS_BYTES(_id, _size) \
  634. 0x05, 0x01, /* Usage Page (Desktop), */ \
  635. 0x09, 0x07, /* Usage (Keypad), */ \
  636. 0xA1, 0x01, /* Collection (Application), */ \
  637. 0x85, (_id), /* Report ID (_id), */ \
  638. 0x14, /* Logical Minimum (0), */ \
  639. 0x25, 0x01, /* Logical Maximum (1), */ \
  640. 0x75, 0x01, /* Report Size (1), */ \
  641. 0x05, 0x0D, /* Usage Page (Digitizer), */ \
  642. 0x09, 0x39, /* Usage (Tablet Function Keys), */ \
  643. 0xA0, /* Collection (Physical), */ \
  644. 0x09, 0x44, /* Usage (Barrel Switch), */ \
  645. 0x95, 0x01, /* Report Count (1), */ \
  646. 0x81, 0x02, /* Input (Variable), */ \
  647. 0x05, 0x01, /* Usage Page (Desktop), */ \
  648. 0x09, 0x30, /* Usage (X), */ \
  649. 0x09, 0x31, /* Usage (Y), */ \
  650. 0x95, 0x02, /* Report Count (2), */ \
  651. 0x81, 0x02, /* Input (Variable), */ \
  652. 0x95, 0x15, /* Report Count (21), */ \
  653. 0x81, 0x01, /* Input (Constant), */ \
  654. 0x05, 0x09, /* Usage Page (Button), */ \
  655. 0x19, 0x01, /* Usage Minimum (01h), */ \
  656. 0x29, 0x0A, /* Usage Maximum (0Ah), */ \
  657. 0x95, 0x0A, /* Report Count (10), */ \
  658. 0x81, 0x02, /* Input (Variable), */ \
  659. 0xC0, /* End Collection, */ \
  660. 0x05, 0x01, /* Usage Page (Desktop), */ \
  661. 0x09, 0x05, /* Usage (Gamepad), */ \
  662. 0xA0, /* Collection (Physical), */ \
  663. 0x05, 0x09, /* Usage Page (Button), */ \
  664. 0x19, 0x01, /* Usage Minimum (01h), */ \
  665. 0x29, 0x03, /* Usage Maximum (03h), */ \
  666. 0x95, 0x03, /* Report Count (3), */ \
  667. 0x81, 0x02, /* Input (Variable), */ \
  668. 0x95, ((_size) * 8 - 45), \
  669. /* Report Count (padding), */ \
  670. 0x81, 0x01, /* Input (Constant), */ \
  671. 0xC0, /* End Collection, */ \
  672. 0xC0 /* End Collection */
  673. /* Fixed report descriptor for (tweaked) v1 frame reports */
  674. const __u8 uclogic_rdesc_v1_frame_arr[] = {
  675. UCLOGIC_RDESC_FRAME_BUTTONS_BYTES(UCLOGIC_RDESC_V1_FRAME_ID, 8)
  676. };
  677. const size_t uclogic_rdesc_v1_frame_size =
  678. sizeof(uclogic_rdesc_v1_frame_arr);
  679. /* Fixed report descriptor for (tweaked) v2 frame button reports */
  680. const __u8 uclogic_rdesc_v2_frame_buttons_arr[] = {
  681. UCLOGIC_RDESC_FRAME_BUTTONS_BYTES(UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID,
  682. 12)
  683. };
  684. const size_t uclogic_rdesc_v2_frame_buttons_size =
  685. sizeof(uclogic_rdesc_v2_frame_buttons_arr);
  686. /* Fixed report descriptor for (tweaked) v2 frame touch ring reports */
  687. const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[] = {
  688. 0x05, 0x01, /* Usage Page (Desktop), */
  689. 0x09, 0x07, /* Usage (Keypad), */
  690. 0xA1, 0x01, /* Collection (Application), */
  691. 0x85, UCLOGIC_RDESC_V2_FRAME_TOUCH_ID,
  692. /* Report ID (TOUCH_ID), */
  693. 0x14, /* Logical Minimum (0), */
  694. 0x05, 0x0D, /* Usage Page (Digitizer), */
  695. 0x09, 0x39, /* Usage (Tablet Function Keys), */
  696. 0xA0, /* Collection (Physical), */
  697. 0x25, 0x01, /* Logical Maximum (1), */
  698. 0x75, 0x01, /* Report Size (1), */
  699. 0x05, 0x09, /* Usage Page (Button), */
  700. 0x09, 0x01, /* Usage (01h), */
  701. 0x95, 0x01, /* Report Count (1), */
  702. 0x81, 0x02, /* Input (Variable), */
  703. 0x95, 0x07, /* Report Count (7), */
  704. 0x81, 0x01, /* Input (Constant), */
  705. 0x75, 0x08, /* Report Size (8), */
  706. 0x95, 0x02, /* Report Count (2), */
  707. 0x81, 0x01, /* Input (Constant), */
  708. 0x05, 0x0D, /* Usage Page (Digitizer), */
  709. 0x0A, 0xFF, 0xFF, /* Usage (FFFFh), */
  710. 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
  711. 0x95, 0x01, /* Report Count (1), */
  712. 0x81, 0x02, /* Input (Variable), */
  713. 0x05, 0x01, /* Usage Page (Desktop), */
  714. 0x09, 0x38, /* Usage (Wheel), */
  715. 0x95, 0x01, /* Report Count (1), */
  716. 0x15, 0x00, /* Logical Minimum (0), */
  717. 0x25, 0x0B, /* Logical Maximum (11), */
  718. 0x81, 0x02, /* Input (Variable), */
  719. 0x09, 0x30, /* Usage (X), */
  720. 0x09, 0x31, /* Usage (Y), */
  721. 0x14, /* Logical Minimum (0), */
  722. 0x25, 0x01, /* Logical Maximum (1), */
  723. 0x75, 0x01, /* Report Size (1), */
  724. 0x95, 0x02, /* Report Count (2), */
  725. 0x81, 0x02, /* Input (Variable), */
  726. 0x95, 0x2E, /* Report Count (46), */
  727. 0x81, 0x01, /* Input (Constant), */
  728. 0xC0, /* End Collection, */
  729. 0xC0 /* End Collection */
  730. };
  731. const size_t uclogic_rdesc_v2_frame_touch_ring_size =
  732. sizeof(uclogic_rdesc_v2_frame_touch_ring_arr);
  733. /* Fixed report descriptor for (tweaked) v2 frame touch strip reports */
  734. const __u8 uclogic_rdesc_v2_frame_touch_strip_arr[] = {
  735. 0x05, 0x01, /* Usage Page (Desktop), */
  736. 0x09, 0x07, /* Usage (Keypad), */
  737. 0xA1, 0x01, /* Collection (Application), */
  738. 0x85, UCLOGIC_RDESC_V2_FRAME_TOUCH_ID,
  739. /* Report ID (TOUCH_ID), */
  740. 0x14, /* Logical Minimum (0), */
  741. 0x05, 0x0D, /* Usage Page (Digitizer), */
  742. 0x09, 0x39, /* Usage (Tablet Function Keys), */
  743. 0xA0, /* Collection (Physical), */
  744. 0x25, 0x01, /* Logical Maximum (1), */
  745. 0x75, 0x01, /* Report Size (1), */
  746. 0x05, 0x09, /* Usage Page (Button), */
  747. 0x09, 0x01, /* Usage (01h), */
  748. 0x95, 0x01, /* Report Count (1), */
  749. 0x81, 0x02, /* Input (Variable), */
  750. 0x95, 0x07, /* Report Count (7), */
  751. 0x81, 0x01, /* Input (Constant), */
  752. 0x75, 0x08, /* Report Size (8), */
  753. 0x95, 0x02, /* Report Count (2), */
  754. 0x81, 0x01, /* Input (Constant), */
  755. 0x05, 0x0D, /* Usage Page (Digitizer), */
  756. 0x0A, 0xFF, 0xFF, /* Usage (FFFFh), */
  757. 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
  758. 0x95, 0x01, /* Report Count (1), */
  759. 0x81, 0x02, /* Input (Variable), */
  760. 0x05, 0x01, /* Usage Page (Desktop), */
  761. 0x09, 0x38, /* Usage (Wheel), */
  762. 0x95, 0x01, /* Report Count (1), */
  763. 0x15, 0x00, /* Logical Minimum (0), */
  764. 0x25, 0x07, /* Logical Maximum (7), */
  765. 0x81, 0x02, /* Input (Variable), */
  766. 0x09, 0x30, /* Usage (X), */
  767. 0x09, 0x31, /* Usage (Y), */
  768. 0x14, /* Logical Minimum (0), */
  769. 0x25, 0x01, /* Logical Maximum (1), */
  770. 0x75, 0x01, /* Report Size (1), */
  771. 0x95, 0x02, /* Report Count (2), */
  772. 0x81, 0x02, /* Input (Variable), */
  773. 0x95, 0x2E, /* Report Count (46), */
  774. 0x81, 0x01, /* Input (Constant), */
  775. 0xC0, /* End Collection, */
  776. 0xC0 /* End Collection */
  777. };
  778. const size_t uclogic_rdesc_v2_frame_touch_strip_size =
  779. sizeof(uclogic_rdesc_v2_frame_touch_strip_arr);
  780. /* Fixed report descriptor for (tweaked) v2 frame dial reports */
  781. const __u8 uclogic_rdesc_v2_frame_dial_arr[] = {
  782. 0x05, 0x01, /* Usage Page (Desktop), */
  783. 0x09, 0x07, /* Usage (Keypad), */
  784. 0xA1, 0x01, /* Collection (Application), */
  785. 0x85, UCLOGIC_RDESC_V2_FRAME_DIAL_ID,
  786. /* Report ID (DIAL_ID), */
  787. 0x14, /* Logical Minimum (0), */
  788. 0x05, 0x0D, /* Usage Page (Digitizer), */
  789. 0x09, 0x39, /* Usage (Tablet Function Keys), */
  790. 0xA0, /* Collection (Physical), */
  791. 0x25, 0x01, /* Logical Maximum (1), */
  792. 0x75, 0x01, /* Report Size (1), */
  793. 0x95, 0x01, /* Report Count (1), */
  794. 0x81, 0x01, /* Input (Constant), */
  795. 0x05, 0x09, /* Usage Page (Button), */
  796. 0x09, 0x01, /* Usage (01h), */
  797. 0x95, 0x01, /* Report Count (1), */
  798. 0x81, 0x02, /* Input (Variable), */
  799. 0x95, 0x06, /* Report Count (6), */
  800. 0x81, 0x01, /* Input (Constant), */
  801. 0x75, 0x08, /* Report Size (8), */
  802. 0x95, 0x02, /* Report Count (2), */
  803. 0x81, 0x01, /* Input (Constant), */
  804. 0x05, 0x0D, /* Usage Page (Digitizer), */
  805. 0x0A, 0xFF, 0xFF, /* Usage (FFFFh), */
  806. 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
  807. 0x95, 0x01, /* Report Count (1), */
  808. 0x81, 0x02, /* Input (Variable), */
  809. 0x05, 0x01, /* Usage Page (Desktop), */
  810. 0x09, 0x38, /* Usage (Wheel), */
  811. 0x95, 0x01, /* Report Count (1), */
  812. 0x15, 0xFF, /* Logical Minimum (-1), */
  813. 0x25, 0x01, /* Logical Maximum (1), */
  814. 0x81, 0x06, /* Input (Variable, Relative), */
  815. 0x09, 0x30, /* Usage (X), */
  816. 0x09, 0x31, /* Usage (Y), */
  817. 0x14, /* Logical Minimum (0), */
  818. 0x25, 0x01, /* Logical Maximum (1), */
  819. 0x75, 0x01, /* Report Size (1), */
  820. 0x95, 0x02, /* Report Count (2), */
  821. 0x81, 0x02, /* Input (Variable), */
  822. 0x95, 0x2E, /* Report Count (46), */
  823. 0x81, 0x01, /* Input (Constant), */
  824. 0xC0, /* End Collection, */
  825. 0xC0 /* End Collection */
  826. };
  827. const size_t uclogic_rdesc_v2_frame_dial_size =
  828. sizeof(uclogic_rdesc_v2_frame_dial_arr);
  829. /* Fixed report descriptor template for UGEE v2 pen reports */
  830. const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[] = {
  831. 0x05, 0x0d, /* Usage Page (Digitizers), */
  832. 0x09, 0x01, /* Usage (Digitizer), */
  833. 0xa1, 0x01, /* Collection (Application), */
  834. 0x85, 0x02, /* Report ID (2), */
  835. 0x09, 0x20, /* Usage (Stylus), */
  836. 0xa1, 0x00, /* Collection (Physical), */
  837. 0x09, 0x42, /* Usage (Tip Switch), */
  838. 0x09, 0x44, /* Usage (Barrel Switch), */
  839. 0x09, 0x46, /* Usage (Tablet Pick), */
  840. 0x75, 0x01, /* Report Size (1), */
  841. 0x95, 0x03, /* Report Count (3), */
  842. 0x14, /* Logical Minimum (0), */
  843. 0x25, 0x01, /* Logical Maximum (1), */
  844. 0x81, 0x02, /* Input (Variable), */
  845. 0x95, 0x02, /* Report Count (2), */
  846. 0x81, 0x03, /* Input (Constant, Variable), */
  847. 0x09, 0x32, /* Usage (In Range), */
  848. 0x95, 0x01, /* Report Count (1), */
  849. 0x81, 0x02, /* Input (Variable), */
  850. 0x95, 0x02, /* Report Count (2), */
  851. 0x81, 0x03, /* Input (Constant, Variable), */
  852. 0x75, 0x10, /* Report Size (16), */
  853. 0x95, 0x01, /* Report Count (1), */
  854. 0x35, 0x00, /* Physical Minimum (0), */
  855. 0xa4, /* Push, */
  856. 0x05, 0x01, /* Usage Page (Desktop), */
  857. 0x09, 0x30, /* Usage (X), */
  858. 0x65, 0x13, /* Unit (Inch), */
  859. 0x55, 0x0d, /* Unit Exponent (-3), */
  860. 0x27, UCLOGIC_RDESC_PEN_PH(X_LM),
  861. /* Logical Maximum (PLACEHOLDER), */
  862. 0x47, UCLOGIC_RDESC_PEN_PH(X_PM),
  863. /* Physical Maximum (PLACEHOLDER), */
  864. 0x81, 0x02, /* Input (Variable), */
  865. 0x09, 0x31, /* Usage (Y), */
  866. 0x27, UCLOGIC_RDESC_PEN_PH(Y_LM),
  867. /* Logical Maximum (PLACEHOLDER), */
  868. 0x47, UCLOGIC_RDESC_PEN_PH(Y_PM),
  869. /* Physical Maximum (PLACEHOLDER), */
  870. 0x81, 0x02, /* Input (Variable), */
  871. 0xb4, /* Pop, */
  872. 0x09, 0x30, /* Usage (Tip Pressure), */
  873. 0x45, 0x00, /* Physical Maximum (0), */
  874. 0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM),
  875. /* Logical Maximum (PLACEHOLDER), */
  876. 0x75, 0x0D, /* Report Size (13), */
  877. 0x95, 0x01, /* Report Count (1), */
  878. 0x81, 0x02, /* Input (Variable), */
  879. 0x75, 0x01, /* Report Size (1), */
  880. 0x95, 0x03, /* Report Count (3), */
  881. 0x81, 0x01, /* Input (Constant), */
  882. 0x09, 0x3d, /* Usage (X Tilt), */
  883. 0x35, 0xC3, /* Physical Minimum (-61), */
  884. 0x45, 0x3C, /* Physical Maximum (60), */
  885. 0x15, 0xC3, /* Logical Minimum (-61), */
  886. 0x25, 0x3C, /* Logical Maximum (60), */
  887. 0x75, 0x08, /* Report Size (8), */
  888. 0x95, 0x01, /* Report Count (1), */
  889. 0x81, 0x02, /* Input (Variable), */
  890. 0x09, 0x3e, /* Usage (Y Tilt), */
  891. 0x35, 0xC3, /* Physical Minimum (-61), */
  892. 0x45, 0x3C, /* Physical Maximum (60), */
  893. 0x15, 0xC3, /* Logical Minimum (-61), */
  894. 0x25, 0x3C, /* Logical Maximum (60), */
  895. 0x81, 0x02, /* Input (Variable), */
  896. 0xc0, /* End Collection, */
  897. 0xc0, /* End Collection */
  898. };
  899. const size_t uclogic_rdesc_ugee_v2_pen_template_size =
  900. sizeof(uclogic_rdesc_ugee_v2_pen_template_arr);
  901. /* Fixed report descriptor template for UGEE v2 frame reports (buttons only) */
  902. const __u8 uclogic_rdesc_ugee_v2_frame_btn_template_arr[] = {
  903. 0x05, 0x01, /* Usage Page (Desktop), */
  904. 0x09, 0x07, /* Usage (Keypad), */
  905. 0xA1, 0x01, /* Collection (Application), */
  906. 0x85, UCLOGIC_RDESC_V1_FRAME_ID,
  907. /* Report ID, */
  908. 0x05, 0x0D, /* Usage Page (Digitizer), */
  909. 0x09, 0x39, /* Usage (Tablet Function Keys), */
  910. 0xA0, /* Collection (Physical), */
  911. 0x75, 0x01, /* Report Size (1), */
  912. 0x95, 0x08, /* Report Count (8), */
  913. 0x81, 0x01, /* Input (Constant), */
  914. 0x05, 0x09, /* Usage Page (Button), */
  915. 0x19, 0x01, /* Usage Minimum (01h), */
  916. UCLOGIC_RDESC_FRAME_PH_BTN,
  917. /* Usage Maximum (PLACEHOLDER), */
  918. 0x95, 0x0A, /* Report Count (10), */
  919. 0x14, /* Logical Minimum (0), */
  920. 0x25, 0x01, /* Logical Maximum (1), */
  921. 0x81, 0x02, /* Input (Variable), */
  922. 0x95, 0x46, /* Report Count (70), */
  923. 0x81, 0x01, /* Input (Constant), */
  924. 0xC0, /* End Collection, */
  925. 0xC0 /* End Collection */
  926. };
  927. const size_t uclogic_rdesc_ugee_v2_frame_btn_template_size =
  928. sizeof(uclogic_rdesc_ugee_v2_frame_btn_template_arr);
  929. /* Fixed report descriptor template for UGEE v2 frame reports (dial) */
  930. const __u8 uclogic_rdesc_ugee_v2_frame_dial_template_arr[] = {
  931. 0x05, 0x01, /* Usage Page (Desktop), */
  932. 0x09, 0x07, /* Usage (Keypad), */
  933. 0xA1, 0x01, /* Collection (Application), */
  934. 0x85, UCLOGIC_RDESC_V1_FRAME_ID,
  935. /* Report ID, */
  936. 0x05, 0x0D, /* Usage Page (Digitizer), */
  937. 0x09, 0x39, /* Usage (Tablet Function Keys), */
  938. 0xA0, /* Collection (Physical), */
  939. 0x75, 0x01, /* Report Size (1), */
  940. 0x95, 0x08, /* Report Count (8), */
  941. 0x81, 0x01, /* Input (Constant), */
  942. 0x05, 0x09, /* Usage Page (Button), */
  943. 0x19, 0x01, /* Usage Minimum (01h), */
  944. UCLOGIC_RDESC_FRAME_PH_BTN,
  945. /* Usage Maximum (PLACEHOLDER), */
  946. 0x95, 0x0A, /* Report Count (10), */
  947. 0x14, /* Logical Minimum (0), */
  948. 0x25, 0x01, /* Logical Maximum (1), */
  949. 0x81, 0x02, /* Input (Variable), */
  950. 0x95, 0x06, /* Report Count (6), */
  951. 0x81, 0x01, /* Input (Constant), */
  952. 0x75, 0x08, /* Report Size (8), */
  953. 0x95, 0x03, /* Report Count (3), */
  954. 0x81, 0x01, /* Input (Constant), */
  955. 0x05, 0x01, /* Usage Page (Desktop), */
  956. 0x09, 0x38, /* Usage (Wheel), */
  957. 0x95, 0x01, /* Report Count (1), */
  958. 0x15, 0xFF, /* Logical Minimum (-1), */
  959. 0x25, 0x01, /* Logical Maximum (1), */
  960. 0x81, 0x06, /* Input (Variable, Relative), */
  961. 0x95, 0x02, /* Report Count (2), */
  962. 0x81, 0x01, /* Input (Constant), */
  963. 0xC0, /* End Collection, */
  964. 0xC0 /* End Collection */
  965. };
  966. const size_t uclogic_rdesc_ugee_v2_frame_dial_template_size =
  967. sizeof(uclogic_rdesc_ugee_v2_frame_dial_template_arr);
  968. /* Fixed report descriptor template for UGEE v2 frame reports (mouse) */
  969. const __u8 uclogic_rdesc_ugee_v2_frame_mouse_template_arr[] = {
  970. 0x05, 0x01, /* Usage Page (Desktop), */
  971. 0x09, 0x02, /* Usage (Mouse), */
  972. 0xA1, 0x01, /* Collection (Application), */
  973. 0x85, 0x01, /* Report ID (1), */
  974. 0x05, 0x01, /* Usage Page (Pointer), */
  975. 0xA0, /* Collection (Physical), */
  976. 0x75, 0x01, /* Report Size (1), */
  977. 0x95, 0x02, /* Report Count (2), */
  978. 0x05, 0x09, /* Usage Page (Button), */
  979. 0x19, 0x01, /* Usage Minimum (01h), */
  980. 0x29, 0x02, /* Usage Maximum (02h), */
  981. 0x14, /* Logical Minimum (0), */
  982. 0x25, 0x01, /* Logical Maximum (1), */
  983. 0x81, 0x02, /* Input (Variable), */
  984. 0x95, 0x06, /* Report Count (6), */
  985. 0x81, 0x01, /* Input (Constant), */
  986. 0x05, 0x01, /* Usage Page (Generic Desktop), */
  987. 0x09, 0x30, /* Usage (X), */
  988. 0x09, 0x31, /* Usage (Y), */
  989. 0x75, 0x10, /* Report Size (16), */
  990. 0x95, 0x02, /* Report Count (2), */
  991. 0x16, 0x00, 0x80, /* Logical Minimum (-32768), */
  992. 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
  993. 0x81, 0x06, /* Input (Variable, Relative), */
  994. 0x95, 0x01, /* Report Count (1), */
  995. 0x81, 0x01, /* Input (Constant), */
  996. 0xC0, /* End Collection, */
  997. 0xC0 /* End Collection */
  998. };
  999. const size_t uclogic_rdesc_ugee_v2_frame_mouse_template_size =
  1000. sizeof(uclogic_rdesc_ugee_v2_frame_mouse_template_arr);
  1001. /* Fixed report descriptor template for UGEE v2 battery reports */
  1002. const __u8 uclogic_rdesc_ugee_v2_battery_template_arr[] = {
  1003. 0x05, 0x01, /* Usage Page (Desktop), */
  1004. 0x09, 0x07, /* Usage (Keypad), */
  1005. 0xA1, 0x01, /* Collection (Application), */
  1006. 0x85, UCLOGIC_RDESC_UGEE_V2_BATTERY_ID,
  1007. /* Report ID, */
  1008. 0x75, 0x08, /* Report Size (8), */
  1009. 0x95, 0x02, /* Report Count (2), */
  1010. 0x81, 0x01, /* Input (Constant), */
  1011. 0x05, 0x84, /* Usage Page (Power Device), */
  1012. 0x05, 0x85, /* Usage Page (Battery System), */
  1013. 0x09, 0x65, /* Usage Page (AbsoluteStateOfCharge), */
  1014. 0x75, 0x08, /* Report Size (8), */
  1015. 0x95, 0x01, /* Report Count (1), */
  1016. 0x15, 0x00, /* Logical Minimum (0), */
  1017. 0x26, 0xff, 0x00, /* Logical Maximum (255), */
  1018. 0x81, 0x02, /* Input (Variable), */
  1019. 0x75, 0x01, /* Report Size (1), */
  1020. 0x95, 0x01, /* Report Count (1), */
  1021. 0x15, 0x00, /* Logical Minimum (0), */
  1022. 0x25, 0x01, /* Logical Maximum (1), */
  1023. 0x09, 0x44, /* Usage Page (Charging), */
  1024. 0x81, 0x02, /* Input (Variable), */
  1025. 0x95, 0x07, /* Report Count (7), */
  1026. 0x81, 0x01, /* Input (Constant), */
  1027. 0x75, 0x08, /* Report Size (8), */
  1028. 0x95, 0x07, /* Report Count (7), */
  1029. 0x81, 0x01, /* Input (Constant), */
  1030. 0xC0 /* End Collection */
  1031. };
  1032. const size_t uclogic_rdesc_ugee_v2_battery_template_size =
  1033. sizeof(uclogic_rdesc_ugee_v2_battery_template_arr);
  1034. /* Fixed report descriptor for Ugee EX07 frame */
  1035. const __u8 uclogic_rdesc_ugee_ex07_frame_arr[] = {
  1036. 0x05, 0x01, /* Usage Page (Desktop), */
  1037. 0x09, 0x07, /* Usage (Keypad), */
  1038. 0xA1, 0x01, /* Collection (Application), */
  1039. 0x85, 0x06, /* Report ID (6), */
  1040. 0x05, 0x0D, /* Usage Page (Digitizer), */
  1041. 0x09, 0x39, /* Usage (Tablet Function Keys), */
  1042. 0xA0, /* Collection (Physical), */
  1043. 0x05, 0x09, /* Usage Page (Button), */
  1044. 0x75, 0x01, /* Report Size (1), */
  1045. 0x19, 0x03, /* Usage Minimum (03h), */
  1046. 0x29, 0x06, /* Usage Maximum (06h), */
  1047. 0x95, 0x04, /* Report Count (4), */
  1048. 0x81, 0x02, /* Input (Variable), */
  1049. 0x95, 0x1A, /* Report Count (26), */
  1050. 0x81, 0x03, /* Input (Constant, Variable), */
  1051. 0x19, 0x01, /* Usage Minimum (01h), */
  1052. 0x29, 0x02, /* Usage Maximum (02h), */
  1053. 0x95, 0x02, /* Report Count (2), */
  1054. 0x81, 0x02, /* Input (Variable), */
  1055. 0xC0, /* End Collection, */
  1056. 0xC0 /* End Collection */
  1057. };
  1058. const size_t uclogic_rdesc_ugee_ex07_frame_size =
  1059. sizeof(uclogic_rdesc_ugee_ex07_frame_arr);
  1060. /* Fixed report descriptor for Ugee G5 frame controls */
  1061. const __u8 uclogic_rdesc_ugee_g5_frame_arr[] = {
  1062. 0x05, 0x01, /* Usage Page (Desktop), */
  1063. 0x09, 0x07, /* Usage (Keypad), */
  1064. 0xA1, 0x01, /* Collection (Application), */
  1065. 0x85, 0x06, /* Report ID (6), */
  1066. 0x05, 0x0D, /* Usage Page (Digitizer), */
  1067. 0x09, 0x39, /* Usage (Tablet Function Keys), */
  1068. 0xA0, /* Collection (Physical), */
  1069. 0x14, /* Logical Minimum (0), */
  1070. 0x25, 0x01, /* Logical Maximum (1), */
  1071. 0x05, 0x01, /* Usage Page (Desktop), */
  1072. 0x05, 0x09, /* Usage Page (Button), */
  1073. 0x19, 0x01, /* Usage Minimum (01h), */
  1074. 0x29, 0x05, /* Usage Maximum (05h), */
  1075. 0x75, 0x01, /* Report Size (1), */
  1076. 0x95, 0x05, /* Report Count (5), */
  1077. 0x81, 0x02, /* Input (Variable), */
  1078. 0x75, 0x01, /* Report Size (1), */
  1079. 0x95, 0x03, /* Report Count (3), */
  1080. 0x81, 0x01, /* Input (Constant), */
  1081. 0x05, 0x0D, /* Usage Page (Digitizer), */
  1082. 0x0A, 0xFF, 0xFF, /* Usage (FFFFh), */
  1083. 0x26, 0xFF, 0x00, /* Logical Maximum (255), */
  1084. 0x75, 0x08, /* Report Size (8), */
  1085. 0x95, 0x01, /* Report Count (1), */
  1086. 0x81, 0x02, /* Input (Variable), */
  1087. 0x25, 0x01, /* Logical Maximum (1), */
  1088. 0x09, 0x44, /* Usage (Barrel Switch), */
  1089. 0x75, 0x01, /* Report Size (1), */
  1090. 0x95, 0x01, /* Report Count (1), */
  1091. 0x81, 0x02, /* Input (Variable), */
  1092. 0x05, 0x01, /* Usage Page (Desktop), */
  1093. 0x09, 0x30, /* Usage (X), */
  1094. 0x09, 0x31, /* Usage (Y), */
  1095. 0x75, 0x01, /* Report Size (1), */
  1096. 0x95, 0x02, /* Report Count (2), */
  1097. 0x81, 0x02, /* Input (Variable), */
  1098. 0x75, 0x01, /* Report Size (1), */
  1099. 0x95, 0x0B, /* Report Count (11), */
  1100. 0x81, 0x01, /* Input (Constant), */
  1101. 0x05, 0x01, /* Usage Page (Desktop), */
  1102. 0x09, 0x38, /* Usage (Wheel), */
  1103. 0x15, 0xFF, /* Logical Minimum (-1), */
  1104. 0x25, 0x01, /* Logical Maximum (1), */
  1105. 0x75, 0x02, /* Report Size (2), */
  1106. 0x95, 0x01, /* Report Count (1), */
  1107. 0x81, 0x06, /* Input (Variable, Relative), */
  1108. 0xC0, /* End Collection, */
  1109. 0xC0 /* End Collection */
  1110. };
  1111. const size_t uclogic_rdesc_ugee_g5_frame_size =
  1112. sizeof(uclogic_rdesc_ugee_g5_frame_arr);
  1113. /* Fixed report descriptor for XP-Pen Deco 01 frame controls */
  1114. const __u8 uclogic_rdesc_xppen_deco01_frame_arr[] = {
  1115. 0x05, 0x01, /* Usage Page (Desktop), */
  1116. 0x09, 0x07, /* Usage (Keypad), */
  1117. 0xA1, 0x01, /* Collection (Application), */
  1118. 0x85, 0x06, /* Report ID (6), */
  1119. 0x14, /* Logical Minimum (0), */
  1120. 0x25, 0x01, /* Logical Maximum (1), */
  1121. 0x75, 0x01, /* Report Size (1), */
  1122. 0x05, 0x0D, /* Usage Page (Digitizer), */
  1123. 0x09, 0x39, /* Usage (Tablet Function Keys), */
  1124. 0xA0, /* Collection (Physical), */
  1125. 0x05, 0x09, /* Usage Page (Button), */
  1126. 0x19, 0x01, /* Usage Minimum (01h), */
  1127. 0x29, 0x08, /* Usage Maximum (08h), */
  1128. 0x95, 0x08, /* Report Count (8), */
  1129. 0x81, 0x02, /* Input (Variable), */
  1130. 0x05, 0x0D, /* Usage Page (Digitizer), */
  1131. 0x09, 0x44, /* Usage (Barrel Switch), */
  1132. 0x95, 0x01, /* Report Count (1), */
  1133. 0x81, 0x02, /* Input (Variable), */
  1134. 0x05, 0x01, /* Usage Page (Desktop), */
  1135. 0x09, 0x30, /* Usage (X), */
  1136. 0x09, 0x31, /* Usage (Y), */
  1137. 0x95, 0x02, /* Report Count (2), */
  1138. 0x81, 0x02, /* Input (Variable), */
  1139. 0x95, 0x15, /* Report Count (21), */
  1140. 0x81, 0x01, /* Input (Constant), */
  1141. 0xC0, /* End Collection, */
  1142. 0xC0 /* End Collection */
  1143. };
  1144. const size_t uclogic_rdesc_xppen_deco01_frame_size =
  1145. sizeof(uclogic_rdesc_xppen_deco01_frame_arr);
  1146. /**
  1147. * uclogic_rdesc_template_apply() - apply report descriptor parameters to a
  1148. * report descriptor template, creating a report descriptor. Copies the
  1149. * template over to the new report descriptor and replaces every occurrence of
  1150. * the template placeholders, followed by an index byte, with the value from the
  1151. * parameter list at that index.
  1152. *
  1153. * @template_ptr: Pointer to the template buffer.
  1154. * @template_size: Size of the template buffer.
  1155. * @param_list: List of template parameters.
  1156. * @param_num: Number of parameters in the list.
  1157. *
  1158. * Returns:
  1159. * Kmalloc-allocated pointer to the created report descriptor,
  1160. * or NULL if allocation failed.
  1161. */
  1162. __u8 *uclogic_rdesc_template_apply(const __u8 *template_ptr,
  1163. size_t template_size,
  1164. const s32 *param_list,
  1165. size_t param_num)
  1166. {
  1167. static const __u8 btn_head[] = {UCLOGIC_RDESC_FRAME_PH_BTN_HEAD};
  1168. static const __u8 pen_head[] = {UCLOGIC_RDESC_PEN_PH_HEAD};
  1169. __u8 *rdesc_ptr;
  1170. __u8 *p;
  1171. s32 v;
  1172. rdesc_ptr = kmemdup(template_ptr, template_size, GFP_KERNEL);
  1173. if (rdesc_ptr == NULL)
  1174. return NULL;
  1175. for (p = rdesc_ptr; p + sizeof(btn_head) < rdesc_ptr + template_size;) {
  1176. if (p + sizeof(pen_head) < rdesc_ptr + template_size &&
  1177. memcmp(p, pen_head, sizeof(pen_head)) == 0 &&
  1178. p[sizeof(pen_head)] < param_num) {
  1179. v = param_list[p[sizeof(pen_head)]];
  1180. put_unaligned((__force u32)cpu_to_le32(v), (s32 *)p);
  1181. p += sizeof(pen_head) + 1;
  1182. } else if (memcmp(p, btn_head, sizeof(btn_head)) == 0 &&
  1183. p[sizeof(btn_head)] < param_num) {
  1184. v = param_list[p[sizeof(btn_head)]];
  1185. put_unaligned((__u8)0x2A, p); /* Usage Maximum */
  1186. put_unaligned((__force u16)cpu_to_le16(v), (s16 *)(p + 1));
  1187. p += sizeof(btn_head) + 1;
  1188. } else {
  1189. p++;
  1190. }
  1191. }
  1192. return rdesc_ptr;
  1193. }