diff mbox series

HID: wacom: Set a default resolution for older tablets

Message ID 20230409164229.29777-1-ping.cheng@wacom.com
State Accepted
Commit 08a46b4190d345544d04ce4fe2e1844b772b8535
Headers show
Series HID: wacom: Set a default resolution for older tablets | expand

Commit Message

Ping Cheng April 9, 2023, 4:42 p.m. UTC
Some older tablets may not report physical maximum for X/Y
coordinates. Set a default to prevent undefined resolution.

Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
---
 drivers/hid/wacom_wac.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Benjamin Tissoires April 13, 2023, 2:37 p.m. UTC | #1
On Sun, 09 Apr 2023 09:42:29 -0700, Ping Cheng wrote:
> 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

Cheers,
diff mbox series

Patch

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 9312d611db8e..e499b447d48c 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -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: