From patchwork Wed Nov 7 06:52:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Patil, Rachna" X-Patchwork-Id: 1708491 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 33E763FD2B for ; Wed, 7 Nov 2012 07:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753106Ab2KGHIu (ORCPT ); Wed, 7 Nov 2012 02:08:50 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:50989 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752353Ab2KGHHl (ORCPT ); Wed, 7 Nov 2012 02:07:41 -0500 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id qA777Otr014483; Wed, 7 Nov 2012 01:07:25 -0600 Received: from DBDE70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id qA777Ifk002835; Wed, 7 Nov 2012 12:37:23 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by dbde70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 14.1.323.3; Wed, 7 Nov 2012 12:37:19 +0530 Received: from ucmsshproxy.india.ext.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with SMTP id qA777JmH004591; Wed, 7 Nov 2012 12:37:19 +0530 Received: from symphony.india.ext.ti.com (unknown [192.168.247.13]) by ucmsshproxy.india.ext.ti.com (Postfix) with ESMTP id C0980158002; Wed, 7 Nov 2012 12:37:19 +0530 (IST) Received: from localhost.localdomain (linux-psp-server [192.168.247.76]) by symphony.india.ext.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id qA777Jq07861; Wed, 7 Nov 2012 12:37:19 +0530 (IST) From: "Patil, Rachna" To: , , , , CC: Rob Landley , Grant Likely , Rob Herring , Samuel Ortiz , Dmitry Torokhov , Dmitry Torokhov , Jonathan Cameron , "Patil, Rachna" Subject: [PATCH RESEND 3/7] input: ti_am335x_tsc: Add variance filter Date: Wed, 7 Nov 2012 12:22:00 +0530 Message-ID: <1352271124-5513-4-git-send-email-rachna@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1352271124-5513-1-git-send-email-rachna@ti.com> References: <1352271124-5513-1-git-send-email-rachna@ti.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 --- 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);