diff mbox

[05/19] input: ti_am335x_tsc: Add variance filters

Message ID 1369681926-22185-6-git-send-email-bigeasy@linutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Sebastian Andrzej Siewior May 27, 2013, 7:11 p.m. UTC
From: "Patil, Rachna" <rachna@ti.com>

Only fine tuning variance present in tslib utility
does not help in removing all the wanted ADC noise.

This logic of filtering is necessary to get this
touchscreen to work finely.

Signed-off-by: Patil, Rachna <rachna@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/input/touchscreen/ti_am335x_tsc.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Comments

Dmitry Torokhov June 4, 2013, 4:43 p.m. UTC | #1
Hi,

On Mon, May 27, 2013 at 09:11:52PM +0200, Sebastian Andrzej Siewior wrote:
> From: "Patil, Rachna" <rachna@ti.com>
> 
> Only fine tuning variance present in tslib utility
> does not help in removing all the wanted ADC noise.
> 
> This logic of filtering is necessary to get this
> touchscreen to work finely.

So why do not we enhancing tslib so that it is useful for more
touchscreen?

FWIW I have been asking this question from the very beginning of this
driver being submitted.
Sebastian Andrzej Siewior June 4, 2013, 4:54 p.m. UTC | #2
* Dmitry Torokhov | 2013-06-04 09:43:49 [-0700]:

>Hi,
Hi Dmitry,

>On Mon, May 27, 2013 at 09:11:52PM +0200, Sebastian Andrzej Siewior wrote:
>> From: "Patil, Rachna" <rachna@ti.com>
>> 
>> Only fine tuning variance present in tslib utility
>> does not help in removing all the wanted ADC noise.
>> 
>> This logic of filtering is necessary to get this
>> touchscreen to work finely.
>
>So why do not we enhancing tslib so that it is useful for more
>touchscreen?

I am reworking the series and dropped this patch. I think it got added
because the driver currently mixes up sometimes some of the Y & Z
coordinates. So I check how it behaves and if required I try to push to
tslib if still required. I doubt someone is using this directly on the
eventX node.

>FWIW I have been asking this question from the very beginning of this
>driver being submitted.

I'm sorry. I'm currently trying to get the three pieces of the driver
(mfd, touch, iio) into shape. If there is anything please let me know.

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index be5cb67..b7d3c23 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -34,6 +34,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
@@ -53,6 +55,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];
@@ -310,11 +314,18 @@  static irqreturn_t titsc_irq(int irq, void *dev)
 	unsigned int x = 0, y = 0;
 	unsigned int z1, z2, z;
 	unsigned int fsm;
+	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;
 
@@ -330,7 +341,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);
@@ -353,6 +365,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);