xref: /OK3568_Linux_fs/kernel/drivers/hid/hid-waltop.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-or-later
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  *  HID driver for Waltop devices not fully compliant with HID standard
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  *  Copyright (c) 2010 Nikolai Kondrashov
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun /*
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <linux/device.h>
12*4882a593Smuzhiyun #include <linux/hid.h>
13*4882a593Smuzhiyun #include <linux/module.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include "hid-ids.h"
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun /*
18*4882a593Smuzhiyun  * There exists an official driver on the manufacturer's website, which
19*4882a593Smuzhiyun  * wasn't submitted to the kernel, for some reason. The official driver
20*4882a593Smuzhiyun  * doesn't seem to support extra features of some tablets, like wheels.
21*4882a593Smuzhiyun  *
22*4882a593Smuzhiyun  * It shows that the feature report ID 2 could be used to control any waltop
23*4882a593Smuzhiyun  * tablet input mode, switching it between "default", "tablet" and "ink".
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  * This driver only uses "default" mode for all the supported tablets. This
26*4882a593Smuzhiyun  * mode tries to be HID-compatible (not very successfully), but cripples the
27*4882a593Smuzhiyun  * resolution of some tablets.
28*4882a593Smuzhiyun  *
29*4882a593Smuzhiyun  * The "tablet" mode uses some proprietary, yet decipherable protocol, which
30*4882a593Smuzhiyun  * represents the correct resolution, but is possibly HID-incompatible (i.e.
31*4882a593Smuzhiyun  * indescribable by a report descriptor).
32*4882a593Smuzhiyun  *
33*4882a593Smuzhiyun  * The purpose of the "ink" mode is unknown.
34*4882a593Smuzhiyun  *
35*4882a593Smuzhiyun  * The feature reports needed for switching to each mode are these:
36*4882a593Smuzhiyun  *
37*4882a593Smuzhiyun  * 02 16 00     default
38*4882a593Smuzhiyun  * 02 16 01     tablet
39*4882a593Smuzhiyun  * 02 16 02     ink
40*4882a593Smuzhiyun  */
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /* Size of the original report descriptor of Slim Tablet 5.8 inch */
43*4882a593Smuzhiyun #define SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE	222
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun /* Fixed Slim Tablet 5.8 inch descriptor */
46*4882a593Smuzhiyun static __u8 slim_tablet_5_8_inch_rdesc_fixed[] = {
47*4882a593Smuzhiyun 	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
48*4882a593Smuzhiyun 	0x09, 0x02,         /*  Usage (Pen),                        */
49*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
50*4882a593Smuzhiyun 	0x85, 0x10,         /*      Report ID (16),                 */
51*4882a593Smuzhiyun 	0x09, 0x20,         /*      Usage (Stylus),                 */
52*4882a593Smuzhiyun 	0xA0,               /*      Collection (Physical),          */
53*4882a593Smuzhiyun 	0x09, 0x42,         /*          Usage (Tip Switch),         */
54*4882a593Smuzhiyun 	0x09, 0x44,         /*          Usage (Barrel Switch),      */
55*4882a593Smuzhiyun 	0x09, 0x46,         /*          Usage (Tablet Pick),        */
56*4882a593Smuzhiyun 	0x15, 0x01,         /*          Logical Minimum (1),        */
57*4882a593Smuzhiyun 	0x25, 0x03,         /*          Logical Maximum (3),        */
58*4882a593Smuzhiyun 	0x75, 0x04,         /*          Report Size (4),            */
59*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
60*4882a593Smuzhiyun 	0x80,               /*          Input,                      */
61*4882a593Smuzhiyun 	0x09, 0x32,         /*          Usage (In Range),           */
62*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
63*4882a593Smuzhiyun 	0x25, 0x01,         /*          Logical Maximum (1),        */
64*4882a593Smuzhiyun 	0x75, 0x01,         /*          Report Size (1),            */
65*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
66*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
67*4882a593Smuzhiyun 	0x95, 0x03,         /*          Report Count (3),           */
68*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
69*4882a593Smuzhiyun 	0x75, 0x10,         /*          Report Size (16),           */
70*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
71*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
72*4882a593Smuzhiyun 	0xA4,               /*          Push,                       */
73*4882a593Smuzhiyun 	0x05, 0x01,         /*          Usage Page (Desktop),       */
74*4882a593Smuzhiyun 	0x65, 0x13,         /*          Unit (Inch),                */
75*4882a593Smuzhiyun 	0x55, 0xFD,         /*          Unit Exponent (-3),         */
76*4882a593Smuzhiyun 	0x34,               /*          Physical Minimum (0),       */
77*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (X),                  */
78*4882a593Smuzhiyun 	0x46, 0x88, 0x13,   /*          Physical Maximum (5000),    */
79*4882a593Smuzhiyun 	0x26, 0x10, 0x27,   /*          Logical Maximum (10000),    */
80*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
81*4882a593Smuzhiyun 	0x09, 0x31,         /*          Usage (Y),                  */
82*4882a593Smuzhiyun 	0x46, 0xB8, 0x0B,   /*          Physical Maximum (3000),    */
83*4882a593Smuzhiyun 	0x26, 0x70, 0x17,   /*          Logical Maximum (6000),     */
84*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
85*4882a593Smuzhiyun 	0xB4,               /*          Pop,                        */
86*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (Tip Pressure),       */
87*4882a593Smuzhiyun 	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
88*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
89*4882a593Smuzhiyun 	0xC0,               /*      End Collection,                 */
90*4882a593Smuzhiyun 	0xC0                /*  End Collection                      */
91*4882a593Smuzhiyun };
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun /* Size of the original report descriptor of Slim Tablet 12.1 inch */
94*4882a593Smuzhiyun #define SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE	269
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun /* Fixed Slim Tablet 12.1 inch descriptor */
97*4882a593Smuzhiyun static __u8 slim_tablet_12_1_inch_rdesc_fixed[] = {
98*4882a593Smuzhiyun 	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
99*4882a593Smuzhiyun 	0x09, 0x02,         /*  Usage (Pen),                        */
100*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
101*4882a593Smuzhiyun 	0x85, 0x10,         /*      Report ID (16),                 */
102*4882a593Smuzhiyun 	0x09, 0x20,         /*      Usage (Stylus),                 */
103*4882a593Smuzhiyun 	0xA0,               /*      Collection (Physical),          */
104*4882a593Smuzhiyun 	0x09, 0x42,         /*          Usage (Tip Switch),         */
105*4882a593Smuzhiyun 	0x09, 0x44,         /*          Usage (Barrel Switch),      */
106*4882a593Smuzhiyun 	0x09, 0x46,         /*          Usage (Tablet Pick),        */
107*4882a593Smuzhiyun 	0x15, 0x01,         /*          Logical Minimum (1),        */
108*4882a593Smuzhiyun 	0x25, 0x03,         /*          Logical Maximum (3),        */
109*4882a593Smuzhiyun 	0x75, 0x04,         /*          Report Size (4),            */
110*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
111*4882a593Smuzhiyun 	0x80,               /*          Input,                      */
112*4882a593Smuzhiyun 	0x09, 0x32,         /*          Usage (In Range),           */
113*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
114*4882a593Smuzhiyun 	0x25, 0x01,         /*          Logical Maximum (1),        */
115*4882a593Smuzhiyun 	0x75, 0x01,         /*          Report Size (1),            */
116*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
117*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
118*4882a593Smuzhiyun 	0x95, 0x03,         /*          Report Count (3),           */
119*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
120*4882a593Smuzhiyun 	0x75, 0x10,         /*          Report Size (16),           */
121*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
122*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
123*4882a593Smuzhiyun 	0xA4,               /*          Push,                       */
124*4882a593Smuzhiyun 	0x05, 0x01,         /*          Usage Page (Desktop),       */
125*4882a593Smuzhiyun 	0x65, 0x13,         /*          Unit (Inch),                */
126*4882a593Smuzhiyun 	0x55, 0xFD,         /*          Unit Exponent (-3),         */
127*4882a593Smuzhiyun 	0x34,               /*          Physical Minimum (0),       */
128*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (X),                  */
129*4882a593Smuzhiyun 	0x46, 0x10, 0x27,   /*          Physical Maximum (10000),   */
130*4882a593Smuzhiyun 	0x26, 0x20, 0x4E,   /*          Logical Maximum (20000),    */
131*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
132*4882a593Smuzhiyun 	0x09, 0x31,         /*          Usage (Y),                  */
133*4882a593Smuzhiyun 	0x46, 0x6A, 0x18,   /*          Physical Maximum (6250),    */
134*4882a593Smuzhiyun 	0x26, 0xD4, 0x30,   /*          Logical Maximum (12500),    */
135*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
136*4882a593Smuzhiyun 	0xB4,               /*          Pop,                        */
137*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (Tip Pressure),       */
138*4882a593Smuzhiyun 	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
139*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
140*4882a593Smuzhiyun 	0xC0,               /*      End Collection,                 */
141*4882a593Smuzhiyun 	0xC0                /*  End Collection                      */
142*4882a593Smuzhiyun };
143*4882a593Smuzhiyun 
144*4882a593Smuzhiyun /* Size of the original report descriptor of Q Pad */
145*4882a593Smuzhiyun #define Q_PAD_RDESC_ORIG_SIZE	241
146*4882a593Smuzhiyun 
147*4882a593Smuzhiyun /* Fixed Q Pad descriptor */
148*4882a593Smuzhiyun static __u8 q_pad_rdesc_fixed[] = {
149*4882a593Smuzhiyun 	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
150*4882a593Smuzhiyun 	0x09, 0x02,         /*  Usage (Pen),                        */
151*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
152*4882a593Smuzhiyun 	0x85, 0x10,         /*      Report ID (16),                 */
153*4882a593Smuzhiyun 	0x09, 0x20,         /*      Usage (Stylus),                 */
154*4882a593Smuzhiyun 	0xA0,               /*      Collection (Physical),          */
155*4882a593Smuzhiyun 	0x09, 0x42,         /*          Usage (Tip Switch),         */
156*4882a593Smuzhiyun 	0x09, 0x44,         /*          Usage (Barrel Switch),      */
157*4882a593Smuzhiyun 	0x09, 0x46,         /*          Usage (Tablet Pick),        */
158*4882a593Smuzhiyun 	0x15, 0x01,         /*          Logical Minimum (1),        */
159*4882a593Smuzhiyun 	0x25, 0x03,         /*          Logical Maximum (3),        */
160*4882a593Smuzhiyun 	0x75, 0x04,         /*          Report Size (4),            */
161*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
162*4882a593Smuzhiyun 	0x80,               /*          Input,                      */
163*4882a593Smuzhiyun 	0x09, 0x32,         /*          Usage (In Range),           */
164*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
165*4882a593Smuzhiyun 	0x25, 0x01,         /*          Logical Maximum (1),        */
166*4882a593Smuzhiyun 	0x75, 0x01,         /*          Report Size (1),            */
167*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
168*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
169*4882a593Smuzhiyun 	0x95, 0x03,         /*          Report Count (3),           */
170*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
171*4882a593Smuzhiyun 	0x75, 0x10,         /*          Report Size (16),           */
172*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
173*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
174*4882a593Smuzhiyun 	0xA4,               /*          Push,                       */
175*4882a593Smuzhiyun 	0x05, 0x01,         /*          Usage Page (Desktop),       */
176*4882a593Smuzhiyun 	0x65, 0x13,         /*          Unit (Inch),                */
177*4882a593Smuzhiyun 	0x55, 0xFD,         /*          Unit Exponent (-3),         */
178*4882a593Smuzhiyun 	0x34,               /*          Physical Minimum (0),       */
179*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (X),                  */
180*4882a593Smuzhiyun 	0x46, 0x70, 0x17,   /*          Physical Maximum (6000),    */
181*4882a593Smuzhiyun 	0x26, 0x00, 0x30,   /*          Logical Maximum (12288),    */
182*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
183*4882a593Smuzhiyun 	0x09, 0x31,         /*          Usage (Y),                  */
184*4882a593Smuzhiyun 	0x46, 0x94, 0x11,   /*          Physical Maximum (4500),    */
185*4882a593Smuzhiyun 	0x26, 0x00, 0x24,   /*          Logical Maximum (9216),     */
186*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
187*4882a593Smuzhiyun 	0xB4,               /*          Pop,                        */
188*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (Tip Pressure),       */
189*4882a593Smuzhiyun 	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
190*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
191*4882a593Smuzhiyun 	0xC0,               /*      End Collection,                 */
192*4882a593Smuzhiyun 	0xC0                /*  End Collection                      */
193*4882a593Smuzhiyun };
194*4882a593Smuzhiyun 
195*4882a593Smuzhiyun /* Size of the original report descriptor of tablet with PID 0038 */
196*4882a593Smuzhiyun #define PID_0038_RDESC_ORIG_SIZE	241
197*4882a593Smuzhiyun 
198*4882a593Smuzhiyun /*
199*4882a593Smuzhiyun  * Fixed report descriptor for tablet with PID 0038.
200*4882a593Smuzhiyun  */
201*4882a593Smuzhiyun static __u8 pid_0038_rdesc_fixed[] = {
202*4882a593Smuzhiyun 	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
203*4882a593Smuzhiyun 	0x09, 0x02,         /*  Usage (Pen),                        */
204*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
205*4882a593Smuzhiyun 	0x85, 0x10,         /*      Report ID (16),                 */
206*4882a593Smuzhiyun 	0x09, 0x20,         /*      Usage (Stylus),                 */
207*4882a593Smuzhiyun 	0xA0,               /*      Collection (Physical),          */
208*4882a593Smuzhiyun 	0x09, 0x42,         /*          Usage (Tip Switch),         */
209*4882a593Smuzhiyun 	0x09, 0x44,         /*          Usage (Barrel Switch),      */
210*4882a593Smuzhiyun 	0x09, 0x46,         /*          Usage (Tablet Pick),        */
211*4882a593Smuzhiyun 	0x15, 0x01,         /*          Logical Minimum (1),        */
212*4882a593Smuzhiyun 	0x25, 0x03,         /*          Logical Maximum (3),        */
213*4882a593Smuzhiyun 	0x75, 0x04,         /*          Report Size (4),            */
214*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
215*4882a593Smuzhiyun 	0x80,               /*          Input,                      */
216*4882a593Smuzhiyun 	0x09, 0x32,         /*          Usage (In Range),           */
217*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
218*4882a593Smuzhiyun 	0x25, 0x01,         /*          Logical Maximum (1),        */
219*4882a593Smuzhiyun 	0x75, 0x01,         /*          Report Size (1),            */
220*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
221*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
222*4882a593Smuzhiyun 	0x95, 0x03,         /*          Report Count (3),           */
223*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
224*4882a593Smuzhiyun 	0x75, 0x10,         /*          Report Size (16),           */
225*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
226*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
227*4882a593Smuzhiyun 	0xA4,               /*          Push,                       */
228*4882a593Smuzhiyun 	0x05, 0x01,         /*          Usage Page (Desktop),       */
229*4882a593Smuzhiyun 	0x65, 0x13,         /*          Unit (Inch),                */
230*4882a593Smuzhiyun 	0x55, 0xFD,         /*          Unit Exponent (-3),         */
231*4882a593Smuzhiyun 	0x34,               /*          Physical Minimum (0),       */
232*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (X),                  */
233*4882a593Smuzhiyun 	0x46, 0x2E, 0x22,   /*          Physical Maximum (8750),    */
234*4882a593Smuzhiyun 	0x26, 0x00, 0x46,   /*          Logical Maximum (17920),    */
235*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
236*4882a593Smuzhiyun 	0x09, 0x31,         /*          Usage (Y),                  */
237*4882a593Smuzhiyun 	0x46, 0x82, 0x14,   /*          Physical Maximum (5250),    */
238*4882a593Smuzhiyun 	0x26, 0x00, 0x2A,   /*          Logical Maximum (10752),    */
239*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
240*4882a593Smuzhiyun 	0xB4,               /*          Pop,                        */
241*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (Tip Pressure),       */
242*4882a593Smuzhiyun 	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
243*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
244*4882a593Smuzhiyun 	0xC0,               /*      End Collection,                 */
245*4882a593Smuzhiyun 	0xC0                /*  End Collection                      */
246*4882a593Smuzhiyun };
247*4882a593Smuzhiyun 
248*4882a593Smuzhiyun /* Size of the original report descriptor of Media Tablet 10.6 inch */
249*4882a593Smuzhiyun #define MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE	300
250*4882a593Smuzhiyun 
251*4882a593Smuzhiyun /* Fixed Media Tablet 10.6 inch descriptor */
252*4882a593Smuzhiyun static __u8 media_tablet_10_6_inch_rdesc_fixed[] = {
253*4882a593Smuzhiyun 	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
254*4882a593Smuzhiyun 	0x09, 0x02,         /*  Usage (Pen),                        */
255*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
256*4882a593Smuzhiyun 	0x85, 0x10,         /*      Report ID (16),                 */
257*4882a593Smuzhiyun 	0x09, 0x20,         /*      Usage (Stylus),                 */
258*4882a593Smuzhiyun 	0xA0,               /*      Collection (Physical),          */
259*4882a593Smuzhiyun 	0x09, 0x42,         /*          Usage (Tip Switch),         */
260*4882a593Smuzhiyun 	0x09, 0x44,         /*          Usage (Barrel Switch),      */
261*4882a593Smuzhiyun 	0x09, 0x46,         /*          Usage (Tablet Pick),        */
262*4882a593Smuzhiyun 	0x15, 0x01,         /*          Logical Minimum (1),        */
263*4882a593Smuzhiyun 	0x25, 0x03,         /*          Logical Maximum (3),        */
264*4882a593Smuzhiyun 	0x75, 0x04,         /*          Report Size (4),            */
265*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
266*4882a593Smuzhiyun 	0x80,               /*          Input,                      */
267*4882a593Smuzhiyun 	0x75, 0x01,         /*          Report Size (1),            */
268*4882a593Smuzhiyun 	0x09, 0x32,         /*          Usage (In Range),           */
269*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
270*4882a593Smuzhiyun 	0x25, 0x01,         /*          Logical Maximum (1),        */
271*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
272*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
273*4882a593Smuzhiyun 	0x95, 0x03,         /*          Report Count (3),           */
274*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
275*4882a593Smuzhiyun 	0x75, 0x10,         /*          Report Size (16),           */
276*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
277*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
278*4882a593Smuzhiyun 	0xA4,               /*          Push,                       */
279*4882a593Smuzhiyun 	0x05, 0x01,         /*          Usage Page (Desktop),       */
280*4882a593Smuzhiyun 	0x65, 0x13,         /*          Unit (Inch),                */
281*4882a593Smuzhiyun 	0x55, 0xFD,         /*          Unit Exponent (-3),         */
282*4882a593Smuzhiyun 	0x34,               /*          Physical Minimum (0),       */
283*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (X),                  */
284*4882a593Smuzhiyun 	0x46, 0x28, 0x23,   /*          Physical Maximum (9000),    */
285*4882a593Smuzhiyun 	0x26, 0x50, 0x46,   /*          Logical Maximum (18000),    */
286*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
287*4882a593Smuzhiyun 	0x09, 0x31,         /*          Usage (Y),                  */
288*4882a593Smuzhiyun 	0x46, 0x7C, 0x15,   /*          Physical Maximum (5500),    */
289*4882a593Smuzhiyun 	0x26, 0xF8, 0x2A,   /*          Logical Maximum (11000),    */
290*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
291*4882a593Smuzhiyun 	0xB4,               /*          Pop,                        */
292*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (Tip Pressure),       */
293*4882a593Smuzhiyun 	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
294*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
295*4882a593Smuzhiyun 	0xC0,               /*      End Collection,                 */
296*4882a593Smuzhiyun 	0xC0,               /*  End Collection,                     */
297*4882a593Smuzhiyun 	0x05, 0x01,         /*  Usage Page (Desktop),               */
298*4882a593Smuzhiyun 	0x09, 0x02,         /*  Usage (Mouse),                      */
299*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
300*4882a593Smuzhiyun 	0x85, 0x01,         /*      Report ID (1),                  */
301*4882a593Smuzhiyun 	0x09, 0x01,         /*      Usage (Pointer),                */
302*4882a593Smuzhiyun 	0xA0,               /*      Collection (Physical),          */
303*4882a593Smuzhiyun 	0x75, 0x08,         /*          Report Size (8),            */
304*4882a593Smuzhiyun 	0x95, 0x03,         /*          Report Count (3),           */
305*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
306*4882a593Smuzhiyun 	0x95, 0x02,         /*          Report Count (2),           */
307*4882a593Smuzhiyun 	0x15, 0xFF,         /*          Logical Minimum (-1),       */
308*4882a593Smuzhiyun 	0x25, 0x01,         /*          Logical Maximum (1),        */
309*4882a593Smuzhiyun 	0x09, 0x38,         /*          Usage (Wheel),              */
310*4882a593Smuzhiyun 	0x0B, 0x38, 0x02,   /*          Usage (Consumer AC Pan),    */
311*4882a593Smuzhiyun 		0x0C, 0x00,
312*4882a593Smuzhiyun 	0x81, 0x06,         /*          Input (Variable, Relative), */
313*4882a593Smuzhiyun 	0x95, 0x02,         /*          Report Count (2),           */
314*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
315*4882a593Smuzhiyun 	0xC0,               /*      End Collection,                 */
316*4882a593Smuzhiyun 	0xC0,               /*  End Collection,                     */
317*4882a593Smuzhiyun 	0x05, 0x0C,         /*  Usage Page (Consumer),              */
318*4882a593Smuzhiyun 	0x09, 0x01,         /*  Usage (Consumer Control),           */
319*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
320*4882a593Smuzhiyun 	0x85, 0x0D,         /*      Report ID (13),                 */
321*4882a593Smuzhiyun 	0x95, 0x01,         /*      Report Count (1),               */
322*4882a593Smuzhiyun 	0x75, 0x10,         /*      Report Size (16),               */
323*4882a593Smuzhiyun 	0x81, 0x03,         /*      Input (Constant, Variable),     */
324*4882a593Smuzhiyun 	0x0A, 0x2F, 0x02,   /*      Usage (AC Zoom),                */
325*4882a593Smuzhiyun 	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
326*4882a593Smuzhiyun 	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
327*4882a593Smuzhiyun 	0x09, 0xB6,         /*      Usage (Scan Previous Track),    */
328*4882a593Smuzhiyun 	0x09, 0xB5,         /*      Usage (Scan Next Track),        */
329*4882a593Smuzhiyun 	0x08,               /*      Usage (00h),                    */
330*4882a593Smuzhiyun 	0x08,               /*      Usage (00h),                    */
331*4882a593Smuzhiyun 	0x08,               /*      Usage (00h),                    */
332*4882a593Smuzhiyun 	0x08,               /*      Usage (00h),                    */
333*4882a593Smuzhiyun 	0x08,               /*      Usage (00h),                    */
334*4882a593Smuzhiyun 	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
335*4882a593Smuzhiyun 	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
336*4882a593Smuzhiyun 	0x15, 0x0C,         /*      Logical Minimum (12),           */
337*4882a593Smuzhiyun 	0x25, 0x17,         /*      Logical Maximum (23),           */
338*4882a593Smuzhiyun 	0x75, 0x05,         /*      Report Size (5),                */
339*4882a593Smuzhiyun 	0x80,               /*      Input,                          */
340*4882a593Smuzhiyun 	0x75, 0x03,         /*      Report Size (3),                */
341*4882a593Smuzhiyun 	0x81, 0x03,         /*      Input (Constant, Variable),     */
342*4882a593Smuzhiyun 	0x75, 0x20,         /*      Report Size (32),               */
343*4882a593Smuzhiyun 	0x81, 0x03,         /*      Input (Constant, Variable),     */
344*4882a593Smuzhiyun 	0xC0,               /*  End Collection,                     */
345*4882a593Smuzhiyun 	0x09, 0x01,         /*  Usage (Consumer Control),           */
346*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
347*4882a593Smuzhiyun 	0x85, 0x0C,         /*      Report ID (12),                 */
348*4882a593Smuzhiyun 	0x75, 0x01,         /*      Report Size (1),                */
349*4882a593Smuzhiyun 	0x09, 0xE9,         /*      Usage (Volume Inc),             */
350*4882a593Smuzhiyun 	0x09, 0xEA,         /*      Usage (Volume Dec),             */
351*4882a593Smuzhiyun 	0x09, 0xE2,         /*      Usage (Mute),                   */
352*4882a593Smuzhiyun 	0x14,               /*      Logical Minimum (0),            */
353*4882a593Smuzhiyun 	0x25, 0x01,         /*      Logical Maximum (1),            */
354*4882a593Smuzhiyun 	0x95, 0x03,         /*      Report Count (3),               */
355*4882a593Smuzhiyun 	0x81, 0x06,         /*      Input (Variable, Relative),     */
356*4882a593Smuzhiyun 	0x95, 0x35,         /*      Report Count (53),              */
357*4882a593Smuzhiyun 	0x81, 0x03,         /*      Input (Constant, Variable),     */
358*4882a593Smuzhiyun 	0xC0                /*  End Collection                      */
359*4882a593Smuzhiyun };
360*4882a593Smuzhiyun 
361*4882a593Smuzhiyun /* Size of the original report descriptor of Media Tablet 14.1 inch */
362*4882a593Smuzhiyun #define MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE	309
363*4882a593Smuzhiyun 
364*4882a593Smuzhiyun /* Fixed Media Tablet 14.1 inch descriptor */
365*4882a593Smuzhiyun static __u8 media_tablet_14_1_inch_rdesc_fixed[] = {
366*4882a593Smuzhiyun 	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
367*4882a593Smuzhiyun 	0x09, 0x02,         /*  Usage (Pen),                        */
368*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
369*4882a593Smuzhiyun 	0x85, 0x10,         /*      Report ID (16),                 */
370*4882a593Smuzhiyun 	0x09, 0x20,         /*      Usage (Stylus),                 */
371*4882a593Smuzhiyun 	0xA0,               /*      Collection (Physical),          */
372*4882a593Smuzhiyun 	0x09, 0x42,         /*          Usage (Tip Switch),         */
373*4882a593Smuzhiyun 	0x09, 0x44,         /*          Usage (Barrel Switch),      */
374*4882a593Smuzhiyun 	0x09, 0x46,         /*          Usage (Tablet Pick),        */
375*4882a593Smuzhiyun 	0x15, 0x01,         /*          Logical Minimum (1),        */
376*4882a593Smuzhiyun 	0x25, 0x03,         /*          Logical Maximum (3),        */
377*4882a593Smuzhiyun 	0x75, 0x04,         /*          Report Size (4),            */
378*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
379*4882a593Smuzhiyun 	0x80,               /*          Input,                      */
380*4882a593Smuzhiyun 	0x75, 0x01,         /*          Report Size (1),            */
381*4882a593Smuzhiyun 	0x09, 0x32,         /*          Usage (In Range),           */
382*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
383*4882a593Smuzhiyun 	0x25, 0x01,         /*          Logical Maximum (1),        */
384*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
385*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
386*4882a593Smuzhiyun 	0x95, 0x03,         /*          Report Count (3),           */
387*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
388*4882a593Smuzhiyun 	0x75, 0x10,         /*          Report Size (16),           */
389*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
390*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
391*4882a593Smuzhiyun 	0xA4,               /*          Push,                       */
392*4882a593Smuzhiyun 	0x05, 0x01,         /*          Usage Page (Desktop),       */
393*4882a593Smuzhiyun 	0x65, 0x13,         /*          Unit (Inch),                */
394*4882a593Smuzhiyun 	0x55, 0xFD,         /*          Unit Exponent (-3),         */
395*4882a593Smuzhiyun 	0x34,               /*          Physical Minimum (0),       */
396*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (X),                  */
397*4882a593Smuzhiyun 	0x46, 0xE0, 0x2E,   /*          Physical Maximum (12000),   */
398*4882a593Smuzhiyun 	0x26, 0xFF, 0x3F,   /*          Logical Maximum (16383),    */
399*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
400*4882a593Smuzhiyun 	0x09, 0x31,         /*          Usage (Y),                  */
401*4882a593Smuzhiyun 	0x46, 0x52, 0x1C,   /*          Physical Maximum (7250),    */
402*4882a593Smuzhiyun 	0x26, 0xFF, 0x3F,   /*          Logical Maximum (16383),    */
403*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
404*4882a593Smuzhiyun 	0xB4,               /*          Pop,                        */
405*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (Tip Pressure),       */
406*4882a593Smuzhiyun 	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
407*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
408*4882a593Smuzhiyun 	0xC0,               /*      End Collection,                 */
409*4882a593Smuzhiyun 	0xC0,               /*  End Collection,                     */
410*4882a593Smuzhiyun 	0x05, 0x01,         /*  Usage Page (Desktop),               */
411*4882a593Smuzhiyun 	0x09, 0x02,         /*  Usage (Mouse),                      */
412*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
413*4882a593Smuzhiyun 	0x85, 0x01,         /*      Report ID (1),                  */
414*4882a593Smuzhiyun 	0x09, 0x01,         /*      Usage (Pointer),                */
415*4882a593Smuzhiyun 	0xA0,               /*      Collection (Physical),          */
416*4882a593Smuzhiyun 	0x75, 0x08,         /*          Report Size (8),            */
417*4882a593Smuzhiyun 	0x95, 0x03,         /*          Report Count (3),           */
418*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
419*4882a593Smuzhiyun 	0x95, 0x02,         /*          Report Count (2),           */
420*4882a593Smuzhiyun 	0x15, 0xFF,         /*          Logical Minimum (-1),       */
421*4882a593Smuzhiyun 	0x25, 0x01,         /*          Logical Maximum (1),        */
422*4882a593Smuzhiyun 	0x09, 0x38,         /*          Usage (Wheel),              */
423*4882a593Smuzhiyun 	0x0B, 0x38, 0x02,   /*          Usage (Consumer AC Pan),    */
424*4882a593Smuzhiyun 		0x0C, 0x00,
425*4882a593Smuzhiyun 	0x81, 0x06,         /*          Input (Variable, Relative), */
426*4882a593Smuzhiyun 	0xC0,               /*      End Collection,                 */
427*4882a593Smuzhiyun 	0xC0,               /*  End Collection,                     */
428*4882a593Smuzhiyun 	0x05, 0x0C,         /*  Usage Page (Consumer),              */
429*4882a593Smuzhiyun 	0x09, 0x01,         /*  Usage (Consumer Control),           */
430*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
431*4882a593Smuzhiyun 	0x85, 0x0D,         /*      Report ID (13),                 */
432*4882a593Smuzhiyun 	0x95, 0x01,         /*      Report Count (1),               */
433*4882a593Smuzhiyun 	0x75, 0x10,         /*      Report Size (16),               */
434*4882a593Smuzhiyun 	0x81, 0x03,         /*      Input (Constant, Variable),     */
435*4882a593Smuzhiyun 	0x0A, 0x2F, 0x02,   /*      Usage (AC Zoom),                */
436*4882a593Smuzhiyun 	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
437*4882a593Smuzhiyun 	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
438*4882a593Smuzhiyun 	0x09, 0xB6,         /*      Usage (Scan Previous Track),    */
439*4882a593Smuzhiyun 	0x09, 0xB5,         /*      Usage (Scan Next Track),        */
440*4882a593Smuzhiyun 	0x08,               /*      Usage (00h),                    */
441*4882a593Smuzhiyun 	0x08,               /*      Usage (00h),                    */
442*4882a593Smuzhiyun 	0x08,               /*      Usage (00h),                    */
443*4882a593Smuzhiyun 	0x08,               /*      Usage (00h),                    */
444*4882a593Smuzhiyun 	0x08,               /*      Usage (00h),                    */
445*4882a593Smuzhiyun 	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
446*4882a593Smuzhiyun 	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
447*4882a593Smuzhiyun 	0x15, 0x0C,         /*      Logical Minimum (12),           */
448*4882a593Smuzhiyun 	0x25, 0x17,         /*      Logical Maximum (23),           */
449*4882a593Smuzhiyun 	0x75, 0x05,         /*      Report Size (5),                */
450*4882a593Smuzhiyun 	0x80,               /*      Input,                          */
451*4882a593Smuzhiyun 	0x75, 0x03,         /*      Report Size (3),                */
452*4882a593Smuzhiyun 	0x81, 0x03,         /*      Input (Constant, Variable),     */
453*4882a593Smuzhiyun 	0x75, 0x20,         /*      Report Size (32),               */
454*4882a593Smuzhiyun 	0x81, 0x03,         /*      Input (Constant, Variable),     */
455*4882a593Smuzhiyun 	0xC0,               /*  End Collection,                     */
456*4882a593Smuzhiyun 	0x09, 0x01,         /*  Usage (Consumer Control),           */
457*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
458*4882a593Smuzhiyun 	0x85, 0x0C,         /*      Report ID (12),                 */
459*4882a593Smuzhiyun 	0x75, 0x01,         /*      Report Size (1),                */
460*4882a593Smuzhiyun 	0x09, 0xE9,         /*      Usage (Volume Inc),             */
461*4882a593Smuzhiyun 	0x09, 0xEA,         /*      Usage (Volume Dec),             */
462*4882a593Smuzhiyun 	0x09, 0xE2,         /*      Usage (Mute),                   */
463*4882a593Smuzhiyun 	0x14,               /*      Logical Minimum (0),            */
464*4882a593Smuzhiyun 	0x25, 0x01,         /*      Logical Maximum (1),            */
465*4882a593Smuzhiyun 	0x95, 0x03,         /*      Report Count (3),               */
466*4882a593Smuzhiyun 	0x81, 0x06,         /*      Input (Variable, Relative),     */
467*4882a593Smuzhiyun 	0x75, 0x05,         /*      Report Size (5),                */
468*4882a593Smuzhiyun 	0x81, 0x03,         /*      Input (Constant, Variable),     */
469*4882a593Smuzhiyun 	0xC0                /*  End Collection                      */
470*4882a593Smuzhiyun };
471*4882a593Smuzhiyun 
472*4882a593Smuzhiyun /* Size of the original report descriptor of Sirius Battery Free Tablet */
473*4882a593Smuzhiyun #define SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE	335
474*4882a593Smuzhiyun 
475*4882a593Smuzhiyun /* Fixed Sirius Battery Free Tablet descriptor */
476*4882a593Smuzhiyun static __u8 sirius_battery_free_tablet_rdesc_fixed[] = {
477*4882a593Smuzhiyun 	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
478*4882a593Smuzhiyun 	0x09, 0x02,         /*  Usage (Pen),                        */
479*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
480*4882a593Smuzhiyun 	0x85, 0x10,         /*      Report ID (16),                 */
481*4882a593Smuzhiyun 	0x09, 0x20,         /*      Usage (Stylus),                 */
482*4882a593Smuzhiyun 	0xA0,               /*      Collection (Physical),          */
483*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
484*4882a593Smuzhiyun 	0x15, 0x01,         /*          Logical Minimum (1),        */
485*4882a593Smuzhiyun 	0x25, 0x03,         /*          Logical Maximum (3),        */
486*4882a593Smuzhiyun 	0x75, 0x02,         /*          Report Size (2),            */
487*4882a593Smuzhiyun 	0x09, 0x42,         /*          Usage (Tip Switch),         */
488*4882a593Smuzhiyun 	0x09, 0x44,         /*          Usage (Barrel Switch),      */
489*4882a593Smuzhiyun 	0x09, 0x46,         /*          Usage (Tablet Pick),        */
490*4882a593Smuzhiyun 	0x80,               /*          Input,                      */
491*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
492*4882a593Smuzhiyun 	0x25, 0x01,         /*          Logical Maximum (1),        */
493*4882a593Smuzhiyun 	0x75, 0x01,         /*          Report Size (1),            */
494*4882a593Smuzhiyun 	0x09, 0x3C,         /*          Usage (Invert),             */
495*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
496*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
497*4882a593Smuzhiyun 	0x09, 0x32,         /*          Usage (In Range),           */
498*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
499*4882a593Smuzhiyun 	0x95, 0x03,         /*          Report Count (3),           */
500*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
501*4882a593Smuzhiyun 	0xA4,               /*          Push,                       */
502*4882a593Smuzhiyun 	0x05, 0x01,         /*          Usage Page (Desktop),       */
503*4882a593Smuzhiyun 	0x55, 0xFD,         /*          Unit Exponent (-3),         */
504*4882a593Smuzhiyun 	0x65, 0x13,         /*          Unit (Inch),                */
505*4882a593Smuzhiyun 	0x34,               /*          Physical Minimum (0),       */
506*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
507*4882a593Smuzhiyun 	0x75, 0x10,         /*          Report Size (16),           */
508*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
509*4882a593Smuzhiyun 	0x46, 0x10, 0x27,   /*          Physical Maximum (10000),   */
510*4882a593Smuzhiyun 	0x26, 0x20, 0x4E,   /*          Logical Maximum (20000),    */
511*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (X),                  */
512*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
513*4882a593Smuzhiyun 	0x46, 0x70, 0x17,   /*          Physical Maximum (6000),    */
514*4882a593Smuzhiyun 	0x26, 0xE0, 0x2E,   /*          Logical Maximum (12000),    */
515*4882a593Smuzhiyun 	0x09, 0x31,         /*          Usage (Y),                  */
516*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
517*4882a593Smuzhiyun 	0xB4,               /*          Pop,                        */
518*4882a593Smuzhiyun 	0x75, 0x10,         /*          Report Size (16),           */
519*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
520*4882a593Smuzhiyun 	0x14,               /*          Logical Minimum (0),        */
521*4882a593Smuzhiyun 	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
522*4882a593Smuzhiyun 	0x09, 0x30,         /*          Usage (Tip Pressure),       */
523*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
524*4882a593Smuzhiyun 	0xA4,               /*          Push,                       */
525*4882a593Smuzhiyun 	0x55, 0xFE,         /*          Unit Exponent (-2),         */
526*4882a593Smuzhiyun 	0x65, 0x12,         /*          Unit (Radians),             */
527*4882a593Smuzhiyun 	0x35, 0x97,         /*          Physical Minimum (-105),    */
528*4882a593Smuzhiyun 	0x45, 0x69,         /*          Physical Maximum (105),     */
529*4882a593Smuzhiyun 	0x15, 0x97,         /*          Logical Minimum (-105),     */
530*4882a593Smuzhiyun 	0x25, 0x69,         /*          Logical Maximum (105),      */
531*4882a593Smuzhiyun 	0x75, 0x08,         /*          Report Size (8),            */
532*4882a593Smuzhiyun 	0x95, 0x02,         /*          Report Count (2),           */
533*4882a593Smuzhiyun 	0x09, 0x3D,         /*          Usage (X Tilt),             */
534*4882a593Smuzhiyun 	0x09, 0x3E,         /*          Usage (Y Tilt),             */
535*4882a593Smuzhiyun 	0x81, 0x02,         /*          Input (Variable),           */
536*4882a593Smuzhiyun 	0xB4,               /*          Pop,                        */
537*4882a593Smuzhiyun 	0xC0,               /*      End Collection,                 */
538*4882a593Smuzhiyun 	0xC0,               /*  End Collection,                     */
539*4882a593Smuzhiyun 	0x05, 0x01,         /*  Usage Page (Desktop),               */
540*4882a593Smuzhiyun 	0x09, 0x02,         /*  Usage (Mouse),                      */
541*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
542*4882a593Smuzhiyun 	0x85, 0x01,         /*      Report ID (1),                  */
543*4882a593Smuzhiyun 	0x09, 0x01,         /*      Usage (Pointer),                */
544*4882a593Smuzhiyun 	0xA0,               /*      Collection (Physical),          */
545*4882a593Smuzhiyun 	0x75, 0x08,         /*          Report Size (8),            */
546*4882a593Smuzhiyun 	0x95, 0x03,         /*          Report Count (3),           */
547*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
548*4882a593Smuzhiyun 	0x09, 0x38,         /*          Usage (Wheel),              */
549*4882a593Smuzhiyun 	0x15, 0xFF,         /*          Logical Minimum (-1),       */
550*4882a593Smuzhiyun 	0x25, 0x01,         /*          Logical Maximum (1),        */
551*4882a593Smuzhiyun 	0x75, 0x08,         /*          Report Size (8),            */
552*4882a593Smuzhiyun 	0x95, 0x01,         /*          Report Count (1),           */
553*4882a593Smuzhiyun 	0x81, 0x06,         /*          Input (Variable, Relative), */
554*4882a593Smuzhiyun 	0x75, 0x08,         /*          Report Size (8),            */
555*4882a593Smuzhiyun 	0x95, 0x03,         /*          Report Count (3),           */
556*4882a593Smuzhiyun 	0x81, 0x03,         /*          Input (Constant, Variable), */
557*4882a593Smuzhiyun 	0xC0,               /*      End Collection,                 */
558*4882a593Smuzhiyun 	0xC0,               /*  End Collection,                     */
559*4882a593Smuzhiyun 	0x05, 0x01,         /*  Usage Page (Desktop),               */
560*4882a593Smuzhiyun 	0x09, 0x06,         /*  Usage (Keyboard),                   */
561*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
562*4882a593Smuzhiyun 	0x85, 0x0D,         /*      Report ID (13),                 */
563*4882a593Smuzhiyun 	0x05, 0x07,         /*      Usage Page (Keyboard),          */
564*4882a593Smuzhiyun 	0x19, 0xE0,         /*      Usage Minimum (KB Leftcontrol), */
565*4882a593Smuzhiyun 	0x29, 0xE7,         /*      Usage Maximum (KB Right GUI),   */
566*4882a593Smuzhiyun 	0x14,               /*      Logical Minimum (0),            */
567*4882a593Smuzhiyun 	0x25, 0x01,         /*      Logical Maximum (1),            */
568*4882a593Smuzhiyun 	0x75, 0x01,         /*      Report Size (1),                */
569*4882a593Smuzhiyun 	0x95, 0x08,         /*      Report Count (8),               */
570*4882a593Smuzhiyun 	0x81, 0x02,         /*      Input (Variable),               */
571*4882a593Smuzhiyun 	0x75, 0x08,         /*      Report Size (8),                */
572*4882a593Smuzhiyun 	0x95, 0x01,         /*      Report Count (1),               */
573*4882a593Smuzhiyun 	0x81, 0x01,         /*      Input (Constant),               */
574*4882a593Smuzhiyun 	0x18,               /*      Usage Minimum (None),           */
575*4882a593Smuzhiyun 	0x29, 0x65,         /*      Usage Maximum (KB Application), */
576*4882a593Smuzhiyun 	0x14,               /*      Logical Minimum (0),            */
577*4882a593Smuzhiyun 	0x25, 0x65,         /*      Logical Maximum (101),          */
578*4882a593Smuzhiyun 	0x75, 0x08,         /*      Report Size (8),                */
579*4882a593Smuzhiyun 	0x95, 0x05,         /*      Report Count (5),               */
580*4882a593Smuzhiyun 	0x80,               /*      Input,                          */
581*4882a593Smuzhiyun 	0xC0,               /*  End Collection,                     */
582*4882a593Smuzhiyun 	0x05, 0x0C,         /*  Usage Page (Consumer),              */
583*4882a593Smuzhiyun 	0x09, 0x01,         /*  Usage (Consumer Control),           */
584*4882a593Smuzhiyun 	0xA1, 0x01,         /*  Collection (Application),           */
585*4882a593Smuzhiyun 	0x85, 0x0C,         /*      Report ID (12),                 */
586*4882a593Smuzhiyun 	0x09, 0xE9,         /*      Usage (Volume Inc),             */
587*4882a593Smuzhiyun 	0x09, 0xEA,         /*      Usage (Volume Dec),             */
588*4882a593Smuzhiyun 	0x14,               /*      Logical Minimum (0),            */
589*4882a593Smuzhiyun 	0x25, 0x01,         /*      Logical Maximum (1),            */
590*4882a593Smuzhiyun 	0x75, 0x01,         /*      Report Size (1),                */
591*4882a593Smuzhiyun 	0x95, 0x02,         /*      Report Count (2),               */
592*4882a593Smuzhiyun 	0x81, 0x02,         /*      Input (Variable),               */
593*4882a593Smuzhiyun 	0x75, 0x06,         /*      Report Size (6),                */
594*4882a593Smuzhiyun 	0x95, 0x01,         /*      Report Count (1),               */
595*4882a593Smuzhiyun 	0x81, 0x03,         /*      Input (Constant, Variable),     */
596*4882a593Smuzhiyun 	0x75, 0x10,         /*      Report Size (16),               */
597*4882a593Smuzhiyun 	0x95, 0x03,         /*      Report Count (3),               */
598*4882a593Smuzhiyun 	0x81, 0x03,         /*      Input (Constant, Variable),     */
599*4882a593Smuzhiyun 	0xC0                /*  End Collection                      */
600*4882a593Smuzhiyun };
601*4882a593Smuzhiyun 
waltop_report_fixup(struct hid_device * hdev,__u8 * rdesc,unsigned int * rsize)602*4882a593Smuzhiyun static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
603*4882a593Smuzhiyun 		unsigned int *rsize)
604*4882a593Smuzhiyun {
605*4882a593Smuzhiyun 	switch (hdev->product) {
606*4882a593Smuzhiyun 	case USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH:
607*4882a593Smuzhiyun 		if (*rsize == SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE) {
608*4882a593Smuzhiyun 			rdesc = slim_tablet_5_8_inch_rdesc_fixed;
609*4882a593Smuzhiyun 			*rsize = sizeof(slim_tablet_5_8_inch_rdesc_fixed);
610*4882a593Smuzhiyun 		}
611*4882a593Smuzhiyun 		break;
612*4882a593Smuzhiyun 	case USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH:
613*4882a593Smuzhiyun 		if (*rsize == SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE) {
614*4882a593Smuzhiyun 			rdesc = slim_tablet_12_1_inch_rdesc_fixed;
615*4882a593Smuzhiyun 			*rsize = sizeof(slim_tablet_12_1_inch_rdesc_fixed);
616*4882a593Smuzhiyun 		}
617*4882a593Smuzhiyun 		break;
618*4882a593Smuzhiyun 	case USB_DEVICE_ID_WALTOP_Q_PAD:
619*4882a593Smuzhiyun 		if (*rsize == Q_PAD_RDESC_ORIG_SIZE) {
620*4882a593Smuzhiyun 			rdesc = q_pad_rdesc_fixed;
621*4882a593Smuzhiyun 			*rsize = sizeof(q_pad_rdesc_fixed);
622*4882a593Smuzhiyun 		}
623*4882a593Smuzhiyun 		break;
624*4882a593Smuzhiyun 	case USB_DEVICE_ID_WALTOP_PID_0038:
625*4882a593Smuzhiyun 		if (*rsize == PID_0038_RDESC_ORIG_SIZE) {
626*4882a593Smuzhiyun 			rdesc = pid_0038_rdesc_fixed;
627*4882a593Smuzhiyun 			*rsize = sizeof(pid_0038_rdesc_fixed);
628*4882a593Smuzhiyun 		}
629*4882a593Smuzhiyun 		break;
630*4882a593Smuzhiyun 	case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH:
631*4882a593Smuzhiyun 		if (*rsize == MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE) {
632*4882a593Smuzhiyun 			rdesc = media_tablet_10_6_inch_rdesc_fixed;
633*4882a593Smuzhiyun 			*rsize = sizeof(media_tablet_10_6_inch_rdesc_fixed);
634*4882a593Smuzhiyun 		}
635*4882a593Smuzhiyun 		break;
636*4882a593Smuzhiyun 	case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH:
637*4882a593Smuzhiyun 		if (*rsize == MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE) {
638*4882a593Smuzhiyun 			rdesc = media_tablet_14_1_inch_rdesc_fixed;
639*4882a593Smuzhiyun 			*rsize = sizeof(media_tablet_14_1_inch_rdesc_fixed);
640*4882a593Smuzhiyun 		}
641*4882a593Smuzhiyun 		break;
642*4882a593Smuzhiyun 	case USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET:
643*4882a593Smuzhiyun 		if (*rsize == SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE) {
644*4882a593Smuzhiyun 			rdesc = sirius_battery_free_tablet_rdesc_fixed;
645*4882a593Smuzhiyun 			*rsize = sizeof(sirius_battery_free_tablet_rdesc_fixed);
646*4882a593Smuzhiyun 		}
647*4882a593Smuzhiyun 		break;
648*4882a593Smuzhiyun 	}
649*4882a593Smuzhiyun 	return rdesc;
650*4882a593Smuzhiyun }
651*4882a593Smuzhiyun 
waltop_raw_event(struct hid_device * hdev,struct hid_report * report,u8 * data,int size)652*4882a593Smuzhiyun static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report,
653*4882a593Smuzhiyun 		     u8 *data, int size)
654*4882a593Smuzhiyun {
655*4882a593Smuzhiyun 	/* If this is a pen input report */
656*4882a593Smuzhiyun 	if (report->type == HID_INPUT_REPORT && report->id == 16 && size >= 8) {
657*4882a593Smuzhiyun 		/*
658*4882a593Smuzhiyun 		 * Ignore reported pressure when a barrel button is pressed,
659*4882a593Smuzhiyun 		 * because it is rarely correct.
660*4882a593Smuzhiyun 		 */
661*4882a593Smuzhiyun 
662*4882a593Smuzhiyun 		/* If a barrel button is pressed */
663*4882a593Smuzhiyun 		if ((data[1] & 0xF) > 1) {
664*4882a593Smuzhiyun 			/* Report zero pressure */
665*4882a593Smuzhiyun 			data[6] = 0;
666*4882a593Smuzhiyun 			data[7] = 0;
667*4882a593Smuzhiyun 		}
668*4882a593Smuzhiyun 	}
669*4882a593Smuzhiyun 
670*4882a593Smuzhiyun 	/* If this is a pen input report of Sirius Battery Free Tablet */
671*4882a593Smuzhiyun 	if (hdev->product == USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET &&
672*4882a593Smuzhiyun 	    report->type == HID_INPUT_REPORT &&
673*4882a593Smuzhiyun 	    report->id == 16 &&
674*4882a593Smuzhiyun 	    size == 10) {
675*4882a593Smuzhiyun 		/*
676*4882a593Smuzhiyun 		 * The tablet reports tilt as roughly sin(a)*21 (18 means 60
677*4882a593Smuzhiyun 		 * degrees).
678*4882a593Smuzhiyun 		 *
679*4882a593Smuzhiyun 		 * This array stores angles as radians * 100, corresponding to
680*4882a593Smuzhiyun 		 * reported values up to 60 degrees, as expected by userspace.
681*4882a593Smuzhiyun 		 */
682*4882a593Smuzhiyun 		static const s8 tilt_to_radians[] = {
683*4882a593Smuzhiyun 			0, 5, 10, 14, 19, 24, 29, 34, 40, 45,
684*4882a593Smuzhiyun 			50, 56, 62, 68, 74, 81, 88, 96, 105
685*4882a593Smuzhiyun 		};
686*4882a593Smuzhiyun 
687*4882a593Smuzhiyun 		s8 tilt_x = (s8)data[8];
688*4882a593Smuzhiyun 		s8 tilt_y = (s8)data[9];
689*4882a593Smuzhiyun 		s8 sign_x = tilt_x >= 0 ? 1 : -1;
690*4882a593Smuzhiyun 		s8 sign_y = tilt_y >= 0 ? 1 : -1;
691*4882a593Smuzhiyun 
692*4882a593Smuzhiyun 		tilt_x *= sign_x;
693*4882a593Smuzhiyun 		tilt_y *= sign_y;
694*4882a593Smuzhiyun 
695*4882a593Smuzhiyun 		/*
696*4882a593Smuzhiyun 		 * Reverse the Y Tilt direction to match the HID standard and
697*4882a593Smuzhiyun 		 * userspace expectations. See HID Usage Tables v1.12 16.3.2
698*4882a593Smuzhiyun 		 * Tilt Orientation.
699*4882a593Smuzhiyun 		 */
700*4882a593Smuzhiyun 		sign_y *= -1;
701*4882a593Smuzhiyun 
702*4882a593Smuzhiyun 		/*
703*4882a593Smuzhiyun 		 * This effectively clamps reported tilt to 60 degrees - the
704*4882a593Smuzhiyun 		 * range expected by userspace
705*4882a593Smuzhiyun 		 */
706*4882a593Smuzhiyun 		if (tilt_x > ARRAY_SIZE(tilt_to_radians) - 1)
707*4882a593Smuzhiyun 			tilt_x = ARRAY_SIZE(tilt_to_radians) - 1;
708*4882a593Smuzhiyun 		if (tilt_y > ARRAY_SIZE(tilt_to_radians) - 1)
709*4882a593Smuzhiyun 			tilt_y = ARRAY_SIZE(tilt_to_radians) - 1;
710*4882a593Smuzhiyun 
711*4882a593Smuzhiyun 		data[8] = tilt_to_radians[tilt_x] * sign_x;
712*4882a593Smuzhiyun 		data[9] = tilt_to_radians[tilt_y] * sign_y;
713*4882a593Smuzhiyun 	}
714*4882a593Smuzhiyun 
715*4882a593Smuzhiyun 	return 0;
716*4882a593Smuzhiyun }
717*4882a593Smuzhiyun 
718*4882a593Smuzhiyun static const struct hid_device_id waltop_devices[] = {
719*4882a593Smuzhiyun 	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
720*4882a593Smuzhiyun 				USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
721*4882a593Smuzhiyun 	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
722*4882a593Smuzhiyun 				USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
723*4882a593Smuzhiyun 	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
724*4882a593Smuzhiyun 				USB_DEVICE_ID_WALTOP_Q_PAD) },
725*4882a593Smuzhiyun 	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
726*4882a593Smuzhiyun 				USB_DEVICE_ID_WALTOP_PID_0038) },
727*4882a593Smuzhiyun 	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
728*4882a593Smuzhiyun 				USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
729*4882a593Smuzhiyun 	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
730*4882a593Smuzhiyun 				USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
731*4882a593Smuzhiyun 	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
732*4882a593Smuzhiyun 			 USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) },
733*4882a593Smuzhiyun 	{ }
734*4882a593Smuzhiyun };
735*4882a593Smuzhiyun MODULE_DEVICE_TABLE(hid, waltop_devices);
736*4882a593Smuzhiyun 
737*4882a593Smuzhiyun static struct hid_driver waltop_driver = {
738*4882a593Smuzhiyun 	.name = "waltop",
739*4882a593Smuzhiyun 	.id_table = waltop_devices,
740*4882a593Smuzhiyun 	.report_fixup = waltop_report_fixup,
741*4882a593Smuzhiyun 	.raw_event = waltop_raw_event,
742*4882a593Smuzhiyun };
743*4882a593Smuzhiyun module_hid_driver(waltop_driver);
744*4882a593Smuzhiyun 
745*4882a593Smuzhiyun MODULE_LICENSE("GPL");
746