]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.1.12/hid-wacom-don-t-set-tool-type-until-we-re-in-range.patch
Linux 5.1.12
[thirdparty/kernel/stable-queue.git] / releases / 5.1.12 / hid-wacom-don-t-set-tool-type-until-we-re-in-range.patch
1 From 2cc08800a6b9fcda7c7afbcf2da1a6e8808da725 Mon Sep 17 00:00:00 2001
2 From: Jason Gerecke <jason.gerecke@wacom.com>
3 Date: Wed, 24 Apr 2019 15:12:57 -0700
4 Subject: HID: wacom: Don't set tool type until we're in range
5
6 From: Jason Gerecke <jason.gerecke@wacom.com>
7
8 commit 2cc08800a6b9fcda7c7afbcf2da1a6e8808da725 upstream.
9
10 The serial number and tool type information that is reported by the tablet
11 while a pen is merely "in prox" instead of fully "in range" can be stale
12 and cause us to report incorrect tool information. Serial number, tool
13 type, and other information is only valid once the pen comes fully in range
14 so we should be careful to not use this information until that point.
15
16 In particular, this issue may cause the driver to incorectly report
17 BTN_TOOL_RUBBER after switching from the eraser tool back to the pen.
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 | 17 ++++++++++++++++-
28 1 file changed, 16 insertions(+), 1 deletion(-)
29
30 --- a/drivers/hid/wacom_wac.c
31 +++ b/drivers/hid/wacom_wac.c
32 @@ -1236,13 +1236,13 @@ static void wacom_intuos_pro2_bt_pen(str
33 /* Add back in missing bits of ID for non-USI pens */
34 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
35 }
36 - wacom->tool[0] = wacom_intuos_get_tool_type(wacom_intuos_id_mangle(wacom->id[0]));
37
38 for (i = 0; i < pen_frames; i++) {
39 unsigned char *frame = &data[i*pen_frame_len + 1];
40 bool valid = frame[0] & 0x80;
41 bool prox = frame[0] & 0x40;
42 bool range = frame[0] & 0x20;
43 + bool invert = frame[0] & 0x10;
44
45 if (!valid)
46 continue;
47 @@ -1251,9 +1251,24 @@ static void wacom_intuos_pro2_bt_pen(str
48 wacom->shared->stylus_in_proximity = false;
49 wacom_exit_report(wacom);
50 input_sync(pen_input);
51 +
52 + wacom->tool[0] = 0;
53 + wacom->id[0] = 0;
54 + wacom->serial[0] = 0;
55 return;
56 }
57 +
58 if (range) {
59 + if (!wacom->tool[0]) { /* first in range */
60 + /* Going into range select tool */
61 + if (invert)
62 + wacom->tool[0] = BTN_TOOL_RUBBER;
63 + else if (wacom->id[0])
64 + wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
65 + else
66 + wacom->tool[0] = BTN_TOOL_PEN;
67 + }
68 +
69 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
70 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
71