update ft5x0x touch driver to fit changes of linux3.0.
authorzwp <zwp@rock-chips.com>
Fri, 30 Dec 2011 02:04:56 +0000 (10:04 +0800)
committerzwp <zwp@rock-chips.com>
Fri, 30 Dec 2011 02:04:56 +0000 (10:04 +0800)
arch/arm/mach-rk29/board-rk29phonepadsdk.c
arch/arm/mach-rk29/include/mach/board.h
drivers/input/touchscreen/ft5x0x_i2c_ts.c
drivers/input/touchscreen/ft5x0x_i2c_ts.h

index d18302eb9fa4f2bb519fa3cc18180a9632b5b390..c13651b7fa42586cac99f72620c00e812f0a35f6 100755 (executable)
@@ -657,6 +657,7 @@ struct nas_platform_data nas_info = {
 #if defined (CONFIG_LAIBAO_TS)
 #define TOUCH_RESET_PIN RK29_PIN6_PC3
 #define TOUCH_INT_PIN   RK29_PIN0_PA2
+#define TOUCH_PWR_PIN  RK29_PIN2_PC3
 //TODO,shut down touch for power saving
 #define TOUCH_SHUTDOWN  RK29_PIN4_PD5
 void laibao_reset(void)
@@ -679,16 +680,26 @@ void laibao_hold(void)
  }
 void laibao_request_io(void)
 {
+    if(gpio_request(TOUCH_PWR_PIN,NULL) != 0){
+      gpio_free(TOUCH_PWR_PIN);
+      printk("laibao_request_io TOUCH_PWR_PIN error\n");
+      return ;
+    }
+    gpio_direction_output(TOUCH_PWR_PIN, 0);
+    gpio_set_value(TOUCH_PWR_PIN,GPIO_HIGH);
+
     if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
       gpio_free(TOUCH_RESET_PIN);
-      printk("laibao_request_io gpio_request error\n");
+      gpio_free(TOUCH_PWR_PIN);
+      printk("laibao_request_io TOUCH_RESET_PIN error\n");
       return ;
     }
 
     if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
       gpio_free(TOUCH_INT_PIN);
          gpio_free(TOUCH_RESET_PIN);
-      printk("laibao_request_io gpio_request error\n");
+      gpio_free(TOUCH_PWR_PIN);
+      printk("laibao_request_io TOUCH_INT_PIN error\n");
       return ;
     }
 }
@@ -698,28 +709,19 @@ int laibao_init_platform_hw(void)
        printk("enter %s()\n", __FUNCTION__);
        laibao_request_io();
        laibao_reset();
-       
-    if(gpio_request(RK29_PIN6_PD3,NULL) != 0){
-      gpio_free(RK29_PIN6_PD3);
-      printk("laibao_init_platform_hw gpio_request error\n");
-      return -EIO;
-    }
-       
-    gpio_direction_output(RK29_PIN6_PD3, 0);
-    gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
-
-
-       return 0;
+               
+       return 0;
 }
 
 
 struct laibao_platform_data laibao_info = {
   .model= 1003,
   .init_platform_hw= laibao_init_platform_hw,
-  .lcd_disp_on_pin = RK29_PIN6_PD0,
-  .disp_on_value = GPIO_HIGH,
-  .lcd_cs_pin = RK29_PIN6_PD1,
-  .lcd_cs_value = GPIO_HIGH,
+  .pwr_pin = TOUCH_PWR_PIN,
+  .pwr_on_value = GPIO_HIGH,
+  .reset_pin = TOUCH_RESET_PIN,
+  .reset_value=GPIO_HIGH,
+
 };
 #endif
 
