All of lore.kernel.org
 help / color / mirror / Atom feed
From: "José Expósito" <jose.exposito89@gmail.com>
To: jikos@kernel.org
Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	"José Expósito" <jose.exposito89@gmail.com>
Subject: [PATCH for-5.19/uclogic 4/5] HID: uclogic: Support disabling pen usage
Date: Thu, 21 Apr 2022 19:50:51 +0200	[thread overview]
Message-ID: <20220421175052.911446-5-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20220421175052.911446-1-jose.exposito89@gmail.com>

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


  parent reply	other threads:[~2022-04-21 17:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` José Expósito [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220421175052.911446-5-jose.exposito89@gmail.com \
    --to=jose.exposito89@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=spbnick@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.