The Linux Kernel Mailing List
 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 3/4] HID: uclogic: Add support for bitmap dials
Date: Thu, 14 Apr 2022 13:09:35 +0200	[thread overview]
Message-ID: <20220414110936.146378-4-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20220414110936.146378-1-jose.exposito89@gmail.com>

From: Nikolai Kondrashov <spbnick@gmail.com>

A bitmap dial sends reports with a dedicated bit per direction: 1 means
clockwise rotation, 2 means counterclockwise, as opposed to the normal
1 and -1 values.

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

diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index 96f3fb8c492c..627f1d0c52f2 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -382,6 +382,12 @@ static int uclogic_raw_event_frame(
 		}
 	}
 
+	/* If need to, and can, transform the bitmap dial reports */
+	if (frame->bitmap_dial_byte > 0 && frame->bitmap_dial_byte < size) {
+		if (data[frame->bitmap_dial_byte] == 2)
+			data[frame->bitmap_dial_byte] = -1;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index 78965e683d20..e5ccc558abc3 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -153,6 +153,13 @@ struct uclogic_params_frame {
 	 * Zero if no reversal should be done.
 	 */
 	__s8 touch_ring_flip_at;
+	/*
+	 * Offset of the bitmap dial byte, in the report. Zero if not present.
+	 * Only valid if "id" is not zero. A bitmap dial sends reports with a
+	 * dedicated bit per direction: 1 means clockwise rotation, 2 means
+	 * counterclockwise, as opposed to the normal 1 and -1.
+	 */
+	unsigned int bitmap_dial_byte;
 };
 
 /*
@@ -230,6 +237,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
 	"\t\t.touch_ring_byte = %u\n"       \
 	"\t\t.touch_ring_max = %hhd\n"      \
 	"\t\t.touch_ring_flip_at = %hhd\n"  \
+	"\t\t.bitmap_dial_byte = %u\n"      \
 	"\t},\n"                            \
 	"\t{\n"                             \
 	"\t\t.desc_ptr = %p\n"              \
@@ -241,6 +249,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
 	"\t\t.touch_ring_byte = %u\n"       \
 	"\t\t.touch_ring_max = %hhd\n"      \
 	"\t\t.touch_ring_flip_at = %hhd\n"  \
+	"\t\t.bitmap_dial_byte = %u\n"      \
 	"\t},\n"                            \
 	"\t{\n"                             \
 	"\t\t.desc_ptr = %p\n"              \
@@ -252,6 +261,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
 	"\t\t.touch_ring_byte = %u\n"       \
 	"\t\t.touch_ring_max = %hhd\n"      \
 	"\t\t.touch_ring_flip_at = %hhd\n"  \
+	"\t\t.bitmap_dial_byte = %u\n"      \
 	"\t},\n"                            \
 	"}\n"
 
@@ -281,6 +291,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
 	(_params)->frame_list[0].touch_ring_byte,                   \
 	(_params)->frame_list[0].touch_ring_max,                    \
 	(_params)->frame_list[0].touch_ring_flip_at,                \
+	(_params)->frame_list[0].bitmap_dial_byte,                  \
 	(_params)->frame_list[1].desc_ptr,                          \
 	(_params)->frame_list[1].desc_size,                         \
 	(_params)->frame_list[1].id,                                \
@@ -290,6 +301,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
 	(_params)->frame_list[1].touch_ring_byte,                   \
 	(_params)->frame_list[1].touch_ring_max,                    \
 	(_params)->frame_list[1].touch_ring_flip_at,                \
+	(_params)->frame_list[1].bitmap_dial_byte,                  \
 	(_params)->frame_list[2].desc_ptr,                          \
 	(_params)->frame_list[2].desc_size,                         \
 	(_params)->frame_list[2].id,                                \
@@ -298,7 +310,8 @@ extern int uclogic_params_init(struct uclogic_params *params,
 	(_params)->frame_list[2].dev_id_byte,                       \
 	(_params)->frame_list[2].touch_ring_byte,                   \
 	(_params)->frame_list[2].touch_ring_max,                    \
-	(_params)->frame_list[2].touch_ring_flip_at
+	(_params)->frame_list[2].touch_ring_flip_at,                \
+	(_params)->frame_list[2].bitmap_dial_byte
 
 /* Get a replacement report descriptor for a tablet's interface. */
 extern int uclogic_params_get_desc(const struct uclogic_params *params,
-- 
2.25.1


  parent reply	other threads:[~2022-04-14 11:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-14 11:09 [PATCH for-5.19/uclogic 0/4] DIGImend patches, part IV José Expósito
2022-04-14 11:09 ` [PATCH for-5.19/uclogic 1/4] HID: uclogic: Compress params format string José Expósito
2022-04-14 11:09 ` [PATCH for-5.19/uclogic 2/4] HID: uclogic: Reduce indent for params format str/args José Expósito
2022-04-14 11:09 ` José Expósito [this message]
2022-04-14 11:09 ` [PATCH for-5.19/uclogic 4/4] HID: uclogic: Add support for Huion Q620M José Expósito
2022-04-21  8:09 ` [PATCH for-5.19/uclogic 0/4] DIGImend patches, part IV 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=20220414110936.146378-4-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