index 5c85b1ac0c51bab254e0e0b3dc3cd947694b73ee..a64901ab3c0d0a287560900e022dc2fa8ee91205 100755 (executable)
@@ -324,10 +324,10 @@ struct laibao_platform_data {
     int     (*laibao_platform_sleep)(void);
     int     (*laibao_platform_wakeup)(void);
     void    (*exit_platform_hw)(void);
-    int     lcd_disp_on_pin;
-    int     disp_on_value;
-    int     lcd_cs_pin;
-    int     lcd_cs_value;
+    int     pwr_pin;
+       int             pwr_on_value;
+    int     reset_pin;
+       int             reset_value;
 };
 
 struct akm8975_platform_data {
index 8723ccf3a8891e5b4da1fd23151c8d061eee8eea..cd53fd48aaced0a8ef92c5f00b7214ecb8b76f1c 100755 (executable)
@@ -31,6 +31,7 @@
 #include <mach/gpio.h>
 #include <mach/board.h>
 #include <linux/earlysuspend.h>
+#include <linux/input/mt.h>
 
 struct FTS_TS_DATA_T {
        struct  i2c_client *client;
@@ -204,7 +205,7 @@ static void fts_ts_release(void)
 
                _st_finger_infos[i].u2_pressure = 0;
 
-               input_report_abs(data->input_dev, ABS_MT_POSITION_X, SCREEN_MAX_X - _st_finger_infos[i].i2_x);
+               input_report_abs(data->input_dev, ABS_MT_POSITION_X, _st_finger_infos[i].i2_x);
                input_report_abs(data->input_dev, ABS_MT_POSITION_Y, _st_finger_infos[i].i2_y);
                input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, _st_finger_infos[i].u2_pressure);
                input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, _st_finger_infos[i].ui2_id);
@@ -249,18 +250,32 @@ static int fts_i2c_rxdata(u8 *rxdata, int length)
        msg.flags = 0;
        msg.len = 1;
        msg.buf = rxdata;
+       msg.scl_rate = FT5X0X_I2C_SPEED;
+       
        ret = i2c_transfer(this_client->adapter, &msg, 1);
 
-       if (ret < 0)
+       if(ret == 0){
                pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
-
+               return -EBUSY;
+       }else if(ret < 0){
+               pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
+               return ret;
+       }
+       
        msg.addr = this_client->addr;
        msg.flags = I2C_M_RD;
        msg.len = length;
        msg.buf = rxdata;
+       msg.scl_rate = FT5X0X_I2C_SPEED;
        ret = i2c_transfer(this_client->adapter, &msg, 1);
-       if (ret < 0)
-               pr_err("msg %s line:%d i2c write error: %d\n", __func__,__LINE__, ret);
+       
+       if(ret == 0){
+               pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
+               return -EBUSY;
+       }else if(ret < 0){
+               pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
+               return ret;
+       }
 
        return ret;
 }
@@ -289,9 +304,17 @@ static int fts_i2c_txdata(u8 *txdata, int length)
        msg.flags = 0;
        msg.len = length;
        msg.buf = txdata;
+       msg.scl_rate = FT5X0X_I2C_SPEED;
+       
        ret = i2c_transfer(this_client->adapter, &msg, 1);
-       if (ret < 0)
-               pr_err("%s i2c write error: %d\n", __func__, ret);
+       
+       if(ret == 0){
+               pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
+               return -EBUSY;
+       }else if(ret < 0){
+               pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret);
+               return ret;
+       }
 
        return ret;
 }
@@ -346,7 +369,7 @@ int fts_read_data(void)
                                temp = temp<<8;
                                temp = temp | buf[3];
                                y=temp;
-                               
+                       #if 1   
                                {
                                        int swap;
                                
@@ -356,11 +379,11 @@ int fts_read_data(void)
                                        swap = x;
                                        x = y;
                                        y = swap;
-
-                                       //x = 1024 - x;////////////////////////////
+                                       
+                                       x = 1024 - x;////////////////////////////
                                        y = 600 - y;
                                }
-
+                       #endif
 
                                pressure = buf[4] & 0x3f; 
                                size = buf[5]&0xf0;
@@ -378,8 +401,8 @@ int fts_read_data(void)
                                                _st_finger_infos[id].i2_y= (int16_t)y;
                                                _st_finger_infos[id].ui2_id  = size;
                                                _si_touch_num ++;
