Skip to contentSkip to conversation

DIGImend patches, part V

PATCH In review José Expósito 2 participants 7 messages Apr 21, 2022 – May 6, 2022 HID

lore
Share & tools
lore
#0 lore raw

cover DIGImend patches, part V

Hi everyone,

This series is a follow up to [1], [2], [3] and [4] upstreaming 5 more patches authored by Nikolai from the DIGImend project.

Patches 1 and 2 are documentation improvements.

Patch 3 allows to create a keyboard interface to the tablets that have a "Usage (Keyboard)" in their descriptor, like for example the Huion HS611, which has media keys [5].

However, some of the tablets that have a keyboard usage, also have an invalid pen usage, creating an invalid pen interface. Patches 4 and 5 allow to disable it.

As always, many thanks to Jiří and Nikolai for their work :D

José Expósito

[1] https://lore.kernel.org/linux-input/[email protected]/T/
[2] https://lore.kernel.org/linux-input/[email protected]/T/
[3] https://lore.kernel.org/linux-input/[email protected]/T/
[4] https://lore.kernel.org/linux-input/[email protected]/T/
[5] https://www.huion.com/es/pen_tablet/HS/huion-hs611.html

Nikolai Kondrashov (5):
HID: uclogic: Clarify params desc_size description
HID: uclogic: Clarify pen/frame desc_ptr description
HID: uclogic: Pass keyboard reports as is
HID: uclogic: Support disabling pen usage
HID: uclogic: Disable pen usage for Huion keyboard interfaces

 drivers/hid/hid-uclogic-core.c   | 19 +++++++++++++++++++
 drivers/hid/hid-uclogic-params.c |  9 +++++++--
 drivers/hid/hid-uclogic-params.h | 17 ++++++++++++-----
 3 files changed, 38 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/5 HID: uclogic: Clarify params desc_size description

From: Nikolai Kondrashov <[email protected]>

Documentation improvements.

---
 drivers/hid/hid-uclogic-params.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-uclogic-params.h +1 -1
