Input: ad7877 - filter events where pressure is beyond the maximum
authorMichael Hennerich <michael.hennerich@analog.com>
Fri, 15 Oct 2010 16:49:08 +0000 (09:49 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 18 Oct 2010 04:12:46 +0000 (21:12 -0700)
Suppress events where pressure > pressure_max.
These events come typically along with inaccurate X and Y samples.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/touchscreen/ad7877.c

index 96c0a0d4b69c2819497bb7cecad1de64d7c290a3..b7de78e8273742cc515f1e5491282c04d0ca6ba8 100644 (file)
@@ -360,6 +360,13 @@ static int ad7877_rx(struct ad7877 *ts)
                Rt /= z1;
                Rt = (Rt + 2047) >> 12;
 
+               /*
+                * 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))
                        input_report_key(input_dev, BTN_TOUCH, 1);