aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-waltop.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-waltop.c')
-rw-r--r--drivers/hid/hid-waltop.c881
1 files changed, 224 insertions, 657 deletions
diff --git a/drivers/hid/hid-waltop.c b/drivers/hid/hid-waltop.c
index b3a4163f2e67..2cfd95c4467b 100644
--- a/drivers/hid/hid-waltop.c
+++ b/drivers/hid/hid-waltop.c
@@ -43,139 +43,14 @@
43 */ 43 */
44 44
45/* 45/*
46 * Original Slim Tablet 5.8 inch report descriptor. 46 * See Slim Tablet 5.8 inch description, device and HID report descriptors at
47 * 47 * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Slim_Tablet_5.8%22
48 * All the reports except the report with ID 16 (the stylus) are unused,
49 * possibly because the tablet is not configured to, or because they were
50 * just copied from a more capable model. The full purpose of features
51 * described for report ID 2 is unknown.
52 *
53 * The stylus buttons are described as three bit fields, whereas actually
54 * it's an "array", i.e. they're reported as button numbers (1, 2 and 3).
55 * The "eraser" field is not used. There is also a "push" without a "pop" in
56 * the stylus description.
57 *
58 * Usage Page (Desktop), ; Generic desktop controls (01h)
59 * Usage (Mouse), ; Mouse (02h, application collection)
60 * Collection (Application),
61 * Report ID (1),
62 * Usage (Pointer), ; Pointer (01h, physical collection)
63 * Collection (Physical),
64 * Usage Page (Button), ; Button (09h)
65 * Usage Minimum (01h),
66 * Usage Maximum (05h),
67 * Logical Minimum (0),
68 * Logical Maximum (1),
69 * Report Size (1),
70 * Report Count (5),
71 * Input (Variable),
72 * Report Size (3),
73 * Report Count (1),
74 * Input (Constant, Variable),
75 * Usage Page (Desktop), ; Generic desktop controls (01h)
76 * Usage (X), ; X (30h, dynamic value)
77 * Usage (Y), ; Y (31h, dynamic value)
78 * Usage (Wheel), ; Wheel (38h, dynamic value)
79 * Logical Minimum (-127),
80 * Logical Maximum (127),
81 * Report Size (8),
82 * Report Count (3),
83 * Input (Variable, Relative),
84 * End Collection,
85 * End Collection,
86 * Usage Page (Digitizer), ; Digitizer (0Dh)
87 * Usage (Pen), ; Pen (02h, application collection)
88 * Collection (Application),
89 * Report ID (2),
90 * Usage (Stylus), ; Stylus (20h, logical collection)
91 * Collection (Physical),
92 * Usage (00h),
93 * Logical Minimum (0),
94 * Logical Maximum (255),
95 * Report Size (8),
96 * Report Count (7),
97 * Input (Variable),
98 * Usage (Azimuth), ; Azimuth (3Fh, dynamic value)
99 * Usage (Altitude), ; Altitude (40h, dynamic value)
100 * Logical Minimum (0),
101 * Logical Maximum (255),
102 * Report Size (8),
103 * Report Count (2),
104 * Feature (Variable),
105 * End Collection,
106 * Report ID (5),
107 * Usage Page (Digitizer), ; Digitizer (0Dh)
108 * Usage (Stylus), ; Stylus (20h, logical collection)
109 * Collection (Physical),
110 * Usage (00h),
111 * Logical Minimum (0),
112 * Logical Maximum (255),
113 * Report Size (8),
114 * Report Count (7),
115 * Input (Variable),
116 * End Collection,
117 * Report ID (10),
118 * Usage Page (Digitizer), ; Digitizer (0Dh)
119 * Usage (Stylus), ; Stylus (20h, logical collection)
120 * Collection (Physical),
121 * Usage (00h),
122 * Logical Minimum (0),
123 * Logical Maximum (255),
124 * Report Size (8),
125 * Report Count (3),
126 * Input (Variable),
127 * End Collection,
128 * Report ID (16),
129 * Usage (Stylus), ; Stylus (20h, logical collection)
130 * Collection (Physical),
131 * Usage (Tip Switch), ; Tip switch (42h, momentary control)
132 * Usage (Barrel Switch), ; Barrel switch (44h, momentary control)
133 * Usage (Invert), ; Invert (3Ch, momentary control)
134 * Usage (Eraser), ; Eraser (45h, momentary control)
135 * Usage (In Range), ; In range (32h, momentary control)
136 * Logical Minimum (0),
137 * Logical Maximum (1),
138 * Report Size (1),
139 * Report Count (5),
140 * Input (Variable),
141 * Report Count (3),
142 * Input (Constant, Variable),
143 * Usage Page (Desktop), ; Generic desktop controls (01h)
144 * Usage (X), ; X (30h, dynamic value)
145 * Report Size (16),
146 * Report Count (1),
147 * Push,
148 * Unit Exponent (13),
149 * Unit (Inch^3),
150 * Logical Minimum (0),
151 * Logical Maximum (10000),
152 * Physical Minimum (0),
153 * Physical Maximum (10000),
154 * Input (Variable),
155 * Usage (Y), ; Y (31h, dynamic value)
156 * Logical Maximum (6000),
157 * Physical Maximum (6000),
158 * Input (Variable),
159 * Usage Page (Digitizer), ; Digitizer (0Dh)
160 * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
161 * Logical Minimum (0),
162 * Logical Maximum (1023),
163 * Physical Minimum (0),
164 * Physical Maximum (1023),
165 * Input (Variable),
166 * End Collection,
167 * End Collection
168 */ 48 */
169 49
170/* Size of the original report descriptor of Slim Tablet 5.8 inch */ 50/* Size of the original report descriptor of Slim Tablet 5.8 inch */
171#define SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE 222 51#define SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE 222
172 52
173/* 53/* Fixed Slim Tablet 5.8 inch descriptor */
174 * Fixed Slim Tablet 5.8 inch descriptor.
175 *
176 * All the reports except the stylus report (ID 16) were removed as unused.
177 * The stylus buttons description was fixed.
178 */
179static __u8 slim_tablet_5_8_inch_rdesc_fixed[] = { 54static __u8 slim_tablet_5_8_inch_rdesc_fixed[] = {
180 0x05, 0x0D, /* Usage Page (Digitizer), */ 55 0x05, 0x0D, /* Usage Page (Digitizer), */
181 0x09, 0x02, /* Usage (Pen), */ 56 0x09, 0x02, /* Usage (Pen), */
@@ -224,158 +99,14 @@ static __u8 slim_tablet_5_8_inch_rdesc_fixed[] = {
224}; 99};
225 100
226/* 101/*
227 * Original Slim Tablet 12.1 inch report descriptor. 102 * See Slim Tablet 12.1 inch description, device and HID report descriptors at
228 * 103 * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Slim_Tablet_12.1%22
229 * The descriptor is similar to the Slim Tablet 5.8 inch descriptor with the
230 * addition of a keyboard report, seemingly unused. It may have get here
231 * from a Media Tablet - probably an unimplemented feature.
232 *
233 * Usage Page (Desktop), ; Generic desktop controls (01h)
234 * Usage (Mouse), ; Mouse (02h, application collection)
235 * Collection (Application),
236 * Report ID (1),
237 * Usage (Pointer), ; Pointer (01h, physical collection)
238 * Collection (Physical),
239 * Usage Page (Button), ; Button (09h)
240 * Usage Minimum (01h),
241 * Usage Maximum (05h),
242 * Logical Minimum (0),
243 * Logical Maximum (1),
244 * Report Size (1),
245 * Report Count (5),
246 * Input (Variable),
247 * Report Size (3),
248 * Report Count (1),
249 * Input (Constant, Variable),
250 * Usage Page (Desktop), ; Generic desktop controls (01h)
251 * Usage (X), ; X (30h, dynamic value)
252 * Usage (Y), ; Y (31h, dynamic value)
253 * Usage (Wheel), ; Wheel (38h, dynamic value)
254 * Logical Minimum (-127),
255 * Logical Maximum (127),
256 * Report Size (8),
257 * Report Count (3),
258 * Input (Variable, Relative),
259 * End Collection,
260 * End Collection,
261 * Usage Page (Digitizer), ; Digitizer (0Dh)
262 * Usage (Pen), ; Pen (02h, application collection)
263 * Collection (Application),
264 * Report ID (2),
265 * Usage (Stylus), ; Stylus (20h, logical collection)
266 * Collection (Physical),
267 * Usage (00h),
268 * Logical Minimum (0),
269 * Logical Maximum (255),
270 * Report Size (8),
271 * Report Count (7),
272 * Input (Variable),
273 * Usage (Azimuth), ; Azimuth (3Fh, dynamic value)
274 * Usage (Altitude), ; Altitude (40h, dynamic value)
275 * Logical Minimum (0),
276 * Logical Maximum (255),
277 * Report Size (8),
278 * Report Count (2),
279 * Feature (Variable),
280 * End Collection,
281 * Report ID (5),
282 * Usage Page (Digitizer), ; Digitizer (0Dh)
283 * Usage (Stylus), ; Stylus (20h, logical collection)
284 * Collection (Physical),
285 * Usage (00h),
286 * Logical Minimum (0),
287 * Logical Maximum (255),
288 * Report Size (8),
289 * Report Count (7),
290 * Input (Variable),
291 * End Collection,
292 * Report ID (10),
293 * Usage Page (Digitizer), ; Digitizer (0Dh)
294 * Usage (Stylus), ; Stylus (20h, logical collection)
295 * Collection (Physical),
296 * Usage (00h),
297 * Logical Minimum (0),
298 * Logical Maximum (255),
299 * Report Size (8),
300 * Report Count (3),
301 * Input (Variable),
302 * End Collection,
303 * Report ID (16),
304 * Usage (Stylus), ; Stylus (20h, logical collection)
305 * Collection (Physical),
306 * Usage (Tip Switch), ; Tip switch (42h, momentary control)
307 * Usage (Barrel Switch), ; Barrel switch (44h, momentary control)
308 * Usage (Invert), ; Invert (3Ch, momentary control)
309 * Usage (Eraser), ; Eraser (45h, momentary control)
310 * Usage (In Range), ; In range (32h, momentary control)
311 * Logical Minimum (0),
312 * Logical Maximum (1),
313 * Report Size (1),
314 * Report Count (5),
315 * Input (Variable),
316 * Report Count (3),
317 * Input (Constant, Variable),
318 * Usage Page (Desktop), ; Generic desktop controls (01h)
319 * Usage (X), ; X (30h, dynamic value)
320 * Report Size (16),
321 * Report Count (1),
322 * Push,
323 * Unit Exponent (13),
324 * Unit (Inch^3),
325 * Logical Minimum (0),
326 * Logical Maximum (20000),
327 * Physical Minimum (0),
328 * Physical Maximum (20000),
329 * Input (Variable),
330 * Usage (Y), ; Y (31h, dynamic value)
331 * Logical Maximum (12500),
332 * Physical Maximum (12500),
333 * Input (Variable),
334 * Usage Page (Digitizer), ; Digitizer (0Dh)
335 * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
336 * Logical Minimum (0),
337 * Logical Maximum (1023),
338 * Physical Minimum (0),
339 * Physical Maximum (1023),
340 * Input (Variable),
341 * End Collection,
342 * End Collection,
343 * Usage Page (Desktop), ; Generic desktop controls (01h)
344 * Usage (Keyboard), ; Keyboard (06h, application collection)
345 * Collection (Application),
346 * Report ID (13),
347 * Usage Page (Keyboard), ; Keyboard/keypad (07h)
348 * Usage Minimum (KB Leftcontrol), ; Keyboard left control
349 * ; (E0h, dynamic value)
350 * Usage Maximum (KB Right GUI), ; Keyboard right GUI (E7h, dynamic value)
351 * Logical Minimum (0),
352 * Logical Maximum (1),
353 * Report Size (1),
354 * Report Count (8),
355 * Input (Variable),
356 * Report Size (8),
357 * Report Count (1),
358 * Input (Constant),
359 * Usage Page (Keyboard), ; Keyboard/keypad (07h)
360 * Usage Minimum (None), ; No event (00h, selector)
361 * Usage Maximum (KB Application), ; Keyboard Application (65h, selector)
362 * Logical Minimum (0),
363 * Logical Maximum (101),
364 * Report Size (8),
365 * Report Count (5),
366 * Input,
367 * End Collection
368 */ 104 */
369 105
370/* Size of the original report descriptor of Slim Tablet 12.1 inch */ 106/* Size of the original report descriptor of Slim Tablet 12.1 inch */
371#define SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE 269 107#define SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE 269
372 108
373/* 109/* Fixed Slim Tablet 12.1 inch descriptor */
374 * Fixed Slim Tablet 12.1 inch descriptor.
375 *
376 * All the reports except the stylus report (ID 16) were removed as unused.
377 * The stylus buttons description was fixed.
378 */
379static __u8 slim_tablet_12_1_inch_rdesc_fixed[] = { 110static __u8 slim_tablet_12_1_inch_rdesc_fixed[] = {
380 0x05, 0x0D, /* Usage Page (Digitizer), */ 111 0x05, 0x0D, /* Usage Page (Digitizer), */
381 0x09, 0x02, /* Usage (Pen), */ 112 0x09, 0x02, /* Usage (Pen), */
@@ -424,217 +155,128 @@ static __u8 slim_tablet_12_1_inch_rdesc_fixed[] = {
424}; 155};
425 156
426/* 157/*
427 * Original Media Tablet 10.6 inch report descriptor. 158 * See Q Pad description, device and HID report descriptors at
428 * 159 * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Q_Pad
429 * There are at least two versions of this model in the wild. They are
430 * represented by Genius G-Pen M609 (older version) and Genius G-Pen M609X
431 * (newer version).
432 *
433 * Both versions have the usual pen with two barrel buttons and two
434 * identical wheels with center buttons in the top corners of the tablet
435 * base. They also have buttons on the top, between the wheels, for
436 * selecting the wheels' functions and wide/standard mode. In the wide mode
437 * the whole working surface is sensed, in the standard mode a narrower area
438 * is sensed, but the logical report extents remain the same. These modes
439 * correspond roughly to 16:9 and 4:3 aspect ratios respectively.
440 *
441 * The older version has three wheel function buttons ("scroll", "zoom" and
442 * "volume") and two separate buttons for wide and standard mode. The newer
443 * version has four wheel function buttons (plus "brush") and only one
444 * button is used for selecting wide/standard mode. So, the total number of
445 * buttons remains the same, but one of the mode buttons is repurposed as a
446 * wheels' function button in the newer version.
447 *
448 * The wheel functions are:
449 * scroll - the wheels act as scroll wheels, the center buttons switch
450 * between vertical and horizontal scrolling;
451 * zoom - the wheels zoom in/out, the buttons supposedly reset to 100%;
452 * volume - the wheels control the sound volume, the buttons mute;
453 * brush - the wheels are supposed to control brush width in a graphics
454 * editor, the buttons do nothing.
455 *
456 * Below is the newer version's report descriptor. It may very well be that
457 * the older version's descriptor is different and thus it won't be
458 * supported.
459 *
460 * The mouse report (ID 1) only uses the wheel field for reporting the tablet
461 * wheels' scroll mode. The keyboard report (ID 13) is used to report the
462 * wheels' zoom and brush control functions as key presses. The report ID 12
463 * is used to report the wheels' volume control functions. The stylus report
464 * (ID 16) has the same problems as the Slim Tablet 5.8 inch report has.
465 *
466 * The rest of the reports are unused, at least in the default configuration.
467 * The purpose of the features is unknown.
468 *
469 * Usage Page (Desktop),
470 * Usage (Mouse),
471 * Collection (Application),
472 * Report ID (1),
473 * Usage (Pointer),
474 * Collection (Physical),
475 * Usage Page (Button),
476 * Usage Minimum (01h),
477 * Usage Maximum (05h),
478 * Logical Minimum (0),
479 * Logical Maximum (1),
480 * Report Size (1),
481 * Report Count (5),
482 * Input (Variable),
483 * Report Size (3),
484 * Report Count (1),
485 * Input (Constant, Variable),
486 * Usage Page (Desktop),
487 * Usage (X),
488 * Usage (Y),
489 * Usage (Wheel),
490 * Logical Minimum (-127),
491 * Logical Maximum (127),
492 * Report Size (8),
493 * Report Count (3),
494 * Input (Variable, Relative),
495 * End Collection,
496 * End Collection,
497 * Usage Page (Digitizer),
498 * Usage (Pen),
499 * Collection (Application),
500 * Report ID (2),
501 * Usage (Stylus),
502 * Collection (Physical),
503 * Usage (00h),
504 * Logical Minimum (0),
505 * Logical Maximum (255),
506 * Report Size (8),
507 * Report Count (7),
508 * Input (Variable),
509 * Usage (Azimuth),
510 * Usage (Altitude),
511 * Logical Minimum (0),
512 * Logical Maximum (255),
513 * Report Size (8),
514 * Report Count (2),
515 * Feature (Variable),
516 * End Collection,
517 * Report ID (5),
518 * Usage Page (Digitizer),
519 * Usage (Stylus),
520 * Collection (Physical),
521 * Usage (00h),
522 * Logical Minimum (0),
523 * Logical Maximum (255),
524 * Report Size (8),
525 * Report Count (7),
526 * Input (Variable),
527 * End Collection,
528 * Report ID (10),
529 * Usage Page (Digitizer),
530 * Usage (Stylus),
531 * Collection (Physical),
532 * Usage (00h),
533 * Logical Minimum (0),
534 * Logical Maximum (255),
535 * Report Size (8),
536 * Report Count (7),
537 * Input (Variable),
538 * End Collection,
539 * Report ID (16),
540 * Usage (Stylus),
541 * Collection (Physical),
542 * Usage (Tip Switch),
543 * Usage (Barrel Switch),
544 * Usage (Invert),
545 * Usage (Eraser),
546 * Usage (In Range),
547 * Logical Minimum (0),
548 * Logical Maximum (1),
549 * Report Size (1),
550 * Report Count (5),
551 * Input (Variable),
552 * Report Count (3),
553 * Input (Constant, Variable),
554 * Usage Page (Desktop),
555 * Usage (X),
556 * Report Size (16),
557 * Report Count (1),
558 * Push,
559 * Unit Exponent (13),
560 * Unit (Inch^3),
561 * Logical Minimum (0),
562 * Logical Maximum (18000),
563 * Physical Minimum (0),
564 * Physical Maximum (18000),
565 * Input (Variable),
566 * Usage (Y),
567 * Logical Maximum (11000),
568 * Physical Maximum (11000),
569 * Input (Variable),
570 * Usage Page (Digitizer),
571 * Usage (Tip Pressure),
572 * Logical Minimum (0),
573 * Logical Maximum (1023),
574 * Physical Minimum (0),
575 * Physical Maximum (1023),
576 * Input (Variable),
577 * End Collection,
578 * End Collection,
579 * Usage Page (Desktop),
580 * Usage (Keyboard),
581 * Collection (Application),
582 * Report ID (13),
583 * Usage Page (Keyboard),
584 * Usage Minimum (KB Leftcontrol),
585 * Usage Maximum (KB Right GUI),
586 * Logical Minimum (0),
587 * Logical Maximum (1),
588 * Report Size (1),
589 * Report Count (8),
590 * Input (Variable),
591 * Report Size (8),
592 * Report Count (1),
593 * Input (Constant),
594 * Usage Page (Keyboard),
595 * Usage Minimum (None),
596 * Usage Maximum (KB Application),
597 * Logical Minimum (0),
598 * Logical Maximum (101),
599 * Report Size (8),
600 * Report Count (5),
601 * Input,
602 * End Collection,
603 * Usage Page (Consumer),
604 * Usage (Consumer Control),
605 * Collection (Application),
606 * Report ID (12),
607 * Usage (Volume Inc),
608 * Usage (Volume Dec),
609 * Usage (Mute),
610 * Logical Minimum (0),
611 * Logical Maximum (1),
612 * Report Size (1),
613 * Report Count (3),
614 * Input (Variable, Relative),
615 * Report Size (5),
616 * Report Count (1),
617 * Input (Constant, Variable, Relative),
618 * End Collection
619 */ 160 */
620 161
621/* Size of the original report descriptor of Media Tablet 10.6 inch */ 162/* Size of the original report descriptor of Q Pad */
622#define MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE 300 163#define Q_PAD_RDESC_ORIG_SIZE 241
164
165/* Fixed Q Pad descriptor */
166static __u8 q_pad_rdesc_fixed[] = {
167 0x05, 0x0D, /* Usage Page (Digitizer), */
168 0x09, 0x02, /* Usage (Pen), */
169 0xA1, 0x01, /* Collection (Application), */
170 0x85, 0x10, /* Report ID (16), */
171 0x09, 0x20, /* Usage (Stylus), */
172 0xA0, /* Collection (Physical), */
173 0x09, 0x42, /* Usage (Tip Switch), */
174 0x09, 0x44, /* Usage (Barrel Switch), */
175 0x09, 0x46, /* Usage (Tablet Pick), */
176 0x15, 0x01, /* Logical Minimum (1), */
177 0x25, 0x03, /* Logical Maximum (3), */
178 0x75, 0x04, /* Report Size (4), */
179 0x95, 0x01, /* Report Count (1), */
180 0x80, /* Input, */
181 0x09, 0x32, /* Usage (In Range), */
182 0x14, /* Logical Minimum (0), */
183 0x25, 0x01, /* Logical Maximum (1), */
184 0x75, 0x01, /* Report Size (1), */
185 0x95, 0x01, /* Report Count (1), */
186 0x81, 0x02, /* Input (Variable), */
187 0x95, 0x03, /* Report Count (3), */
188 0x81, 0x03, /* Input (Constant, Variable), */
189 0x75, 0x10, /* Report Size (16), */
190 0x95, 0x01, /* Report Count (1), */
191 0x14, /* Logical Minimum (0), */
192 0xA4, /* Push, */
193 0x05, 0x01, /* Usage Page (Desktop), */
194 0x65, 0x13, /* Unit (Inch), */
195 0x55, 0xFD, /* Unit Exponent (-3), */
196 0x34, /* Physical Minimum (0), */
197 0x09, 0x30, /* Usage (X), */
198 0x46, 0x70, 0x17, /* Physical Maximum (6000), */
199 0x26, 0x00, 0x30, /* Logical Maximum (12288), */
200 0x81, 0x02, /* Input (Variable), */
201 0x09, 0x31, /* Usage (Y), */
202 0x46, 0x94, 0x11, /* Physical Maximum (4500), */
203 0x26, 0x00, 0x24, /* Logical Maximum (9216), */
204 0x81, 0x02, /* Input (Variable), */
205 0xB4, /* Pop, */
206 0x09, 0x30, /* Usage (Tip Pressure), */
207 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
208 0x81, 0x02, /* Input (Variable), */
209 0xC0, /* End Collection, */
210 0xC0 /* End Collection */
211};
623 212
624/* 213/*
625 * Fixed Media Tablet 10.6 inch descriptor. 214 * See description, device and HID report descriptors of tablet with PID 0038 at
626 * 215 * http://sf.net/apps/mediawiki/digimend/?title=Waltop_PID_0038
627 * The descriptions of reports unused in the default configuration are 216 */
628 * removed. The stylus report (ID 16) is fixed similarly to Slim Tablet 5.8 217
629 * inch. The unused mouse report (ID 1) fields are replaced with constant 218/* Size of the original report descriptor of tablet with PID 0038 */
630 * padding. 219#define PID_0038_RDESC_ORIG_SIZE 241
631 * 220
632 * The keyboard report (ID 13) is hacked to instead have an "array" field 221/*
633 * reporting consumer page controls, and all the unused bits are masked out 222 * Fixed report descriptor for tablet with PID 0038.
634 * with constant padding. The "brush" wheels' function is represented as "Scan 223 */
635 * Previous/Next Track" controls due to the lack of brush controls in the 224static __u8 pid_0038_rdesc_fixed[] = {
636 * usage tables specification. 225 0x05, 0x0D, /* Usage Page (Digitizer), */
226 0x09, 0x02, /* Usage (Pen), */
227 0xA1, 0x01, /* Collection (Application), */
228 0x85, 0x10, /* Report ID (16), */
229 0x09, 0x20, /* Usage (Stylus), */
230 0xA0, /* Collection (Physical), */
231 0x09, 0x42, /* Usage (Tip Switch), */
232 0x09, 0x44, /* Usage (Barrel Switch), */
233 0x09, 0x46, /* Usage (Tablet Pick), */
234 0x15, 0x01, /* Logical Minimum (1), */
235 0x25, 0x03, /* Logical Maximum (3), */
236 0x75, 0x04, /* Report Size (4), */
237 0x95, 0x01, /* Report Count (1), */
238 0x80, /* Input, */
239 0x09, 0x32, /* Usage (In Range), */
240 0x14, /* Logical Minimum (0), */
241 0x25, 0x01, /* Logical Maximum (1), */
242 0x75, 0x01, /* Report Size (1), */
243 0x95, 0x01, /* Report Count (1), */
244 0x81, 0x02, /* Input (Variable), */
245 0x95, 0x03, /* Report Count (3), */
246 0x81, 0x03, /* Input (Constant, Variable), */
247 0x75, 0x10, /* Report Size (16), */
248 0x95, 0x01, /* Report Count (1), */
249 0x14, /* Logical Minimum (0), */
250 0xA4, /* Push, */
251 0x05, 0x01, /* Usage Page (Desktop), */
252 0x65, 0x13, /* Unit (Inch), */
253 0x55, 0xFD, /* Unit Exponent (-3), */
254 0x34, /* Physical Minimum (0), */
255 0x09, 0x30, /* Usage (X), */
256 0x46, 0x2E, 0x22, /* Physical Maximum (8750), */
257 0x26, 0x00, 0x46, /* Logical Maximum (17920), */
258 0x81, 0x02, /* Input (Variable), */
259 0x09, 0x31, /* Usage (Y), */
260 0x46, 0x82, 0x14, /* Physical Maximum (5250), */
261 0x26, 0x00, 0x2A, /* Logical Maximum (10752), */
262 0x81, 0x02, /* Input (Variable), */
263 0xB4, /* Pop, */
264 0x09, 0x30, /* Usage (Tip Pressure), */
265 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
266 0x81, 0x02, /* Input (Variable), */
267 0xC0, /* End Collection, */
268 0xC0 /* End Collection */
269};
270
271/*
272 * See Media Tablet 10.6 inch description, device and HID report descriptors at
273 * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Media_Tablet_10.6%22
637 */ 274 */
275
276/* Size of the original report descriptor of Media Tablet 10.6 inch */
277#define MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE 300
278
279/* Fixed Media Tablet 10.6 inch descriptor */
638static __u8 media_tablet_10_6_inch_rdesc_fixed[] = { 280static __u8 media_tablet_10_6_inch_rdesc_fixed[] = {
639 0x05, 0x0D, /* Usage Page (Digitizer), */ 281 0x05, 0x0D, /* Usage Page (Digitizer), */
640 0x09, 0x02, /* Usage (Pen), */ 282 0x09, 0x02, /* Usage (Pen), */
@@ -745,187 +387,14 @@ static __u8 media_tablet_10_6_inch_rdesc_fixed[] = {
745}; 387};
746 388
747/* 389/*
748 * Original Media Tablet 14.1 inch report descriptor. 390 * See Media Tablet 14.1 inch description, device and HID report descriptors at
749 * 391 * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Media_Tablet_14.1%22
750 * There are at least two versions of this model in the wild. They are
751 * represented by Genius G-Pen M712 (older version) and Genius G-Pen M712X
752 * (newer version). The hardware difference between these versions is the same
753 * as between older and newer versions of Media Tablet 10.6 inch. The report
754 * descriptors are identical for both versions.
755 *
756 * The function, behavior and report descriptor of this tablet is similar to
757 * that of Media Tablet 10.6 inch. However, there is one more field (with
758 * Consumer AC Pan usage) in the mouse description. Then the tablet X and Y
759 * logical extents both get scaled to 0..16383 range (a hardware limit?),
760 * which kind of defeats the advertised 4000 LPI resolution, considering the
761 * physical extents of 12x7.25 inches. Plus, reports 5, 10 and 255 are used
762 * sometimes (while moving the pen) with unknown purpose. Also, the key codes
763 * generated for zoom in/out are different.
764 *
765 * Usage Page (Desktop),
766 * Usage (Mouse),
767 * Collection (Application),
768 * Report ID (1),
769 * Usage (Pointer),
770 * Collection (Physical),
771 * Usage Page (Button),
772 * Usage Minimum (01h),
773 * Usage Maximum (05h),
774 * Logical Minimum (0),
775 * Logical Maximum (1),
776 * Report Size (1),
777 * Report Count (5),
778 * Input (Variable),
779 * Report Size (3),
780 * Report Count (1),
781 * Input (Constant, Variable),
782 * Usage Page (Desktop),
783 * Usage (X),
784 * Usage (Y),
785 * Usage (Wheel),
786 * Logical Minimum (-127),
787 * Logical Maximum (127),
788 * Report Size (8),
789 * Report Count (3),
790 * Input (Variable, Relative),
791 * Usage Page (Consumer),
792 * Logical Minimum (-127),
793 * Logical Maximum (127),
794 * Report Size (8),
795 * Report Count (1),
796 * Usage (AC Pan),
797 * Input (Variable, Relative),
798 * End Collection,
799 * End Collection,
800 * Usage Page (Digitizer),
801 * Usage (Pen),
802 * Collection (Application),
803 * Report ID (2),
804 * Usage (Stylus),
805 * Collection (Physical),
806 * Usage (00h),
807 * Logical Minimum (0),
808 * Logical Maximum (255),
809 * Report Size (8),
810 * Report Count (7),
811 * Input (Variable),
812 * Usage (Azimuth),
813 * Usage (Altitude),
814 * Logical Minimum (0),
815 * Logical Maximum (255),
816 * Report Size (8),
817 * Report Count (2),
818 * Feature (Variable),
819 * End Collection,
820 * Report ID (5),
821 * Usage Page (Digitizer),
822 * Usage (Stylus),
823 * Collection (Physical),
824 * Usage (00h),
825 * Logical Minimum (0),
826 * Logical Maximum (255),
827 * Report Size (8),
828 * Report Count (7),
829 * Input (Variable),
830 * End Collection,
831 * Report ID (10),
832 * Usage Page (Digitizer),
833 * Usage (Stylus),
834 * Collection (Physical),
835 * Usage (00h),
836 * Logical Minimum (0),
837 * Logical Maximum (255),
838 * Report Size (8),
839 * Report Count (7),
840 * Input (Variable),
841 * End Collection,
842 * Report ID (16),
843 * Usage (Stylus),
844 * Collection (Physical),
845 * Usage (Tip Switch),
846 * Usage (Barrel Switch),
847 * Usage (Invert),
848 * Usage (Eraser),
849 * Usage (In Range),
850 * Logical Minimum (0),
851 * Logical Maximum (1),
852 * Report Size (1),
853 * Report Count (5),
854 * Input (Variable),
855 * Report Count (3),
856 * Input (Constant, Variable),
857 * Usage Page (Desktop),
858 * Usage (X),
859 * Report Size (16),
860 * Report Count (1),
861 * Push,
862 * Unit Exponent (13),
863 * Unit (Inch^3),
864 * Logical Minimum (0),
865 * Logical Maximum (16383),
866 * Physical Minimum (0),
867 * Physical Maximum (16383),
868 * Input (Variable),
869 * Usage (Y),
870 * Input (Variable),
871 * Usage Page (Digitizer),
872 * Usage (Tip Pressure),
873 * Logical Minimum (0),
874 * Logical Maximum (1023),
875 * Physical Minimum (0),
876 * Physical Maximum (1023),
877 * Input (Variable),
878 * End Collection,
879 * End Collection,
880 * Usage Page (Desktop),
881 * Usage (Keyboard),
882 * Collection (Application),
883 * Report ID (13),
884 * Usage Page (Keyboard),
885 * Usage Minimum (KB Leftcontrol),
886 * Usage Maximum (KB Right GUI),
887 * Logical Minimum (0),
888 * Logical Maximum (1),
889 * Report Size (1),
890 * Report Count (8),
891 * Input (Variable),
892 * Report Size (8),
893 * Report Count (1),
894 * Input (Constant),
895 * Usage Page (Keyboard),
896 * Usage Minimum (None),
897 * Usage Maximum (KB Application),
898 * Logical Minimum (0),
899 * Logical Maximum (101),
900 * Report Size (8),
901 * Report Count (5),
902 * Input,
903 * End Collection,
904 * Usage Page (Consumer),
905 * Usage (Consumer Control),
906 * Collection (Application),
907 * Report ID (12),
908 * Usage (Volume Inc),
909 * Usage (Volume Dec),
910 * Usage (Mute),
911 * Logical Minimum (0),
912 * Logical Maximum (1),
913 * Report Size (1),
914 * Report Count (3),
915 * Input (Variable, Relative),
916 * Report Size (5),
917 * Report Count (1),
918 * Input (Constant, Variable, Relative),
919 * End Collection
920 */ 392 */
921 393
922/* Size of the original report descriptor of Media Tablet 14.1 inch */ 394/* Size of the original report descriptor of Media Tablet 14.1 inch */
923#define MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE 309 395#define MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE 309
924 396
925/* 397/* Fixed Media Tablet 14.1 inch descriptor */
926 * Fixed Media Tablet 14.1 inch descriptor.
927 * It is fixed similarly to the Media Tablet 10.6 inch descriptor.
928 */
929static __u8 media_tablet_14_1_inch_rdesc_fixed[] = { 398static __u8 media_tablet_14_1_inch_rdesc_fixed[] = {
930 0x05, 0x0D, /* Usage Page (Digitizer), */ 399 0x05, 0x0D, /* Usage Page (Digitizer), */
931 0x09, 0x02, /* Usage (Pen), */ 400 0x09, 0x02, /* Usage (Pen), */
@@ -1033,6 +502,47 @@ static __u8 media_tablet_14_1_inch_rdesc_fixed[] = {
1033 0xC0 /* End Collection */ 502 0xC0 /* End Collection */
1034}; 503};
1035 504
505struct waltop_state {
506 u8 pressure0;
507 u8 pressure1;
508};
509
510static int waltop_probe(struct hid_device *hdev,
511 const struct hid_device_id *id)
512{
513 int ret;
514 struct waltop_state *s;
515
516 s = kzalloc(sizeof(*s), GFP_KERNEL);
517 if (s == NULL) {
518 hid_err(hdev, "can't allocate device state\n");
519 ret = -ENOMEM;
520 goto err;
521 }
522
523 s->pressure0 = 0;
524 s->pressure1 = 0;
525
526 hid_set_drvdata(hdev, s);
527
528 ret = hid_parse(hdev);
529 if (ret) {
530 hid_err(hdev, "parse failed\n");
531 goto err;
532 }
533
534 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
535 if (ret) {
536 hid_err(hdev, "hw start failed\n");
537 goto err;
538 }
539
540 return 0;
541err:
542 kfree(s);
543 return ret;
544}
545
1036static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc, 546static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
1037 unsigned int *rsize) 547 unsigned int *rsize)
1038{ 548{
@@ -1049,6 +559,18 @@ static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
1049 *rsize = sizeof(slim_tablet_12_1_inch_rdesc_fixed); 559 *rsize = sizeof(slim_tablet_12_1_inch_rdesc_fixed);
1050 } 560 }
1051 break; 561 break;
562 case USB_DEVICE_ID_WALTOP_Q_PAD:
563 if (*rsize == Q_PAD_RDESC_ORIG_SIZE) {
564 rdesc = q_pad_rdesc_fixed;
565 *rsize = sizeof(q_pad_rdesc_fixed);
566 }
567 break;
568 case USB_DEVICE_ID_WALTOP_PID_0038:
569 if (*rsize == PID_0038_RDESC_ORIG_SIZE) {
570 rdesc = pid_0038_rdesc_fixed;
571 *rsize = sizeof(pid_0038_rdesc_fixed);
572 }
573 break;
1052 case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH: 574 case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH:
1053 if (*rsize == MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE) { 575 if (*rsize == MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE) {
1054 rdesc = media_tablet_10_6_inch_rdesc_fixed; 576 rdesc = media_tablet_10_6_inch_rdesc_fixed;
@@ -1065,12 +587,54 @@ static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
1065 return rdesc; 587 return rdesc;
1066} 588}
1067 589
590static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report,
591 u8 *data, int size)
592{
593 /* If this is a pen input report of a tablet with PID 0038 */
594 if (hdev->product == USB_DEVICE_ID_WALTOP_PID_0038 &&
595 report->type == HID_INPUT_REPORT &&
596 report->id == 16 &&
597 size == 8) {
598 struct waltop_state *s = hid_get_drvdata(hdev);
599
600 /*
601 * Ignore maximum pressure reported when a barrel button is
602 * pressed.
603 */
604
605 /* If a barrel button is pressed */
606 if ((data[1] & 0xF) > 1) {
607 /* Use the last known pressure */
608 data[6] = s->pressure0;
609 data[7] = s->pressure1;
610 } else {
611 /* Remember reported pressure */
612 s->pressure0 = data[6];
613 s->pressure1 = data[7];
614 }
615 }
616
617 return 0;
618}
619
620static void waltop_remove(struct hid_device *hdev)
621{
622 struct waltop_state *s = hid_get_drvdata(hdev);
623
624 hid_hw_stop(hdev);
625 kfree(s);
626}
627
1068static const struct hid_device_id waltop_devices[] = { 628static const struct hid_device_id waltop_devices[] = {
1069 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, 629 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
1070 USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, 630 USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
1071 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, 631 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
1072 USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, 632 USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
1073 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, 633 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
634 USB_DEVICE_ID_WALTOP_Q_PAD) },
635 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
636 USB_DEVICE_ID_WALTOP_PID_0038) },
637 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
1074 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, 638 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
1075 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, 639 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
1076 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, 640 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
@@ -1081,7 +645,10 @@ MODULE_DEVICE_TABLE(hid, waltop_devices);
1081static struct hid_driver waltop_driver = { 645static struct hid_driver waltop_driver = {
1082 .name = "waltop", 646 .name = "waltop",
1083 .id_table = waltop_devices, 647 .id_table = waltop_devices,
648 .probe = waltop_probe,
1084 .report_fixup = waltop_report_fixup, 649 .report_fixup = waltop_report_fixup,
650 .raw_event = waltop_raw_event,
651 .remove = waltop_remove,
1085}; 652};
1086 653
1087static int __init waltop_init(void) 654static int __init waltop_init(void)