Skip to contentSkip to conversation

HID: uclogic: Add support for XP-PEN Artist 22R Pro

PATCH New Joshua Goins 1 participant 3 messages Feb 4, 2023 HID

lore
Share & tools
lore
#0 lore raw

v3 cover HID: uclogic: Add support for XP-PEN Artist 22R Pro

Adds support for the XP-PEN Artist 22R Pro, including stylus, tablet frame and pen pressure.

The tablet has 20 buttons, but need to be remapped in order since the device reports invalid keycodes. Existing tablet functionality should not be inhibited, as BTN0-8 is still used.

New initialization functions are added since the device differs slightly from other UGEE v2 devices.

---
v3 changes:
- Removed duplicate frame initialization code, overriding the num of frame buttons instead.
- Removed unnessecary key > 0 check.
- Renamed init function to something more specific to the device.
- Cherry-picked probe magic data patch.
- Rebased onto 6.2-rc6
v2 changes:
- rewrote initialization code to be more concise, and less error-prone, thanks Dan Carpenter & José Expósito for pointers!
- less struct duplication, it now uses compatiable UGEE v2 ones.
- uclogic_extra_input_mapping is now static, thanks José again!
- straightened out dial transformation, now there's just the two cases and they're decimal.
- fixed the patch formatting, it should be easier to apply now.
- rebased onto 6.2-rc2

Joshua Goins (1):
HID: uclogic: Add support for XP-PEN Artist 22R Pro

José Expósito (1):
HID: uclogic: Refactor UGEEv2 probe magic data

 drivers/hid/hid-ids.h            |   1 +
 drivers/hid/hid-uclogic-core.c   |  66 +++++++++++++-
 drivers/hid/hid-uclogic-params.c | 143 +++++++++++++++++++++++++++++--
 drivers/hid/hid-uclogic-params.h |   5 ++
 drivers/hid/hid-uclogic-rdesc.c  |  50 +++++++++++
 drivers/hid/hid-uclogic-rdesc.h  |   9 ++
 6 files changed, 264 insertions(+), 10 deletions(-)

base-commit: 0136d86b78522bbd5755f8194c97a987f0586ba5

Signature · 1 line
2.39.1
#1 lore raw

PATCH v3 1/2 HID: uclogic: Refactor UGEEv2 probe magic data

From: José Expósito <[email protected]>

A fututure patch will need to use the array of magic data that the UGEEv2 devices expect on probe and the endpoint number. Move them to a common place.

Refactor, no functional changes.

---
 drivers/hid/hid-uclogic-params.c | 11 +++++------
 drivers/hid/hid-uclogic-rdesc.c  |  6 ++++++
 drivers/hid/hid-uclogic-rdesc.h  |  5 +++++
 3 files changed, 16 insertions(+), 6 deletions(-)
drivers/hid/hid-uclogic-params.c +5 -6
index 3c5eea3df328..d68cb99a03de 100644
@@ -1021,8 +1021,8 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
  * Returns:
  *	Zero, if successful. A negative errno code on error.
  */
-static int uclogic_probe_interface(struct hid_device *hdev, u8 *magic_arr,
-				   int magic_size, int endpoint)
+static int uclogic_probe_interface(struct hid_device *hdev, const u8 *magic_arr,
+				   size_t magic_size, int endpoint)
 {
 	struct usb_device *udev;
 	unsigned int pipe = 0;
@@ -1305,9 +1305,6 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
 	__u8 *rdesc_pen = NULL;
 	s32 desc_params[UCLOGIC_RDESC_PH_ID_NUM];
 	enum uclogic_params_frame_type frame_type;
-	__u8 magic_arr[] = {
-		0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-	};
 	/* The resulting parameters (noop) */
 	struct uclogic_params p = {0, };
 
@@ -1337,7 +1334,9 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
 	 * The specific data was discovered by sniffing the Windows driver
 	 * traffic.
 	 */
-	rc = uclogic_probe_interface(hdev, magic_arr, sizeof(magic_arr), 0x03);
+	rc = uclogic_probe_interface(hdev, uclogic_ugee_v2_probe_arr,
+				     uclogic_ugee_v2_probe_size,
+				     uclogic_ugee_v2_probe_endpoint);
 	if (rc) {
 		uclogic_params_init_invalid(&p);
 		goto output;
drivers/hid/hid-uclogic-rdesc.c +6 -0
index fb40775f5f5b..b6dfdf6356a6 100644
@@ -859,6 +859,12 @@ const __u8 uclogic_rdesc_v2_frame_dial_arr[] = {
 const size_t uclogic_rdesc_v2_frame_dial_size =
 			sizeof(uclogic_rdesc_v2_frame_dial_arr);
 
+const __u8 uclogic_ugee_v2_probe_arr[] = {
+	0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+const size_t uclogic_ugee_v2_probe_size = sizeof(uclogic_ugee_v2_probe_arr);
+const int uclogic_ugee_v2_probe_endpoint = 0x03;
+
 /* Fixed report descriptor template for UGEE v2 pen reports */
 const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[] = {
 	0x05, 0x0d,         /*  Usage Page (Digitizers),                */
drivers/hid/hid-uclogic-rdesc.h +5 -0
index a1f78c07293f..906d068f50a9 100644
@@ -164,6 +164,11 @@ extern const size_t uclogic_rdesc_v2_frame_dial_size;
 /* Report ID for tweaked UGEE v2 battery reports */
 #define UCLOGIC_RDESC_UGEE_V2_BATTERY_ID 0xba
 
+/* Magic data expected by UGEEv2 devices on probe */
+extern const __u8 uclogic_ugee_v2_probe_arr[];
+extern const size_t uclogic_ugee_v2_probe_size;
+extern const int uclogic_ugee_v2_probe_endpoint;
+
 /* Fixed report descriptor template for UGEE v2 pen reports */
 extern const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[];
 extern const size_t uclogic_rdesc_ugee_v2_pen_template_size;
Signature · 1 line
2.39.1
#2 lore raw

PATCH v3 2/2 HID: uclogic: Add support for XP-PEN Artist 22R Pro

In reply to Joshua Goins

Adds support for the XP-PEN Artist 22R Pro, including stylus, tablet frame and pen pressure.

The tablet has 20 buttons, but need to be remapped in order since the device reports invalid keycodes. Existing tablet functionality should not be inhibited, as BTN0-8 is still used.

New initialization functions are added since the device differs slightly from other UGEE v2 devices.

---
 drivers/hid/hid-ids.h            |   1 +
 drivers/hid/hid-uclogic-core.c   |  66 +++++++++++++++-
 drivers/hid/hid-uclogic-params.c | 132 +++++++++++++++++++++++++++++++
 drivers/hid/hid-uclogic-params.h |   5 ++
 drivers/hid/hid-uclogic-rdesc.c  |  44 +++++++++++
 drivers/hid/hid-uclogic-rdesc.h  |   4 +
 6 files changed, 248 insertions(+), 4 deletions(-)
drivers/hid/hid-ids.h +1 -0
index 0f8c11842a3a..ac8b06fed870 100644
@@ -1298,6 +1298,7 @@
 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L	0x0935
 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_S	0x0909
 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_STAR06	0x0078
+#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_22R_PRO	0x091b
 #define USB_DEVICE_ID_UGEE_TABLET_G5		0x0074
 #define USB_DEVICE_ID_UGEE_TABLET_EX07S		0x0071
 #define USB_DEVICE_ID_UGEE_TABLET_RAINBOW_CV720	0x0055
drivers/hid/hid-uclogic-core.c +62 -4

91 lines not on this page · raw message

drivers/hid/hid-uclogic-params.c +132 -0

150 lines not on this page · raw message

drivers/hid/hid-uclogic-params.h +5 -0
index a97477c02ff8..6621a75a4b1a 100644
@@ -171,6 +171,11 @@ struct uclogic_params_frame {
 	 * counterclockwise, as opposed to the normal 1 and -1.
 	 */
 	unsigned int bitmap_dial_byte;
+	/*
+	 * Destination offset for the second bitmap dial byte, if the tablet
+	 * supports a second dial at all.
+	 */
+	unsigned int bitmap_second_dial_destination_byte;
 };
 
 /*
drivers/hid/hid-uclogic-rdesc.c +44 -0

50 lines not on this page · raw message

drivers/hid/hid-uclogic-rdesc.h +4 -0
index 906d068f50a9..c3cb2c75dda5 100644
@@ -210,4 +210,8 @@ extern const size_t uclogic_rdesc_ugee_g5_frame_size;
 /* Least-significant bit of Ugee G5 frame rotary encoder state */
 #define UCLOGIC_RDESC_UGEE_G5_FRAME_RE_LSB 38
 
+/* Fixed report descriptor for XP-Pen Arist 22R Pro frame */
+extern const __u8 uclogic_rdesc_xppen_artist_22r_pro_frame_arr[];
+extern const size_t uclogic_rdesc_xppen_artist_22r_pro_frame_size;
+
 #endif /* _HID_UCLOGIC_RDESC_H */
Signature · 1 line
2.39.1