]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - drivers/hid/hid-waltop.c
HID: waltop: add Media Tablet 14.1 inch support
[mirror_ubuntu-eoan-kernel.git] / drivers / hid / hid-waltop.c
CommitLineData
72a46344
NK
1/*
2 * HID driver for Waltop devices not fully compliant with HID standard
3 *
4 * Copyright (c) 2010 Nikolai Kondrashov
5 */
6
7/*
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 */
13
14#include <linux/device.h>
15#include <linux/hid.h>
16#include <linux/module.h>
17
18#include "hid-ids.h"
19
20/*
21 * Original Slim Tablet 5.8 inch report descriptor.
22 *
23 * All the reports except the report with ID 16 (the stylus) are unused,
24 * possibly because the tablet is not configured to, or because they were
25 * just copied from a more capable model. The purpose of features described
26 * for report ID 2 is unknown.
27 *
28 * The stylus buttons are described as three bit fields, whereas actually
29 * it's an "array", i.e. they're reported as button numbers (1, 2 and 3).
30 * The "eraser" field is not used. There is also a "push" without a "pop" in
31 * the stylus description.
32 *
33 * Usage Page (Desktop), ; Generic desktop controls (01h)
34 * Usage (Mouse), ; Mouse (02h, application collection)
35 * Collection (Application),
36 * Report ID (1),
37 * Usage (Pointer), ; Pointer (01h, physical collection)
38 * Collection (Physical),
39 * Usage Page (Button), ; Button (09h)
40 * Usage Minimum (01h),
41 * Usage Maximum (05h),
42 * Logical Minimum (0),
43 * Logical Maximum (1),
44 * Report Size (1),
45 * Report Count (5),
46 * Input (Variable),
47 * Report Size (3),
48 * Report Count (1),
49 * Input (Constant, Variable),
50 * Usage Page (Desktop), ; Generic desktop controls (01h)
51 * Usage (X), ; X (30h, dynamic value)
52 * Usage (Y), ; Y (31h, dynamic value)
53 * Usage (Wheel), ; Wheel (38h, dynamic value)
54 * Logical Minimum (-127),
55 * Logical Maximum (127),
56 * Report Size (8),
57 * Report Count (3),
58 * Input (Variable, Relative),
59 * End Collection,
60 * End Collection,
61 * Usage Page (Digitizer), ; Digitizer (0Dh)
62 * Usage (Pen), ; Pen (02h, application collection)
63 * Collection (Application),
64 * Report ID (2),
65 * Usage (Stylus), ; Stylus (20h, logical collection)
66 * Collection (Physical),
67 * Usage (00h),
68 * Logical Minimum (0),
69 * Logical Maximum (255),
70 * Report Size (8),
71 * Report Count (7),
72 * Input (Variable),
73 * Usage (Azimuth), ; Azimuth (3Fh, dynamic value)
74 * Usage (Altitude), ; Altitude (40h, dynamic value)
75 * Logical Minimum (0),
76 * Logical Maximum (255),
77 * Report Size (8),
78 * Report Count (2),
79 * Feature (Variable),
80 * End Collection,
81 * Report ID (5),
82 * Usage Page (Digitizer), ; Digitizer (0Dh)
83 * Usage (Stylus), ; Stylus (20h, logical collection)
84 * Collection (Physical),
85 * Usage (00h),
86 * Logical Minimum (0),
87 * Logical Maximum (255),
88 * Report Size (8),
89 * Report Count (7),
90 * Input (Variable),
91 * End Collection,
92 * Report ID (10),
93 * Usage Page (Digitizer), ; Digitizer (0Dh)
94 * Usage (Stylus), ; Stylus (20h, logical collection)
95 * Collection (Physical),
96 * Usage (00h),
97 * Logical Minimum (0),
98 * Logical Maximum (255),
99 * Report Size (8),
100 * Report Count (3),
101 * Input (Variable),
102 * End Collection,
103 * Report ID (16),
104 * Usage (Stylus), ; Stylus (20h, logical collection)
105 * Collection (Physical),
106 * Usage (Tip Switch), ; Tip switch (42h, momentary control)
107 * Usage (Barrel Switch), ; Barrel switch (44h, momentary control)
108 * Usage (Invert), ; Invert (3Ch, momentary control)
109 * Usage (Eraser), ; Eraser (45h, momentary control)
110 * Usage (In Range), ; In range (32h, momentary control)
111 * Logical Minimum (0),
112 * Logical Maximum (1),
113 * Report Size (1),
114 * Report Count (5),
115 * Input (Variable),
116 * Report Count (3),
117 * Input (Constant, Variable),
118 * Usage Page (Desktop), ; Generic desktop controls (01h)
119 * Usage (X), ; X (30h, dynamic value)
120 * Report Size (16),
121 * Report Count (1),
122 * Push,
123 * Unit Exponent (13),
124 * Unit (Inch^3),
125 * Logical Minimum (0),
126 * Logical Maximum (10000),
127 * Physical Minimum (0),
128 * Physical Maximum (10000),
129 * Input (Variable),
130 * Usage (Y), ; Y (31h, dynamic value)
131 * Logical Maximum (6000),
132 * Physical Maximum (6000),
133 * Input (Variable),
134 * Usage Page (Digitizer), ; Digitizer (0Dh)
135 * Usage (Tip Pressure), ; Tip pressure (30h, dynamic value)
136 * Logical Minimum (0),
137 * Logical Maximum (1023),
138 * Physical Minimum (0),
139 * Physical Maximum (1023),
140 * Input (Variable),
141 * End Collection,
142 * End Collection
143 */
144
145/* Size of the original report descriptor of Slim Tablet 5.8 inch */
146#define SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE 222
147
148/*
149 * Fixed Slim Tablet 5.8 inch descriptor.
150 *
151 * All the reports except the stylus report (ID 16) were removed as unused.
152 * The stylus buttons description was fixed.
153 */
154static __u8 slim_tablet_5_8_inch_rdesc_fixed[] = {
155 0x05, 0x0D, /* Usage Page (Digitizer), */
156 0x09, 0x02, /* Usage (Pen), */
157 0xA1, 0x01, /* Collection (Application), */
158 0x85, 0x10, /* Report ID (16), */
159 0x09, 0x20, /* Usage (Stylus), */
160 0xA0, /* Collection (Physical), */
161 0x09, 0x42, /* Usage (Tip Switch), */
162 0x09, 0x44, /* Usage (Barrel Switch), */
163 0x09, 0x46, /* Usage (Tablet Pick), */
164 0x15, 0x01, /* Logical Minimum (1), */
165 0x25, 0x03, /* Logical Maximum (3), */
166 0x75, 0x04, /* Report Size (4), */
167 0x95, 0x01, /* Report Count (1), */
168 0x80, /* Input, */
169 0x09, 0x32, /* Usage (In Range), */
170 0x14, /* Logical Minimum (0), */
171 0x25, 0x01, /* Logical Maximum (1), */
172 0x75, 0x01, /* Report Size (1), */
173 0x95, 0x01, /* Report Count (1), */
174 0x81, 0x02, /* Input (Variable), */
175 0x95, 0x03, /* Report Count (3), */
176 0x81, 0x03, /* Input (Constant, Variable), */
177 0x75, 0x10, /* Report Size (16), */
178 0x95, 0x01, /* Report Count (1), */
179 0x14, /* Logical Minimum (0), */
180 0xA4, /* Push, */
181 0x05, 0x01, /* Usage Page (Desktop), */
182 0x65, 0x13, /* Unit (Inch), */
183 0x55, 0xFD, /* Unit Exponent (-3), */
184 0x34, /* Physical Minimum (0), */
185 0x09, 0x30, /* Usage (X), */
186 0x46, 0x88, 0x13, /* Physical Maximum (5000), */
187 0x26, 0x10, 0x27, /* Logical Maximum (10000), */
188 0x81, 0x02, /* Input (Variable), */
189 0x09, 0x31, /* Usage (Y), */
190 0x46, 0xB8, 0x0B, /* Physical Maximum (3000), */
191 0x26, 0x70, 0x17, /* Logical Maximum (6000), */
192 0x81, 0x02, /* Input (Variable), */
193 0xB4, /* Pop, */
194 0x09, 0x30, /* Usage (Tip Pressure), */
195 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
196 0x81, 0x02, /* Input (Variable), */
197 0xC0, /* End Collection, */
198 0xC0 /* End Collection */
199};
200
201/*
202 * Original Media Tablet 10.6 inch report descriptor.
203 *
204 * There are at least two versions of this model in the wild. They are
205 * represented by Genius G-Pen M609 (older version) and Genius G-Pen M609X
206 * (newer version).
207 *
208 * Both versions have the usual pen with two barrel buttons and two
209 * identical wheels with center buttons in the top corners of the tablet
210 * base. They also have buttons on the top, between the wheels, for
211 * selecting the wheels' functions and wide/standard mode. In the wide mode
212 * the whole working surface is sensed, in the standard mode a narrower area
213 * is sensed, but the logical report extents remain the same. These modes
214 * correspond roughly to 16:9 and 4:3 aspect ratios respectively.
215 *
216 * The older version has three wheel function buttons ("scroll", "zoom" and
217 * "volume") and two separate buttons for wide and standard mode. The newer
218 * version has four wheel function buttons (plus "brush") and only one
219 * button is used for selecting wide/standard mode. So, the total number of
220 * buttons remains the same, but one of the mode buttons is repurposed as a
221 * wheels' function button in the newer version.
222 *
223 * The wheel functions are:
4b5b4575
NK
224 * scroll - the wheels act as scroll wheels, the center buttons switch
225 * between vertical and horizontal scrolling;
226 * zoom - the wheels zoom in/out, the buttons supposedly reset to 100%;
227 * volume - the wheels control the sound volume, the buttons mute;
72a46344
NK
228 * brush - the wheels are supposed to control brush width in a graphics
229 * editor, the buttons do nothing.
230 *
231 * Below is the newer version's report descriptor. It may very well be that
232 * the older version's descriptor is different and thus it won't be
233 * supported.
234 *
235 * The mouse report (ID 1) only uses the wheel field for reporting the tablet
236 * wheels' scroll mode. The keyboard report (ID 13) is used to report the
237 * wheels' zoom and brush control functions as key presses. The report ID 12
238 * is used to report the wheels' volume control functions. The stylus report
239 * (ID 16) has the same problems as the Slim Tablet 5.8 inch report has.
240 *
241 * The rest of the reports are unused, at least in the default configuration.
242 * The purpose of the features is unknown.
243 *
244 * Usage Page (Desktop),
245 * Usage (Mouse),
246 * Collection (Application),
247 * Report ID (1),
248 * Usage (Pointer),
249 * Collection (Physical),
250 * Usage Page (Button),
251 * Usage Minimum (01h),
252 * Usage Maximum (05h),
253 * Logical Minimum (0),
254 * Logical Maximum (1),
255 * Report Size (1),
256 * Report Count (5),
257 * Input (Variable),
258 * Report Size (3),
259 * Report Count (1),
260 * Input (Constant, Variable),
261 * Usage Page (Desktop),
262 * Usage (X),
263 * Usage (Y),
264 * Usage (Wheel),
265 * Logical Minimum (-127),
266 * Logical Maximum (127),
267 * Report Size (8),
268 * Report Count (3),
269 * Input (Variable, Relative),
270 * End Collection,
271 * End Collection,
272 * Usage Page (Digitizer),
273 * Usage (Pen),
274 * Collection (Application),
275 * Report ID (2),
276 * Usage (Stylus),
277 * Collection (Physical),
278 * Usage (00h),
279 * Logical Minimum (0),
280 * Logical Maximum (255),
281 * Report Size (8),
282 * Report Count (7),
283 * Input (Variable),
284 * Usage (Azimuth),
285 * Usage (Altitude),
286 * Logical Minimum (0),
287 * Logical Maximum (255),
288 * Report Size (8),
289 * Report Count (2),
290 * Feature (Variable),
291 * End Collection,
292 * Report ID (5),
293 * Usage Page (Digitizer),
294 * Usage (Stylus),
295 * Collection (Physical),
296 * Usage (00h),
297 * Logical Minimum (0),
298 * Logical Maximum (255),
299 * Report Size (8),
300 * Report Count (7),
301 * Input (Variable),
302 * End Collection,
303 * Report ID (10),
304 * Usage Page (Digitizer),
305 * Usage (Stylus),
306 * Collection (Physical),
307 * Usage (00h),
308 * Logical Minimum (0),
309 * Logical Maximum (255),
310 * Report Size (8),
311 * Report Count (7),
312 * Input (Variable),
313 * End Collection,
314 * Report ID (16),
315 * Usage (Stylus),
316 * Collection (Physical),
317 * Usage (Tip Switch),
318 * Usage (Barrel Switch),
319 * Usage (Invert),
320 * Usage (Eraser),
321 * Usage (In Range),
322 * Logical Minimum (0),
323 * Logical Maximum (1),
324 * Report Size (1),
325 * Report Count (5),
326 * Input (Variable),
327 * Report Count (3),
328 * Input (Constant, Variable),
329 * Usage Page (Desktop),
330 * Usage (X),
331 * Report Size (16),
332 * Report Count (1),
333 * Push,
334 * Unit Exponent (13),
335 * Unit (Inch^3),
336 * Logical Minimum (0),
337 * Logical Maximum (18000),
338 * Physical Minimum (0),
339 * Physical Maximum (18000),
340 * Input (Variable),
341 * Usage (Y),
342 * Logical Maximum (11000),
343 * Physical Maximum (11000),
344 * Input (Variable),
345 * Usage Page (Digitizer),
346 * Usage (Tip Pressure),
347 * Logical Minimum (0),
348 * Logical Maximum (1023),
349 * Physical Minimum (0),
350 * Physical Maximum (1023),
351 * Input (Variable),
352 * End Collection,
353 * End Collection,
354 * Usage Page (Desktop),
355 * Usage (Keyboard),
356 * Collection (Application),
357 * Report ID (13),
358 * Usage Page (Keyboard),
359 * Usage Minimum (KB Leftcontrol),
360 * Usage Maximum (KB Right GUI),
361 * Logical Minimum (0),
362 * Logical Maximum (1),
363 * Report Size (1),
364 * Report Count (8),
365 * Input (Variable),
366 * Report Size (8),
367 * Report Count (1),
368 * Input (Constant),
369 * Usage Page (Keyboard),
370 * Usage Minimum (None),
371 * Usage Maximum (KB Application),
372 * Logical Minimum (0),
373 * Logical Maximum (101),
374 * Report Size (8),
375 * Report Count (5),
376 * Input,
377 * End Collection,
378 * Usage Page (Consumer),
379 * Usage (Consumer Control),
380 * Collection (Application),
381 * Report ID (12),
382 * Usage (Volume Inc),
383 * Usage (Volume Dec),
384 * Usage (Mute),
385 * Logical Minimum (0),
386 * Logical Maximum (1),
387 * Report Size (1),
388 * Report Count (3),
389 * Input (Variable, Relative),
390 * Report Size (5),
391 * Report Count (1),
392 * Input (Constant, Variable, Relative),
393 * End Collection
394 */
395
396/* Size of the original report descriptor of Media Tablet 10.6 inch */
397#define MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE 300
398
399/*
400 * Fixed Media Tablet 10.6 inch descriptor.
401 *
402 * The descriptions of reports unused in the default configuration are
403 * removed. The stylus report (ID 16) is fixed similarly to Slim Tablet 5.8
404 * inch. The unused mouse report (ID 1) fields are replaced with constant
405 * padding.
406 *
407 * The keyboard report (ID 13) is hacked to instead have an "array" field
408 * reporting consumer page controls, and all the unused bits are masked out
409 * with constant padding. The "brush" wheels' function is represented as "Scan
410 * Previous/Next Track" controls due to the lack of brush controls in the
411 * usage tables specification.
412 */
413static __u8 media_tablet_10_6_inch_rdesc_fixed[] = {
414 0x05, 0x0D, /* Usage Page (Digitizer), */
415 0x09, 0x02, /* Usage (Pen), */
416 0xA1, 0x01, /* Collection (Application), */
417 0x85, 0x10, /* Report ID (16), */
418 0x09, 0x20, /* Usage (Stylus), */
419 0xA0, /* Collection (Physical), */
420 0x09, 0x42, /* Usage (Tip Switch), */
421 0x09, 0x44, /* Usage (Barrel Switch), */
422 0x09, 0x46, /* Usage (Tablet Pick), */
423 0x15, 0x01, /* Logical Minimum (1), */
424 0x25, 0x03, /* Logical Maximum (3), */
425 0x75, 0x04, /* Report Size (4), */
426 0x95, 0x01, /* Report Count (1), */
427 0x80, /* Input, */
428 0x75, 0x01, /* Report Size (1), */
429 0x09, 0x32, /* Usage (In Range), */
430 0x14, /* Logical Minimum (0), */
431 0x25, 0x01, /* Logical Maximum (1), */
432 0x95, 0x01, /* Report Count (1), */
433 0x81, 0x02, /* Input (Variable), */
434 0x95, 0x03, /* Report Count (3), */
435 0x81, 0x03, /* Input (Constant, Variable), */
436 0x75, 0x10, /* Report Size (16), */
437 0x95, 0x01, /* Report Count (1), */
438 0x14, /* Logical Minimum (0), */
439 0xA4, /* Push, */
440 0x05, 0x01, /* Usage Page (Desktop), */
441 0x65, 0x13, /* Unit (Inch), */
442 0x55, 0xFD, /* Unit Exponent (-3), */
443 0x34, /* Physical Minimum (0), */
444 0x09, 0x30, /* Usage (X), */
445 0x46, 0x28, 0x23, /* Physical Maximum (9000), */
446 0x26, 0x50, 0x46, /* Logical Maximum (18000), */
447 0x81, 0x02, /* Input (Variable), */
448 0x09, 0x31, /* Usage (Y), */
449 0x46, 0x7C, 0x15, /* Physical Maximum (5500), */
450 0x26, 0xF8, 0x2A, /* Logical Maximum (11000), */
451 0x81, 0x02, /* Input (Variable), */
452 0xB4, /* Pop, */
453 0x09, 0x30, /* Usage (Tip Pressure), */
454 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
455 0x81, 0x02, /* Input (Variable), */
456 0xC0, /* End Collection, */
457 0xC0, /* End Collection, */
458 0x05, 0x01, /* Usage Page (Desktop), */
459 0x09, 0x02, /* Usage (Mouse), */
460 0xA1, 0x01, /* Collection (Application), */
461 0x85, 0x01, /* Report ID (1), */
462 0x09, 0x01, /* Usage (Pointer), */
463 0xA0, /* Collection (Physical), */
4b5b4575
NK
464 0x75, 0x08, /* Report Size (8), */
465 0x95, 0x03, /* Report Count (3), */
72a46344 466 0x81, 0x03, /* Input (Constant, Variable), */
4b5b4575 467 0x95, 0x02, /* Report Count (2), */
72a46344
NK
468 0x15, 0xFF, /* Logical Minimum (-1), */
469 0x25, 0x01, /* Logical Maximum (1), */
4b5b4575
NK
470 0x09, 0x38, /* Usage (Wheel), */
471 0x0B, 0x38, 0x02, /* Usage (Consumer AC Pan), */
472 0x0C, 0x00,
72a46344 473 0x81, 0x06, /* Input (Variable, Relative), */
4b5b4575 474 0x95, 0x02, /* Report Count (2), */
72a46344
NK
475 0x81, 0x03, /* Input (Constant, Variable), */
476 0xC0, /* End Collection, */
477 0xC0, /* End Collection, */
478 0x05, 0x0C, /* Usage Page (Consumer), */
479 0x09, 0x01, /* Usage (Consumer Control), */
480 0xA1, 0x01, /* Collection (Application), */
481 0x85, 0x0D, /* Report ID (13), */
482 0x95, 0x01, /* Report Count (1), */
483 0x75, 0x10, /* Report Size (16), */
484 0x81, 0x03, /* Input (Constant, Variable), */
485 0x0A, 0x2F, 0x02, /* Usage (AC Zoom), */
486 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
487 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
488 0x09, 0xB6, /* Usage (Scan Previous Track), */
489 0x09, 0xB5, /* Usage (Scan Next Track), */
490 0x15, 0x2C, /* Logical Minimum (44), */
491 0x25, 0x30, /* Logical Maximum (48), */
492 0x75, 0x08, /* Report Size (8), */
493 0x80, /* Input, */
494 0x75, 0x20, /* Report Size (32), */
495 0x81, 0x03, /* Input (Constant, Variable), */
496 0xC0, /* End Collection, */
497 0x09, 0x01, /* Usage (Consumer Control), */
498 0xA1, 0x01, /* Collection (Application), */
499 0x85, 0x0C, /* Report ID (12), */
500 0x75, 0x01, /* Report Size (1), */
501 0x09, 0xE9, /* Usage (Volume Inc), */
502 0x09, 0xEA, /* Usage (Volume Dec), */
503 0x09, 0xE2, /* Usage (Mute), */
504 0x14, /* Logical Minimum (0), */
505 0x25, 0x01, /* Logical Maximum (1), */
506 0x95, 0x03, /* Report Count (3), */
507 0x81, 0x06, /* Input (Variable, Relative), */
508 0x95, 0x35, /* Report Count (53), */
509 0x81, 0x03, /* Input (Constant, Variable), */
510 0xC0 /* End Collection */
511};
512
8f1acc32
NK
513/*
514 * Original Media Tablet 14.1 inch report descriptor.
515 *
516 * There are at least two versions of this model in the wild. They are
517 * represented by Genius G-Pen M712 (older version) and Genius G-Pen M712X
518 * (newer version). The hardware difference between these versions is the same
519 * as between older and newer versions of Media Tablet 10.6 inch. The report
520 * descriptors are identical for both versions.
521 *
522 * The function, behavior and report descriptor of this tablet is similar to
523 * that of Media Tablet 10.6 inch. However, there is one more field (with
524 * Consumer AC Pan usage) in the mouse description. Then the tablet X and Y
525 * logical extents both get scaled to 0..16383 range (a hardware limit?),
526 * which kind of defeats the advertised 4000 LPI resolution, considering the
527 * physical extents of 12x7.25 inches. Plus, reports 5, 10 and 255 are used
528 * sometimes (while moving the pen) with unknown purpose. Also, the key codes
529 * generated for zoom in/out are different.
530 *
531 * Usage Page (Desktop),
532 * Usage (Mouse),
533 * Collection (Application),
534 * Report ID (1),
535 * Usage (Pointer),
536 * Collection (Physical),
537 * Usage Page (Button),
538 * Usage Minimum (01h),
539 * Usage Maximum (05h),
540 * Logical Minimum (0),
541 * Logical Maximum (1),
542 * Report Size (1),
543 * Report Count (5),
544 * Input (Variable),
545 * Report Size (3),
546 * Report Count (1),
547 * Input (Constant, Variable),
548 * Usage Page (Desktop),
549 * Usage (X),
550 * Usage (Y),
551 * Usage (Wheel),
552 * Logical Minimum (-127),
553 * Logical Maximum (127),
554 * Report Size (8),
555 * Report Count (3),
556 * Input (Variable, Relative),
557 * Usage Page (Consumer),
558 * Logical Minimum (-127),
559 * Logical Maximum (127),
560 * Report Size (8),
561 * Report Count (1),
562 * Usage (AC Pan),
563 * Input (Variable, Relative),
564 * End Collection,
565 * End Collection,
566 * Usage Page (Digitizer),
567 * Usage (Pen),
568 * Collection (Application),
569 * Report ID (2),
570 * Usage (Stylus),
571 * Collection (Physical),
572 * Usage (00h),
573 * Logical Minimum (0),
574 * Logical Maximum (255),
575 * Report Size (8),
576 * Report Count (7),
577 * Input (Variable),
578 * Usage (Azimuth),
579 * Usage (Altitude),
580 * Logical Minimum (0),
581 * Logical Maximum (255),
582 * Report Size (8),
583 * Report Count (2),
584 * Feature (Variable),
585 * End Collection,
586 * Report ID (5),
587 * Usage Page (Digitizer),
588 * Usage (Stylus),
589 * Collection (Physical),
590 * Usage (00h),
591 * Logical Minimum (0),
592 * Logical Maximum (255),
593 * Report Size (8),
594 * Report Count (7),
595 * Input (Variable),
596 * End Collection,
597 * Report ID (10),
598 * Usage Page (Digitizer),
599 * Usage (Stylus),
600 * Collection (Physical),
601 * Usage (00h),
602 * Logical Minimum (0),
603 * Logical Maximum (255),
604 * Report Size (8),
605 * Report Count (7),
606 * Input (Variable),
607 * End Collection,
608 * Report ID (16),
609 * Usage (Stylus),
610 * Collection (Physical),
611 * Usage (Tip Switch),
612 * Usage (Barrel Switch),
613 * Usage (Invert),
614 * Usage (Eraser),
615 * Usage (In Range),
616 * Logical Minimum (0),
617 * Logical Maximum (1),
618 * Report Size (1),
619 * Report Count (5),
620 * Input (Variable),
621 * Report Count (3),
622 * Input (Constant, Variable),
623 * Usage Page (Desktop),
624 * Usage (X),
625 * Report Size (16),
626 * Report Count (1),
627 * Push,
628 * Unit Exponent (13),
629 * Unit (Inch^3),
630 * Logical Minimum (0),
631 * Logical Maximum (16383),
632 * Physical Minimum (0),
633 * Physical Maximum (16383),
634 * Input (Variable),
635 * Usage (Y),
636 * Input (Variable),
637 * Usage Page (Digitizer),
638 * Usage (Tip Pressure),
639 * Logical Minimum (0),
640 * Logical Maximum (1023),
641 * Physical Minimum (0),
642 * Physical Maximum (1023),
643 * Input (Variable),
644 * End Collection,
645 * End Collection,
646 * Usage Page (Desktop),
647 * Usage (Keyboard),
648 * Collection (Application),
649 * Report ID (13),
650 * Usage Page (Keyboard),
651 * Usage Minimum (KB Leftcontrol),
652 * Usage Maximum (KB Right GUI),
653 * Logical Minimum (0),
654 * Logical Maximum (1),
655 * Report Size (1),
656 * Report Count (8),
657 * Input (Variable),
658 * Report Size (8),
659 * Report Count (1),
660 * Input (Constant),
661 * Usage Page (Keyboard),
662 * Usage Minimum (None),
663 * Usage Maximum (KB Application),
664 * Logical Minimum (0),
665 * Logical Maximum (101),
666 * Report Size (8),
667 * Report Count (5),
668 * Input,
669 * End Collection,
670 * Usage Page (Consumer),
671 * Usage (Consumer Control),
672 * Collection (Application),
673 * Report ID (12),
674 * Usage (Volume Inc),
675 * Usage (Volume Dec),
676 * Usage (Mute),
677 * Logical Minimum (0),
678 * Logical Maximum (1),
679 * Report Size (1),
680 * Report Count (3),
681 * Input (Variable, Relative),
682 * Report Size (5),
683 * Report Count (1),
684 * Input (Constant, Variable, Relative),
685 * End Collection
686 */
687
688/* Size of the original report descriptor of Media Tablet 14.1 inch */
689#define MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE 309
690
691/*
692 * Fixed Media Tablet 14.1 inch descriptor.
693 * It is fixed similarly to the Media Tablet 10.6 inch descriptor.
694 */
695static __u8 media_tablet_14_1_inch_rdesc_fixed[] = {
696 0x05, 0x0D, /* Usage Page (Digitizer), */
697 0x09, 0x02, /* Usage (Pen), */
698 0xA1, 0x01, /* Collection (Application), */
699 0x85, 0x10, /* Report ID (16), */
700 0x09, 0x20, /* Usage (Stylus), */
701 0xA0, /* Collection (Physical), */
702 0x09, 0x42, /* Usage (Tip Switch), */
703 0x09, 0x44, /* Usage (Barrel Switch), */
704 0x09, 0x46, /* Usage (Tablet Pick), */
705 0x15, 0x01, /* Logical Minimum (1), */
706 0x25, 0x03, /* Logical Maximum (3), */
707 0x75, 0x04, /* Report Size (4), */
708 0x95, 0x01, /* Report Count (1), */
709 0x80, /* Input, */
710 0x75, 0x01, /* Report Size (1), */
711 0x09, 0x32, /* Usage (In Range), */
712 0x14, /* Logical Minimum (0), */
713 0x25, 0x01, /* Logical Maximum (1), */
714 0x95, 0x01, /* Report Count (1), */
715 0x81, 0x02, /* Input (Variable), */
716 0x95, 0x03, /* Report Count (3), */
717 0x81, 0x03, /* Input (Constant, Variable), */
718 0x75, 0x10, /* Report Size (16), */
719 0x95, 0x01, /* Report Count (1), */
720 0x14, /* Logical Minimum (0), */
721 0xA4, /* Push, */
722 0x05, 0x01, /* Usage Page (Desktop), */
723 0x65, 0x13, /* Unit (Inch), */
724 0x55, 0xFD, /* Unit Exponent (-3), */
725 0x34, /* Physical Minimum (0), */
726 0x09, 0x30, /* Usage (X), */
727 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */
728 0x26, 0xFF, 0x3F, /* Logical Maximum (16383), */
729 0x81, 0x02, /* Input (Variable), */
730 0x09, 0x31, /* Usage (Y), */
731 0x46, 0x52, 0x1C, /* Physical Maximum (7250), */
732 0x26, 0xFF, 0x3F, /* Logical Maximum (16383), */
733 0x81, 0x02, /* Input (Variable), */
734 0xB4, /* Pop, */
735 0x09, 0x30, /* Usage (Tip Pressure), */
736 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
737 0x81, 0x02, /* Input (Variable), */
738 0xC0, /* End Collection, */
739 0xC0, /* End Collection, */
740 0x05, 0x01, /* Usage Page (Desktop), */
741 0x09, 0x02, /* Usage (Mouse), */
742 0xA1, 0x01, /* Collection (Application), */
743 0x85, 0x01, /* Report ID (1), */
744 0x09, 0x01, /* Usage (Pointer), */
745 0xA0, /* Collection (Physical), */
746 0x75, 0x08, /* Report Size (8), */
747 0x95, 0x03, /* Report Count (3), */
748 0x81, 0x03, /* Input (Constant, Variable), */
749 0x95, 0x02, /* Report Count (2), */
750 0x15, 0xFF, /* Logical Minimum (-1), */
751 0x25, 0x01, /* Logical Maximum (1), */
752 0x09, 0x38, /* Usage (Wheel), */
753 0x0B, 0x38, 0x02, /* Usage (Consumer AC Pan), */
754 0x0C, 0x00,
755 0x81, 0x06, /* Input (Variable, Relative), */
756 0xC0, /* End Collection, */
757 0xC0, /* End Collection, */
758 0x05, 0x0C, /* Usage Page (Consumer), */
759 0x09, 0x01, /* Usage (Consumer Control), */
760 0xA1, 0x01, /* Collection (Application), */
761 0x85, 0x0D, /* Report ID (13), */
762 0x95, 0x01, /* Report Count (1), */
763 0x75, 0x10, /* Report Size (16), */
764 0x81, 0x03, /* Input (Constant, Variable), */
765 0x0A, 0x2F, 0x02, /* Usage (AC Zoom), */
766 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
767 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
768 0x09, 0xB6, /* Usage (Scan Previous Track), */
769 0x09, 0xB5, /* Usage (Scan Next Track), */
770 0x08, /* Usage (00h), */
771 0x08, /* Usage (00h), */
772 0x08, /* Usage (00h), */
773 0x08, /* Usage (00h), */
774 0x08, /* Usage (00h), */
775 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
776 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
777 0x15, 0x0C, /* Logical Minimum (12), */
778 0x25, 0x17, /* Logical Maximum (23), */
779 0x75, 0x05, /* Report Size (5), */
780 0x80, /* Input, */
781 0x75, 0x03, /* Report Size (3), */
782 0x81, 0x03, /* Input (Constant, Variable), */
783 0x75, 0x20, /* Report Size (32), */
784 0x81, 0x03, /* Input (Constant, Variable), */
785 0xC0, /* End Collection, */
786 0x09, 0x01, /* Usage (Consumer Control), */
787 0xA1, 0x01, /* Collection (Application), */
788 0x85, 0x0C, /* Report ID (12), */
789 0x75, 0x01, /* Report Size (1), */
790 0x09, 0xE9, /* Usage (Volume Inc), */
791 0x09, 0xEA, /* Usage (Volume Dec), */
792 0x09, 0xE2, /* Usage (Mute), */
793 0x14, /* Logical Minimum (0), */
794 0x25, 0x01, /* Logical Maximum (1), */
795 0x95, 0x03, /* Report Count (3), */
796 0x81, 0x06, /* Input (Variable, Relative), */
797 0x75, 0x05, /* Report Size (5), */
798 0x81, 0x03, /* Input (Constant, Variable), */
799 0xC0 /* End Collection */
800};
801
72a46344
NK
802static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
803 unsigned int *rsize)
804{
805 switch (hdev->product) {
806 case USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH:
807 if (*rsize == SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE) {
808 rdesc = slim_tablet_5_8_inch_rdesc_fixed;
809 *rsize = sizeof(slim_tablet_5_8_inch_rdesc_fixed);
810 }
811 break;
812 case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH:
813 if (*rsize == MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE) {
814 rdesc = media_tablet_10_6_inch_rdesc_fixed;
815 *rsize = sizeof(media_tablet_10_6_inch_rdesc_fixed);
816 }
817 break;
8f1acc32
NK
818 case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH:
819 if (*rsize == MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE) {
820 rdesc = media_tablet_14_1_inch_rdesc_fixed;
821 *rsize = sizeof(media_tablet_14_1_inch_rdesc_fixed);
822 }
823 break;
72a46344
NK
824 }
825 return rdesc;
826}
827
828static const struct hid_device_id waltop_devices[] = {
829 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
830 USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
831 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
832 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
8f1acc32
NK
833 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
834 USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
72a46344
NK
835 { }
836};
837MODULE_DEVICE_TABLE(hid, waltop_devices);
838
839static struct hid_driver waltop_driver = {
840 .name = "waltop",
841 .id_table = waltop_devices,
842 .report_fixup = waltop_report_fixup,
843};
844
845static int __init waltop_init(void)
846{
847 return hid_register_driver(&waltop_driver);
848}
849
850static void __exit waltop_exit(void)
851{
852 hid_unregister_driver(&waltop_driver);
853}
854
855module_init(waltop_init);
856module_exit(waltop_exit);
857MODULE_LICENSE("GPL");