gt818_ts driver : change regist and report func to adapt android 4.0
author张昊 <zhanghao@rock-chips.com>
Sat, 19 Nov 2011 08:26:06 +0000 (16:26 +0800)
committer张昊 <zhanghao@rock-chips.com>
Sat, 19 Nov 2011 08:26:06 +0000 (16:26 +0800)
drivers/input/touchscreen/gt818_ts.c

index 5fc376435d6801b88f00e489c89cd423a9477af2..4a447f7d4750a1a6d88851134b4d8ce2ac4ef997 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/string.h>\r
 #include <linux/completion.h>\r
 #include <asm/uaccess.h>\r
+#include <linux/input/mt.h>\r
 \r
 #include "gt818_ts.h"\r
 \r
@@ -76,6 +77,9 @@ static void goodix_ts_late_resume(struct early_suspend *h);
        #define MAX_KEY_NUM      (sizeof(gt818_key_array)/sizeof(gt818_key_array[0]))\r
 #endif\r
 \r
+unsigned int last_x[MAX_FINGER_NUM + 1]= {0};\r
+unsigned int last_y[MAX_FINGER_NUM + 1]= {0};\r
+\r
 \r
 /*Function as i2c_master_send */\r
 static int i2c_read_bytes(struct i2c_client *client, u8 *buf, int len)\r
@@ -303,19 +307,23 @@ static void goodix_ts_work_func(struct work_struct *work)
 \r
        for(position = 1; position < MAX_FINGER_NUM + 1; position++)\r
        {\r
-               //printk("%s:positon:%d\n", __func__, position);\r
                if((finger_current[position] == 0) && (finger_last[position] != 0))\r
                {\r
-                       input_report_abs(ts->input_dev, ABS_MT_POSITION_X, 0);\r
-                       input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, 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
+                       //printk("<<<<<<<<<<<<<<<<<<<%s:positon:%d (%d,%d)\n", __func__, position,last_x,last_y);\r
+                       //printk("<<<%d , %d ",finger_current[position],finger_last[position]);\r
+                       //input_mt_slot(ts->input_dev, position);\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_POSITION_X, last_x[position]);\r
+                       //input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, last_y[position]);\r
+                       //input_report_abs(ts->input_dev, ABS_MT_PRESSURE, 100);\r
+                       //input_mt_sync(ts->input_dev);\r
+                       input_mt_slot(ts->input_dev, position);\r
+                       input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false);\r
                        syn_flag = 1;\r
                }\r
                else if(finger_current[position])\r
                {\r
-\r
                        x = (*(coor_point+3*(position-1)))*SCREEN_MAX_WIDTH/(TOUCH_MAX_WIDTH);\r
                        y = (*(coor_point+3*(position-1)+1))*SCREEN_MAX_HEIGHT/(TOUCH_MAX_HEIGHT);\r
                        pressure = (*(coor_point+3*(position-1)+2));\r
@@ -326,14 +334,23 @@ static void goodix_ts_work_func(struct work_struct *work)
                        if(y < SCREEN_MAX_HEIGHT){\r
                        //      y = SCREEN_MAX_HEIGHT-y;\r
                        }\r
-                       input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, position - 1);\r
+\r
+                       //printk(">>>>>>>>>>>>>>>>>%s:positon:%d (%d,%d)\n", __func__, position,x,y);\r
+                       input_mt_slot(ts->input_dev, position);\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, pressure);\r
                        input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x);\r
                        input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y);\r
-                       input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, pressure);\r
-                       input_mt_sync(ts->input_dev);\r
+\r
+                       last_x[position] = x;\r
+                       last_y[position] = y;\r
+                       //input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, pressure);\r
+                       //input_mt_sync(ts->input_dev);\r
                        syn_flag = 1;\r
                }\r
+\r
+               input_sync(ts->input_dev);\r
        }\r
 \r
 \r
@@ -488,7 +505,7 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
        struct gt818_ts_data *ts;\r
 \r
        struct gt818_platform_data *pdata;\r
-       dev_dbg(&client->dev,"Install touch driver.\n");\r
+       dev_info(&client->dev,"Install touch driver.\n");\r
        printk("gt818: Install touch driver.\n");\r
        //Check I2C function\r
        if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) \r
@@ -576,10 +593,10 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
                goto err_input_dev_alloc_failed;\r
        }\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_MASK(ABS_MT_POSITION_X) | BIT_MASK(ABS_MT_POSITION_Y) |\r
-                       BIT_MASK(ABS_MT_TOUCH_MAJOR) | BIT_MASK(ABS_MT_WIDTH_MAJOR);  // for android\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_MASK(ABS_MT_POSITION_X) | BIT_MASK(ABS_MT_POSITION_Y) |\r
+       //              BIT_MASK(ABS_MT_TOUCH_MAJOR) | BIT_MASK(ABS_MT_WIDTH_MAJOR);  // for android\r
 \r
 \r
 #ifdef HAVE_TOUCH_KEY\r
@@ -600,13 +617,16 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
        ts->input_dev->id.product = 0xBEEF;\r
        ts->input_dev->id.version = 10427;      //screen firmware version\r
 \r
+       __set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit);\r
+       __set_bit(EV_ABS, ts->input_dev->evbit);\r
 #ifdef GOODIX_MULTI_TOUCH\r
-\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_FINGER_NUM);\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, SCREEN_MAX_WIDTH, 0, 0);\r
        input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, SCREEN_MAX_HEIGHT, 0, 0);\r
-       input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, MAX_FINGER_NUM, 0, 0);\r
+       //input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, MAX_FINGER_NUM, 0, 0);\r
+       input_set_abs_params(ts->input_dev, ABS_MT_PRESSURE, 0, 255, 0, 0);\r
 #else\r
        input_set_abs_params(ts->input_dev, ABS_X, 0, SCREEN_MAX_HEIGHT, 0, 0);\r
        input_set_abs_params(ts->input_dev, ABS_Y, 0, SCREEN_MAX_WIDTH, 0, 0);\r
@@ -619,7 +639,7 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
                goto err_input_register_device_failed;\r
        }\r
        ts->bad_data = 0;\r
-//     finger_list.length = 0;\r
+//     16finger_list.length = 0;\r
 \r
        client->irq = gpio_to_irq(pdata->gpio_pendown);         //If not defined in client\r
        if (client->irq)\r