18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  HID driver for Waltop devices not fully compliant with HID standard
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (c) 2010 Nikolai Kondrashov
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/*
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/device.h>
128c2ecf20Sopenharmony_ci#include <linux/hid.h>
138c2ecf20Sopenharmony_ci#include <linux/module.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include "hid-ids.h"
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/*
188c2ecf20Sopenharmony_ci * There exists an official driver on the manufacturer's website, which
198c2ecf20Sopenharmony_ci * wasn't submitted to the kernel, for some reason. The official driver
208c2ecf20Sopenharmony_ci * doesn't seem to support extra features of some tablets, like wheels.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci * It shows that the feature report ID 2 could be used to control any waltop
238c2ecf20Sopenharmony_ci * tablet input mode, switching it between "default", "tablet" and "ink".
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * This driver only uses "default" mode for all the supported tablets. This
268c2ecf20Sopenharmony_ci * mode tries to be HID-compatible (not very successfully), but cripples the
278c2ecf20Sopenharmony_ci * resolution of some tablets.
288c2ecf20Sopenharmony_ci *
298c2ecf20Sopenharmony_ci * The "tablet" mode uses some proprietary, yet decipherable protocol, which
308c2ecf20Sopenharmony_ci * represents the correct resolution, but is possibly HID-incompatible (i.e.
318c2ecf20Sopenharmony_ci * indescribable by a report descriptor).
328c2ecf20Sopenharmony_ci *
338c2ecf20Sopenharmony_ci * The purpose of the "ink" mode is unknown.
348c2ecf20Sopenharmony_ci *
358c2ecf20Sopenharmony_ci * The feature reports needed for switching to each mode are these:
368c2ecf20Sopenharmony_ci *
378c2ecf20Sopenharmony_ci * 02 16 00     default
388c2ecf20Sopenharmony_ci * 02 16 01     tablet
398c2ecf20Sopenharmony_ci * 02 16 02     ink
408c2ecf20Sopenharmony_ci */
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/* Size of the original report descriptor of Slim Tablet 5.8 inch */
438c2ecf20Sopenharmony_ci#define SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE	222
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/* Fixed Slim Tablet 5.8 inch descriptor */
468c2ecf20Sopenharmony_cistatic __u8 slim_tablet_5_8_inch_rdesc_fixed[] = {
478c2ecf20Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
488c2ecf20Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
498c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
508c2ecf20Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
518c2ecf20Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
528c2ecf20Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
538c2ecf20Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
548c2ecf20Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
558c2ecf20Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
568c2ecf20Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
578c2ecf20Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
588c2ecf20Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
598c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
608c2ecf20Sopenharmony_ci	0x80,               /*          Input,                      */
618c2ecf20Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
628c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
638c2ecf20Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
648c2ecf20Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
658c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
668c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
678c2ecf20Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
688c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
698c2ecf20Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
708c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
718c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
728c2ecf20Sopenharmony_ci	0xA4,               /*          Push,                       */
738c2ecf20Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
748c2ecf20Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
758c2ecf20Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
768c2ecf20Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
778c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
788c2ecf20Sopenharmony_ci	0x46, 0x88, 0x13,   /*          Physical Maximum (5000),    */
798c2ecf20Sopenharmony_ci	0x26, 0x10, 0x27,   /*          Logical Maximum (10000),    */
808c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
818c2ecf20Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
828c2ecf20Sopenharmony_ci	0x46, 0xB8, 0x0B,   /*          Physical Maximum (3000),    */
838c2ecf20Sopenharmony_ci	0x26, 0x70, 0x17,   /*          Logical Maximum (6000),     */
848c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
858c2ecf20Sopenharmony_ci	0xB4,               /*          Pop,                        */
868c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
878c2ecf20Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
888c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
898c2ecf20Sopenharmony_ci	0xC0,               /*      End Collection,                 */
908c2ecf20Sopenharmony_ci	0xC0                /*  End Collection                      */
918c2ecf20Sopenharmony_ci};
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci/* Size of the original report descriptor of Slim Tablet 12.1 inch */
948c2ecf20Sopenharmony_ci#define SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE	269
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci/* Fixed Slim Tablet 12.1 inch descriptor */
978c2ecf20Sopenharmony_cistatic __u8 slim_tablet_12_1_inch_rdesc_fixed[] = {
988c2ecf20Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
998c2ecf20Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
1008c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
1018c2ecf20Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
1028c2ecf20Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
1038c2ecf20Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
1048c2ecf20Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
1058c2ecf20Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
1068c2ecf20Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
1078c2ecf20Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
1088c2ecf20Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
1098c2ecf20Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
1108c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
1118c2ecf20Sopenharmony_ci	0x80,               /*          Input,                      */
1128c2ecf20Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
1138c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
1148c2ecf20Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
1158c2ecf20Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
1168c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
1178c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
1188c2ecf20Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
1198c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
1208c2ecf20Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
1218c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
1228c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
1238c2ecf20Sopenharmony_ci	0xA4,               /*          Push,                       */
1248c2ecf20Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
1258c2ecf20Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
1268c2ecf20Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
1278c2ecf20Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
1288c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
1298c2ecf20Sopenharmony_ci	0x46, 0x10, 0x27,   /*          Physical Maximum (10000),   */
1308c2ecf20Sopenharmony_ci	0x26, 0x20, 0x4E,   /*          Logical Maximum (20000),    */
1318c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
1328c2ecf20Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
1338c2ecf20Sopenharmony_ci	0x46, 0x6A, 0x18,   /*          Physical Maximum (6250),    */
1348c2ecf20Sopenharmony_ci	0x26, 0xD4, 0x30,   /*          Logical Maximum (12500),    */
1358c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
1368c2ecf20Sopenharmony_ci	0xB4,               /*          Pop,                        */
1378c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
1388c2ecf20Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
1398c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
1408c2ecf20Sopenharmony_ci	0xC0,               /*      End Collection,                 */
1418c2ecf20Sopenharmony_ci	0xC0                /*  End Collection                      */
1428c2ecf20Sopenharmony_ci};
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci/* Size of the original report descriptor of Q Pad */
1458c2ecf20Sopenharmony_ci#define Q_PAD_RDESC_ORIG_SIZE	241
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci/* Fixed Q Pad descriptor */
1488c2ecf20Sopenharmony_cistatic __u8 q_pad_rdesc_fixed[] = {
1498c2ecf20Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
1508c2ecf20Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
1518c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
1528c2ecf20Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
1538c2ecf20Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
1548c2ecf20Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
1558c2ecf20Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
1568c2ecf20Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
1578c2ecf20Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
1588c2ecf20Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
1598c2ecf20Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
1608c2ecf20Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
1618c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
1628c2ecf20Sopenharmony_ci	0x80,               /*          Input,                      */
1638c2ecf20Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
1648c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
1658c2ecf20Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
1668c2ecf20Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
1678c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
1688c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
1698c2ecf20Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
1708c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
1718c2ecf20Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
1728c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
1738c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
1748c2ecf20Sopenharmony_ci	0xA4,               /*          Push,                       */
1758c2ecf20Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
1768c2ecf20Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
1778c2ecf20Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
1788c2ecf20Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
1798c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
1808c2ecf20Sopenharmony_ci	0x46, 0x70, 0x17,   /*          Physical Maximum (6000),    */
1818c2ecf20Sopenharmony_ci	0x26, 0x00, 0x30,   /*          Logical Maximum (12288),    */
1828c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
1838c2ecf20Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
1848c2ecf20Sopenharmony_ci	0x46, 0x94, 0x11,   /*          Physical Maximum (4500),    */
1858c2ecf20Sopenharmony_ci	0x26, 0x00, 0x24,   /*          Logical Maximum (9216),     */
1868c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
1878c2ecf20Sopenharmony_ci	0xB4,               /*          Pop,                        */
1888c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
1898c2ecf20Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
1908c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
1918c2ecf20Sopenharmony_ci	0xC0,               /*      End Collection,                 */
1928c2ecf20Sopenharmony_ci	0xC0                /*  End Collection                      */
1938c2ecf20Sopenharmony_ci};
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci/* Size of the original report descriptor of tablet with PID 0038 */
1968c2ecf20Sopenharmony_ci#define PID_0038_RDESC_ORIG_SIZE	241
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci/*
1998c2ecf20Sopenharmony_ci * Fixed report descriptor for tablet with PID 0038.
2008c2ecf20Sopenharmony_ci */
2018c2ecf20Sopenharmony_cistatic __u8 pid_0038_rdesc_fixed[] = {
2028c2ecf20Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
2038c2ecf20Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
2048c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
2058c2ecf20Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
2068c2ecf20Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
2078c2ecf20Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
2088c2ecf20Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
2098c2ecf20Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
2108c2ecf20Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
2118c2ecf20Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
2128c2ecf20Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
2138c2ecf20Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
2148c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
2158c2ecf20Sopenharmony_ci	0x80,               /*          Input,                      */
2168c2ecf20Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
2178c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
2188c2ecf20Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
2198c2ecf20Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
2208c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
2218c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
2228c2ecf20Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
2238c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
2248c2ecf20Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
2258c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
2268c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
2278c2ecf20Sopenharmony_ci	0xA4,               /*          Push,                       */
2288c2ecf20Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
2298c2ecf20Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
2308c2ecf20Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
2318c2ecf20Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
2328c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
2338c2ecf20Sopenharmony_ci	0x46, 0x2E, 0x22,   /*          Physical Maximum (8750),    */
2348c2ecf20Sopenharmony_ci	0x26, 0x00, 0x46,   /*          Logical Maximum (17920),    */
2358c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
2368c2ecf20Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
2378c2ecf20Sopenharmony_ci	0x46, 0x82, 0x14,   /*          Physical Maximum (5250),    */
2388c2ecf20Sopenharmony_ci	0x26, 0x00, 0x2A,   /*          Logical Maximum (10752),    */
2398c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
2408c2ecf20Sopenharmony_ci	0xB4,               /*          Pop,                        */
2418c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
2428c2ecf20Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
2438c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
2448c2ecf20Sopenharmony_ci	0xC0,               /*      End Collection,                 */
2458c2ecf20Sopenharmony_ci	0xC0                /*  End Collection                      */
2468c2ecf20Sopenharmony_ci};
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci/* Size of the original report descriptor of Media Tablet 10.6 inch */
2498c2ecf20Sopenharmony_ci#define MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE	300
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci/* Fixed Media Tablet 10.6 inch descriptor */
2528c2ecf20Sopenharmony_cistatic __u8 media_tablet_10_6_inch_rdesc_fixed[] = {
2538c2ecf20Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
2548c2ecf20Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
2558c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
2568c2ecf20Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
2578c2ecf20Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
2588c2ecf20Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
2598c2ecf20Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
2608c2ecf20Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
2618c2ecf20Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
2628c2ecf20Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
2638c2ecf20Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
2648c2ecf20Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
2658c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
2668c2ecf20Sopenharmony_ci	0x80,               /*          Input,                      */
2678c2ecf20Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
2688c2ecf20Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
2698c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
2708c2ecf20Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
2718c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
2728c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
2738c2ecf20Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
2748c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
2758c2ecf20Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
2768c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
2778c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
2788c2ecf20Sopenharmony_ci	0xA4,               /*          Push,                       */
2798c2ecf20Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
2808c2ecf20Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
2818c2ecf20Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
2828c2ecf20Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
2838c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
2848c2ecf20Sopenharmony_ci	0x46, 0x28, 0x23,   /*          Physical Maximum (9000),    */
2858c2ecf20Sopenharmony_ci	0x26, 0x50, 0x46,   /*          Logical Maximum (18000),    */
2868c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
2878c2ecf20Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
2888c2ecf20Sopenharmony_ci	0x46, 0x7C, 0x15,   /*          Physical Maximum (5500),    */
2898c2ecf20Sopenharmony_ci	0x26, 0xF8, 0x2A,   /*          Logical Maximum (11000),    */
2908c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
2918c2ecf20Sopenharmony_ci	0xB4,               /*          Pop,                        */
2928c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
2938c2ecf20Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
2948c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
2958c2ecf20Sopenharmony_ci	0xC0,               /*      End Collection,                 */
2968c2ecf20Sopenharmony_ci	0xC0,               /*  End Collection,                     */
2978c2ecf20Sopenharmony_ci	0x05, 0x01,         /*  Usage Page (Desktop),               */
2988c2ecf20Sopenharmony_ci	0x09, 0x02,         /*  Usage (Mouse),                      */
2998c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
3008c2ecf20Sopenharmony_ci	0x85, 0x01,         /*      Report ID (1),                  */
3018c2ecf20Sopenharmony_ci	0x09, 0x01,         /*      Usage (Pointer),                */
3028c2ecf20Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
3038c2ecf20Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
3048c2ecf20Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
3058c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
3068c2ecf20Sopenharmony_ci	0x95, 0x02,         /*          Report Count (2),           */
3078c2ecf20Sopenharmony_ci	0x15, 0xFF,         /*          Logical Minimum (-1),       */
3088c2ecf20Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
3098c2ecf20Sopenharmony_ci	0x09, 0x38,         /*          Usage (Wheel),              */
3108c2ecf20Sopenharmony_ci	0x0B, 0x38, 0x02,   /*          Usage (Consumer AC Pan),    */
3118c2ecf20Sopenharmony_ci		0x0C, 0x00,
3128c2ecf20Sopenharmony_ci	0x81, 0x06,         /*          Input (Variable, Relative), */
3138c2ecf20Sopenharmony_ci	0x95, 0x02,         /*          Report Count (2),           */
3148c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
3158c2ecf20Sopenharmony_ci	0xC0,               /*      End Collection,                 */
3168c2ecf20Sopenharmony_ci	0xC0,               /*  End Collection,                     */
3178c2ecf20Sopenharmony_ci	0x05, 0x0C,         /*  Usage Page (Consumer),              */
3188c2ecf20Sopenharmony_ci	0x09, 0x01,         /*  Usage (Consumer Control),           */
3198c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
3208c2ecf20Sopenharmony_ci	0x85, 0x0D,         /*      Report ID (13),                 */
3218c2ecf20Sopenharmony_ci	0x95, 0x01,         /*      Report Count (1),               */
3228c2ecf20Sopenharmony_ci	0x75, 0x10,         /*      Report Size (16),               */
3238c2ecf20Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
3248c2ecf20Sopenharmony_ci	0x0A, 0x2F, 0x02,   /*      Usage (AC Zoom),                */
3258c2ecf20Sopenharmony_ci	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
3268c2ecf20Sopenharmony_ci	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
3278c2ecf20Sopenharmony_ci	0x09, 0xB6,         /*      Usage (Scan Previous Track),    */
3288c2ecf20Sopenharmony_ci	0x09, 0xB5,         /*      Usage (Scan Next Track),        */
3298c2ecf20Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
3308c2ecf20Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
3318c2ecf20Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
3328c2ecf20Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
3338c2ecf20Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
3348c2ecf20Sopenharmony_ci	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
3358c2ecf20Sopenharmony_ci	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
3368c2ecf20Sopenharmony_ci	0x15, 0x0C,         /*      Logical Minimum (12),           */
3378c2ecf20Sopenharmony_ci	0x25, 0x17,         /*      Logical Maximum (23),           */
3388c2ecf20Sopenharmony_ci	0x75, 0x05,         /*      Report Size (5),                */
3398c2ecf20Sopenharmony_ci	0x80,               /*      Input,                          */
3408c2ecf20Sopenharmony_ci	0x75, 0x03,         /*      Report Size (3),                */
3418c2ecf20Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
3428c2ecf20Sopenharmony_ci	0x75, 0x20,         /*      Report Size (32),               */
3438c2ecf20Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
3448c2ecf20Sopenharmony_ci	0xC0,               /*  End Collection,                     */
3458c2ecf20Sopenharmony_ci	0x09, 0x01,         /*  Usage (Consumer Control),           */
3468c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
3478c2ecf20Sopenharmony_ci	0x85, 0x0C,         /*      Report ID (12),                 */
3488c2ecf20Sopenharmony_ci	0x75, 0x01,         /*      Report Size (1),                */
3498c2ecf20Sopenharmony_ci	0x09, 0xE9,         /*      Usage (Volume Inc),             */
3508c2ecf20Sopenharmony_ci	0x09, 0xEA,         /*      Usage (Volume Dec),             */
3518c2ecf20Sopenharmony_ci	0x09, 0xE2,         /*      Usage (Mute),                   */
3528c2ecf20Sopenharmony_ci	0x14,               /*      Logical Minimum (0),            */
3538c2ecf20Sopenharmony_ci	0x25, 0x01,         /*      Logical Maximum (1),            */
3548c2ecf20Sopenharmony_ci	0x95, 0x03,         /*      Report Count (3),               */
3558c2ecf20Sopenharmony_ci	0x81, 0x06,         /*      Input (Variable, Relative),     */
3568c2ecf20Sopenharmony_ci	0x95, 0x35,         /*      Report Count (53),              */
3578c2ecf20Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
3588c2ecf20Sopenharmony_ci	0xC0                /*  End Collection                      */
3598c2ecf20Sopenharmony_ci};
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci/* Size of the original report descriptor of Media Tablet 14.1 inch */
3628c2ecf20Sopenharmony_ci#define MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE	309
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci/* Fixed Media Tablet 14.1 inch descriptor */
3658c2ecf20Sopenharmony_cistatic __u8 media_tablet_14_1_inch_rdesc_fixed[] = {
3668c2ecf20Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
3678c2ecf20Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
3688c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
3698c2ecf20Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
3708c2ecf20Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
3718c2ecf20Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
3728c2ecf20Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
3738c2ecf20Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
3748c2ecf20Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
3758c2ecf20Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
3768c2ecf20Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
3778c2ecf20Sopenharmony_ci	0x75, 0x04,         /*          Report Size (4),            */
3788c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
3798c2ecf20Sopenharmony_ci	0x80,               /*          Input,                      */
3808c2ecf20Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
3818c2ecf20Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
3828c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
3838c2ecf20Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
3848c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
3858c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
3868c2ecf20Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
3878c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
3888c2ecf20Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
3898c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
3908c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
3918c2ecf20Sopenharmony_ci	0xA4,               /*          Push,                       */
3928c2ecf20Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
3938c2ecf20Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
3948c2ecf20Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
3958c2ecf20Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
3968c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
3978c2ecf20Sopenharmony_ci	0x46, 0xE0, 0x2E,   /*          Physical Maximum (12000),   */
3988c2ecf20Sopenharmony_ci	0x26, 0xFF, 0x3F,   /*          Logical Maximum (16383),    */
3998c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
4008c2ecf20Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
4018c2ecf20Sopenharmony_ci	0x46, 0x52, 0x1C,   /*          Physical Maximum (7250),    */
4028c2ecf20Sopenharmony_ci	0x26, 0xFF, 0x3F,   /*          Logical Maximum (16383),    */
4038c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
4048c2ecf20Sopenharmony_ci	0xB4,               /*          Pop,                        */
4058c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
4068c2ecf20Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
4078c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
4088c2ecf20Sopenharmony_ci	0xC0,               /*      End Collection,                 */
4098c2ecf20Sopenharmony_ci	0xC0,               /*  End Collection,                     */
4108c2ecf20Sopenharmony_ci	0x05, 0x01,         /*  Usage Page (Desktop),               */
4118c2ecf20Sopenharmony_ci	0x09, 0x02,         /*  Usage (Mouse),                      */
4128c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
4138c2ecf20Sopenharmony_ci	0x85, 0x01,         /*      Report ID (1),                  */
4148c2ecf20Sopenharmony_ci	0x09, 0x01,         /*      Usage (Pointer),                */
4158c2ecf20Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
4168c2ecf20Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
4178c2ecf20Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
4188c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
4198c2ecf20Sopenharmony_ci	0x95, 0x02,         /*          Report Count (2),           */
4208c2ecf20Sopenharmony_ci	0x15, 0xFF,         /*          Logical Minimum (-1),       */
4218c2ecf20Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
4228c2ecf20Sopenharmony_ci	0x09, 0x38,         /*          Usage (Wheel),              */
4238c2ecf20Sopenharmony_ci	0x0B, 0x38, 0x02,   /*          Usage (Consumer AC Pan),    */
4248c2ecf20Sopenharmony_ci		0x0C, 0x00,
4258c2ecf20Sopenharmony_ci	0x81, 0x06,         /*          Input (Variable, Relative), */
4268c2ecf20Sopenharmony_ci	0xC0,               /*      End Collection,                 */
4278c2ecf20Sopenharmony_ci	0xC0,               /*  End Collection,                     */
4288c2ecf20Sopenharmony_ci	0x05, 0x0C,         /*  Usage Page (Consumer),              */
4298c2ecf20Sopenharmony_ci	0x09, 0x01,         /*  Usage (Consumer Control),           */
4308c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
4318c2ecf20Sopenharmony_ci	0x85, 0x0D,         /*      Report ID (13),                 */
4328c2ecf20Sopenharmony_ci	0x95, 0x01,         /*      Report Count (1),               */
4338c2ecf20Sopenharmony_ci	0x75, 0x10,         /*      Report Size (16),               */
4348c2ecf20Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
4358c2ecf20Sopenharmony_ci	0x0A, 0x2F, 0x02,   /*      Usage (AC Zoom),                */
4368c2ecf20Sopenharmony_ci	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
4378c2ecf20Sopenharmony_ci	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
4388c2ecf20Sopenharmony_ci	0x09, 0xB6,         /*      Usage (Scan Previous Track),    */
4398c2ecf20Sopenharmony_ci	0x09, 0xB5,         /*      Usage (Scan Next Track),        */
4408c2ecf20Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
4418c2ecf20Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
4428c2ecf20Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
4438c2ecf20Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
4448c2ecf20Sopenharmony_ci	0x08,               /*      Usage (00h),                    */
4458c2ecf20Sopenharmony_ci	0x0A, 0x2E, 0x02,   /*      Usage (AC Zoom Out),            */
4468c2ecf20Sopenharmony_ci	0x0A, 0x2D, 0x02,   /*      Usage (AC Zoom In),             */
4478c2ecf20Sopenharmony_ci	0x15, 0x0C,         /*      Logical Minimum (12),           */
4488c2ecf20Sopenharmony_ci	0x25, 0x17,         /*      Logical Maximum (23),           */
4498c2ecf20Sopenharmony_ci	0x75, 0x05,         /*      Report Size (5),                */
4508c2ecf20Sopenharmony_ci	0x80,               /*      Input,                          */
4518c2ecf20Sopenharmony_ci	0x75, 0x03,         /*      Report Size (3),                */
4528c2ecf20Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
4538c2ecf20Sopenharmony_ci	0x75, 0x20,         /*      Report Size (32),               */
4548c2ecf20Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
4558c2ecf20Sopenharmony_ci	0xC0,               /*  End Collection,                     */
4568c2ecf20Sopenharmony_ci	0x09, 0x01,         /*  Usage (Consumer Control),           */
4578c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
4588c2ecf20Sopenharmony_ci	0x85, 0x0C,         /*      Report ID (12),                 */
4598c2ecf20Sopenharmony_ci	0x75, 0x01,         /*      Report Size (1),                */
4608c2ecf20Sopenharmony_ci	0x09, 0xE9,         /*      Usage (Volume Inc),             */
4618c2ecf20Sopenharmony_ci	0x09, 0xEA,         /*      Usage (Volume Dec),             */
4628c2ecf20Sopenharmony_ci	0x09, 0xE2,         /*      Usage (Mute),                   */
4638c2ecf20Sopenharmony_ci	0x14,               /*      Logical Minimum (0),            */
4648c2ecf20Sopenharmony_ci	0x25, 0x01,         /*      Logical Maximum (1),            */
4658c2ecf20Sopenharmony_ci	0x95, 0x03,         /*      Report Count (3),               */
4668c2ecf20Sopenharmony_ci	0x81, 0x06,         /*      Input (Variable, Relative),     */
4678c2ecf20Sopenharmony_ci	0x75, 0x05,         /*      Report Size (5),                */
4688c2ecf20Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
4698c2ecf20Sopenharmony_ci	0xC0                /*  End Collection                      */
4708c2ecf20Sopenharmony_ci};
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ci/* Size of the original report descriptor of Sirius Battery Free Tablet */
4738c2ecf20Sopenharmony_ci#define SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE	335
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci/* Fixed Sirius Battery Free Tablet descriptor */
4768c2ecf20Sopenharmony_cistatic __u8 sirius_battery_free_tablet_rdesc_fixed[] = {
4778c2ecf20Sopenharmony_ci	0x05, 0x0D,         /*  Usage Page (Digitizer),             */
4788c2ecf20Sopenharmony_ci	0x09, 0x02,         /*  Usage (Pen),                        */
4798c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
4808c2ecf20Sopenharmony_ci	0x85, 0x10,         /*      Report ID (16),                 */
4818c2ecf20Sopenharmony_ci	0x09, 0x20,         /*      Usage (Stylus),                 */
4828c2ecf20Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
4838c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
4848c2ecf20Sopenharmony_ci	0x15, 0x01,         /*          Logical Minimum (1),        */
4858c2ecf20Sopenharmony_ci	0x25, 0x03,         /*          Logical Maximum (3),        */
4868c2ecf20Sopenharmony_ci	0x75, 0x02,         /*          Report Size (2),            */
4878c2ecf20Sopenharmony_ci	0x09, 0x42,         /*          Usage (Tip Switch),         */
4888c2ecf20Sopenharmony_ci	0x09, 0x44,         /*          Usage (Barrel Switch),      */
4898c2ecf20Sopenharmony_ci	0x09, 0x46,         /*          Usage (Tablet Pick),        */
4908c2ecf20Sopenharmony_ci	0x80,               /*          Input,                      */
4918c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
4928c2ecf20Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
4938c2ecf20Sopenharmony_ci	0x75, 0x01,         /*          Report Size (1),            */
4948c2ecf20Sopenharmony_ci	0x09, 0x3C,         /*          Usage (Invert),             */
4958c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
4968c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
4978c2ecf20Sopenharmony_ci	0x09, 0x32,         /*          Usage (In Range),           */
4988c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
4998c2ecf20Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
5008c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
5018c2ecf20Sopenharmony_ci	0xA4,               /*          Push,                       */
5028c2ecf20Sopenharmony_ci	0x05, 0x01,         /*          Usage Page (Desktop),       */
5038c2ecf20Sopenharmony_ci	0x55, 0xFD,         /*          Unit Exponent (-3),         */
5048c2ecf20Sopenharmony_ci	0x65, 0x13,         /*          Unit (Inch),                */
5058c2ecf20Sopenharmony_ci	0x34,               /*          Physical Minimum (0),       */
5068c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
5078c2ecf20Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
5088c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
5098c2ecf20Sopenharmony_ci	0x46, 0x10, 0x27,   /*          Physical Maximum (10000),   */
5108c2ecf20Sopenharmony_ci	0x26, 0x20, 0x4E,   /*          Logical Maximum (20000),    */
5118c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (X),                  */
5128c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
5138c2ecf20Sopenharmony_ci	0x46, 0x70, 0x17,   /*          Physical Maximum (6000),    */
5148c2ecf20Sopenharmony_ci	0x26, 0xE0, 0x2E,   /*          Logical Maximum (12000),    */
5158c2ecf20Sopenharmony_ci	0x09, 0x31,         /*          Usage (Y),                  */
5168c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
5178c2ecf20Sopenharmony_ci	0xB4,               /*          Pop,                        */
5188c2ecf20Sopenharmony_ci	0x75, 0x10,         /*          Report Size (16),           */
5198c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
5208c2ecf20Sopenharmony_ci	0x14,               /*          Logical Minimum (0),        */
5218c2ecf20Sopenharmony_ci	0x26, 0xFF, 0x03,   /*          Logical Maximum (1023),     */
5228c2ecf20Sopenharmony_ci	0x09, 0x30,         /*          Usage (Tip Pressure),       */
5238c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
5248c2ecf20Sopenharmony_ci	0xA4,               /*          Push,                       */
5258c2ecf20Sopenharmony_ci	0x55, 0xFE,         /*          Unit Exponent (-2),         */
5268c2ecf20Sopenharmony_ci	0x65, 0x12,         /*          Unit (Radians),             */
5278c2ecf20Sopenharmony_ci	0x35, 0x97,         /*          Physical Minimum (-105),    */
5288c2ecf20Sopenharmony_ci	0x45, 0x69,         /*          Physical Maximum (105),     */
5298c2ecf20Sopenharmony_ci	0x15, 0x97,         /*          Logical Minimum (-105),     */
5308c2ecf20Sopenharmony_ci	0x25, 0x69,         /*          Logical Maximum (105),      */
5318c2ecf20Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
5328c2ecf20Sopenharmony_ci	0x95, 0x02,         /*          Report Count (2),           */
5338c2ecf20Sopenharmony_ci	0x09, 0x3D,         /*          Usage (X Tilt),             */
5348c2ecf20Sopenharmony_ci	0x09, 0x3E,         /*          Usage (Y Tilt),             */
5358c2ecf20Sopenharmony_ci	0x81, 0x02,         /*          Input (Variable),           */
5368c2ecf20Sopenharmony_ci	0xB4,               /*          Pop,                        */
5378c2ecf20Sopenharmony_ci	0xC0,               /*      End Collection,                 */
5388c2ecf20Sopenharmony_ci	0xC0,               /*  End Collection,                     */
5398c2ecf20Sopenharmony_ci	0x05, 0x01,         /*  Usage Page (Desktop),               */
5408c2ecf20Sopenharmony_ci	0x09, 0x02,         /*  Usage (Mouse),                      */
5418c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
5428c2ecf20Sopenharmony_ci	0x85, 0x01,         /*      Report ID (1),                  */
5438c2ecf20Sopenharmony_ci	0x09, 0x01,         /*      Usage (Pointer),                */
5448c2ecf20Sopenharmony_ci	0xA0,               /*      Collection (Physical),          */
5458c2ecf20Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
5468c2ecf20Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
5478c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
5488c2ecf20Sopenharmony_ci	0x09, 0x38,         /*          Usage (Wheel),              */
5498c2ecf20Sopenharmony_ci	0x15, 0xFF,         /*          Logical Minimum (-1),       */
5508c2ecf20Sopenharmony_ci	0x25, 0x01,         /*          Logical Maximum (1),        */
5518c2ecf20Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
5528c2ecf20Sopenharmony_ci	0x95, 0x01,         /*          Report Count (1),           */
5538c2ecf20Sopenharmony_ci	0x81, 0x06,         /*          Input (Variable, Relative), */
5548c2ecf20Sopenharmony_ci	0x75, 0x08,         /*          Report Size (8),            */
5558c2ecf20Sopenharmony_ci	0x95, 0x03,         /*          Report Count (3),           */
5568c2ecf20Sopenharmony_ci	0x81, 0x03,         /*          Input (Constant, Variable), */
5578c2ecf20Sopenharmony_ci	0xC0,               /*      End Collection,                 */
5588c2ecf20Sopenharmony_ci	0xC0,               /*  End Collection,                     */
5598c2ecf20Sopenharmony_ci	0x05, 0x01,         /*  Usage Page (Desktop),               */
5608c2ecf20Sopenharmony_ci	0x09, 0x06,         /*  Usage (Keyboard),                   */
5618c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
5628c2ecf20Sopenharmony_ci	0x85, 0x0D,         /*      Report ID (13),                 */
5638c2ecf20Sopenharmony_ci	0x05, 0x07,         /*      Usage Page (Keyboard),          */
5648c2ecf20Sopenharmony_ci	0x19, 0xE0,         /*      Usage Minimum (KB Leftcontrol), */
5658c2ecf20Sopenharmony_ci	0x29, 0xE7,         /*      Usage Maximum (KB Right GUI),   */
5668c2ecf20Sopenharmony_ci	0x14,               /*      Logical Minimum (0),            */
5678c2ecf20Sopenharmony_ci	0x25, 0x01,         /*      Logical Maximum (1),            */
5688c2ecf20Sopenharmony_ci	0x75, 0x01,         /*      Report Size (1),                */
5698c2ecf20Sopenharmony_ci	0x95, 0x08,         /*      Report Count (8),               */
5708c2ecf20Sopenharmony_ci	0x81, 0x02,         /*      Input (Variable),               */
5718c2ecf20Sopenharmony_ci	0x75, 0x08,         /*      Report Size (8),                */
5728c2ecf20Sopenharmony_ci	0x95, 0x01,         /*      Report Count (1),               */
5738c2ecf20Sopenharmony_ci	0x81, 0x01,         /*      Input (Constant),               */
5748c2ecf20Sopenharmony_ci	0x18,               /*      Usage Minimum (None),           */
5758c2ecf20Sopenharmony_ci	0x29, 0x65,         /*      Usage Maximum (KB Application), */
5768c2ecf20Sopenharmony_ci	0x14,               /*      Logical Minimum (0),            */
5778c2ecf20Sopenharmony_ci	0x25, 0x65,         /*      Logical Maximum (101),          */
5788c2ecf20Sopenharmony_ci	0x75, 0x08,         /*      Report Size (8),                */
5798c2ecf20Sopenharmony_ci	0x95, 0x05,         /*      Report Count (5),               */
5808c2ecf20Sopenharmony_ci	0x80,               /*      Input,                          */
5818c2ecf20Sopenharmony_ci	0xC0,               /*  End Collection,                     */
5828c2ecf20Sopenharmony_ci	0x05, 0x0C,         /*  Usage Page (Consumer),              */
5838c2ecf20Sopenharmony_ci	0x09, 0x01,         /*  Usage (Consumer Control),           */
5848c2ecf20Sopenharmony_ci	0xA1, 0x01,         /*  Collection (Application),           */
5858c2ecf20Sopenharmony_ci	0x85, 0x0C,         /*      Report ID (12),                 */
5868c2ecf20Sopenharmony_ci	0x09, 0xE9,         /*      Usage (Volume Inc),             */
5878c2ecf20Sopenharmony_ci	0x09, 0xEA,         /*      Usage (Volume Dec),             */
5888c2ecf20Sopenharmony_ci	0x14,               /*      Logical Minimum (0),            */
5898c2ecf20Sopenharmony_ci	0x25, 0x01,         /*      Logical Maximum (1),            */
5908c2ecf20Sopenharmony_ci	0x75, 0x01,         /*      Report Size (1),                */
5918c2ecf20Sopenharmony_ci	0x95, 0x02,         /*      Report Count (2),               */
5928c2ecf20Sopenharmony_ci	0x81, 0x02,         /*      Input (Variable),               */
5938c2ecf20Sopenharmony_ci	0x75, 0x06,         /*      Report Size (6),                */
5948c2ecf20Sopenharmony_ci	0x95, 0x01,         /*      Report Count (1),               */
5958c2ecf20Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
5968c2ecf20Sopenharmony_ci	0x75, 0x10,         /*      Report Size (16),               */
5978c2ecf20Sopenharmony_ci	0x95, 0x03,         /*      Report Count (3),               */
5988c2ecf20Sopenharmony_ci	0x81, 0x03,         /*      Input (Constant, Variable),     */
5998c2ecf20Sopenharmony_ci	0xC0                /*  End Collection                      */
6008c2ecf20Sopenharmony_ci};
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_cistatic __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
6038c2ecf20Sopenharmony_ci		unsigned int *rsize)
6048c2ecf20Sopenharmony_ci{
6058c2ecf20Sopenharmony_ci	switch (hdev->product) {
6068c2ecf20Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH:
6078c2ecf20Sopenharmony_ci		if (*rsize == SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE) {
6088c2ecf20Sopenharmony_ci			rdesc = slim_tablet_5_8_inch_rdesc_fixed;
6098c2ecf20Sopenharmony_ci			*rsize = sizeof(slim_tablet_5_8_inch_rdesc_fixed);
6108c2ecf20Sopenharmony_ci		}
6118c2ecf20Sopenharmony_ci		break;
6128c2ecf20Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH:
6138c2ecf20Sopenharmony_ci		if (*rsize == SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE) {
6148c2ecf20Sopenharmony_ci			rdesc = slim_tablet_12_1_inch_rdesc_fixed;
6158c2ecf20Sopenharmony_ci			*rsize = sizeof(slim_tablet_12_1_inch_rdesc_fixed);
6168c2ecf20Sopenharmony_ci		}
6178c2ecf20Sopenharmony_ci		break;
6188c2ecf20Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_Q_PAD:
6198c2ecf20Sopenharmony_ci		if (*rsize == Q_PAD_RDESC_ORIG_SIZE) {
6208c2ecf20Sopenharmony_ci			rdesc = q_pad_rdesc_fixed;
6218c2ecf20Sopenharmony_ci			*rsize = sizeof(q_pad_rdesc_fixed);
6228c2ecf20Sopenharmony_ci		}
6238c2ecf20Sopenharmony_ci		break;
6248c2ecf20Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_PID_0038:
6258c2ecf20Sopenharmony_ci		if (*rsize == PID_0038_RDESC_ORIG_SIZE) {
6268c2ecf20Sopenharmony_ci			rdesc = pid_0038_rdesc_fixed;
6278c2ecf20Sopenharmony_ci			*rsize = sizeof(pid_0038_rdesc_fixed);
6288c2ecf20Sopenharmony_ci		}
6298c2ecf20Sopenharmony_ci		break;
6308c2ecf20Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH:
6318c2ecf20Sopenharmony_ci		if (*rsize == MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE) {
6328c2ecf20Sopenharmony_ci			rdesc = media_tablet_10_6_inch_rdesc_fixed;
6338c2ecf20Sopenharmony_ci			*rsize = sizeof(media_tablet_10_6_inch_rdesc_fixed);
6348c2ecf20Sopenharmony_ci		}
6358c2ecf20Sopenharmony_ci		break;
6368c2ecf20Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH:
6378c2ecf20Sopenharmony_ci		if (*rsize == MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE) {
6388c2ecf20Sopenharmony_ci			rdesc = media_tablet_14_1_inch_rdesc_fixed;
6398c2ecf20Sopenharmony_ci			*rsize = sizeof(media_tablet_14_1_inch_rdesc_fixed);
6408c2ecf20Sopenharmony_ci		}
6418c2ecf20Sopenharmony_ci		break;
6428c2ecf20Sopenharmony_ci	case USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET:
6438c2ecf20Sopenharmony_ci		if (*rsize == SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE) {
6448c2ecf20Sopenharmony_ci			rdesc = sirius_battery_free_tablet_rdesc_fixed;
6458c2ecf20Sopenharmony_ci			*rsize = sizeof(sirius_battery_free_tablet_rdesc_fixed);
6468c2ecf20Sopenharmony_ci		}
6478c2ecf20Sopenharmony_ci		break;
6488c2ecf20Sopenharmony_ci	}
6498c2ecf20Sopenharmony_ci	return rdesc;
6508c2ecf20Sopenharmony_ci}
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_cistatic int waltop_raw_event(struct hid_device *hdev, struct hid_report *report,
6538c2ecf20Sopenharmony_ci		     u8 *data, int size)
6548c2ecf20Sopenharmony_ci{
6558c2ecf20Sopenharmony_ci	/* If this is a pen input report */
6568c2ecf20Sopenharmony_ci	if (report->type == HID_INPUT_REPORT && report->id == 16 && size >= 8) {
6578c2ecf20Sopenharmony_ci		/*
6588c2ecf20Sopenharmony_ci		 * Ignore reported pressure when a barrel button is pressed,
6598c2ecf20Sopenharmony_ci		 * because it is rarely correct.
6608c2ecf20Sopenharmony_ci		 */
6618c2ecf20Sopenharmony_ci
6628c2ecf20Sopenharmony_ci		/* If a barrel button is pressed */
6638c2ecf20Sopenharmony_ci		if ((data[1] & 0xF) > 1) {
6648c2ecf20Sopenharmony_ci			/* Report zero pressure */
6658c2ecf20Sopenharmony_ci			data[6] = 0;
6668c2ecf20Sopenharmony_ci			data[7] = 0;
6678c2ecf20Sopenharmony_ci		}
6688c2ecf20Sopenharmony_ci	}
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ci	/* If this is a pen input report of Sirius Battery Free Tablet */
6718c2ecf20Sopenharmony_ci	if (hdev->product == USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET &&
6728c2ecf20Sopenharmony_ci	    report->type == HID_INPUT_REPORT &&
6738c2ecf20Sopenharmony_ci	    report->id == 16 &&
6748c2ecf20Sopenharmony_ci	    size == 10) {
6758c2ecf20Sopenharmony_ci		/*
6768c2ecf20Sopenharmony_ci		 * The tablet reports tilt as roughly sin(a)*21 (18 means 60
6778c2ecf20Sopenharmony_ci		 * degrees).
6788c2ecf20Sopenharmony_ci		 *
6798c2ecf20Sopenharmony_ci		 * This array stores angles as radians * 100, corresponding to
6808c2ecf20Sopenharmony_ci		 * reported values up to 60 degrees, as expected by userspace.
6818c2ecf20Sopenharmony_ci		 */
6828c2ecf20Sopenharmony_ci		static const s8 tilt_to_radians[] = {
6838c2ecf20Sopenharmony_ci			0, 5, 10, 14, 19, 24, 29, 34, 40, 45,
6848c2ecf20Sopenharmony_ci			50, 56, 62, 68, 74, 81, 88, 96, 105
6858c2ecf20Sopenharmony_ci		};
6868c2ecf20Sopenharmony_ci
6878c2ecf20Sopenharmony_ci		s8 tilt_x = (s8)data[8];
6888c2ecf20Sopenharmony_ci		s8 tilt_y = (s8)data[9];
6898c2ecf20Sopenharmony_ci		s8 sign_x = tilt_x >= 0 ? 1 : -1;
6908c2ecf20Sopenharmony_ci		s8 sign_y = tilt_y >= 0 ? 1 : -1;
6918c2ecf20Sopenharmony_ci
6928c2ecf20Sopenharmony_ci		tilt_x *= sign_x;
6938c2ecf20Sopenharmony_ci		tilt_y *= sign_y;
6948c2ecf20Sopenharmony_ci
6958c2ecf20Sopenharmony_ci		/*
6968c2ecf20Sopenharmony_ci		 * Reverse the Y Tilt direction to match the HID standard and
6978c2ecf20Sopenharmony_ci		 * userspace expectations. See HID Usage Tables v1.12 16.3.2
6988c2ecf20Sopenharmony_ci		 * Tilt Orientation.
6998c2ecf20Sopenharmony_ci		 */
7008c2ecf20Sopenharmony_ci		sign_y *= -1;
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_ci		/*
7038c2ecf20Sopenharmony_ci		 * This effectively clamps reported tilt to 60 degrees - the
7048c2ecf20Sopenharmony_ci		 * range expected by userspace
7058c2ecf20Sopenharmony_ci		 */
7068c2ecf20Sopenharmony_ci		if (tilt_x > ARRAY_SIZE(tilt_to_radians) - 1)
7078c2ecf20Sopenharmony_ci			tilt_x = ARRAY_SIZE(tilt_to_radians) - 1;
7088c2ecf20Sopenharmony_ci		if (tilt_y > ARRAY_SIZE(tilt_to_radians) - 1)
7098c2ecf20Sopenharmony_ci			tilt_y = ARRAY_SIZE(tilt_to_radians) - 1;
7108c2ecf20Sopenharmony_ci
7118c2ecf20Sopenharmony_ci		data[8] = tilt_to_radians[tilt_x] * sign_x;
7128c2ecf20Sopenharmony_ci		data[9] = tilt_to_radians[tilt_y] * sign_y;
7138c2ecf20Sopenharmony_ci	}
7148c2ecf20Sopenharmony_ci
7158c2ecf20Sopenharmony_ci	return 0;
7168c2ecf20Sopenharmony_ci}
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_cistatic const struct hid_device_id waltop_devices[] = {
7198c2ecf20Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
7208c2ecf20Sopenharmony_ci				USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
7218c2ecf20Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
7228c2ecf20Sopenharmony_ci				USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
7238c2ecf20Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
7248c2ecf20Sopenharmony_ci				USB_DEVICE_ID_WALTOP_Q_PAD) },
7258c2ecf20Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
7268c2ecf20Sopenharmony_ci				USB_DEVICE_ID_WALTOP_PID_0038) },
7278c2ecf20Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
7288c2ecf20Sopenharmony_ci				USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
7298c2ecf20Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
7308c2ecf20Sopenharmony_ci				USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
7318c2ecf20Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
7328c2ecf20Sopenharmony_ci			 USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) },
7338c2ecf20Sopenharmony_ci	{ }
7348c2ecf20Sopenharmony_ci};
7358c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(hid, waltop_devices);
7368c2ecf20Sopenharmony_ci
7378c2ecf20Sopenharmony_cistatic struct hid_driver waltop_driver = {
7388c2ecf20Sopenharmony_ci	.name = "waltop",
7398c2ecf20Sopenharmony_ci	.id_table = waltop_devices,
7408c2ecf20Sopenharmony_ci	.report_fixup = waltop_report_fixup,
7418c2ecf20Sopenharmony_ci	.raw_event = waltop_raw_event,
7428c2ecf20Sopenharmony_ci};
7438c2ecf20Sopenharmony_cimodule_hid_driver(waltop_driver);
7448c2ecf20Sopenharmony_ci
7458c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
746