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