All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Harvey <tharvey@gateworks.com>
To: linux-input@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Tim Harvey <tharvey@gateworks.com>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>
Subject: [RFC PATCH 4/4] input: edt-ft5x06 - Handle unreliable TOUCH_UP events
Date: Thu, 16 Dec 2021 15:30:41 -0800	[thread overview]
Message-ID: <20211216233041.1220-5-tharvey@gateworks.com> (raw)
In-Reply-To: <20211216233041.1220-1-tharvey@gateworks.com>

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 <dave.stevenson@raspberrypi.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
 drivers/input/touchscreen/edt-ft5x06.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index a3622d6e8e65..53906fcbaa51 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -126,6 +126,7 @@ struct edt_ft5x06_ts_data {
 	int offset_y;
 	int report_rate;
 	int max_support_points;
+	unsigned int known_ids;
 
 	char name[EDT_NAME_LEN];
 
@@ -198,6 +199,8 @@ static void edt_ft5x06_process(struct edt_ft5x06_ts_data *tsdata)
 	int offset, tplen, datalen, crclen;
 	int error;
 	int num_points;
+	unsigned int active_ids = 0, known_ids = tsdata->known_ids;
+	long released_ids;
 
 	switch (tsdata->version) {
 	case EDT_M06:
@@ -297,10 +300,21 @@ static void edt_ft5x06_process(struct edt_ft5x06_ts_data *tsdata)
 
 		input_mt_slot(tsdata->input, id);
 		if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER,
-					       type != TOUCH_EVENT_UP))
+					       type != TOUCH_EVENT_UP)) {
 			touchscreen_report_pos(tsdata->input, &tsdata->prop,
 					       x, y, true);
+			active_ids |= BIT(id);
+		} else {
+			known_ids &= ~BIT(id);
+		}
+	}
+
+	released_ids = known_ids & ~active_ids;
+	for_each_set_bit_from(i, &released_ids, tsdata->max_support_points) {
+		input_mt_slot(tsdata->input, i);
+		input_mt_report_slot_inactive(tsdata->input);
 	}
+	tsdata->known_ids = active_ids;
 
 	input_mt_report_pointer_emulation(tsdata->input, true);
 	input_sync(tsdata->input);
-- 
2.17.1


  parent reply	other threads:[~2021-12-16 23:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16 23:30 [RFC PATCH 0/4] input: edt-ft5x06: add support for DFROBOT touch controller to Tim Harvey
2021-12-16 23:30 ` [RFC PATCH 1/4] dt-bindings: input: touchscreen: edt-ft5x06: add poll-interval Tim Harvey
2021-12-17 14:53   ` Rob Herring
2021-12-16 23:30 ` [RFC PATCH 2/4] input: edt-ft5x06 - add polled input support Tim Harvey
2021-12-16 23:30 ` [RFC PATCH 3/4] input: edt-ft5x06 - add support for DFROBOT touch controllers Tim Harvey
2021-12-16 23:30 ` Tim Harvey [this message]
2022-01-21 17:24 ` [RFC PATCH 0/4] input: edt-ft5x06: add support for DFROBOT touch controller to Tim Harvey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211216233041.1220-5-tharvey@gateworks.com \
    --to=tharvey@gateworks.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.