]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/hid-wacom-don-t-report-anything-prior-to-the-tool-entering-range.patch
Linux 4.19.54
[thirdparty/kernel/stable-queue.git] / queue-4.14 / hid-wacom-don-t-report-anything-prior-to-the-tool-entering-range.patch
1 From e92a7be7fe5b2510fa60965eaf25f9e3dc08b8cc Mon Sep 17 00:00:00 2001
2 From: Jason Gerecke <jason.gerecke@wacom.com>
3 Date: Wed, 24 Apr 2019 15:12:58 -0700
4 Subject: HID: wacom: Don't report anything prior to the tool entering range
5
6 From: Jason Gerecke <jason.gerecke@wacom.com>
7
8 commit e92a7be7fe5b2510fa60965eaf25f9e3dc08b8cc upstream.
9
10 If the tool spends some time in prox before entering range, a series of
11 events (e.g. ABS_DISTANCE, MSC_SERIAL) can be sent before we or userspace
12 have any clue about the pen whose data is being reported. We need to hold
13 off on reporting anything until the pen has entered range. Since we still
14 want to report events that occur "in prox" after the pen has *left* range
15 we use 'wacom-tool[0]' as the indicator that the pen did at one point
16 enter range and provide us/userspace with tool type and serial number
17 information.
18
19 Fixes: a48324de6d4d ("HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range")
20 Cc: <stable@vger.kernel.org> # 4.11+
21 Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
22 Reviewed-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
23 Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26 ---
27 drivers/hid/wacom_wac.c | 20 +++++++++++---------
28 1 file changed, 11 insertions(+), 9 deletions(-)
29
30 --- a/drivers/hid/wacom_wac.c
31 +++ b/drivers/hid/wacom_wac.c
32 @@ -1271,17 +1271,19 @@ static void wacom_intuos_pro2_bt_pen(str
33 input_report_abs(pen_input, ABS_Z, rotation);
34 input_report_abs(pen_input, ABS_WHEEL, get_unaligned_le16(&frame[11]));
35 }
36 - input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
37 - input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max);
38 + if (wacom->tool[0]) {
39 + input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
40 + input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max);
41
42 - input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01);
43 - input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
44 - input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
45 + input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01);
46 + input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
47 + input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
48
49 - input_report_key(pen_input, wacom->tool[0], prox);
50 - input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
51 - input_report_abs(pen_input, ABS_MISC,
52 - wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
53 + input_report_key(pen_input, wacom->tool[0], prox);
54 + input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
55 + input_report_abs(pen_input, ABS_MISC,
56 + wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
57 + }
58
59 wacom->shared->stylus_in_proximity = prox;
60