mirror of https://gitee.com/openkylin/linux.git
Merge branch 'for-5.1/hid-uclogic' into for-linus
hid-uclogic driver revamp, in order to support wider range of Huion tablets, from Nikolai Kondrashov
This commit is contained in:
commit
487b6d0c87
|
@ -412,6 +412,12 @@ config HID_WALTOP
|
|||
---help---
|
||||
Support for Waltop tablets.
|
||||
|
||||
config HID_VIEWSONIC
|
||||
tristate "ViewSonic/Signotec"
|
||||
depends on HID
|
||||
help
|
||||
Support for ViewSonic/Signotec PD1011 signature pad.
|
||||
|
||||
config HID_GYRATION
|
||||
tristate "Gyration remote control"
|
||||
depends on HID
|
||||
|
|
|
@ -109,12 +109,16 @@ obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o
|
|||
obj-$(CONFIG_HID_TIVO) += hid-tivo.o
|
||||
obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o
|
||||
obj-$(CONFIG_HID_TWINHAN) += hid-twinhan.o
|
||||
hid-uclogic-objs := hid-uclogic-core.o \
|
||||
hid-uclogic-rdesc.o \
|
||||
hid-uclogic-params.o
|
||||
obj-$(CONFIG_HID_UCLOGIC) += hid-uclogic.o
|
||||
obj-$(CONFIG_HID_UDRAW_PS3) += hid-udraw-ps3.o
|
||||
obj-$(CONFIG_HID_LED) += hid-led.o
|
||||
obj-$(CONFIG_HID_XINMO) += hid-xinmo.o
|
||||
obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o
|
||||
obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o
|
||||
obj-$(CONFIG_HID_VIEWSONIC) += hid-viewsonic.o
|
||||
|
||||
wacom-objs := wacom_wac.o wacom_sys.o
|
||||
obj-$(CONFIG_HID_WACOM) += wacom.o
|
||||
|
|
|
@ -663,6 +663,7 @@
|
|||
#define USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2 0x501a
|
||||
#define USB_DEVICE_ID_KYE_EASYPEN_M610X 0x5013
|
||||
#define USB_DEVICE_ID_KYE_PENSKETCH_M912 0x5015
|
||||
#define USB_DEVICE_ID_KYE_EASYPEN_M406XE 0x5019
|
||||
|
||||
#define USB_VENDOR_ID_LABTEC 0x1020
|
||||
#define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006
|
||||
|
@ -1138,11 +1139,16 @@
|
|||
#define USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850 0x0522
|
||||
#define USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60 0x0781
|
||||
#define USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3 0x3031
|
||||
#define USB_DEVICE_ID_UGEE_TABLET_81 0x0081
|
||||
#define USB_DEVICE_ID_UGEE_TABLET_45 0x0045
|
||||
#define USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81 0x0081
|
||||
#define USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45 0x0045
|
||||
#define USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_47 0x0047
|
||||
#define USB_DEVICE_ID_YIYNOVA_TABLET 0x004d
|
||||
|
||||
#define USB_VENDOR_ID_UGEE 0x28bd
|
||||
#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540 0x0075
|
||||
#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640 0x0094
|
||||
#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01 0x0042
|
||||
#define USB_DEVICE_ID_UGEE_TABLET_G5 0x0074
|
||||
#define USB_DEVICE_ID_UGEE_TABLET_EX07S 0x0071
|
||||
|
||||
#define USB_VENDOR_ID_UNITEC 0x227d
|
||||
|
@ -1244,4 +1250,10 @@
|
|||
#define USB_VENDOR_ID_UGTIZER 0x2179
|
||||
#define USB_DEVICE_ID_UGTIZER_TABLET_GP0610 0x0053
|
||||
|
||||
#define USB_VENDOR_ID_VIEWSONIC 0x0543
|
||||
#define USB_DEVICE_ID_VIEWSONIC_PD1011 0xe621
|
||||
|
||||
#define USB_VENDOR_ID_SIGNOTEC 0x2133
|
||||
#define USB_DEVICE_ID_SIGNOTEC_VIEWSONIC_PD1011 0x0018
|
||||
|
||||
#endif
|
||||
|
|
|
@ -483,6 +483,80 @@ static __u8 pensketch_m912_rdesc_fixed[] = {
|
|||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
/* Original EasyPen M406XE report descriptor size */
|
||||
#define EASYPEN_M406XE_RDESC_ORIG_SIZE 476
|
||||
|
||||
/* Fixed EasyPen M406XE report descriptor */
|
||||
static __u8 easypen_m406xe_rdesc_fixed[] = {
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x01, /* Usage (01h), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
0x85, 0x05, /* Report ID (5), */
|
||||
0x09, 0x01, /* Usage (01h), */
|
||||
0x15, 0x80, /* Logical Minimum (-128), */
|
||||
0x25, 0x7F, /* Logical Maximum (127), */
|
||||
0x75, 0x08, /* Report Size (8), */
|
||||
0x95, 0x07, /* Report Count (7), */
|
||||
0xB1, 0x02, /* Feature (Variable), */
|
||||
0xC0, /* End Collection, */
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x02, /* Usage (Pen), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
0x85, 0x10, /* Report ID (16), */
|
||||
0x09, 0x20, /* Usage (Stylus), */
|
||||
0xA0, /* Collection (Physical), */
|
||||
0x14, /* Logical Minimum (0), */
|
||||
0x25, 0x01, /* Logical Maximum (1), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x09, 0x42, /* Usage (Tip Switch), */
|
||||
0x09, 0x44, /* Usage (Barrel Switch), */
|
||||
0x09, 0x46, /* Usage (Tablet Pick), */
|
||||
0x95, 0x03, /* Report Count (3), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x95, 0x04, /* Report Count (4), */
|
||||
0x81, 0x03, /* Input (Constant, Variable), */
|
||||
0x09, 0x32, /* Usage (In Range), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x75, 0x10, /* Report Size (16), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0xA4, /* Push, */
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x55, 0xFD, /* Unit Exponent (-3), */
|
||||
0x65, 0x13, /* Unit (Inch), */
|
||||
0x34, /* Physical Minimum (0), */
|
||||
0x09, 0x30, /* Usage (X), */
|
||||
0x46, 0x70, 0x17, /* Physical Maximum (6000), */
|
||||
0x26, 0x00, 0x3C, /* Logical Maximum (15360), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x09, 0x31, /* Usage (Y), */
|
||||
0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */
|
||||
0x26, 0x00, 0x28, /* Logical Maximum (10240), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0xB4, /* Pop, */
|
||||
0x09, 0x30, /* Usage (Tip Pressure), */
|
||||
0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0xC0, /* End Collection, */
|
||||
0xC0, /* End Collection */
|
||||
0x05, 0x0C, /* Usage Page (Consumer), */
|
||||
0x09, 0x01, /* Usage (Consumer Control), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
0x85, 0x12, /* Report ID (18), */
|
||||
0x14, /* Logical Minimum (0), */
|
||||
0x25, 0x01, /* Logical Maximum (1), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x95, 0x04, /* Report Count (4), */
|
||||
0x0A, 0x79, 0x02, /* Usage (AC Redo Or Repeat), */
|
||||
0x0A, 0x1A, 0x02, /* Usage (AC Undo), */
|
||||
0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */
|
||||
0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x95, 0x34, /* Report Count (52), */
|
||||
0x81, 0x03, /* Input (Constant, Variable), */
|
||||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
static __u8 *kye_consumer_control_fixup(struct hid_device *hdev, __u8 *rdesc,
|
||||
unsigned int *rsize, int offset, const char *device_name) {
|
||||
/*
|
||||
|
@ -555,6 +629,12 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
|
|||
*rsize = sizeof(easypen_m610x_rdesc_fixed);
|
||||
}
|
||||
break;
|
||||
case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
|
||||
if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
|
||||
rdesc = easypen_m406xe_rdesc_fixed;
|
||||
*rsize = sizeof(easypen_m406xe_rdesc_fixed);
|
||||
}
|
||||
break;
|
||||
case USB_DEVICE_ID_KYE_PENSKETCH_M912:
|
||||
if (*rsize == PENSKETCH_M912_RDESC_ORIG_SIZE) {
|
||||
rdesc = pensketch_m912_rdesc_fixed;
|
||||
|
@ -644,6 +724,7 @@ static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
|||
case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
|
||||
case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2:
|
||||
case USB_DEVICE_ID_KYE_EASYPEN_M610X:
|
||||
case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
|
||||
case USB_DEVICE_ID_KYE_PENSKETCH_M912:
|
||||
ret = kye_tablet_enable(hdev);
|
||||
if (ret) {
|
||||
|
@ -678,6 +759,8 @@ static const struct hid_device_id kye_devices[] = {
|
|||
USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
|
||||
USB_DEVICE_ID_KYE_EASYPEN_M610X) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
|
||||
USB_DEVICE_ID_KYE_EASYPEN_M406XE) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
|
||||
USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
|
||||
|
|
|
@ -99,6 +99,7 @@ static const struct hid_device_id hid_quirks[] = {
|
|||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X), HID_QUIRK_MULTI_INPUT },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2), HID_QUIRK_MULTI_INPUT },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_PENSKETCH_M912), HID_QUIRK_MULTI_INPUT },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M406XE), HID_QUIRK_MULTI_INPUT },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE_ID2), HID_QUIRK_ALWAYS_POLL },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_C007), HID_QUIRK_ALWAYS_POLL },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_C077), HID_QUIRK_ALWAYS_POLL },
|
||||
|
@ -411,11 +412,6 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
|||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_MANTICORE) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_GX_IMPERATOR) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_PENSKETCH_M912) },
|
||||
#endif
|
||||
#if IS_ENABLED(CONFIG_HID_LCPOWER)
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000) },
|
||||
|
@ -674,35 +670,9 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
|||
#if IS_ENABLED(CONFIG_HID_TWINHAN)
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) },
|
||||
#endif
|
||||
#if IS_ENABLED(CONFIG_HID_UCLOGIC)
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_TABLET) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_HUION_TABLET) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_YIYNOVA_TABLET) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_81) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_45) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) },
|
||||
#endif
|
||||
#if IS_ENABLED(CONFIG_HID_UDRAW_PS3)
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_THQ, USB_DEVICE_ID_THQ_PS3_UDRAW) },
|
||||
#endif
|
||||
#if IS_ENABLED(CONFIG_HID_WALTOP)
|
||||
{ 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) },
|
||||
#endif
|
||||
#if IS_ENABLED(CONFIG_HID_XINMO)
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_THT_2P_ARCADE) },
|
||||
|
|
|
@ -0,0 +1,418 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* HID driver for UC-Logic devices not fully compliant with HID standard
|
||||
*
|
||||
* Copyright (c) 2010-2014 Nikolai Kondrashov
|
||||
* Copyright (c) 2013 Martin Rusko
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/hid.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/timer.h>
|
||||
#include "usbhid/usbhid.h"
|
||||
#include "hid-uclogic-params.h"
|
||||
|
||||
#include "hid-ids.h"
|
||||
|
||||
/* Driver data */
|
||||
struct uclogic_drvdata {
|
||||
/* Interface parameters */
|
||||
struct uclogic_params params;
|
||||
/* Pointer to the replacement report descriptor. NULL if none. */
|
||||
__u8 *desc_ptr;
|
||||
/*
|
||||
* Size of the replacement report descriptor.
|
||||
* Only valid if desc_ptr is not NULL
|
||||
*/
|
||||
unsigned int desc_size;
|
||||
/* Pen input device */
|
||||
struct input_dev *pen_input;
|
||||
/* In-range timer */
|
||||
struct timer_list inrange_timer;
|
||||
/* Last rotary encoder state, or U8_MAX for none */
|
||||
u8 re_state;
|
||||
};
|
||||
|
||||
/**
|
||||
* uclogic_inrange_timeout - handle pen in-range state timeout.
|
||||
* Emulate input events normally generated when pen goes out of range for
|
||||
* tablets which don't report that.
|
||||
*
|
||||
* @t: The timer the timeout handler is attached to, stored in a struct
|
||||
* uclogic_drvdata.
|
||||
*/
|
||||
static void uclogic_inrange_timeout(struct timer_list *t)
|
||||
{
|
||||
struct uclogic_drvdata *drvdata = from_timer(drvdata, t,
|
||||
inrange_timer);
|
||||
struct input_dev *input = drvdata->pen_input;
|
||||
|
||||
if (input == NULL)
|
||||
return;
|
||||
input_report_abs(input, ABS_PRESSURE, 0);
|
||||
/* If BTN_TOUCH state is changing */
|
||||
if (test_bit(BTN_TOUCH, input->key)) {
|
||||
input_event(input, EV_MSC, MSC_SCAN,
|
||||
/* Digitizer Tip Switch usage */
|
||||
0xd0042);
|
||||
input_report_key(input, BTN_TOUCH, 0);
|
||||
}
|
||||
input_report_key(input, BTN_TOOL_PEN, 0);
|
||||
input_sync(input);
|
||||
}
|
||||
|
||||
static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
|
||||
unsigned int *rsize)
|
||||
{
|
||||
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
|
||||
|
||||
if (drvdata->desc_ptr != NULL) {
|
||||
rdesc = drvdata->desc_ptr;
|
||||
*rsize = drvdata->desc_size;
|
||||
}
|
||||
return rdesc;
|
||||
}
|
||||
|
||||
static int uclogic_input_mapping(struct hid_device *hdev,
|
||||
struct hid_input *hi,
|
||||
struct hid_field *field,
|
||||
struct hid_usage *usage,
|
||||
unsigned long **bit,
|
||||
int *max)
|
||||
{
|
||||
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
|
||||
struct uclogic_params *params = &drvdata->params;
|
||||
|
||||
/* discard the unused pen interface */
|
||||
if (params->pen_unused && (field->application == HID_DG_PEN))
|
||||
return -1;
|
||||
|
||||
/* let hid-core decide what to do */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uclogic_input_configured(struct hid_device *hdev,
|
||||
struct hid_input *hi)
|
||||
{
|
||||
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
|
||||
struct uclogic_params *params = &drvdata->params;
|
||||
char *name;
|
||||
const char *suffix = NULL;
|
||||
struct hid_field *field;
|
||||
size_t len;
|
||||
|
||||
/* no report associated (HID_QUIRK_MULTI_INPUT not set) */
|
||||
if (!hi->report)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* If this is the input corresponding to the pen report
|
||||
* in need of tweaking.
|
||||
*/
|
||||
if (hi->report->id == params->pen.id) {
|
||||
/* Remember the input device so we can simulate events */
|
||||
drvdata->pen_input = hi->input;
|
||||
}
|
||||
|
||||
field = hi->report->field[0];
|
||||
|
||||
switch (field->application) {
|
||||
case HID_GD_KEYBOARD:
|
||||
suffix = "Keyboard";
|
||||
break;
|
||||
case HID_GD_MOUSE:
|
||||
suffix = "Mouse";
|
||||
break;
|
||||
case HID_GD_KEYPAD:
|
||||
suffix = "Pad";
|
||||
break;
|
||||
case HID_DG_PEN:
|
||||
suffix = "Pen";
|
||||
break;
|
||||
case HID_CP_CONSUMER_CONTROL:
|
||||
suffix = "Consumer Control";
|
||||
break;
|
||||
case HID_GD_SYSTEM_CONTROL:
|
||||
suffix = "System Control";
|
||||
break;
|
||||
}
|
||||
|
||||
if (suffix) {
|
||||
len = strlen(hdev->name) + 2 + strlen(suffix);
|
||||
name = devm_kzalloc(&hi->input->dev, len, GFP_KERNEL);
|
||||
if (name) {
|
||||
snprintf(name, len, "%s %s", hdev->name, suffix);
|
||||
hi->input->name = name;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uclogic_probe(struct hid_device *hdev,
|
||||
const struct hid_device_id *id)
|
||||
{
|
||||
int rc;
|
||||
struct uclogic_drvdata *drvdata = NULL;
|
||||
bool params_initialized = false;
|
||||
|
||||
/*
|
||||
* libinput requires the pad interface to be on a different node
|
||||
* than the pen, so use QUIRK_MULTI_INPUT for all tablets.
|
||||
*/
|
||||
hdev->quirks |= HID_QUIRK_MULTI_INPUT;
|
||||
|
||||
/* Allocate and assign driver data */
|
||||
drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
|
||||
if (drvdata == NULL) {
|
||||
rc = -ENOMEM;
|
||||
goto failure;
|
||||
}
|
||||
timer_setup(&drvdata->inrange_timer, uclogic_inrange_timeout, 0);
|
||||
drvdata->re_state = U8_MAX;
|
||||
hid_set_drvdata(hdev, drvdata);
|
||||
|
||||
/* Initialize the device and retrieve interface parameters */
|
||||
rc = uclogic_params_init(&drvdata->params, hdev);
|
||||
if (rc != 0) {
|
||||
hid_err(hdev, "failed probing parameters: %d\n", rc);
|
||||
goto failure;
|
||||
}
|
||||
params_initialized = true;
|
||||
hid_dbg(hdev, "parameters:\n" UCLOGIC_PARAMS_FMT_STR,
|
||||
UCLOGIC_PARAMS_FMT_ARGS(&drvdata->params));
|
||||
if (drvdata->params.invalid) {
|
||||
hid_info(hdev, "interface is invalid, ignoring\n");
|
||||
rc = -ENODEV;
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/* Generate replacement report descriptor */
|
||||
rc = uclogic_params_get_desc(&drvdata->params,
|
||||
&drvdata->desc_ptr,
|
||||
&drvdata->desc_size);
|
||||
if (rc) {
|
||||
hid_err(hdev,
|
||||
"failed generating replacement report descriptor: %d\n",
|
||||
rc);
|
||||
goto failure;
|
||||
}
|
||||
|
||||
rc = hid_parse(hdev);
|
||||
if (rc) {
|
||||
hid_err(hdev, "parse failed\n");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
rc = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
|
||||
if (rc) {
|
||||
hid_err(hdev, "hw start failed\n");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
return 0;
|
||||
failure:
|
||||
/* Assume "remove" might not be called if "probe" failed */
|
||||
if (params_initialized)
|
||||
uclogic_params_cleanup(&drvdata->params);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int uclogic_resume(struct hid_device *hdev)
|
||||
{
|
||||
int rc;
|
||||
struct uclogic_params params;
|
||||
|
||||
/* Re-initialize the device, but discard parameters */
|
||||
rc = uclogic_params_init(¶ms, hdev);
|
||||
if (rc != 0)
|
||||
hid_err(hdev, "failed to re-initialize the device\n");
|
||||
else
|
||||
uclogic_params_cleanup(¶ms);
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int uclogic_raw_event(struct hid_device *hdev,
|
||||
struct hid_report *report,
|
||||
u8 *data, int size)
|
||||
{
|
||||
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
|
||||
struct uclogic_params *params = &drvdata->params;
|
||||
|
||||
/* Tweak pen reports, if necessary */
|
||||
if (!params->pen_unused &&
|
||||
(report->type == HID_INPUT_REPORT) &&
|
||||
(report->id == params->pen.id) &&
|
||||
(size >= 2)) {
|
||||
/* If it's the "virtual" frame controls report */
|
||||
if (params->frame.id != 0 &&
|
||||
data[1] & params->pen_frame_flag) {
|
||||
/* Change to virtual frame controls report ID */
|
||||
data[0] = params->frame.id;
|
||||
return 0;
|
||||
}
|
||||
/* If in-range reports are inverted */
|
||||
if (params->pen.inrange ==
|
||||
UCLOGIC_PARAMS_PEN_INRANGE_INVERTED) {
|
||||
/* Invert the in-range bit */
|
||||
data[1] ^= 0x40;
|
||||
}
|
||||
/*
|
||||
* If report contains fragmented high-resolution pen
|
||||
* coordinates
|
||||
*/
|
||||
if (size >= 10 && params->pen.fragmented_hires) {
|
||||
u8 pressure_low_byte;
|
||||
u8 pressure_high_byte;
|
||||
|
||||
/* Lift pressure bytes */
|
||||
pressure_low_byte = data[6];
|
||||
pressure_high_byte = data[7];
|
||||
/*
|
||||
* Move Y coord to make space for high-order X
|
||||
* coord byte
|
||||
*/
|
||||
data[6] = data[5];
|
||||
data[5] = data[4];
|
||||
/* Move high-order X coord byte */
|
||||
data[4] = data[8];
|
||||
/* Move high-order Y coord byte */
|
||||
data[7] = data[9];
|
||||
/* Place pressure bytes */
|
||||
data[8] = pressure_low_byte;
|
||||
data[9] = pressure_high_byte;
|
||||
}
|
||||
/* If we need to emulate in-range detection */
|
||||
if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) {
|
||||
/* Set in-range bit */
|
||||
data[1] |= 0x40;
|
||||
/* (Re-)start in-range timeout */
|
||||
mod_timer(&drvdata->inrange_timer,
|
||||
jiffies + msecs_to_jiffies(100));
|
||||
}
|
||||
}
|
||||
|
||||
/* Tweak frame control reports, if necessary */
|
||||
if ((report->type == HID_INPUT_REPORT) &&
|
||||
(report->id == params->frame.id)) {
|
||||
/* If need to, and can, set pad device ID for Wacom drivers */
|
||||
if (params->frame.dev_id_byte > 0 &&
|
||||
params->frame.dev_id_byte < size) {
|
||||
data[params->frame.dev_id_byte] = 0xf;
|
||||
}
|
||||
/* If need to, and can, read rotary encoder state change */
|
||||
if (params->frame.re_lsb > 0 &&
|
||||
params->frame.re_lsb / 8 < size) {
|
||||
unsigned int byte = params->frame.re_lsb / 8;
|
||||
unsigned int bit = params->frame.re_lsb % 8;
|
||||
|
||||
u8 change;
|
||||
u8 prev_state = drvdata->re_state;
|
||||
/* Read Gray-coded state */
|
||||
u8 state = (data[byte] >> bit) & 0x3;
|
||||
/* Encode state change into 2-bit signed integer */
|
||||
if ((prev_state == 1 && state == 0) ||
|
||||
(prev_state == 2 && state == 3)) {
|
||||
change = 1;
|
||||
} else if ((prev_state == 2 && state == 0) ||
|
||||
(prev_state == 1 && state == 3)) {
|
||||
change = 3;
|
||||
} else {
|
||||
change = 0;
|
||||
}
|
||||
/* Write change */
|
||||
data[byte] = (data[byte] & ~((u8)3 << bit)) |
|
||||
(change << bit);
|
||||
/* Remember state */
|
||||
drvdata->re_state = state;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void uclogic_remove(struct hid_device *hdev)
|
||||
{
|
||||
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
|
||||
|
||||
del_timer_sync(&drvdata->inrange_timer);
|
||||
hid_hw_stop(hdev);
|
||||
kfree(drvdata->desc_ptr);
|
||||
uclogic_params_cleanup(&drvdata->params);
|
||||
}
|
||||
|
||||
static const struct hid_device_id uclogic_devices[] = {
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_HUION,
|
||||
USB_DEVICE_ID_HUION_TABLET) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_HUION_TABLET) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_YIYNOVA_TABLET) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_47) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER,
|
||||
USB_DEVICE_ID_UGTIZER_TABLET_GP0610) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE,
|
||||
USB_DEVICE_ID_UGEE_TABLET_G5) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE,
|
||||
USB_DEVICE_ID_UGEE_TABLET_EX07S) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE,
|
||||
USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE,
|
||||
USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE,
|
||||
USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01) },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(hid, uclogic_devices);
|
||||
|
||||
static struct hid_driver uclogic_driver = {
|
||||
.name = "uclogic",
|
||||
.id_table = uclogic_devices,
|
||||
.probe = uclogic_probe,
|
||||
.remove = uclogic_remove,
|
||||
.report_fixup = uclogic_report_fixup,
|
||||
.raw_event = uclogic_raw_event,
|
||||
.input_mapping = uclogic_input_mapping,
|
||||
.input_configured = uclogic_input_configured,
|
||||
#ifdef CONFIG_PM
|
||||
.resume = uclogic_resume,
|
||||
.reset_resume = uclogic_resume,
|
||||
#endif
|
||||
};
|
||||
module_hid_driver(uclogic_driver);
|
||||
|
||||
MODULE_AUTHOR("Martin Rusko");
|
||||
MODULE_AUTHOR("Nikolai Kondrashov");
|
||||
MODULE_LICENSE("GPL");
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,207 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* HID driver for UC-Logic devices not fully compliant with HID standard
|
||||
* - tablet initialization and parameter retrieval
|
||||
*
|
||||
* Copyright (c) 2018 Nikolai Kondrashov
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*/
|
||||
|
||||
#ifndef _HID_UCLOGIC_PARAMS_H
|
||||
#define _HID_UCLOGIC_PARAMS_H
|
||||
|
||||
#include <linux/usb.h>
|
||||
#include <linux/hid.h>
|
||||
|
||||
/* Types of pen in-range reporting */
|
||||
enum uclogic_params_pen_inrange {
|
||||
/* Normal reports: zero - out of proximity, one - in proximity */
|
||||
UCLOGIC_PARAMS_PEN_INRANGE_NORMAL = 0,
|
||||
/* Inverted reports: zero - in proximity, one - out of proximity */
|
||||
UCLOGIC_PARAMS_PEN_INRANGE_INVERTED,
|
||||
/* No reports */
|
||||
UCLOGIC_PARAMS_PEN_INRANGE_NONE,
|
||||
};
|
||||
|
||||
/* Convert a pen in-range reporting type to a string */
|
||||
extern const char *uclogic_params_pen_inrange_to_str(
|
||||
enum uclogic_params_pen_inrange inrange);
|
||||
|
||||
/*
|
||||
* Tablet interface's pen input parameters.
|
||||
*
|
||||
* Must use declarative (descriptive) language, not imperative, to simplify
|
||||
* understanding and maintain consistency.
|
||||
*
|
||||
* Noop (preserving functionality) when filled with zeroes.
|
||||
*/
|
||||
struct uclogic_params_pen {
|
||||
/*
|
||||
* Pointer to report descriptor describing the inputs.
|
||||
* Allocated with kmalloc.
|
||||
*/
|
||||
__u8 *desc_ptr;
|
||||
/*
|
||||
* Size of the report descriptor.
|
||||
* Only valid, if "desc_ptr" is not NULL.
|
||||
*/
|
||||
unsigned int desc_size;
|
||||
/* Report ID, if reports should be tweaked, zero if not */
|
||||
unsigned int id;
|
||||
/* Type of in-range reporting, only valid if "id" is not zero */
|
||||
enum uclogic_params_pen_inrange inrange;
|
||||
/*
|
||||
* True, if reports include fragmented high resolution coords, with
|
||||
* high-order X and then Y bytes following the pressure field.
|
||||
* Only valid if "id" is not zero.
|
||||
*/
|
||||
bool fragmented_hires;
|
||||
};
|
||||
|
||||
/*
|
||||
* Parameters of frame control inputs of a tablet interface.
|
||||
*
|
||||
* Must use declarative (descriptive) language, not imperative, to simplify
|
||||
* understanding and maintain consistency.
|
||||
*
|
||||
* Noop (preserving functionality) when filled with zeroes.
|
||||
*/
|
||||
struct uclogic_params_frame {
|
||||
/*
|
||||
* Pointer to report descriptor describing the inputs.
|
||||
* Allocated with kmalloc.
|
||||
*/
|
||||
__u8 *desc_ptr;
|
||||
/*
|
||||
* Size of the report descriptor.
|
||||
* Only valid, if "desc_ptr" is not NULL.
|
||||
*/
|
||||
unsigned int desc_size;
|
||||
/*
|
||||
* Report ID, if reports should be tweaked, zero if not.
|
||||
*/
|
||||
unsigned int id;
|
||||
/*
|
||||
* Number of the least-significant bit of the 2-bit state of a rotary
|
||||
* encoder, in the report. Cannot point to a 2-bit field crossing a
|
||||
* byte boundary. Zero if not present. Only valid if "id" is not zero.
|
||||
*/
|
||||
unsigned int re_lsb;
|
||||
/*
|
||||
* Offset of the Wacom-style device ID byte in the report, to be set
|
||||
* to pad device ID (0xf), for compatibility with Wacom drivers. Zero
|
||||
* if no changes to the report should be made. Only valid if "id" is
|
||||
* not zero.
|
||||
*/
|
||||
unsigned int dev_id_byte;
|
||||
};
|
||||
|
||||
/*
|
||||
* Tablet interface report parameters.
|
||||
*
|
||||
* Must use declarative (descriptive) language, not imperative, to simplify
|
||||
* understanding and maintain consistency.
|
||||
*
|
||||
* When filled with zeros represents a "noop" configuration - passes all
|
||||
* reports unchanged and lets the generic HID driver handle everything.
|
||||
*
|
||||
* The resulting device report descriptor is assembled from all the report
|
||||
* descriptor parts referenced by the structure. No order of assembly should
|
||||
* be assumed. The structure represents original device report descriptor if
|
||||
* all the parts are NULL.
|
||||
*/
|
||||
struct uclogic_params {
|
||||
/*
|
||||
* True if the whole interface is invalid, false otherwise.
|
||||
*/
|
||||
bool invalid;
|
||||
/*
|
||||
* Pointer to the common part of the replacement report descriptor,
|
||||
* allocated with kmalloc. NULL if no common part is needed.
|
||||
* Only valid, if "invalid" is false.
|
||||
*/
|
||||
__u8 *desc_ptr;
|
||||
/*
|
||||
* Size of the common part of the replacement report descriptor.
|
||||
* Only valid, if "desc_ptr" is not NULL.
|
||||
*/
|
||||
unsigned int desc_size;
|
||||
/*
|
||||
* True, if pen usage in report descriptor is invalid, when present.
|
||||
* Only valid, if "invalid" is false.
|
||||
*/
|
||||
bool pen_unused;
|
||||
/*
|
||||
* Pen parameters and optional report descriptor part.
|
||||
* Only valid if "pen_unused" is valid and false.
|
||||
*/
|
||||
struct uclogic_params_pen pen;
|
||||
/*
|
||||
* Frame control parameters and optional report descriptor part.
|
||||
* Only valid, if "invalid" is false.
|
||||
*/
|
||||
struct uclogic_params_frame frame;
|
||||
/*
|
||||
* Bitmask matching frame controls "sub-report" flag in the second
|
||||
* byte of the pen report, or zero if it's not expected.
|
||||
* Only valid if both "pen" and "frame" are valid, and "frame.id" is
|
||||
* not zero.
|
||||
*/
|
||||
__u8 pen_frame_flag;
|
||||
};
|
||||
|
||||
/* Initialize a tablet interface and discover its parameters */
|
||||
extern int uclogic_params_init(struct uclogic_params *params,
|
||||
struct hid_device *hdev);
|
||||
|
||||
/* Tablet interface parameters *printf format string */
|
||||
#define UCLOGIC_PARAMS_FMT_STR \
|
||||
".invalid = %s\n" \
|
||||
".desc_ptr = %p\n" \
|
||||
".desc_size = %u\n" \
|
||||
".pen_unused = %s\n" \
|
||||
".pen.desc_ptr = %p\n" \
|
||||
".pen.desc_size = %u\n" \
|
||||
".pen.id = %u\n" \
|
||||
".pen.inrange = %s\n" \
|
||||
".pen.fragmented_hires = %s\n" \
|
||||
".frame.desc_ptr = %p\n" \
|
||||
".frame.desc_size = %u\n" \
|
||||
".frame.id = %u\n" \
|
||||
".frame.re_lsb = %u\n" \
|
||||
".frame.dev_id_byte = %u\n" \
|
||||
".pen_frame_flag = 0x%02x\n"
|
||||
|
||||
/* Tablet interface parameters *printf format arguments */
|
||||
#define UCLOGIC_PARAMS_FMT_ARGS(_params) \
|
||||
((_params)->invalid ? "true" : "false"), \
|
||||
(_params)->desc_ptr, \
|
||||
(_params)->desc_size, \
|
||||
((_params)->pen_unused ? "true" : "false"), \
|
||||
(_params)->pen.desc_ptr, \
|
||||
(_params)->pen.desc_size, \
|
||||
(_params)->pen.id, \
|
||||
uclogic_params_pen_inrange_to_str((_params)->pen.inrange), \
|
||||
((_params)->pen.fragmented_hires ? "true" : "false"), \
|
||||
(_params)->frame.desc_ptr, \
|
||||
(_params)->frame.desc_size, \
|
||||
(_params)->frame.id, \
|
||||
(_params)->frame.re_lsb, \
|
||||
(_params)->frame.dev_id_byte, \
|
||||
(_params)->pen_frame_flag
|
||||
|
||||
/* Get a replacement report descriptor for a tablet's interface. */
|
||||
extern int uclogic_params_get_desc(const struct uclogic_params *params,
|
||||
__u8 **pdesc,
|
||||
unsigned int *psize);
|
||||
|
||||
/* Free resources used by tablet interface's parameters */
|
||||
extern void uclogic_params_cleanup(struct uclogic_params *params);
|
||||
|
||||
#endif /* _HID_UCLOGIC_PARAMS_H */
|
|
@ -1,7 +1,9 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* HID driver for UC-Logic devices not fully compliant with HID standard
|
||||
* - original and fixed report descriptors
|
||||
*
|
||||
* Copyright (c) 2010-2014 Nikolai Kondrashov
|
||||
* Copyright (c) 2010-2017 Nikolai Kondrashov
|
||||
* Copyright (c) 2013 Martin Rusko
|
||||
*/
|
||||
|
||||
|
@ -12,20 +14,12 @@
|
|||
* any later version.
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/hid.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/usb.h>
|
||||
#include "hid-uclogic-rdesc.h"
|
||||
#include <linux/slab.h>
|
||||
#include <asm/unaligned.h>
|
||||
#include "usbhid/usbhid.h"
|
||||
|
||||
#include "hid-ids.h"
|
||||
|
||||
/* Size of the original descriptor of WPXXXXU tablets */
|
||||
#define WPXXXXU_RDESC_ORIG_SIZE 212
|
||||
|
||||
/* Fixed WP4030U report descriptor */
|
||||
static __u8 wp4030u_rdesc_fixed[] = {
|
||||
__u8 uclogic_rdesc_wp4030u_fixed_arr[] = {
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x02, /* Usage (Pen), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
|
@ -66,8 +60,11 @@ static __u8 wp4030u_rdesc_fixed[] = {
|
|||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
const size_t uclogic_rdesc_wp4030u_fixed_size =
|
||||
sizeof(uclogic_rdesc_wp4030u_fixed_arr);
|
||||
|
||||
/* Fixed WP5540U report descriptor */
|
||||
static __u8 wp5540u_rdesc_fixed[] = {
|
||||
__u8 uclogic_rdesc_wp5540u_fixed_arr[] = {
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x02, /* Usage (Pen), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
|
@ -140,8 +137,11 @@ static __u8 wp5540u_rdesc_fixed[] = {
|
|||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
const size_t uclogic_rdesc_wp5540u_fixed_size =
|
||||
sizeof(uclogic_rdesc_wp5540u_fixed_arr);
|
||||
|
||||
/* Fixed WP8060U report descriptor */
|
||||
static __u8 wp8060u_rdesc_fixed[] = {
|
||||
__u8 uclogic_rdesc_wp8060u_fixed_arr[] = {
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x02, /* Usage (Pen), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
|
@ -214,11 +214,11 @@ static __u8 wp8060u_rdesc_fixed[] = {
|
|||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
/* Size of the original descriptor of WP1062 tablet */
|
||||
#define WP1062_RDESC_ORIG_SIZE 254
|
||||
const size_t uclogic_rdesc_wp8060u_fixed_size =
|
||||
sizeof(uclogic_rdesc_wp8060u_fixed_arr);
|
||||
|
||||
/* Fixed WP1062 report descriptor */
|
||||
static __u8 wp1062_rdesc_fixed[] = {
|
||||
__u8 uclogic_rdesc_wp1062_fixed_arr[] = {
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x02, /* Usage (Pen), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
|
@ -262,11 +262,11 @@ static __u8 wp1062_rdesc_fixed[] = {
|
|||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
/* Size of the original descriptor of PF1209 tablet */
|
||||
#define PF1209_RDESC_ORIG_SIZE 234
|
||||
const size_t uclogic_rdesc_wp1062_fixed_size =
|
||||
sizeof(uclogic_rdesc_wp1062_fixed_arr);
|
||||
|
||||
/* Fixed PF1209 report descriptor */
|
||||
static __u8 pf1209_rdesc_fixed[] = {
|
||||
__u8 uclogic_rdesc_pf1209_fixed_arr[] = {
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x02, /* Usage (Pen), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
|
@ -339,13 +339,11 @@ static __u8 pf1209_rdesc_fixed[] = {
|
|||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
/* Size of the original descriptors of TWHL850 tablet */
|
||||
#define TWHL850_RDESC_ORIG_SIZE0 182
|
||||
#define TWHL850_RDESC_ORIG_SIZE1 161
|
||||
#define TWHL850_RDESC_ORIG_SIZE2 92
|
||||
const size_t uclogic_rdesc_pf1209_fixed_size =
|
||||
sizeof(uclogic_rdesc_pf1209_fixed_arr);
|
||||
|
||||
/* Fixed PID 0522 tablet report descriptor, interface 0 (stylus) */
|
||||
static __u8 twhl850_rdesc_fixed0[] = {
|
||||
__u8 uclogic_rdesc_twhl850_fixed0_arr[] = {
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x02, /* Usage (Pen), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
|
@ -387,8 +385,11 @@ static __u8 twhl850_rdesc_fixed0[] = {
|
|||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
const size_t uclogic_rdesc_twhl850_fixed0_size =
|
||||
sizeof(uclogic_rdesc_twhl850_fixed0_arr);
|
||||
|
||||
/* Fixed PID 0522 tablet report descriptor, interface 1 (mouse) */
|
||||
static __u8 twhl850_rdesc_fixed1[] = {
|
||||
__u8 uclogic_rdesc_twhl850_fixed1_arr[] = {
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x02, /* Usage (Mouse), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
|
@ -424,8 +425,11 @@ static __u8 twhl850_rdesc_fixed1[] = {
|
|||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
const size_t uclogic_rdesc_twhl850_fixed1_size =
|
||||
sizeof(uclogic_rdesc_twhl850_fixed1_arr);
|
||||
|
||||
/* Fixed PID 0522 tablet report descriptor, interface 2 (frame buttons) */
|
||||
static __u8 twhl850_rdesc_fixed2[] = {
|
||||
__u8 uclogic_rdesc_twhl850_fixed2_arr[] = {
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x06, /* Usage (Keyboard), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
|
@ -447,12 +451,11 @@ static __u8 twhl850_rdesc_fixed2[] = {
|
|||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
/* Size of the original descriptors of TWHA60 tablet */
|
||||
#define TWHA60_RDESC_ORIG_SIZE0 254
|
||||
#define TWHA60_RDESC_ORIG_SIZE1 139
|
||||
const size_t uclogic_rdesc_twhl850_fixed2_size =
|
||||
sizeof(uclogic_rdesc_twhl850_fixed2_arr);
|
||||
|
||||
/* Fixed TWHA60 report descriptor, interface 0 (stylus) */
|
||||
static __u8 twha60_rdesc_fixed0[] = {
|
||||
__u8 uclogic_rdesc_twha60_fixed0_arr[] = {
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x02, /* Usage (Pen), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
|
@ -497,8 +500,11 @@ static __u8 twha60_rdesc_fixed0[] = {
|
|||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
const size_t uclogic_rdesc_twha60_fixed0_size =
|
||||
sizeof(uclogic_rdesc_twha60_fixed0_arr);
|
||||
|
||||
/* Fixed TWHA60 report descriptor, interface 1 (frame buttons) */
|
||||
static __u8 twha60_rdesc_fixed1[] = {
|
||||
__u8 uclogic_rdesc_twha60_fixed1_arr[] = {
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x06, /* Usage (Keyboard), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
|
@ -522,25 +528,11 @@ static __u8 twha60_rdesc_fixed1[] = {
|
|||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
/* Report descriptor template placeholder head */
|
||||
#define UCLOGIC_PH_HEAD 0xFE, 0xED, 0x1D
|
||||
const size_t uclogic_rdesc_twha60_fixed1_size =
|
||||
sizeof(uclogic_rdesc_twha60_fixed1_arr);
|
||||
|
||||
/* Report descriptor template placeholder IDs */
|
||||
enum uclogic_ph_id {
|
||||
UCLOGIC_PH_ID_X_LM,
|
||||
UCLOGIC_PH_ID_X_PM,
|
||||
UCLOGIC_PH_ID_Y_LM,
|
||||
UCLOGIC_PH_ID_Y_PM,
|
||||
UCLOGIC_PH_ID_PRESSURE_LM,
|
||||
UCLOGIC_PH_ID_NUM
|
||||
};
|
||||
|
||||
/* Report descriptor template placeholder */
|
||||
#define UCLOGIC_PH(_ID) UCLOGIC_PH_HEAD, UCLOGIC_PH_ID_##_ID
|
||||
#define UCLOGIC_PEN_REPORT_ID 0x07
|
||||
|
||||
/* Fixed report descriptor template */
|
||||
static const __u8 uclogic_tablet_rdesc_template[] = {
|
||||
/* Fixed report descriptor template for (tweaked) v1 pen reports */
|
||||
const __u8 uclogic_rdesc_pen_v1_template_arr[] = {
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x02, /* Usage (Pen), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
|
@ -570,521 +562,301 @@ static const __u8 uclogic_tablet_rdesc_template[] = {
|
|||
0x55, 0xFD, /* Unit Exponent (-3), */
|
||||
0x34, /* Physical Minimum (0), */
|
||||
0x09, 0x30, /* Usage (X), */
|
||||
0x27, UCLOGIC_PH(X_LM), /* Logical Maximum (PLACEHOLDER), */
|
||||
0x47, UCLOGIC_PH(X_PM), /* Physical Maximum (PLACEHOLDER), */
|
||||
0x27, UCLOGIC_RDESC_PEN_PH(X_LM),
|
||||
/* Logical Maximum (PLACEHOLDER), */
|
||||
0x47, UCLOGIC_RDESC_PEN_PH(X_PM),
|
||||
/* Physical Maximum (PLACEHOLDER), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x09, 0x31, /* Usage (Y), */
|
||||
0x27, UCLOGIC_PH(Y_LM), /* Logical Maximum (PLACEHOLDER), */
|
||||
0x47, UCLOGIC_PH(Y_PM), /* Physical Maximum (PLACEHOLDER), */
|
||||
0x27, UCLOGIC_RDESC_PEN_PH(Y_LM),
|
||||
/* Logical Maximum (PLACEHOLDER), */
|
||||
0x47, UCLOGIC_RDESC_PEN_PH(Y_PM),
|
||||
/* Physical Maximum (PLACEHOLDER), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0xB4, /* Pop, */
|
||||
0x09, 0x30, /* Usage (Tip Pressure), */
|
||||
0x27,
|
||||
UCLOGIC_PH(PRESSURE_LM),/* Logical Maximum (PLACEHOLDER), */
|
||||
0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM),
|
||||
/* Logical Maximum (PLACEHOLDER), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0xC0, /* End Collection, */
|
||||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
/* Fixed virtual pad report descriptor */
|
||||
static const __u8 uclogic_buttonpad_rdesc[] = {
|
||||
const size_t uclogic_rdesc_pen_v1_template_size =
|
||||
sizeof(uclogic_rdesc_pen_v1_template_arr);
|
||||
|
||||
/* Fixed report descriptor template for (tweaked) v2 pen reports */
|
||||
const __u8 uclogic_rdesc_pen_v2_template_arr[] = {
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x02, /* Usage (Pen), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
0x85, 0x08, /* Report ID (8), */
|
||||
0x09, 0x20, /* Usage (Stylus), */
|
||||
0xA0, /* Collection (Physical), */
|
||||
0x14, /* Logical Minimum (0), */
|
||||
0x25, 0x01, /* Logical Maximum (1), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x09, 0x42, /* Usage (Tip Switch), */
|
||||
0x09, 0x44, /* Usage (Barrel Switch), */
|
||||
0x09, 0x46, /* Usage (Tablet Pick), */
|
||||
0x95, 0x03, /* Report Count (3), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x95, 0x03, /* Report Count (3), */
|
||||
0x81, 0x03, /* Input (Constant, Variable), */
|
||||
0x09, 0x32, /* Usage (In Range), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x81, 0x03, /* Input (Constant, Variable), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0xA4, /* Push, */
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x65, 0x13, /* Unit (Inch), */
|
||||
0x55, 0xFD, /* Unit Exponent (-3), */
|
||||
0x75, 0x18, /* Report Size (24), */
|
||||
0x34, /* Physical Minimum (0), */
|
||||
0x09, 0x30, /* Usage (X), */
|
||||
0x27, UCLOGIC_RDESC_PEN_PH(X_LM),
|
||||
/* Logical Maximum (PLACEHOLDER), */
|
||||
0x47, UCLOGIC_RDESC_PEN_PH(X_PM),
|
||||
/* Physical Maximum (PLACEHOLDER), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x09, 0x31, /* Usage (Y), */
|
||||
0x27, UCLOGIC_RDESC_PEN_PH(Y_LM),
|
||||
/* Logical Maximum (PLACEHOLDER), */
|
||||
0x47, UCLOGIC_RDESC_PEN_PH(Y_PM),
|
||||
/* Physical Maximum (PLACEHOLDER), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0xB4, /* Pop, */
|
||||
0x09, 0x30, /* Usage (Tip Pressure), */
|
||||
0x75, 0x10, /* Report Size (16), */
|
||||
0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM),
|
||||
/* Logical Maximum (PLACEHOLDER), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x81, 0x03, /* Input (Constant, Variable), */
|
||||
0xC0, /* End Collection, */
|
||||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
const size_t uclogic_rdesc_pen_v2_template_size =
|
||||
sizeof(uclogic_rdesc_pen_v2_template_arr);
|
||||
|
||||
/**
|
||||
* Expand to the contents of a generic buttonpad report descriptor.
|
||||
*
|
||||
* @_padding: Padding from the end of button bits at bit 44, until
|
||||
* the end of the report, in bits.
|
||||
*/
|
||||
#define UCLOGIC_RDESC_BUTTONPAD_BYTES(_padding) \
|
||||
0x05, 0x01, /* Usage Page (Desktop), */ \
|
||||
0x09, 0x07, /* Usage (Keypad), */ \
|
||||
0xA1, 0x01, /* Collection (Application), */ \
|
||||
0x85, 0xF7, /* Report ID (247), */ \
|
||||
0x14, /* Logical Minimum (0), */ \
|
||||
0x25, 0x01, /* Logical Maximum (1), */ \
|
||||
0x75, 0x01, /* Report Size (1), */ \
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */ \
|
||||
0x09, 0x39, /* Usage (Tablet Function Keys), */ \
|
||||
0xA0, /* Collection (Physical), */ \
|
||||
0x09, 0x44, /* Usage (Barrel Switch), */ \
|
||||
0x95, 0x01, /* Report Count (1), */ \
|
||||
0x81, 0x02, /* Input (Variable), */ \
|
||||
0x05, 0x01, /* Usage Page (Desktop), */ \
|
||||
0x09, 0x30, /* Usage (X), */ \
|
||||
0x09, 0x31, /* Usage (Y), */ \
|
||||
0x95, 0x02, /* Report Count (2), */ \
|
||||
0x81, 0x02, /* Input (Variable), */ \
|
||||
0x95, 0x15, /* Report Count (21), */ \
|
||||
0x81, 0x01, /* Input (Constant), */ \
|
||||
0x05, 0x09, /* Usage Page (Button), */ \
|
||||
0x19, 0x01, /* Usage Minimum (01h), */ \
|
||||
0x29, 0x0A, /* Usage Maximum (0Ah), */ \
|
||||
0x95, 0x0A, /* Report Count (10), */ \
|
||||
0x81, 0x02, /* Input (Variable), */ \
|
||||
0xC0, /* End Collection, */ \
|
||||
0x05, 0x01, /* Usage Page (Desktop), */ \
|
||||
0x09, 0x05, /* Usage (Gamepad), */ \
|
||||
0xA0, /* Collection (Physical), */ \
|
||||
0x05, 0x09, /* Usage Page (Button), */ \
|
||||
0x19, 0x01, /* Usage Minimum (01h), */ \
|
||||
0x29, 0x02, /* Usage Maximum (02h), */ \
|
||||
0x95, 0x02, /* Report Count (2), */ \
|
||||
0x81, 0x02, /* Input (Variable), */ \
|
||||
0x95, _padding, /* Report Count (_padding), */ \
|
||||
0x81, 0x01, /* Input (Constant), */ \
|
||||
0xC0, /* End Collection, */ \
|
||||
0xC0 /* End Collection */
|
||||
|
||||
/* Fixed report descriptor for (tweaked) v1 buttonpad reports */
|
||||
const __u8 uclogic_rdesc_buttonpad_v1_arr[] = {
|
||||
UCLOGIC_RDESC_BUTTONPAD_BYTES(20)
|
||||
};
|
||||
const size_t uclogic_rdesc_buttonpad_v1_size =
|
||||
sizeof(uclogic_rdesc_buttonpad_v1_arr);
|
||||
|
||||
/* Fixed report descriptor for (tweaked) v2 buttonpad reports */
|
||||
const __u8 uclogic_rdesc_buttonpad_v2_arr[] = {
|
||||
UCLOGIC_RDESC_BUTTONPAD_BYTES(52)
|
||||
};
|
||||
const size_t uclogic_rdesc_buttonpad_v2_size =
|
||||
sizeof(uclogic_rdesc_buttonpad_v2_arr);
|
||||
|
||||
/* Fixed report descriptor for Ugee EX07 buttonpad */
|
||||
const __u8 uclogic_rdesc_ugee_ex07_buttonpad_arr[] = {
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x07, /* Usage (Keypad), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
0x85, 0xF7, /* Report ID (247), */
|
||||
0x05, 0x0D, /* Usage Page (Digitizers), */
|
||||
0x85, 0x06, /* Report ID (6), */
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x39, /* Usage (Tablet Function Keys), */
|
||||
0xA0, /* Collection (Physical), */
|
||||
0x05, 0x09, /* Usage Page (Button), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x95, 0x18, /* Report Count (24), */
|
||||
0x19, 0x03, /* Usage Minimum (03h), */
|
||||
0x29, 0x06, /* Usage Maximum (06h), */
|
||||
0x95, 0x04, /* Report Count (4), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x95, 0x1A, /* Report Count (26), */
|
||||
0x81, 0x03, /* Input (Constant, Variable), */
|
||||
0x19, 0x01, /* Usage Minimum (01h), */
|
||||
0x29, 0x08, /* Usage Maximum (08h), */
|
||||
0x95, 0x08, /* Report Count (8), */
|
||||
0x29, 0x02, /* Usage Maximum (02h), */
|
||||
0x95, 0x02, /* Report Count (2), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0xC0, /* End Collection */
|
||||
0xC0, /* End Collection, */
|
||||
0xC0 /* End Collection */
|
||||
};
|
||||
const size_t uclogic_rdesc_ugee_ex07_buttonpad_size =
|
||||
sizeof(uclogic_rdesc_ugee_ex07_buttonpad_arr);
|
||||
|
||||
/* Parameter indices */
|
||||
enum uclogic_prm {
|
||||
UCLOGIC_PRM_X_LM = 1,
|
||||
UCLOGIC_PRM_Y_LM = 2,
|
||||
UCLOGIC_PRM_PRESSURE_LM = 4,
|
||||
UCLOGIC_PRM_RESOLUTION = 5,
|
||||
UCLOGIC_PRM_NUM
|
||||
/* Fixed report descriptor for Ugee G5 frame controls */
|
||||
const __u8 uclogic_rdesc_ugee_g5_frame_arr[] = {
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x07, /* Usage (Keypad), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
0x85, 0x06, /* Report ID (6), */
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x39, /* Usage (Tablet Function Keys), */
|
||||
0xA0, /* Collection (Physical), */
|
||||
0x14, /* Logical Minimum (0), */
|
||||
0x25, 0x01, /* Logical Maximum (1), */
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x05, 0x09, /* Usage Page (Button), */
|
||||
0x19, 0x01, /* Usage Minimum (01h), */
|
||||
0x29, 0x05, /* Usage Maximum (05h), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x95, 0x05, /* Report Count (5), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x95, 0x03, /* Report Count (3), */
|
||||
0x81, 0x01, /* Input (Constant), */
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x0A, 0xFF, 0xFF, /* Usage (FFFFh), */
|
||||
0x26, 0xFF, 0x00, /* Logical Maximum (255), */
|
||||
0x75, 0x08, /* Report Size (8), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x25, 0x01, /* Logical Maximum (1), */
|
||||
0x09, 0x44, /* Usage (Barrel Switch), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x30, /* Usage (X), */
|
||||
0x09, 0x31, /* Usage (Y), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x95, 0x02, /* Report Count (2), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x95, 0x0B, /* Report Count (11), */
|
||||
0x81, 0x01, /* Input (Constant), */
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x38, /* Usage (Wheel), */
|
||||
0x15, 0xFF, /* Logical Minimum (-1), */
|
||||
0x25, 0x01, /* Logical Maximum (1), */
|
||||
0x75, 0x02, /* Report Size (2), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x81, 0x06, /* Input (Variable, Relative), */
|
||||
0xC0, /* End Collection, */
|
||||
0xC0 /* End Collection */
|
||||
};
|
||||
const size_t uclogic_rdesc_ugee_g5_frame_size =
|
||||
sizeof(uclogic_rdesc_ugee_g5_frame_arr);
|
||||
|
||||
/* Fixed report descriptor for XP-Pen Deco 01 frame controls */
|
||||
const __u8 uclogic_rdesc_xppen_deco01_frame_arr[] = {
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x07, /* Usage (Keypad), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
0x85, 0x06, /* Report ID (6), */
|
||||
0x14, /* Logical Minimum (0), */
|
||||
0x25, 0x01, /* Logical Maximum (1), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x39, /* Usage (Tablet Function Keys), */
|
||||
0xA0, /* Collection (Physical), */
|
||||
0x05, 0x09, /* Usage Page (Button), */
|
||||
0x19, 0x01, /* Usage Minimum (01h), */
|
||||
0x29, 0x08, /* Usage Maximum (08h), */
|
||||
0x95, 0x08, /* Report Count (8), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x44, /* Usage (Barrel Switch), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x09, 0x30, /* Usage (X), */
|
||||
0x09, 0x31, /* Usage (Y), */
|
||||
0x95, 0x02, /* Report Count (2), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x95, 0x15, /* Report Count (21), */
|
||||
0x81, 0x01, /* Input (Constant), */
|
||||
0xC0, /* End Collection, */
|
||||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
/* Driver data */
|
||||
struct uclogic_drvdata {
|
||||
__u8 *rdesc;
|
||||
unsigned int rsize;
|
||||
bool invert_pen_inrange;
|
||||
bool ignore_pen_usage;
|
||||
bool has_virtual_pad_interface;
|
||||
};
|
||||
|
||||
static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
|
||||
unsigned int *rsize)
|
||||
{
|
||||
struct usb_interface *iface = to_usb_interface(hdev->dev.parent);
|
||||
__u8 iface_num = iface->cur_altsetting->desc.bInterfaceNumber;
|
||||
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
|
||||
|
||||
if (drvdata->rdesc != NULL) {
|
||||
rdesc = drvdata->rdesc;
|
||||
*rsize = drvdata->rsize;
|
||||
return rdesc;
|
||||
}
|
||||
|
||||
switch (hdev->product) {
|
||||
case USB_DEVICE_ID_UCLOGIC_TABLET_PF1209:
|
||||
if (*rsize == PF1209_RDESC_ORIG_SIZE) {
|
||||
rdesc = pf1209_rdesc_fixed;
|
||||
*rsize = sizeof(pf1209_rdesc_fixed);
|
||||
}
|
||||
break;
|
||||
case USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U:
|
||||
if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
|
||||
rdesc = wp4030u_rdesc_fixed;
|
||||
*rsize = sizeof(wp4030u_rdesc_fixed);
|
||||
}
|
||||
break;
|
||||
case USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U:
|
||||
if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
|
||||
rdesc = wp5540u_rdesc_fixed;
|
||||
*rsize = sizeof(wp5540u_rdesc_fixed);
|
||||
}
|
||||
break;
|
||||
case USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U:
|
||||
if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) {
|
||||
rdesc = wp8060u_rdesc_fixed;
|
||||
*rsize = sizeof(wp8060u_rdesc_fixed);
|
||||
}
|
||||
break;
|
||||
case USB_DEVICE_ID_UCLOGIC_TABLET_WP1062:
|
||||
if (*rsize == WP1062_RDESC_ORIG_SIZE) {
|
||||
rdesc = wp1062_rdesc_fixed;
|
||||
*rsize = sizeof(wp1062_rdesc_fixed);
|
||||
}
|
||||
break;
|
||||
case USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850:
|
||||
switch (iface_num) {
|
||||
case 0:
|
||||
if (*rsize == TWHL850_RDESC_ORIG_SIZE0) {
|
||||
rdesc = twhl850_rdesc_fixed0;
|
||||
*rsize = sizeof(twhl850_rdesc_fixed0);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (*rsize == TWHL850_RDESC_ORIG_SIZE1) {
|
||||
rdesc = twhl850_rdesc_fixed1;
|
||||
*rsize = sizeof(twhl850_rdesc_fixed1);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (*rsize == TWHL850_RDESC_ORIG_SIZE2) {
|
||||
rdesc = twhl850_rdesc_fixed2;
|
||||
*rsize = sizeof(twhl850_rdesc_fixed2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60:
|
||||
switch (iface_num) {
|
||||
case 0:
|
||||
if (*rsize == TWHA60_RDESC_ORIG_SIZE0) {
|
||||
rdesc = twha60_rdesc_fixed0;
|
||||
*rsize = sizeof(twha60_rdesc_fixed0);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (*rsize == TWHA60_RDESC_ORIG_SIZE1) {
|
||||
rdesc = twha60_rdesc_fixed1;
|
||||
*rsize = sizeof(twha60_rdesc_fixed1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return rdesc;
|
||||
}
|
||||
|
||||
static int uclogic_input_mapping(struct hid_device *hdev, struct hid_input *hi,
|
||||
struct hid_field *field, struct hid_usage *usage,
|
||||
unsigned long **bit, int *max)
|
||||
{
|
||||
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
|
||||
|
||||
/* discard the unused pen interface */
|
||||
if ((drvdata->ignore_pen_usage) &&
|
||||
(field->application == HID_DG_PEN))
|
||||
return -1;
|
||||
|
||||
/* let hid-core decide what to do */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uclogic_input_configured(struct hid_device *hdev,
|
||||
struct hid_input *hi)
|
||||
{
|
||||
char *name;
|
||||
const char *suffix = NULL;
|
||||
struct hid_field *field;
|
||||
size_t len;
|
||||
|
||||
/* no report associated (HID_QUIRK_MULTI_INPUT not set) */
|
||||
if (!hi->report)
|
||||
return 0;
|
||||
|
||||
field = hi->report->field[0];
|
||||
|
||||
switch (field->application) {
|
||||
case HID_GD_KEYBOARD:
|
||||
suffix = "Keyboard";
|
||||
break;
|
||||
case HID_GD_MOUSE:
|
||||
suffix = "Mouse";
|
||||
break;
|
||||
case HID_GD_KEYPAD:
|
||||
suffix = "Pad";
|
||||
break;
|
||||
case HID_DG_PEN:
|
||||
suffix = "Pen";
|
||||
break;
|
||||
case HID_CP_CONSUMER_CONTROL:
|
||||
suffix = "Consumer Control";
|
||||
break;
|
||||
case HID_GD_SYSTEM_CONTROL:
|
||||
suffix = "System Control";
|
||||
break;
|
||||
}
|
||||
|
||||
if (suffix) {
|
||||
len = strlen(hdev->name) + 2 + strlen(suffix);
|
||||
name = devm_kzalloc(&hi->input->dev, len, GFP_KERNEL);
|
||||
if (name) {
|
||||
snprintf(name, len, "%s %s", hdev->name, suffix);
|
||||
hi->input->name = name;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
const size_t uclogic_rdesc_xppen_deco01_frame_size =
|
||||
sizeof(uclogic_rdesc_xppen_deco01_frame_arr);
|
||||
|
||||
/**
|
||||
* Enable fully-functional tablet mode and determine device parameters.
|
||||
* uclogic_rdesc_template_apply() - apply report descriptor parameters to a
|
||||
* report descriptor template, creating a report descriptor. Copies the
|
||||
* template over to the new report descriptor and replaces every occurrence of
|
||||
* UCLOGIC_RDESC_PH_HEAD, followed by an index byte, with the value from the
|
||||
* parameter list at that index.
|
||||
*
|
||||
* @hdev: HID device
|
||||
* @template_ptr: Pointer to the template buffer.
|
||||
* @template_size: Size of the template buffer.
|
||||
* @param_list: List of template parameters.
|
||||
* @param_num: Number of parameters in the list.
|
||||
*
|
||||
* Returns:
|
||||
* Kmalloc-allocated pointer to the created report descriptor,
|
||||
* or NULL if allocation failed.
|
||||
*/
|
||||
static int uclogic_tablet_enable(struct hid_device *hdev)
|
||||
__u8 *uclogic_rdesc_template_apply(const __u8 *template_ptr,
|
||||
size_t template_size,
|
||||
const s32 *param_list,
|
||||
size_t param_num)
|
||||
{
|
||||
int rc;
|
||||
struct usb_device *usb_dev = hid_to_usb_dev(hdev);
|
||||
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
|
||||
__le16 *buf = NULL;
|
||||
size_t len;
|
||||
s32 params[UCLOGIC_PH_ID_NUM];
|
||||
s32 resolution;
|
||||
static const __u8 head[] = {UCLOGIC_RDESC_PH_HEAD};
|
||||
__u8 *rdesc_ptr;
|
||||
__u8 *p;
|
||||
s32 v;
|
||||
|
||||
/*
|
||||
* Read string descriptor containing tablet parameters. The specific
|
||||
* string descriptor and data were discovered by sniffing the Windows
|
||||
* driver traffic.
|
||||
* NOTE: This enables fully-functional tablet mode.
|
||||
*/
|
||||
len = UCLOGIC_PRM_NUM * sizeof(*buf);
|
||||
buf = kmalloc(len, GFP_KERNEL);
|
||||
if (buf == NULL) {
|
||||
rc = -ENOMEM;
|
||||
goto cleanup;
|
||||
}
|
||||
rc = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
|
||||
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
|
||||
(USB_DT_STRING << 8) + 0x64,
|
||||
0x0409, buf, len,
|
||||
USB_CTRL_GET_TIMEOUT);
|
||||
if (rc == -EPIPE) {
|
||||
hid_err(hdev, "device parameters not found\n");
|
||||
rc = -ENODEV;
|
||||
goto cleanup;
|
||||
} else if (rc < 0) {
|
||||
hid_err(hdev, "failed to get device parameters: %d\n", rc);
|
||||
rc = -ENODEV;
|
||||
goto cleanup;
|
||||
} else if (rc != len) {
|
||||
hid_err(hdev, "invalid device parameters\n");
|
||||
rc = -ENODEV;
|
||||
goto cleanup;
|
||||
}
|
||||
rdesc_ptr = kmemdup(template_ptr, template_size, GFP_KERNEL);
|
||||
if (rdesc_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Extract device parameters */
|
||||
params[UCLOGIC_PH_ID_X_LM] = le16_to_cpu(buf[UCLOGIC_PRM_X_LM]);
|
||||
params[UCLOGIC_PH_ID_Y_LM] = le16_to_cpu(buf[UCLOGIC_PRM_Y_LM]);
|
||||
params[UCLOGIC_PH_ID_PRESSURE_LM] =
|
||||
le16_to_cpu(buf[UCLOGIC_PRM_PRESSURE_LM]);
|
||||
resolution = le16_to_cpu(buf[UCLOGIC_PRM_RESOLUTION]);
|
||||
if (resolution == 0) {
|
||||
params[UCLOGIC_PH_ID_X_PM] = 0;
|
||||
params[UCLOGIC_PH_ID_Y_PM] = 0;
|
||||
} else {
|
||||
params[UCLOGIC_PH_ID_X_PM] = params[UCLOGIC_PH_ID_X_LM] *
|
||||
1000 / resolution;
|
||||
params[UCLOGIC_PH_ID_Y_PM] = params[UCLOGIC_PH_ID_Y_LM] *
|
||||
1000 / resolution;
|
||||
}
|
||||
|
||||
/* Allocate fixed report descriptor */
|
||||
drvdata->rdesc = devm_kzalloc(&hdev->dev,
|
||||
sizeof(uclogic_tablet_rdesc_template),
|
||||
GFP_KERNEL);
|
||||
if (drvdata->rdesc == NULL) {
|
||||
rc = -ENOMEM;
|
||||
goto cleanup;
|
||||
}
|
||||
drvdata->rsize = sizeof(uclogic_tablet_rdesc_template);
|
||||
|
||||
/* Format fixed report descriptor */
|
||||
memcpy(drvdata->rdesc, uclogic_tablet_rdesc_template,
|
||||
drvdata->rsize);
|
||||
for (p = drvdata->rdesc;
|
||||
p <= drvdata->rdesc + drvdata->rsize - 4;) {
|
||||
if (p[0] == 0xFE && p[1] == 0xED && p[2] == 0x1D &&
|
||||
p[3] < ARRAY_SIZE(params)) {
|
||||
v = params[p[3]];
|
||||
for (p = rdesc_ptr; p + sizeof(head) < rdesc_ptr + template_size;) {
|
||||
if (memcmp(p, head, sizeof(head)) == 0 &&
|
||||
p[sizeof(head)] < param_num) {
|
||||
v = param_list[p[sizeof(head)]];
|
||||
put_unaligned(cpu_to_le32(v), (s32 *)p);
|
||||
p += 4;
|
||||
p += sizeof(head) + 1;
|
||||
} else {
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
|
||||
cleanup:
|
||||
kfree(buf);
|
||||
return rc;
|
||||
return rdesc_ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable actual button mode.
|
||||
*
|
||||
* @hdev: HID device
|
||||
*/
|
||||
static int uclogic_button_enable(struct hid_device *hdev)
|
||||
{
|
||||
int rc;
|
||||
struct usb_device *usb_dev = hid_to_usb_dev(hdev);
|
||||
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
|
||||
char *str_buf;
|
||||
size_t str_len = 16;
|
||||
unsigned char *rdesc;
|
||||
size_t rdesc_len;
|
||||
|
||||
str_buf = kzalloc(str_len, GFP_KERNEL);
|
||||
if (str_buf == NULL) {
|
||||
rc = -ENOMEM;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Enable abstract keyboard mode */
|
||||
rc = usb_string(usb_dev, 0x7b, str_buf, str_len);
|
||||
if (rc == -EPIPE) {
|
||||
hid_info(hdev, "button mode setting not found\n");
|
||||
rc = 0;
|
||||
goto cleanup;
|
||||
} else if (rc < 0) {
|
||||
hid_err(hdev, "failed to enable abstract keyboard\n");
|
||||
goto cleanup;
|
||||
} else if (strncmp(str_buf, "HK On", rc)) {
|
||||
hid_info(hdev, "invalid answer when requesting buttons: '%s'\n",
|
||||
str_buf);
|
||||
rc = -EINVAL;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Re-allocate fixed report descriptor */
|
||||
rdesc_len = drvdata->rsize + sizeof(uclogic_buttonpad_rdesc);
|
||||
rdesc = devm_kzalloc(&hdev->dev, rdesc_len, GFP_KERNEL);
|
||||
if (!rdesc) {
|
||||
rc = -ENOMEM;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
memcpy(rdesc, drvdata->rdesc, drvdata->rsize);
|
||||
|
||||
/* Append the buttonpad descriptor */
|
||||
memcpy(rdesc + drvdata->rsize, uclogic_buttonpad_rdesc,
|
||||
sizeof(uclogic_buttonpad_rdesc));
|
||||
|
||||
/* clean up old rdesc and use the new one */
|
||||
drvdata->rsize = rdesc_len;
|
||||
devm_kfree(&hdev->dev, drvdata->rdesc);
|
||||
drvdata->rdesc = rdesc;
|
||||
|
||||
rc = 0;
|
||||
|
||||
cleanup:
|
||||
kfree(str_buf);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int uclogic_probe(struct hid_device *hdev,
|
||||
const struct hid_device_id *id)
|
||||
{
|
||||
int rc;
|
||||
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
|
||||
struct usb_device *udev = hid_to_usb_dev(hdev);
|
||||
struct uclogic_drvdata *drvdata;
|
||||
|
||||
/*
|
||||
* libinput requires the pad interface to be on a different node
|
||||
* than the pen, so use QUIRK_MULTI_INPUT for all tablets.
|
||||
*/
|
||||
hdev->quirks |= HID_QUIRK_MULTI_INPUT;
|
||||
|
||||
/* Allocate and assign driver data */
|
||||
drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
|
||||
if (drvdata == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
hid_set_drvdata(hdev, drvdata);
|
||||
|
||||
switch (id->product) {
|
||||
case USB_DEVICE_ID_HUION_TABLET:
|
||||
case USB_DEVICE_ID_YIYNOVA_TABLET:
|
||||
case USB_DEVICE_ID_UGEE_TABLET_81:
|
||||
case USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3:
|
||||
case USB_DEVICE_ID_UGEE_TABLET_45:
|
||||
/* If this is the pen interface */
|
||||
if (intf->cur_altsetting->desc.bInterfaceNumber == 0) {
|
||||
rc = uclogic_tablet_enable(hdev);
|
||||
if (rc) {
|
||||
hid_err(hdev, "tablet enabling failed\n");
|
||||
return rc;
|
||||
}
|
||||
drvdata->invert_pen_inrange = true;
|
||||
|
||||
rc = uclogic_button_enable(hdev);
|
||||
drvdata->has_virtual_pad_interface = !rc;
|
||||
} else {
|
||||
drvdata->ignore_pen_usage = true;
|
||||
}
|
||||
break;
|
||||
case USB_DEVICE_ID_UGTIZER_TABLET_GP0610:
|
||||
case USB_DEVICE_ID_UGEE_TABLET_EX07S:
|
||||
/* If this is the pen interface */
|
||||
if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
|
||||
rc = uclogic_tablet_enable(hdev);
|
||||
if (rc) {
|
||||
hid_err(hdev, "tablet enabling failed\n");
|
||||
return rc;
|
||||
}
|
||||
drvdata->invert_pen_inrange = true;
|
||||
} else {
|
||||
drvdata->ignore_pen_usage = true;
|
||||
}
|
||||
break;
|
||||
case USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60:
|
||||
/*
|
||||
* If it is the three-interface version, which is known to
|
||||
* respond to initialization.
|
||||
*/
|
||||
if (udev->config->desc.bNumInterfaces == 3) {
|
||||
/* If it is the pen interface */
|
||||
if (intf->cur_altsetting->desc.bInterfaceNumber == 0) {
|
||||
rc = uclogic_tablet_enable(hdev);
|
||||
if (rc) {
|
||||
hid_err(hdev, "tablet enabling failed\n");
|
||||
return rc;
|
||||
}
|
||||
drvdata->invert_pen_inrange = true;
|
||||
|
||||
rc = uclogic_button_enable(hdev);
|
||||
drvdata->has_virtual_pad_interface = !rc;
|
||||
} else {
|
||||
drvdata->ignore_pen_usage = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
rc = hid_parse(hdev);
|
||||
if (rc) {
|
||||
hid_err(hdev, "parse failed\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
|
||||
if (rc) {
|
||||
hid_err(hdev, "hw start failed\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uclogic_raw_event(struct hid_device *hdev, struct hid_report *report,
|
||||
u8 *data, int size)
|
||||
{
|
||||
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
|
||||
|
||||
if ((report->type == HID_INPUT_REPORT) &&
|
||||
(report->id == UCLOGIC_PEN_REPORT_ID) &&
|
||||
(size >= 2)) {
|
||||
if (drvdata->has_virtual_pad_interface && (data[1] & 0x20))
|
||||
/* Change to virtual frame button report ID */
|
||||
data[0] = 0xf7;
|
||||
else if (drvdata->invert_pen_inrange)
|
||||
/* Invert the in-range bit */
|
||||
data[1] ^= 0x40;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct hid_device_id uclogic_devices[] = {
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
|
||||
USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_TABLET) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_HUION_TABLET) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_YIYNOVA_TABLET) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_81) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_45) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(hid, uclogic_devices);
|
||||
|
||||
static struct hid_driver uclogic_driver = {
|
||||
.name = "uclogic",
|
||||
.id_table = uclogic_devices,
|
||||
.probe = uclogic_probe,
|
||||
.report_fixup = uclogic_report_fixup,
|
||||
.raw_event = uclogic_raw_event,
|
||||
.input_mapping = uclogic_input_mapping,
|
||||
.input_configured = uclogic_input_configured,
|
||||
};
|
||||
module_hid_driver(uclogic_driver);
|
||||
|
||||
MODULE_AUTHOR("Martin Rusko");
|
||||
MODULE_AUTHOR("Nikolai Kondrashov");
|
||||
MODULE_LICENSE("GPL");
|
|
@ -0,0 +1,155 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* HID driver for UC-Logic devices not fully compliant with HID standard
|
||||
* - original and fixed report descriptors
|
||||
*
|
||||
* Copyright (c) 2010-2018 Nikolai Kondrashov
|
||||
* Copyright (c) 2013 Martin Rusko
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*/
|
||||
|
||||
#ifndef _HID_UCLOGIC_RDESC_H
|
||||
#define _HID_UCLOGIC_RDESC_H
|
||||
|
||||
#include <linux/usb.h>
|
||||
|
||||
/* Size of the original descriptor of WPXXXXU tablets */
|
||||
#define UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE 212
|
||||
|
||||
/* Fixed WP4030U report descriptor */
|
||||
extern __u8 uclogic_rdesc_wp4030u_fixed_arr[];
|
||||
extern const size_t uclogic_rdesc_wp4030u_fixed_size;
|
||||
|
||||
/* Fixed WP5540U report descriptor */
|
||||
extern __u8 uclogic_rdesc_wp5540u_fixed_arr[];
|
||||
extern const size_t uclogic_rdesc_wp5540u_fixed_size;
|
||||
|
||||
/* Fixed WP8060U report descriptor */
|
||||
extern __u8 uclogic_rdesc_wp8060u_fixed_arr[];
|
||||
extern const size_t uclogic_rdesc_wp8060u_fixed_size;
|
||||
|
||||
/* Size of the original descriptor of the new WP5540U tablet */
|
||||
#define UCLOGIC_RDESC_WP5540U_V2_ORIG_SIZE 232
|
||||
|
||||
/* Size of the original descriptor of WP1062 tablet */
|
||||
#define UCLOGIC_RDESC_WP1062_ORIG_SIZE 254
|
||||
|
||||
/* Fixed WP1062 report descriptor */
|
||||
extern __u8 uclogic_rdesc_wp1062_fixed_arr[];
|
||||
extern const size_t uclogic_rdesc_wp1062_fixed_size;
|
||||
|
||||
/* Size of the original descriptor of PF1209 tablet */
|
||||
#define UCLOGIC_RDESC_PF1209_ORIG_SIZE 234
|
||||
|
||||
/* Fixed PF1209 report descriptor */
|
||||
extern __u8 uclogic_rdesc_pf1209_fixed_arr[];
|
||||
extern const size_t uclogic_rdesc_pf1209_fixed_size;
|
||||
|
||||
/* Size of the original descriptors of TWHL850 tablet */
|
||||
#define UCLOGIC_RDESC_TWHL850_ORIG0_SIZE 182
|
||||
#define UCLOGIC_RDESC_TWHL850_ORIG1_SIZE 161
|
||||
#define UCLOGIC_RDESC_TWHL850_ORIG2_SIZE 92
|
||||
|
||||
/* Fixed PID 0522 tablet report descriptor, interface 0 (stylus) */
|
||||
extern __u8 uclogic_rdesc_twhl850_fixed0_arr[];
|
||||
extern const size_t uclogic_rdesc_twhl850_fixed0_size;
|
||||
|
||||
/* Fixed PID 0522 tablet report descriptor, interface 1 (mouse) */
|
||||
extern __u8 uclogic_rdesc_twhl850_fixed1_arr[];
|
||||
extern const size_t uclogic_rdesc_twhl850_fixed1_size;
|
||||
|
||||
/* Fixed PID 0522 tablet report descriptor, interface 2 (frame buttons) */
|
||||
extern __u8 uclogic_rdesc_twhl850_fixed2_arr[];
|
||||
extern const size_t uclogic_rdesc_twhl850_fixed2_size;
|
||||
|
||||
/* Size of the original descriptors of TWHA60 tablet */
|
||||
#define UCLOGIC_RDESC_TWHA60_ORIG0_SIZE 254
|
||||
#define UCLOGIC_RDESC_TWHA60_ORIG1_SIZE 139
|
||||
|
||||
/* Fixed TWHA60 report descriptor, interface 0 (stylus) */
|
||||
extern __u8 uclogic_rdesc_twha60_fixed0_arr[];
|
||||
extern const size_t uclogic_rdesc_twha60_fixed0_size;
|
||||
|
||||
/* Fixed TWHA60 report descriptor, interface 1 (frame buttons) */
|
||||
extern __u8 uclogic_rdesc_twha60_fixed1_arr[];
|
||||
extern const size_t uclogic_rdesc_twha60_fixed1_size;
|
||||
|
||||
/* Report descriptor template placeholder head */
|
||||
#define UCLOGIC_RDESC_PH_HEAD 0xFE, 0xED, 0x1D
|
||||
|
||||
/* Apply report descriptor parameters to a report descriptor template */
|
||||
extern __u8 *uclogic_rdesc_template_apply(const __u8 *template_ptr,
|
||||
size_t template_size,
|
||||
const s32 *param_list,
|
||||
size_t param_num);
|
||||
|
||||
/* Pen report descriptor template placeholder IDs */
|
||||
enum uclogic_rdesc_pen_ph_id {
|
||||
UCLOGIC_RDESC_PEN_PH_ID_X_LM,
|
||||
UCLOGIC_RDESC_PEN_PH_ID_X_PM,
|
||||
UCLOGIC_RDESC_PEN_PH_ID_Y_LM,
|
||||
UCLOGIC_RDESC_PEN_PH_ID_Y_PM,
|
||||
UCLOGIC_RDESC_PEN_PH_ID_PRESSURE_LM,
|
||||
UCLOGIC_RDESC_PEN_PH_ID_NUM
|
||||
};
|
||||
|
||||
/* Report descriptor pen template placeholder */
|
||||
#define UCLOGIC_RDESC_PEN_PH(_ID) \
|
||||
UCLOGIC_RDESC_PH_HEAD, UCLOGIC_RDESC_PEN_PH_ID_##_ID
|
||||
|
||||
/* Report ID for v1 pen reports */
|
||||
#define UCLOGIC_RDESC_PEN_V1_ID 0x07
|
||||
|
||||
/* Fixed report descriptor template for (tweaked) v1 pen reports */
|
||||
extern const __u8 uclogic_rdesc_pen_v1_template_arr[];
|
||||
extern const size_t uclogic_rdesc_pen_v1_template_size;
|
||||
|
||||
/* Report ID for v2 pen reports */
|
||||
#define UCLOGIC_RDESC_PEN_V2_ID 0x08
|
||||
|
||||
/* Fixed report descriptor template for (tweaked) v2 pen reports */
|
||||
extern const __u8 uclogic_rdesc_pen_v2_template_arr[];
|
||||
extern const size_t uclogic_rdesc_pen_v2_template_size;
|
||||
|
||||
/* Fixed report descriptor for (tweaked) v1 buttonpad reports */
|
||||
extern const __u8 uclogic_rdesc_buttonpad_v1_arr[];
|
||||
extern const size_t uclogic_rdesc_buttonpad_v1_size;
|
||||
|
||||
/* Report ID for tweaked v1 buttonpad reports */
|
||||
#define UCLOGIC_RDESC_BUTTONPAD_V1_ID 0xf7
|
||||
|
||||
/* Fixed report descriptor for (tweaked) v2 buttonpad reports */
|
||||
extern const __u8 uclogic_rdesc_buttonpad_v2_arr[];
|
||||
extern const size_t uclogic_rdesc_buttonpad_v2_size;
|
||||
|
||||
/* Report ID for tweaked v2 buttonpad reports */
|
||||
#define UCLOGIC_RDESC_BUTTONPAD_V2_ID 0xf7
|
||||
|
||||
/* Fixed report descriptor for Ugee EX07 buttonpad */
|
||||
extern const __u8 uclogic_rdesc_ugee_ex07_buttonpad_arr[];
|
||||
extern const size_t uclogic_rdesc_ugee_ex07_buttonpad_size;
|
||||
|
||||
/* Fixed report descriptor for XP-Pen Deco 01 frame controls */
|
||||
extern const __u8 uclogic_rdesc_xppen_deco01_frame_arr[];
|
||||
extern const size_t uclogic_rdesc_xppen_deco01_frame_size;
|
||||
|
||||
/* Fixed report descriptor for Ugee G5 frame controls */
|
||||
extern const __u8 uclogic_rdesc_ugee_g5_frame_arr[];
|
||||
extern const size_t uclogic_rdesc_ugee_g5_frame_size;
|
||||
|
||||
/* Report ID of Ugee G5 frame control reports */
|
||||
#define UCLOGIC_RDESC_UGEE_G5_FRAME_ID 0x06
|
||||
|
||||
/* Device ID byte offset in Ugee G5 frame report */
|
||||
#define UCLOGIC_RDESC_UGEE_G5_FRAME_DEV_ID_BYTE 0x2
|
||||
|
||||
/* Least-significant bit of Ugee G5 frame rotary encoder state */
|
||||
#define UCLOGIC_RDESC_UGEE_G5_FRAME_RE_LSB 38
|
||||
|
||||
#endif /* _HID_UCLOGIC_RDESC_H */
|
|
@ -0,0 +1,105 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* HID driver for ViewSonic devices not fully compliant with HID standard
|
||||
*
|
||||
* Copyright (c) 2017 Nikolai Kondrashov
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/hid.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include "hid-ids.h"
|
||||
|
||||
/* Size of the original descriptor of PD1011 signature pad */
|
||||
#define PD1011_RDESC_ORIG_SIZE 408
|
||||
|
||||
/* Fixed report descriptor of PD1011 signature pad */
|
||||
static __u8 pd1011_rdesc_fixed[] = {
|
||||
0x05, 0x0D, /* Usage Page (Digitizer), */
|
||||
0x09, 0x02, /* Usage (Pen), */
|
||||
0xA1, 0x01, /* Collection (Application), */
|
||||
0x85, 0x02, /* Report ID (2), */
|
||||
0x09, 0x20, /* Usage (Stylus), */
|
||||
0xA0, /* Collection (Physical), */
|
||||
0x75, 0x10, /* Report Size (16), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0xA4, /* Push, */
|
||||
0x05, 0x01, /* Usage Page (Desktop), */
|
||||
0x65, 0x13, /* Unit (Inch), */
|
||||
0x55, 0xFD, /* Unit Exponent (-3), */
|
||||
0x34, /* Physical Minimum (0), */
|
||||
0x09, 0x30, /* Usage (X), */
|
||||
0x46, 0x5D, 0x21, /* Physical Maximum (8541), */
|
||||
0x27, 0x80, 0xA9,
|
||||
0x00, 0x00, /* Logical Maximum (43392), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x09, 0x31, /* Usage (Y), */
|
||||
0x46, 0xDA, 0x14, /* Physical Maximum (5338), */
|
||||
0x26, 0xF0, 0x69, /* Logical Maximum (27120), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0xB4, /* Pop, */
|
||||
0x14, /* Logical Minimum (0), */
|
||||
0x25, 0x01, /* Logical Maximum (1), */
|
||||
0x75, 0x01, /* Report Size (1), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x81, 0x03, /* Input (Constant, Variable), */
|
||||
0x09, 0x32, /* Usage (In Range), */
|
||||
0x09, 0x42, /* Usage (Tip Switch), */
|
||||
0x95, 0x02, /* Report Count (2), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x95, 0x05, /* Report Count (5), */
|
||||
0x81, 0x03, /* Input (Constant, Variable), */
|
||||
0x75, 0x10, /* Report Size (16), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x09, 0x30, /* Usage (Tip Pressure), */
|
||||
0x15, 0x05, /* Logical Minimum (5), */
|
||||
0x26, 0xFF, 0x07, /* Logical Maximum (2047), */
|
||||
0x81, 0x02, /* Input (Variable), */
|
||||
0x75, 0x10, /* Report Size (16), */
|
||||
0x95, 0x01, /* Report Count (1), */
|
||||
0x81, 0x03, /* Input (Constant, Variable), */
|
||||
0xC0, /* End Collection, */
|
||||
0xC0 /* End Collection */
|
||||
};
|
||||
|
||||
static __u8 *viewsonic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
|
||||
unsigned int *rsize)
|
||||
{
|
||||
switch (hdev->product) {
|
||||
case USB_DEVICE_ID_VIEWSONIC_PD1011:
|
||||
case USB_DEVICE_ID_SIGNOTEC_VIEWSONIC_PD1011:
|
||||
if (*rsize == PD1011_RDESC_ORIG_SIZE) {
|
||||
rdesc = pd1011_rdesc_fixed;
|
||||
*rsize = sizeof(pd1011_rdesc_fixed);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return rdesc;
|
||||
}
|
||||
|
||||
static const struct hid_device_id viewsonic_devices[] = {
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_VIEWSONIC,
|
||||
USB_DEVICE_ID_VIEWSONIC_PD1011) },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_SIGNOTEC,
|
||||
USB_DEVICE_ID_SIGNOTEC_VIEWSONIC_PD1011) },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(hid, viewsonic_devices);
|
||||
|
||||
static struct hid_driver viewsonic_driver = {
|
||||
.name = "viewsonic",
|
||||
.id_table = viewsonic_devices,
|
||||
.report_fixup = viewsonic_report_fixup,
|
||||
};
|
||||
module_hid_driver(viewsonic_driver);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
Loading…
Reference in New Issue