Skip to content

Commit 2e688e6

Browse files
author
Jiri Kosina
committed
Merge branch 'for-5.19/uclogic' into for-linus
- support for wider variety of Huion tablets ported from DIGImend project (José Expósito, Nikolai Kondrashov)
2 parents fa4c7c6 + f7d8e38 commit 2e688e6

File tree

8 files changed

+587
-149
lines changed

8 files changed

+587
-149
lines changed

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,7 @@
12781278
#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540 0x0075
12791279
#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640 0x0094
12801280
#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01 0x0042
1281+
#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_STAR06 0x0078
12811282
#define USB_DEVICE_ID_UGEE_TABLET_G5 0x0074
12821283
#define USB_DEVICE_ID_UGEE_TABLET_EX07S 0x0071
12831284
#define USB_DEVICE_ID_UGEE_TABLET_RAINBOW_CV720 0x0055

drivers/hid/hid-kye.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static __u8 easypen_i405x_rdesc_fixed[] = {
3333
0xB1, 0x02, /* Feature (Variable), */
3434
0xC0, /* End Collection, */
3535
0x05, 0x0D, /* Usage Page (Digitizer), */
36-
0x09, 0x02, /* Usage (Pen), */
36+
0x09, 0x01, /* Usage (Digitizer), */
3737
0xA1, 0x01, /* Collection (Application), */
3838
0x85, 0x10, /* Report ID (16), */
3939
0x09, 0x20, /* Usage (Stylus), */
@@ -91,7 +91,7 @@ static __u8 mousepen_i608x_rdesc_fixed[] = {
9191
0xB1, 0x02, /* Feature (Variable), */
9292
0xC0, /* End Collection, */
9393
0x05, 0x0D, /* Usage Page (Digitizer), */
94-
0x09, 0x02, /* Usage (Pen), */
94+
0x09, 0x01, /* Usage (Digitizer), */
9595
0xA1, 0x01, /* Collection (Application), */
9696
0x85, 0x10, /* Report ID (16), */
9797
0x09, 0x20, /* Usage (Stylus), */
@@ -190,7 +190,7 @@ static __u8 mousepen_i608x_v2_rdesc_fixed[] = {
190190
0xB1, 0x02, /* Feature (Variable), */
191191
0xC0, /* End Collection, */
192192
0x05, 0x0D, /* Usage Page (Digitizer), */
193-
0x09, 0x02, /* Usage (Pen), */
193+
0x09, 0x01, /* Usage (Digitizer), */
194194
0xA1, 0x01, /* Collection (Application), */
195195
0x85, 0x10, /* Report ID (16), */
196196
0x09, 0x20, /* Usage (Stylus), */
@@ -289,7 +289,7 @@ static __u8 easypen_m610x_rdesc_fixed[] = {
289289
0xB1, 0x02, /* Feature (Variable), */
290290
0xC0, /* End Collection, */
291291
0x05, 0x0D, /* Usage Page (Digitizer), */
292-
0x09, 0x02, /* Usage (Pen), */
292+
0x09, 0x01, /* Usage (Digitizer), */
293293
0xA1, 0x01, /* Collection (Application), */
294294
0x85, 0x10, /* Report ID (16), */
295295
0x09, 0x20, /* Usage (Stylus), */
@@ -368,7 +368,7 @@ static __u8 pensketch_m912_rdesc_fixed[] = {
368368
0xB1, 0x02, /* Feature (Variable), */
369369
0xC0, /* End Collection, */
370370
0x05, 0x0D, /* Usage Page (Digitizer), */
371-
0x09, 0x02, /* Usage (Pen), */
371+
0x09, 0x01, /* Usage (Digitizer), */
372372
0xA1, 0x01, /* Collection (Application), */
373373
0x85, 0x10, /* Report ID (16), */
374374
0x09, 0x20, /* Usage (Stylus), */
@@ -497,7 +497,7 @@ static __u8 easypen_m406xe_rdesc_fixed[] = {
497497
0xB1, 0x02, /* Feature (Variable), */
498498
0xC0, /* End Collection, */
499499
0x05, 0x0D, /* Usage Page (Digitizer), */
500-
0x09, 0x02, /* Usage (Pen), */
500+
0x09, 0x01, /* Usage (Digitizer), */
501501
0xA1, 0x01, /* Collection (Application), */
502502
0x85, 0x10, /* Report ID (16), */
503503
0x09, 0x20, /* Usage (Stylus), */

drivers/hid/hid-uclogic-core.c

Lines changed: 90 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
8181
return rdesc;
8282
}
8383

84+
static int uclogic_input_mapping(struct hid_device *hdev,
85+
struct hid_input *hi,
86+
struct hid_field *field,
87+
struct hid_usage *usage,
88+
unsigned long **bit,
89+
int *max)
90+
{
91+
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
92+
struct uclogic_params *params = &drvdata->params;
93+
94+
/* Discard invalid pen usages */
95+
if (params->pen.usage_invalid && (field->application == HID_DG_PEN))
96+
return -1;
97+
98+
/* Let hid-core decide what to do */
99+
return 0;
100+
}
101+
84102
static int uclogic_input_configured(struct hid_device *hdev,
85103
struct hid_input *hi)
86104
{
@@ -90,6 +108,8 @@ static int uclogic_input_configured(struct hid_device *hdev,
90108
const char *suffix = NULL;
91109
struct hid_field *field;
92110
size_t len;
111+
size_t i;
112+
const struct uclogic_params_frame *frame;
93113

94114
/* no report associated (HID_QUIRK_MULTI_INPUT not set) */
95115
if (!hi->report)
@@ -104,27 +124,44 @@ static int uclogic_input_configured(struct hid_device *hdev,
104124
drvdata->pen_input = hi->input;
105125
}
106126

107-
field = hi->report->field[0];
127+
/* If it's one of the frame devices */
128+
for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) {
129+
frame = &params->frame_list[i];
130+
if (hi->report->id == frame->id) {
131+
/* Assign custom suffix, if any */
132+
suffix = frame->suffix;
133+
/*
134+
* Disable EV_MSC reports for touch ring interfaces to
135+
* make the Wacom driver pickup touch ring extents
136+
*/
137+
if (frame->touch_byte > 0)
138+
__clear_bit(EV_MSC, hi->input->evbit);
139+
}
140+
}
108141

109-
switch (field->application) {
110-
case HID_GD_KEYBOARD:
111-
suffix = "Keyboard";
112-
break;
113-
case HID_GD_MOUSE:
114-
suffix = "Mouse";
115-
break;
116-
case HID_GD_KEYPAD:
117-
suffix = "Pad";
118-
break;
119-
case HID_DG_PEN:
120-
suffix = "Pen";
121-
break;
122-
case HID_CP_CONSUMER_CONTROL:
123-
suffix = "Consumer Control";
124-
break;
125-
case HID_GD_SYSTEM_CONTROL:
126-
suffix = "System Control";
127-
break;
142+
if (!suffix) {
143+
field = hi->report->field[0];
144+
145+
switch (field->application) {
146+
case HID_GD_KEYBOARD:
147+
suffix = "Keyboard";
148+
break;
149+
case HID_GD_MOUSE:
150+
suffix = "Mouse";
151+
break;
152+
case HID_GD_KEYPAD:
153+
suffix = "Pad";
154+
break;
155+
case HID_DG_PEN:
156+
suffix = "Pen";
157+
break;
158+
case HID_CP_CONSUMER_CONTROL:
159+
suffix = "Consumer Control";
160+
break;
161+
case HID_GD_SYSTEM_CONTROL:
162+
suffix = "System Control";
163+
break;
164+
}
128165
}
129166

130167
if (suffix) {
@@ -172,8 +209,8 @@ static int uclogic_probe(struct hid_device *hdev,
172209
goto failure;
173210
}
174211
params_initialized = true;
175-
hid_dbg(hdev, "parameters:\n" UCLOGIC_PARAMS_FMT_STR,
176-
UCLOGIC_PARAMS_FMT_ARGS(&drvdata->params));
212+
hid_dbg(hdev, "parameters:\n");
213+
uclogic_params_hid_dbg(hdev, &drvdata->params);
177214
if (drvdata->params.invalid) {
178215
hid_info(hdev, "interface is invalid, ignoring\n");
179216
rc = -ENODEV;
@@ -313,8 +350,15 @@ static int uclogic_raw_event_frame(
313350

314351
/* If need to, and can, set pad device ID for Wacom drivers */
315352
if (frame->dev_id_byte > 0 && frame->dev_id_byte < size) {
316-
data[frame->dev_id_byte] = 0xf;
353+
/* If we also have a touch ring and the finger left it */
354+
if (frame->touch_byte > 0 && frame->touch_byte < size &&
355+
data[frame->touch_byte] == 0) {
356+
data[frame->dev_id_byte] = 0;
357+
} else {
358+
data[frame->dev_id_byte] = 0xf;
359+
}
317360
}
361+
318362
/* If need to, and can, read rotary encoder state change */
319363
if (frame->re_lsb > 0 && frame->re_lsb / 8 < size) {
320364
unsigned int byte = frame->re_lsb / 8;
@@ -341,6 +385,26 @@ static int uclogic_raw_event_frame(
341385
drvdata->re_state = state;
342386
}
343387

388+
/* If need to, and can, transform the touch ring reports */
389+
if (frame->touch_byte > 0 && frame->touch_byte < size) {
390+
__s8 value = data[frame->touch_byte];
391+
392+
if (value != 0) {
393+
if (frame->touch_flip_at != 0) {
394+
value = frame->touch_flip_at - value;
395+
if (value <= 0)
396+
value = frame->touch_max + value;
397+
}
398+
data[frame->touch_byte] = value - 1;
399+
}
400+
}
401+
402+
/* If need to, and can, transform the bitmap dial reports */
403+
if (frame->bitmap_dial_byte > 0 && frame->bitmap_dial_byte < size) {
404+
if (data[frame->bitmap_dial_byte] == 2)
405+
data[frame->bitmap_dial_byte] = -1;
406+
}
407+
344408
return 0;
345409
}
346410

@@ -457,6 +521,8 @@ static const struct hid_device_id uclogic_devices[] = {
457521
USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640) },
458522
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE,
459523
USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01) },
524+
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE,
525+
USB_DEVICE_ID_UGEE_XPPEN_TABLET_STAR06) },
460526
{ }
461527
};
462528
MODULE_DEVICE_TABLE(hid, uclogic_devices);
@@ -468,6 +534,7 @@ static struct hid_driver uclogic_driver = {
468534
.remove = uclogic_remove,
469535
.report_fixup = uclogic_report_fixup,
470536
.raw_event = uclogic_raw_event,
537+
.input_mapping = uclogic_input_mapping,
471538
.input_configured = uclogic_input_configured,
472539
#ifdef CONFIG_PM
473540
.resume = uclogic_resume,

0 commit comments

Comments
 (0)