From 12d25894f0fb551f6e1846de445ade1e336653ed Mon Sep 17 00:00:00 2001 From: "Rich.jiangyk" Date: Fri, 17 Sep 2010 11:41:35 +0800 Subject: [PATCH] Correct xpt2046_cbn_ts bug on IT50 On IT50 board, the touch screen sends 4095 invalid message for first raw data sample, especially for the top-left corner. The modification discards the first sample before processing it, which correct the bug and solve the problem on IT50. This won't affect other boards. NOTE: mod by srt, commit by jyk --- drivers/input/touchscreen/xpt2046_cbn_ts.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/input/touchscreen/xpt2046_cbn_ts.c b/drivers/input/touchscreen/xpt2046_cbn_ts.c index 8e34fadbb510..ca1bd122a7e3 100644 --- a/drivers/input/touchscreen/xpt2046_cbn_ts.c +++ b/drivers/input/touchscreen/xpt2046_cbn_ts.c @@ -386,21 +386,26 @@ static int xpt2046_debounce(void *xpt, int data_idx, int *val) abs(ts->last_read - *val),ts->debounce_tol, ts->read_rep,ts->debounce_rep); + /* discard the first sample. */ + //on info_it50, the top-left area(1cmx1cm top-left square ) is not responding cause the first sample is invalid, @sep 17th + if(!ts->read_cnt) + { + //udelay(100); + ts->read_cnt++; + return XPT2046_FILTER_REPEAT; + } + if(*val == 4095 || *val == 0) { ts->read_cnt = 0; ts->last_read = 0; memset(average_val,0,sizeof(average_val)); xpt2046printk("***>%s:*val == 4095 || *val == 0\n",__FUNCTION__); + return XPT2046_FILTER_IGNORE; + } - /* discard the first sample. */ - if(!ts->read_cnt) - { - //udelay(100); - ts->read_cnt++; - return XPT2046_FILTER_REPEAT; - } + if (ts->read_cnt==1 || (abs(ts->last_read - *val) > ts->debounce_tol)) { /* Start over collecting consistent readings. */ -- 2.34.1