6b2442ce9ad7870702ab61d58576e3328cac30db
[openwrt/staging/neocturne.git] /
1 From 4c2cec3cfad183400f191413e4867f3f07273ed6 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Fri, 19 May 2023 18:16:58 +0100
4 Subject: [PATCH] input: edt-ft5x06: Only read data for number of
5 points reported
6
7 Rather than always reading the maximum number of points supported
8 by the chip (which may be as high as 10), read the number of
9 active points first, and read data for just those.
10 In most cases this will result in less data on the I2C bus,
11 with only the maximum touch points taking more due to a second
12 read that has to configure the start address.
13
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 ---
16 drivers/input/touchscreen/edt-ft5x06.c | 10 +++++++++-
17 1 file changed, 9 insertions(+), 1 deletion(-)
18
19 --- a/drivers/input/touchscreen/edt-ft5x06.c
20 +++ b/drivers/input/touchscreen/edt-ft5x06.c
21 @@ -220,6 +220,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int
22 offset = 5; /* where the actual touch data starts */
23 tplen = 4; /* data comes in so called frames */
24 crclen = 1; /* length of the crc data */
25 + datalen = tplen * tsdata->max_support_points + offset + crclen;
26 break;
27
28 case EDT_M09:
29 @@ -230,6 +231,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int
30 offset = 3;
31 tplen = 6;
32 crclen = 0;
33 + datalen = 3;
34 break;
35
36 default:
37 @@ -237,7 +239,6 @@ static irqreturn_t edt_ft5x06_ts_isr(int
38 }
39
40 memset(rdbuf, 0, sizeof(rdbuf));
41 - datalen = tplen * tsdata->max_support_points + offset + crclen;
42
43 error = edt_ft5x06_ts_readwrite(tsdata->client,
44 sizeof(cmd), &cmd,
45 @@ -267,6 +268,13 @@ static irqreturn_t edt_ft5x06_ts_isr(int
46 * points.
47 */
48 num_points = min(rdbuf[2] & 0xf, tsdata->max_support_points);
49 + if (num_points) {
50 + datalen = tplen * num_points + crclen;
51 + cmd = offset;
52 + error = edt_ft5x06_ts_readwrite(tsdata->client,
53 + sizeof(cmd), &cmd,
54 + datalen, &rdbuf[offset]);
55 + }
56 }
57
58 for (i = 0; i < num_points; i++) {