public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] HID: wacom: Stop mangling tool IDs
@ 2024-09-03 18:26 Gerecke, Jason
  2024-09-03 18:32 ` Dmitry Torokhov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Gerecke, Jason @ 2024-09-03 18:26 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Jiri Kosina, Dmitry Torokhov
  Cc: Ping Cheng, Tobita, Tatsunosuke, Erin Skomra, Joshua Dickens,
	Peter Hutterer, Jason Gerecke

From: Jason Gerecke <jason.gerecke@wacom.com>

In ancient times, an off-by-one-nybble error resulted in the Wacom
driver sending "mangled" tool IDs to userspace. This mangling behavior
was later enshrined into a function so that devices using the then-new
generic codepath could share the same broken behavior. The mangled IDs
have not historically been a major problem for userspace since few
applications care about the exact numeric value of the IDs. As long as
the IDs were unique it didn't much matter. Some programs (cross-
platform and remote-desktop applications in particular) /do/ rely on
the IDs being correct, however.

This patch rids the driver of the mangling behavior.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
References: 493630b20389 ("Input: wacom - fix serial number handling on Cintiq 21UX2")
References: 82527da319ee ("HID: wacom: Read and internally use corrected Intuos tool IDs")
---
I'd like to get the opinion of the kernel maintainers on making a
change like this at some point in the future. There are _very_ few
userspace uses of these IDs (primarily: drivers, compositors, and
tablet control panels) and my plan is to update those bits and then
give some time for the changes to roll out to users before re-
submitting this for real. I don't expect any kind of breakage since
we'll be taking our time with the rollout and userspace needs to
have handling for "unknown" IDs anyway (since Wacom periodically
releases new pens).
---
 drivers/hid/wacom_wac.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 2541fa2e0fa3b..facab5bd37e41 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -671,11 +671,6 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
 	return 1;
 }
 
-static int wacom_intuos_id_mangle(int tool_id)
-{
-	return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
-}
-
 static bool wacom_is_art_pen(int tool_id)
 {
 	bool is_art_pen = false;
@@ -1010,8 +1005,7 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
 		break;
 	}
 
-	input_report_abs(input, ABS_MISC,
-			 wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
+	input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
 	input_report_key(input, wacom->tool[idx], 1);
 	input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
 	wacom->reporting_data = true;
@@ -1379,8 +1373,7 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
 
 			input_report_key(pen_input, wacom->tool[0], prox);
 			input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
-			input_report_abs(pen_input, ABS_MISC,
-					 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
+			input_report_abs(pen_input, ABS_MISC, wacom->id[0]); /* report tool id */
 		}
 
 		wacom->shared->stylus_in_proximity = prox;
@@ -2514,13 +2507,6 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
 		input_report_key(input, BTN_STYLUS2, wacom_wac->hid_data.barrelswitch2);
 		input_report_key(input, BTN_STYLUS3, wacom_wac->hid_data.barrelswitch3);
 
-		/*
-		 * Non-USI EMR tools should have their IDs mangled to
-		 * match the legacy behavior of wacom_intuos_general
-		 */
-		if (wacom_wac->serial[0] >> 52 == 1)
-			id = wacom_intuos_id_mangle(id);
-
 		/*
 		 * To ensure compatibility with xf86-input-wacom, we should
 		 * report the BTN_TOOL_* event prior to the ABS_MISC or
-- 
2.46.0


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

end of thread, other threads:[~2024-09-05 23:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-03 18:26 [RFC PATCH] HID: wacom: Stop mangling tool IDs Gerecke, Jason
2024-09-03 18:32 ` Dmitry Torokhov
2024-09-04  0:36 ` Peter Hutterer
2024-09-05  8:46 ` Jiri Kosina
2024-09-05  9:01   ` Benjamin Tissoires
2024-09-05 23:33     ` Peter Hutterer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox