fix touch ct363
authorwuhao <wuhao@wuhao@rock-chips.com>
Tue, 26 Feb 2013 01:15:37 +0000 (09:15 +0800)
committerwuhao <wuhao@wuhao@rock-chips.com>
Tue, 26 Feb 2013 01:15:37 +0000 (09:15 +0800)
arch/arm/mach-rk3188/board-rk3188-ds1006h.c
drivers/input/touchscreen/ct36x/ct363.c
drivers/input/touchscreen/ct36x/ct36x_priv.h
drivers/input/touchscreen/ct36x/ct36x_ts.c

index 38b6c7701a40c467b8ce8f8c968a03e178d2df71..2c0adf1cf8721daaf7318d46bd04f6cc713706cc 100755 (executable)
@@ -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[] = {
index f29d708ccdb9804f9579ffd589d699f2923a417a..3fd8a4eefbe405024413ce52ca2ceb815a7f8950 100644 (file)
@@ -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);
index 4f4cd8b951076250bed9241692494a27c9a04a73..539743435ff54af140ccc081275d01d54951a4ce 100644 (file)
 
 #include <mach/board.h>
 #include <mach/gpio.h>
-#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;
 
index 752370fbc51fe0679936e54dcec547f39395f7b0..8e48495b83f43e6de6f36c5fb793d408ab590e67 100644 (file)
@@ -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;