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,
stefanberzl@gmail.com, albertofanjul@gmail.com,
"José Expósito" <jose.exposito89@gmail.com>
Subject: [PATCH for-5.19/uclogic 5/7] HID: uclogic: Differentiate touch ring and touch strip
Date: Sun, 8 May 2022 18:01:44 +0200 [thread overview]
Message-ID: <20220508160146.13004-6-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20220508160146.13004-1-jose.exposito89@gmail.com>
From: Nikolai Kondrashov <spbnick@gmail.com>
Improve support for touch strips.
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-uclogic-params.c | 84 +++++++++++++++++++++++---------
drivers/hid/hid-uclogic-rdesc.c | 48 ++++++++++++++++++
drivers/hid/hid-uclogic-rdesc.h | 4 ++
3 files changed, 112 insertions(+), 24 deletions(-)
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index 163efd026881..7db63bb77158 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -808,6 +808,14 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
static const char transition_ver[] = "HUION_T153_160607";
char *ver_ptr = NULL;
const size_t ver_len = sizeof(transition_ver) + 1;
+ __u8 *params_ptr = NULL;
+ size_t params_len = 0;
+ /* Parameters string descriptor of a model with touch ring (HS610) */
+ const __u8 touch_ring_model_params_buf[] = {
+ 0x13, 0x03, 0x70, 0xC6, 0x00, 0x06, 0x7C, 0x00,
+ 0xFF, 0x1F, 0xD8, 0x13, 0x03, 0x0D, 0x10, 0x01,
+ 0x04, 0x3C, 0x3E
+ };
/* Check arguments */
if (params == NULL || hdev == NULL) {
@@ -852,7 +860,8 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
} else {
/* Try to probe v2 pen parameters */
rc = uclogic_params_pen_init_v2(&p.pen, &found,
- NULL, NULL, hdev);
+ ¶ms_ptr, ¶ms_len,
+ hdev);
if (rc != 0) {
hid_err(hdev,
"failed probing pen v2 parameters: %d\n", rc);
@@ -872,24 +881,58 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
goto cleanup;
}
- /* Create v2 frame touch ring parameters */
- rc = uclogic_params_frame_init_with_desc(
+ /* Link from pen sub-report */
+ p.pen.subreport_list[0].value = 0xe0;
+ p.pen.subreport_list[0].id =
+ UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID;
+
+ /* If this is the model with touch ring */
+ if (params_ptr != NULL &&
+ params_len == sizeof(touch_ring_model_params_buf) &&
+ memcmp(params_ptr, touch_ring_model_params_buf,
+ params_len) == 0) {
+ /* Create 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_ID);
- if (rc != 0) {
- hid_err(hdev,
- "failed creating v2 frame touch ring parameters: %d\n",
- rc);
- goto cleanup;
+ 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_DEV_ID_BYTE;
+ p.frame_list[1].touch_byte = 5;
+ p.frame_list[1].touch_max = 12;
+ p.frame_list[1].touch_flip_at = 7;
+ } else {
+ /* Create touch strip parameters */
+ rc = uclogic_params_frame_init_with_desc(
+ &p.frame_list[1],
+ uclogic_rdesc_v2_frame_touch_strip_arr,
+ uclogic_rdesc_v2_frame_touch_strip_size,
+ UCLOGIC_RDESC_V2_FRAME_TOUCH_ID);
+ if (rc != 0) {
+ hid_err(hdev,
+ "failed creating v2 frame touch strip parameters: %d\n",
+ rc);
+ goto cleanup;
+ }
+ p.frame_list[1].suffix = "Touch Strip";
+ p.frame_list[1].dev_id_byte =
+ UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE;
+ p.frame_list[1].touch_byte = 5;
+ p.frame_list[1].touch_max = 8;
}
- p.frame_list[1].suffix = "Touch Ring";
- p.frame_list[1].dev_id_byte =
- UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE;
- p.frame_list[1].touch_byte = 5;
- p.frame_list[1].touch_max = 12;
- p.frame_list[1].touch_flip_at = 7;
+
+ /* Link from pen sub-report */
+ p.pen.subreport_list[1].value = 0xf0;
+ p.pen.subreport_list[1].id =
+ UCLOGIC_RDESC_V2_FRAME_TOUCH_ID;
/* Create v2 frame dial parameters */
rc = uclogic_params_frame_init_with_desc(
@@ -908,19 +951,11 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
UCLOGIC_RDESC_V2_FRAME_DIAL_DEV_ID_BYTE;
p.frame_list[2].bitmap_dial_byte = 5;
- /*
- * 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_BUTTONS_ID;
- p.pen.subreport_list[1].value = 0xf0;
- p.pen.subreport_list[1].id =
- UCLOGIC_RDESC_V2_FRAME_TOUCH_ID;
+ /* Link from pen sub-report */
p.pen.subreport_list[2].value = 0xf1;
p.pen.subreport_list[2].id =
UCLOGIC_RDESC_V2_FRAME_DIAL_ID;
+
goto output;
}
hid_dbg(hdev, "pen v2 parameters not found\n");
@@ -961,6 +996,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
memset(&p, 0, sizeof(p));
rc = 0;
cleanup:
+ kfree(params_ptr);
kfree(ver_ptr);
uclogic_params_cleanup(&p);
return rc;
diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c
index e2bd3a91e6fd..3c3d4e8780dc 100644
--- a/drivers/hid/hid-uclogic-rdesc.c
+++ b/drivers/hid/hid-uclogic-rdesc.c
@@ -761,6 +761,54 @@ const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[] = {
const size_t uclogic_rdesc_v2_frame_touch_ring_size =
sizeof(uclogic_rdesc_v2_frame_touch_ring_arr);
+/* Fixed report descriptor for (tweaked) v2 frame touch strip reports */
+const __u8 uclogic_rdesc_v2_frame_touch_strip_arr[] = {
+ 0x05, 0x01, /* Usage Page (Desktop), */
+ 0x09, 0x07, /* Usage (Keypad), */
+ 0xA1, 0x01, /* Collection (Application), */
+ 0x85, UCLOGIC_RDESC_V2_FRAME_TOUCH_ID,
+ /* Report ID (TOUCH_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, 0x07, /* Logical Maximum (7), */
+ 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_strip_size =
+ sizeof(uclogic_rdesc_v2_frame_touch_strip_arr);
+
/* Fixed report descriptor for (tweaked) v2 frame dial reports */
const __u8 uclogic_rdesc_v2_frame_dial_arr[] = {
0x05, 0x01, /* Usage Page (Desktop), */
diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h
index b7bbaa70261e..0c6e95e8bde7 100644
--- a/drivers/hid/hid-uclogic-rdesc.h
+++ b/drivers/hid/hid-uclogic-rdesc.h
@@ -138,6 +138,10 @@ extern const size_t uclogic_rdesc_v2_frame_buttons_size;
extern const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[];
extern const size_t uclogic_rdesc_v2_frame_touch_ring_size;
+/* Fixed report descriptor for (tweaked) v2 frame touch strip reports */
+extern const __u8 uclogic_rdesc_v2_frame_touch_strip_arr[];
+extern const size_t uclogic_rdesc_v2_frame_touch_strip_size;
+
/* Device ID byte offset in v2 frame touch ring/strip reports */
#define UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE 0x4
--
2.25.1
next prev parent reply other threads:[~2022-05-08 16:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-08 16:01 [PATCH for-5.19/uclogic 0/7] DIGImend patches, part VI José Expósito
2022-05-08 16:01 ` [PATCH for-5.19/uclogic 1/7] HID: uclogic: Move param printing to a function José Expósito
2022-05-08 17:16 ` kernel test robot
2022-05-08 17:32 ` José Expósito
2022-05-08 18:39 ` kernel test robot
2022-05-08 16:01 ` [PATCH for-5.19/uclogic 2/7] HID: uclogic: Return raw parameters from v2 pen init José Expósito
2022-05-08 16:01 ` [PATCH for-5.19/uclogic 3/7] HID: uclogic: Do not focus on touch ring only José Expósito
2022-05-08 16:01 ` [PATCH for-5.19/uclogic 4/7] HID: uclogic: Always shift touch reports to zero José Expósito
2022-05-08 16:01 ` José Expósito [this message]
2022-05-08 16:01 ` [PATCH for-5.19/uclogic 6/7] HID: uclogic: Add pen support for XP-PEN Star 06 José Expósito
2022-05-08 16:01 ` [PATCH for-5.19/uclogic 7/7] HID: uclogic: Switch to Digitizer usage for styluses José Expósito
2022-05-11 12:20 ` [PATCH for-5.19/uclogic 0/7] DIGImend patches, part VI 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=20220508160146.13004-6-jose.exposito89@gmail.com \
--to=jose.exposito89@gmail.com \
--cc=albertofanjul@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 \
--cc=stefanberzl@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).