Skip to content

Commit eb41c95

Browse files
author
Jiri Kosina
committed
Merge branch 'for-6.19/uclogic' into for-linus
- support for UcLogic XP-PEN Artist 24 Pro (Joshua Goins)
2 parents eacdef8 + ee35448 commit eb41c95

6 files changed

Lines changed: 194 additions & 11 deletions

File tree

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,7 @@
14221422
#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_SW 0x0933
14231423
#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_STAR06 0x0078
14241424
#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_22R_PRO 0x091b
1425+
#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_24_PRO 0x092d
14251426
#define USB_DEVICE_ID_UGEE_TABLET_G5 0x0074
14261427
#define USB_DEVICE_ID_UGEE_TABLET_EX07S 0x0071
14271428
#define USB_DEVICE_ID_UGEE_TABLET_RAINBOW_CV720 0x0055

drivers/hid/hid-uclogic-core.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,23 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
362362
data[8] = pressure_low_byte;
363363
data[9] = pressure_high_byte;
364364
}
365+
if (size == 12 && pen->fragmented_hires2) {
366+
// 00 00 when on the left side, 01 00 in the right
367+
// we move these to the end of the x coord (u16) to create a correct x coord (u32)
368+
u8 lsb_low_byte = data[10];
369+
u8 lsb_high_byte = data[11];
370+
371+
// shift everything right by 2 bytes, to make space for the moved lsb
372+
data[11] = data[9];
373+
data[10] = data[8];
374+
data[9] = data[7];
375+
data[8] = data[6];
376+
data[7] = data[5];
377+
data[6] = data[4];
378+
379+
data[4] = lsb_low_byte;
380+
data[5] = lsb_high_byte;
381+
}
365382
/* If we need to emulate in-range detection */
366383
if (pen->inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) {
367384
/* Set in-range bit */
@@ -604,6 +621,8 @@ static const struct hid_device_id uclogic_devices[] = {
604621
USB_DEVICE_ID_UGEE_XPPEN_TABLET_STAR06) },
605622
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE,
606623
USB_DEVICE_ID_UGEE_XPPEN_TABLET_22R_PRO) },
624+
{ HID_USB_DEVICE(USB_VENDOR_ID_UGEE,
625+
USB_DEVICE_ID_UGEE_XPPEN_TABLET_24_PRO) },
607626
{ }
608627
};
609628
MODULE_DEVICE_TABLE(hid, uclogic_devices);

drivers/hid/hid-uclogic-params.c

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,9 @@ static int uclogic_params_parse_ugee_v2_desc(const __u8 *str_desc,
11231123
return -EINVAL;
11241124

11251125
pen_x_lm = get_unaligned_le16(str_desc + 2);
1126+
if (str_desc_size > 12)
1127+
pen_x_lm += (u8)str_desc[12] << 16;
1128+
11261129
pen_y_lm = get_unaligned_le16(str_desc + 4);
11271130
frame_num_buttons = str_desc[6];
11281131
*frame_type = str_desc[7];
@@ -1534,7 +1537,7 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
15341537
}
15351538