index e5ccc558abc3..a489c92cee43 100644
@@ -189,7 +189,7 @@ struct uclogic_params {
 	__u8 *desc_ptr;
 	/*
 	 * Size of the common part of the replacement report descriptor.
-	 * Only valid, if "desc_ptr" is not NULL.
+	 * Only valid, if "desc_ptr" is valid and not NULL.
 	 */
 	unsigned int desc_size;
 	/*
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/5 HID: uclogic: Clarify pen/frame desc_ptr description

In reply to José Expósito

From: Nikolai Kondrashov <[email protected]>

Documentation improvements.

---
 drivers/hid/hid-uclogic-params.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hid/hid-uclogic-params.h +4 -4
index a489c92cee43..fa75efba3130 100644
@@ -62,8 +62,8 @@ struct uclogic_params_pen_subreport {
  */
 struct uclogic_params_pen {
 	/*
-	 * Pointer to report descriptor describing the inputs.
-	 * Allocated with kmalloc.
+	 * Pointer to report descriptor part describing the pen inputs.
+	 * Allocated with kmalloc. NULL if the part is not specified.
 	 */
 	__u8 *desc_ptr;
 	/*
@@ -101,8 +101,8 @@ struct uclogic_params_pen {
  */
 struct uclogic_params_frame {
 	/*
-	 * Pointer to report descriptor describing the inputs.
-	 * Allocated with kmalloc.
+	 * Pointer to report descriptor part describing the frame inputs.
+	 * Allocated with kmalloc. NULL if the part is not specified.
 	 */
 	__u8 *desc_ptr;
 	/*
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/5 HID: uclogic: Pass keyboard reports as is

In reply to José Expósito

From: Nikolai Kondrashov <[email protected]>

Allow keyboard reports from interface #1 of Huion tablets to pass unmodified, and stop the Wacom X.org driver from handling them.

The method for the latter is rather crude and also take the Dial reports from the Wacom driver, but it's expected that libinput will be able to handle them (still to be tested).

This enables Huion HS611 media and desktop keys.

---
 drivers/hid/hid-uclogic-params.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hid/hid-uclogic-params.c +6 -2
index 09c332c6a412..b85585ac3372 100644
@@ -711,8 +711,12 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
 	iface = to_usb_interface(hdev->dev.parent);
 	bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber;
 
-	/* If it's not a pen interface */
-	if (bInterfaceNumber != 0) {
+	/* If it's a custom keyboard interface */
+	if (bInterfaceNumber == 1) {
+		/* Keep everything intact */
+		goto output;
+	/* Else, if it's not a pen interface */
+	} else if (bInterfaceNumber != 0) {
 		uclogic_params_init_invalid(&p);
 		goto output;
 	}
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/5 HID: uclogic: Support disabling pen usage

In reply to José Expósito

From: Nikolai Kondrashov <[email protected]>

Restore the ability to disable pen usage in hid-uclogic to support e.g. keyboard interfaces which also have pen usages for some reason, but which we don't want to rewrite report descriptors for.

---
 drivers/hid/hid-uclogic-core.c   | 19 +++++++++++++++++++
 drivers/hid/hid-uclogic-params.h |  7 +++++++
 2 files changed, 26 insertions(+)
drivers/hid/hid-uclogic-core.c +19 -0
index 627f1d0c52f2..8ef3d1830052 100644
@@ -81,6 +81,24 @@ static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 	return rdesc;
 }
 
+static int uclogic_input_mapping(struct hid_device *hdev,
+				 struct hid_input *hi,
+				 struct hid_field *field,
+				 struct hid_usage *usage,
+				 unsigned long **bit,
+				 int *max)
+{
+	struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
+	struct uclogic_params *params = &drvdata->params;
+
+	/* Discard invalid pen usages */
+	if (params->pen.usage_invalid && (field->application == HID_DG_PEN))
+		return -1;
+
+	/* Let hid-core decide what to do */
+	return 0;
+}
+
 static int uclogic_input_configured(struct hid_device *hdev,
 		struct hid_input *hi)
 {
@@ -515,6 +533,7 @@ static struct hid_driver uclogic_driver = {
 	.remove = uclogic_remove,
 	.report_fixup = uclogic_report_fixup,
 	.raw_event = uclogic_raw_event,
+	.input_mapping = uclogic_input_mapping,
 	.input_configured = uclogic_input_configured,
 #ifdef CONFIG_PM
 	.resume	          = uclogic_resume,
drivers/hid/hid-uclogic-params.h +7 -0
index fa75efba3130..fb2001018c46 100644
@@ -61,6 +61,11 @@ struct uclogic_params_pen_subreport {
  * Noop (preserving functionality) when filled with zeroes.
  */
 struct uclogic_params_pen {
+	/*
+	 * True if pen usage is invalid for this interface and should be
+	 * ignored, false otherwise.
+	 */
+	bool usage_invalid;
 	/*
 	 * Pointer to report descriptor part describing the pen inputs.
 	 * Allocated with kmalloc. NULL if the part is not specified.
@@ -214,6 +219,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
 	".desc_ptr = %p\n"                  \
 	".desc_size = %u\n"                 \
 	".pen = {\n"                        \
+	"\t.usage_invalid = %s\n"           \
 	"\t.desc_ptr = %p\n"                \
 	"\t.desc_size = %u\n"               \
 	"\t.id = %u\n"                      \
@@ -270,6 +276,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
 	((_params)->invalid ? "true" : "false"),                    \
 	(_params)->desc_ptr,                                        \
 	(_params)->desc_size,                                       \
+	((_params)->pen.usage_invalid ? "true" : "false"),          \
 	(_params)->pen.desc_ptr,                                    \
 	(_params)->pen.desc_size,                                   \
 	(_params)->pen.id,                                          \
Signature · 1 line
2.25.1
#5 lore raw

PATCH 5/5 HID: uclogic: Disable pen usage for Huion keyboard interfaces

In reply to José Expósito

From: Nikolai Kondrashov <[email protected]>

Disable pen usage inputs for Huion interfaces reporting on-the-frame buttons. We don't want to change those, as they mostly work, but we want to avoid creation of a mute pen interface, confusing to users.

---
 drivers/hid/hid-uclogic-params.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hid/hid-uclogic-params.c +2 -1
index b85585ac3372..22f9c4f9da8a 100644
@@ -713,7 +713,8 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
 
 	/* If it's a custom keyboard interface */
 	if (bInterfaceNumber == 1) {
-		/* Keep everything intact */
+		/* Keep everything intact, but mark pen usage invalid */
+		p.pen.usage_invalid = true;
 		goto output;
 	/* Else, if it's not a pen interface */
 	} else if (bInterfaceNumber != 0) {
Signature · 1 line
2.25.1
maintainer
#6 lore raw
In reply to José Expósito
Quoted 32 lines · José Expósito

Hi everyone,

This series is a follow up to [1], [2], [3] and [4] upstreaming 5 more patches authored by Nikolai from the DIGImend project.

Patches 1 and 2 are documentation improvements.

Patch 3 allows to create a keyboard interface to the tablets that have a "Usage (Keyboard)" in their descriptor, like for example the Huion HS611, which has media keys [5].

However, some of the tablets that have a keyboard usage, also have an invalid pen usage, creating an invalid pen interface. Patches 4 and 5 allow to disable it.

As always, many thanks to Jiří and Nikolai for their work :D

José Expósito

[1] https://lore.kernel.org/linux-input/[email protected]/T/
[2] https://lore.kernel.org/linux-input/[email protected]/T/
[3] https://lore.kernel.org/linux-input/[email protected]/T/
[4] https://lore.kernel.org/linux-input/[email protected]/T/
[5] https://www.huion.com/es/pen_tablet/HS/huion-hs611.html

Nikolai Kondrashov (5):
HID: uclogic: Clarify params desc_size description
HID: uclogic: Clarify pen/frame desc_ptr description
HID: uclogic: Pass keyboard reports as is
HID: uclogic: Support disabling pen usage
HID: uclogic: Disable pen usage for Huion keyboard interfaces

Quoted 4 lines
 drivers/hid/hid-uclogic-core.c   | 19 +++++++++++++++++++
 drivers/hid/hid-uclogic-params.c |  9 +++++++--
 drivers/hid/hid-uclogic-params.h | 17 ++++++++++++-----
 3 files changed, 38 insertions(+), 7 deletions(-)

Now in hid.git#for-5.19/uclogic

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs