linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V
@ 2022-04-21 17:50 José Expósito
  2022-04-21 17:50 ` [PATCH for-5.19/uclogic 1/5] HID: uclogic: Clarify params desc_size description José Expósito
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: José Expósito @ 2022-04-21 17:50 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], [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/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/
[3] https://lore.kernel.org/linux-input/nycvar.YFH.7.76.2204111653000.30217@cbobk.fhfr.pm/T/
[4] https://lore.kernel.org/linux-input/nycvar.YFH.7.76.2204211005520.30217@cbobk.fhfr.pm/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(-)

-- 
2.25.1


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

* [PATCH for-5.19/uclogic 1/5] HID: uclogic: Clarify params desc_size description
  2022-04-21 17:50 [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V José Expósito
@ 2022-04-21 17:50 ` José Expósito
  2022-04-21 17:50 ` [PATCH for-5.19/uclogic 2/5] HID: uclogic: Clarify pen/frame desc_ptr description José Expósito
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: José Expósito @ 2022-04-21 17:50 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
	José Expósito

From: Nikolai Kondrashov <spbnick@gmail.com>

Documentation improvements.

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

diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index e5ccc558abc3..a489c92cee43 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -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;
 	/*
-- 
2.25.1


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

* [PATCH for-5.19/uclogic 2/5] HID: uclogic: Clarify pen/frame desc_ptr description
  2022-04-21 17:50 [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V José Expósito
  2022-04-21 17:50 ` [PATCH for-5.19/uclogic 1/5] HID: uclogic: Clarify params desc_size description José Expósito
@ 2022-04-21 17:50 ` José Expósito
  2022-04-21 17:50 ` [PATCH for-5.19/uclogic 3/5] HID: uclogic: Pass keyboard reports as is José Expósito
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: José Expósito @ 2022-04-21 17:50 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
	José Expósito

From: Nikolai Kondrashov <spbnick@gmail.com>

Documentation improvements.

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

diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index a489c92cee43..fa75efba3130 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -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;
 	/*
-- 
2.25.1


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

* [PATCH for-5.19/uclogic 3/5] HID: uclogic: Pass keyboard reports as is
  2022-04-21 17:50 [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V José Expósito
  2022-04-21 17:50 ` [PATCH for-5.19/uclogic 1/5] HID: uclogic: Clarify params desc_size description José Expósito
  2022-04-21 17:50 ` [PATCH for-5.19/uclogic 2/5] HID: uclogic: Clarify pen/frame desc_ptr description José Expósito
@ 2022-04-21 17:50 ` José Expósito
  2022-04-21 17:50 ` [PATCH for-5.19/uclogic 4/5] HID: uclogic: Support disabling pen usage José Expósito
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: José Expósito @ 2022-04-21 17:50 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
	José Expósito

From: Nikolai Kondrashov <spbnick@gmail.com>

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.

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

diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index 09c332c6a412..b85585ac3372 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -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;
 	}
-- 
2.25.1


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

* [PATCH for-5.19/uclogic 4/5] HID: uclogic: Support disabling pen usage
  2022-04-21 17:50 [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V José Expósito
                   ` (2 preceding siblings ...)
  2022-04-21 17:50 ` [PATCH for-5.19/uclogic 3/5] HID: uclogic: Pass keyboard reports as is José Expósito
@ 2022-04-21 17:50 ` José Expósito
  2022-04-21 17:50 ` [PATCH for-5.19/uclogic 5/5] HID: uclogic: Disable pen usage for Huion keyboard interfaces José Expósito
  2022-05-06  6:35 ` [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V Jiri Kosina
  5 siblings, 0 replies; 7+ messages in thread
From: José Expósito @ 2022-04-21 17:50 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
	José Expósito

From: Nikolai Kondrashov <spbnick@gmail.com>

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.

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

diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index 627f1d0c52f2..8ef3d1830052 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -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,
diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index fa75efba3130..fb2001018c46 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -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,                                          \
-- 
2.25.1


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

* [PATCH for-5.19/uclogic 5/5] HID: uclogic: Disable pen usage for Huion keyboard interfaces
  2022-04-21 17:50 [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V José Expósito
                   ` (3 preceding siblings ...)
  2022-04-21 17:50 ` [PATCH for-5.19/uclogic 4/5] HID: uclogic: Support disabling pen usage José Expósito
@ 2022-04-21 17:50 ` José Expósito
  2022-05-06  6:35 ` [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V Jiri Kosina
  5 siblings, 0 replies; 7+ messages in thread
From: José Expósito @ 2022-04-21 17:50 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
	José Expósito

From: Nikolai Kondrashov <spbnick@gmail.com>

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.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
 drivers/hid/hid-uclogic-params.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index b85585ac3372..22f9c4f9da8a 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -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) {
-- 
2.25.1


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

* Re: [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V
  2022-04-21 17:50 [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V José Expósito
                   ` (4 preceding siblings ...)
  2022-04-21 17:50 ` [PATCH for-5.19/uclogic 5/5] HID: uclogic: Disable pen usage for Huion keyboard interfaces José Expósito
@ 2022-05-06  6:35 ` Jiri Kosina
  5 siblings, 0 replies; 7+ messages in thread
From: Jiri Kosina @ 2022-05-06  6:35 UTC (permalink / raw)
  To: José Expósito
  Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel

On Thu, 21 Apr 2022, José Expósito wrote:

> 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/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/
> [3] https://lore.kernel.org/linux-input/nycvar.YFH.7.76.2204111653000.30217@cbobk.fhfr.pm/T/
> [4] https://lore.kernel.org/linux-input/nycvar.YFH.7.76.2204211005520.30217@cbobk.fhfr.pm/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(-)

Now in hid.git#for-5.19/uclogic

Thanks,

-- 
Jiri Kosina
SUSE Labs


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

end of thread, other threads:[~2022-05-06  6:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 17:50 [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V José Expósito
2022-04-21 17:50 ` [PATCH for-5.19/uclogic 1/5] HID: uclogic: Clarify params desc_size description José Expósito
2022-04-21 17:50 ` [PATCH for-5.19/uclogic 2/5] HID: uclogic: Clarify pen/frame desc_ptr description José Expósito
2022-04-21 17:50 ` [PATCH for-5.19/uclogic 3/5] HID: uclogic: Pass keyboard reports as is José Expósito
2022-04-21 17:50 ` [PATCH for-5.19/uclogic 4/5] HID: uclogic: Support disabling pen usage José Expósito
2022-04-21 17:50 ` [PATCH for-5.19/uclogic 5/5] HID: uclogic: Disable pen usage for Huion keyboard interfaces José Expósito
2022-05-06  6:35 ` [PATCH for-5.19/uclogic 0/5] DIGImend patches, part V 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).