15361539
/*
1537-
* uclogic_params_init_ugee_xppen_pro_22r() - Initializes a UGEE XP-Pen Pro 22R tablet device.
1540+
* uclogic_params_init_ugee_xppen_pro() - Initializes a UGEE XP-Pen Pro tablet device.
15381541
*
15391542
* @hdev: The HID device of the tablet interface to initialize and get
15401543
* parameters from. Cannot be NULL.
@@ -1545,15 +1548,17 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
15451548
* Returns:
15461549
* Zero, if successful. A negative errno code on error.
15471550
*/
1548-
static int uclogic_params_init_ugee_xppen_pro_22r(struct uclogic_params *params,
1549-
struct hid_device *hdev,
1550-
const u8 rdesc_frame_arr[],
1551-
const size_t rdesc_frame_size)
1551+
static int uclogic_params_init_ugee_xppen_pro(struct uclogic_params *params,
1552+
struct hid_device *hdev,
1553+
const u8 rdesc_pen_arr[],
1554+
const size_t rdesc_pen_size,
1555+
const u8 rdesc_frame_arr[],
1556+
const size_t rdesc_frame_size,
1557+
size_t str_desc_len)
15521558
{
15531559
int rc = 0;
15541560
struct usb_interface *iface;
15551561
__u8 bInterfaceNumber;
1556-
const int str_desc_len = 12;
15571562
u8 *str_desc = NULL;
15581563
__u8 *rdesc_pen = NULL;
15591564
s32 desc_params[UCLOGIC_RDESC_PH_ID_NUM];
@@ -1616,16 +1621,16 @@ static int uclogic_params_init_ugee_xppen_pro_22r(struct uclogic_params *params,
16161621

16171622
/* Initialize the pen interface */
16181623
rdesc_pen = uclogic_rdesc_template_apply(
1619-
uclogic_rdesc_ugee_v2_pen_template_arr,
1620-
uclogic_rdesc_ugee_v2_pen_template_size,
1624+
rdesc_pen_arr,
1625+
rdesc_pen_size,
16211626
desc_params, ARRAY_SIZE(desc_params));
16221627
if (!rdesc_pen) {
16231628
rc = -ENOMEM;
16241629
goto cleanup;
16251630
}
16261631

16271632
p.pen.desc_ptr = rdesc_pen;
1628-
p.pen.desc_size = uclogic_rdesc_ugee_v2_pen_template_size;
1633+
p.pen.desc_size = rdesc_pen_size;
16291634
p.pen.id = 0x02;
16301635
p.pen.subreport_list[0].value = 0xf0;
16311636
p.pen.subreport_list[0].id = UCLOGIC_RDESC_V1_FRAME_ID;
@@ -1972,10 +1977,30 @@ int uclogic_params_init(struct uclogic_params *params,
19721977
break;
19731978
case VID_PID(USB_VENDOR_ID_UGEE,
19741979
USB_DEVICE_ID_UGEE_XPPEN_TABLET_22R_PRO):
1975-
rc = uclogic_params_init_ugee_xppen_pro_22r(&p,
1980+
rc = uclogic_params_init_ugee_xppen_pro(&p,
19761981
hdev,
1982+
uclogic_rdesc_ugee_v2_pen_template_arr,
1983+
uclogic_rdesc_ugee_v2_pen_template_size,
19771984
uclogic_rdesc_xppen_artist_22r_pro_frame_arr,
1978-
uclogic_rdesc_xppen_artist_22r_pro_frame_size);
1985+
uclogic_rdesc_xppen_artist_22r_pro_frame_size,
1986+
12);
1987+
if (rc != 0)
1988+
goto cleanup;
1989+
1990+
break;
1991+
case VID_PID(USB_VENDOR_ID_UGEE,
1992+
USB_DEVICE_ID_UGEE_XPPEN_TABLET_24_PRO):
1993+
rc = uclogic_params_init_ugee_xppen_pro(&p,
1994+
hdev,
1995+
uclogic_rdesc_xppen_artist_24_pro_pen_template_arr,
1996+
uclogic_rdesc_xppen_artist_24_pro_pen_template_size,
1997+
uclogic_rdesc_xppen_artist_24_pro_frame_arr,
1998+
uclogic_rdesc_xppen_artist_24_pro_frame_size,
1999+
14);
2000+
2001+
// The 24 Pro has a fragmented X Coord.
2002+
p.pen.fragmented_hires2 = true;
2003+
19792004
if (rc != 0)
19802005
goto cleanup;
19812006

drivers/hid/hid-uclogic-params.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ struct uclogic_params_pen {
103103
* Only valid if "id" is not zero.
104104
*/
105105
bool tilt_y_flipped;
106+
/*
107+
* True, if reports include fragmented high resolution X coords.
108+
* This moves bytes 10-11 to the LSB of the X coordinate.
109+
*/
110+
bool fragmented_hires2;
106111
};
107112

108113
/*

drivers/hid/hid-uclogic-rdesc.c

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,131 @@ const __u8 uclogic_rdesc_xppen_artist_22r_pro_frame_arr[] = {
12371237
const size_t uclogic_rdesc_xppen_artist_22r_pro_frame_size =
12381238
sizeof(uclogic_rdesc_xppen_artist_22r_pro_frame_arr);
12391239

1240+
/* Fixed report descriptor template for XP-PEN 24 Pro reports
1241+
* Mostly identical to uclogic_rdesc_ugee_v2_pen_template_arr except that the X coordinate has to be
1242+
* 32-bits instead of 16-bits.
1243+
*/
1244+
const __u8 uclogic_rdesc_xppen_artist_24_pro_pen_template_arr[] = {
1245+
0x05, 0x0d, /* Usage Page (Digitizers), */
1246+
0x09, 0x01, /* Usage (Digitizer), */
1247+
0xa1, 0x01, /* Collection (Application), */
1248+
0x85, 0x02, /* Report ID (2), */
1249+
0x09, 0x20, /* Usage (Stylus), */
1250+
0xa1, 0x00, /* Collection (Physical), */
1251+
0x09, 0x42, /* Usage (Tip Switch), */
1252+
0x09, 0x44, /* Usage (Barrel Switch), */
1253+
0x09, 0x46, /* Usage (Tablet Pick), */
1254+
0x75, 0x01, /* Report Size (1), */
1255+
0x95, 0x03, /* Report Count (3), */
1256+
0x14, /* Logical Minimum (0), */
1257+
0x25, 0x01, /* Logical Maximum (1), */
1258+
0x81, 0x02, /* Input (Variable), */
1259+
0x95, 0x02, /* Report Count (2), */
1260+
0x81, 0x03, /* Input (Constant, Variable), */
1261+
0x09, 0x32, /* Usage (In Range), */
1262+
0x95, 0x01, /* Report Count (1), */
1263+
0x81, 0x02, /* Input (Variable), */
1264+
0x95, 0x02, /* Report Count (2), */
1265+
0x81, 0x03, /* Input (Constant, Variable), */
1266+
0x75, 0x10, /* Report Size (16), */
1267+
0x95, 0x01, /* Report Count (1), */
1268+
0x35, 0x00, /* Physical Minimum (0), */
1269+
0xa4, /* Push, */
1270+
0x05, 0x01, /* Usage Page (Desktop), */
1271+
0x09, 0x30, /* Usage (X), */
1272+
0x65, 0x13, /* Unit (Inch), */
1273+
0x55, 0x0d, /* Unit Exponent (-3), */
1274+
0x27, UCLOGIC_RDESC_PEN_PH(X_LM),
1275+
/* Logical Maximum (PLACEHOLDER), */
1276+
0x47, UCLOGIC_RDESC_PEN_PH(X_PM),
1277+
/* Physical Maximum (PLACEHOLDER), */
1278+
0x75, 0x20, /* Report Size (32), */
1279+
0x81, 0x02, /* Input (Variable), */
1280+
0x75, 0x10, /* Report Size (16), */
1281+
0x09, 0x31, /* Usage (Y), */
1282+
0x27, UCLOGIC_RDESC_PEN_PH(Y_LM),
1283+
/* Logical Maximum (PLACEHOLDER), */
1284+
0x47, UCLOGIC_RDESC_PEN_PH(Y_PM),
1285+
/* Physical Maximum (PLACEHOLDER), */
1286+
0x81, 0x02, /* Input (Variable), */
1287+
0xb4, /* Pop, */
1288+
0x09, 0x30, /* Usage (Tip Pressure), */
1289+
0x45, 0x00, /* Physical Maximum (0), */
1290+
0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM),
1291+
/* Logical Maximum (PLACEHOLDER), */
1292+
0x75, 0x0D, /* Report Size (13), */
1293+
0x95, 0x01, /* Report Count (1), */
1294+
0x81, 0x02, /* Input (Variable), */
1295+
0x75, 0x01, /* Report Size (1), */
1296+
0x95, 0x03, /* Report Count (3), */
1297+
0x81, 0x01, /* Input (Constant), */
1298+
0x09, 0x3d, /* Usage (X Tilt), */
1299+
0x35, 0xC3, /* Physical Minimum (-61), */
1300+
0x45, 0x3C, /* Physical Maximum (60), */
1301+
0x15, 0xC3, /* Logical Minimum (-61), */
1302+
0x25, 0x3C, /* Logical Maximum (60), */
1303+
0x75, 0x08, /* Report Size (8), */
1304+
0x95, 0x01, /* Report Count (1), */
1305+
0x81, 0x02, /* Input (Variable), */
1306+
0x09, 0x3e, /* Usage (Y Tilt), */
1307+
0x35, 0xC3, /* Physical Minimum (-61), */
1308+
0x45, 0x3C, /* Physical Maximum (60), */
1309+
0x15, 0xC3, /* Logical Minimum (-61), */
1310+
0x25, 0x3C, /* Logical Maximum (60), */
1311+
0x81, 0x02, /* Input (Variable), */
1312+
0xc0, /* End Collection, */
1313+
0xc0, /* End Collection */
1314+
};
1315+
const size_t uclogic_rdesc_xppen_artist_24_pro_pen_template_size =
1316+
sizeof(uclogic_rdesc_xppen_artist_24_pro_pen_template_arr);
1317+
1318+
/* Fixed report descriptor for XP-Pen Arist 24 Pro frame */
1319+
const __u8 uclogic_rdesc_xppen_artist_24_pro_frame_arr[] = {
1320+
0x05, 0x01, /* Usage Page (Desktop), */
1321+
0x09, 0x07, /* Usage (Keypad), */
1322+
0xA1, 0x01, /* Collection (Application), */
1323+
0x85, UCLOGIC_RDESC_V1_FRAME_ID,
1324+
/* Report ID (Virtual report), */
1325+
0x05, 0x0D, /* Usage Page (Digitizer), */
1326+
0x09, 0x39, /* Usage (Tablet Function Keys), */
1327+
0xA0, /* Collection (Physical), */
1328+
0x14, /* Logical Minimum (0), */
1329+
0x25, 0x01, /* Logical Maximum (1), */
1330+
0x75, 0x01, /* Report Size (1), */
1331+
0x95, 0x08, /* Report Count (8), */
1332+
0x81, 0x01, /* Input (Constant), */
1333+
0x05, 0x09, /* Usage Page (Button), */
1334+
0x19, 0x01, /* Usage Minimum (01h), */
1335+
0x29, 0x14, /* Usage Maximum (14h), */
1336+
0x95, 0x14, /* Report Count (20), */
1337+
0x81, 0x02, /* Input (Variable), */
1338+
0x95, 0x14, /* Report Count (20), */
1339+
0x81, 0x01, /* Input (Constant), */
1340+
0x05, 0x01, /* Usage Page (Desktop), */
1341+
0x09, 0x38, /* Usage (Wheel), */
1342+
0x75, 0x08, /* Report Size (8), */
1343+
0x95, 0x01, /* Report Count (1), */
1344+
0x15, 0xFF, /* Logical Minimum (-1), */
1345+
0x25, 0x08, /* Logical Maximum (8), */
1346+
0x81, 0x06, /* Input (Variable, Relative), */
1347+
0x05, 0x0C, /* Usage Page (Consumer Devices), */
1348+
0x0A, 0x38, 0x02, /* Usage (AC PAN), */
1349+
0x95, 0x01, /* Report Count (1), */
1350+
0x81, 0x06, /* Input (Variable, Relative), */
1351+
0x26, 0xFF, 0x00, /* Logical Maximum (255), */
1352+
0x75, 0x08, /* Report Size (8), */
1353+
0x95, 0x01, /* Report Count (1), */
1354+
0x81, 0x02, /* Input (Variable), */
1355+
0x75, 0x01, /* Report Size (1), */
1356+
0x95, 16, /* Report Count (16), */
1357+
0x81, 0x01, /* Input (Constant), */
1358+
0xC0, /* End Collection */
1359+
0xC0, /* End Collection */
1360+
};
1361+
1362+
const size_t uclogic_rdesc_xppen_artist_24_pro_frame_size =
1363+
sizeof(uclogic_rdesc_xppen_artist_24_pro_frame_arr);
1364+
12401365
/**
12411366
* uclogic_rdesc_template_apply() - apply report descriptor parameters to a
12421367
* report descriptor template, creating a report descriptor. Copies the

drivers/hid/hid-uclogic-rdesc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,12 @@ extern const size_t uclogic_rdesc_ugee_g5_frame_size;
214214
extern const __u8 uclogic_rdesc_xppen_artist_22r_pro_frame_arr[];
215215
extern const size_t uclogic_rdesc_xppen_artist_22r_pro_frame_size;
216216

217+
/* Fixed report descriptor for XP-Pen Arist 24 Pro frame */
218+
extern const __u8 uclogic_rdesc_xppen_artist_24_pro_pen_template_arr[];
219+
extern const size_t uclogic_rdesc_xppen_artist_24_pro_pen_template_size;
220+
221+
/* Fixed report descriptor for XP-Pen Arist 24 Pro frame */
222+
extern const __u8 uclogic_rdesc_xppen_artist_24_pro_frame_arr[];
223+
extern const size_t uclogic_rdesc_xppen_artist_24_pro_frame_size;
224+
217225
#endif /* _HID_UCLOGIC_RDESC_H */

0 commit comments

Comments
 (0)