Skip to contentSkip to conversation

DIGImend patches, part one

PATCH In review José Expósito 2 participants 9 messages Feb 10, 2022 – Feb 16, 2022 HID

lore
Share & tools
lore
#0 lore raw

cover DIGImend patches, part one

Hi everyone,

I'm working on the UC Logic driver to add support for my tablet. After some work, I noticed that I needed some patches from the DIGImend project [1].

Instead of cherry picking what I needed, I decided to go the hard way and upstream every change present in DIGImend but missing in the kernel with the intention of making development easier in the future for everyone and providing better hardware support.

In a private conversation with DIGImend's maintainer, Nikolai Kondrashov, I asked him for permission to upstream his changes and he said it was fine :) All credit goes to him, I only fixed his patches so they apply, fixed minor checkpatch errors, squashed related changes and reviewed and tested them when my hardware allowed me to.

This is the first series of patches from DIGImend. There are 37 patches in total [2], but I can imagine nobody wants to review such a long series, so I'll be sending small groups of related patches... Unless someone feels brave and tells me to send all of them ;)

Thank you very much in advance,
José Expósito

[1] https://github.com/DIGImend/digimend-kernel-drivers
[2] https://github.com/JoseExposito/linux/commits/patch-digimend-parblo-patches-mailing-list

Nikolai Kondrashov (7):
HID: uclogic: Support Huion tilt reporting
HID: uclogic: Rename Huion HS64 PID to Huion Tablet 2
HID: uclogic: Support Huion 13th frame button
HID: uclogic: Split pen and frame raw event handling
HID: uclogic: Access pen/frame params directly in raw_event handling
HID: uclogic: Skip non-input raw events earlier
HID: uclogic: Handle virtual frame reports

 drivers/hid/hid-ids.h            |   2 +-
 drivers/hid/hid-uclogic-core.c   | 205 +++++++++++++++++++------------
 drivers/hid/hid-uclogic-params.c |   3 +-
 drivers/hid/hid-uclogic-params.h |   8 ++
 drivers/hid/hid-uclogic-rdesc.c  |  20 ++-
 5 files changed, 153 insertions(+), 85 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/7 HID: uclogic: Support Huion tilt reporting

From: Nikolai Kondrashov <[email protected]>

Add support for Huion v2 protocol tilt reporting. Describe reports as angles in degrees, which is not exactly true, but there doesn't seem to be a straightforward, consistent conversion possible, and what's reported would have to be enough.

---
 drivers/hid/hid-uclogic-core.c   |  3 +++
 drivers/hid/hid-uclogic-params.c |  1 +
 drivers/hid/hid-uclogic-params.h |  8 ++++++++
 drivers/hid/hid-uclogic-rdesc.c  | 12 +++++++++++-
 4 files changed, 23 insertions(+), 1 deletion(-)
drivers/hid/hid-uclogic-core.c +3 -0
index d8ab0139e5cd..823704bc02ef 100644
@@ -304,6 +304,9 @@ static int uclogic_raw_event(struct hid_device *hdev,
 			mod_timer(&drvdata->inrange_timer,
 					jiffies + msecs_to_jiffies(100));
 		}
+		/* If we report tilt and Y direction is flipped */
+		if (size >= 12 && params->pen.tilt_y_flipped)
+			data[11] = -data[11];
 	}
 
 	/* Tweak frame control reports, if necessary */
drivers/hid/hid-uclogic-params.c +1 -0
index 3e70f969fb84..30e0f69ed5af 100644
@@ -369,6 +369,7 @@ static int uclogic_params_pen_init_v2(struct uclogic_params_pen *pen,
 	pen->id = UCLOGIC_RDESC_PEN_V2_ID;
 	pen->inrange = UCLOGIC_PARAMS_PEN_INRANGE_NONE;
 	pen->fragmented_hires = true;
+	pen->tilt_y_flipped = true;
 	found = true;
 finish:
 	*pfound = found;
drivers/hid/hid-uclogic-params.h +8 -0
index ba48b1c7a0e5..e8381bb77bd0 100644
@@ -62,6 +62,12 @@ struct uclogic_params_pen {
 	 * Only valid if "id" is not zero.
 	 */
 	bool fragmented_hires;
+	/*
+	 * True if the pen reports tilt in bytes at offset 10 (X) and 11 (Y),
+	 * and the Y tilt direction is flipped.
+	 * Only valid if "id" is not zero.
+	 */
+	bool tilt_y_flipped;
 };
 
 /*
@@ -171,6 +177,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
 		".pen.id = %u\n"                    \
 		".pen.inrange = %s\n"               \
 		".pen.fragmented_hires = %s\n"      \
+		".pen.tilt_y_flipped = %s\n"        \
 		".frame.desc_ptr = %p\n"            \
 		".frame.desc_size = %u\n"           \
 		".frame.id = %u\n"                  \
@@ -189,6 +196,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
 		(_params)->pen.id,                                          \
 		uclogic_params_pen_inrange_to_str((_params)->pen.inrange),  \
 		((_params)->pen.fragmented_hires ? "true" : "false"),       \
+		((_params)->pen.tilt_y_flipped ? "true" : "false"),         \
 		(_params)->frame.desc_ptr,                                  \
 		(_params)->frame.desc_size,                                 \
 		(_params)->frame.id,                                        \
drivers/hid/hid-uclogic-rdesc.c +11 -1
index 6dd6dcd09c8b..2607cbdf8ff2 100644
@@ -633,7 +633,17 @@ const __u8 uclogic_rdesc_pen_v2_template_arr[] = {
 	0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM),
 				/*          Logical Maximum (PLACEHOLDER),  */
 	0x81, 0x02,             /*          Input (Variable),               */
-	0x81, 0x03,             /*          Input (Constant, Variable),     */
+	0x54,                   /*          Unit Exponent (0),              */
+	0x65, 0x14,             /*          Unit (Degrees),                 */
+	0x35, 0xC4,             /*          Physical Minimum (-60),         */
+	0x45, 0x3C,             /*          Physical Maximum (60),          */
+	0x15, 0xC4,             /*          Logical Minimum (-60),          */
+	0x25, 0x3C,             /*          Logical Maximum (60),           */
+	0x75, 0x08,             /*          Report Size (8),                */
+	0x95, 0x02,             /*          Report Count (2),               */
+	0x09, 0x3D,             /*          Usage (X Tilt),                 */
+	0x09, 0x3E,             /*          Usage (Y Tilt),                 */
+	0x81, 0x02,             /*          Input (Variable),               */
 	0xC0,                   /*      End Collection,                     */
 	0xC0                    /*  End Collection                          */
 };
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/7 HID: uclogic: Rename Huion HS64 PID to Huion Tablet 2

In reply to José Expósito

From: Nikolai Kondrashov <[email protected]>

Since the 006d Huion PID is used by multiple tablets (at least HS64 and HS610), rename its constant to a more general "USB_DEVICE_ID_HUION_TABLET2".

---
 drivers/hid/hid-ids.h            | 2 +-
 drivers/hid/hid-uclogic-core.c   | 2 +-
 drivers/hid/hid-uclogic-params.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/hid/hid-ids.h +1 -1
index 85975031389b..10780a076693 100644
@@ -606,7 +606,7 @@
 
 #define USB_VENDOR_ID_HUION		0x256c
 #define USB_DEVICE_ID_HUION_TABLET	0x006e
-#define USB_DEVICE_ID_HUION_HS64	0x006d
+#define USB_DEVICE_ID_HUION_TABLET2	0x006d
 
 #define USB_VENDOR_ID_IBM					0x04b3
 #define USB_DEVICE_ID_IBM_SCROLLPOINT_III			0x3100
drivers/hid/hid-uclogic-core.c +1 -1
index 823704bc02ef..850c660ec2ab 100644
@@ -376,7 +376,7 @@ static const struct hid_device_id uclogic_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_HUION,
 				USB_DEVICE_ID_HUION_TABLET) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_HUION,
