123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749 |
- #include <linux/device.h>
- #include <linux/hid.h>
- #include <linux/module.h>
- #include "hid-ids.h"
- #define SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE 222
- static __u8 slim_tablet_5_8_inch_rdesc_fixed[] = {
- 0x05, 0x0D,
- 0x09, 0x02,
- 0xA1, 0x01,
- 0x85, 0x10,
- 0x09, 0x20,
- 0xA0,
- 0x09, 0x42,
- 0x09, 0x44,
- 0x09, 0x46,
- 0x15, 0x01,
- 0x25, 0x03,
- 0x75, 0x04,
- 0x95, 0x01,
- 0x80,
- 0x09, 0x32,
- 0x14,
- 0x25, 0x01,
- 0x75, 0x01,
- 0x95, 0x01,
- 0x81, 0x02,
- 0x95, 0x03,
- 0x81, 0x03,
- 0x75, 0x10,
- 0x95, 0x01,
- 0x14,
- 0xA4,
- 0x05, 0x01,
- 0x65, 0x13,
- 0x55, 0xFD,
- 0x34,
- 0x09, 0x30,
- 0x46, 0x88, 0x13,
- 0x26, 0x10, 0x27,
- 0x81, 0x02,
- 0x09, 0x31,
- 0x46, 0xB8, 0x0B,
- 0x26, 0x70, 0x17,
- 0x81, 0x02,
- 0xB4,
- 0x09, 0x30,
- 0x26, 0xFF, 0x03,
- 0x81, 0x02,
- 0xC0,
- 0xC0
- };
- #define SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE 269
- static __u8 slim_tablet_12_1_inch_rdesc_fixed[] = {
- 0x05, 0x0D,
- 0x09, 0x02,
- 0xA1, 0x01,
- 0x85, 0x10,
- 0x09, 0x20,
- 0xA0,
- 0x09, 0x42,
- 0x09, 0x44,
- 0x09, 0x46,
- 0x15, 0x01,
- 0x25, 0x03,
- 0x75, 0x04,
- 0x95, 0x01,
- 0x80,
- 0x09, 0x32,
- 0x14,
- 0x25, 0x01,
- 0x75, 0x01,
- 0x95, 0x01,
- 0x81, 0x02,
- 0x95, 0x03,
- 0x81, 0x03,
- 0x75, 0x10,
- 0x95, 0x01,
- 0x14,
- 0xA4,
- 0x05, 0x01,
- 0x65, 0x13,
- 0x55, 0xFD,
- 0x34,
- 0x09, 0x30,
- 0x46, 0x10, 0x27,
- 0x26, 0x20, 0x4E,
- 0x81, 0x02,
- 0x09, 0x31,
- 0x46, 0x6A, 0x18,
- 0x26, 0xD4, 0x30,
- 0x81, 0x02,
- 0xB4,
- 0x09, 0x30,
- 0x26, 0xFF, 0x03,
- 0x81, 0x02,
- 0xC0,
- 0xC0
- };
- #define Q_PAD_RDESC_ORIG_SIZE 241
- static __u8 q_pad_rdesc_fixed[] = {
- 0x05, 0x0D,
- 0x09, 0x02,
- 0xA1, 0x01,
- 0x85, 0x10,
- 0x09, 0x20,
- 0xA0,
- 0x09, 0x42,
- 0x09, 0x44,
- 0x09, 0x46,
- 0x15, 0x01,
- 0x25, 0x03,
- 0x75, 0x04,
- 0x95, 0x01,
- 0x80,
- 0x09, 0x32,
- 0x14,
- 0x25, 0x01,
- 0x75, 0x01,
- 0x95, 0x01,
- 0x81, 0x02,
- 0x95, 0x03,
- 0x81, 0x03,
- 0x75, 0x10,
- 0x95, 0x01,
- 0x14,
- 0xA4,
- 0x05, 0x01,
- 0x65, 0x13,
- 0x55, 0xFD,
- 0x34,
- 0x09, 0x30,
- 0x46, 0x70, 0x17,
- 0x26, 0x00, 0x30,
- 0x81, 0x02,
- 0x09, 0x31,
- 0x46, 0x94, 0x11,
- 0x26, 0x00, 0x24,
- 0x81, 0x02,
- 0xB4,
- 0x09, 0x30,
- 0x26, 0xFF, 0x03,
- 0x81, 0x02,
- 0xC0,
- 0xC0
- };
- #define PID_0038_RDESC_ORIG_SIZE 241
- static __u8 pid_0038_rdesc_fixed[] = {
- 0x05, 0x0D,
- 0x09, 0x02,
- 0xA1, 0x01,
- 0x85, 0x10,
- 0x09, 0x20,
- 0xA0,
- 0x09, 0x42,
- 0x09, 0x44,
- 0x09, 0x46,
- 0x15, 0x01,
- 0x25, 0x03,
- 0x75, 0x04,
- 0x95, 0x01,
- 0x80,
- 0x09, 0x32,
- 0x14,
- 0x25, 0x01,
- 0x75, 0x01,
- 0x95, 0x01,
- 0x81, 0x02,
- 0x95, 0x03,
- 0x81, 0x03,
- 0x75, 0x10,
- 0x95, 0x01,
- 0x14,
- 0xA4,
- 0x05, 0x01,
- 0x65, 0x13,
- 0x55, 0xFD,
- 0x34,
- 0x09, 0x30,
- 0x46, 0x2E, 0x22,
- 0x26, 0x00, 0x46,
- 0x81, 0x02,
- 0x09, 0x31,
- 0x46, 0x82, 0x14,
- 0x26, 0x00, 0x2A,
- 0x81, 0x02,
- 0xB4,
- 0x09, 0x30,
- 0x26, 0xFF, 0x03,
- 0x81, 0x02,
- 0xC0,
- 0xC0
- };
- #define MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE 300
- static __u8 media_tablet_10_6_inch_rdesc_fixed[] = {
- 0x05, 0x0D,
- 0x09, 0x02,
- 0xA1, 0x01,
- 0x85, 0x10,
- 0x09, 0x20,
- 0xA0,
- 0x09, 0x42,
- 0x09, 0x44,
- 0x09, 0x46,
- 0x15, 0x01,
- 0x25, 0x03,
- 0x75, 0x04,
- 0x95, 0x01,
- 0x80,
- 0x75, 0x01,
- 0x09, 0x32,
- 0x14,
- 0x25, 0x01,
- 0x95, 0x01,
- 0x81, 0x02,
- 0x95, 0x03,
- 0x81, 0x03,
- 0x75, 0x10,
- 0x95, 0x01,
- 0x14,
- 0xA4,
- 0x05, 0x01,
- 0x65, 0x13,
- 0x55, 0xFD,
- 0x34,
- 0x09, 0x30,
- 0x46, 0x28, 0x23,
- 0x26, 0x50, 0x46,
- 0x81, 0x02,
- 0x09, 0x31,
- 0x46, 0x7C, 0x15,
- 0x26, 0xF8, 0x2A,
- 0x81, 0x02,
- 0xB4,
- 0x09, 0x30,
- 0x26, 0xFF, 0x03,
- 0x81, 0x02,
- 0xC0,
- 0xC0,
- 0x05, 0x01,
- 0x09, 0x02,
- 0xA1, 0x01,
- 0x85, 0x01,
- 0x09, 0x01,
- 0xA0,
- 0x75, 0x08,
- 0x95, 0x03,
- 0x81, 0x03,
- 0x95, 0x02,
- 0x15, 0xFF,
- 0x25, 0x01,
- 0x09, 0x38,
- 0x0B, 0x38, 0x02,
- 0x0C, 0x00,
- 0x81, 0x06,
- 0x95, 0x02,
- 0x81, 0x03,
- 0xC0,
- 0xC0,
- 0x05, 0x0C,
- 0x09, 0x01,
- 0xA1, 0x01,
- 0x85, 0x0D,
- 0x95, 0x01,
- 0x75, 0x10,
- 0x81, 0x03,
- 0x0A, 0x2F, 0x02,
- 0x0A, 0x2E, 0x02,
- 0x0A, 0x2D, 0x02,
- 0x09, 0xB6,
- 0x09, 0xB5,
- 0x08,
- 0x08,
- 0x08,
- 0x08,
- 0x08,
- 0x0A, 0x2E, 0x02,
- 0x0A, 0x2D, 0x02,
- 0x15, 0x0C,
- 0x25, 0x17,
- 0x75, 0x05,
- 0x80,
- 0x75, 0x03,
- 0x81, 0x03,
- 0x75, 0x20,
- 0x81, 0x03,
- 0xC0,
- 0x09, 0x01,
- 0xA1, 0x01,
- 0x85, 0x0C,
- 0x75, 0x01,
- 0x09, 0xE9,
- 0x09, 0xEA,
- 0x09, 0xE2,
- 0x14,
- 0x25, 0x01,
- 0x95, 0x03,
- 0x81, 0x06,
- 0x95, 0x35,
- 0x81, 0x03,
- 0xC0
- };
- #define MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE 309
- static __u8 media_tablet_14_1_inch_rdesc_fixed[] = {
- 0x05, 0x0D,
- 0x09, 0x02,
- 0xA1, 0x01,
- 0x85, 0x10,
- 0x09, 0x20,
- 0xA0,
- 0x09, 0x42,
- 0x09, 0x44,
- 0x09, 0x46,
- 0x15, 0x01,
- 0x25, 0x03,
- 0x75, 0x04,
- 0x95, 0x01,
- 0x80,
- 0x75, 0x01,
- 0x09, 0x32,
- 0x14,
- 0x25, 0x01,
- 0x95, 0x01,
- 0x81, 0x02,
- 0x95, 0x03,
- 0x81, 0x03,
- 0x75, 0x10,
- 0x95, 0x01,
- 0x14,
- 0xA4,
- 0x05, 0x01,
- 0x65, 0x13,
- 0x55, 0xFD,
- 0x34,
- 0x09, 0x30,
- 0x46, 0xE0, 0x2E,
- 0x26, 0xFF, 0x3F,
- 0x81, 0x02,
- 0x09, 0x31,
- 0x46, 0x52, 0x1C,
- 0x26, 0xFF, 0x3F,
- 0x81, 0x02,
- 0xB4,
- 0x09, 0x30,
- 0x26, 0xFF, 0x03,
- 0x81, 0x02,
- 0xC0,
- 0xC0,
- 0x05, 0x01,
- 0x09, 0x02,
- 0xA1, 0x01,
- 0x85, 0x01,
- 0x09, 0x01,
- 0xA0,
- 0x75, 0x08,
- 0x95, 0x03,
- 0x81, 0x03,
- 0x95, 0x02,
- 0x15, 0xFF,
- 0x25, 0x01,
- 0x09, 0x38,
- 0x0B, 0x38, 0x02,
- 0x0C, 0x00,
- 0x81, 0x06,
- 0xC0,
- 0xC0,
- 0x05, 0x0C,
- 0x09, 0x01,
- 0xA1, 0x01,
- 0x85, 0x0D,
- 0x95, 0x01,
- 0x75, 0x10,
- 0x81, 0x03,
- 0x0A, 0x2F, 0x02,
- 0x0A, 0x2E, 0x02,
- 0x0A, 0x2D, 0x02,
- 0x09, 0xB6,
- 0x09, 0xB5,
- 0x08,
- 0x08,
- 0x08,
- 0x08,
- 0x08,
- 0x0A, 0x2E, 0x02,
- 0x0A, 0x2D, 0x02,
- 0x15, 0x0C,
- 0x25, 0x17,
- 0x75, 0x05,
- 0x80,
- 0x75, 0x03,
- 0x81, 0x03,
- 0x75, 0x20,
- 0x81, 0x03,
- 0xC0,
- 0x09, 0x01,
- 0xA1, 0x01,
- 0x85, 0x0C,
- 0x75, 0x01,
- 0x09, 0xE9,
- 0x09, 0xEA,
- 0x09, 0xE2,
- 0x14,
- 0x25, 0x01,
- 0x95, 0x03,
- 0x81, 0x06,
- 0x75, 0x05,
- 0x81, 0x03,
- 0xC0
- };
- #define SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE 335
- static __u8 sirius_battery_free_tablet_rdesc_fixed[] = {
- 0x05, 0x0D,
- 0x09, 0x02,
- 0xA1, 0x01,
- 0x85, 0x10,
- 0x09, 0x20,
- 0xA0,
- 0x95, 0x01,
- 0x15, 0x01,
- 0x25, 0x03,
- 0x75, 0x02,
- 0x09, 0x42,
- 0x09, 0x44,
- 0x09, 0x46,
- 0x80,
- 0x14,
- 0x25, 0x01,
- 0x75, 0x01,
- 0x09, 0x3C,
- 0x81, 0x02,
- 0x81, 0x03,
- 0x09, 0x32,
- 0x81, 0x02,
- 0x95, 0x03,
- 0x81, 0x03,
- 0xA4,
- 0x05, 0x01,
- 0x55, 0xFD,
- 0x65, 0x13,
- 0x34,
- 0x14,
- 0x75, 0x10,
- 0x95, 0x01,
- 0x46, 0x10, 0x27,
- 0x26, 0x20, 0x4E,
- 0x09, 0x30,
- 0x81, 0x02,
- 0x46, 0x70, 0x17,
- 0x26, 0xE0, 0x2E,
- 0x09, 0x31,
- 0x81, 0x02,
- 0xB4,
- 0x75, 0x10,
- 0x95, 0x01,
- 0x14,
- 0x26, 0xFF, 0x03,
- 0x09, 0x30,
- 0x81, 0x02,
- 0xA4,
- 0x55, 0xFE,
- 0x65, 0x12,
- 0x35, 0x97,
- 0x45, 0x69,
- 0x15, 0x97,
- 0x25, 0x69,
- 0x75, 0x08,
- 0x95, 0x02,
- 0x09, 0x3D,
- 0x09, 0x3E,
- 0x81, 0x02,
- 0xB4,
- 0xC0,
- 0xC0,
- 0x05, 0x01,
- 0x09, 0x02,
- 0xA1, 0x01,
- 0x85, 0x01,
- 0x09, 0x01,
- 0xA0,
- 0x75, 0x08,
- 0x95, 0x03,
- 0x81, 0x03,
- 0x09, 0x38,
- 0x15, 0xFF,
- 0x25, 0x01,
- 0x75, 0x08,
- 0x95, 0x01,
- 0x81, 0x06,
- 0x75, 0x08,
- 0x95, 0x03,
- 0x81, 0x03,
- 0xC0,
- 0xC0,
- 0x05, 0x01,
- 0x09, 0x06,
- 0xA1, 0x01,
- 0x85, 0x0D,
- 0x05, 0x07,
- 0x19, 0xE0,
- 0x29, 0xE7,
- 0x14,
- 0x25, 0x01,
- 0x75, 0x01,
- 0x95, 0x08,
- 0x81, 0x02,
- 0x75, 0x08,
- 0x95, 0x01,
- 0x81, 0x01,
- 0x18,
- 0x29, 0x65,
- 0x14,
- 0x25, 0x65,
- 0x75, 0x08,
- 0x95, 0x05,
- 0x80,
- 0xC0,
- 0x05, 0x0C,
- 0x09, 0x01,
- 0xA1, 0x01,
- 0x85, 0x0C,
- 0x09, 0xE9,
- 0x09, 0xEA,
- 0x14,
- 0x25, 0x01,
- 0x75, 0x01,
- 0x95, 0x02,
- 0x81, 0x02,
- 0x75, 0x06,
- 0x95, 0x01,
- 0x81, 0x03,
- 0x75, 0x10,
- 0x95, 0x03,
- 0x81, 0x03,
- 0xC0
- };
- static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
- unsigned int *rsize)
- {
- switch (hdev->product) {
- case USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH:
- if (*rsize == SLIM_TABLET_5_8_INCH_RDESC_ORIG_SIZE) {
- rdesc = slim_tablet_5_8_inch_rdesc_fixed;
- *rsize = sizeof(slim_tablet_5_8_inch_rdesc_fixed);
- }
- break;
- case USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH:
- if (*rsize == SLIM_TABLET_12_1_INCH_RDESC_ORIG_SIZE) {
- rdesc = slim_tablet_12_1_inch_rdesc_fixed;
- *rsize = sizeof(slim_tablet_12_1_inch_rdesc_fixed);
- }
- break;
- case USB_DEVICE_ID_WALTOP_Q_PAD:
- if (*rsize == Q_PAD_RDESC_ORIG_SIZE) {
- rdesc = q_pad_rdesc_fixed;
- *rsize = sizeof(q_pad_rdesc_fixed);
- }
- break;
- case USB_DEVICE_ID_WALTOP_PID_0038:
- if (*rsize == PID_0038_RDESC_ORIG_SIZE) {
- rdesc = pid_0038_rdesc_fixed;
- *rsize = sizeof(pid_0038_rdesc_fixed);
- }
- break;
- case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH:
- if (*rsize == MEDIA_TABLET_10_6_INCH_RDESC_ORIG_SIZE) {
- rdesc = media_tablet_10_6_inch_rdesc_fixed;
- *rsize = sizeof(media_tablet_10_6_inch_rdesc_fixed);
- }
- break;
- case USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH:
- if (*rsize == MEDIA_TABLET_14_1_INCH_RDESC_ORIG_SIZE) {
- rdesc = media_tablet_14_1_inch_rdesc_fixed;
- *rsize = sizeof(media_tablet_14_1_inch_rdesc_fixed);
- }
- break;
- case USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET:
- if (*rsize == SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE) {
- rdesc = sirius_battery_free_tablet_rdesc_fixed;
- *rsize = sizeof(sirius_battery_free_tablet_rdesc_fixed);
- }
- break;
- }
- return rdesc;
- }
- static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report,
- u8 *data, int size)
- {
-
- if (report->type == HID_INPUT_REPORT && report->id == 16 && size >= 8) {
-
-
- if ((data[1] & 0xF) > 1) {
-
- data[6] = 0;
- data[7] = 0;
- }
- }
-
- if (hdev->product == USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET &&
- report->type == HID_INPUT_REPORT &&
- report->id == 16 &&
- size == 10) {
-
- static const s8 tilt_to_radians[] = {
- 0, 5, 10, 14, 19, 24, 29, 34, 40, 45,
- 50, 56, 62, 68, 74, 81, 88, 96, 105
- };
- s8 tilt_x = (s8)data[8];
- s8 tilt_y = (s8)data[9];
- s8 sign_x = tilt_x >= 0 ? 1 : -1;
- s8 sign_y = tilt_y >= 0 ? 1 : -1;
- tilt_x *= sign_x;
- tilt_y *= sign_y;
-
- sign_y *= -1;
-
- if (tilt_x > ARRAY_SIZE(tilt_to_radians) - 1)
- tilt_x = ARRAY_SIZE(tilt_to_radians) - 1;
- if (tilt_y > ARRAY_SIZE(tilt_to_radians) - 1)
- tilt_y = ARRAY_SIZE(tilt_to_radians) - 1;
- data[8] = tilt_to_radians[tilt_x] * sign_x;
- data[9] = tilt_to_radians[tilt_y] * sign_y;
- }
- return 0;
- }
- static const struct hid_device_id waltop_devices[] = {
- { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
- USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
- { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
- USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
- { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
- USB_DEVICE_ID_WALTOP_Q_PAD) },
- { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
- USB_DEVICE_ID_WALTOP_PID_0038) },
- { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
- USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
- { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
- USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
- { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP,
- USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) },
- { }
- };
- MODULE_DEVICE_TABLE(hid, waltop_devices);
- static struct hid_driver waltop_driver = {
- .name = "waltop",
- .id_table = waltop_devices,
- .report_fixup = waltop_report_fixup,
- .raw_event = waltop_raw_event,
- };
- module_hid_driver(waltop_driver);
- MODULE_LICENSE("GPL");
|