linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: touchscreen: AD7879: prevent invalid finger data reports
@ 2010-10-18 13:33 michael.hennerich
  2010-10-22  5:00 ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: michael.hennerich @ 2010-10-18 13:33 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: linux-input, device-drivers-devel, drivers, Michael Hennerich

From: Michael Hennerich <michael.hennerich@analog.com>

Considering following scenario - the touch is present on the screen
at the beginning of the last conversion sequence, but by the time
the last sequence is finished, the finger is lift off.
The AD7879 data available interrupt signals (DAV) completion,
however some X,Y values are not valid because the screen inputs were
floating during the acquisition.

The AD7877 acts differently here, since it only asserts DAV
if the touch is still present when the conversion sequence finished.

Based on the fact that this can only happen in the last sample of the
repeated conversion sequence. We simply skip the last.
(Short glitches are filtered by the AD7879 internal median and average filters)
This doesn't cause noticeable side effects, since the minimum conversion
interval is 9.44ms. We receive ~100 waypoint samples per second,
so we simply delay the result by 9.44ms.

Actually this patch repeats the first waypoint twice and then skips the last.
This patch also rejects samples where pressure > pressure_max.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
---
 drivers/input/touchscreen/ad7879.c |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index ba6f0bd..3173589 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -129,6 +129,9 @@ struct ad7879 {
 	u16			cmd_crtl1;
 	u16			cmd_crtl2;
 	u16			cmd_crtl3;
+	int			x;
+	int			y;
+	int			Rt;	
 };
 
 static int ad7879_read(struct ad7879 *ts, u8 reg)
@@ -175,13 +178,29 @@ static int ad7879_report(struct ad7879 *ts)
 		Rt /= z1;
 		Rt = (Rt + 2047) >> 12;
 
-		if (!timer_pending(&ts->timer))
+		/*
+		 * Sample found inconsistent, pressure is beyond
+		 * the maximum. Don't report it to user space.
+		 */
+		if (Rt > ts->pressure_max)
+			return -EINVAL;
+
+		if (!timer_pending(&ts->timer)) {
+			ts->x = x;
+			ts->y = y;
+			ts->Rt = Rt;
 			input_report_key(input_dev, BTN_TOUCH, 1);
-
-		input_report_abs(input_dev, ABS_X, x);
-		input_report_abs(input_dev, ABS_Y, y);
-		input_report_abs(input_dev, ABS_PRESSURE, Rt);
-		input_sync(input_dev);
+		}
+		
+		input_report_abs(input_dev, ABS_X, ts->x);
+		input_report_abs(input_dev, ABS_Y, ts->y);
+		input_report_abs(input_dev, ABS_PRESSURE, ts->Rt);
+		input_sync(input_dev);		
+
+		ts->x = x;
+		ts->y = y;
+		ts->Rt = Rt;
+		
 		return 0;
 	}
 
-- 
1.6.0.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-10-25 11:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-18 13:33 [PATCH] Input: touchscreen: AD7879: prevent invalid finger data reports michael.hennerich
2010-10-22  5:00 ` Dmitry Torokhov
2010-10-22  7:16   ` Hennerich, Michael
2010-10-22 16:30     ` Dmitry Torokhov
2010-10-25 11:02       ` Hennerich, Michael

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).