linux-input.vger.kernel.org archive mirror
 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.18/uclogic 2/4] HID: uclogic: Support custom device suffix for frames
Date: Thu,  3 Mar 2022 08:47:32 +0100	[thread overview]
Message-ID: <20220303074734.7235-3-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20220303074734.7235-1-jose.exposito89@gmail.com>

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


  parent reply	other threads:[~2022-03-03  7:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20220303074734.7235-3-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 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).