From 8d06500430e1130a353180117dba07555eeae103 Mon Sep 17 00:00:00 2001
From: hhb <hhb@rock-chips.com>
Date: Fri, 29 Jul 2011 10:58:24 +0800
Subject: [PATCH] rk29phonesdk:touch screen->modify gt818 driver to fit the new
 touch screen panel

---
 drivers/input/touchscreen/gt818_ts.c | 75 +++++++---------------------
 1 file changed, 19 insertions(+), 56 deletions(-)

diff --git a/drivers/input/touchscreen/gt818_ts.c b/drivers/input/touchscreen/gt818_ts.c
index b9e86f94c6d4..2313982e3c46 100644
--- a/drivers/input/touchscreen/gt818_ts.c
+++ b/drivers/input/touchscreen/gt818_ts.c
@@ -151,27 +151,7 @@ static int goodix_init_panel(struct gt818_ts_data *ts)
 {
 	int ret = -1;
 
-	#if 1
-	u8 config_info[] = {
-	0x06,0xA2,
-	0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,
-	0x10,0x12,0x00,0x00,0x10,0x00,0x20,0x00,
-	0x30,0x00,0x40,0x00,0x50,0x00,0x60,0x00,
-	0xE0,0x00,0xD0,0x00,0xC0,0x00,0xB0,0x00,
-	0xA0,0x00,0x90,0x00,0x80,0x00,0x70,0x00,
-	0x00,0x00,0x01,0x13,0x90,0x90,0x90,0x38,
-	0x38,0x38,0x0F,0x0E,0x0A,0x40   ,0x30,0x00,
-	0x3f,00,MAX_FINGER_NUM,0x00,0x14,0x00,0x1C,0x01,
-	0x01,0x3E,0x35,0x68,0x58,0x00,0x00,0x06,
-	0x19,0x05,0x00,0x00,0x00,0x00,0x00,0x00,
-	0x14,0x10,0x51,0x02,0x00,0x00,0x00,0x00,
-	0x00,0x00,0x20,0x40,0x60,0x90,0x08,0x40,
-	0x30,0x32,0x20,0x00,0x00,0x00,0x00,0x00,
-	0x00,0x01
-	};
-	#endif
-		
-	#if 0
+#if 1
 	u8 config_info[] = {
 	0x06,0xA2,
 	0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,
@@ -179,18 +159,18 @@ static int goodix_init_panel(struct gt818_ts_data *ts)
 	0x30,0x00,0x40,0x00,0x50,0x00,0x60,0x00,
 	0xE0,0x00,0xD0,0x00,0xC0,0x00,0xB0,0x00,
 	0xA0,0x00,0x90,0x00,0x80,0x00,0x70,0x00,
-	0x00,0x00,0x11,0x13,0x80,0x80,0x80,0x12,
-	0x12,0x12,0x0F,0x0F,0x0A,0x50,0x3C,0x49,
-	0x03,0x00,0x05,0x00,0x14,0xFA,0x1B,0x00,
-	0x00,0x4D,0x3D,0x81,0x65,0x00,0x00,0x06,
+	0xF0,0x00,0x13,0x13,0x90,0x90,0x90,0x27,
+	0x27,0x27,0x0F,0x0E,0x0A,0x40,0x30,0x01,
+	0x03,0x00,MAX_FINGER_NUM,0x00,0x14,0xFA,0x1B,0x00,
+	0x00,0x66,0x5A,0x6A,0x5E,0x00,0x00,0x05,
 	0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-	0x14,0x10,0xAB,0x02,0x00,0x00,0x00,0x00,
-	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,
-	0x00,0x3C,0x28,0x00,0x00,0x00,0x00,0x00,
+	0x14,0x10,0xEF,0x03,0x00,0x00,0x00,0x00,
+	0x00,0x00,0x20,0x40,0x70,0x90,0x0F,0x40,
+	0x30,0x3C,0x28,0x00,0x00,0x00,0x00,0x00,
 	0x00,0x01
+	};
+#endif
 
-	};								
-	#endif
 	ret = i2c_write_bytes(ts->client, config_info, (sizeof(config_info)/sizeof(config_info[0])));
 	if (ret < 0) 
 		return ret;
@@ -234,7 +214,6 @@ static void goodix_ts_work_func(struct work_struct *work)
 	u8 retry = 0;
 	unsigned int  count = 0;
 	unsigned int position = 0;	
-	int ret = -1;
 	int temp = 0;
 	int x = 0, y = 0 , pressure;
 
@@ -244,27 +223,10 @@ static void goodix_ts_work_func(struct work_struct *work)
 
 	struct gt818_ts_data *ts = container_of(work, struct gt818_ts_data, work);
 
-	ret = i2c_read_bytes(ts->client, touch_status, sizeof(touch_status)/sizeof(touch_status[0]));
+	i2c_pre_cmd(ts);
+	i2c_read_bytes(ts->client, touch_status, sizeof(touch_status)/sizeof(touch_status[0]));
+	i2c_end_cmd(ts);
 
-	if(ret <= 0) {
-		for(retry = 0; retry < 3; retry++)
-		{
-			ret = i2c_pre_cmd(ts);
-			if(ret <= 0)
-				continue;
-			else
-				break;
-		}
-		if(ret <= 0) {
-			dev_err(&(ts->client->dev),"I2C transfer error. Number:%d\n ", ret);
-			ts->bad_data = 1;
-			ts->retry++;
-			goto XFER_ERROR;
-		}
-		else{
-			i2c_read_bytes(ts->client, touch_status, sizeof(touch_status)/sizeof(touch_status[0]));
-		}
-	}
 	//judge whether the data is ready
 	if((touch_status[2] & 0x30) != 0x20)
 	{
@@ -471,13 +433,13 @@ static int goodix_ts_power(struct gt818_ts_data * ts, int on)
 			msleep(30);
 
 			ret = i2c_pre_cmd(ts);
-			if(ret >0){
+			if(ret > 0){
 				printk(KERN_INFO"**gt818 resume**\n");
 			}
 			else{
 				printk(KERN_INFO"**gt818 resume fail**\n");
 			}
-
+			i2c_end_cmd(ts);
 			return ret;
 				
 		default:
@@ -571,7 +533,8 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
 		goto err_init_godix_ts;
 	}
 	goodix_read_version(ts);
-//	i2c_end_cmd(ts);
+
+	i2c_end_cmd(ts);
 	INIT_WORK(&ts->work, goodix_ts_work_func);		//init work_struct
 	ts->input_dev = input_allocate_device();
 	if (ts->input_dev == NULL) {
@@ -663,7 +626,7 @@ err_gpio_request_failed:
 	ts->early_suspend.resume = goodix_ts_late_resume;
 	register_early_suspend(&ts->early_suspend);
 #endif
-	dev_info(&client->dev,"Start %s in %s mode\n", 
+	dev_info(&client->dev,"Start %s in %s mode\n",
 		ts->input_dev->name, ts->use_irq ? "interrupt" : "polling");
 
 	if (ts->use_irq)
@@ -679,7 +642,7 @@ err_gpio_request_failed:
 	return 0;
 
 err_init_godix_ts:
-//	i2c_end_cmd(ts);
+	i2c_end_cmd(ts);
 	if(ts->use_irq)
 	{
 		ts->use_irq = 0;
-- 
2.34.1