linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Patil, Rachna" <rachna@ti.com>
To: linux-doc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
	linux-iio@vger.kernel.org
Cc: Rob Landley <rob@landley.net>,
	Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <rob.herring@calxeda.com>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Dmitry Torokhov <dtor@mail.ru>,
	Jonathan Cameron <jic23@cam.ac.uk>,
	"Patil, Rachna" <rachna@ti.com>
Subject: [PATCH RESEND 3/7] input: ti_am335x_tsc: Add variance filter
Date: Wed, 7 Nov 2012 12:22:00 +0530	[thread overview]
Message-ID: <1352271124-5513-4-git-send-email-rachna@ti.com> (raw)
In-Reply-To: <1352271124-5513-1-git-send-email-rachna@ti.com>

Only fine tuning variance parameter present in tslib
utility does not help in removing all the ADC noise.
This logic of filtering is necessary to get this
touchscreen to work finely.

Signed-off-by: Patil, Rachna <rachna@ti.com>
---
 drivers/input/touchscreen/ti_am335x_tsc.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 6a817a8..7a26810 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -32,6 +32,8 @@
 #define ADCFSM_STEPID		0x10
 #define SEQ_SETTLE		275
 #define MAX_12BIT		((1 << 12) - 1)
+#define TSCADC_DELTA_X		15
+#define TSCADC_DELTA_Y		15
 
 /*
  * Refer to function regbit_map() to
@@ -51,6 +53,8 @@ struct titsc {
 	unsigned int		wires;
 	unsigned int		x_plate_resistance;
 	unsigned int		enable_bits;
+	unsigned int		bckup_x;
+	unsigned int		bckup_y;
 	bool			pen_down;
 	int			steps_to_configure;
 	int			config_inp[20];
@@ -309,12 +313,18 @@ static irqreturn_t titsc_irq(int irq, void *dev)
 	unsigned int z1, z2, z;
 	unsigned int fsm;
 	unsigned int fifo1count, fifo0count;
+	unsigned int diffx = 0, diffy = 0;
 	int i;
 
 	status = titsc_readl(ts_dev, REG_IRQSTATUS);
 	if (status & IRQENB_FIFO0THRES) {
 		titsc_read_coordinates(ts_dev, &x, &y);
 
+		diffx = abs(x - (ts_dev->bckup_x));
+		diffy = abs(y - (ts_dev->bckup_y));
+		ts_dev->bckup_x = x;
+		ts_dev->bckup_y = y;
+
 		z1 = titsc_readl(ts_dev, REG_FIFO0) & 0xfff;
 		z2 = titsc_readl(ts_dev, REG_FIFO1) & 0xfff;
 
@@ -338,7 +348,8 @@ static irqreturn_t titsc_irq(int irq, void *dev)
 			z /= z1;
 			z = (z + 2047) >> 12;
 
-			if (z <= MAX_12BIT) {
+			if ((diffx < TSCADC_DELTA_X) &&
+			(diffy < TSCADC_DELTA_Y) && (z <= MAX_12BIT)) {
 				input_report_abs(input_dev, ABS_X, x);
 				input_report_abs(input_dev, ABS_Y, y);
 				input_report_abs(input_dev, ABS_PRESSURE, z);
@@ -361,6 +372,8 @@ static irqreturn_t titsc_irq(int irq, void *dev)
 		fsm = titsc_readl(ts_dev, REG_ADCFSM);
 		if (fsm == ADCFSM_STEPID) {
 			ts_dev->pen_down = false;
+			ts_dev->bckup_x = 0;
+			ts_dev->bckup_y = 0;
 			input_report_key(input_dev, BTN_TOUCH, 0);
 			input_report_abs(input_dev, ABS_PRESSURE, 0);
 			input_sync(input_dev);
-- 
1.7.0.4

  parent reply	other threads:[~2012-11-07  6:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-07  6:51 [PATCH RESEND 0/7] MFD: ti_am335x_tscadc: DT support and TSC features addition Patil, Rachna
2012-11-07  6:51 ` [PATCH RESEND 1/7] input: ti_am335x_tsc: Step enable bits made configurable Patil, Rachna
2012-11-07  6:51 ` [PATCH RESEND 2/7] input: ti_am335x_tsc: Order of TSC wires, " Patil, Rachna
2012-11-07  6:52 ` Patil, Rachna [this message]
2012-11-21 18:33   ` [PATCH RESEND 3/7] input: ti_am335x_tsc: Add variance filter Dmitry Torokhov
     [not found]     ` <20121121183350.GB18950-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2012-11-27  7:07       ` Patil, Rachna
2012-11-07  6:52 ` [PATCH RESEND 4/7] MFD: ti_am335x_tscadc: add device tree binding information Patil, Rachna
     [not found] ` <1352271124-5513-1-git-send-email-rachna-l0cyMroinI0@public.gmane.org>
2012-11-07  6:52   ` [PATCH RESEND 5/7] MFD: ti_am335x_tscadc: Add DT support Patil, Rachna
2012-11-07  6:52 ` [PATCH RESEND 6/7] input: ti_am335x_tsc: " Patil, Rachna
     [not found]   ` <1352271124-5513-7-git-send-email-rachna-l0cyMroinI0@public.gmane.org>
2012-11-21 18:32     ` Dmitry Torokhov
2012-11-27  7:11       ` Patil, Rachna
2012-11-07  6:52 ` [PATCH RESEND 7/7] IIO: ti_am335x_adc: " Patil, Rachna
2012-11-16 10:33 ` [PATCH RESEND 0/7] MFD: ti_am335x_tscadc: DT support and TSC features addition Patil, Rachna
     [not found]   ` <4CE347531D4CA947960AF71FF095B9323E96C54A-Er742YJ7I/eIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2012-11-21 17:00     ` Samuel Ortiz
2012-11-27  7:14       ` Patil, Rachna

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=1352271124-5513-4-git-send-email-rachna@ti.com \
    --to=rachna@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dtor@mail.ru \
    --cc=grant.likely@secretlab.ca \
    --cc=jic23@cam.ac.uk \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rob.herring@calxeda.com \
    --cc=rob@landley.net \
    --cc=sameo@linux.intel.com \
    /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 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).