162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  HID driver for Waltop devices not fully compliant with HID standard
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci *  Copyright (c) 2010 Nikolai Kondrashov
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci/*
962306a36Sopenharmony_ci */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <linux/device.h>
1262306a36Sopenharmony_ci#include <linux/hid.h>
1362306a36Sopenharmony_ci#include <linux/module.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#include "hid-ids.h"
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/*
1862306a36Sopenharmony_ci * There exists an official driver on the manufacturer's website, which
1962306a36Sopenharmony_ci * wasn't submitted to the kernel, for some reason. The official driver
2062306a36Sopenharmony_ci * doesn't seem to support extra features of some tablets, like wheels.
2162306a36Sopenharmony_ci *
2262306a36Sopenharmony_ci * It shows that the feature report ID 2 could be used to control any waltop
2362306a36Sopenharmony_ci * tablet input mode, switching it between "default", "tablet" and "ink".
2462306a36Sopenharmony_ci *
2562306a36Sopenharmony_ci * This driver only uses "default" mode for all the supported tablets. This
2662306a36Sopenharmony_ci * mode tries to be HID-compatible (not very successfully), but cripples the
2762306a36Sopenharmony_ci * resolution of some tablets.
2862306a36Sopenharmony_ci *
2962306a36Sopenharmony_ci * The "tablet" mode uses some proprietary, yet decipherable protocol, which
3062306a36Sopenharmony_ci * represents the correct resolution, but is possibly HID-incompatible (i.e.
3162306a36Sopenharmony_ci * indescribable by a report descriptor).
3262306a36Sopenharmony_ci *
3362306a36Sopenharmony_ci * The purpose of the "ink" mode is unknown.
3462306a36Sopenharmony_ci *
3562306a36Sopenharmony_ci * The feature reports needed for switching to each mode are these:
3662306a36Sopenharmony_ci *
3762306a36Sopenharmony_ci * 02 16 00     default
3862306a36Sopenharmony_ci * 02 16 01     tablet
3962306a36Sopenharmony_ci * 02 16 02     ink
4062306a36Sopenharmony_ci */
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci/* Size of the original report descriptor of Slim Tablet 5.8 inch */
4362306a36Sopenharmony_ci#define SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE	222
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/* Fixed Slim Tablet 5.8 inch descriptor */
4662306a36Sopenharmony_cistatic __u8 slim_tablet_5_8_inch_rdesc_fixed[] = {
4762306a36Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
4862306a36Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
4962306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
5062306a36Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
5162306a36Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
5262306a36Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
5362306a36Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
5462306a36Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
5562306a36Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
5662306a36Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
5762306a36Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
5862306a36Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
5962306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
6062306a36Sopenharmony_ci	0x80,               /*          Input,                      */
6162306a36Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
6262306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
6362306a36Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
6462306a36Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
6562306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
6662306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
6762306a36Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
6862306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
6962306a36Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
7062306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
7162306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
7262306a36Sopenharmony_ci	0xA4,               /*          Push,                       */
7362306a36Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
7462306a36Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
7562306a36Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
7662306a36Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
7762306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
7862306a36Sopenharmony_ci	0x46, 0x88, 0x13,   /*          Physical Maximum (5000),    */
7962306a36Sopenharmony_ci	0x26, 0x10, 0x27,   /*          Logical Maximum (10000),    */
8062306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
8162306a36Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
8262306a36Sopenharmony_ci	0x46, 0xB8, 0x0B,   /*          Physical Maximum (3000),    */
8362306a36Sopenharmony_ci	0x26, 0x70, 0x17,   /*          Logical Maximum (6000),     */
8462306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
8562306a36Sopenharmony_ci	0xB4,               /*          Pop,                        */
8662306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
8762306a36Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
8862306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
8962306a36Sopenharmony_ci	0xC0,               /*      End Collection,                 */
9062306a36Sopenharmony_ci	0xC0                /*  End Collection                      */
9162306a36Sopenharmony_ci};
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci/* Size of the original report descriptor of Slim Tablet 12.1 inch */
9462306a36Sopenharmony_ci#define SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE	269
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci/* Fixed Slim Tablet 12.1 inch descriptor */
9762306a36Sopenharmony_cistatic __u8 slim_tablet_12_1_inch_rdesc_fixed[] = {
9862306a36Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
9962306a36Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
10062306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
10162306a36Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
10262306a36Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
10362306a36Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
10462306a36Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
10562306a36Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
10662306a36Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
10762306a36Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
10862306a36Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
10962306a36Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
11062306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
11162306a36Sopenharmony_ci	0x80,               /*          Input,                      */
11262306a36Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
11362306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
11462306a36Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
11562306a36Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
11662306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
11762306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
11862306a36Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
11962306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
12062306a36Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
12162306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
12262306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
12362306a36Sopenharmony_ci	0xA4,               /*          Push,                       */
12462306a36Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
12562306a36Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
12662306a36Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
12762306a36Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
12862306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
12962306a36Sopenharmony_ci	0x46, 0x10, 0x27,   /*          Physical Maximum (10000),   */
13062306a36Sopenharmony_ci	0x26, 0x20, 0x4E,   /*          Logical Maximum (20000),    */
13162306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
13262306a36Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
13362306a36Sopenharmony_ci	0x46, 0x6A, 0x18,   /*          Physical Maximum (6250),    */
13462306a36Sopenharmony_ci	0x26, 0xD4, 0x30,   /*          Logical Maximum (12500),    */
13562306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
13662306a36Sopenharmony_ci	0xB4,               /*          Pop,                        */
13762306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
13862306a36Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
13962306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
14062306a36Sopenharmony_ci	0xC0,               /*      End Collection,                 */
14162306a36Sopenharmony_ci	0xC0                /*  End Collection                      */
14262306a36Sopenharmony_ci};
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci/* Size of the original report descriptor of Q Pad */
14562306a36Sopenharmony_ci#define Q_PAD_RDESC_ORIG_SIZE	241
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci/* Fixed Q Pad descriptor */
14862306a36Sopenharmony_cistatic __u8 q_pad_rdesc_fixed[] = {
14962306a36Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
15062306a36Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
15162306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
15262306a36Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
15362306a36Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
15462306a36Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
15562306a36Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
15662306a36Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
15762306a36Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
15862306a36Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
15962306a36Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
16062306a36Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
16162306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
16262306a36Sopenharmony_ci	0x80,               /*          Input,                      */
16362306a36Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
16462306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
16562306a36Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
16662306a36Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
16762306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
16862306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
16962306a36Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
17062306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
17162306a36Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
17262306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
17362306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
17462306a36Sopenharmony_ci	0xA4,               /*          Push,                       */
17562306a36Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
17662306a36Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
17762306a36Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
17862306a36Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
17962306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
18062306a36Sopenharmony_ci	0x46, 0x70, 0x17,   /*          Physical Maximum (6000),    */
18162306a36Sopenharmony_ci	0x26, 0x00, 0x30,   /*          Logical Maximum (12288),    */
18262306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
18362306a36Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
18462306a36Sopenharmony_ci	0x46, 0x94, 0x11,   /*          Physical Maximum (4500),    */
18562306a36Sopenharmony_ci	0x26, 0x00, 0x24,   /*          Logical Maximum (9216),     */
18662306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
18762306a36Sopenharmony_ci	0xB4,               /*          Pop,                        */
18862306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
18962306a36Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
19062306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
19162306a36Sopenharmony_ci	0xC0,               /*      End Collection,                 */
19262306a36Sopenharmony_ci	0xC0                /*  End Collection                      */
19362306a36Sopenharmony_ci};
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci/* Size of the original report descriptor of tablet with PID 0038 */
19662306a36Sopenharmony_ci#define PID_0038_RDESC_ORIG_SIZE	241
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci/*
19962306a36Sopenharmony_ci * Fixed report descriptor for tablet with PID 0038.
20062306a36Sopenharmony_ci */
20162306a36Sopenharmony_cistatic __u8 pid_0038_rdesc_fixed[] = {
20262306a36Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
20362306a36Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
20462306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
20562306a36Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
20662306a36Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
20762306a36Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
20862306a36Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
20962306a36Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
21062306a36Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
21162306a36Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
21262306a36Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
21362306a36Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
21462306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
21562306a36Sopenharmony_ci	0x80,               /*          Input,                      */
21662306a36Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
21762306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
21862306a36Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
21962306a36Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
22062306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
22162306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
22262306a36Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
22362306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
22462306a36Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
22562306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
22662306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
22762306a36Sopenharmony_ci	0xA4,               /*          Push,                       */
22862306a36Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
22962306a36Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
23062306a36Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
23162306a36Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
23262306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
23362306a36Sopenharmony_ci	0x46, 0x2E, 0x22,   /*          Physical Maximum (8750),    */
23462306a36Sopenharmony_ci	0x26, 0x00, 0x46,   /*          Logical Maximum (17920),    */
23562306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
23662306a36Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
23762306a36Sopenharmony_ci	0x46, 0x82, 0x14,   /*          Physical Maximum (5250),    */
23862306a36Sopenharmony_ci	0x26, 0x00, 0x2A,   /*          Logical Maximum (10752),    */
23962306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
24062306a36Sopenharmony_ci	0xB4,               /*          Pop,                        */
24162306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
24262306a36Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
24362306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
24462306a36Sopenharmony_ci	0xC0,               /*      End Collection,                 */
24562306a36Sopenharmony_ci	0xC0                /*  End Collection                      */
24662306a36Sopenharmony_ci};
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ci/* Size of the original report descriptor of Media Tablet 10.6 inch */
24962306a36Sopenharmony_ci#define MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE	300
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_ci/* Fixed Media Tablet 10.6 inch descriptor */
25262306a36Sopenharmony_cistatic __u8 media_tablet_10_6_inch_rdesc_fixed[] = {
25362306a36Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
25462306a36Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
25562306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
25662306a36Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
25762306a36Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
25862306a36Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
25962306a36Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
26062306a36Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
26162306a36Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
26262306a36Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
26362306a36Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
26462306a36Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
26562306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
26662306a36Sopenharmony_ci	0x80,               /*          Input,                      */
26762306a36Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
26862306a36Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
26962306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
27062306a36Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
27162306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
27262306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
27362306a36Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
27462306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
27562306a36Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
27662306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
27762306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
27862306a36Sopenharmony_ci	0xA4,               /*          Push,                       */
27962306a36Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
28062306a36Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
28162306a36Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
28262306a36Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
28362306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
28462306a36Sopenharmony_ci	0x46, 0x28, 0x23,   /*          Physical Maximum (9000),    */
28562306a36Sopenharmony_ci	0x26, 0x50, 0x46,   /*          Logical Maximum (18000),    */
28662306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
28762306a36Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
28862306a36Sopenharmony_ci	0x46, 0x7C, 0x15,   /*          Physical Maximum (5500),    */
28962306a36Sopenharmony_ci	0x26, 0xF8, 0x2A,   /*          Logical Maximum (11000),    */
29062306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
29162306a36Sopenharmony_ci	0xB4,               /*          Pop,                        */
29262306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
29362306a36Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
29462306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
29562306a36Sopenharmony_ci	0xC0,               /*      End Collection,                 */
29662306a36Sopenharmony_ci	0xC0,               /*  End Collection,                     */
29762306a36Sopenharmony_ci	0x05, 0x01,         /*  Usage Page (Desktop),               */
29862306a36Sopenharmony_ci	0x09, 0x02,         /*  Usage (Mouse),                      */
29962306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
30062306a36Sopenharmony_ci	0x85, 0x01,         /*      Report ID (1),                  */
30162306a36Sopenharmony_ci	0x09, 0x01,         /*      Usage (Pointer),                */
30262306a36Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
30362306a36Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
30462306a36Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
30562306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
30662306a36Sopenharmony_ci	0x95, 0x02,         /*          Report Count (2),           */
30762306a36Sopenharmony_ci	0x15, 0xFF,         /*          Logical Minimum (-1),       */
30862306a36Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
30962306a36Sopenharmony_ci	0x09, 0x38,         /*          Usage (Wheel),              */
31062306a36Sopenharmony_ci	0x0B, 0x38, 0x02,   /*          Usage (Consumer AC Pan),    */
31162306a36Sopenharmony_ci		0x0C, 0x00,
31262306a36Sopenharmony_ci	0x81, 0x06,         /*          Input (Variable, Relative), */
31362306a36Sopenharmony_ci	0x95, 0x02,         /*          Report Count (2),           */
31462306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
31562306a36Sopenharmony_ci	0xC0,               /*      End Collection,                 */
31662306a36Sopenharmony_ci	0xC0,               /*  End Collection,                     */
31762306a36Sopenharmony_ci	0x05, 0x0C,         /*  Usage Page (Consumer),              */
31862306a36Sopenharmony_ci	0x09, 0x01,         /*  Usage (Consumer Control),           */
31962306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
32062306a36Sopenharmony_ci	0x85, 0x0D,         /*      Report ID (13),                 */
32162306a36Sopenharmony_ci	0x95, 0x01,         /*      Report Count (1),               */
32262306a36Sopenharmony_ci	0x75, 0x10,         /*      Report Size (16),               */
32362306a36Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
32462306a36Sopenharmony_ci	0x0A, 0x2F, 0x02,   /*      Usage (AC Zoom),                */
32562306a36Sopenharmony_ci	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
32662306a36Sopenharmony_ci	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
32762306a36Sopenharmony_ci	0x09, 0xB6,         /*      Usage (Scan Previous Track),    */
32862306a36Sopenharmony_ci	0x09, 0xB5,         /*      Usage (Scan Next Track),        */
32962306a36Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
33062306a36Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
33162306a36Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
33262306a36Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
33362306a36Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
33462306a36Sopenharmony_ci	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
33562306a36Sopenharmony_ci	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
33662306a36Sopenharmony_ci	0x15, 0x0C,         /*      Logical Minimum (12),           */
33762306a36Sopenharmony_ci	0x25, 0x17,         /*      Logical Maximum (23),           */
33862306a36Sopenharmony_ci	0x75, 0x05,         /*      Report Size (5),                */
33962306a36Sopenharmony_ci	0x80,               /*      Input,                          */
34062306a36Sopenharmony_ci	0x75, 0x03,         /*      Report Size (3),                */
34162306a36Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
34262306a36Sopenharmony_ci	0x75, 0x20,         /*      Report Size (32),               */
34362306a36Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
34462306a36Sopenharmony_ci	0xC0,               /*  End Collection,                     */
34562306a36Sopenharmony_ci	0x09, 0x01,         /*  Usage (Consumer Control),           */
34662306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
34762306a36Sopenharmony_ci	0x85, 0x0C,         /*      Report ID (12),                 */
34862306a36Sopenharmony_ci	0x75, 0x01,         /*      Report Size (1),                */
34962306a36Sopenharmony_ci	0x09, 0xE9,         /*      Usage (Volume Inc),             */
35062306a36Sopenharmony_ci	0x09, 0xEA,         /*      Usage (Volume Dec),             */
35162306a36Sopenharmony_ci	0x09, 0xE2,         /*      Usage (Mute),                   */
35262306a36Sopenharmony_ci	0x14,               /*      Logical Minimum (0),            */
35362306a36Sopenharmony_ci	0x25, 0x01,         /*      Logical Maximum (1),            */
35462306a36Sopenharmony_ci	0x95, 0x03,         /*      Report Count (3),               */
35562306a36Sopenharmony_ci	0x81, 0x06,         /*      Input (Variable, Relative),     */
35662306a36Sopenharmony_ci	0x95, 0x35,         /*      Report Count (53),              */
35762306a36Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
35862306a36Sopenharmony_ci	0xC0                /*  End Collection                      */
35962306a36Sopenharmony_ci};
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_ci/* Size of the original report descriptor of Media Tablet 14.1 inch */
36262306a36Sopenharmony_ci#define MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE	309
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ci/* Fixed Media Tablet 14.1 inch descriptor */
36562306a36Sopenharmony_cistatic __u8 media_tablet_14_1_inch_rdesc_fixed[] = {
36662306a36Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
36762306a36Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
36862306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
36962306a36Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
37062306a36Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
37162306a36Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
37262306a36Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
37362306a36Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
37462306a36Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
37562306a36Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
37662306a36Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
37762306a36Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
37862306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
37962306a36Sopenharmony_ci	0x80,               /*          Input,                      */
38062306a36Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
38162306a36Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
38262306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
38362306a36Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
38462306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
38562306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
38662306a36Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
38762306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
38862306a36Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
38962306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
39062306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
39162306a36Sopenharmony_ci	0xA4,               /*          Push,                       */
39262306a36Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
39362306a36Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
39462306a36Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
39562306a36Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
39662306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
39762306a36Sopenharmony_ci	0x46, 0xE0, 0x2E,   /*          Physical Maximum (12000),   */
39862306a36Sopenharmony_ci	0x26, 0xFF, 0x3F,   /*          Logical Maximum (16383),    */
39962306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
40062306a36Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
40162306a36Sopenharmony_ci	0x46, 0x52, 0x1C,   /*          Physical Maximum (7250),    */
40262306a36Sopenharmony_ci	0x26, 0xFF, 0x3F,   /*          Logical Maximum (16383),    */
40362306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
40462306a36Sopenharmony_ci	0xB4,               /*          Pop,                        */
40562306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
40662306a36Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
40762306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
40862306a36Sopenharmony_ci	0xC0,               /*      End Collection,                 */
40962306a36Sopenharmony_ci	0xC0,               /*  End Collection,                     */
41062306a36Sopenharmony_ci	0x05, 0x01,         /*  Usage Page (Desktop),               */
41162306a36Sopenharmony_ci	0x09, 0x02,         /*  Usage (Mouse),                      */
41262306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
41362306a36Sopenharmony_ci	0x85, 0x01,         /*      Report ID (1),                  */
41462306a36Sopenharmony_ci	0x09, 0x01,         /*      Usage (Pointer),                */
41562306a36Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
41662306a36Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
41762306a36Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
41862306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
41962306a36Sopenharmony_ci	0x95, 0x02,         /*          Report Count (2),           */
42062306a36Sopenharmony_ci	0x15, 0xFF,         /*          Logical Minimum (-1),       */
42162306a36Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
42262306a36Sopenharmony_ci	0x09, 0x38,         /*          Usage (Wheel),              */
42362306a36Sopenharmony_ci	0x0B, 0x38, 0x02,   /*          Usage (Consumer AC Pan),    */
42462306a36Sopenharmony_ci		0x0C, 0x00,
42562306a36Sopenharmony_ci	0x81, 0x06,         /*          Input (Variable, Relative), */
42662306a36Sopenharmony_ci	0xC0,               /*      End Collection,                 */
42762306a36Sopenharmony_ci	0xC0,               /*  End Collection,                     */
42862306a36Sopenharmony_ci	0x05, 0x0C,         /*  Usage Page (Consumer),              */
42962306a36Sopenharmony_ci	0x09, 0x01,         /*  Usage (Consumer Control),           */
43062306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
43162306a36Sopenharmony_ci	0x85, 0x0D,         /*      Report ID (13),                 */
43262306a36Sopenharmony_ci	0x95, 0x01,         /*      Report Count (1),               */
43362306a36Sopenharmony_ci	0x75, 0x10,         /*      Report Size (16),               */
43462306a36Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
43562306a36Sopenharmony_ci	0x0A, 0x2F, 0x02,   /*      Usage (AC Zoom),                */
43662306a36Sopenharmony_ci	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
43762306a36Sopenharmony_ci	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
43862306a36Sopenharmony_ci	0x09, 0xB6,         /*      Usage (Scan Previous Track),    */
43962306a36Sopenharmony_ci	0x09, 0xB5,         /*      Usage (Scan Next Track),        */
44062306a36Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
44162306a36Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
44262306a36Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
44362306a36Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
44462306a36Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
44562306a36Sopenharmony_ci	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
44662306a36Sopenharmony_ci	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
44762306a36Sopenharmony_ci	0x15, 0x0C,         /*      Logical Minimum (12),           */
44862306a36Sopenharmony_ci	0x25, 0x17,         /*      Logical Maximum (23),           */
44962306a36Sopenharmony_ci	0x75, 0x05,         /*      Report Size (5),                */
45062306a36Sopenharmony_ci	0x80,               /*      Input,                          */
45162306a36Sopenharmony_ci	0x75, 0x03,         /*      Report Size (3),                */
45262306a36Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
45362306a36Sopenharmony_ci	0x75, 0x20,         /*      Report Size (32),               */
45462306a36Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
45562306a36Sopenharmony_ci	0xC0,               /*  End Collection,                     */
45662306a36Sopenharmony_ci	0x09, 0x01,         /*  Usage (Consumer Control),           */
45762306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
45862306a36Sopenharmony_ci	0x85, 0x0C,         /*      Report ID (12),                 */
45962306a36Sopenharmony_ci	0x75, 0x01,         /*      Report Size (1),                */
46062306a36Sopenharmony_ci	0x09, 0xE9,         /*      Usage (Volume Inc),             */
46162306a36Sopenharmony_ci	0x09, 0xEA,         /*      Usage (Volume Dec),             */
46262306a36Sopenharmony_ci	0x09, 0xE2,         /*      Usage (Mute),                   */
46362306a36Sopenharmony_ci	0x14,               /*      Logical Minimum (0),            */
46462306a36Sopenharmony_ci	0x25, 0x01,         /*      Logical Maximum (1),            */
46562306a36Sopenharmony_ci	0x95, 0x03,         /*      Report Count (3),               */
46662306a36Sopenharmony_ci	0x81, 0x06,         /*      Input (Variable, Relative),     */
46762306a36Sopenharmony_ci	0x75, 0x05,         /*      Report Size (5),                */
46862306a36Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
46962306a36Sopenharmony_ci	0xC0                /*  End Collection                      */
47062306a36Sopenharmony_ci};
47162306a36Sopenharmony_ci
47262306a36Sopenharmony_ci/* Size of the original report descriptor of Sirius Battery Free Tablet */
47362306a36Sopenharmony_ci#define SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE	335
47462306a36Sopenharmony_ci
47562306a36Sopenharmony_ci/* Fixed Sirius Battery Free Tablet descriptor */
47662306a36Sopenharmony_cistatic __u8 sirius_battery_free_tablet_rdesc_fixed[] = {
47762306a36Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
47862306a36Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
47962306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
48062306a36Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
48162306a36Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
48262306a36Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
48362306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
48462306a36Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
48562306a36Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
48662306a36Sopenharmony_ci	0x75, 0x02,         /*          Report Size (2),            */
48762306a36Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
48862306a36Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
48962306a36Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
49062306a36Sopenharmony_ci	0x80,               /*          Input,                      */
49162306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
49262306a36Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
49362306a36Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
49462306a36Sopenharmony_ci	0x09, 0x3C,         /*          Usage (Invert),             */
49562306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
49662306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
49762306a36Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
49862306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
49962306a36Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
50062306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
50162306a36Sopenharmony_ci	0xA4,               /*          Push,                       */
50262306a36Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
50362306a36Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
50462306a36Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
50562306a36Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
50662306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
50762306a36Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
50862306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
50962306a36Sopenharmony_ci	0x46, 0x10, 0x27,   /*          Physical Maximum (10000),   */
51062306a36Sopenharmony_ci	0x26, 0x20, 0x4E,   /*          Logical Maximum (20000),    */
51162306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
51262306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
51362306a36Sopenharmony_ci	0x46, 0x70, 0x17,   /*          Physical Maximum (6000),    */
51462306a36Sopenharmony_ci	0x26, 0xE0, 0x2E,   /*          Logical Maximum (12000),    */
51562306a36Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
51662306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
51762306a36Sopenharmony_ci	0xB4,               /*          Pop,                        */
51862306a36Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
51962306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
52062306a36Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
52162306a36Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
52262306a36Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
52362306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
52462306a36Sopenharmony_ci	0xA4,               /*          Push,                       */
52562306a36Sopenharmony_ci	0x55, 0xFE,         /*          Unit Exponent (-2),         */
52662306a36Sopenharmony_ci	0x65, 0x12,         /*          Unit (Radians),             */
52762306a36Sopenharmony_ci	0x35, 0x97,         /*          Physical Minimum (-105),    */
52862306a36Sopenharmony_ci	0x45, 0x69,         /*          Physical Maximum (105),     */
52962306a36Sopenharmony_ci	0x15, 0x97,         /*          Logical Minimum (-105),     */
53062306a36Sopenharmony_ci	0x25, 0x69,         /*          Logical Maximum (105),      */
53162306a36Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
53262306a36Sopenharmony_ci	0x95, 0x02,         /*          Report Count (2),           */
53362306a36Sopenharmony_ci	0x09, 0x3D,         /*          Usage (X Tilt),             */
53462306a36Sopenharmony_ci	0x09, 0x3E,         /*          Usage (Y Tilt),             */
53562306a36Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
53662306a36Sopenharmony_ci	0xB4,               /*          Pop,                        */
53762306a36Sopenharmony_ci	0xC0,               /*      End Collection,                 */
53862306a36Sopenharmony_ci	0xC0,               /*  End Collection,                     */
53962306a36Sopenharmony_ci	0x05, 0x01,         /*  Usage Page (Desktop),               */
54062306a36Sopenharmony_ci	0x09, 0x02,         /*  Usage (Mouse),                      */
54162306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
54262306a36Sopenharmony_ci	0x85, 0x01,         /*      Report ID (1),                  */
54362306a36Sopenharmony_ci	0x09, 0x01,         /*      Usage (Pointer),                */
54462306a36Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
54562306a36Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
54662306a36Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
54762306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
54862306a36Sopenharmony_ci	0x09, 0x38,         /*          Usage (Wheel),              */
54962306a36Sopenharmony_ci	0x15, 0xFF,         /*          Logical Minimum (-1),       */
55062306a36Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
55162306a36Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
55262306a36Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
55362306a36Sopenharmony_ci	0x81, 0x06,         /*          Input (Variable, Relative), */
55462306a36Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
55562306a36Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
55662306a36Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
55762306a36Sopenharmony_ci	0xC0,               /*      End Collection,                 */
55862306a36Sopenharmony_ci	0xC0,               /*  End Collection,                     */
55962306a36Sopenharmony_ci	0x05, 0x01,         /*  Usage Page (Desktop),               */
56062306a36Sopenharmony_ci	0x09, 0x06,         /*  Usage (Keyboard),                   */
56162306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
56262306a36Sopenharmony_ci	0x85, 0x0D,         /*      Report ID (13),                 */
56362306a36Sopenharmony_ci	0x05, 0x07,         /*      Usage Page (Keyboard),          */
56462306a36Sopenharmony_ci	0x19, 0xE0,         /*      Usage Minimum (KB Leftcontrol), */
56562306a36Sopenharmony_ci	0x29, 0xE7,         /*      Usage Maximum (KB Right GUI),   */
56662306a36Sopenharmony_ci	0x14,               /*      Logical Minimum (0),            */
56762306a36Sopenharmony_ci	0x25, 0x01,         /*      Logical Maximum (1),            */
56862306a36Sopenharmony_ci	0x75, 0x01,         /*      Report Size (1),                */
56962306a36Sopenharmony_ci	0x95, 0x08,         /*      Report Count (8),               */
57062306a36Sopenharmony_ci	0x81, 0x02,         /*      Input (Variable),               */
57162306a36Sopenharmony_ci	0x75, 0x08,         /*      Report Size (8),                */
57262306a36Sopenharmony_ci	0x95, 0x01,         /*      Report Count (1),               */
57362306a36Sopenharmony_ci	0x81, 0x01,         /*      Input (Constant),               */
57462306a36Sopenharmony_ci	0x18,               /*      Usage Minimum (None),           */
57562306a36Sopenharmony_ci	0x29, 0x65,         /*      Usage Maximum (KB Application), */
57662306a36Sopenharmony_ci	0x14,               /*      Logical Minimum (0),            */
57762306a36Sopenharmony_ci	0x25, 0x65,         /*      Logical Maximum (101),          */
57862306a36Sopenharmony_ci	0x75, 0x08,         /*      Report Size (8),                */
57962306a36Sopenharmony_ci	0x95, 0x05,         /*      Report Count (5),               */
58062306a36Sopenharmony_ci	0x80,               /*      Input,                          */
58162306a36Sopenharmony_ci	0xC0,               /*  End Collection,                     */
58262306a36Sopenharmony_ci	0x05, 0x0C,         /*  Usage Page (Consumer),              */
58362306a36Sopenharmony_ci	0x09, 0x01,         /*  Usage (Consumer Control),           */
58462306a36Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
58562306a36Sopenharmony_ci	0x85, 0x0C,         /*      Report ID (12),                 */
58662306a36Sopenharmony_ci	0x09, 0xE9,         /*      Usage (Volume Inc),             */
58762306a36Sopenharmony_ci	0x09, 0xEA,         /*      Usage (Volume Dec),             */
58862306a36Sopenharmony_ci	0x14,               /*      Logical Minimum (0),            */
58962306a36Sopenharmony_ci	0x25, 0x01,         /*      Logical Maximum (1),            */
59062306a36Sopenharmony_ci	0x75, 0x01,         /*      Report Size (1),                */
59162306a36Sopenharmony_ci	0x95, 0x02,         /*      Report Count (2),               */
59262306a36Sopenharmony_ci	0x81, 0x02,         /*      Input (Variable),               */
59362306a36Sopenharmony_ci	0x75, 0x06,         /*      Report Size (6),                */
59462306a36Sopenharmony_ci	0x95, 0x01,         /*      Report Count (1),               */
59562306a36Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
59662306a36Sopenharmony_ci	0x75, 0x10,         /*      Report Size (16),               */
59762306a36Sopenharmony_ci	0x95, 0x03,         /*      Report Count (3),               */
59862306a36Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
59962306a36Sopenharmony_ci	0xC0                /*  End Collection                      */
60062306a36Sopenharmony_ci};
60162306a36Sopenharmony_ci
60262306a36Sopenharmony_cistatic __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
60362306a36Sopenharmony_ci		unsigned int *rsize)
60462306a36Sopenharmony_ci{
60562306a36Sopenharmony_ci	switch (hdev->product) {
60662306a36Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH:
60762306a36Sopenharmony_ci		if (*rsize == SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE) {
60862306a36Sopenharmony_ci			rdesc = slim_tablet_5_8_inch_rdesc_fixed;
60962306a36Sopenharmony_ci			*rsize = sizeof(slim_tablet_5_8_inch_rdesc_fixed);
61062306a36Sopenharmony_ci		}
61162306a36Sopenharmony_ci		break;
61262306a36Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH:
61362306a36Sopenharmony_ci		if (*rsize == SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE) {
61462306a36Sopenharmony_ci			rdesc = slim_tablet_12_1_inch_rdesc_fixed;
61562306a36Sopenharmony_ci			*rsize = sizeof(slim_tablet_12_1_inch_rdesc_fixed);
61662306a36Sopenharmony_ci		}
61762306a36Sopenharmony_ci		break;
61862306a36Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_Q_PAD:
61962306a36Sopenharmony_ci		if (*rsize == Q_PAD_RDESC_ORIG_SIZE) {
62062306a36Sopenharmony_ci			rdesc = q_pad_rdesc_fixed;
62162306a36Sopenharmony_ci			*rsize = sizeof(q_pad_rdesc_fixed);
62262306a36Sopenharmony_ci		}
62362306a36Sopenharmony_ci		break;
62462306a36Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_PID_0038:
62562306a36Sopenharmony_ci		if (*rsize == PID_0038_RDESC_ORIG_SIZE) {
62662306a36Sopenharmony_ci			rdesc = pid_0038_rdesc_fixed;
62762306a36Sopenharmony_ci			*rsize = sizeof(pid_0038_rdesc_fixed);
62862306a36Sopenharmony_ci		}
62962306a36Sopenharmony_ci		break;
63062306a36Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH:
63162306a36Sopenharmony_ci		if (*rsize == MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE) {
63262306a36Sopenharmony_ci			rdesc = media_tablet_10_6_inch_rdesc_fixed;
63362306a36Sopenharmony_ci			*rsize = sizeof(media_tablet_10_6_inch_rdesc_fixed);
63462306a36Sopenharmony_ci		}
63562306a36Sopenharmony_ci		break;
63662306a36Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH:
63762306a36Sopenharmony_ci		if (*rsize == MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE) {
63862306a36Sopenharmony_ci			rdesc = media_tablet_14_1_inch_rdesc_fixed;
63962306a36Sopenharmony_ci			*rsize = sizeof(media_tablet_14_1_inch_rdesc_fixed);
64062306a36Sopenharmony_ci		}
64162306a36Sopenharmony_ci		break;
64262306a36Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET:
64362306a36Sopenharmony_ci		if (*rsize == SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE) {
64462306a36Sopenharmony_ci			rdesc = sirius_battery_free_tablet_rdesc_fixed;
64562306a36Sopenharmony_ci			*rsize = sizeof(sirius_battery_free_tablet_rdesc_fixed);
64662306a36Sopenharmony_ci		}
64762306a36Sopenharmony_ci		break;
64862306a36Sopenharmony_ci	}
64962306a36Sopenharmony_ci	return rdesc;
65062306a36Sopenharmony_ci}
65162306a36Sopenharmony_ci
65262306a36Sopenharmony_cistatic int waltop_raw_event(struct hid_device *hdev, struct hid_report *report,
65362306a36Sopenharmony_ci		     u8 *data, int size)
65462306a36Sopenharmony_ci{
65562306a36Sopenharmony_ci	/* If this is a pen input report */
65662306a36Sopenharmony_ci	if (report->type == HID_INPUT_REPORT && report->id == 16 && size >= 8) {
65762306a36Sopenharmony_ci		/*
65862306a36Sopenharmony_ci		 * Ignore reported pressure when a barrel button is pressed,
65962306a36Sopenharmony_ci		 * because it is rarely correct.
66062306a36Sopenharmony_ci		 */
66162306a36Sopenharmony_ci
66262306a36Sopenharmony_ci		/* If a barrel button is pressed */
66362306a36Sopenharmony_ci		if ((data[1] & 0xF) > 1) {
66462306a36Sopenharmony_ci			/* Report zero pressure */
66562306a36Sopenharmony_ci			data[6] = 0;
66662306a36Sopenharmony_ci			data[7] = 0;
66762306a36Sopenharmony_ci		}
66862306a36Sopenharmony_ci	}
66962306a36Sopenharmony_ci
67062306a36Sopenharmony_ci	/* If this is a pen input report of Sirius Battery Free Tablet */
67162306a36Sopenharmony_ci	if (hdev->product == USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET &&
67262306a36Sopenharmony_ci	    report->type == HID_INPUT_REPORT &&
67362306a36Sopenharmony_ci	    report->id == 16 &&
67462306a36Sopenharmony_ci	    size == 10) {
67562306a36Sopenharmony_ci		/*
67662306a36Sopenharmony_ci		 * The tablet reports tilt as roughly sin(a)*21 (18 means 60
67762306a36Sopenharmony_ci		 * degrees).
67862306a36Sopenharmony_ci		 *
67962306a36Sopenharmony_ci		 * This array stores angles as radians * 100, corresponding to
68062306a36Sopenharmony_ci		 * reported values up to 60 degrees, as expected by userspace.
68162306a36Sopenharmony_ci		 */
68262306a36Sopenharmony_ci		static const s8 tilt_to_radians[] = {
68362306a36Sopenharmony_ci			0, 5, 10, 14, 19, 24, 29, 34, 40, 45,
68462306a36Sopenharmony_ci			50, 56, 62, 68, 74, 81, 88, 96, 105
68562306a36Sopenharmony_ci		};
68662306a36Sopenharmony_ci
68762306a36Sopenharmony_ci		s8 tilt_x = (s8)data[8];
68862306a36Sopenharmony_ci		s8 tilt_y = (s8)data[9];
68962306a36Sopenharmony_ci		s8 sign_x = tilt_x >= 0 ? 1 : -1;
69062306a36Sopenharmony_ci		s8 sign_y = tilt_y >= 0 ? 1 : -1;
69162306a36Sopenharmony_ci
69262306a36Sopenharmony_ci		tilt_x *= sign_x;
69362306a36Sopenharmony_ci		tilt_y *= sign_y;
69462306a36Sopenharmony_ci
69562306a36Sopenharmony_ci		/*
69662306a36Sopenharmony_ci		 * Reverse the Y Tilt direction to match the HID standard and
69762306a36Sopenharmony_ci		 * userspace expectations. See HID Usage Tables v1.12 16.3.2
69862306a36Sopenharmony_ci		 * Tilt Orientation.
69962306a36Sopenharmony_ci		 */
70062306a36Sopenharmony_ci		sign_y *= -1;
70162306a36Sopenharmony_ci
70262306a36Sopenharmony_ci		/*
70362306a36Sopenharmony_ci		 * This effectively clamps reported tilt to 60 degrees - the
70462306a36Sopenharmony_ci		 * range expected by userspace
70562306a36Sopenharmony_ci		 */
70662306a36Sopenharmony_ci		if (tilt_x > ARRAY_SIZE(tilt_to_radians) - 1)
70762306a36Sopenharmony_ci			tilt_x = ARRAY_SIZE(tilt_to_radians) - 1;
70862306a36Sopenharmony_ci		if (tilt_y > ARRAY_SIZE(tilt_to_radians) - 1)
70962306a36Sopenharmony_ci			tilt_y = ARRAY_SIZE(tilt_to_radians) - 1;
71062306a36Sopenharmony_ci
71162306a36Sopenharmony_ci		data[8] = tilt_to_radians[tilt_x] * sign_x;
71262306a36Sopenharmony_ci		data[9] = tilt_to_radians[tilt_y] * sign_y;
71362306a36Sopenharmony_ci	}
71462306a36Sopenharmony_ci
71562306a36Sopenharmony_ci	return 0;
71662306a36Sopenharmony_ci}
71762306a36Sopenharmony_ci
71862306a36Sopenharmony_cistatic const struct hid_device_id waltop_devices[] = {
71962306a36Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
72062306a36Sopenharmony_ci				USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
72162306a36Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
72262306a36Sopenharmony_ci				USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
72362306a36Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
72462306a36Sopenharmony_ci				USB_DEVICE_ID_WALTOP_Q_PAD) },
72562306a36Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
72662306a36Sopenharmony_ci				USB_DEVICE_ID_WALTOP_PID_0038) },
72762306a36Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
72862306a36Sopenharmony_ci				USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
72962306a36Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
73062306a36Sopenharmony_ci				USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
73162306a36Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
73262306a36Sopenharmony_ci			 USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) },
73362306a36Sopenharmony_ci	{ }
73462306a36Sopenharmony_ci};
73562306a36Sopenharmony_ciMODULE_DEVICE_TABLE(hid, waltop_devices);
73662306a36Sopenharmony_ci
73762306a36Sopenharmony_cistatic struct hid_driver waltop_driver = {
73862306a36Sopenharmony_ci	.name = "waltop",
73962306a36Sopenharmony_ci	.id_table = waltop_devices,
74062306a36Sopenharmony_ci	.report_fixup = waltop_report_fixup,
74162306a36Sopenharmony_ci	.raw_event = waltop_raw_event,
74262306a36Sopenharmony_ci};
74362306a36Sopenharmony_cimodule_hid_driver(waltop_driver);
74462306a36Sopenharmony_ci
74562306a36Sopenharmony_ciMODULE_LICENSE("GPL");
746