[RFC PATCH] HID: wacom: Stop mangling tool IDs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jason Gerecke <jason.gerecke@xxxxxxxxx>

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@xxxxxxxxx>
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





[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux