bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0581-input-edt-ft5x06-Handle-unreliable-TOUCH_UP-events.patch
1 From 7b658b57d05317656fec750eca1094049de41c76 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Fri, 26 Nov 2021 14:37:40 +0000
4 Subject: [PATCH] input: edt-ft5x06: Handle unreliable TOUCH_UP events
5
6 The ft5x06 is unreliable in sending touch up events, so some
7 touch IDs can become stuck in the detected state.
8
9 Ensure that IDs that are unreported by the controller are
10 released.
11
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
13 ---
14 drivers/input/touchscreen/edt-ft5x06.c | 21 ++++++++++++++++++++-
15 1 file changed, 20 insertions(+), 1 deletion(-)
16
17 --- a/drivers/input/touchscreen/edt-ft5x06.c
18 +++ b/drivers/input/touchscreen/edt-ft5x06.c
19 @@ -127,6 +127,7 @@ struct edt_ft5x06_ts_data {
20 int offset_y;
21 int report_rate;
22 int max_support_points;
23 + unsigned int known_ids;
24
25 char name[EDT_NAME_LEN];
26
27 @@ -201,6 +202,9 @@ static irqreturn_t edt_ft5x06_ts_isr(int
28 int i, type, x, y, id;
29 int offset, tplen, datalen, crclen;
30 int error;
31 + unsigned int active_ids = 0, known_ids = tsdata->known_ids;
32 + long released_ids;
33 + int b = 0;
34
35 switch (tsdata->version) {
36 case EDT_M06:
37 @@ -272,10 +276,25 @@ static irqreturn_t edt_ft5x06_ts_isr(int
38
39 input_mt_slot(tsdata->input, id);
40 if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER,
41 - type != TOUCH_EVENT_UP))
42 + type != TOUCH_EVENT_UP)) {
43 touchscreen_report_pos(tsdata->input, &tsdata->prop,
44 x, y, true);
45 + active_ids |= BIT(id);
46 + } else {
47 + known_ids &= ~BIT(id);
48 + }
49 + }
50 +
51 + /* One issue with the device is the TOUCH_UP message is not always
52 + * returned. Instead track which ids we know about and report when they
53 + * are no longer updated
54 + */
55 + released_ids = known_ids & ~active_ids;
56 + for_each_set_bit_from(b, &released_ids, tsdata->max_support_points) {
57 + input_mt_slot(tsdata->input, b);
58 + input_mt_report_slot_inactive(tsdata->input);
59 }
60 + tsdata->known_ids = active_ids;
61
62 input_mt_report_pointer_emulation(tsdata->input, true);
63 input_sync(tsdata->input);