Skip to content

Commit 16c7561

Browse files
6by9pelwell
authored andcommitted
input: edt-ft5x06: Handle unreliable TOUCH_UP events
The ft5x06 is unreliable in sending touch up events, so some touch IDs can become stuck in the detected state. Ensure that IDs that are unreported by the controller are released. Signed-off-by: Dave Stevenson <[email protected]>
1 parent f5faa74 commit 16c7561

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

drivers/input/touchscreen/edt-ft5x06.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ struct edt_ft5x06_ts_data {
123123
int offset_y;
124124
int report_rate;
125125
int max_support_points;
126+
unsigned int known_ids;
126127

127128
char name[EDT_NAME_LEN];
128129

@@ -197,6 +198,9 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
197198
int i, type, x, y, id;
198199
int offset, tplen, datalen, crclen;
199200
int error;
201+
unsigned int active_ids = 0, known_ids = tsdata->known_ids;
202+
long released_ids;
203+
int b = 0;
200204

201205
switch (tsdata->version) {
202206
case EDT_M06:
@@ -268,10 +272,25 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
268272

269273
input_mt_slot(tsdata->input, id);
270274
if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER,
271-
type != TOUCH_EVENT_UP))
275+
type != TOUCH_EVENT_UP)) {
272276
touchscreen_report_pos(tsdata->input, &tsdata->prop,
273277
x, y, true);
278+
active_ids |= BIT(id);
279+
} else {
280+
known_ids &= ~BIT(id);
281+
}
282+
}
283+
284+
/* One issue with the device is the TOUCH_UP message is not always
285+
* returned. Instead track which ids we know about and report when they
286+
* are no longer updated
287+
*/
288+
released_ids = known_ids & ~active_ids;
289+
for_each_set_bit_from(b, &released_ids, tsdata->max_support_points) {
290+
input_mt_slot(tsdata->input, b);
291+
input_mt_report_slot_inactive(tsdata->input);
274292
}
293+
tsdata->known_ids = active_ids;
275294

276295
input_mt_report_pointer_emulation(tsdata->input, true);
277296
input_sync(tsdata->input);

0 commit comments

Comments
 (0)