linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-5.18/uclogic 0/4] DIGImend patches, part III
@ 2022-03-03  7:47 José Expósito
  2022-03-03  7:47 ` [PATCH for-5.18/uclogic 1/4] HID: uclogic: Add support for touch ring reports José Expósito
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: José Expósito @ 2022-03-03  7:47 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
	José Expósito

Hi everyone,

This series is a follow up to [1] and [2], kindly reviewed and applied
by Jiří in hid.git#for-5.18/uclogic.

It adds support for touch rings in order handle the Huion HS610 tablet.

Thank you very much to Nikolai for the patches a to the maintaners for
the quick reviews,
José Expósito

[1] https://lore.kernel.org/linux-input/nycvar.YFH.7.76.2202161642180.11721@cbobk.fhfr.pm/T/
[2] https://lore.kernel.org/linux-input/56454560-5f62-05b9-1a24-3f51a305140e@gmail.com/T/

Nikolai Kondrashov (4):
  HID: uclogic: Add support for touch ring reports
  HID: uclogic: Support custom device suffix for frames
  HID: uclogic: Allow three frame parameter sets
  HID: uclogic: Add support for Huion touch ring reports

 drivers/hid/hid-uclogic-core.c   | 83 +++++++++++++++++++++--------
 drivers/hid/hid-uclogic-params.c | 40 +++++++++++---
 drivers/hid/hid-uclogic-params.h | 90 +++++++++++++++++++++++++++++---
 drivers/hid/hid-uclogic-rdesc.c  | 65 ++++++++++++++++++++---
 drivers/hid/hid-uclogic-rdesc.h  | 20 +++++--
 5 files changed, 250 insertions(+), 48 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH for-5.18/uclogic 1/4] HID: uclogic: Add support for touch ring reports
  2022-03-03  7:47 [PATCH for-5.18/uclogic 0/4] DIGImend patches, part III José Expósito
@ 2022-03-03  7:47 ` José Expósito
  2022-03-03  7:47 ` [PATCH for-5.18/uclogic 2/4] HID: uclogic: Support custom device suffix for frames José Expósito
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: José Expósito @ 2022-03-03  7:47 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
	José Expósito

From: Nikolai Kondrashov <spbnick@gmail.com>

Add support for touch ring to UC-Logic driver. The touch ring reports
can be flipped around a specific point to match the orientation and
direction reported by the Wacom drivers. The proximity will also be
reported similar to the Wacom drivers.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
 drivers/hid/hid-uclogic-core.c   | 39 +++++++++++++++++++++++++++++++-
 drivers/hid/hid-uclogic-params.h | 36 +++++++++++++++++++++++++----
 2 files changed, 70 insertions(+), 5 deletions(-)

diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index 05147f2d7564..b448616dacb9 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -90,6 +90,8 @@ static int uclogic_input_configured(struct hid_device *hdev,
 	const char *suffix = NULL;
 	struct hid_field *field;
 	size_t len;
+	size_t i;
+	const struct uclogic_params_frame *frame;
 
 	/* no report associated (HID_QUIRK_MULTI_INPUT not set) */
 	if (!hi->report)
@@ -104,6 +106,19 @@ static int uclogic_input_configured(struct hid_device *hdev,
 		drvdata->pen_input = hi->input;
 	}
 
+	/* If it's one of the frame devices */
+	for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) {
+		frame = &params->frame_list[i];
+		if (hi->report->id == frame->id) {
+			/*
+			 * Disable EV_MSC reports for touch ring interfaces to
+			 * make the Wacom driver pickup touch ring extents
+			 */
+			if (frame->touch_ring_byte > 0)
+				__clear_bit(EV_MSC, hi->input->evbit);
+		}
+	}
+
 	field = hi->report->field[0];
 
 	switch (field->application) {
@@ -313,8 +328,16 @@ static int uclogic_raw_event_frame(
 
 	/* If need to, and can, set pad device ID for Wacom drivers */
 	if (frame->dev_id_byte > 0 && frame->dev_id_byte < size) {
-		data[frame->dev_id_byte] = 0xf;
+		/* If we also have a touch ring and the finger left it */
+		if (frame->touch_ring_byte > 0 &&
+		    frame->touch_ring_byte < size &&
+		    data[frame->touch_ring_byte] == 0) {
+			data[frame->dev_id_byte] = 0;
+		} else {
+			data[frame->dev_id_byte] = 0xf;
+		}
 	}
+
 	/* If need to, and can, read rotary encoder state change */
 	if (frame->re_lsb > 0 && frame->re_lsb / 8 < size) {
 		unsigned int byte = frame->re_lsb / 8;
@@ -341,6 +364,20 @@ static int uclogic_raw_event_frame(
 		drvdata->re_state = state;
 	}
 
+	/* If need to, and can, transform the touch ring reports */
+	if (frame->touch_ring_byte > 0 && frame->touch_ring_byte < size &&
+	    frame->touch_ring_flip_at != 0) {
+		__s8 value = data[frame->touch_ring_byte];
+
+		if (value != 0) {
+			value = frame->touch_ring_flip_at - value;
+			if (value < 0)
+				value = frame->touch_ring_max + value;
+
+			data[frame->touch_ring_byte] = value;
+		}
+	}
+
 	return 0;
 }
 
diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index 86f616dfbb53..fe13bc36983b 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -123,10 +123,32 @@ struct uclogic_params_frame {
 	/*
 	 * 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.
+	 * if no changes to the report should be made. The ID byte will be set
+	 * to zero whenever the byte pointed by "touch_ring_byte" is zero, if
+	 * the latter is valid. Only valid if "id" is not zero.
 	 */
 	unsigned int dev_id_byte;
+	/*
+	 * Offset of the touch ring state byte, in the report.
+	 * Zero if not present. If dev_id_byte is also valid and non-zero,
+	 * then the device ID byte will be cleared when the byte pointed to by
+	 * this offset is zero. Only valid if "id" is not zero.
+	 */
+	unsigned int touch_ring_byte;
+
+	/*
+	 * Maximum value of the touch ring report.
+	 * The minimum valid value is considered to be one,
+	 * with zero being out-of-proximity (finger lift) value.
+	 */
+	__s8 touch_ring_max;
+
+	/*
+	 * The value to anchor the reversed reports at.
+	 * I.e. one, if the reports should be flipped without offset.
+	 * Zero if no reversal should be done.
+	 */
+	__s8 touch_ring_flip_at;
 };
 
 /*
@@ -191,7 +213,10 @@ extern int uclogic_params_init(struct uclogic_params *params,
 		".frame_list[0].desc_size = %u\n"               \
 		".frame_list[0].id = %u\n"                      \
 		".frame_list[0].re_lsb = %u\n"                  \
-		".frame_list[0].dev_id_byte = %u\n"
+		".frame_list[0].dev_id_byte = %u\n"             \
+		".frame_list[0].touch_ring_byte = %u\n"         \
+		".frame_list[0].touch_ring_max = %hhd\n"        \
+		".frame_list[0].touch_ring_flip_at = %hhd\n"
 
 /* Tablet interface parameters *printf format arguments */
 #define UCLOGIC_PARAMS_FMT_ARGS(_params) \
@@ -210,7 +235,10 @@ extern int uclogic_params_init(struct uclogic_params *params,
 		(_params)->frame_list[0].desc_size,                         \
 		(_params)->frame_list[0].id,                                \
 		(_params)->frame_list[0].re_lsb,                            \
-		(_params)->frame_list[0].dev_id_byte
+		(_params)->frame_list[0].dev_id_byte,                       \
+		(_params)->frame_list[0].touch_ring_byte,                   \
+		(_params)->frame_list[0].touch_ring_max,                    \
+		(_params)->frame_list[0].touch_ring_flip_at
 
 /* Get a replacement report descriptor for a tablet's interface. */
 extern int uclogic_params_get_desc(const struct uclogic_params *params,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH for-5.18/uclogic 2/4] HID: uclogic: Support custom device suffix for frames
  2022-03-03  7:47 [PATCH for-5.18/uclogic 0/4] DIGImend patches, part III José Expósito
  2022-03-03  7:47 ` [PATCH for-5.18/uclogic 1/4] HID: uclogic: Add support for touch ring reports José Expósito
