support for goodix touch v1.0
authoryxj <yxj@yxj-desktop.(none)>
Fri, 18 Nov 2011 11:01:04 +0000 (19:01 +0800)
committeryxj <yxj@yxj-desktop.(none)>
Fri, 18 Nov 2011 11:01:04 +0000 (19:01 +0800)
arch/arm/mach-rk29/board-rk29k97-key.c
drivers/input/touchscreen/rk29_i2c_goodix.c
drivers/input/touchscreen/rk29_i2c_goodix.h

index aa92c486f5b092ad4fff0abac2a0bc80c162e5a0..51c7c5722f6795f8ea7b5a2bf4d1e9e2c8934626 100755 (executable)
@@ -12,7 +12,7 @@ static struct rk29_keys_button key_button[] = {
        {
                .desc   = "menu",
                .code   = EV_MENU,
-               .gpio   = RK29_PIN6_PA0,
+               .gpio   = RK29_PIN6_PA4,
                .active_low = PRESS_LEV_LOW,
        },
        {
@@ -33,16 +33,10 @@ static struct rk29_keys_button key_button[] = {
                .gpio   = RK29_PIN6_PA3,
                .active_low = PRESS_LEV_LOW,
        },
-       {
-               .desc   = "search",
-               .code   = KEY_SEARCH,
-               .gpio   = RK29_PIN6_PA4,
-               .active_low = PRESS_LEV_LOW,
-       },
        {
                .desc   = "esc",
                .code   = KEY_BACK,
-               .gpio   = RK29_PIN6_PA5,
+               .gpio   = RK29_PIN6_PA0,
                .active_low = PRESS_LEV_LOW,
        },
        {
index 7d9a27f6d566a88a344fd5e7c4ac05721ee82648..329178ca605e10e4b264ed8230c447ac94e8cea6 100755 (executable)
@@ -22,6 +22,8 @@
 #include <linux/hrtimer.h>\r
 #include <linux/i2c.h>\r
 #include <linux/input.h>\r
+#include <linux/input/mt.h>\r
+\r
 #include <linux/interrupt.h>\r
 #include <linux/io.h>\r
 #include <linux/platform_device.h>\r
@@ -45,6 +47,8 @@
 \r
 #define PEN_DOWN 1\r
 #define PEN_RELEASE 0\r
+#define MAX_SUPPORT_POINT 2\r
+#define fjp_debug 1\r
 \r
 //#define fjp_debug\r
 /*******************************************************       \r
@@ -266,6 +270,9 @@ static int  goodix_read_version(struct goodix_ts_data *ts, char **version)
        else \r
                return 1;       \r
 }\r
+unsigned int last_x = 0;\r
+unsigned int last_y = 0;\r
+\r
 \r
 /*******************************************************\r
 Description:\r
@@ -277,7 +284,7 @@ Parameter:
 return:\r
        Executive outcomes.0---succeed.\r
 *******************************************************/\r
-static void goodix_ts_work_func(struct work_struct *work)\r
+static void goodix_ts_work_func(struct work_struct *pwork)\r
 {      \r
        int ret=-1;\r
        int tmp = 0;\r
@@ -291,14 +298,14 @@ static void goodix_ts_work_func(struct work_struct *work)
        unsigned int input_x = 0;\r
        unsigned int input_y = 0;\r
        unsigned int input_w = 0;\r
-       unsigned char index = 0;\r
+       unsigned int index = 0;\r
        unsigned char touch_num = 0;\r
-       uint8_t current_num =0;\r
-  uint8_t chksum_err = 0;\r
+       uint8_t chksum_err = 0;\r
+       \r
 \r
 \r
-       unsigned int i;\r
-       struct goodix_ts_data *ts = container_of(work, struct goodix_ts_data, work);\r
+       \r
+       struct goodix_ts_data *ts = container_of(pwork, struct goodix_ts_data, work);\r
 \r
        //printk("enter the goodix_ts_timer_func!\n");\r
 //     if(g_enter_isp)return;\r
@@ -447,19 +454,26 @@ read_one_more_time:
                        position = 4 - READ_COOR_ADDR + 5*index;\r
                        input_x = (unsigned int) (point_data[position]<<8) + (unsigned int)( point_data[position+1]);\r
                        input_y = (unsigned int)(point_data[position+2]<<8) + (unsigned int) (point_data[position+3]);\r
-                       input_w =(unsigned int) (point_data[position+4]);               \r
-\r
-                       if((input_x > ts->abs_x_max)||(input_y > ts->abs_y_max))continue;\r
-                       \r
-                       input_report_abs(ts->input_dev, ABS_MT_POSITION_X, (input_x));\r
+                       input_w =(unsigned int) (point_data[position+4]);       \r
+                       #ifdef fjp_debug\r
+                       printk("input_x = %d,input_y = %d,input_w=%d, index = %d,touch number:%d\n", (input_x), input_y, input_w,index,touch_num);//add by fjp 2010-9-28\r
+                       #endif\r
+                       last_x = input_x;\r
+                       last_y = input_y;\r
+                       if((input_x > ts->abs_x_max)||(input_y > ts->abs_y_max))\r
+                               continue;\r
+\r
+                       input_mt_slot(ts->input_dev, 0);\r
+                       input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true);\r
+                       input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 1);\r
+                       //input_report_abs(ts->input_dev, ABS_MT_PRESSURE, 100);\r
+                       input_report_abs(ts->input_dev, ABS_MT_POSITION_X, input_x);\r
                        input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, input_y);                    \r
-                       input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, input_w);\r
-                       input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, input_w);\r
-                       input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, track_id[index]);\r
-                       input_mt_sync(ts->input_dev);\r
-               #ifdef fjp_debug\r
-               printk("input_x = %d,input_y = %d,input_w=%d, index = %d\n", (input_x), input_y, input_w,track_id[index]);//add by fjp 2010-9-28\r
-               #endif\r
+                       \r
+                       //input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, input_w);\r
+                       //input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, track_id[index]);\r
+                       //input_mt_sync(ts->input_dev);\r
+               \r
                \r
                }\r
                 ts->pendown =PEN_DOWN;\r
