Skip to contentSkip to conversation

HID: wacom: Set a default resolution for older tablets

PATCH Applied Ping Cheng 4 participants 9 messages Apr 9, 2023 – May 13, 2023

Subsystems (3)
lore
Share & tools
lore

Ping Cheng

author
#0 lore raw

PATCH 1/1 HID: wacom: Set a default resolution for older tablets

Some older tablets may not report physical maximum for X/Y coordinates. Set a default to prevent undefined resolution.

---
 drivers/hid/wacom_wac.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/hid/wacom_wac.c +10 -2
index 9312d611db8e..e499b447d48c 100644
@@ -1895,6 +1895,7 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
 	int fmax = field->logical_maximum;
 	unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
 	int resolution_code = code;
+	int resolution = hidinput_calc_abs_res(field, resolution_code);
 
 	if (equivalent_usage == HID_DG_TWIST) {
 		resolution_code = ABS_RZ;
@@ -1915,8 +1916,15 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
 	switch (type) {
 	case EV_ABS:
 		input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
-		input_abs_set_res(input, code,
-				  hidinput_calc_abs_res(field, resolution_code));
+
+		/* older tablet may miss physical usage */
+		if ((code == ABS_X || code == ABS_Y) && !resolution) {
+			resolution = WACOM_INTUOS_RES;
+			hid_warn(input,
+				 "Wacom usage (%d) missing resolution \n",
+				 code);
+		}
+		input_abs_set_res(input, code, resolution);
 		break;
 	case EV_KEY:
 	case EV_MSC:
Signature · 1 line
2.39.2
author
#2 lore raw
Quoted 11 lines · Benjamin Tissoires
Quoted 4 lines · Ping Cheng

Some older tablets may not report physical maximum for X/Y coordinates. Set a default to prevent undefined resolution.

Applied to hid/hid.git (for-6.4/wacom), thanks!

[1/1] HID: wacom: Set a default resolution for older tablets

      https://git.kernel.org/hid/hid/c/08a46b4190d3

This patch can be backported to kernels as early as 3.18. It fixes a firmware HID descriptor issue.

Thank you,
Ping

maintainer
#3 lore raw
Quoted 9 lines · Ping Cheng
Quoted 7 lines · Benjamin Tissoires
Quoted 4 lines · Ping Cheng

Some older tablets may not report physical maximum for X/Y coordinates. Set a default to prevent undefined resolution.

Quoted 7 lines
Quoted 4 lines

Applied to hid/hid.git (for-6.4/wacom), thanks!

[1/1] HID: wacom: Set a default resolution for older tablets

      https://git.kernel.org/hid/hid/c/08a46b4190d3

This patch can be backported to kernels as early as 3.18. It fixes a firmware HID descriptor issue.

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

author
#4 lore raw

PATCH 1/1 HID: wacom: Set a default resolution for older tablets

In reply to Ping Cheng

Hi Stable maintainers,

This patch, ID 08a46b4190d3, fixes an issue for a few older devices. It can be backported as is to all the current Long Term Supported kernels.

Thank you,
Ping

#5 lore raw
Quoted 6 lines · Ping Cheng

Hi Stable maintainers,

This patch, ID 08a46b4190d3, fixes an issue for a few older devices. It can be backported as is to all the current Long Term Supported kernels.

Now that your fix has been upstreamed, can you provide a backport for each supported stable versions (v4.14 up to v6.3)?

Thanks.

Signature · 1 line
An old man doll... just what I always wanted! - Clara
maintainer
#6 lore raw
Quoted 10 lines · Bagas Sanjaya
Quoted 6 lines · Ping Cheng

Hi Stable maintainers,

This patch, ID 08a46b4190d3, fixes an issue for a few older devices. It can be backported as is to all the current Long Term Supported kernels.

Now that your fix has been upstreamed, can you provide a backport for each supported stable versions (v4.14 up to v6.3)?

Why? That's not needed if the commit can be cherry-picked cleanly everywhere.

Please do not ask people to do unnecessary things.

greg k-h

author
#7 lore raw
Quoted 5 lines · Greg KH
Quoted 3 lines · Bagas Sanjaya
Quoted 2 lines · Ping Cheng

Hi Stable maintainers,

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

This patch, ID 08a46b4190d3, fixes an issue for a few older devices. It can be backported as is to all the current Long Term Supported kernels.

Now that your fix has been upstreamed, can you provide a backport for each supported stable versions (v4.14 up to v6.3)?

To speed up the process, I tested the patch on all stable branches. The upstream patch can be APPLIED to kernels 5.15 and later, AS IS.

The attached patch applies to kernels 4.14 to 5.10. If you'd like me to send the patch in a separate email, please let me know. Thank you for your effort!

Quoted 2 lines

Why? That's not needed if the commit can be cherry-picked cleanly everywhere.

Thank you @Greg KH for your support. The Linux community would not have got this far without people like you!

Cheers,
Ping

From 3eef69d84901f1d4369a436f87b3049e430b4b37 Mon Sep 17 00:00:00 2001
From: Ping Cheng <[email protected]>
Date: Wed, 10 May 2023 10:20:14 -0700
Subject: [PATCH Longterm 4.11 1/5] HID: wacom: Set a default resolution for older tablets

Some older tablets may not report physical maximum for X/Y coordinates. Set a default to prevent undefined resolution.

---
 drivers/hid/wacom_wac.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/hid/wacom_wac.c +10 -2
index 417e1083556b..921d5184196d 100644
@@ -1734,6 +1734,7 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
 	int fmax = field->logical_maximum;
 	unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
 	int resolution_code = code;
+	int resolution = hidinput_calc_abs_res(field, resolution_code);
 
 	if (equivalent_usage == HID_DG_TWIST) {
 		resolution_code = ABS_RZ;
@@ -1756,8 +1757,15 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
 	switch (type) {
 	case EV_ABS:
 		input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
-		input_abs_set_res(input, code,
-				  hidinput_calc_abs_res(field, resolution_code));
+
+		/* older tablet may miss physical usage */
+		if ((code == ABS_X || code == ABS_Y) && !resolution) {
+			resolution = WACOM_INTUOS_RES;
+			hid_warn(input,
+				 "Wacom usage (%d) missing resolution \n",
+				 code);
+		}
+		input_abs_set_res(input, code, resolution);
 		break;
 	case EV_KEY:
 		input_set_capability(input, EV_KEY, code);
Signature · 1 line
2.40.1
maintainer
#8 lore raw
Quoted 14 lines · Ping Cheng
Quoted 5 lines · Greg KH
Quoted 3 lines · Bagas Sanjaya
Quoted 2 lines · Ping Cheng

Hi Stable maintainers,

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

This patch, ID 08a46b4190d3, fixes an issue for a few older devices. It can be backported as is to all the current Long Term Supported kernels.

Now that your fix has been upstreamed, can you provide a backport for each supported stable versions (v4.14 up to v6.3)?

Quoted 6 lines

To speed up the process, I tested the patch on all stable branches. The upstream patch can be APPLIED to kernels 5.15 and later, AS IS.

The attached patch applies to kernels 4.14 to 5.10. If you'd like me to send the patch in a separate email, please let me know. Thank you for your effort!

All now queued up, thanks.

greg k-h