-//                                             printk("\n--report x position  is  %d,pressure=%d----\n",_st_finger_infos[id].i2_x, pressure);
-//                                             printk("\n--report y position  is  %d,pressure=%d----\n",_st_finger_infos[id].i2_y, pressure);
+                                               printk("\n--report x position  is  %d,pressure=%d----\n",_st_finger_infos[id].i2_x, pressure);
+                                               printk("\n--report y position  is  %d,pressure=%d----\n",_st_finger_infos[id].i2_y, pressure);
                                        }  
 #if 0
 
@@ -452,11 +475,23 @@ int fts_read_data(void)
 
                                for( i= 0; i<CFG_MAX_POINT_NUM; ++i )
                                {
-                                       input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, _st_finger_infos[i].ui2_id);
-                                       input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, _st_finger_infos[i].u2_pressure);
-                                       input_report_abs(data->input_dev, ABS_MT_POSITION_X,  SCREEN_MAX_X - _st_finger_infos[i].i2_x);
-                                       input_report_abs(data->input_dev, ABS_MT_POSITION_Y,  _st_finger_infos[i].i2_y);
-                                       input_mt_sync(data->input_dev);
+                                       if(_st_finger_infos[i].u2_pressure == 1)//down
+                                       {
+                                               input_mt_slot(data->input_dev, i);
+                                               input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, true);                                      
+                                               input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 1);
+                                               input_report_abs(data->input_dev, ABS_MT_POSITION_X,  _st_finger_infos[i].i2_x);
+                                               input_report_abs(data->input_dev, ABS_MT_POSITION_Y,  _st_finger_infos[i].i2_y);
+                                       }
+                                       else if(_st_finger_infos[i].u2_pressure == 0)//up
+                                       {
+                                               input_mt_slot(data->input_dev, i);
+                                               input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, false);
+                                       }
+//                                     else
+//                                             printk("[%s]invalid pressure value %d\n",__FUNCTION__,_st_finger_infos[i].u2_pressure);
+
+                                       input_sync(data->input_dev);
 
                                        if(_st_finger_infos[i].u2_pressure == 0 )
                                        {
@@ -813,23 +848,22 @@ unsigned char fts_ctpm_get_upg_ver(void)
 
 void ft5x0x_ts_set_standby(struct i2c_client *client, int enable)
 {
-        struct laibao_platform_data *mach_info = client->dev.platform_data;
-       unsigned display_on = mach_info->lcd_disp_on_pin;
-       unsigned lcd_cs = mach_info->lcd_cs_pin;
-
-       int display_on_pol = mach_info->disp_on_value;
-       int lcd_cs_pol = mach_info->lcd_cs_value;
-
-        printk("%s : %s, enable = %d", __FILE__, __FUNCTION__,enable);
-    if(display_on != INVALID_GPIO)
+    struct laibao_platform_data *mach_info = client->dev.platform_data;
+       unsigned pwr_pin = mach_info->pwr_pin;
+       unsigned pwr_on_value = mach_info->pwr_on_value;
+       unsigned reset_pin = mach_info->reset_pin;
+       unsigned reset_value = mach_info->reset_value;
+
+    printk("%s : %s, enable = %d\n", __FILE__, __FUNCTION__,enable);
+    if(pwr_pin != INVALID_GPIO)
     {
-        gpio_direction_output(display_on, 0);
-        gpio_set_value(display_on, enable ? display_on_pol : !display_on_pol);                         
+        gpio_direction_output(pwr_pin, 0);
+        gpio_set_value(pwr_pin, enable ? pwr_on_value : !pwr_on_value);                                
     }
-    if(lcd_cs != INVALID_GPIO)
+    if(reset_pin != INVALID_GPIO)
     {
-               gpio_direction_output(lcd_cs, 0);
-               gpio_set_value(lcd_cs, enable ? lcd_cs_pol : !lcd_cs_pol);                        
+        gpio_direction_output(reset_pin, enable ? reset_value : !reset_value);
+        gpio_set_value(reset_pin, enable ? reset_value : !reset_value);                                
     }
 }
 
@@ -841,10 +875,11 @@ static void ft5x0x_ts_early_suspend(struct early_suspend *h)
 
     printk("enter ft5x0x_ts_early_suspend\n");
        
-       disable_irq_nosync(this_client->irq);
-
        cancel_work_sync(&data->pen_event_work);
        
+       disable_irq(this_client->irq);
+
+       
        ft5x0x_ts_set_standby(this_client,0);
        
        return;
@@ -855,20 +890,15 @@ static void ft5x0x_ts_late_resume(struct early_suspend *h)
 
        ft5x0x_ts_set_standby(this_client,1);
 
-    if(!work_pending(&data->pen_event_work)){
-               PREPARE_WORK(&data->pen_event_work, fts_work_func);
-       queue_work(data->ts_workqueue, &data->pen_event_work);
-    }
-       else
-               enable_irq(this_client->irq);
+       enable_irq(this_client->irq);
 
     printk("ft5x0x_ts_late_resume finish\n");
 
        return ;
 }
 #else
-#define egalax_i2c_suspend       NULL
-#define egalax_i2c_resume        NULL
+#define ft5x0x_ts_early_suspend       NULL
+#define ft5x0x_ts_late_resume        NULL
 #endif
 
 
@@ -980,21 +1010,29 @@ static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *i
        //set_bit(ABS_MT_POSITION_X, input_dev->absbit);
        //set_bit(ABS_MT_POSITION_Y, input_dev->absbit);
        //set_bit(ABS_MT_WIDTH_MAJOR, input_dev->absbit);
-       input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
+       
+//     input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
+
+       __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
+       __set_bit(EV_ABS, input_dev->evbit);
 
        /****** for multi-touch *******/
        for (i=0; i<CFG_MAX_POINT_NUM; i++)   
                _st_finger_infos[i].u2_pressure = -1;
 
        input_set_abs_params(input_dev,
-                       ABS_MT_POSITION_X, 0, SCREEN_MAX_X, 0, 0);
-       input_set_abs_params(input_dev,
-                       ABS_MT_POSITION_Y, 0, SCREEN_MAX_Y, 0, 0);
+                       ABS_MT_POSITION_X, 0, SCREEN_MAX_X + SCREEN_BOUNDARY_ADJUST_VALUE, 0, 0);
        input_set_abs_params(input_dev,
-                       ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
+                       ABS_MT_POSITION_Y, 0, SCREEN_MAX_Y + SCREEN_BOUNDARY_ADJUST_VALUE, 0, 0);
+//     input_set_abs_params(input_dev,
+//                     ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
        //input_set_abs_params(input_dev,
        //              ABS_MT_TRACKING_ID, 0, 30, 0, 0);
-       input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
+//     input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
+
+       input_mt_init_slots(input_dev, CFG_MAX_POINT_NUM);
+       input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
+       
        /*****setup key code area******/
        //set_bit(EV_SYN, input_dev->evbit);
        //set_bit(EV_KEY, input_dev->evbit);
index d61f7a88c2d8c48ec540be5e55ad3124beaca098..d15c8cf908d4251ae1bde4eb18fb055c4a92fb2b 100755 (executable)
@@ -4,6 +4,8 @@
 //#define CONFIG_SUPPORT_FTS_CTP_UPG
 #define CONFIG_FTS_CUSTOME_ENV
 
+#define FT5X0X_I2C_SPEED 100*1000
+
 #define CFG_DBG_DUMMY_INFO_SUPPORT   1     //output touch point information
 #define CFG_DBG_FUCTION_INFO_SUPPORT 0     //output fouction name
 #define CFG_DBG_INPUT_EVENT                   0     //debug input event
 #define CFG_NUMOFKEYS                    0x4    //number of touch keys
 
 #ifdef CONFIG_FTS_CUSTOME_ENV  
-#define SCREEN_MAX_X           1044//1024
-#define SCREEN_MAX_Y           620//600
+//µ±ÊÖÖ¸´Ó±ß½ç»®Æðʱ,»á³öÏÖÎÞÏìÓ¦µÄÇé¿ö,Òò´ËÌí¼ÓÒ»¸öºê½«±ß½ç×î´óÖµÏòÍâÀ­Éì
+#define SCREEN_BOUNDARY_ADJUST_VALUE 10 
+
+#define SCREEN_MAX_X           1024
+#define SCREEN_MAX_Y           600
 #else
 #define SCREEN_MAX_X           800
 #define SCREEN_MAX_Y           480