-/* \r
- * drivers/input/touchscreen/ft5x0x_ts.c\r
- *\r
- * FocalTech ft5x0x TouchScreen driver. \r
- *\r
- * Copyright (c) 2010 Focal tech Ltd.\r
- *\r
- * This software is licensed under the terms of the GNU General Public\r
- * License version 2, as published by the Free Software Foundation, and\r
- * may be copied, distributed, and modified under those terms.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- *\r
- * note: only support mulititouch Wenfs 2010-10-01\r
- */\r
-\r
-#include <linux/input.h>\r
-#include <linux/module.h>\r
-#include <linux/init.h>\r
-#include <linux/interrupt.h>\r
-#include <linux/kernel.h>\r
-#include <linux/platform_device.h>\r
-#include <linux/spi/spi.h>\r
-#include <linux/slab.h>\r
-#include <linux/fcntl.h>\r
-#include <linux/delay.h>\r
-#include <linux/device.h>\r
-#include <linux/timer.h>\r
-#include <linux/jiffies.h>\r
-#include <linux/miscdevice.h>\r
-#include <linux/types.h>\r
-#include <linux/io.h>\r
-#include <linux/delay.h>\r
-#include <linux/ioport.h>\r
-#include <linux/input-polldev.h>\r
-#include <linux/i2c.h>\r
-#include <linux/workqueue.h>\r
-#ifdef CONFIG_ANDROID_POWER\r
-#include <linux/android_power.h>\r
-#endif\r
-#include <mach/hardware.h>\r
-#include <asm/setup.h>\r
-#include <asm/mach-types.h>\r
-#include <asm/mach/arch.h>\r
-#include <asm/mach/map.h>\r
-#include <asm/mach/flash.h>\r
-#include <asm/hardware/gic.h>\r
-#include <mach/iomux.h>\r
-#include <mach/gpio.h>\r
-#include <mach/irqs.h>\r
-//#include <mach/rk29_iomap.h>\r
-#include <mach/board.h>\r
-//#include <mach/rk29_nand.h>\r
-//#include <mach/rk29_camera.h> /* ddl@rock-chips.com : camera support */\r
-#include <media/soc_camera.h> /* ddl@rock-chips.com : camera support */\r
-//#include <mach/vpu_mem.h>\r
-#include <mach/sram.h>\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
-#include <linux/earlysuspend.h>\r
-#endif\r
-#include <linux/input/mt.h>\r
-\r
-\r
-#if 0\r
-#define FTprintk(x...) printk(x)\r
-#else\r
-#define FTprintk(x...) do{} while(0)\r
-#endif\r
-\r
-#define CONFIG_FT5X0X_MULTITOUCH 1\r
-#define MAX_POINT 5\r
-#define FT5306_IIC_SPEED 400*1000 //300*1000\r
-#define TOUCH_RESET_PIN RK30_PIN1_PC0\r
-#define FT5X0X_REG_THRES 0x80 /* Thresshold, the threshold be low, the sensitivy will be high */\r
-#define FT5X0X_REG_REPORT_RATE 0x88 /* **************report rate, in unit of 10Hz **************/\r
-#define FT5X0X_REG_PMODE 0xA5 /* Power Consume Mode 0 -- active, 1 -- monitor, 3 -- sleep */ \r
-#define FT5X0X_REG_FIRMID 0xA6 /* ***************firmware version **********************/\r
-#define FT5X0X_REG_NOISE_MODE 0xb2 /* to enable or disable power noise, 1 -- enable, 0 -- disable */\r
-#define SCREEN_MAX_X 1024\r
-#define SCREEN_MAX_Y 600\r
-#define PRESS_MAX 255\r
-#define FT5X0X_NAME "ft5x0x_ts"//"synaptics_i2c_rmi"//"synaptics-rmi-ts"// \r
-#define TOUCH_MAJOR_MAX 200\r
-#define WIDTH_MAJOR_MAX 200\r
-//FT5X0X_REG_PMODE\r
-#define PMODE_ACTIVE 0x00\r
-#define PMODE_MONITOR 0x01\r
-#define PMODE_STANDBY 0x02\r
-#define PMODE_HIBERNATE 0x03\r
-\r
-\r
-struct ts_event {\r
- u16 x1;\r
- u16 y1;\r
- u16 x2;\r
- u16 y2;\r
- u16 x3;\r
- u16 y3;\r
- u16 x4;\r
- u16 y4;\r
- u16 x5;\r
- u16 y5;\r
- u16 pressure;\r
- s16 touch_ID1;\r
- s16 touch_ID2;\r
- s16 touch_ID3;\r
- s16 touch_ID4;\r
- s16 touch_ID5;\r
- u8 touch_point;\r
- u8 status;\r
-};\r
-\r
-struct tp_event {\r
- u16 x;\r
- u16 y;\r
- s16 id;\r
- u16 pressure;\r
- u8 touch_point;\r
- u8 flag;\r
-};\r
-\r
-struct ft5x0x_ts_data {\r
- struct i2c_client *client;\r
- struct input_dev *input_dev;\r
- int irq;\r
- int (*platform_sleep)(void);\r
- int (*platform_wakeup)(void);\r
- struct ts_event event;\r
- struct work_struct pen_event_work;\r
- struct workqueue_struct *ts_workqueue;\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
- struct early_suspend ft5306_early_suspend;\r
-#endif\r
-};\r
-static struct i2c_client *this_client;\r
-\r
-/***********************************************************************/\r
-\r
-#define FTS_PACKET_LENGTH 128\r
-\r
-\r
-static u8 CTPM_FW[]=\r
-{\r
-#include "7022620120726B.txt"\r
-};\r
-\r
-typedef enum\r
-{\r
- ERR_OK,\r
- ERR_MODE,\r
- ERR_READID,\r
- ERR_ERASE,\r
- ERR_STATUS,\r
- ERR_ECC,\r
- ERR_DL_ERASE_FAIL,\r
- ERR_DL_PROGRAM_FAIL,\r
- ERR_DL_VERIFY_FAIL\r
-}E_UPGRADE_ERR_TYPE;\r
-\r
-/***********************************************************************/\r
-\r
-/***********************************************************************\r
- [function]: \r
- callback: send data to ctpm by i2c interface;\r
- [parameters]:\r
- txdata[in]: data buffer which is used to send data;\r
- length[in]: the length of the data buffer;\r
- [return]:\r
- FTS_TRUE: success;\r
- FTS_FALSE: fail;\r
-************************************************************************/\r
-static int fts_i2c_txdata(u8 *txdata, int length)\r
-{\r
- int ret;\r
-\r
- struct i2c_msg msg;\r
-\r
- msg.addr = this_client->addr;\r
- msg.flags = 0;\r
- msg.len = length;\r
- msg.buf = txdata;\r
- msg.scl_rate = FT5306_IIC_SPEED;\r
- ret = i2c_transfer(this_client->adapter, &msg, 1);\r
- if (ret < 0)\r
- pr_err("%s i2c write error: %d\n", __func__, ret);\r
-\r
- return ret;\r
-}\r
-\r
-/***********************************************************************\r
- [function]: \r
- callback: write data to ctpm by i2c interface;\r
- [parameters]:\r
- buffer[in]: data buffer;\r
- length[in]: the length of the data buffer;\r
- [return]:\r
- FTS_TRUE: success;\r
- FTS_FALSE: fail;\r
-************************************************************************/\r
-static bool i2c_write_interface(u8* pbt_buf, int dw_lenth)\r
-{\r
- int ret;\r
- ret=i2c_master_send(this_client, pbt_buf, dw_lenth);\r
- if(ret<=0)\r
- {\r
- FTprintk("[TSP]i2c_write_interface error line = %d, ret = %d\n", __LINE__, ret);\r
- return false;\r
- }\r
-\r
- return true;\r
-}\r
-\r
-/***********************************************************************\r
- [function]: \r
- callback: read register value ftom ctpm by i2c interface;\r
- [parameters]:\r
- reg_name[in]: the register which you want to write;\r
- tx_buf[in]: buffer which is contained of the writing value;\r
- [return]:\r
- FTS_TRUE: success;\r
- FTS_FALSE: fail;\r
-************************************************************************/\r
-static bool fts_register_write(u8 reg_name, u8* tx_buf)\r
-{\r
- u8 write_cmd[2] = {0};\r
-\r
- write_cmd[0] = reg_name;\r
- write_cmd[1] = *tx_buf;\r
-\r
- /*call the write callback function*/\r
- return i2c_write_interface(write_cmd, 2);\r
-}\r
-\r
-/***********************************************************************\r
-[function]: \r
- callback: send a command to ctpm.\r
-[parameters]:\r
- btcmd[in]: command code;\r
- btPara1[in]: parameter 1; \r
- btPara2[in]: parameter 2; \r
- btPara3[in]: parameter 3; \r
- num[in]: the valid input parameter numbers, \r
- if only command code needed and no \r
- parameters followed,then the num is 1; \r
-[return]:\r
- FTS_TRUE: success;\r
- FTS_FALSE: io fail;\r
-************************************************************************/\r
-static bool cmd_write(u8 btcmd,u8 btPara1,u8 btPara2,u8 btPara3,u8 num)\r
-{\r
- u8 write_cmd[4] = {0};\r
-\r
- write_cmd[0] = btcmd;\r
- write_cmd[1] = btPara1;\r
- write_cmd[2] = btPara2;\r
- write_cmd[3] = btPara3;\r
- return i2c_write_interface(write_cmd, num);\r
-}\r
-\r
-/***********************************************************************\r
- [function]: \r
- callback: read data from ctpm by i2c interface;\r
- [parameters]:\r
- buffer[in]: data buffer;\r
- length[in]: the length of the data buffer;\r
- [return]:\r
- FTS_TRUE: success;\r
- FTS_FALSE: fail;\r
-************************************************************************/\r
-static bool i2c_read_interface(u8* pbt_buf, int dw_lenth)\r
-{\r
- int ret;\r
- \r
- ret=i2c_master_recv(this_client, pbt_buf, dw_lenth);\r
-\r
- if(ret<=0)\r
- {\r
- FTprintk("[TSP]i2c_read_interface error\n");\r
- return false;\r
- }\r
- \r
- return true;\r
-}\r
-\r
-\r
-/***********************************************************************\r
-[function]: \r
- callback: read a byte data from ctpm;\r
-[parameters]:\r
- buffer[in]: read buffer;\r
- length[in]: the size of read data; \r
-[return]:\r
- FTS_TRUE: success;\r
- FTS_FALSE: io fail;\r
-************************************************************************/\r
-static bool byte_read(u8* buffer, int length)\r
-{\r
- return i2c_read_interface(buffer, length);\r
-}\r
-\r
-/***********************************************************************\r
-[function]: \r
- callback: write a byte data to ctpm;\r
-[parameters]:\r
- buffer[in]: write buffer;\r
- length[in]: the size of write data; \r
-[return]:\r
- FTS_TRUE: success;\r
- FTS_FALSE: io fail;\r
-************************************************************************/\r
-static bool byte_write(u8* buffer, int length)\r
-{\r
- \r
- return i2c_write_interface(buffer, length);\r
-}\r
-\r
-/***********************************************************************\r
- [function]: \r
- callback: read register value ftom ctpm by i2c interface;\r
- [parameters]:\r
- reg_name[in]: the register which you want to read;\r
- rx_buf[in]: data buffer which is used to store register value;\r
- rx_length[in]: the length of the data buffer;\r
- [return]:\r
- FTS_TRUE: success;\r
- FTS_FALSE: fail;\r
-************************************************************************/\r
-static bool fts_register_read(u8 reg_name, u8* rx_buf, int rx_length)\r
-{\r
- u8 read_cmd[2]= {0};\r
- u8 cmd_len = 0;\r
-\r
- read_cmd[0] = reg_name;\r
- cmd_len = 1; \r
-\r
- /*send register addr*/\r
- if(!i2c_write_interface(&read_cmd[0], cmd_len))\r
- {\r
- return false;\r
- }\r
-\r
- /*call the read callback function to get the register value*/ \r
- if(!i2c_read_interface(rx_buf, rx_length))\r
- {\r
- return false;\r
- }\r
- return true;\r
-}\r
-\r
-\r
-\r
-/***********************************************************************\r
-[function]: \r
- callback: burn the FW to ctpm.\r
-[parameters]:\r
- pbt_buf[in]: point to Head+FW ;\r
- dw_lenth[in]: the length of the FW + 6(the Head length); \r
-[return]:\r
- ERR_OK: no error;\r
- ERR_MODE: fail to switch to UPDATE mode;\r
- ERR_READID: read id fail;\r
- ERR_ERASE: erase chip fail;\r
- ERR_STATUS: status error;\r
- ERR_ECC: ecc error.\r
-************************************************************************/\r
-E_UPGRADE_ERR_TYPE fts_ctpm_fw_upgrade(u8* pbt_buf, int dw_lenth)\r
-{\r
- u8 cmd,reg_val[2] = {0};\r
- u8 buffer[2] = {0};\r
- u8 packet_buf[FTS_PACKET_LENGTH + 6];\r
- u8 auc_i2c_write_buf[10];\r
- u8 bt_ecc;\r
- \r
- int j,temp,lenght,i_ret,packet_number, i = 0;\r
- int i_is_new_protocol = 0;\r
- \r
-\r
- /******write 0xaa to register 0xfc******/\r
- cmd=0xaa;\r
- fts_register_write(0xfc,&cmd);\r
- mdelay(50);\r
- \r
- /******write 0x55 to register 0xfc******/\r
- cmd=0x55;\r
- fts_register_write(0xfc,&cmd);\r
- FTprintk("[TSP] Step 1: Reset CTPM test\n");\r
- \r
- mdelay(10); \r
-\r
-\r
- /*******Step 2:Enter upgrade mode ****/\r
- FTprintk("\n[TSP] Step 2:enter new update mode\n");\r
- auc_i2c_write_buf[0] = 0x55;\r
- auc_i2c_write_buf[1] = 0xaa;\r
- do\r
- {\r
- i ++;\r
- i_ret = fts_i2c_txdata(auc_i2c_write_buf, 2);\r
- mdelay(5);\r
- }while(i_ret <= 0 && i < 10 );\r
-\r
- if (i > 1)\r
- {\r
- i_is_new_protocol = 1;\r
- }\r
-\r
- /********Step 3:check READ-ID********/ \r
- cmd_write(0x90,0x00,0x00,0x00,4);\r
- byte_read(reg_val,2);\r
- if (reg_val[0] == 0x79 && reg_val[1] == 0x3)\r
- {\r
- FTprintk("[TSP] Step 3: CTPM ID,ID1 = 0x%x,ID2 = 0x%x\n",reg_val[0],reg_val[1]);\r
- }\r
- else\r
- {\r
- return ERR_READID;\r
- //i_is_new_protocol = 1;\r
- }\r
- \r
-\r
- /*********Step 4:erase app**********/\r
- if (i_is_new_protocol)\r
- {\r
- cmd_write(0x61,0x00,0x00,0x00,1);\r
- }\r
- else\r
- {\r
- cmd_write(0x60,0x00,0x00,0x00,1);\r
- }\r
- mdelay(1500);\r
- FTprintk("[TSP] Step 4: erase. \n");\r
-\r
-\r
-\r
- /*Step 5:write firmware(FW) to ctpm flash*/\r
- bt_ecc = 0;\r
- FTprintk("[TSP] Step 5: start upgrade. \n");\r
- dw_lenth = dw_lenth - 8;\r
- packet_number = (dw_lenth) / FTS_PACKET_LENGTH;\r
- packet_buf[0] = 0xbf;\r
- packet_buf[1] = 0x00;\r
- FTprintk("[TSP] packet_number = %d\n",packet_number);\r
- for (j=0;j<packet_number;j++)\r
- {\r
- temp = j * FTS_PACKET_LENGTH;\r
- packet_buf[2] = (u8)(temp>>8);\r
- packet_buf[3] = (u8)temp;\r
- lenght = FTS_PACKET_LENGTH;\r
- packet_buf[4] = (u8)(lenght>>8);\r
- packet_buf[5] = (u8)lenght;\r
-\r
- for (i=0;i<FTS_PACKET_LENGTH;i++)\r
- {\r
- packet_buf[6+i] = pbt_buf[j*FTS_PACKET_LENGTH + i]; \r
- bt_ecc ^= packet_buf[6+i];\r
- }\r
- \r
- byte_write(&packet_buf[0],FTS_PACKET_LENGTH + 6);\r
- mdelay(FTS_PACKET_LENGTH/6 + 1);\r
- if ((j * FTS_PACKET_LENGTH % 1024) == 0)\r
- {\r
- FTprintk("[TSP] upgrade the 0x%x th byte.\n", ((unsigned int)j) * FTS_PACKET_LENGTH);\r
- }\r
- }\r
-\r
- if ((dw_lenth) % FTS_PACKET_LENGTH > 0)\r
- {\r
- temp = packet_number * FTS_PACKET_LENGTH;\r
- packet_buf[2] = (u8)(temp>>8);\r
- packet_buf[3] = (u8)temp;\r
-\r
- temp = (dw_lenth) % FTS_PACKET_LENGTH;\r
- packet_buf[4] = (u8)(temp>>8);\r
- packet_buf[5] = (u8)temp;\r
-\r
- for (i=0;i<temp;i++)\r
- {\r
- packet_buf[6+i] = pbt_buf[ packet_number*FTS_PACKET_LENGTH + i]; \r
- bt_ecc ^= packet_buf[6+i];\r
- }\r
-\r
- byte_write(&packet_buf[0],temp+6); \r
- mdelay(20);\r
- }\r
-\r
- /***********send the last six byte**********/\r
- for (i = 0; i<6; i++)\r
- {\r
- temp = 0x6ffa + i;\r
- packet_buf[2] = (u8)(temp>>8);\r
- packet_buf[3] = (u8)temp;\r
- temp =1;\r
- packet_buf[4] = (u8)(temp>>8);\r
- packet_buf[5] = (u8)temp;\r
- packet_buf[6] = pbt_buf[ dw_lenth + i]; \r
- bt_ecc ^= packet_buf[6];\r
-\r
- byte_write(&packet_buf[0],7); \r
- mdelay(20);\r
- }\r
-\r
- /********send the opration head************/\r
- cmd_write(0xcc,0x00,0x00,0x00,1);\r
- byte_read(reg_val,1);\r
- FTprintk("[TSP] Step 6: ecc read 0x%x, new firmware 0x%x. \n", reg_val[0], bt_ecc);\r
- if(reg_val[0] != bt_ecc)\r
- {\r
- return ERR_ECC;\r
- }\r
-\r
- /*******Step 7: reset the new FW**********/\r
- cmd_write(0x07,0x00,0x00,0x00,1);\r
- mdelay(100);//100ms \r
- fts_register_read(0xfc, buffer, 1); \r
- if (buffer[0] == 1)\r
- {\r
- cmd=4;\r
- fts_register_write(0xfc, &cmd);\r
- mdelay(2500);//2500ms \r
- do \r
- { \r
- fts_register_read(0xfc, buffer, 1); \r
- mdelay(100);//100ms \r
- }while (buffer[0] != 1); \r
- }\r
- return ERR_OK;\r
-}\r
-\r
-\r
-/***********************************************************************/\r
-\r
-int fts_ctpm_fw_upgrade_with_i_file(void)\r
-{\r
- u8* pbt_buf = 0;\r
- int i_ret;\r
- \r
- pbt_buf = CTPM_FW;\r
- i_ret = fts_ctpm_fw_upgrade(pbt_buf,sizeof(CTPM_FW));\r
- \r
- return i_ret;\r
-}\r
-\r
-/***********************************************************************/\r
-\r
-unsigned char fts_ctpm_get_upg_ver(void)\r
-{\r
- unsigned int ui_sz;\r
- \r
- ui_sz = sizeof(CTPM_FW);\r
- if (ui_sz > 2)\r
- {\r
- return CTPM_FW[ui_sz - 2];\r
- }\r
- else\r
- return 0xff; \r
- \r
-}\r
-\r
-/*read the it7260 register ,used i2c bus*/\r
-static int ft5306_read_regs(struct i2c_client *client, u8 reg, u8 *buf, unsigned len)\r
-{\r
- int ret; \r
- ret = i2c_master_reg8_recv(client, reg, buf, len, FT5306_IIC_SPEED);\r
- return ret; \r
-}\r
-\r
-/* set the it7260 registe,used i2c bus*/\r
-static int ft5306_set_regs(struct i2c_client *client, u8 reg, u8 *buf, unsigned short len)\r
-{\r
- int ret; \r
- ret = i2c_master_reg8_send(client, reg, buf, (int)len, FT5306_IIC_SPEED);\r
- return ret;\r
-}\r
-\r
-static void ft5306_queue_work(struct work_struct *work)\r
-{\r
- struct ft5x0x_ts_data *data = container_of(work, struct ft5x0x_ts_data, pen_event_work);\r
- struct tp_event event;\r
- u8 start_reg=0x0;\r
- u8 buf[32] = {0};\r
- int ret,i,offset,points;\r
- static u8 points_last_flag[MAX_POINT]={0};\r
- struct tp_event current_events[MAX_POINT];\r
- \r
-#if CONFIG_FT5X0X_MULTITOUCH\r
- ret = ft5306_read_regs(data->client,start_reg, buf, 6*MAX_POINT+1);\r
-#else\r
- ret = ft5306_read_regs(data->client,start_reg, buf, 7);\r
-#endif\r
- if (ret < 0) {\r
- dev_err(&data->client->dev, "ft5306_read_regs fail:%d!\n",ret);\r
- enable_irq(data->irq);\r
- return;\r
- }\r
-#if 0\r
- for (i=0; i<32; i++) {\r
- FTprintk("buf[%d] = 0x%x \n", i, buf[i]);\r
- }\r
-#endif\r
- \r
- points = buf[2] & 0x07;\r
- //dev_info(&data->client->dev, "ft5306_read_and_report_data points = %d\n",points);\r
- if (points == 0) {\r
-#if CONFIG_FT5X0X_MULTITOUCH\r
- //input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 0);\r
- //input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 0);\r
- \r
- for(i=0;i<MAX_POINT;i++)\r
- {\r
- if(points_last_flag[i]!=0)\r
- {\r
- FTprintk("Point UP event.id=%d\n",i);\r
- input_mt_slot(data->input_dev, i);\r
- input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, false); \r
- }\r
- }\r
-\r
- memset(points_last_flag, 0, sizeof(points_last_flag));\r
- //input_mt_sync(data->input_dev);\r
-#else\r
- input_report_abs(data->input_dev, ABS_PRESSURE, 0);\r
- input_report_key(data->input_dev, BTN_TOUCH, 0);\r
-#endif\r
- input_sync(data->input_dev);\r
- enable_irq(data->irq);\r
- return; \r
- }\r
- memset(&event, 0, sizeof(struct tp_event));\r
-#if CONFIG_FT5X0X_MULTITOUCH\r
- memset(current_events, 0, sizeof(current_events));\r
- \r
- for(i=0;i<points;i++){\r
- offset = i*6+3;\r
- event.x = (((s16)(buf[offset+0] & 0x0F))<<8) | ((s16)buf[offset+1]);\r
- event.y = (((s16)(buf[offset+2] & 0x0F))<<8) | ((s16)buf[offset+3]);\r
- event.id = (s16)(buf[offset+2] & 0xF0)>>4;\r
- event.flag = ((buf[offset+0] & 0xc0) >> 6);\r
- event.pressure = 200;\r
- FTprintk("x=%d, y=%d event.id=%d event.flag=%d\n",event.x,event.y,event.id,event.flag);\r
- if(event.x<=SCREEN_MAX_X && event.y<=SCREEN_MAX_Y+60){\r
- //dev_info(&data->client->dev, \r
- // "ft5306 multiple report event[%d]:x = %d,y = %d,id = %d,flag = %d,pressure = %d\n",\r
- // i,event.x,event.y,event.id,event.flag,event.pressure);\r
- if(event.flag)\r
- memcpy(¤t_events[event.id], &event, sizeof(event));\r
- //points_current[event.id] = event.flag; \r
- }\r
- }\r
- \r
- for(i=0;i<MAX_POINT;i++)\r
- {\r
- if((current_events[i].flag == 0) && (points_last_flag[i] != 0))\r
- {\r
- FTprintk("Point UP event.id=%d\n",i);\r
- input_mt_slot(data->input_dev, i);\r
- input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, false); \r
- }\r
- else if(current_events[i].flag) \r
- { \r
- FTprintk("Point DN event.id=%d\n",i);\r
- input_mt_slot(data->input_dev, i);\r
- input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, true);\r
- input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 1);\r
- //input_report_abs(data->input_dev, ABS_MT_PRESSURE, event.pressure);\r
- input_report_abs(data->input_dev, ABS_MT_POSITION_X, current_events[i].x);\r
- input_report_abs(data->input_dev, ABS_MT_POSITION_Y, current_events[i].y); \r
- } \r
- points_last_flag[i] = current_events[i].flag;\r
- }\r
-#else\r
- event.x = (s16)(buf[3] & 0x0F)<<8 | (s16)buf[4];\r
- event.y = (s16)(buf[5] & 0x0F)<<8 | (s16)buf[6];\r
- event.pressure =200;\r
- input_report_abs(data->input_dev, ABS_X, event.x);\r
- input_report_abs(data->input_dev, ABS_Y, event.y);\r
- //input_report_abs(data->input_dev, ABS_PRESSURE, event.pressure);\r
- input_report_key(data->input_dev, BTN_TOUCH, 1);\r
- \r
- \r
- //dev_info(&data->client->dev, "ft5306 single report event:x = %d,y = %d\n",event.x,event.y);\r
-#endif\r
- //printk("ft5306 sync x = %d ,y = %d\n",event.x,event.y);\r
- input_sync(data->input_dev);\r
- enable_irq(data->irq);\r
- return;\r
-}\r
-\r
-static irqreturn_t ft5306_interrupt(int irq, void *dev_id)\r
-{\r
- struct ft5x0x_ts_data *ft5x0x_ts = dev_id;\r
- FTprintk("[TSP] ft5306_interrupt\n");\r
- disable_irq_nosync(ft5x0x_ts->irq);\r
- if (!work_pending(&ft5x0x_ts->pen_event_work)) \r
- queue_work(ft5x0x_ts->ts_workqueue, &ft5x0x_ts->pen_event_work);\r
- return IRQ_HANDLED;\r
-}\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
-\r
-static int ft5306_suspend(struct early_suspend *h)\r
-{\r
- struct ft5x0x_ts_data *ft5x0x_ts;\r
- char buf_w[1] = {3};\r
- int err;\r
- ft5x0x_ts = container_of(h, struct ft5x0x_ts_data, ft5306_early_suspend);\r
- FTprintk("TSP ft5306_suspend\n");\r
- //if (ft5x0x_ts->platform_sleep){ \r
- // ft5x0x_ts->platform_sleep();\r
- //}\r
- err = ft5306_set_regs(this_client,0xA5,buf_w,1);\r
- if (err>0)\r
- printk("ft5306_set_regs OK!!\n");\r
- disable_irq(ft5x0x_ts->irq);\r
- return 0;\r
-}\r
-\r
-\r
-static int ft5306_resume(struct early_suspend *h)\r
-{\r
- struct ft5x0x_ts_data *ft5x0x_ts; \r
- ft5x0x_ts = container_of(h, struct ft5x0x_ts_data, ft5306_early_suspend);\r
- FTprintk("TSP ft5306_resume\n");\r
- enable_irq(ft5x0x_ts->irq);\r
- //if (ft5x0x_ts->platform_wakeup) \r
- //ft5x0x_ts->platform_wakeup();\r
- gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);\r
- mdelay(100);\r
- gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);\r
- return 0;\r
-}\r
-#endif\r
-\r
-static int __devexit ft5306_remove(struct i2c_client *client)\r
-{\r
- struct ft5x0x_ts_data *ft5x0x_ts = i2c_get_clientdata(client);\r
-\r
- free_irq(ft5x0x_ts->irq, ft5x0x_ts);\r
- input_unregister_device(ft5x0x_ts->input_dev);\r
- kfree(ft5x0x_ts);\r
- cancel_work_sync(&ft5x0x_ts->pen_event_work);\r
- destroy_workqueue(ft5x0x_ts->ts_workqueue);\r
- i2c_set_clientdata(client, NULL);\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
- unregister_early_suspend(&ft5x0x_ts->ft5306_early_suspend);\r
-#endif \r
- this_client = NULL;\r
- return 0;\r
-}\r
-\r
-static int ft5306_probe(struct i2c_client *client ,const struct i2c_device_id *id)\r
-{\r
- struct ft5x0x_ts_data *ft5x0x_ts;\r
- struct input_dev *input_dev;\r
- struct ft5606_platform_data *pdata = client->dev.platform_data;\r
- int err = 0;\r
- int ret = 0;\r
- int retry = 0;\r
- u8 buf_w[1];\r
- u8 buf_r[1];\r
- const u8 buf_test[1] = {0};\r
- unsigned char reg_value;\r
- unsigned char reg_version;\r
-\r
- dev_info(&client->dev, "ft5306_ts_probe!\n");\r
- if (!pdata) {\r
- dev_err(&client->dev, "platform data is required!\n");\r
- return -EINVAL;\r
- }\r
-\r
- if (pdata->init_platform_hw) \r
- pdata->init_platform_hw();\r
- if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)){\r
- dev_err(&client->dev, "Must have I2C_FUNC_I2C.\n");\r
- return -ENODEV;\r
- }\r
- \r
- ft5x0x_ts = kzalloc(sizeof(*ft5x0x_ts), GFP_KERNEL);\r
- ft5x0x_ts->platform_wakeup = pdata->platform_wakeup;\r
- ft5x0x_ts->platform_sleep = pdata->platform_sleep; \r
- if (!ft5x0x_ts) {\r
- return -ENOMEM;\r
- }\r
-\r
- while(retry < 5)\r
- {\r
- ret=ft5306_set_regs(client,FT5X0X_REG_PMODE, buf_test,1);\r
- if(ret > 0)break;\r
- retry++;\r
- }\r
- if(ret <= 0)\r
- {\r
- FTprintk("FT5306 I2C TEST ERROR!\n");\r
- err = -ENODEV;\r
- goto exit_i2c_test_fail;\r
- }\r
- \r
- input_dev = input_allocate_device();\r
- if (!input_dev) {\r
- err = -ENOMEM;\r
- FTprintk("failed to allocate input device\n");\r
- goto exit_input_dev_alloc_failed;\r
- }\r
- ft5x0x_ts->client = this_client = client;\r
- ft5x0x_ts->irq = client->irq;\r
- ft5x0x_ts->input_dev = input_dev;\r
-\r
- #if CONFIG_FT5X0X_MULTITOUCH\r
- __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);\r
- __set_bit(EV_ABS, input_dev->evbit); \r
-\r
- input_mt_init_slots(input_dev, MAX_POINT);\r
- input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); \r
- input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, SCREEN_MAX_X, 0, 0);\r
- input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, SCREEN_MAX_Y, 0, 0);\r
- //input_set_abs_params(input_dev, ABS_MT_TRACKING_ID, 0, MAX_POINT, 0, 0);\r
- //input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, 255, 0, 0);\r
- \r
-#else\r
- set_bit(ABS_X, input_dev->absbit);\r
- set_bit(ABS_Y, input_dev->absbit);\r
- set_bit(ABS_PRESSURE, input_dev->absbit);\r
- set_bit(BTN_TOUCH, input_dev->keybit);\r
- input_set_abs_params(input_dev, ABS_X, 0, SCREEN_MAX_X, 0, 0);\r
- input_set_abs_params(input_dev, ABS_Y, 0, SCREEN_MAX_Y, 0, 0);\r
- //input_set_abs_params(input_dev, ABS_PRESSURE, 0, PRESS_MAX, 0 , 0);\r
-#endif\r
-\r
- //input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); \r
- //input_dev->keybit[BIT_WORD(BTN_START)] = BIT_MASK(BTN_START);\r
- //set_bit(EV_ABS, input_dev->evbit);\r
- //set_bit(EV_KEY, input_dev->evbit);\r
- \r
- input_dev->name = "ft5x0x_ts-touchscreen"; //dev_name(&client->dev)\r
- err = input_register_device(input_dev);\r
- if (err) {\r
- FTprintk("ft5306_ts_probe: failed to register input device: \n");\r
- goto exit_input_register_device_failed;\r
- }\r
-\r
- if (!ft5x0x_ts->irq) {\r
- err = -ENODEV;\r
- dev_err(&ft5x0x_ts->client->dev, "no IRQ?\n");\r
- goto exit_no_irq_fail;\r
- }else{\r
- ft5x0x_ts->irq = gpio_to_irq(ft5x0x_ts->irq);\r
- }\r
-\r
- INIT_WORK(&ft5x0x_ts->pen_event_work, ft5306_queue_work);\r
- ft5x0x_ts->ts_workqueue = create_singlethread_workqueue("ft5x0x_ts");\r
- if (!ft5x0x_ts->ts_workqueue) {\r
- err = -ESRCH;\r
- goto exit_create_singlethread;\r
- }\r
-\r
- /***wait CTP to bootup normally***/\r
- msleep(200); \r
- \r
- fts_register_read(FT5X0X_REG_FIRMID, ®_version,1);\r
- printk("cdy == [TSP] firmware version = 0x%2x\n", reg_version);\r
- \r
-#if 1 //write firmware \r
- fts_register_read(FT5X0X_REG_FIRMID, ®_version,1);\r
- FTprintk("[TSP] firmware version = 0x%2x\n", reg_version);\r
- if (fts_ctpm_get_upg_ver() != reg_version) \r
- {\r
- FTprintk("[TSP] start upgrade new verison 0x%2x\n", fts_ctpm_get_upg_ver());\r
- msleep(200);\r
- err = fts_ctpm_fw_upgrade_with_i_file();\r
- if (err == 0)\r
- {\r
- FTprintk("[TSP] ugrade successfuly.\n");\r
- msleep(300);\r
- fts_register_read(FT5X0X_REG_FIRMID, ®_value,1);\r
- FTprintk("FTS_DBG from old version 0x%2x to new version = 0x%2x\n", reg_version, reg_value);\r
- }\r
- else\r
- {\r
- FTprintk("[TSP] ugrade fail err=%d, line = %d.\n",err, __LINE__);\r
- }\r
- msleep(4000);\r
- }\r
-#endif\r
- ret = request_irq(ft5x0x_ts->irq, ft5306_interrupt, IRQF_TRIGGER_FALLING, client->dev.driver->name, ft5x0x_ts);\r
- if (ret < 0) {\r
- dev_err(&client->dev, "irq %d busy?\n", ft5x0x_ts->irq);\r
- goto exit_irq_request_fail;\r
- }\r
- i2c_set_clientdata(client, ft5x0x_ts);\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
- ft5x0x_ts->ft5306_early_suspend.suspend =ft5306_suspend;\r
- ft5x0x_ts->ft5306_early_suspend.resume =ft5306_resume;\r
- ft5x0x_ts->ft5306_early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;;\r
- register_early_suspend(&ft5x0x_ts->ft5306_early_suspend);\r
-#endif\r
- buf_w[0] = 6;\r
- err = ft5306_set_regs(client,0x88,buf_w,1);\r
- buf_r[0] = 0;\r
- err = ft5306_read_regs(client,0x88,buf_r,1);\r
- FTprintk("read buf[0x88] = %d\n", buf_r[0]);\r
- return 0;\r
-\r
- i2c_set_clientdata(client, NULL);\r
- free_irq(ft5x0x_ts->irq,ft5x0x_ts);\r
-exit_irq_request_fail:\r
- cancel_work_sync(&ft5x0x_ts->pen_event_work);\r
- destroy_workqueue(ft5x0x_ts->ts_workqueue);\r
-exit_create_singlethread:\r
-exit_no_irq_fail:\r
- input_unregister_device(input_dev);\r
-exit_input_register_device_failed:\r
- input_free_device(input_dev);\r
-exit_input_dev_alloc_failed:\r
-exit_i2c_test_fail:\r
- if (pdata->exit_platform_hw) \r
- pdata->exit_platform_hw();\r
- kfree(ft5x0x_ts);\r
- return err;\r
-}\r
-\r
-\r
-\r
-static struct i2c_device_id ft5306_idtable[] = {\r
- { FT5X0X_NAME, 0 },\r
- { }\r
-};\r
-\r
-MODULE_DEVICE_TABLE(i2c, ft5306_idtable);\r
-\r
-static struct i2c_driver ft5306_driver = {\r
- .driver = {\r
- .owner = THIS_MODULE,\r
- .name = FT5X0X_NAME\r
- },\r
- .id_table = ft5306_idtable,\r
- .probe = ft5306_probe,\r
- //.suspend = ft5306_suspend,\r
- //.resume = ft5306_resume,\r
- .remove = __devexit_p(ft5306_remove),\r
-};\r
-\r
-static int __init ft5306_ts_init(void)\r
-{\r
- return i2c_add_driver(&ft5306_driver);\r
-}\r
-\r
-static void __exit ft5306_ts_exit(void)\r
-{\r
- FTprintk("Touchscreen driver of ft5306 exited.\n");\r
- i2c_del_driver(&ft5306_driver);\r
-}\r
-\r
-\r
-/***********************************************************************/\r
-\r
-module_init(ft5306_ts_init);\r
-module_exit(ft5306_ts_exit);\r
-\r
-MODULE_AUTHOR("<wenfs@Focaltech-systems.com>");\r
-MODULE_DESCRIPTION("FocalTech ft5x0x TouchScreen driver");\r
-\r
+/*
+ * drivers/input/touchscreen/ft5x0x_ts.c
+ *
+ * FocalTech ft5x0x TouchScreen driver.
+ *
+ * Copyright (c) 2010 Focal tech Ltd.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ *
+ * note: only support mulititouch Wenfs 2010-10-01
+ */
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/hrtimer.h>
+#include <linux/i2c.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/async.h>
+#include <linux/workqueue.h>
+#include <linux/slab.h>
+#include <mach/gpio.h>
+#include <linux/irq.h>
+#include <mach/board.h>
+#include <linux/input/mt.h>
+
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+
+
+#define CONFIG_FT5X0X_MULTITOUCH 1
+#define CONFIG_TOUCH_PANEL_KEY 1
+#define NEW_PAL_DRV
+#define CHECK_KEY
+#define LONGPRESS_LOCK_SPECKEY //是否使用长按某键(如search键)锁住功能键的功能
+#ifdef LONGPRESS_LOCK_SPECKEY
+#define KEY_LOCK 195
+#define ORIGIN_KEY KEY_SEARCH
+#define LOCK_LONG_PRESS_CNT 100
+static int Origin2LockPressCnt = 0;
+static int lockflag =0;
+static int touch_key_hold_press = 0;
+
+ssize_t glock_status_show(struct device *dev, char *buf)
+{
+ printk("lockflag === %d\n",lockflag);
+ return sprintf(buf, "%d", lockflag);
+}
+#endif
+
+
+static int err_ft5X06 = 0; //w++记载有没有此设备
+static int debug1=1;
+module_param(debug1, int, S_IRUGO|S_IWUSR);
+
+static int gpress = 0;
+extern void gpio_enable1();
+static int Motoenble = 0;
+module_param(Motoenble, int, S_IRUGO|S_IWUSR);
+static int MotoStart = 0;
+
+/*
+ * Added by yick @RockChip
+ * Compatible with both types of firmware
+ * default: point - only pressdown finger num
+ * event - both down and up event
+ */
+#define USE_POINT 1
+#if USE_POINT
+uint16_t down_table = 0;
+uint16_t up_table = ~0;
+#endif
+
+#define SCREEN_MAX_X 480
+#define SCREEN_MAX_Y 800
+#define PRESS_MAX 255
+
+#define FT5X0X_NAME "ft5x0x_ts"
+#define MAX_CONTACTS 5
+enum ft5x0x_ts_regs {
+ FT5X0X_REG_PMODE = 0xA5, /* Power Consume Mode */
+};
+
+#define KEY_MIN_X 800
+#define KEY_NUM 4
+
+int touch_key_press[] = {0, 0, 0, 0};
+//int touch_key_code[] = { KEY_BACK,KEY_HOME, KEY_MENU};
+//int touch_key_min[KEY_NUM] ={-1,59,105};
+//int touch_key_max[KEY_NUM] ={2,73,121};
+
+int touch_key_code[] = {KEY_MENU, KEY_HOMEPAGE, KEY_BACK, KEY_SEARCH};
+int touch_key_min[KEY_NUM] ={30,150,270,390};
+int touch_key_max[KEY_NUM] ={90,210,330,450};
+
+//FT5X0X_REG_PMODE
+#define PMODE_ACTIVE 0x00
+#define PMODE_MONITOR 0x01
+#define PMODE_STANDBY 0x02
+#define PMODE_HIBERNATE 0x03
+
+#ifndef ABS_MT_TOUCH_MAJOR
+#define ABS_MT_TOUCH_MAJOR 0x30 /* touching ellipse */
+#define ABS_MT_TOUCH_MINOR 0x31 /* (omit if circular) */
+#define ABS_MT_WIDTH_MAJOR 0x32 /* approaching ellipse */
+#define ABS_MT_WIDTH_MINOR 0x33 /* (omit if circular) */
+#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */
+#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */
+#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */
+#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */
+#define ABS_MT_BLOB_ID 0x38 /* Group set of pkts as blob */
+#endif /* ABS_MT_TOUCH_MAJOR */
+
+struct point_data {
+ u8 status;
+ u8 id;
+ u16 x;
+ u16 y;
+};
+
+struct ts_event {
+ u16 touch_point;
+ struct point_data point[5];
+};
+
+struct ft5x0x_ts_dev {
+ struct i2c_client *client;
+ struct input_dev *input_dev;
+ int irq;
+ struct ts_event event;
+ struct work_struct pen_event_work;
+ struct workqueue_struct *ts_workqueue;
+ struct early_suspend early_suspend;
+
+#ifdef CHECK_KEY
+ struct timer_list timer;
+#endif
+};
+
+static struct ft5x0x_ts_dev *g_dev;
+static bool rember_point_into = true;
+
+
+static ssize_t Moto_status(struct device_driver *_drv,char *_buf)
+{
+ //printk("Moto_status Motoenble==%d\n", Motoenble);
+ if(Motoenble)
+ return sprintf(_buf, "Ledlevel is Low\n");
+ else
+ return sprintf(_buf, "Ledlevel is High\n");
+}
+static ssize_t Moto_control(struct device_driver *_drv, const char *_buf, size_t _count)
+{
+ char temp[5];
+ //printk("Read data from Android: %s\n", _buf);
+ strncpy(temp, _buf, 1);
+ Motoenble = simple_strtol(temp, NULL, 10);
+ //printk("Moto_control Motoenble=%d\n", Motoenble);
+}
+
+
+static int ft5x0x_i2c_rxdata(char *rxdata, int length)
+{
+ int ret;
+
+ struct i2c_msg msgs[] = {
+ {
+ .addr = g_dev->client->addr,
+ .flags = 0,
+ .len = 1,
+ .buf = rxdata,
+ .scl_rate = 200 * 1000,
+ },
+ {
+ .addr = g_dev->client->addr,
+ .flags = I2C_M_RD,
+ .len = length,
+ .buf = rxdata,
+ .scl_rate = 200 * 1000,
+ },
+ };
+
+ ret = i2c_transfer(g_dev->client->adapter, msgs, 2);
+ if (ret < 0)
+ pr_err("msg %s i2c read error: %d\n", __func__, ret);
+
+ return ret;
+}
+
+static int ft5x0x_i2c_txdata(char *txdata, int length)
+{
+ int ret;
+
+ struct i2c_msg msg[] = {
+ {
+ .addr = g_dev->client->addr,
+ .flags = 0,
+ .len = length,
+ .buf = txdata,
+ .scl_rate = 200 * 1000,
+ },
+ };
+
+ ret = i2c_transfer(g_dev->client->adapter, msg, 1);
+ if (ret < 0)
+ pr_err("%s i2c write error: %d\n", __func__, ret);
+
+ return ret;
+}
+
+static int ft5x0x_set_reg(u8 addr, u8 para)
+{
+ u8 buf[3];
+ int ret = -1;
+
+ buf[0] = addr;
+ buf[1] = para;
+ ret = ft5x0x_i2c_txdata(buf, 2);
+ if (ret < 0) {
+ pr_err("write reg failed! %#x ret: %d", buf[0], ret);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int ft5x0x_read_data(void)
+{
+ struct ft5x0x_ts_dev *data = i2c_get_clientdata(g_dev->client);
+ struct ts_event *event = &data->event;
+
+ u8 buf[32]= {0};//set send addr to 0x00 *important*
+ int ret = -1;
+ int key;
+
+
+ if(Motoenble)
+ {
+ if(!MotoStart)
+ {
+ //printk("the moto is enable!\n");
+ //gpio_enable1();
+ MotoStart =1;
+ }
+ }
+
+
+ ret = ft5x0x_i2c_rxdata(buf, 32);
+
+ if (ret < 0) {
+ printk("%s read_data i2c_rxdata failed: %d\n", __func__, ret);
+ return ret;
+ }
+#if 0 // Just for debug
+ u8 uc_ecc;
+ int i;
+ uc_ecc = buf[2];
+ for (i=0; i<5; i++)
+ {
+ uc_ecc ^= buf[3+6*i];
+ uc_ecc ^= buf[4+6*i];
+ uc_ecc ^= buf[5+6*i];
+ uc_ecc ^= buf[6+6*i];
+ }
+// if (uc_ecc == buf[1]) break;
+// }
+
+
+ if (uc_ecc != buf[1])
+ {
+ printk("ecc check error uc_ecc=0x%x, buf[1]=0x%x.\n",uc_ecc, buf[1]);
+ return 1;
+ }
+#endif
+
+
+ memset(event, ~0x00, sizeof(struct ts_event));
+
+#if USE_POINT
+ event->touch_point = buf[2] & 0x07;// 0000 1111
+#else
+ event->touch_point = buf[2] >>4;// 0000 1111
+#endif
+ if (event->touch_point == 0) {
+ rember_point_into = false;
+#ifdef LONGPRESS_LOCK_SPECKEY
+ if(Origin2LockPressCnt)
+ {//说明按到了search键
+ if(Origin2LockPressCnt < LOCK_LONG_PRESS_CNT)
+ {//没有长按
+ if(lockflag ==0)
+ {//键盘没锁
+ input_report_key(data->input_dev,KEY_SEARCH,1); //158 //MENU
+ input_sync(data->input_dev);
+ input_report_key(data->input_dev,KEY_SEARCH,0); //158 //MENU
+ input_sync(data->input_dev);
+ //printk("menu is up ==========================\n");
+ }
+ }
+ else
+ {
+ //printk("release long press !!!!!!!!!!!!!!!!!\n");
+ input_report_key(data->input_dev, KEY_LOCK, 0);
+ //printk("up::KEY_LOCK: %d\n", KEY_LOCK);
+ input_sync(data->input_dev);
+ }
+ Origin2LockPressCnt = 0;
+ touch_key_hold_press = 0;
+ }
+#endif
+#ifdef NEW_PAL_DRV
+ if(touch_key_hold_press)
+ {
+ touch_key_hold_press = 0;
+ for(key=0; key<sizeof(touch_key_code)/sizeof(touch_key_code[0]); key++)
+ {
+ if(touch_key_press[key])
+ {
+ input_report_key(data->input_dev, touch_key_code[key], 0);
+ touch_key_press[key] = 0;
+ input_sync(data->input_dev);
+ //printk("up::KEY: %d\n", touch_key_code[key]);
+ }
+ }
+ }
+#endif
+ gpress = 0;
+ MotoStart =0;
+ //printk("release point !!!!!!!!!!!!!!!!!\n");
+ //ft5x0x_ts_release(data);
+ #ifdef CHECK_KEY
+ //event->penddown = Release;
+ #endif
+ return 0;
+ }
+
+#ifdef CONFIG_FT5X0X_MULTITOUCH
+ switch (event->touch_point) {
+ case 5:
+ event->point[4].status = (buf[0x1b] & 0xc0)>>6;
+ event->point[4].id = (buf[0x1d] & 0xf0)>>4;
+ event->point[4].x = (s16)(buf[0x1b] & 0x07)<<8 | (s16)buf[0x1c];
+ event->point[4].y = (s16)(buf[0x1d] & 0x07)<<8 | (s16)buf[0x1e];
+ case 4:
+ event->point[3].status = (buf[0x15] & 0xc0)>>6;
+ event->point[3].id = (buf[0x17] & 0xf0)>>4;
+ event->point[3].x = (s16)(buf[0x15] & 0x07)<<8 | (s16)buf[0x16];
+ event->point[3].y = (s16)(buf[0x17] & 0x07)<<8 | (s16)buf[0x18];
+ case 3:
+ event->point[2].status = (buf[0x0f] & 0xc0)>>6;
+ event->point[2].id = (buf[0x11] & 0xf0)>>4;
+ event->point[2].x = (s16)(buf[0x0f] & 0x07)<<8 | (s16)buf[0x10];
+ event->point[2].y = (s16)(buf[0x11] & 0x07)<<8 | (s16)buf[0x12];
+ case 2:
+ event->point[1].status = (buf[0x09] & 0xc0)>>6;
+ event->point[1].id = (buf[0x0b] & 0xf0)>>4;
+ event->point[1].x = (s16)(buf[0x09] & 0x07)<<8 | (s16)buf[0x0a];
+ event->point[1].y = (s16)(buf[0x0b] & 0x07)<<8 | (s16)buf[0x0c];
+ case 1:
+ event->point[0].status = (buf[0x03] & 0xc0)>>6;
+ event->point[0].id = (buf[0x05] & 0xf0)>>4;
+
+ event->point[0].y = (s16)(buf[0x03] & 0x0f)<<8 | (s16)buf[0x04];
+ event->point[0].x = (s16)(buf[0x05] & 0x0f)<<8 | (s16)buf[0x06];
+ event->point[0].x = 480 - event->point[0].x;
+ if(event->point[0].x < 0){
+ event->point[0].x = 0;
+ }
+
+ default:
+ return 0;
+ }
+#endif
+}
+
+static void ft5x0x_report_value(void)
+{
+ struct ft5x0x_ts_dev *data = i2c_get_clientdata(g_dev->client);
+ struct ts_event *event = &data->event;
+ u8 j;
+ u8 i = 0;
+ int key_id = 0xff;
+#if 0
+ printk("point is %d x0 is %d y0 is %d\n",
+ //P1 status is %x ID1 is %x x1 is 0x%x y1 is 0x%x\n\n",
+ event->touch_point,
+ //event->point[0].status, //event->point[0].id,
+ event->point[0].y, event->point[0].x);
+ //event->point[1].status, event->point[1].id,
+ //event->point[1].x, event->point[1].y);
+#endif
+#if USE_POINT
+ down_table = 0;
+
+ for(i=0; i<event->touch_point; i++) {
+ //================
+ //printk("event->x[%d]:%d,event->y[%d]:%d\n", i,event->x[i],i,event->y[i]);
+ if((event->point[i].y > KEY_MIN_X) && (debug1)/*&&(posx[i]<KEY_MAX_X)*/)
+ {
+ for(j=0;j<KEY_NUM;j++)
+ {
+ //printk("i === %d,event->point[i].x==%d,event->point[i].y===%d\n",i,event->point[i].x,event->point[i].y);
+ if((event->point[i].x >touch_key_min[j])&&(event->point[i].x <touch_key_max[j]))
+ {
+ key_id = j;
+ // printk("touch_key_hold_press = %d\n",touch_key_hold_press);
+ if((touch_key_press[key_id] == 0) && (touch_key_hold_press == 0))
+ {
+ #ifdef LONGPRESS_LOCK_SPECKEY
+ // printk("touch_key_code[%d]:%d\n",key_id,touch_key_code[key_id]);
+
+ if(touch_key_code[key_id] == ORIGIN_KEY)
+ { /*
+ if(++Origin2LockPressCnt>LOCK_LONG_PRESS_CNT)
+ {
+ Origin2LockPressCnt = LOCK_LONG_PRESS_CNT + 2;
+ input_report_key(data->input_dev, KEY_LOCK, 1);
+ touch_key_hold_press = 1;
+ if(lockflag)
+ lockflag =0;
+ else
+ lockflag =1;
+ }*/
+ Origin2LockPressCnt=1;
+ break;
+ }
+ //if(lockflag)
+ //goto out;
+ #endif
+ input_report_key(data->input_dev, touch_key_code[key_id], 1);
+ touch_key_press[key_id] = 1;
+ touch_key_hold_press = 1;
+ // printk("down::KEY: %d\n", touch_key_code[key_id]);
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ input_mt_slot(data->input_dev, event->point[i].id);
+
+ input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, event->point[i].id);
+
+ down_table |= 1 << event->point[i].id;
+ input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 100);
+ input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->point[i].x);
+ input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->point[i].y);
+ input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 100);
+ // printk("ABS_MT_TRACKING_ID == %d, ABS_MT_POSITION_X == %d, ABS_MT_POSITION_Y == %d\n",event->point[i].id,event->point[i].x,event->point[i].y);
+
+ }
+
+
+ }
+
+ for(i=0; i<MAX_CONTACTS; i++) {
+ if( ( (~down_table) & 1<<i) && !(up_table & 1<<i) )
+ {
+ input_mt_slot(data->input_dev, i);
+ input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, -1);
+ /*printk("ABS_MT_TRACKING_ID == %d, ABS_MT_POSITION_X == %d, ABS_MT_POSITION_Y == %d\n",event->point[i]
+.id,event->point[i].y,event->point[i].x);*/
+ }
+ }
+ up_table = ~down_table;
+ input_sync(data->input_dev);
+#else
+
+ for(i=0; i<event->touch_point; i++) {
+ if(event->point[i].status == 0 || event->point[i].status == 2 ) {
+ input_mt_slot(data->input_dev, event->point[i].id);
+ input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, event->point[i].id);
+ input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 200);
+ input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->point[i].x);
+ input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->point[i].y);
+ input_report_abs(data->input_dev, ABS_MT_WIDTH_MAJOR, 100);
+ }
+ else if(event->point[i].status == 1) {
+ input_mt_slot(data->input_dev, event->point[i].id);
+ input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, -1);
+ }
+ }
+ input_sync(data->input_dev);
+#endif
+
+
+
+
+ out:
+ ;
+#ifdef CHECK_KEY
+ data->timer.expires = jiffies +8;
+ add_timer(&data->timer);
+ down_table = 0;
+
+#endif
+
+
+
+
+} /*end ft5x0x_report_value*/
+
+static void ft5x0x_ts_pen_irq_work(struct work_struct *work)
+{
+ int ret = -1;
+ //printk("==ft5x0x_ts_pen_work =\n");
+ ret = ft5x0x_read_data();
+ if (ret == 0) {
+ ft5x0x_report_value();
+ }
+ enable_irq(g_dev->irq);
+}
+
+static irqreturn_t ft5x0x_ts_interrupt(int irq, void *dev_id)
+{
+ struct ft5x0x_ts_dev *ft5x0x_ts = dev_id;
+
+#ifdef CHECK_KEY
+
+ del_timer(&ft5x0x_ts->timer);
+#endif
+ disable_irq_nosync(g_dev->irq);
+ //printk("==ft5x0x_ts_interrupt =\n");
+ queue_work(ft5x0x_ts->ts_workqueue, &ft5x0x_ts->pen_event_work);
+
+ return IRQ_HANDLED;
+}
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static void ft5x0x_ts_suspend(struct early_suspend *handler)
+{
+ int ret;
+ struct ft5x0x_ts_dev *ts;
+ ts = container_of(handler, struct ft5x0x_ts_dev, early_suspend);
+
+ if(ts->irq)
+ disable_irq_nosync(ts->irq);
+
+ ret = cancel_work_sync(&ts->pen_event_work);
+ if (ret && ts->irq) /* if work was pending disable-count is now 2 */
+ enable_irq(ts->irq);
+ // ==set mode ==,
+// ft5x0x_set_reg(FT5X0X_REG_PMODE, PMODE_HIBERNATE);
+}
+
+static void ft5x0x_ts_resume(struct early_suspend *handler)
+{
+ struct ft5x0x_ts_dev *ts;
+ ts = container_of(handler, struct ft5x0x_ts_dev, early_suspend);
+ // wake the mode
+// gpio_direction_output(RK29_PIN6_PC3, 0);
+// gpio_set_value(RK29_PIN6_PC3,GPIO_LOW);
+// msleep(50);
+// gpio_set_value(RK29_PIN6_PC3,GPIO_HIGH);
+
+#if USE_POINT
+ down_table = 0;
+ up_table = ~0;
+#endif
+
+ if(ts->irq)
+ enable_irq(ts->irq);
+}
+#endif //CONFIG_HAS_EARLYSUSPEND
+#ifdef CHECK_KEY
+static void Touch_timer_release(unsigned long ft_ts_pdev)
+{
+
+ struct ft5x0x_ts_dev *data = ft_ts_pdev;
+ int key, i=0;
+ int inflag =0;
+ /*if(rember_point_into)
+ {
+ for(i=0;i<MAX_CONTACTS;i++)
+ {
+ printk("hand to modefy with up !!!!!!\n");
+#if 1
+ input_mt_slot(data->input_dev, i);
+ input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, -1);
+#endif
+ }
+
+ input_sync(data->input_dev);
+ rember_point_into = true;
+ }*/
+
+ for(i=0; i<MAX_CONTACTS; i++) {
+ if( ( (~down_table) & 1<<i) && !(up_table & 1<<i) )
+ {
+ printk("%d is up !!!!!!\n",i);
+ input_mt_slot(data->input_dev, i);
+ input_report_abs(data->input_dev, ABS_MT_TRACKING_ID, -1);
+ inflag =1;
+ }
+ }
+ if(inflag==1)input_sync(data->input_dev);
+ inflag = 0;
+//===================================
+#ifdef LONGPRESS_LOCK_SPECKEY
+
+ if(Origin2LockPressCnt)
+ {//说明按到了search键
+ if(Origin2LockPressCnt < LOCK_LONG_PRESS_CNT)
+ {//没有长按
+ //if(lockflag ==0)
+ {//键盘没锁
+ input_report_key(data->input_dev,KEY_SEARCH,1); //158 //MENU
+ input_sync(data->input_dev);
+ input_report_key(data->input_dev,KEY_SEARCH,0); //158 //MENU
+ input_sync(data->input_dev);
+ //printk("menu is up ==========================\n");
+ }
+ }
+ else
+ {
+ //printk("release long press !!!!!!!!!!!!!!!!!\n");
+ //input_report_key(data->input_dev, KEY_LOCK, 0);
+ //printk("up::KEY_LOCK: %d\n", KEY_LOCK);
+ //input_sync(data->input_dev);
+ }
+ Origin2LockPressCnt = 0;
+ touch_key_hold_press = 0;
+ }
+#endif
+#ifdef NEW_PAL_DRV
+ if((touch_key_hold_press)&&(debug1))
+ {
+ touch_key_hold_press = 0;
+ for(key=0; key<sizeof(touch_key_code)/sizeof(touch_key_code[0]); key++)
+ {
+ if(touch_key_press[key])
+ {
+ input_report_key(data->input_dev, touch_key_code[key], 0);
+ touch_key_press[key] = 0;
+ input_sync(data->input_dev);
+ //printk("up::KEY: %d\n", touch_key_code[key]);
+ }
+ }
+ }
+#endif
+
+//===================================
+
+
+
+}
+
+#endif
+
+static int ft5x0x_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
+{
+ struct ft5x0x_ts_dev *ft5x0x_ts;
+ struct ft5x0x_platform_data *pdata = pdata = client->dev.platform_data;
+ struct input_dev *input_dev;
+ int err = 0;
+ u8 buf_w[1];
+ u8 buf_r[1];
+ u8 buf[3]={0}; //w++
+
+
+ if (pdata == NULL) {
+ dev_err(&client->dev, "%s: platform data is null\n", __func__);
+ goto exit_platform_data_null;
+ }
+
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+ err = -ENODEV;
+ goto exit_check_functionality_failed;
+ }
+
+ if (pdata->init_platform_hw)
+ pdata->init_platform_hw();
+
+
+ err_ft5X06=i2c_master_reg8_recv(client, 0x02, buf, 2, 200*1000); //w++6
+ //err_ft5X06 = i2c_master_reg8_recv(client, 0x00, buf, 2, 200 * 1000); //w++5
+
+ //buf[0] = 0x00;
+ //err_ft5X06 = ft5x0x_i2c_rxdata(buf,1);
+ if(err_ft5X06<0){
+ printk("%s:i2c_transfer fail =%d\n",__FUNCTION__,err);
+ return err;
+ }
+
+
+ ft5x0x_ts = (struct ft5x0x_ts_dev *)kzalloc(sizeof(*ft5x0x_ts), GFP_KERNEL);
+ if (!ft5x0x_ts) {
+ err = -ENOMEM;
+ goto exit_alloc_data_failed;
+ }
+
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ err = -ENOMEM;
+ dev_err(&client->dev, "failed to allocate input device\n");
+ goto exit_input_dev_alloc_failed;
+ }
+
+ ft5x0x_ts->input_dev = input_dev;
+ ft5x0x_ts->client = client;
+ ft5x0x_ts->irq = client->irq;
+
+ __set_bit(EV_ABS, input_dev->evbit);
+ __set_bit(EV_KEY, input_dev->evbit);
+ __set_bit(EV_REP, input_dev->evbit);
+ __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
+ set_bit(ABS_MT_POSITION_X, input_dev->absbit);
+ set_bit(ABS_MT_POSITION_Y, input_dev->absbit);
+ set_bit(ABS_MT_TOUCH_MAJOR, input_dev->absbit);
+ set_bit(ABS_MT_WIDTH_MAJOR, input_dev->absbit);
+
+ input_mt_init_slots(input_dev, MAX_CONTACTS);
+
+ 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);
+ input_set_abs_params(input_dev,ABS_MT_TOUCH_MAJOR, 0, PRESS_MAX, 0, 0);
+ input_set_abs_params(input_dev,ABS_MT_WIDTH_MAJOR, 0, 200, 0, 0);
+#if CONFIG_TOUCH_PANEL_KEY
+ set_bit(KEY_HOMEPAGE, input_dev->keybit);
+ set_bit(KEY_MENU, input_dev->keybit);
+ set_bit(KEY_BACK, input_dev->keybit);
+ set_bit(KEY_SEARCH, input_dev->keybit);
+#ifdef LONGPRESS_LOCK_SPECKEY
+ // set_bit(KEY_SEARCH, input_dev->keybit);
+ set_bit(KEY_LOCK, input_dev->keybit);
+#endif
+#endif
+
+ input_dev->name = FT5X0X_NAME; //dev_name(&client->dev)
+ err = input_register_device(input_dev);
+ if (err) {
+ dev_err(&client->dev,
+ "ft5x0x_ts_probe: failed to register input device: %s\n",
+ dev_name(&client->dev));
+ goto exit_input_register_device_failed;
+ }
+
+ g_dev = ft5x0x_ts;
+
+ i2c_set_clientdata(client, ft5x0x_ts);
+ INIT_WORK(&ft5x0x_ts->pen_event_work, ft5x0x_ts_pen_irq_work);
+ ft5x0x_ts->ts_workqueue = create_workqueue(FT5X0X_NAME);
+ if (!ft5x0x_ts->ts_workqueue) {
+ err = -ESRCH;
+ goto exit_create_singlethread;
+ }
+
+ //if(pdata->init_platform_hw)
+ // pdata->init_platform_hw();
+
+ //ft5x0x_set_reg(0x80,0x64);
+
+ if(!ft5x0x_ts->irq)
+ {
+ dev_dbg(&ft5x0x_ts->client->dev, "no IRQ?\n");
+ return -ENODEV;
+ }
+ else
+ {
+ ft5x0x_ts->irq = gpio_to_irq(ft5x0x_ts->irq);
+ }
+
+ err = request_irq(ft5x0x_ts->irq, ft5x0x_ts_interrupt, IRQF_TRIGGER_FALLING/*IRQF_DISABLED*/, "ft5x0x_ts", ft5x0x_ts);
+ if (err < 0) {
+ dev_err(&client->dev, "ft5x0x_probe: request irq failed\n");
+ goto exit_irq_request_failed;
+ }
+
+ disable_irq_nosync(g_dev->irq);
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+ ft5x0x_ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
+ ft5x0x_ts->early_suspend.suspend = ft5x0x_ts_suspend;
+ ft5x0x_ts->early_suspend.resume = ft5x0x_ts_resume;
+ register_early_suspend(&ft5x0x_ts->early_suspend);
+#endif
+#ifdef CHECK_KEY
+ setup_timer(&ft5x0x_ts->timer, Touch_timer_release, (unsigned long)ft5x0x_ts);
+#endif
+
+//wake the CTPM
+// __gpio_as_output(GPIO_FT5X0X_WAKE);
+// __gpio_clear_pin(GPIO_FT5X0X_WAKE); //set wake = 0,base on system
+// msleep(100);
+// __gpio_set_pin(GPIO_FT5X0X_WAKE); //set wake = 1,base on system
+// msleep(100);
+// ft5x0x_set_reg(0x88, 0x05); //5, 6,7,8
+// ft5x0x_set_reg(0x80, 30);
+// msleep(50);
+
+ buf_w[0] = 6;
+ err = ft5x0x_set_reg(0x88,6);
+ //ft5x0x_i2c_txdata(0x88, buf_w, 1); /* adjust frequency 60Hz */
+
+ buf_r[0] = 0x88;
+ err = ft5x0x_i2c_rxdata(buf_r,1);
+
+ enable_irq(g_dev->irq);
+
+printk("==ft5x0x_ts_probe = %0x\n", buf_r[0]);
+
+ return 0;
+
+exit_input_register_device_failed:
+ input_free_device(input_dev);
+exit_input_dev_alloc_failed:
+ free_irq(client->irq, ft5x0x_ts);
+ //free_irq(IRQ_EINT(6), ft5x0x_ts);
+exit_irq_request_failed:
+exit_platform_data_null:
+ cancel_work_sync(&ft5x0x_ts->pen_event_work);
+ destroy_workqueue(ft5x0x_ts->ts_workqueue);
+exit_create_singlethread:
+ printk("==singlethread error =\n");
+ i2c_set_clientdata(client, NULL);
+ kfree(ft5x0x_ts);
+exit_alloc_data_failed:
+exit_check_functionality_failed:
+ return err;
+}
+
+static int __devexit ft5x0x_ts_remove(struct i2c_client *client)
+{
+ struct ft5x0x_ts_dev *ft5x0x_ts = i2c_get_clientdata(client);
+ unregister_early_suspend(&ft5x0x_ts->early_suspend);
+ free_irq(client->irq, ft5x0x_ts);
+ input_unregister_device(ft5x0x_ts->input_dev);
+ kfree(ft5x0x_ts);
+ cancel_work_sync(&ft5x0x_ts->pen_event_work);
+ destroy_workqueue(ft5x0x_ts->ts_workqueue);
+ i2c_set_clientdata(client, NULL);
+ return 0;
+}
+
+static const struct i2c_device_id ft5x0x_ts_id[] = {
+ { FT5X0X_NAME, 0 },{ }
+};
+MODULE_DEVICE_TABLE(i2c, ft5x0x_ts_id);
+
+static struct i2c_driver ft5x0x_ts_driver = {
+ .probe = ft5x0x_ts_probe,
+ .remove = __devexit_p(ft5x0x_ts_remove),
+ .id_table = ft5x0x_ts_id,
+ .driver = {
+ .name = FT5X0X_NAME,
+ .owner = THIS_MODULE,
+ },
+};
+#ifdef LONGPRESS_LOCK_SPECKEY
+static DRIVER_ATTR(get_lock_status, 0777, glock_status_show, NULL);
+#endif
+static DRIVER_ATTR(MOTOenable, 0666, Moto_status, Moto_control);
+
+static int __init ft5x0x_ts_init(void)
+{
+ int ret;
+ret = i2c_add_driver(&ft5x0x_ts_driver);
+ if (ret)
+ {
+ printk("Register 5406_ts driver failed.\n");
+ return ret;
+ }
+#ifdef LONGPRESS_LOCK_SPECKEY
+ if(err_ft5X06>=0) //w++
+ ret =driver_create_file(&ft5x0x_ts_driver.driver, &driver_attr_get_lock_status);
+#endif
+ if(err_ft5X06>=0) //
+ ret =driver_create_file(&ft5x0x_ts_driver.driver, &driver_attr_MOTOenable);
+ return ret;
+}
+
+static void __exit ft5x0x_ts_exit(void)
+{
+ i2c_del_driver(&ft5x0x_ts_driver);
+#ifdef LONGPRESS_LOCK_SPECKEY
+ driver_remove_file(&ft5x0x_ts_driver.driver, &driver_attr_get_lock_status);
+#endif
+ driver_remove_file(&ft5x0x_ts_driver.driver, &driver_attr_MOTOenable);
+}
+
+module_init(ft5x0x_ts_init);
+module_exit(ft5x0x_ts_exit);
+
+MODULE_AUTHOR("<wenfs@Focaltech-systems.com>");
+MODULE_DESCRIPTION("FocalTech ft5x0x TouchScreen driver");
+MODULE_LICENSE("GPL");
+
#include <linux/fb.h>\r
#include <linux/delay.h>\r
-#include <linux/rk_fb.h>\r
+#include "../../rk29_fb.h"\r
#include <mach/gpio.h>\r
#include <mach/iomux.h>\r
#include <mach/board.h>\r
-#include "../../rockchip/hdmi/rk_hdmi.h"\r
#include "screen.h"\r
\r
-#ifdef CONFIG_RK610_LVDS\r
-#include "../transmitter/rk610_lcd.h"\r
-#endif\r
-\r
\r
/* Base */\r
-#ifdef CONFIG_RK610_LVDS\r
-#define OUT_TYPE SCREEN_LVDS\r
-#define OUT_FORMAT LVDS_8BIT_1\r
-#else\r
-#define OUT_TYPE SCREEN_RGB\r
-#endif\r
+#define OUT_TYPE SCREEN_RGB\r
\r
-#define OUT_FACE OUT_P888 \r
-//#define OUT_FACE OUT_P888 \r
-#define OUT_CLK 50000000 // 65000000\r
+//#define OUT_FACE OUT_D888_P666 \r
+#define OUT_FACE OUT_P888 \r
+#define OUT_CLK 45000000 // 65000000\r
#define LCDC_ACLK 312000000//312000000 //29 lcdc axi DMA ƵÂÊ\r
\r
/* Timing */\r
-#define H_PW 20\r
-#define H_BP 20\r
+#define H_PW 3\r
+#define H_BP 176\r
#define H_VD 1024\r
-#define H_FP 280\r
+#define H_FP 0\r
\r
-#define V_PW 2\r
-#define V_BP 2\r
+#define V_PW 1\r
+#define V_BP 25\r
#define V_VD 600\r
-#define V_FP 34\r
+#define V_FP 0\r
\r
#define LCD_WIDTH 154//1024\r
#define LCD_HEIGHT 91//600\r
/* Other */\r
-#ifdef CONFIG_RK610_LVDS\r
-#define DCLK_POL 1\r
-#else\r
-#define DCLK_POL 0\r
-#endif\r
-\r
+#define DCLK_POL 0\r
#define SWAP_RB 0 \r
\r
-int dsp_lut[256] ={\r
- 0x00000000, 0x00010101, 0x00020202, 0x00030303, 0x00040404, 0x00050505, 0x00060606, 0x00070707, \r
- 0x00080808, 0x00090909, 0x000a0a0a, 0x000b0b0b, 0x000c0c0c, 0x000d0d0d, 0x000e0e0e, 0x000f0f0f, \r
- 0x00101010, 0x00111111, 0x00121212, 0x00131313, 0x00141414, 0x00151515, 0x00161616, 0x00171717, \r
- 0x00181818, 0x00191919, 0x001a1a1a, 0x001b1b1b, 0x001c1c1c, 0x001d1d1d, 0x001e1e1e, 0x001f1f1f, \r
- 0x00202020, 0x00212121, 0x00222222, 0x00232323, 0x00242424, 0x00252525, 0x00262626, 0x00272727, \r
- 0x00282828, 0x00292929, 0x002a2a2a, 0x002b2b2b, 0x002c2c2c, 0x002d2d2d, 0x002e2e2e, 0x002f2f2f, \r
- 0x00303030, 0x00313131, 0x00323232, 0x00333333, 0x00343434, 0x00353535, 0x00363636, 0x00373737, \r
- 0x00383838, 0x00393939, 0x003a3a3a, 0x003b3b3b, 0x003c3c3c, 0x003d3d3d, 0x003e3e3e, 0x003f3f3f, \r
- 0x00404040, 0x00414141, 0x00424242, 0x00434343, 0x00444444, 0x00454545, 0x00464646, 0x00474747, \r
- 0x00484848, 0x00494949, 0x004a4a4a, 0x004b4b4b, 0x004c4c4c, 0x004d4d4d, 0x004e4e4e, 0x004f4f4f, \r
- 0x00505050, 0x00515151, 0x00525252, 0x00535353, 0x00545454, 0x00555555, 0x00565656, 0x00575757, \r
- 0x00585858, 0x00595959, 0x005a5a5a, 0x005b5b5b, 0x005c5c5c, 0x005d5d5d, 0x005e5e5e, 0x005f5f5f, \r
- 0x00606060, 0x00616161, 0x00626262, 0x00636363, 0x00646464, 0x00656565, 0x00666666, 0x00676767, \r
- 0x00686868, 0x00696969, 0x006a6a6a, 0x006b6b6b, 0x006c6c6c, 0x006d6d6d, 0x006e6e6e, 0x006f6f6f, \r
- 0x00707070, 0x00717171, 0x00727272, 0x00737373, 0x00747474, 0x00757575, 0x00767676, 0x00777777, \r
- 0x00787878, 0x00797979, 0x007a7a7a, 0x007b7b7b, 0x007c7c7c, 0x007d7d7d, 0x007e7e7e, 0x007f7f7f, \r
- 0x00808080, 0x00818181, 0x00828282, 0x00838383, 0x00848484, 0x00858585, 0x00868686, 0x00878787, \r
- 0x00888888, 0x00898989, 0x008a8a8a, 0x008b8b8b, 0x008c8c8c, 0x008d8d8d, 0x008e8e8e, 0x008f8f8f, \r
- 0x00909090, 0x00919191, 0x00929292, 0x00939393, 0x00949494, 0x00959595, 0x00969696, 0x00979797, \r
- 0x00989898, 0x00999999, 0x009a9a9a, 0x009b9b9b, 0x009c9c9c, 0x009d9d9d, 0x009e9e9e, 0x009f9f9f, \r
- 0x00a0a0a0, 0x00a1a1a1, 0x00a2a2a2, 0x00a3a3a3, 0x00a4a4a4, 0x00a5a5a5, 0x00a6a6a6, 0x00a7a7a7, \r
- 0x00a8a8a8, 0x00a9a9a9, 0x00aaaaaa, 0x00ababab, 0x00acacac, 0x00adadad, 0x00aeaeae, 0x00afafaf, \r
- 0x00b0b0b0, 0x00b1b1b1, 0x00b2b2b2, 0x00b3b3b3, 0x00b4b4b4, 0x00b5b5b5, 0x00b6b6b6, 0x00b7b7b7, \r
- 0x00b8b8b8, 0x00b9b9b9, 0x00bababa, 0x00bbbbbb, 0x00bcbcbc, 0x00bdbdbd, 0x00bebebe, 0x00bfbfbf, \r
- 0x00c0c0c0, 0x00c1c1c1, 0x00c2c2c2, 0x00c3c3c3, 0x00c4c4c4, 0x00c5c5c5, 0x00c6c6c6, 0x00c7c7c7, \r
- 0x00c8c8c8, 0x00c9c9c9, 0x00cacaca, 0x00cbcbcb, 0x00cccccc, 0x00cdcdcd, 0x00cecece, 0x00cfcfcf, \r
- 0x00d0d0d0, 0x00d1d1d1, 0x00d2d2d2, 0x00d3d3d3, 0x00d4d4d4, 0x00d5d5d5, 0x00d6d6d6, 0x00d7d7d7, \r
- 0x00d8d8d8, 0x00d9d9d9, 0x00dadada, 0x00dbdbdb, 0x00dcdcdc, 0x00dddddd, 0x00dedede, 0x00dfdfdf, \r
- 0x00e0e0e0, 0x00e1e1e1, 0x00e2e2e2, 0x00e3e3e3, 0x00e4e4e4, 0x00e5e5e5, 0x00e6e6e6, 0x00e7e7e7, \r
- 0x00e8e8e8, 0x00e9e9e9, 0x00eaeaea, 0x00ebebeb, 0x00ececec, 0x00ededed, 0x00eeeeee, 0x00efefef, \r
- 0x00f0f0f0, 0x00f1f1f1, 0x00f2f2f2, 0x00f3f3f3, 0x00f4f4f4, 0x00f5f5f5, 0x00f6f6f6, 0x00f7f7f7, \r
- 0x00f8f8f8, 0x00f9f9f9, 0x00fafafa, 0x00fbfbfb, 0x00fcfcfc, 0x00fdfdfd, 0x00fefefe, 0x00ffffff, \r
-};\r
-\r
-#if defined(CONFIG_ONE_LCDC_DUAL_OUTPUT_INF)&& defined(CONFIG_RK610_LVDS)\r
-\r
-/* scaler Timing */\r
-//1920*1080*60\r
-\r
-#define S_OUT_CLK SCALE_RATE(148500000,66000000) //m=16 n=9 no=4\r
-#define S_H_PW 10\r
-#define S_H_BP 10\r
-#define S_H_VD 1280\r
-#define S_H_FP 20\r
-\r
-#define S_V_PW 10\r
-#define S_V_BP 10\r
-#define S_V_VD 800\r
-#define S_V_FP 13\r
-\r
-#define S_H_ST 440\r
-#define S_V_ST 13\r
-\r
-//1920*1080*50\r
-#define S1_OUT_CLK SCALE_RATE(148500000,57375000) //m=17 n=11 no=4 \r
-#define S1_H_PW 10\r
-#define S1_H_BP 10\r
-#define S1_H_VD 1280\r
-#define S1_H_FP 77\r
-\r
-#define S1_V_PW 10\r
-#define S1_V_BP 10\r
-#define S1_V_VD 800\r
-#define S1_V_FP 13\r
-\r
-#define S1_H_ST 459\r
-#define S1_V_ST 13\r
-\r
-//1280*720*60\r
-#define S2_OUT_CLK SCALE_RATE(74250000,66000000) //m=32 n=9 no=4\r
-#define S2_H_PW 10\r
-#define S2_H_BP 10\r
-#define S2_H_VD 1280\r
-#define S2_H_FP 20\r
-\r
-#define S2_V_PW 10\r
-#define S2_V_BP 10\r
-#define S2_V_VD 800\r
-#define S2_V_FP 13\r
-\r
-#define S2_H_ST 440\r
-#define S2_V_ST 13\r
-\r
-//1280*720*50\r
-\r
-#define S3_OUT_CLK SCALE_RATE(74250000,57375000) // m=34 n=11 no=4\r
-#define S3_H_PW 10\r
-#define S3_H_BP 10\r
-#define S3_H_VD 1280\r
-#define S3_H_FP 77\r
-\r
-#define S3_V_PW 10\r
-#define S3_V_BP 10\r
-#define S3_V_VD 800\r
-#define S3_V_FP 13\r
-\r
-#define S3_H_ST 459\r
-#define S3_V_ST 13\r
-\r
-//720*576*50\r
-#define S4_OUT_CLK SCALE_RATE(27000000,63281250) //m=75 n=4 no=8\r
-#define S4_H_PW 10\r
-#define S4_H_BP 10\r
-#define S4_H_VD 1280\r
-#define S4_H_FP 185\r
-\r
-#define S4_V_PW 10\r
-#define S4_V_BP 10\r
-#define S4_V_VD 800\r
-#define S4_V_FP 48\r
-\r
-#define S4_H_ST 81\r
-#define S4_V_ST 48\r
-\r
-//720*480*60\r
-#define S5_OUT_CLK SCALE_RATE(27000000,75000000) //m=100 n=9 no=4\r
-#define S5_H_PW 10\r
-#define S5_H_BP 10\r
-#define S5_H_VD 1280\r
-#define S5_H_FP 130\r
-\r
-#define S5_V_PW 10\r
-#define S5_V_BP 10\r
-#define S5_V_VD 800\r
-#define S5_V_FP 54\r
-\r
-#define S5_H_ST 476\r
-#define S5_V_ST 48\r
-\r
-#define S_DCLK_POL 0\r
-\r
-static int set_scaler_info(struct rk29fb_screen *screen, u8 hdmi_resolution)\r
-{\r
- screen->s_clk_inv = S_DCLK_POL;\r
- screen->s_den_inv = 0;\r
- screen->s_hv_sync_inv = 0;\r
- switch(hdmi_resolution){\r
- case HDMI_1920x1080p_60Hz:\r
- /* Scaler Timing */\r
- screen->hdmi_resolution = hdmi_resolution;\r
- screen->s_pixclock = S_OUT_CLK;\r
- screen->s_hsync_len = S_H_PW;\r
- screen->s_left_margin = S_H_BP;\r
- screen->s_right_margin = S_H_FP;\r
- screen->s_hsync_len = S_H_PW;\r
- screen->s_upper_margin = S_V_BP;\r
- screen->s_lower_margin = S_V_FP;\r
- screen->s_vsync_len = S_V_PW;\r
- screen->s_hsync_st = S_H_ST;\r
- screen->s_vsync_st = S_V_ST;\r
- break;\r
- case HDMI_1920x1080p_50Hz:\r
- /* Scaler Timing */\r
- screen->hdmi_resolution = hdmi_resolution;\r
- screen->s_pixclock = S1_OUT_CLK;\r
- screen->s_hsync_len = S1_H_PW;\r
- screen->s_left_margin = S1_H_BP;\r
- screen->s_right_margin = S1_H_FP;\r
- screen->s_hsync_len = S1_H_PW;\r
- screen->s_upper_margin = S1_V_BP;\r
- screen->s_lower_margin = S1_V_FP;\r
- screen->s_vsync_len = S1_V_PW;\r
- screen->s_hsync_st = S1_H_ST;\r
- screen->s_vsync_st = S1_V_ST;\r
- break;\r
- case HDMI_1280x720p_60Hz:\r
- /* Scaler Timing */\r
- screen->hdmi_resolution = hdmi_resolution;\r
- screen->s_pixclock = S2_OUT_CLK;\r
- screen->s_hsync_len = S2_H_PW;\r
- screen->s_left_margin = S2_H_BP;\r
- screen->s_right_margin = S2_H_FP;\r
- screen->s_hsync_len = S2_H_PW;\r
- screen->s_upper_margin = S2_V_BP;\r
- screen->s_lower_margin = S2_V_FP;\r
- screen->s_vsync_len = S2_V_PW;\r
- screen->s_hsync_st = S2_H_ST;\r
- screen->s_vsync_st = S2_V_ST;\r
- break;\r
- case HDMI_1280x720p_50Hz:\r
- /* Scaler Timing */\r
- screen->hdmi_resolution = hdmi_resolution;\r
- screen->s_pixclock = S3_OUT_CLK;\r
- screen->s_hsync_len = S3_H_PW;\r
- screen->s_left_margin = S3_H_BP;\r
- screen->s_right_margin = S3_H_FP;\r
- screen->s_hsync_len = S3_H_PW;\r
- screen->s_upper_margin = S3_V_BP;\r
- screen->s_lower_margin = S3_V_FP;\r
- screen->s_vsync_len = S3_V_PW;\r
- screen->s_hsync_st = S3_H_ST;\r
- screen->s_vsync_st = S3_V_ST;\r
- break;\r
- case HDMI_720x576p_50Hz_4_3:\r
- case HDMI_720x576p_50Hz_16_9:\r
- /* Scaler Timing */\r
- screen->hdmi_resolution = hdmi_resolution;\r
- screen->s_pixclock = S4_OUT_CLK;\r
- screen->s_hsync_len = S4_H_PW;\r
- screen->s_left_margin = S4_H_BP;\r
- screen->s_right_margin = S4_H_FP;\r
- screen->s_hsync_len = S4_H_PW;\r
- screen->s_upper_margin = S4_V_BP;\r
- screen->s_lower_margin = S4_V_FP;\r
- screen->s_vsync_len = S4_V_PW;\r
- screen->s_hsync_st = S4_H_ST;\r
- screen->s_vsync_st = S4_V_ST;\r
- break;\r
- case HDMI_720x480p_60Hz_16_9:\r
- case HDMI_720x480p_60Hz_4_3:\r
- /* Scaler Timing */\r
- screen->hdmi_resolution = hdmi_resolution;\r
- screen->s_pixclock = S5_OUT_CLK;\r
- screen->s_hsync_len = S5_H_PW;\r
- screen->s_left_margin = S5_H_BP;\r
- screen->s_right_margin = S5_H_FP;\r
- screen->s_hsync_len = S5_H_PW;\r
- screen->s_upper_margin = S5_V_BP;\r
- screen->s_lower_margin = S5_V_FP;\r
- screen->s_vsync_len = S5_V_PW;\r
- screen->s_hsync_st = S5_H_ST;\r
- screen->s_vsync_st = S5_V_ST;\r
- break;\r
- default :\r
- printk("%s lcd not support dual display at this hdmi resolution %d \n",__func__,hdmi_resolution);\r
- return -1;\r
- break;\r
- }\r
- \r
- return 0;\r
-}\r
-#else\r
-#define set_scaler_info NULL\r
-#endif\r
-\r
void set_lcd_info(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info )\r
{\r
/* screen type & face */\r
screen->type = OUT_TYPE;\r
-#ifdef CONFIG_RK610_LVDS\r
- screen->hw_format = OUT_FORMAT;\r
-#endif\r
screen->face = OUT_FACE;\r
\r
/* Screen size */\r
\r
/* Operation function*/\r
screen->init = NULL;\r
- screen->standby = NULL;\r
- screen->dsp_lut = dsp_lut;\r
- screen->sscreen_get = set_scaler_info;\r
-#ifdef CONFIG_RK610_LVDS\r
- screen->sscreen_set = rk610_lcd_scaler_set_param;\r
-#endif\r
+ screen->standby = NULL;\r
}\r
\r
\r