tp: vtl new driver
[firefly-linux-kernel-4.4.55.git] / drivers / input / touchscreen / vtl_ts / vtl_ts.h
1 #ifndef _TS_CORE_H_ \r
2 #define _TS_CORE_H_ \r
3 \r
4 #include <linux/gpio.h>\r
5 #ifdef CONFIG_HAS_EARLYSUSPEND\r
6 #include <linux/earlysuspend.h>\r
7 #endif\r
8 #include "../tp_suspend.h"\r
9 \r
10 \r
11 /*vtl touch IC define*/\r
12 #define CT36X                   0x01//(CT36X:ct362,ct363,ct365)\r
13 #define CT360                   0x02//(CT360:ct360)\r
14 \r
15 /*xy data protocol*/\r
16 #define OLD_PROTOCOL            0x01\r
17 #define NEW_PROTOCOL            0x02\r
18 \r
19 \r
20 \r
21 /***********************vtl ts driver config ******************************************/\r
22 \r
23 /*vtl chip ID*/\r
24 #define CHIP_ID                 CT36X//CT360//\r
25 \r
26 #define XY_DATA_PROTOCOL        NEW_PROTOCOL//OLD_PROTOCOL//\r
27 \r
28 #define TS_I2C_SPEED            400000      //for rockchip\r
29 \r
30 \r
31 #define         XY_SWAP_ENABLE          0\r
32 \r
33 #define         X_REVERSE_ENABLE        0\r
34 \r
35 #define         Y_REVERSE_ENABLE        1\r
36 \r
37 #define         CHIP_UPDATE_ENABLE      1\r
38 \r
39 #define         DEBUG_ENABLE            0\r
40 \r
41 \r
42 /***********************vtl ts driver config  end******************************************/\r
43 \r
44 \r
45 \r
46 \r
47 \r
48 \r
49 \r
50 \r
51 \r
52 \r
53 \r
54 \r
55 \r
56 \r
57 \r
58 \r
59 \r
60 \r
61 \r
62 \r
63 \r
64 \r
65 \r
66 \r
67 \r
68 \r
69 \r
70 \r
71 \r
72 \r
73 /*vtl ts driver name*/\r
74 #define DRIVER_NAME             "vtl_ts"\r
75 //#define DEBUG_ENABLE  1\r
76 #if(DEBUG_ENABLE)\r
77 #define         DEBUG()                         printk("___%s___\n",__func__);\r
78 //#define       XY_DEBUG(id,status,x,y)         printk("id = %d,status = %d,X = %d,Y = %d\n",id,status,x,y);\r
79 #else   \r
80 #define         DEBUG()\r
81 //#define       XY_DEBUG(id,status,x,y)\r
82 #endif\r
83 \r
84 /*TOUCH_POINT_NUM define*/\r
85 #if(CHIP_ID == CT360)\r
86 #define TOUCH_POINT_NUM         5\r
87 #elif(CHIP_ID == CT36X)\r
88 #define TOUCH_POINT_NUM         10\r
89 #endif\r
90 \r
91 /*priate define and declare*/\r
92 #if(CHIP_ID == CT360)\r
93 struct xy_data {\r
94         #if(XY_DATA_PROTOCOL == OLD_PROTOCOL)\r
95         unsigned char   status : 4;             // Action information, 1: Down; 2: Move; 3: Up\r
96         unsigned char   id : 4;                 // ID information, from 1 to CFG_MAX_POINT_NUM\r
97         #endif\r
98         unsigned char   xhi;                    // X coordinate Hi\r
99         unsigned char   yhi;                    // Y coordinate Hi\r
100         unsigned char   ylo : 4;                // Y coordinate Lo\r
101         unsigned char   xlo : 4;                // X coordinate Lo\r
102         #if(XY_DATA_PROTOCOL == NEW_PROTOCOL)\r
103         unsigned char   status : 4;             // Action information, 1: Down; 2: Move; 3: Up\r
104         unsigned char   id : 4;                 // ID information, from 1 to CFG_MAX_POINT_NUM\r
105         #endif\r
106 };\r
107 #else\r
108 struct xy_data {\r
109         #if(XY_DATA_PROTOCOL == OLD_PROTOCOL)\r
110         unsigned char   status : 3;             // Action information, 1: Down; 2: Move; 3: Up\r
111         unsigned char   id : 5;                 // ID information, from 1 to CFG_MAX_POINT_NUM\r
112         #endif\r
113         unsigned char   xhi;                    // X coordinate Hi\r
114         unsigned char   yhi;                    // Y coordinate Hi\r
115         unsigned char   ylo : 4;                // Y coordinate Lo\r
116         unsigned char   xlo : 4;                // X coordinate Lo\r
117         #if(XY_DATA_PROTOCOL == NEW_PROTOCOL)\r
118         unsigned char   status : 3;             // Action information, 1: Down; 2: Move; 3: Up\r
119         unsigned char   id : 5;                 // ID information, from 1 to CFG_MAX_POINT_NUM\r
120         #endif\r
121         unsigned char   area;                   // Touch area\r
122         unsigned char   pressure;               // Touch Pressure\r
123 };\r
124 #endif\r
125 \r
126 \r
127 union ts_xy_data {\r
128         struct xy_data  point[TOUCH_POINT_NUM];\r
129         unsigned char   buf[TOUCH_POINT_NUM * sizeof(struct xy_data)];\r
130 };\r
131 \r
132 \r
133 struct ts_driver{\r
134 \r
135         struct i2c_client               *client;\r
136 \r
137         /* input devices */\r
138         struct input_dev                *input_dev;                     \r
139 \r
140         struct proc_dir_entry           *proc_entry;    \r
141 \r
142         struct task_struct              *ts_thread;\r
143 \r
144         //#ifdef CONFIG_HAS_EARLYSUSPEND\r
145         //struct early_suspend          early_suspend;\r
146         //#endif\r
147 };\r
148 \r
149 struct ts_config_info{      \r
150         \r
151         unsigned int    screen_max_x;\r
152         unsigned int    screen_max_y;\r
153         unsigned int    irq_gpio_number;\r
154         unsigned int    irq_number;\r
155         unsigned int    rst_gpio_number;\r
156         unsigned char   touch_point_number;\r
157         unsigned char   ctp_used;\r
158         //unsigned char i2c_bus_number;\r
159         //unsigned char revert_x_flag;\r
160         //unsigned char revert_y_flag;\r
161         //unsigned char exchange_x_y_flag;                  \r
162 };\r
163 \r
164 struct  ts_info{\r
165         \r
166         struct ts_driver        *driver;\r
167         struct ts_config_info   config_info;\r
168         union ts_xy_data        xy_data;\r
169         unsigned char           debug;\r
170         struct  tp_device  tp;\r
171 };\r
172 \r
173 \r
174 //extern struct ts_info *pg_ts;\r
175 extern struct ts_info * vtl_ts_get_object(void);\r
176 extern void vtl_ts_hw_reset(void);\r
177 \r
178 #endif\r
179 \r