input: touchscreen: add touch screen of gslx680 for rk3399-firefly-edp
[firefly-linux-kernel-4.4.55.git] / drivers / input / touchscreen / sitronix_ts_a720.c
index 0b449a7721941f7d99e1d0a0bb8530c4f73c2e9b..37b4ffea345299d56d43124eb386a2c9fc4b1702 100755 (executable)
@@ -43,7 +43,7 @@
 #ifdef CONFIG_RK_CONFIG
 
 enum {
-#ifdef RK2926_SDK_DEFAULT_CONFIG
+#if defined(RK2926_SDK_DEFAULT_CONFIG)
         DEF_EN = 1,
 #else
         DEF_EN = 0,
@@ -170,6 +170,7 @@ struct sitronix_ts_data {
        uint8_t touch_protocol_type;
        uint8_t pixel_length;
        int suspend_state;
+        int irq;
 };
 
 static unsigned char initkey_code[] =
@@ -303,7 +304,7 @@ long         sitronix_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                        UpgradeMsg("IOCTL_SMT_ENABLE_IRQ\n");
                        if(!sitronix_ts_irq_on){
                                sitronix_ts_irq_on = 1;
-                               enable_irq(sitronix_ts_gpts->client->irq);
+                               enable_irq(sitronix_ts_gpts->irq);
 #ifdef SITRONIX_MONITOR_THREAD
                                atomic_set(&iMonitorThreadPostpone,1);
                                SitronixMonitorThread = kthread_run(sitronix_ts_monitor_thread,"Sitronix","Monitorthread");
@@ -316,7 +317,7 @@ long         sitronix_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                        UpgradeMsg("IOCTL_SMT_DISABLE_IRQ\n");
                        if(sitronix_ts_irq_on){
                                sitronix_ts_irq_on = 0;
-                               disable_irq_nosync(sitronix_ts_gpts->client->irq);
+                               disable_irq_nosync(sitronix_ts_gpts->irq);
 #ifdef SITRONIX_MONITOR_THREAD
                                if(SitronixMonitorThread){
                                        kthread_stop(SitronixMonitorThread);
@@ -753,6 +754,8 @@ static void sitronix_ts_work_func(struct work_struct *work)
        uint8_t PixelCount = 0;
        static uint8_t all_clear = 1;
 
+      struct ft5x0x_platform_data *pdata=ts->client->dev.platform_data;
+
        DbgMsg("%s\n",  __FUNCTION__);
        if(ts->suspend_state){
                goto exit_invalid_data;
@@ -823,8 +826,24 @@ static void sitronix_ts_work_func(struct work_struct *work)
                                input_mt_slot(ts->input_dev, i);
                                input_report_abs(ts->input_dev,  ABS_MT_TRACKING_ID, i);
                                input_report_abs(ts->input_dev,  ABS_MT_TOUCH_MAJOR, 200);
-                               input_report_abs(ts->input_dev,  ABS_MT_POSITION_X, MTDStructure[i].Pixel_X);
-                               input_report_abs(ts->input_dev,  ABS_MT_POSITION_Y, MTDStructure[i].Pixel_Y);
+
+                               #ifdef CONFIG_RK_CONFIG
+                                input_report_abs(ts->input_dev,  ABS_MT_POSITION_X, MTDStructure[i].Pixel_X);
+                               input_report_abs(ts->input_dev,  ABS_MT_POSITION_Y, MTDStructure[i].Pixel_Y);
+                               #else
+                               if( pdata && (pdata->direction_otation) )
+                               {
+                                     int temp_x , temp_y ;
+                                     temp_x = MTDStructure[i].Pixel_X ;
+                                     temp_y = MTDStructure[i].Pixel_Y ;
+                                     pdata->direction_otation(&temp_x,&temp_y);
+                                input_report_abs(ts->input_dev,  ABS_MT_POSITION_X, temp_x);
+                                     input_report_abs(ts->input_dev,  ABS_MT_POSITION_Y, temp_y);
+                               }else{
+                                       input_report_abs(ts->input_dev,  ABS_MT_POSITION_X, MTDStructure[i].Pixel_X);
+                                       input_report_abs(ts->input_dev,  ABS_MT_POSITION_Y, MTDStructure[i].Pixel_Y);
+                               }
+                               #endif
                                input_report_abs(ts->input_dev,  ABS_MT_WIDTH_MAJOR, 100);
                                DbgMsg("lr[%d](%d, %d)+\n", i, MTDStructure[i].Pixel_X, MTDStructure[i].Pixel_Y);
                        }else if(MTDStructure[i].Current_Pressed_area == AREA_NONE){
@@ -862,7 +881,7 @@ static void sitronix_ts_work_func(struct work_struct *work)
 #ifdef SITRONIX_INT_POLLING_MODE
                if (ts->use_irq){
                        sitronix_ts_irq_on = 1;
-                       enable_irq(ts->client->irq);
+                       enable_irq(ts->irq);
                }
 #endif // SITRONIX_INT_POLLING_MODE
        }
@@ -872,7 +891,7 @@ exit_invalid_data:
 #if defined(SITRONIX_LEVEL_TRIGGERED)
        if (ts->use_irq){
                sitronix_ts_irq_on = 1;
-               enable_irq(ts->client->irq);
+               enable_irq(ts->irq);
        }
 #endif // defined(SITRONIX_LEVEL_TRIGGERED)
        if ((2 <= i2cErrorCount)){
@@ -895,7 +914,7 @@ static irqreturn_t sitronix_ts_irq_handler(int irq, void *dev_id)
 //     printk("lr:%s\n", __FUNCTION__);
 #if defined(SITRONIX_LEVEL_TRIGGERED) || defined(SITRONIX_INT_POLLING_MODE)
        sitronix_ts_irq_on = 0;
-       disable_irq_nosync(ts->client->irq);
+       disable_irq_nosync(ts->irq);
 #endif // defined(SITRONIX_LEVEL_TRIGGERED) || defined(SITRONIX_INT_POLLING_MODE)
 #ifdef SITRONIX_MONITOR_THREAD
        atomic_set(&iMonitorThreadPostpone,1);
@@ -925,6 +944,7 @@ static int sitronix_ts_probe(struct i2c_client *client, const struct i2c_device_
         client->irq = irq_cfg.gpio;
         tp_hw_init();
 #else
+       pdata = client->dev.platform_data;
        if(pdata->init_platform_hw)
                pdata->init_platform_hw();
 #endif
@@ -945,8 +965,9 @@ static int sitronix_ts_probe(struct i2c_client *client, const struct i2c_device_
        INIT_DELAYED_WORK(&ts->work, sitronix_ts_work_func);
 #endif // SITRONIX_INT_POLLING_MODE
        ts->client = client;
+        if(client->irq != INVALID_GPIO)
+                ts->irq = gpio_to_irq(client->irq);
        i2c_set_clientdata(client, ts);
-       pdata = client->dev.platform_data;
 #if 0
        if(pdata->reset_ic){
                ts->reset_ic = pdata->reset_ic;
@@ -1046,7 +1067,7 @@ static int sitronix_ts_probe(struct i2c_client *client, const struct i2c_device_
        ts->max_touches = 5;
 
        input_mt_init_slots(ts->input_dev, ts->max_touches);
-#ifdef CONFIG_RK_COFNIG
+#ifdef CONFIG_RK_CONFIG
        input_set_abs_params(ts->input_dev,ABS_MT_POSITION_X, 0, x_max, 0, 0);
        input_set_abs_params(ts->input_dev,ABS_MT_POSITION_Y, 0, y_max, 0, 0);
 #else
@@ -1066,14 +1087,14 @@ static int sitronix_ts_probe(struct i2c_client *client, const struct i2c_device_
        }
 
        ts->suspend_state = 0;
-       if (client->irq){
+       if (ts->irq){
         #ifdef CONFIG_RK_CONFIG
-               ret = request_irq(client->irq, sitronix_ts_irq_handler,  irq_cfg.irq.irq_flags | IRQF_DISABLED, client->name, ts);
+               ret = request_irq(ts->irq, sitronix_ts_irq_handler,  irq_cfg.irq.irq_flags | IRQF_DISABLED, client->name, ts);
         #else
                 #ifdef SITRONIX_LEVEL_TRIGGERED
-               ret = request_irq(client->irq, sitronix_ts_irq_handler, IRQF_TRIGGER_LOW | IRQF_DISABLED, client->name, ts);
+               ret = request_irq(ts->irq, sitronix_ts_irq_handler, IRQF_TRIGGER_LOW | IRQF_DISABLED, client->name, ts);
                 #else
-               ret = request_irq(client->irq, sitronix_ts_irq_handler, IRQF_TRIGGER_FALLING | IRQF_DISABLED, client->name, ts);
+               ret = request_irq(ts->irq, sitronix_ts_irq_handler, IRQF_TRIGGER_FALLING | IRQF_DISABLED, client->name, ts);
                 #endif // SITRONIX_LEVEL_TRIGGERED
         #endif // CONFIG_RK_CONFIG
                if (ret == 0){
@@ -1128,7 +1149,7 @@ static int sitronix_ts_remove(struct i2c_client *client)
        }
 #endif // SITRONIX_MONITOR_THREAD
        if (ts->use_irq)
-               free_irq(client->irq, ts);
+               free_irq(ts->irq, ts);
        else
                hrtimer_cancel(&ts->timer);
        input_unregister_device(ts->input_dev);
@@ -1154,13 +1175,13 @@ static int sitronix_ts_suspend(struct i2c_client *client, pm_message_t mesg)
 #endif // SITRONIX_MONITOR_THREAD
        if(ts->use_irq){
                sitronix_ts_irq_on = 0;
-               disable_irq_nosync(ts->client->irq);
+               disable_irq_nosync(ts->irq);
        }
        ts->suspend_state = 1;
 
        ret = sitronix_ts_set_powerdown_bit(ts, 1);
 #ifdef SITRONIX_WAKE_UP_TOUCH_BY_INT
-       gpio_direction_output(irq_to_gpio(client->irq), 1);
+       gpio_direction_output(client->irq, 1);
 #endif // SITRONIX_WAKE_UP_TOUCH_BY_INT
        DbgMsg("%s return\n", __FUNCTION__);
 
@@ -1186,7 +1207,7 @@ static int sitronix_ts_resume(struct i2c_client *client)
        DbgMsg("%s\n", __FUNCTION__);
 
 #ifdef SITRONIX_WAKE_UP_TOUCH_BY_INT
-       gpio = irq_to_gpio(client->irq);
+       gpio = client->irq;
        gpio_set_value(gpio, 0);
        gpio_direction_input(gpio);
 #else
@@ -1196,7 +1217,7 @@ static int sitronix_ts_resume(struct i2c_client *client)
        ts->suspend_state = 0;
        if(ts->use_irq){
                sitronix_ts_irq_on = 1;
-               enable_irq(ts->client->irq);
+               enable_irq(ts->irq);
        }
 #ifdef SITRONIX_MONITOR_THREAD
        atomic_set(&iMonitorThreadPostpone,1);
@@ -1252,7 +1273,7 @@ static struct file_operations nc_fops = {
 };
 #endif // SITRONIX_FW_UPGRADE_FEATURE
 
-static int __devinit sitronix_ts_init(void)
+static int __init sitronix_ts_init(void)
 {
 #ifdef SITRONIX_FW_UPGRADE_FEATURE
        int result;