1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-or-later
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * HID driver for Kye/Genius devices not fully compliant with HID standard
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright (c) 2009 Jiri Kosina
6*4882a593Smuzhiyun * Copyright (c) 2009 Tomas Hanak
7*4882a593Smuzhiyun * Copyright (c) 2012 Nikolai Kondrashov
8*4882a593Smuzhiyun */
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun /*
11*4882a593Smuzhiyun */
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun #include <linux/device.h>
14*4882a593Smuzhiyun #include <linux/hid.h>
15*4882a593Smuzhiyun #include <linux/module.h>
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun #include "hid-ids.h"
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun /* Original EasyPen i405X report descriptor size */
20*4882a593Smuzhiyun #define EASYPEN_I405X_RDESC_ORIG_SIZE 476
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun /* Fixed EasyPen i405X report descriptor */
23*4882a593Smuzhiyun static __u8 easypen_i405x_rdesc_fixed[] = {
24*4882a593Smuzhiyun 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
25*4882a593Smuzhiyun 0x09, 0x01, /* Usage (01h), */
26*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
27*4882a593Smuzhiyun 0x85, 0x05, /* Report ID (5), */
28*4882a593Smuzhiyun 0x09, 0x01, /* Usage (01h), */
29*4882a593Smuzhiyun 0x15, 0x80, /* Logical Minimum (-128), */
30*4882a593Smuzhiyun 0x25, 0x7F, /* Logical Maximum (127), */
31*4882a593Smuzhiyun 0x75, 0x08, /* Report Size (8), */
32*4882a593Smuzhiyun 0x95, 0x07, /* Report Count (7), */
33*4882a593Smuzhiyun 0xB1, 0x02, /* Feature (Variable), */
34*4882a593Smuzhiyun 0xC0, /* End Collection, */
35*4882a593Smuzhiyun 0x05, 0x0D, /* Usage Page (Digitizer), */
36*4882a593Smuzhiyun 0x09, 0x02, /* Usage (Pen), */
37*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
38*4882a593Smuzhiyun 0x85, 0x10, /* Report ID (16), */
39*4882a593Smuzhiyun 0x09, 0x20, /* Usage (Stylus), */
40*4882a593Smuzhiyun 0xA0, /* Collection (Physical), */
41*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
42*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
43*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
44*4882a593Smuzhiyun 0x09, 0x42, /* Usage (Tip Switch), */
45*4882a593Smuzhiyun 0x09, 0x44, /* Usage (Barrel Switch), */
46*4882a593Smuzhiyun 0x09, 0x46, /* Usage (Tablet Pick), */
47*4882a593Smuzhiyun 0x95, 0x03, /* Report Count (3), */
48*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
49*4882a593Smuzhiyun 0x95, 0x04, /* Report Count (4), */
50*4882a593Smuzhiyun 0x81, 0x03, /* Input (Constant, Variable), */
51*4882a593Smuzhiyun 0x09, 0x32, /* Usage (In Range), */
52*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
53*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
54*4882a593Smuzhiyun 0x75, 0x10, /* Report Size (16), */
55*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
56*4882a593Smuzhiyun 0xA4, /* Push, */
57*4882a593Smuzhiyun 0x05, 0x01, /* Usage Page (Desktop), */
58*4882a593Smuzhiyun 0x55, 0xFD, /* Unit Exponent (-3), */
59*4882a593Smuzhiyun 0x65, 0x13, /* Unit (Inch), */
60*4882a593Smuzhiyun 0x34, /* Physical Minimum (0), */
61*4882a593Smuzhiyun 0x09, 0x30, /* Usage (X), */
62*4882a593Smuzhiyun 0x46, 0x7C, 0x15, /* Physical Maximum (5500), */
63*4882a593Smuzhiyun 0x26, 0x00, 0x37, /* Logical Maximum (14080), */
64*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
65*4882a593Smuzhiyun 0x09, 0x31, /* Usage (Y), */
66*4882a593Smuzhiyun 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */
67*4882a593Smuzhiyun 0x26, 0x00, 0x28, /* Logical Maximum (10240), */
68*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
69*4882a593Smuzhiyun 0xB4, /* Pop, */
70*4882a593Smuzhiyun 0x09, 0x30, /* Usage (Tip Pressure), */
71*4882a593Smuzhiyun 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
72*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
73*4882a593Smuzhiyun 0xC0, /* End Collection, */
74*4882a593Smuzhiyun 0xC0 /* End Collection */
75*4882a593Smuzhiyun };
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun /* Original MousePen i608X report descriptor size */
78*4882a593Smuzhiyun #define MOUSEPEN_I608X_RDESC_ORIG_SIZE 476
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun /* Fixed MousePen i608X report descriptor */
81*4882a593Smuzhiyun static __u8 mousepen_i608x_rdesc_fixed[] = {
82*4882a593Smuzhiyun 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
83*4882a593Smuzhiyun 0x09, 0x01, /* Usage (01h), */
84*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
85*4882a593Smuzhiyun 0x85, 0x05, /* Report ID (5), */
86*4882a593Smuzhiyun 0x09, 0x01, /* Usage (01h), */
87*4882a593Smuzhiyun 0x15, 0x80, /* Logical Minimum (-128), */
88*4882a593Smuzhiyun 0x25, 0x7F, /* Logical Maximum (127), */
89*4882a593Smuzhiyun 0x75, 0x08, /* Report Size (8), */
90*4882a593Smuzhiyun 0x95, 0x07, /* Report Count (7), */
91*4882a593Smuzhiyun 0xB1, 0x02, /* Feature (Variable), */
92*4882a593Smuzhiyun 0xC0, /* End Collection, */
93*4882a593Smuzhiyun 0x05, 0x0D, /* Usage Page (Digitizer), */
94*4882a593Smuzhiyun 0x09, 0x02, /* Usage (Pen), */
95*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
96*4882a593Smuzhiyun 0x85, 0x10, /* Report ID (16), */
97*4882a593Smuzhiyun 0x09, 0x20, /* Usage (Stylus), */
98*4882a593Smuzhiyun 0xA0, /* Collection (Physical), */
99*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
100*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
101*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
102*4882a593Smuzhiyun 0x09, 0x42, /* Usage (Tip Switch), */
103*4882a593Smuzhiyun 0x09, 0x44, /* Usage (Barrel Switch), */
104*4882a593Smuzhiyun 0x09, 0x46, /* Usage (Tablet Pick), */
105*4882a593Smuzhiyun 0x95, 0x03, /* Report Count (3), */
106*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
107*4882a593Smuzhiyun 0x95, 0x04, /* Report Count (4), */
108*4882a593Smuzhiyun 0x81, 0x03, /* Input (Constant, Variable), */
109*4882a593Smuzhiyun 0x09, 0x32, /* Usage (In Range), */
110*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
111*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
112*4882a593Smuzhiyun 0x75, 0x10, /* Report Size (16), */
113*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
114*4882a593Smuzhiyun 0xA4, /* Push, */
115*4882a593Smuzhiyun 0x05, 0x01, /* Usage Page (Desktop), */
116*4882a593Smuzhiyun 0x55, 0xFD, /* Unit Exponent (-3), */
117*4882a593Smuzhiyun 0x65, 0x13, /* Unit (Inch), */
118*4882a593Smuzhiyun 0x34, /* Physical Minimum (0), */
119*4882a593Smuzhiyun 0x09, 0x30, /* Usage (X), */
120*4882a593Smuzhiyun 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
121*4882a593Smuzhiyun 0x26, 0x00, 0x50, /* Logical Maximum (20480), */
122*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
123*4882a593Smuzhiyun 0x09, 0x31, /* Usage (Y), */
124*4882a593Smuzhiyun 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
125*4882a593Smuzhiyun 0x26, 0x00, 0x3C, /* Logical Maximum (15360), */
126*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
127*4882a593Smuzhiyun 0xB4, /* Pop, */
128*4882a593Smuzhiyun 0x09, 0x30, /* Usage (Tip Pressure), */
129*4882a593Smuzhiyun 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
130*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
131*4882a593Smuzhiyun 0xC0, /* End Collection, */
132*4882a593Smuzhiyun 0xC0, /* End Collection, */
133*4882a593Smuzhiyun 0x05, 0x01, /* Usage Page (Desktop), */
134*4882a593Smuzhiyun 0x09, 0x02, /* Usage (Mouse), */
135*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
136*4882a593Smuzhiyun 0x85, 0x11, /* Report ID (17), */
137*4882a593Smuzhiyun 0x09, 0x01, /* Usage (Pointer), */
138*4882a593Smuzhiyun 0xA0, /* Collection (Physical), */
139*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
140*4882a593Smuzhiyun 0xA4, /* Push, */
141*4882a593Smuzhiyun 0x05, 0x09, /* Usage Page (Button), */
142*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
143*4882a593Smuzhiyun 0x19, 0x01, /* Usage Minimum (01h), */
144*4882a593Smuzhiyun 0x29, 0x03, /* Usage Maximum (03h), */
145*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
146*4882a593Smuzhiyun 0x95, 0x03, /* Report Count (3), */
147*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
148*4882a593Smuzhiyun 0x95, 0x05, /* Report Count (5), */
149*4882a593Smuzhiyun 0x81, 0x01, /* Input (Constant), */
150*4882a593Smuzhiyun 0xB4, /* Pop, */
151*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
152*4882a593Smuzhiyun 0xA4, /* Push, */
153*4882a593Smuzhiyun 0x55, 0xFD, /* Unit Exponent (-3), */
154*4882a593Smuzhiyun 0x65, 0x13, /* Unit (Inch), */
155*4882a593Smuzhiyun 0x34, /* Physical Minimum (0), */
156*4882a593Smuzhiyun 0x75, 0x10, /* Report Size (16), */
157*4882a593Smuzhiyun 0x09, 0x30, /* Usage (X), */
158*4882a593Smuzhiyun 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
159*4882a593Smuzhiyun 0x26, 0x00, 0x50, /* Logical Maximum (20480), */
160*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
161*4882a593Smuzhiyun 0x09, 0x31, /* Usage (Y), */
162*4882a593Smuzhiyun 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
163*4882a593Smuzhiyun 0x26, 0x00, 0x3C, /* Logical Maximum (15360), */
164*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
165*4882a593Smuzhiyun 0xB4, /* Pop, */
166*4882a593Smuzhiyun 0x75, 0x08, /* Report Size (8), */
167*4882a593Smuzhiyun 0x09, 0x38, /* Usage (Wheel), */
168*4882a593Smuzhiyun 0x15, 0xFF, /* Logical Minimum (-1), */
169*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
170*4882a593Smuzhiyun 0x81, 0x06, /* Input (Variable, Relative), */
171*4882a593Smuzhiyun 0x81, 0x01, /* Input (Constant), */
172*4882a593Smuzhiyun 0xC0, /* End Collection, */
173*4882a593Smuzhiyun 0xC0 /* End Collection */
174*4882a593Smuzhiyun };
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun /* Original MousePen i608X v2 report descriptor size */
177*4882a593Smuzhiyun #define MOUSEPEN_I608X_V2_RDESC_ORIG_SIZE 482
178*4882a593Smuzhiyun
179*4882a593Smuzhiyun /* Fixed MousePen i608X v2 report descriptor */
180*4882a593Smuzhiyun static __u8 mousepen_i608x_v2_rdesc_fixed[] = {
181*4882a593Smuzhiyun 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
182*4882a593Smuzhiyun 0x09, 0x01, /* Usage (01h), */
183*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
184*4882a593Smuzhiyun 0x85, 0x05, /* Report ID (5), */
185*4882a593Smuzhiyun 0x09, 0x01, /* Usage (01h), */
186*4882a593Smuzhiyun 0x15, 0x80, /* Logical Minimum (-128), */
187*4882a593Smuzhiyun 0x25, 0x7F, /* Logical Maximum (127), */
188*4882a593Smuzhiyun 0x75, 0x08, /* Report Size (8), */
189*4882a593Smuzhiyun 0x95, 0x07, /* Report Count (7), */
190*4882a593Smuzhiyun 0xB1, 0x02, /* Feature (Variable), */
191*4882a593Smuzhiyun 0xC0, /* End Collection, */
192*4882a593Smuzhiyun 0x05, 0x0D, /* Usage Page (Digitizer), */
193*4882a593Smuzhiyun 0x09, 0x02, /* Usage (Pen), */
194*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
195*4882a593Smuzhiyun 0x85, 0x10, /* Report ID (16), */
196*4882a593Smuzhiyun 0x09, 0x20, /* Usage (Stylus), */
197*4882a593Smuzhiyun 0xA0, /* Collection (Physical), */
198*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
199*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
200*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
201*4882a593Smuzhiyun 0x09, 0x42, /* Usage (Tip Switch), */
202*4882a593Smuzhiyun 0x09, 0x44, /* Usage (Barrel Switch), */
203*4882a593Smuzhiyun 0x09, 0x46, /* Usage (Tablet Pick), */
204*4882a593Smuzhiyun 0x95, 0x03, /* Report Count (3), */
205*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
206*4882a593Smuzhiyun 0x95, 0x04, /* Report Count (4), */
207*4882a593Smuzhiyun 0x81, 0x03, /* Input (Constant, Variable), */
208*4882a593Smuzhiyun 0x09, 0x32, /* Usage (In Range), */
209*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
210*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
211*4882a593Smuzhiyun 0x75, 0x10, /* Report Size (16), */
212*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
213*4882a593Smuzhiyun 0xA4, /* Push, */
214*4882a593Smuzhiyun 0x05, 0x01, /* Usage Page (Desktop), */
215*4882a593Smuzhiyun 0x55, 0xFD, /* Unit Exponent (-3), */
216*4882a593Smuzhiyun 0x65, 0x13, /* Unit (Inch), */
217*4882a593Smuzhiyun 0x34, /* Physical Minimum (0), */
218*4882a593Smuzhiyun 0x09, 0x30, /* Usage (X), */
219*4882a593Smuzhiyun 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
220*4882a593Smuzhiyun 0x27, 0x00, 0xA0, 0x00, 0x00, /* Logical Maximum (40960), */
221*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
222*4882a593Smuzhiyun 0x09, 0x31, /* Usage (Y), */
223*4882a593Smuzhiyun 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
224*4882a593Smuzhiyun 0x26, 0x00, 0x78, /* Logical Maximum (30720), */
225*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
226*4882a593Smuzhiyun 0xB4, /* Pop, */
227*4882a593Smuzhiyun 0x09, 0x30, /* Usage (Tip Pressure), */
228*4882a593Smuzhiyun 0x26, 0xFF, 0x07, /* Logical Maximum (2047), */
229*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
230*4882a593Smuzhiyun 0xC0, /* End Collection, */
231*4882a593Smuzhiyun 0xC0, /* End Collection, */
232*4882a593Smuzhiyun 0x05, 0x01, /* Usage Page (Desktop), */
233*4882a593Smuzhiyun 0x09, 0x02, /* Usage (Mouse), */
234*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
235*4882a593Smuzhiyun 0x85, 0x11, /* Report ID (17), */
236*4882a593Smuzhiyun 0x09, 0x01, /* Usage (Pointer), */
237*4882a593Smuzhiyun 0xA0, /* Collection (Physical), */
238*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
239*4882a593Smuzhiyun 0xA4, /* Push, */
240*4882a593Smuzhiyun 0x05, 0x09, /* Usage Page (Button), */
241*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
242*4882a593Smuzhiyun 0x19, 0x01, /* Usage Minimum (01h), */
243*4882a593Smuzhiyun 0x29, 0x03, /* Usage Maximum (03h), */
244*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
245*4882a593Smuzhiyun 0x95, 0x03, /* Report Count (3), */
246*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
247*4882a593Smuzhiyun 0x95, 0x05, /* Report Count (5), */
248*4882a593Smuzhiyun 0x81, 0x01, /* Input (Constant), */
249*4882a593Smuzhiyun 0xB4, /* Pop, */
250*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
251*4882a593Smuzhiyun 0xA4, /* Push, */
252*4882a593Smuzhiyun 0x55, 0xFD, /* Unit Exponent (-3), */
253*4882a593Smuzhiyun 0x65, 0x13, /* Unit (Inch), */
254*4882a593Smuzhiyun 0x34, /* Physical Minimum (0), */
255*4882a593Smuzhiyun 0x75, 0x10, /* Report Size (16), */
256*4882a593Smuzhiyun 0x09, 0x30, /* Usage (X), */
257*4882a593Smuzhiyun 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */
258*4882a593Smuzhiyun 0x27, 0x00, 0xA0, 0x00, 0x00, /* Logical Maximum (40960), */
259*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
260*4882a593Smuzhiyun 0x09, 0x31, /* Usage (Y), */
261*4882a593Smuzhiyun 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
262*4882a593Smuzhiyun 0x26, 0x00, 0x78, /* Logical Maximum (30720), */
263*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
264*4882a593Smuzhiyun 0xB4, /* Pop, */
265*4882a593Smuzhiyun 0x75, 0x08, /* Report Size (8), */
266*4882a593Smuzhiyun 0x09, 0x38, /* Usage (Wheel), */
267*4882a593Smuzhiyun 0x15, 0xFF, /* Logical Minimum (-1), */
268*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
269*4882a593Smuzhiyun 0x81, 0x06, /* Input (Variable, Relative), */
270*4882a593Smuzhiyun 0x81, 0x01, /* Input (Constant), */
271*4882a593Smuzhiyun 0xC0, /* End Collection, */
272*4882a593Smuzhiyun 0xC0 /* End Collection */
273*4882a593Smuzhiyun };
274*4882a593Smuzhiyun
275*4882a593Smuzhiyun /* Original EasyPen M610X report descriptor size */
276*4882a593Smuzhiyun #define EASYPEN_M610X_RDESC_ORIG_SIZE 476
277*4882a593Smuzhiyun
278*4882a593Smuzhiyun /* Fixed EasyPen M610X report descriptor */
279*4882a593Smuzhiyun static __u8 easypen_m610x_rdesc_fixed[] = {
280*4882a593Smuzhiyun 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
281*4882a593Smuzhiyun 0x09, 0x01, /* Usage (01h), */
282*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
283*4882a593Smuzhiyun 0x85, 0x05, /* Report ID (5), */
284*4882a593Smuzhiyun 0x09, 0x01, /* Usage (01h), */
285*4882a593Smuzhiyun 0x15, 0x80, /* Logical Minimum (-128), */
286*4882a593Smuzhiyun 0x25, 0x7F, /* Logical Maximum (127), */
287*4882a593Smuzhiyun 0x75, 0x08, /* Report Size (8), */
288*4882a593Smuzhiyun 0x95, 0x07, /* Report Count (7), */
289*4882a593Smuzhiyun 0xB1, 0x02, /* Feature (Variable), */
290*4882a593Smuzhiyun 0xC0, /* End Collection, */
291*4882a593Smuzhiyun 0x05, 0x0D, /* Usage Page (Digitizer), */
292*4882a593Smuzhiyun 0x09, 0x02, /* Usage (Pen), */
293*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
294*4882a593Smuzhiyun 0x85, 0x10, /* Report ID (16), */
295*4882a593Smuzhiyun 0x09, 0x20, /* Usage (Stylus), */
296*4882a593Smuzhiyun 0xA0, /* Collection (Physical), */
297*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
298*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
299*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
300*4882a593Smuzhiyun 0x09, 0x42, /* Usage (Tip Switch), */
301*4882a593Smuzhiyun 0x09, 0x44, /* Usage (Barrel Switch), */
302*4882a593Smuzhiyun 0x09, 0x46, /* Usage (Tablet Pick), */
303*4882a593Smuzhiyun 0x95, 0x03, /* Report Count (3), */
304*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
305*4882a593Smuzhiyun 0x95, 0x04, /* Report Count (4), */
306*4882a593Smuzhiyun 0x81, 0x03, /* Input (Constant, Variable), */
307*4882a593Smuzhiyun 0x09, 0x32, /* Usage (In Range), */
308*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
309*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
310*4882a593Smuzhiyun 0x75, 0x10, /* Report Size (16), */
311*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
312*4882a593Smuzhiyun 0xA4, /* Push, */
313*4882a593Smuzhiyun 0x05, 0x01, /* Usage Page (Desktop), */
314*4882a593Smuzhiyun 0x55, 0xFD, /* Unit Exponent (-3), */
315*4882a593Smuzhiyun 0x65, 0x13, /* Unit (Inch), */
316*4882a593Smuzhiyun 0x34, /* Physical Minimum (0), */
317*4882a593Smuzhiyun 0x09, 0x30, /* Usage (X), */
318*4882a593Smuzhiyun 0x46, 0x10, 0x27, /* Physical Maximum (10000), */
319*4882a593Smuzhiyun 0x27, 0x00, 0xA0, 0x00, 0x00, /* Logical Maximum (40960), */
320*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
321*4882a593Smuzhiyun 0x09, 0x31, /* Usage (Y), */
322*4882a593Smuzhiyun 0x46, 0x6A, 0x18, /* Physical Maximum (6250), */
323*4882a593Smuzhiyun 0x26, 0x00, 0x64, /* Logical Maximum (25600), */
324*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
325*4882a593Smuzhiyun 0xB4, /* Pop, */
326*4882a593Smuzhiyun 0x09, 0x30, /* Usage (Tip Pressure), */
327*4882a593Smuzhiyun 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
328*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
329*4882a593Smuzhiyun 0xC0, /* End Collection, */
330*4882a593Smuzhiyun 0xC0, /* End Collection, */
331*4882a593Smuzhiyun 0x05, 0x0C, /* Usage Page (Consumer), */
332*4882a593Smuzhiyun 0x09, 0x01, /* Usage (Consumer Control), */
333*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
334*4882a593Smuzhiyun 0x85, 0x12, /* Report ID (18), */
335*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
336*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
337*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
338*4882a593Smuzhiyun 0x95, 0x04, /* Report Count (4), */
339*4882a593Smuzhiyun 0x0A, 0x1A, 0x02, /* Usage (AC Undo), */
340*4882a593Smuzhiyun 0x0A, 0x79, 0x02, /* Usage (AC Redo Or Repeat), */
341*4882a593Smuzhiyun 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
342*4882a593Smuzhiyun 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
343*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
344*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
345*4882a593Smuzhiyun 0x75, 0x14, /* Report Size (20), */
346*4882a593Smuzhiyun 0x81, 0x03, /* Input (Constant, Variable), */
347*4882a593Smuzhiyun 0x75, 0x20, /* Report Size (32), */
348*4882a593Smuzhiyun 0x81, 0x03, /* Input (Constant, Variable), */
349*4882a593Smuzhiyun 0xC0 /* End Collection */
350*4882a593Smuzhiyun };
351*4882a593Smuzhiyun
352*4882a593Smuzhiyun
353*4882a593Smuzhiyun /* Original PenSketch M912 report descriptor size */
354*4882a593Smuzhiyun #define PENSKETCH_M912_RDESC_ORIG_SIZE 482
355*4882a593Smuzhiyun
356*4882a593Smuzhiyun /* Fixed PenSketch M912 report descriptor */
357*4882a593Smuzhiyun static __u8 pensketch_m912_rdesc_fixed[] = {
358*4882a593Smuzhiyun 0x05, 0x01, /* Usage Page (Desktop), */
359*4882a593Smuzhiyun 0x08, /* Usage (00h), */
360*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
361*4882a593Smuzhiyun 0x85, 0x05, /* Report ID (5), */
362*4882a593Smuzhiyun 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
363*4882a593Smuzhiyun 0x09, 0x01, /* Usage (01h), */
364*4882a593Smuzhiyun 0x15, 0x81, /* Logical Minimum (-127), */
365*4882a593Smuzhiyun 0x25, 0x7F, /* Logical Maximum (127), */
366*4882a593Smuzhiyun 0x75, 0x08, /* Report Size (8), */
367*4882a593Smuzhiyun 0x95, 0x07, /* Report Count (7), */
368*4882a593Smuzhiyun 0xB1, 0x02, /* Feature (Variable), */
369*4882a593Smuzhiyun 0xC0, /* End Collection, */
370*4882a593Smuzhiyun 0x05, 0x0D, /* Usage Page (Digitizer), */
371*4882a593Smuzhiyun 0x09, 0x02, /* Usage (Pen), */
372*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
373*4882a593Smuzhiyun 0x85, 0x10, /* Report ID (16), */
374*4882a593Smuzhiyun 0x09, 0x20, /* Usage (Stylus), */
375*4882a593Smuzhiyun 0xA0, /* Collection (Physical), */
376*4882a593Smuzhiyun 0x09, 0x42, /* Usage (Tip Switch), */
377*4882a593Smuzhiyun 0x09, 0x44, /* Usage (Barrel Switch), */
378*4882a593Smuzhiyun 0x09, 0x46, /* Usage (Tablet Pick), */
379*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
380*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
381*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
382*4882a593Smuzhiyun 0x95, 0x03, /* Report Count (3), */
383*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
384*4882a593Smuzhiyun 0x95, 0x04, /* Report Count (4), */
385*4882a593Smuzhiyun 0x81, 0x03, /* Input (Constant, Variable), */
386*4882a593Smuzhiyun 0x09, 0x32, /* Usage (In Range), */
387*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
388*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
389*4882a593Smuzhiyun 0x75, 0x10, /* Report Size (16), */
390*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
391*4882a593Smuzhiyun 0xA4, /* Push, */
392*4882a593Smuzhiyun 0x05, 0x01, /* Usage Page (Desktop), */
393*4882a593Smuzhiyun 0x55, 0xFD, /* Unit Exponent (-3), */
394*4882a593Smuzhiyun 0x65, 0x13, /* Unit (Inch), */
395*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
396*4882a593Smuzhiyun 0x34, /* Physical Minimum (0), */
397*4882a593Smuzhiyun 0x09, 0x30, /* Usage (X), */
398*4882a593Smuzhiyun 0x27, 0x00, 0xF0, 0x00, 0x00, /* Logical Maximum (61440), */
399*4882a593Smuzhiyun 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */
400*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
401*4882a593Smuzhiyun 0x09, 0x31, /* Usage (Y), */
402*4882a593Smuzhiyun 0x27, 0x00, 0xB4, 0x00, 0x00, /* Logical Maximum (46080), */
403*4882a593Smuzhiyun 0x46, 0x28, 0x23, /* Physical Maximum (9000), */
404*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
405*4882a593Smuzhiyun 0xB4, /* Pop, */
406*4882a593Smuzhiyun 0x09, 0x30, /* Usage (Tip Pressure), */
407*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
408*4882a593Smuzhiyun 0x26, 0xFF, 0x07, /* Logical Maximum (2047), */
409*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
410*4882a593Smuzhiyun 0xC0, /* End Collection, */
411*4882a593Smuzhiyun 0xC0, /* End Collection, */
412*4882a593Smuzhiyun 0x05, 0x0D, /* Usage Page (Digitizer), */
413*4882a593Smuzhiyun 0x09, 0x21, /* Usage (Puck), */
414*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
415*4882a593Smuzhiyun 0x85, 0x11, /* Report ID (17), */
416*4882a593Smuzhiyun 0x09, 0x21, /* Usage (Puck), */
417*4882a593Smuzhiyun 0xA0, /* Collection (Physical), */
418*4882a593Smuzhiyun 0x05, 0x09, /* Usage Page (Button), */
419*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
420*4882a593Smuzhiyun 0x19, 0x01, /* Usage Minimum (01h), */
421*4882a593Smuzhiyun 0x29, 0x03, /* Usage Maximum (03h), */
422*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
423*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
424*4882a593Smuzhiyun 0x95, 0x03, /* Report Count (3), */
425*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
426*4882a593Smuzhiyun 0x95, 0x04, /* Report Count (4), */
427*4882a593Smuzhiyun 0x81, 0x01, /* Input (Constant), */
428*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
429*4882a593Smuzhiyun 0x0B, 0x32, 0x00, 0x0D, 0x00, /* Usage (Digitizer In Range), */
430*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
431*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
432*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
433*4882a593Smuzhiyun 0xA4, /* Push, */
434*4882a593Smuzhiyun 0x05, 0x01, /* Usage Page (Desktop), */
435*4882a593Smuzhiyun 0x75, 0x10, /* Report Size (16), */
436*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
437*4882a593Smuzhiyun 0x55, 0xFD, /* Unit Exponent (-3), */
438*4882a593Smuzhiyun 0x65, 0x13, /* Unit (Inch), */
439*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
440*4882a593Smuzhiyun 0x34, /* Physical Minimum (0), */
441*4882a593Smuzhiyun 0x09, 0x30, /* Usage (X), */
442*4882a593Smuzhiyun 0x27, 0x00, 0xF0, 0x00, 0x00, /* Logical Maximum (61440), */
443*4882a593Smuzhiyun 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */
444*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
445*4882a593Smuzhiyun 0x09, 0x31, /* Usage (Y), */
446*4882a593Smuzhiyun 0x27, 0x00, 0xB4, 0x00, 0x00, /* Logical Maximum (46080), */
447*4882a593Smuzhiyun 0x46, 0x28, 0x23, /* Physical Maximum (9000), */
448*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
449*4882a593Smuzhiyun 0x09, 0x38, /* Usage (Wheel), */
450*4882a593Smuzhiyun 0x75, 0x08, /* Report Size (8), */
451*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
452*4882a593Smuzhiyun 0x15, 0xFF, /* Logical Minimum (-1), */
453*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
454*4882a593Smuzhiyun 0x34, /* Physical Minimum (0), */
455*4882a593Smuzhiyun 0x44, /* Physical Maximum (0), */
456*4882a593Smuzhiyun 0x81, 0x06, /* Input (Variable, Relative), */
457*4882a593Smuzhiyun 0xB4, /* Pop, */
458*4882a593Smuzhiyun 0xC0, /* End Collection, */
459*4882a593Smuzhiyun 0xC0, /* End Collection, */
460*4882a593Smuzhiyun 0x05, 0x0C, /* Usage Page (Consumer), */
461*4882a593Smuzhiyun 0x09, 0x01, /* Usage (Consumer Control), */
462*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
463*4882a593Smuzhiyun 0x85, 0x12, /* Report ID (18), */
464*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
465*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
466*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
467*4882a593Smuzhiyun 0x95, 0x08, /* Report Count (8), */
468*4882a593Smuzhiyun 0x05, 0x0C, /* Usage Page (Consumer), */
469*4882a593Smuzhiyun 0x0A, 0x6A, 0x02, /* Usage (AC Delete), */
470*4882a593Smuzhiyun 0x0A, 0x1A, 0x02, /* Usage (AC Undo), */
471*4882a593Smuzhiyun 0x0A, 0x01, 0x02, /* Usage (AC New), */
472*4882a593Smuzhiyun 0x0A, 0x2F, 0x02, /* Usage (AC Zoom), */
473*4882a593Smuzhiyun 0x0A, 0x25, 0x02, /* Usage (AC Forward), */
474*4882a593Smuzhiyun 0x0A, 0x24, 0x02, /* Usage (AC Back), */
475*4882a593Smuzhiyun 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
476*4882a593Smuzhiyun 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
477*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
478*4882a593Smuzhiyun 0x95, 0x30, /* Report Count (48), */
479*4882a593Smuzhiyun 0x81, 0x03, /* Input (Constant, Variable), */
480*4882a593Smuzhiyun 0xC0 /* End Collection */
481*4882a593Smuzhiyun };
482*4882a593Smuzhiyun
483*4882a593Smuzhiyun /* Original EasyPen M406XE report descriptor size */
484*4882a593Smuzhiyun #define EASYPEN_M406XE_RDESC_ORIG_SIZE 476
485*4882a593Smuzhiyun
486*4882a593Smuzhiyun /* Fixed EasyPen M406XE report descriptor */
487*4882a593Smuzhiyun static __u8 easypen_m406xe_rdesc_fixed[] = {
488*4882a593Smuzhiyun 0x05, 0x01, /* Usage Page (Desktop), */
489*4882a593Smuzhiyun 0x09, 0x01, /* Usage (01h), */
490*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
491*4882a593Smuzhiyun 0x85, 0x05, /* Report ID (5), */
492*4882a593Smuzhiyun 0x09, 0x01, /* Usage (01h), */
493*4882a593Smuzhiyun 0x15, 0x80, /* Logical Minimum (-128), */
494*4882a593Smuzhiyun 0x25, 0x7F, /* Logical Maximum (127), */
495*4882a593Smuzhiyun 0x75, 0x08, /* Report Size (8), */
496*4882a593Smuzhiyun 0x95, 0x07, /* Report Count (7), */
497*4882a593Smuzhiyun 0xB1, 0x02, /* Feature (Variable), */
498*4882a593Smuzhiyun 0xC0, /* End Collection, */
499*4882a593Smuzhiyun 0x05, 0x0D, /* Usage Page (Digitizer), */
500*4882a593Smuzhiyun 0x09, 0x02, /* Usage (Pen), */
501*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
502*4882a593Smuzhiyun 0x85, 0x10, /* Report ID (16), */
503*4882a593Smuzhiyun 0x09, 0x20, /* Usage (Stylus), */
504*4882a593Smuzhiyun 0xA0, /* Collection (Physical), */
505*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
506*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
507*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
508*4882a593Smuzhiyun 0x09, 0x42, /* Usage (Tip Switch), */
509*4882a593Smuzhiyun 0x09, 0x44, /* Usage (Barrel Switch), */
510*4882a593Smuzhiyun 0x09, 0x46, /* Usage (Tablet Pick), */
511*4882a593Smuzhiyun 0x95, 0x03, /* Report Count (3), */
512*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
513*4882a593Smuzhiyun 0x95, 0x04, /* Report Count (4), */
514*4882a593Smuzhiyun 0x81, 0x03, /* Input (Constant, Variable), */
515*4882a593Smuzhiyun 0x09, 0x32, /* Usage (In Range), */
516*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
517*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
518*4882a593Smuzhiyun 0x75, 0x10, /* Report Size (16), */
519*4882a593Smuzhiyun 0x95, 0x01, /* Report Count (1), */
520*4882a593Smuzhiyun 0xA4, /* Push, */
521*4882a593Smuzhiyun 0x05, 0x01, /* Usage Page (Desktop), */
522*4882a593Smuzhiyun 0x55, 0xFD, /* Unit Exponent (-3), */
523*4882a593Smuzhiyun 0x65, 0x13, /* Unit (Inch), */
524*4882a593Smuzhiyun 0x34, /* Physical Minimum (0), */
525*4882a593Smuzhiyun 0x09, 0x30, /* Usage (X), */
526*4882a593Smuzhiyun 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
527*4882a593Smuzhiyun 0x26, 0x00, 0x3C, /* Logical Maximum (15360), */
528*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
529*4882a593Smuzhiyun 0x09, 0x31, /* Usage (Y), */
530*4882a593Smuzhiyun 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */
531*4882a593Smuzhiyun 0x26, 0x00, 0x28, /* Logical Maximum (10240), */
532*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
533*4882a593Smuzhiyun 0xB4, /* Pop, */
534*4882a593Smuzhiyun 0x09, 0x30, /* Usage (Tip Pressure), */
535*4882a593Smuzhiyun 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
536*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
537*4882a593Smuzhiyun 0xC0, /* End Collection, */
538*4882a593Smuzhiyun 0xC0, /* End Collection */
539*4882a593Smuzhiyun 0x05, 0x0C, /* Usage Page (Consumer), */
540*4882a593Smuzhiyun 0x09, 0x01, /* Usage (Consumer Control), */
541*4882a593Smuzhiyun 0xA1, 0x01, /* Collection (Application), */
542*4882a593Smuzhiyun 0x85, 0x12, /* Report ID (18), */
543*4882a593Smuzhiyun 0x14, /* Logical Minimum (0), */
544*4882a593Smuzhiyun 0x25, 0x01, /* Logical Maximum (1), */
545*4882a593Smuzhiyun 0x75, 0x01, /* Report Size (1), */
546*4882a593Smuzhiyun 0x95, 0x04, /* Report Count (4), */
547*4882a593Smuzhiyun 0x0A, 0x79, 0x02, /* Usage (AC Redo Or Repeat), */
548*4882a593Smuzhiyun 0x0A, 0x1A, 0x02, /* Usage (AC Undo), */
549*4882a593Smuzhiyun 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
550*4882a593Smuzhiyun 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
551*4882a593Smuzhiyun 0x81, 0x02, /* Input (Variable), */
552*4882a593Smuzhiyun 0x95, 0x34, /* Report Count (52), */
553*4882a593Smuzhiyun 0x81, 0x03, /* Input (Constant, Variable), */
554*4882a593Smuzhiyun 0xC0 /* End Collection */
555*4882a593Smuzhiyun };
556*4882a593Smuzhiyun
kye_consumer_control_fixup(struct hid_device * hdev,__u8 * rdesc,unsigned int * rsize,int offset,const char * device_name)557*4882a593Smuzhiyun static __u8 *kye_consumer_control_fixup(struct hid_device *hdev, __u8 *rdesc,
558*4882a593Smuzhiyun unsigned int *rsize, int offset, const char *device_name) {
559*4882a593Smuzhiyun /*
560*4882a593Smuzhiyun * the fixup that need to be done:
561*4882a593Smuzhiyun * - change Usage Maximum in the Consumer Control
562*4882a593Smuzhiyun * (report ID 3) to a reasonable value
563*4882a593Smuzhiyun */
564*4882a593Smuzhiyun if (*rsize >= offset + 31 &&
565*4882a593Smuzhiyun /* Usage Page (Consumer Devices) */
566*4882a593Smuzhiyun rdesc[offset] == 0x05 && rdesc[offset + 1] == 0x0c &&
567*4882a593Smuzhiyun /* Usage (Consumer Control) */
568*4882a593Smuzhiyun rdesc[offset + 2] == 0x09 && rdesc[offset + 3] == 0x01 &&
569*4882a593Smuzhiyun /* Usage Maximum > 12287 */
570*4882a593Smuzhiyun rdesc[offset + 10] == 0x2a && rdesc[offset + 12] > 0x2f) {
571*4882a593Smuzhiyun hid_info(hdev, "fixing up %s report descriptor\n", device_name);
572*4882a593Smuzhiyun rdesc[offset + 12] = 0x2f;
573*4882a593Smuzhiyun }
574*4882a593Smuzhiyun return rdesc;
575*4882a593Smuzhiyun }
576*4882a593Smuzhiyun
kye_report_fixup(struct hid_device * hdev,__u8 * rdesc,unsigned int * rsize)577*4882a593Smuzhiyun static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
578*4882a593Smuzhiyun unsigned int *rsize)
579*4882a593Smuzhiyun {
580*4882a593Smuzhiyun switch (hdev->product) {
581*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_ERGO_525V:
582*4882a593Smuzhiyun /* the fixups that need to be done:
583*4882a593Smuzhiyun * - change led usage page to button for extra buttons
584*4882a593Smuzhiyun * - report size 8 count 1 must be size 1 count 8 for button
585*4882a593Smuzhiyun * bitfield
586*4882a593Smuzhiyun * - change the button usage range to 4-7 for the extra
587*4882a593Smuzhiyun * buttons
588*4882a593Smuzhiyun */
589*4882a593Smuzhiyun if (*rsize >= 75 &&
590*4882a593Smuzhiyun rdesc[61] == 0x05 && rdesc[62] == 0x08 &&
591*4882a593Smuzhiyun rdesc[63] == 0x19 && rdesc[64] == 0x08 &&
592*4882a593Smuzhiyun rdesc[65] == 0x29 && rdesc[66] == 0x0f &&
593*4882a593Smuzhiyun rdesc[71] == 0x75 && rdesc[72] == 0x08 &&
594*4882a593Smuzhiyun rdesc[73] == 0x95 && rdesc[74] == 0x01) {
595*4882a593Smuzhiyun hid_info(hdev,
596*4882a593Smuzhiyun "fixing up Kye/Genius Ergo Mouse "
597*4882a593Smuzhiyun "report descriptor\n");
598*4882a593Smuzhiyun rdesc[62] = 0x09;
599*4882a593Smuzhiyun rdesc[64] = 0x04;
600*4882a593Smuzhiyun rdesc[66] = 0x07;
601*4882a593Smuzhiyun rdesc[72] = 0x01;
602*4882a593Smuzhiyun rdesc[74] = 0x08;
603*4882a593Smuzhiyun }
604*4882a593Smuzhiyun break;
605*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_EASYPEN_I405X:
606*4882a593Smuzhiyun if (*rsize == EASYPEN_I405X_RDESC_ORIG_SIZE) {
607*4882a593Smuzhiyun rdesc = easypen_i405x_rdesc_fixed;
608*4882a593Smuzhiyun *rsize = sizeof(easypen_i405x_rdesc_fixed);
609*4882a593Smuzhiyun }
610*4882a593Smuzhiyun break;
611*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
612*4882a593Smuzhiyun if (*rsize == MOUSEPEN_I608X_RDESC_ORIG_SIZE) {
613*4882a593Smuzhiyun rdesc = mousepen_i608x_rdesc_fixed;
614*4882a593Smuzhiyun *rsize = sizeof(mousepen_i608x_rdesc_fixed);
615*4882a593Smuzhiyun }
616*4882a593Smuzhiyun break;
617*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2:
618*4882a593Smuzhiyun if (*rsize == MOUSEPEN_I608X_V2_RDESC_ORIG_SIZE) {
619*4882a593Smuzhiyun rdesc = mousepen_i608x_v2_rdesc_fixed;
620*4882a593Smuzhiyun *rsize = sizeof(mousepen_i608x_v2_rdesc_fixed);
621*4882a593Smuzhiyun }
622*4882a593Smuzhiyun break;
623*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_EASYPEN_M610X:
624*4882a593Smuzhiyun if (*rsize == EASYPEN_M610X_RDESC_ORIG_SIZE) {
625*4882a593Smuzhiyun rdesc = easypen_m610x_rdesc_fixed;
626*4882a593Smuzhiyun *rsize = sizeof(easypen_m610x_rdesc_fixed);
627*4882a593Smuzhiyun }
628*4882a593Smuzhiyun break;
629*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
630*4882a593Smuzhiyun if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
631*4882a593Smuzhiyun rdesc = easypen_m406xe_rdesc_fixed;
632*4882a593Smuzhiyun *rsize = sizeof(easypen_m406xe_rdesc_fixed);
633*4882a593Smuzhiyun }
634*4882a593Smuzhiyun break;
635*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_PENSKETCH_M912:
636*4882a593Smuzhiyun if (*rsize == PENSKETCH_M912_RDESC_ORIG_SIZE) {
637*4882a593Smuzhiyun rdesc = pensketch_m912_rdesc_fixed;
638*4882a593Smuzhiyun *rsize = sizeof(pensketch_m912_rdesc_fixed);
639*4882a593Smuzhiyun }
640*4882a593Smuzhiyun break;
641*4882a593Smuzhiyun case USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE:
642*4882a593Smuzhiyun rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104,
643*4882a593Smuzhiyun "Genius Gila Gaming Mouse");
644*4882a593Smuzhiyun break;
645*4882a593Smuzhiyun case USB_DEVICE_ID_GENIUS_GX_IMPERATOR:
646*4882a593Smuzhiyun rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 83,
647*4882a593Smuzhiyun "Genius Gx Imperator Keyboard");
648*4882a593Smuzhiyun break;
649*4882a593Smuzhiyun case USB_DEVICE_ID_GENIUS_MANTICORE:
650*4882a593Smuzhiyun rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104,
651*4882a593Smuzhiyun "Genius Manticore Keyboard");
652*4882a593Smuzhiyun break;
653*4882a593Smuzhiyun }
654*4882a593Smuzhiyun return rdesc;
655*4882a593Smuzhiyun }
656*4882a593Smuzhiyun
657*4882a593Smuzhiyun /**
658*4882a593Smuzhiyun * Enable fully-functional tablet mode by setting a special feature report.
659*4882a593Smuzhiyun *
660*4882a593Smuzhiyun * @hdev: HID device
661*4882a593Smuzhiyun *
662*4882a593Smuzhiyun * The specific report ID and data were discovered by sniffing the
663*4882a593Smuzhiyun * Windows driver traffic.
664*4882a593Smuzhiyun */
kye_tablet_enable(struct hid_device * hdev)665*4882a593Smuzhiyun static int kye_tablet_enable(struct hid_device *hdev)
666*4882a593Smuzhiyun {
667*4882a593Smuzhiyun struct list_head *list;
668*4882a593Smuzhiyun struct list_head *head;
669*4882a593Smuzhiyun struct hid_report *report;
670*4882a593Smuzhiyun __s32 *value;
671*4882a593Smuzhiyun
672*4882a593Smuzhiyun list = &hdev->report_enum[HID_FEATURE_REPORT].report_list;
673*4882a593Smuzhiyun list_for_each(head, list) {
674*4882a593Smuzhiyun report = list_entry(head, struct hid_report, list);
675*4882a593Smuzhiyun if (report->id == 5)
676*4882a593Smuzhiyun break;
677*4882a593Smuzhiyun }
678*4882a593Smuzhiyun
679*4882a593Smuzhiyun if (head == list) {
680*4882a593Smuzhiyun hid_err(hdev, "tablet-enabling feature report not found\n");
681*4882a593Smuzhiyun return -ENODEV;
682*4882a593Smuzhiyun }
683*4882a593Smuzhiyun
684*4882a593Smuzhiyun if (report->maxfield < 1 || report->field[0]->report_count < 7) {
685*4882a593Smuzhiyun hid_err(hdev, "invalid tablet-enabling feature report\n");
686*4882a593Smuzhiyun return -ENODEV;
687*4882a593Smuzhiyun }
688*4882a593Smuzhiyun
689*4882a593Smuzhiyun value = report->field[0]->value;
690*4882a593Smuzhiyun
691*4882a593Smuzhiyun value[0] = 0x12;
692*4882a593Smuzhiyun value[1] = 0x10;
693*4882a593Smuzhiyun value[2] = 0x11;
694*4882a593Smuzhiyun value[3] = 0x12;
695*4882a593Smuzhiyun value[4] = 0x00;
696*4882a593Smuzhiyun value[5] = 0x00;
697*4882a593Smuzhiyun value[6] = 0x00;
698*4882a593Smuzhiyun hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
699*4882a593Smuzhiyun
700*4882a593Smuzhiyun return 0;
701*4882a593Smuzhiyun }
702*4882a593Smuzhiyun
kye_probe(struct hid_device * hdev,const struct hid_device_id * id)703*4882a593Smuzhiyun static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id)
704*4882a593Smuzhiyun {
705*4882a593Smuzhiyun int ret;
706*4882a593Smuzhiyun
707*4882a593Smuzhiyun ret = hid_parse(hdev);
708*4882a593Smuzhiyun if (ret) {
709*4882a593Smuzhiyun hid_err(hdev, "parse failed\n");
710*4882a593Smuzhiyun goto err;
711*4882a593Smuzhiyun }
712*4882a593Smuzhiyun
713*4882a593Smuzhiyun ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
714*4882a593Smuzhiyun if (ret) {
715*4882a593Smuzhiyun hid_err(hdev, "hw start failed\n");
716*4882a593Smuzhiyun goto err;
717*4882a593Smuzhiyun }
718*4882a593Smuzhiyun
719*4882a593Smuzhiyun switch (id->product) {
720*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_EASYPEN_I405X:
721*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
722*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2:
723*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_EASYPEN_M610X:
724*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
725*4882a593Smuzhiyun case USB_DEVICE_ID_KYE_PENSKETCH_M912:
726*4882a593Smuzhiyun ret = kye_tablet_enable(hdev);
727*4882a593Smuzhiyun if (ret) {
728*4882a593Smuzhiyun hid_err(hdev, "tablet enabling failed\n");
729*4882a593Smuzhiyun goto enabling_err;
730*4882a593Smuzhiyun }
731*4882a593Smuzhiyun break;
732*4882a593Smuzhiyun case USB_DEVICE_ID_GENIUS_MANTICORE:
733*4882a593Smuzhiyun /*
734*4882a593Smuzhiyun * The manticore keyboard needs to have all the interfaces
735*4882a593Smuzhiyun * opened at least once to be fully functional.
736*4882a593Smuzhiyun */
737*4882a593Smuzhiyun if (hid_hw_open(hdev))
738*4882a593Smuzhiyun hid_hw_close(hdev);
739*4882a593Smuzhiyun break;
740*4882a593Smuzhiyun }
741*4882a593Smuzhiyun
742*4882a593Smuzhiyun return 0;
743*4882a593Smuzhiyun enabling_err:
744*4882a593Smuzhiyun hid_hw_stop(hdev);
745*4882a593Smuzhiyun err:
746*4882a593Smuzhiyun return ret;
747*4882a593Smuzhiyun }
748*4882a593Smuzhiyun
749*4882a593Smuzhiyun static const struct hid_device_id kye_devices[] = {
750*4882a593Smuzhiyun { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) },
751*4882a593Smuzhiyun { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
752*4882a593Smuzhiyun USB_DEVICE_ID_KYE_EASYPEN_I405X) },
753*4882a593Smuzhiyun { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
754*4882a593Smuzhiyun USB_DEVICE_ID_KYE_MOUSEPEN_I608X) },
755*4882a593Smuzhiyun { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
756*4882a593Smuzhiyun USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) },
757*4882a593Smuzhiyun { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
758*4882a593Smuzhiyun USB_DEVICE_ID_KYE_EASYPEN_M610X) },
759*4882a593Smuzhiyun { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
760*4882a593Smuzhiyun USB_DEVICE_ID_KYE_EASYPEN_M406XE) },
761*4882a593Smuzhiyun { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
762*4882a593Smuzhiyun USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) },
763*4882a593Smuzhiyun { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
764*4882a593Smuzhiyun USB_DEVICE_ID_GENIUS_GX_IMPERATOR) },
765*4882a593Smuzhiyun { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
766*4882a593Smuzhiyun USB_DEVICE_ID_GENIUS_MANTICORE) },
767*4882a593Smuzhiyun { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
768*4882a593Smuzhiyun USB_DEVICE_ID_KYE_PENSKETCH_M912) },
769*4882a593Smuzhiyun { }
770*4882a593Smuzhiyun };
771*4882a593Smuzhiyun MODULE_DEVICE_TABLE(hid, kye_devices);
772*4882a593Smuzhiyun
773*4882a593Smuzhiyun static struct hid_driver kye_driver = {
774*4882a593Smuzhiyun .name = "kye",
775*4882a593Smuzhiyun .id_table = kye_devices,
776*4882a593Smuzhiyun .probe = kye_probe,
777*4882a593Smuzhiyun .report_fixup = kye_report_fixup,
778*4882a593Smuzhiyun };
779*4882a593Smuzhiyun module_hid_driver(kye_driver);
780*4882a593Smuzhiyun
781*4882a593Smuzhiyun MODULE_LICENSE("GPL");
782