From d8bf9a89cd6d9c0a0c65f8fad37bf7a806fefb6e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 13 May 2023 16:52:16 +0900 Subject: [PATCH] 6.3-stable patches added patches: hid-wacom-insert-timestamp-to-packed-bluetooth-bt-events.patch hid-wacom-set-a-default-resolution-for-older-tablets.patch --- ...estamp-to-packed-bluetooth-bt-events.patch | 109 ++++++++++++++++++ ...default-resolution-for-older-tablets.patch | 48 ++++++++ queue-6.3/series | 2 + 3 files changed, 159 insertions(+) create mode 100644 queue-6.3/hid-wacom-insert-timestamp-to-packed-bluetooth-bt-events.patch create mode 100644 queue-6.3/hid-wacom-set-a-default-resolution-for-older-tablets.patch diff --git a/queue-6.3/hid-wacom-insert-timestamp-to-packed-bluetooth-bt-events.patch b/queue-6.3/hid-wacom-insert-timestamp-to-packed-bluetooth-bt-events.patch new file mode 100644 index 00000000000..384176325c9 --- /dev/null +++ b/queue-6.3/hid-wacom-insert-timestamp-to-packed-bluetooth-bt-events.patch @@ -0,0 +1,109 @@ +From 17d793f3ed53080dab6bbeabfc82de890c901001 Mon Sep 17 00:00:00 2001 +From: Ping Cheng +Date: Fri, 24 Feb 2023 08:26:43 -0800 +Subject: HID: wacom: insert timestamp to packed Bluetooth (BT) events + +From: Ping Cheng + +commit 17d793f3ed53080dab6bbeabfc82de890c901001 upstream. + +To fully utilize the BT polling/refresh rate, a few input events +are sent together to reduce event delay. This causes issue to the +timestamp generated by input_sync since all the events in the same +packet would pretty much have the same timestamp. This patch inserts +time interval to the events by averaging the total time used for +sending the packet. + +This decision was mainly based on observing the actual time interval +between each BT polling. The interval doesn't seem to be constant, +due to the network and system environment. So, using solutions other +than averaging doesn't end up with valid timestamps. + +Signed-off-by: Ping Cheng +Reviewed-by: Jason Gerecke +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman +--- + drivers/hid/wacom_wac.c | 26 ++++++++++++++++++++++++++ + drivers/hid/wacom_wac.h | 1 + + 2 files changed, 27 insertions(+) + +--- a/drivers/hid/wacom_wac.c ++++ b/drivers/hid/wacom_wac.c +@@ -1308,6 +1308,9 @@ static void wacom_intuos_pro2_bt_pen(str + + struct input_dev *pen_input = wacom->pen_input; + unsigned char *data = wacom->data; ++ int number_of_valid_frames = 0; ++ int time_interval = 15000000; ++ ktime_t time_packet_received = ktime_get(); + int i; + + if (wacom->features.type == INTUOSP2_BT || +@@ -1328,12 +1331,30 @@ static void wacom_intuos_pro2_bt_pen(str + wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF; + } + ++ /* number of valid frames */ + for (i = 0; i < pen_frames; i++) { + unsigned char *frame = &data[i*pen_frame_len + 1]; + bool valid = frame[0] & 0x80; ++ ++ if (valid) ++ number_of_valid_frames++; ++ } ++ ++ if (number_of_valid_frames) { ++ if (wacom->hid_data.time_delayed) ++ time_interval = ktime_get() - wacom->hid_data.time_delayed; ++ time_interval /= number_of_valid_frames; ++ wacom->hid_data.time_delayed = time_packet_received; ++ } ++ ++ for (i = 0; i < number_of_valid_frames; i++) { ++ unsigned char *frame = &data[i*pen_frame_len + 1]; ++ bool valid = frame[0] & 0x80; + bool prox = frame[0] & 0x40; + bool range = frame[0] & 0x20; + bool invert = frame[0] & 0x10; ++ int frames_number_reversed = number_of_valid_frames - i - 1; ++ int event_timestamp = time_packet_received - frames_number_reversed * time_interval; + + if (!valid) + continue; +@@ -1346,6 +1367,7 @@ static void wacom_intuos_pro2_bt_pen(str + wacom->tool[0] = 0; + wacom->id[0] = 0; + wacom->serial[0] = 0; ++ wacom->hid_data.time_delayed = 0; + return; + } + +@@ -1382,6 +1404,7 @@ static void wacom_intuos_pro2_bt_pen(str + get_unaligned_le16(&frame[11])); + } + } ++ + if (wacom->tool[0]) { + input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5])); + if (wacom->features.type == INTUOSP2_BT || +@@ -1405,6 +1428,9 @@ static void wacom_intuos_pro2_bt_pen(str + + wacom->shared->stylus_in_proximity = prox; + ++ /* add timestamp to unpack the frames */ ++ input_set_timestamp(pen_input, event_timestamp); ++ + input_sync(pen_input); + } + } +--- a/drivers/hid/wacom_wac.h ++++ b/drivers/hid/wacom_wac.h +@@ -324,6 +324,7 @@ struct hid_data { + int ps_connected; + bool pad_input_event_flag; + unsigned short sequence_number; ++ int time_delayed; + }; + + struct wacom_remote_data { diff --git a/queue-6.3/hid-wacom-set-a-default-resolution-for-older-tablets.patch b/queue-6.3/hid-wacom-set-a-default-resolution-for-older-tablets.patch new file mode 100644 index 00000000000..96027418e9a --- /dev/null +++ b/queue-6.3/hid-wacom-set-a-default-resolution-for-older-tablets.patch @@ -0,0 +1,48 @@ +From 08a46b4190d345544d04ce4fe2e1844b772b8535 Mon Sep 17 00:00:00 2001 +From: Ping Cheng +Date: Sun, 9 Apr 2023 09:42:29 -0700 +Subject: HID: wacom: Set a default resolution for older tablets + +From: Ping Cheng + +commit 08a46b4190d345544d04ce4fe2e1844b772b8535 upstream. + +Some older tablets may not report physical maximum for X/Y +coordinates. Set a default to prevent undefined resolution. + +Signed-off-by: Ping Cheng +Link: https://lore.kernel.org/r/20230409164229.29777-1-ping.cheng@wacom.com +Signed-off-by: Benjamin Tissoires +Signed-off-by: Greg Kroah-Hartman +--- + drivers/hid/wacom_wac.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +--- a/drivers/hid/wacom_wac.c ++++ b/drivers/hid/wacom_wac.c +@@ -1895,6 +1895,7 @@ static void wacom_map_usage(struct input + 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 + 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: diff --git a/queue-6.3/series b/queue-6.3/series index 9db01fef806..310af88b837 100644 --- a/queue-6.3/series +++ b/queue-6.3/series @@ -207,3 +207,5 @@ drm-amdgpu-drop-gfx_v11_0_cp_ecc_error_irq_funcs.patch drm-amdgpu-disable-sdma-ecc-irq-only-when-sdma-ras-is-enabled-in-suspend.patch drm-amd-pm-avoid-potential-ubsan-issue-on-legacy-asics.patch firewire-net-fix-unexpected-release-of-object-for-asynchronous-request-packet.patch +hid-wacom-set-a-default-resolution-for-older-tablets.patch +hid-wacom-insert-timestamp-to-packed-bluetooth-bt-events.patch -- 2.47.3