@ 2022-03-03  7:47 ` José Expósito
  2022-03-03  7:47 ` [PATCH for-5.18/uclogic 3/4] HID: uclogic: Allow three frame parameter sets José Expósito
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: José Expósito @ 2022-03-03  7:47 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
	José Expósito

From: Nikolai Kondrashov <spbnick@gmail.com>

Support assigning custom device name suffixes to frame input devices
instead of just "Pad". This allows distinguishing multiple frame input
devices, e.g. for Huion HS610.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
 drivers/hid/hid-uclogic-core.c   | 46 +++++++++++++++++---------------
 drivers/hid/hid-uclogic-params.h |  6 +++++
 2 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index b448616dacb9..96f3fb8c492c 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -110,6 +110,8 @@ static int uclogic_input_configured(struct hid_device *hdev,
 	for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) {
 		frame = &params->frame_list[i];
 		if (hi->report->id == frame->id) {
+			/* Assign custom suffix, if any */
+			suffix = frame->suffix;
 			/*
 			 * Disable EV_MSC reports for touch ring interfaces to
 			 * make the Wacom driver pickup touch ring extents
@@ -119,27 +121,29 @@ static int uclogic_input_configured(struct hid_device *hdev,
 		}
 	}
 
-	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) {
+		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) {
diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index fe13bc36983b..8042820e78b1 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -114,6 +114,10 @@ struct uclogic_params_frame {
 	 * Report ID, if reports should be tweaked, zero if not.
 	 */
 	unsigned int id;
+	/*
+	 * The suffix to add to the input device name, if not NULL.
+	 */
+	const char *suffix;
 	/*
 	 * 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
@@ -212,6 +216,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
 		".frame_list[0].desc_ptr = %p\n"                \
 		".frame_list[0].desc_size = %u\n"               \
 		".frame_list[0].id = %u\n"                      \
+		".frame_list[0].suffix = %s\n"                  \
 		".frame_list[0].re_lsb = %u\n"                  \
 		".frame_list[0].dev_id_byte = %u\n"             \
 		".frame_list[0].touch_ring_byte = %u\n"         \
@@ -234,6 +239,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
 		(_params)->frame_list[0].desc_ptr,                          \
 		(_params)->frame_list[0].desc_size,                         \
 		(_params)->frame_list[0].id,                                \
+		(_params)->frame_list[0].suffix,                            \
 		(_params)->frame_list[0].re_lsb,                            \
 		(_params)->frame_list[0].dev_id_byte,                       \
 		(_params)->frame_list[0].touch_ring_byte,                   \
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH for-5.18/uclogic 3/4] HID: uclogic: Allow three frame parameter sets
  2022-03-03  7:47 [PATCH for-5.18/uclogic 0/4] DIGImend patches, part III José Expósito
  2022-03-03  7:47 ` [PATCH for-5.18/uclogic 1/4] HID: uclogic: Add support for touch ring reports José Expósito
  2022-03-03  7:47 ` [PATCH for-5.18/uclogic 2/4] HID: uclogic: Support custom device suffix for frames José Expósito
@ 2022-03-03  7:47 ` José Expósito
  2022-03-03  7:47 ` [PATCH for-5.18/uclogic 4/4] HID: uclogic: Add support for Huion touch ring reports José Expósito
  2022-04-11 14:53 ` [PATCH for-5.18/uclogic 0/4] DIGImend patches, part III Jiri Kosina
  4 siblings, 0 replies; 6+ messages in thread
From: José Expósito @ 2022-03-03  7:47 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
	José Expósito

From: Nikolai Kondrashov <spbnick@gmail.com>

Allow three frame parameter sets per each UC-Logic tablet interface.
Bump the number of supported subreports to three as well to accommodate
ID routing. This allows supporting the dial on Huion Q620M.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
 drivers/hid/hid-uclogic-params.h | 52 +++++++++++++++++++++++++++++---
 1 file changed, 47 insertions(+), 5 deletions(-)

diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index 8042820e78b1..f2649e8f959d 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -73,8 +73,8 @@ struct uclogic_params_pen {
 	unsigned int desc_size;
 	/* Report ID, if reports should be tweaked, zero if not */
 	unsigned int id;
-	/* The list of subreports */
-	struct uclogic_params_pen_subreport subreport_list[1];
+	/* The list of subreports, only valid if "id" is not zero */
+	struct uclogic_params_pen_subreport subreport_list[3];
 	/* Type of in-range reporting, only valid if "id" is not zero */
 	enum uclogic_params_pen_inrange inrange;
 	/*
@@ -194,7 +194,7 @@ struct uclogic_params {
 	 * The list of frame control parameters and optional report descriptor
 	 * parts. Only valid, if "invalid" is false.
 	 */
-	struct uclogic_params_frame frame_list[1];
+	struct uclogic_params_frame frame_list[3];
 };
 
 /* Initialize a tablet interface and discover its parameters */
@@ -210,6 +210,8 @@ extern int uclogic_params_init(struct uclogic_params *params,
 		".pen.desc_size = %u\n"                         \
 		".pen.id = %u\n"                                \
 		".pen.subreport_list[0] = {0x%02hhx, %hhu}\n"   \
+		".pen.subreport_list[1] = {0x%02hhx, %hhu}\n"   \
+		".pen.subreport_list[2] = {0x%02hhx, %hhu}\n"   \
 		".pen.inrange = %s\n"                           \
 		".pen.fragmented_hires = %s\n"                  \
 		".pen.tilt_y_flipped = %s\n"                    \
@@ -221,7 +223,25 @@ extern int uclogic_params_init(struct uclogic_params *params,
 		".frame_list[0].dev_id_byte = %u\n"             \
 		".frame_list[0].touch_ring_byte = %u\n"         \
 		".frame_list[0].touch_ring_max = %hhd\n"        \
-		".frame_list[0].touch_ring_flip_at = %hhd\n"
+		".frame_list[0].touch_ring_flip_at = %hhd\n"    \
+		".frame_list[1].desc_ptr = %p\n"                \
+		".frame_list[1].desc_size = %u\n"               \
+		".frame_list[1].id = %u\n"                      \
+		".frame_list[1].suffix = %s\n"                  \
+		".frame_list[1].re_lsb = %u\n"                  \
+		".frame_list[1].dev_id_byte = %u\n"             \
+		".frame_list[1].touch_ring_byte = %u\n"         \
+		".frame_list[1].touch_ring_max = %hhd\n"        \
+		".frame_list[1].touch_ring_flip_at = %hhd\n"    \
+		".frame_list[2].desc_ptr = %p\n"                \
+		".frame_list[2].desc_size = %u\n"               \
+		".frame_list[2].id = %u\n"                      \
+		".frame_list[2].suffix = %s\n"                  \
+		".frame_list[2].re_lsb = %u\n"                  \
+		".frame_list[2].dev_id_byte = %u\n"             \
+		".frame_list[2].touch_ring_byte = %u\n"         \
+		".frame_list[2].touch_ring_max = %hhd\n"        \
+		".frame_list[2].touch_ring_flip_at = %hhd\n"
 
 /* Tablet interface parameters *printf format arguments */
 #define UCLOGIC_PARAMS_FMT_ARGS(_params) \
@@ -233,6 +253,10 @@ extern int uclogic_params_init(struct uclogic_params *params,
 		(_params)->pen.id,                                          \
 		(_params)->pen.subreport_list[0].value,                     \
 		(_params)->pen.subreport_list[0].id,                        \
+		(_params)->pen.subreport_list[1].value,                     \
+		(_params)->pen.subreport_list[1].id,                        \
+		(_params)->pen.subreport_list[2].value,                     \
+		(_params)->pen.subreport_list[2].id,                        \
 		uclogic_params_pen_inrange_to_str((_params)->pen.inrange),  \
 		((_params)->pen.fragmented_hires ? "true" : "false"),       \
 		((_params)->pen.tilt_y_flipped ? "true" : "false"),         \
@@ -244,7 +268,25 @@ extern int uclogic_params_init(struct uclogic_params *params,
 		(_params)->frame_list[0].dev_id_byte,                       \
 		(_params)->frame_list[0].touch_ring_byte,                   \
 		(_params)->frame_list[0].touch_ring_max,                    \
-		(_params)->frame_list[0].touch_ring_flip_at
+		(_params)->frame_list[0].touch_ring_flip_at,                \
+		(_params)->frame_list[1].desc_ptr,                          \
+		(_params)->frame_list[1].desc_size,                         \
+		(_params)->frame_list[1].id,                                \
+		(_params)->frame_list[1].suffix,                            \
+		(_params)->frame_list[1].re_lsb,                            \
+		(_params)->frame_list[1].dev_id_byte,                       \
+		(_params)->frame_list[1].touch_ring_byte,                   \
+		(_params)->frame_list[1].touch_ring_max,                    \
+		(_params)->frame_list[1].touch_ring_flip_at,                \
+		(_params)->frame_list[2].desc_ptr,                          \
+		(_params)->frame_list[2].desc_size,                         \
+		(_params)->frame_list[2].id,                                \
+		(_params)->frame_list[2].suffix,                            \
+		(_params)->frame_list[2].re_lsb,                            \
+		(_params)->frame_list[2].dev_id_byte,                       \
+		(_params)->frame_list[2].touch_ring_byte,                   \
+		(_params)->frame_list[2].touch_ring_max,                    \
+		(_params)->frame_list[2].touch_ring_flip_at
 
 /* Get a replacement report descriptor for a tablet's interface. */
 extern int uclogic_params_get_desc(const struct uclogic_params *params,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH for-5.18/uclogic 4/4] HID: uclogic: Add support for Huion touch ring reports
  2022-03-03  7:47 [PATCH for-5.18/uclogic 0/4] DIGImend patches, part III José Expósito
                   ` (2 preceding siblings ...)
  2022-03-03  7:47 ` [PATCH for-5.18/uclogic 3/4] HID: uclogic: Allow three frame parameter sets José Expósito
@ 2022-03-03  7:47 ` José Expósito
  2022-04-11 14:53 ` [PATCH for-5.18/uclogic 0/4] DIGImend patches, part III Jiri Kosina
  4 siblings, 0 replies; 6+ messages in thread
From: José Expósito @ 2022-03-03  7:47 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
	José Expósito

From: Nikolai Kondrashov <spbnick@gmail.com>

Support touch ring reports found in Huion HS610 to the UC-Logic driver.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
 drivers/hid/hid-uclogic-params.c | 40 ++++++++++++++++----
 drivers/hid/hid-uclogic-rdesc.c  | 65 ++++++++++++++++++++++++++++----
 drivers/hid/hid-uclogic-rdesc.h  | 20 +++++++---
 3 files changed, 105 insertions(+), 20 deletions(-)

diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index 5f50ceb875d6..3ac45e7572a0 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -745,22 +745,48 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
 			goto cleanup;
 		} else if (found) {
 			hid_dbg(hdev, "pen v2 parameters found\n");
-			/* Create v2 frame parameters */
+			/* Create v2 frame button parameters */
 			rc = uclogic_params_frame_init_with_desc(
 					&p.frame_list[0],
-					uclogic_rdesc_v2_frame_arr,
-					uclogic_rdesc_v2_frame_size,
-					UCLOGIC_RDESC_V2_FRAME_ID);
+					uclogic_rdesc_v2_frame_buttons_arr,
+					uclogic_rdesc_v2_frame_buttons_size,
+					UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID);
 			if (rc != 0) {
 				hid_err(hdev,
-					"failed creating v2 frame parameters: %d\n",
+					"failed creating v2 frame button parameters: %d\n",
 					rc);
 				goto cleanup;
 			}
-			/* Link frame button subreports from pen reports */
+
+			/* Create v2 frame touch ring parameters */
+			rc = uclogic_params_frame_init_with_desc(
+					&p.frame_list[1],
+					uclogic_rdesc_v2_frame_touch_ring_arr,
+					uclogic_rdesc_v2_frame_touch_ring_size,
+					UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_ID);
+			if (rc != 0) {
+				hid_err(hdev,
+					"failed creating v2 frame touch ring parameters: %d\n",
+					rc);
+				goto cleanup;
+			}
+			p.frame_list[1].suffix = "Touch Ring";
+			p.frame_list[1].dev_id_byte =
+				UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_DEV_ID_BYTE;
+			p.frame_list[1].touch_ring_byte = 5;
+			p.frame_list[1].touch_ring_max = 12;
+			p.frame_list[1].touch_ring_flip_at = 6;
+
+			/*
+			 * Link button and touch ring subreports from pen
+			 * reports
+			 */
 			p.pen.subreport_list[0].value = 0xe0;
 			p.pen.subreport_list[0].id =
-				UCLOGIC_RDESC_V2_FRAME_ID;
+				UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID;
+			p.pen.subreport_list[1].value = 0xf0;
+			p.pen.subreport_list[1].id =
+				UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_ID;
 			goto output;
 		}
 		hid_dbg(hdev, "pen v2 parameters not found\n");
diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c
index 04644d93bd11..d64b607dce5d 100644
--- a/drivers/hid/hid-uclogic-rdesc.c
+++ b/drivers/hid/hid-uclogic-rdesc.c
@@ -652,12 +652,12 @@ const size_t uclogic_rdesc_v2_pen_template_size =
 			sizeof(uclogic_rdesc_v2_pen_template_arr);
 
 /*
- * Expand to the contents of a generic frame report descriptor.
+ * Expand to the contents of a generic frame buttons report descriptor.
  *
  * @_id:	The report ID to use.
  * @_size:	Size of the report to pad to, including report ID, bytes.
  */
-#define UCLOGIC_RDESC_FRAME_BYTES(_id, _size) \
+#define UCLOGIC_RDESC_FRAME_BUTTONS_BYTES(_id, _size) \
 	0x05, 0x01,     /*  Usage Page (Desktop),               */ \
 	0x09, 0x07,     /*  Usage (Keypad),                     */ \
 	0xA1, 0x01,     /*  Collection (Application),           */ \
@@ -700,17 +700,66 @@ const size_t uclogic_rdesc_v2_pen_template_size =
 
 /* Fixed report descriptor for (tweaked) v1 frame reports */
 const __u8 uclogic_rdesc_v1_frame_arr[] = {
-	UCLOGIC_RDESC_FRAME_BYTES(UCLOGIC_RDESC_V1_FRAME_ID, 8)
+	UCLOGIC_RDESC_FRAME_BUTTONS_BYTES(UCLOGIC_RDESC_V1_FRAME_ID, 8)
 };
 const size_t uclogic_rdesc_v1_frame_size =
 			sizeof(uclogic_rdesc_v1_frame_arr);
 
-/* Fixed report descriptor for (tweaked) v2 frame reports */
-const __u8 uclogic_rdesc_v2_frame_arr[] = {
-	UCLOGIC_RDESC_FRAME_BYTES(UCLOGIC_RDESC_V2_FRAME_ID, 12)
+/* Fixed report descriptor for (tweaked) v2 frame button reports */
+const __u8 uclogic_rdesc_v2_frame_buttons_arr[] = {
+	UCLOGIC_RDESC_FRAME_BUTTONS_BYTES(UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID,
+					  12)
 };
-const size_t uclogic_rdesc_v2_frame_size =
-			sizeof(uclogic_rdesc_v2_frame_arr);
+const size_t uclogic_rdesc_v2_frame_buttons_size =
+			sizeof(uclogic_rdesc_v2_frame_buttons_arr);
+
+/* Fixed report descriptor for (tweaked) v2 frame touch ring reports */
+const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[] = {
+	0x05, 0x01,         /*  Usage Page (Desktop),               */
+	0x09, 0x07,         /*  Usage (Keypad),                     */
+	0xA1, 0x01,         /*  Collection (Application),           */
+	0x85, UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_ID,
+			    /*      Report ID (DIAL_ID),            */
+	0x14,               /*      Logical Minimum (0),            */
+	0x05, 0x0D,         /*      Usage Page (Digitizer),         */
+	0x09, 0x39,         /*      Usage (Tablet Function Keys),   */
+	0xA0,               /*      Collection (Physical),          */
+	0x25, 0x01,         /*          Logical Maximum (1),        */
+	0x75, 0x01,         /*          Report Size (1),            */
+	0x05, 0x09,         /*          Usage Page (Button),        */
+	0x09, 0x01,         /*          Usage (01h),                */
+	0x95, 0x01,         /*          Report Count (1),           */
+	0x81, 0x02,         /*          Input (Variable),           */
+	0x95, 0x07,         /*          Report Count (7),           */
+	0x81, 0x01,         /*          Input (Constant),           */
+	0x75, 0x08,         /*          Report Size (8),            */
+	0x95, 0x02,         /*          Report Count (2),           */
+	0x81, 0x01,         /*          Input (Constant),           */
+	0x05, 0x0D,         /*          Usage Page (Digitizer),     */
+	0x0A, 0xFF, 0xFF,   /*          Usage (FFFFh),              */
+	0x26, 0xFF, 0x00,   /*          Logical Maximum (255),      */
+	0x95, 0x01,         /*          Report Count (1),           */
+	0x81, 0x02,         /*          Input (Variable),           */
+	0x05, 0x01,         /*          Usage Page (Desktop),       */
+	0x09, 0x38,         /*          Usage (Wheel),              */
+	0x95, 0x01,         /*          Report Count (1),           */
+	0x15, 0x00,         /*          Logical Minimum (0),        */
+	0x25, 0x0B,         /*          Logical Maximum (11),       */
+	0x81, 0x02,         /*          Input (Variable),           */
+	0x09, 0x30,         /*          Usage (X),                  */
+	0x09, 0x31,         /*          Usage (Y),                  */
+	0x14,               /*          Logical Minimum (0),        */
+	0x25, 0x01,         /*          Logical Maximum (1),        */
+	0x75, 0x01,         /*          Report Size (1),            */
+	0x95, 0x02,         /*          Report Count (2),           */
+	0x81, 0x02,         /*          Input (Variable),           */
+	0x95, 0x2E,         /*          Report Count (46),          */
+	0x81, 0x01,         /*          Input (Constant),           */
+	0xC0,               /*      End Collection,                 */
+	0xC0                /*  End Collection                      */
+};
+const size_t uclogic_rdesc_v2_frame_touch_ring_size =
+			sizeof(uclogic_rdesc_v2_frame_touch_ring_arr);
 
 /* Fixed report descriptor for Ugee EX07 frame */
 const __u8 uclogic_rdesc_ugee_ex07_frame_arr[] = {
diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h
index 3d904c27b86a..f15a9d8a946b 100644
--- a/drivers/hid/hid-uclogic-rdesc.h
+++ b/drivers/hid/hid-uclogic-rdesc.h
@@ -124,12 +124,22 @@ extern const size_t uclogic_rdesc_v2_pen_template_size;
 extern const __u8 uclogic_rdesc_v1_frame_arr[];
 extern const size_t uclogic_rdesc_v1_frame_size;
 
-/* Report ID for tweaked v2 frame reports */
-#define UCLOGIC_RDESC_V2_FRAME_ID 0xf7
+/* Report ID for tweaked v2 frame button reports */
+#define UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID 0xf7
 
-/* Fixed report descriptor for (tweaked) v2 frame reports */
-extern const __u8 uclogic_rdesc_v2_frame_arr[];
-extern const size_t uclogic_rdesc_v2_frame_size;
+/* Fixed report descriptor for (tweaked) v2 frame button reports */
+extern const __u8 uclogic_rdesc_v2_frame_buttons_arr[];
+extern const size_t uclogic_rdesc_v2_frame_buttons_size;
+
+/* Report ID for tweaked v2 frame touch ring reports */
+#define UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_ID 0xf8
+
+/* Fixed report descriptor for (tweaked) v2 frame touch ring reports */
+extern const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[];
+extern const size_t uclogic_rdesc_v2_frame_touch_ring_size;
+
+/* Device ID byte offset in v2 frame touch ring reports */
+#define UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_DEV_ID_BYTE	0x4
 
 /* Fixed report descriptor for Ugee EX07 frame */
 extern const __u8 uclogic_rdesc_ugee_ex07_frame_arr[];
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH for-5.18/uclogic 0/4] DIGImend patches, part III
  2022-03-03  7:47 [PATCH for-5.18/uclogic 0/4] DIGImend patches, part III José Expósito
                   ` (3 preceding siblings ...)
  2022-03-03  7:47 ` [PATCH for-5.18/uclogic 4/4] HID: uclogic: Add support for Huion touch ring reports José Expósito
@ 2022-04-11 14:53 ` Jiri Kosina
  4 siblings, 0 replies; 6+ messages in thread
From: Jiri Kosina @ 2022-04-11 14:53 UTC (permalink / raw)
  To: José Expósito
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel

On Thu, 3 Mar 2022, José Expósito wrote:

> Hi everyone,
> 
> This series is a follow up to [1] and [2], kindly reviewed and applied
> by Jiří in hid.git#for-5.18/uclogic.
> 
> It adds support for touch rings in order handle the Huion HS610 tablet.
> 
> Thank you very much to Nikolai for the patches a to the maintaners for
> the quick reviews,
> José Expósito
> 
> [1] https://lore.kernel.org/linux-input/nycvar.YFH.7.76.2202161642180.11721@cbobk.fhfr.pm/T/
> [2] https://lore.kernel.org/linux-input/56454560-5f62-05b9-1a24-3f51a305140e@gmail.com/T/
> 
> Nikolai Kondrashov (4):
>   HID: uclogic: Add support for touch ring reports
>   HID: uclogic: Support custom device suffix for frames
>   HID: uclogic: Allow three frame parameter sets
>   HID: uclogic: Add support for Huion touch ring reports
> 
>  drivers/hid/hid-uclogic-core.c   | 83 +++++++++++++++++++++--------
>  drivers/hid/hid-uclogic-params.c | 40 +++++++++++---
>  drivers/hid/hid-uclogic-params.h | 90 +++++++++++++++++++++++++++++---
>  drivers/hid/hid-uclogic-rdesc.c  | 65 ++++++++++++++++++++---
>  drivers/hid/hid-uclogic-rdesc.h  | 20 +++++--
>  5 files changed, 250 insertions(+), 48 deletions(-)

Now in hid.git#for-5.19/uclogic. Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-04-11 14:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-03  7:47 [PATCH for-5.18/uclogic 0/4] DIGImend patches, part III José Expósito
2022-03-03  7:47 ` [PATCH for-5.18/uclogic 1/4] HID: uclogic: Add support for touch ring reports José Expósito
2022-03-03  7:47 ` [PATCH for-5.18/uclogic 2/4] HID: uclogic: Support custom device suffix for frames José Expósito
2022-03-03  7:47 ` [PATCH for-5.18/uclogic 3/4] HID: uclogic: Allow three frame parameter sets José Expósito
2022-03-03  7:47 ` [PATCH for-5.18/uclogic 4/4] HID: uclogic: Add support for Huion touch ring reports José Expósito
2022-04-11 14:53 ` [PATCH for-5.18/uclogic 0/4] DIGImend patches, part III Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).