-				USB_DEVICE_ID_HUION_HS64) },
+				USB_DEVICE_ID_HUION_TABLET2) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_TRUST,
 				USB_DEVICE_ID_TRUST_PANORA_TABLET) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
drivers/hid/hid-uclogic-params.c +1 -1
index 30e0f69ed5af..98910d8dae92 100644
@@ -993,7 +993,7 @@ int uclogic_params_init(struct uclogic_params *params,
 	case VID_PID(USB_VENDOR_ID_HUION,
 		     USB_DEVICE_ID_HUION_TABLET):
 	case VID_PID(USB_VENDOR_ID_HUION,
-		     USB_DEVICE_ID_HUION_HS64):
+		     USB_DEVICE_ID_HUION_TABLET2):
 	case VID_PID(USB_VENDOR_ID_UCLOGIC,
 		     USB_DEVICE_ID_HUION_TABLET):
 	case VID_PID(USB_VENDOR_ID_UCLOGIC,
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/7 HID: uclogic: Support Huion 13th frame button

In reply to José Expósito

From: Nikolai Kondrashov <[email protected]>

Support reporting 13th frame button for Huion tablets. This supports reporting the button in the center of the dial for Huion HS610.

---
 drivers/hid/hid-uclogic-rdesc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hid/hid-uclogic-rdesc.c +4 -4
index 2607cbdf8ff2..ec16355d200b 100644
@@ -689,8 +689,8 @@ const size_t uclogic_rdesc_pen_v2_template_size =
 	0xA0,           /*      Collection (Physical),          */ \
 	0x05, 0x09,     /*          Usage Page (Button),        */ \
 	0x19, 0x01,     /*          Usage Minimum (01h),        */ \
-	0x29, 0x02,     /*          Usage Maximum (02h),        */ \
-	0x95, 0x02,     /*          Report Count (2),           */ \
+	0x29, 0x03,     /*          Usage Maximum (03h),        */ \
+	0x95, 0x03,     /*          Report Count (3),           */ \
 	0x81, 0x02,     /*          Input (Variable),           */ \
 	0x95, _padding, /*          Report Count (_padding),    */ \
 	0x81, 0x01,     /*          Input (Constant),           */ \
@@ -699,14 +699,14 @@ const size_t uclogic_rdesc_pen_v2_template_size =
 
 /* Fixed report descriptor for (tweaked) v1 buttonpad reports */
 const __u8 uclogic_rdesc_buttonpad_v1_arr[] = {
-	UCLOGIC_RDESC_BUTTONPAD_BYTES(20)
+	UCLOGIC_RDESC_BUTTONPAD_BYTES(19)
 };
 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)
+	UCLOGIC_RDESC_BUTTONPAD_BYTES(51)
 };
 const size_t uclogic_rdesc_buttonpad_v2_size =
 			sizeof(uclogic_rdesc_buttonpad_v2_arr);
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/7 HID: uclogic: Split pen and frame raw event handling

In reply to José Expósito

From: Nikolai Kondrashov <[email protected]>

In order to avoid ending up with a big uclogic_raw_event function, split it in two smaller functions: uclogic_raw_event_pen for the pen events and uclogic_raw_event_frame for the pad events.

---
 drivers/hid/hid-uclogic-core.c | 195 ++++++++++++++++++++-------------
 1 file changed, 120 insertions(+), 75 deletions(-)
drivers/hid/hid-uclogic-core.c +120 -75
index 850c660ec2ab..9187fd835a46 100644
@@ -246,6 +246,123 @@ static int uclogic_resume(struct hid_device *hdev)
 }
 #endif
 
+/**
+ * uclogic_raw_event_pen - handle raw pen events (pen HID reports).
+ *
+ * @drvdata:	Driver data.
+ * @data:	Report data buffer, can be modified.
+ * @size:	Report data size, bytes.
+ *
+ * Returns:
+ *	Negative value on error (stops event delivery), zero for success.
+ */
+static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
+					u8 *data, int size)
+{
+	struct uclogic_params *params = &drvdata->params;
+
+	WARN_ON(drvdata == NULL);
+	WARN_ON(data == NULL && size != 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));
+	}
+	/* If we report tilt and Y direction is flipped */
+	if (size >= 12 && params->pen.tilt_y_flipped)
+		data[11] = -data[11];
+
+	return 0;
+}
+
+/**
+ * uclogic_raw_event_frame - handle raw frame events (frame HID reports).
+ *
+ * @drvdata:	Driver data.
+ * @data:	Report data buffer, can be modified.
+ * @size:	Report data size, bytes.
+ *
+ * Returns:
+ *	Negative value on error (stops event delivery), zero for success.
+ */
+static int uclogic_raw_event_frame(struct uclogic_drvdata *drvdata,
+					u8 *data, int size)
+{
+	struct uclogic_params *params = &drvdata->params;
+
+	WARN_ON(drvdata == NULL);
+	WARN_ON(data == NULL && size != 0);
+
+	/* 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 int uclogic_raw_event(struct hid_device *hdev,
 				struct hid_report *report,
 				u8 *data, int size)
@@ -265,85 +382,13 @@ static int uclogic_raw_event(struct hid_device *hdev,
 			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));
-		}
-		/* If we report tilt and Y direction is flipped */
-		if (size >= 12 && params->pen.tilt_y_flipped)
-			data[11] = -data[11];
+		return uclogic_raw_event_pen(drvdata, data, size);
 	}
 
 	/* 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;
-		}
-	}
+	    (report->id == params->frame.id))
+		return uclogic_raw_event_frame(drvdata, data, size);
 
 	return 0;
 }
Signature · 1 line
2.25.1
#5 lore raw

PATCH 5/7 HID: uclogic: Access pen/frame params directly in raw_event handling

In reply to José Expósito

From: Nikolai Kondrashov <[email protected]>

Simplify the raw event handling code by accessing the uclogic_params_pen/uclogic_params_frame structs directly.

---
 drivers/hid/hid-uclogic-core.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/hid/hid-uclogic-core.c +11 -13
index 9187fd835a46..56b76d9b46af 100644
@@ -259,13 +259,13 @@ static int uclogic_resume(struct hid_device *hdev)
 static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
 					u8 *data, int size)
 {
-	struct uclogic_params *params = &drvdata->params;
+	struct uclogic_params_pen *pen = &drvdata->params.pen;
 
 	WARN_ON(drvdata == NULL);
 	WARN_ON(data == NULL && size != 0);
 
 	/* If in-range reports are inverted */