@@ -509,14 +523,29 @@ XFER_ERROR:
       {\r
            if((ts->pendown))\r
            {\r
+                       #if 0\r
                input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0);\r
                input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0);\r
                input_mt_sync(ts->input_dev);\r
                input_sync(ts->input_dev);\r
-               ts->pendown =PEN_RELEASE;\r
                #ifdef fjp_debug\r
                printk("touch finish finsih\n");//add by fjp 2010-9-28\r
                #endif  \r
+                        #else\r
+                               input_mt_slot(ts->input_dev, 0);\r
+                               input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true);\r
+                               input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0);\r
+                               //input_report_abs(ts->input_dev, ABS_MT_PRESSURE, 100);\r
+                               input_report_abs(ts->input_dev, ABS_MT_POSITION_X, last_x);\r
+                               input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, last_y);\r
+                               input_mt_slot(ts->input_dev, 0);\r
+                               input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false);\r
+                               input_sync(ts->input_dev);\r
+                               ts->pendown =PEN_RELEASE;\r
+                               #ifdef fjp_debug\r
+                               printk("touch up>>x:%d>>y:%d\n",last_x,last_y);//add by fjp 2010-9-28\r
+                       #endif  \r
+                        #endif\r
            }\r
            if(ts->use_irq)\r
                enable_irq(ts->client->irq);\r
@@ -539,7 +568,8 @@ return:
 static enum hrtimer_restart goodix_ts_timer_func(struct hrtimer *timer)\r
 {\r
        struct goodix_ts_data *ts = container_of(timer, struct goodix_ts_data, timer);\r
-       queue_work(goodix_wq, &ts->work);\r
+       //queue_work(goodix_wq, &ts->work);\r
+       queue_delayed_work(goodix_wq,&ts->work,0);\r
        hrtimer_start(&ts->timer, ktime_set(0, (POLL_TIME+6)*1000000), HRTIMER_MODE_REL);\r
        return HRTIMER_NORESTART;\r
 }\r
@@ -860,11 +890,7 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
        struct goodix_ts_data *ts;\r
        char *version_info = NULL;\r
        char test_data = 1;\r
-       const char irq_table[4] = {IRQ_TYPE_EDGE_RISING,\r
-                                                          IRQ_TYPE_LEVEL_LOW,\r
-                                                          IRQ_TYPE_EDGE_FALLING,\r
-                                                          IRQ_TYPE_LEVEL_HIGH};\r
-\r
+       \r
        struct goodix_platform_data *pdata = pdata = client->dev.platform_data;\r
        dev_dbg(&client->dev,"Install touch driver.\n");\r
 \r
@@ -929,9 +955,12 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
        }\r
 \r
 #endif\r
-       ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ;\r
-       ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);\r
-       ts->input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);                                                 // absolute coor (x,y)\r
+       __set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit);\r
+       __set_bit(EV_ABS, ts->input_dev->evbit);\r
+\r
+       //ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ;\r
+       //ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);\r
+       //ts->input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);                                               // absolute coor (x,y)\r
 #if 0\r
 #ifdef HAVE_TOUCH_KEY\r
        for(retry = 0; retry < MAX_KEY_NUM; retry++)\r
@@ -941,16 +970,18 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
 #endif\r
 #endif\r
 \r
-       input_set_abs_params(ts->input_dev, ABS_X, 0, ts->abs_x_max, 0, 0);\r
-       input_set_abs_params(ts->input_dev, ABS_Y, 0, ts->abs_y_max, 0, 0);\r
-       input_set_abs_params(ts->input_dev, ABS_PRESSURE, 0, 255, 0, 0);\r
+       //input_set_abs_params(ts->input_dev, ABS_X, 0, ts->abs_x_max, 0, 0);\r
+       //input_set_abs_params(ts->input_dev, ABS_Y, 0, ts->abs_y_max, 0, 0);\r
+       //input_set_abs_params(ts->input_dev, ABS_PRESSURE, 0, 255, 0, 0);\r
 \r
 #ifdef GOODIX_MULTI_TOUCH\r
-       input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);\r
+       input_mt_init_slots(ts->input_dev, MAX_SUPPORT_POINT);\r
+       //input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);\r
        input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);\r
        input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, ts->abs_x_max, 0, 0);\r
        input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, ts->abs_y_max, 0, 0);\r
-       input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, ts->max_touch_num, 0, 0);\r
+       //input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, ts->max_touch_num, 0, 0);\r
+       //input_set_abs_params(ts->input_dev, ABS_MT_PRESSURE, 0, 255, 0, 0);\r
 #endif \r
 \r
        sprintf(ts->phys, "input/ts");\r
index bcfa48481e333ec53f32fdae58b8c428a5c3b544..a5d13f8766233bffaff8b9e723c48dc04588cce7 100755 (executable)
@@ -88,7 +88,7 @@ static const char *goodix_ts_name = "Goodix Capacitive TouchScreen";
 static struct workqueue_struct *goodix_wq;
 struct i2c_client * i2c_connect_client = NULL; 
 static struct proc_dir_entry *goodix_proc_entry;
-static struct kobject *goodix_debug_kobj;
+//static struct kobject *goodix_debug_kobj;
        
 #ifdef CONFIG_HAS_EARLYSUSPEND
 static void goodix_ts_early_suspend(struct early_suspend *h);