From: wuhao Date: Tue, 26 Feb 2013 01:15:37 +0000 (+0800) Subject: fix touch ct363 X-Git-Tag: firefly_0821_release~7524 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5df76cc136d3e692d15abd4ea2256703e860aa3e;p=firefly-linux-kernel-4.4.55.git fix touch ct363 --- diff --git a/arch/arm/mach-rk3188/board-rk3188-ds1006h.c b/arch/arm/mach-rk3188/board-rk3188-ds1006h.c index 38b6c7701a40..2c0adf1cf872 100755 --- a/arch/arm/mach-rk3188/board-rk3188-ds1006h.c +++ b/arch/arm/mach-rk3188/board-rk3188-ds1006h.c @@ -118,7 +118,7 @@ static struct ct36x_platform_data ct36x_info = { .gpio = TOUCH_INT_PIN, .active_low = 1, }, - .orientation = {1, 0, 1, 0}, + .orientation = {1, 0, 0, 1}, }; #endif static struct spi_board_info board_spi_devices[] = { diff --git a/drivers/input/touchscreen/ct36x/ct363.c b/drivers/input/touchscreen/ct36x/ct363.c index f29d708ccdb9..3fd8a4eefbe4 100644 --- a/drivers/input/touchscreen/ct36x/ct363.c +++ b/drivers/input/touchscreen/ct36x/ct363.c @@ -174,27 +174,44 @@ static void ct363_report(struct ct36x_data *ts) return; } - + int t ,m; + if(ct36x_dbg_level==2) + for(t=0;t< ts->point_num;t++){ + ct36x_dbg(ts, "CT363buf[%d]: ", t); + for(m=0;m<6;m++){ + ct36x_dbg(ts, " 0x%x %x %x %x %x %x %x %x ",ct363->pts[t].xhi, + ct363->pts[t].yhi, + ct363->pts[t].ylo, + ct363->pts[t].xlo, + ct363->pts[t].status, + ct363->pts[t].id, + ct363->pts[t].area, + ct363->pts[t].pressure); + } + ct36x_dbg(ts, " \n "); + } + ct363->press = 0; for(i = 0; i < ts->point_num; i++){ if((ct363->pts[i].xhi != 0xFF && ct363->pts[i].yhi != 0xFF) && (ct363->pts[i].status == 1 || ct363->pts[i].status == 2)){ x = (ct363->pts[i].xhi<<4)|(ct363->pts[i].xlo&0xF); y = (ct363->pts[i].yhi<<4)|(ct363->pts[i].ylo&0xF); + ct363->x = ts->orientation[0] * x + ts->orientation[1] * y; ct363->y = ts->orientation[2] * x + ts->orientation[3] * y; - if(ct363->x < 0) - ct363->x = ts->x_max - ct363->x; - if(ct363->y < 0) - ct363->y = ts->y_max - ct363->y; + if( (ct363->x > ts->x_max) || (ct363->y > ts->y_max) || (ct363->x < 0) || (ct363->y < 0) ){ + continue ; + } + input_mt_slot(ts->input, ct363->pts[i].id - 1); input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true); input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, 1); - input_report_abs(ts->input, ABS_MT_POSITION_X, x); - input_report_abs(ts->input, ABS_MT_POSITION_Y, y); + input_report_abs(ts->input, ABS_MT_POSITION_X, ct363->x); + input_report_abs(ts->input, ABS_MT_POSITION_Y, ct363->y); input_report_abs(ts->input, ABS_MT_PRESSURE, ct363->pts[i].pressure); - ct36x_dbg(ts, "CT363 report value: x: %d, y:%d\n", ct363->x, ct363->y); + ct36x_dbg(ts, "CT363 report value: id: %d, x: %d, y:%d\n",ct363->pts[i].id - 1, ct363->x, ct363->y); sync = 1; ct363->press |= 0x01 << (ct363->pts[i].id - 1); diff --git a/drivers/input/touchscreen/ct36x/ct36x_priv.h b/drivers/input/touchscreen/ct36x/ct36x_priv.h index 4f4cd8b95107..539743435ff5 100644 --- a/drivers/input/touchscreen/ct36x/ct36x_priv.h +++ b/drivers/input/touchscreen/ct36x/ct36x_priv.h @@ -22,13 +22,28 @@ #include #include -#if 0 +//#if 1 +//#define ct36x_dbg(ts, format, arg...) \ +// dev_printk(KERN_INFO , ts->dev , format , ## arg) +//#else +//#define ct36x_dbg(ts, format, arg...) +//#endif +int ct36x_dbg_level = 0; +module_param_named(dbg_level, ct36x_dbg_level, int, 0644); +#if 1 #define ct36x_dbg(ts, format, arg...) \ - dev_printk(KERN_INFO , ts->dev , format , ## arg) -#else -#define ct36x_dbg(ts, format, arg...) + do { \ + if (ct36x_dbg_level) { \ + dev_printk(KERN_INFO , ts->dev , format , ## arg) ;\ + } \ + } while (0) +#else +#define DBG(x...) #endif + + + #define CT36X_I2C_RATE (200 * 1000) struct ct36x_data; diff --git a/drivers/input/touchscreen/ct36x/ct36x_ts.c b/drivers/input/touchscreen/ct36x/ct36x_ts.c index 752370fbc51f..8e48495b83f4 100644 --- a/drivers/input/touchscreen/ct36x/ct36x_ts.c +++ b/drivers/input/touchscreen/ct36x/ct36x_ts.c @@ -101,7 +101,7 @@ static int ct36x_add_client(void) static irqreturn_t ct36x_irq_handler(int irq, void *data) { struct ct36x_data *ts = data; - + ct36x_dbg(ts, "----------- ct36x_irq_handler -----------\n"); //disable_irq(ts->irq); if(ts->ops->report) ts->ops->report(ts); @@ -216,7 +216,7 @@ static int ct36x_ts_probe(struct i2c_client *client, const struct i2c_device_id register_early_suspend(&ts->early_suspend); #endif ts->irq = gpio_to_irq(ts->irq_io.gpio); - ret = request_threaded_irq(ts->irq, NULL, ct36x_irq_handler, IRQF_ONESHOT, CT36X_NAME, ts); + ret = request_threaded_irq(ts->irq, NULL, ct36x_irq_handler, IRQF_TRIGGER_FALLING|IRQF_ONESHOT, CT36X_NAME, ts); if(ret < 0){ dev_err(ts->dev, "Failed to request threaded irq\n"); goto err_request_threaded_irq;