-	if (params->pen.inrange ==
+	if (pen->inrange ==
 		UCLOGIC_PARAMS_PEN_INRANGE_INVERTED) {
 		/* Invert the in-range bit */
 		data[1] ^= 0x40;
@@ -274,7 +274,7 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
 	 * If report contains fragmented high-resolution pen
 	 * coordinates
 	 */
-	if (size >= 10 && params->pen.fragmented_hires) {
+	if (size >= 10 && pen->fragmented_hires) {
 		u8 pressure_low_byte;
 		u8 pressure_high_byte;
 
@@ -296,7 +296,7 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
 		data[9] = pressure_high_byte;
 	}
 	/* If we need to emulate in-range detection */
-	if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) {
+	if (pen->inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) {
 		/* Set in-range bit */
 		data[1] |= 0x40;
 		/* (Re-)start in-range timeout */
@@ -304,7 +304,7 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
 				jiffies + msecs_to_jiffies(100));
 	}
 	/* If we report tilt and Y direction is flipped */
-	if (size >= 12 && params->pen.tilt_y_flipped)
+	if (size >= 12 && pen->tilt_y_flipped)
 		data[11] = -data[11];
 
 	return 0;
@@ -323,21 +323,19 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
 static int uclogic_raw_event_frame(struct uclogic_drvdata *drvdata,
 					u8 *data, int size)
 {
-	struct uclogic_params *params = &drvdata->params;
+	struct uclogic_params_frame *frame = &drvdata->params.frame;
 
 	WARN_ON(drvdata == NULL);
 	WARN_ON(data == NULL && size != 0);
 
 	/* 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 (frame->dev_id_byte > 0 && frame->dev_id_byte < size) {
+		data[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;
+	if (frame->re_lsb > 0 && frame->re_lsb / 8 < size) {
+		unsigned int byte = frame->re_lsb / 8;
+		unsigned int bit = frame->re_lsb % 8;
 
 		u8 change;
 		u8 prev_state = drvdata->re_state;
Signature · 1 line
2.25.1
#6 lore raw

PATCH 6/7 HID: uclogic: Skip non-input raw events earlier

In reply to José Expósito

From: Nikolai Kondrashov <[email protected]>

Early return when a non-input raw event is received to simplify the logic present in uclogic_raw_event.

---
 drivers/hid/hid-uclogic-core.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/hid/hid-uclogic-core.c +5 -3
index 56b76d9b46af..8aac3f7a9cda 100644
@@ -368,9 +368,12 @@ static int uclogic_raw_event(struct hid_device *hdev,
 	struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
 	struct uclogic_params *params = &drvdata->params;
 
+	/* Do not handle anything but input reports */
+	if (report->type != HID_INPUT_REPORT)
+		return 0;
+
 	/* 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 */
@@ -384,8 +387,7 @@ static int uclogic_raw_event(struct hid_device *hdev,
 	}
 
 	/* Tweak frame control reports, if necessary */
-	if ((report->type == HID_INPUT_REPORT) &&
-	    (report->id == params->frame.id))
+	if (report->id == params->frame.id)
 		return uclogic_raw_event_frame(drvdata, data, size);
 
 	return 0;
Signature · 1 line
2.25.1
#7 lore raw

PATCH 7/7 HID: uclogic: Handle virtual frame reports

In reply to José Expósito

From: Nikolai Kondrashov <[email protected]>

Explicitly change report ID to virtual ID and handle virtual frame reports as real for consistency.

---
 drivers/hid/hid-uclogic-core.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/hid/hid-uclogic-core.c +6 -5
index 8aac3f7a9cda..73d79d149869 100644
@@ -365,6 +365,7 @@ static int uclogic_raw_event(struct hid_device *hdev,
 				struct hid_report *report,
 				u8 *data, int size)
 {
+	unsigned int report_id = report->id;
 	struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
 	struct uclogic_params *params = &drvdata->params;
 
@@ -374,20 +375,20 @@ static int uclogic_raw_event(struct hid_device *hdev,
 
 	/* Tweak pen reports, if necessary */
 	if (!params->pen_unused &&
-	    (report->id == params->pen.id) &&
+	    (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;
+			report_id = data[0] = params->frame.id;
+		} else {
+			return uclogic_raw_event_pen(drvdata, data, size);
 		}
-		return uclogic_raw_event_pen(drvdata, data, size);
 	}
 
 	/* Tweak frame control reports, if necessary */
-	if (report->id == params->frame.id)
+	if (report_id == params->frame.id)
 		return uclogic_raw_event_frame(drvdata, data, size);
 
 	return 0;
Signature · 1 line
2.25.1
maintainer
#8 lore raw
In reply to José Expósito
Quoted 16 lines · José Expósito

I'm working on the UC Logic driver to add support for my tablet. After some work, I noticed that I needed some patches from the DIGImend project [1].

Instead of cherry picking what I needed, I decided to go the hard way and upstream every change present in DIGImend but missing in the kernel with the intention of making development easier in the future for everyone and providing better hardware support.

In a private conversation with DIGImend's maintainer, Nikolai Kondrashov, I asked him for permission to upstream his changes and he said it was fine :) All credit goes to him, I only fixed his patches so they apply, fixed minor checkpatch errors, squashed related changes and reviewed and tested them when my hardware allowed me to.

Quoted 3 lines

This is the first series of patches from DIGImend. There are 37 patches in total [2], but I can imagine nobody wants to review such a long series, so I'll be sending small groups of related patches...

Thanks a lot for consideration :)

Quoted 1 line

Unless someone feels brave and tells me to send all of them ;)

Definitely not me :)

The patches look good to me, and I see Nikolai is CCed, so I've now queued them in hid.git#for-5.18/uclogic

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs