summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/vtl/vtl_ts.h
blob: 9f61565d6639f031e50459f8b7eb00b883ef5c51 (plain)
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
/*
 * VTL CTP driver
 *
 * Copyright (C) 2016 Freescale Semiconductor, Inc
 *
 * Using code from:
 *  - github.com/qdk0901/q98_source:drivers/input/touchscreen/vtl/vtl_ts.h
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * 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.
 *
 */

#ifndef _TS_CORE_H_
#define _TS_CORE_H_

#include <linux/gpio.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif


#ifdef TS_DEBUG
#define DEBUG() pr_debug("___%s___\n", __func__)
#else
#define DEBUG()
#endif


/* platform define */
#define COMMON    0x01 /* Samsung,Freescale,Amlogic,actions */
#define ROCKCHIP  0X02
#define ALLWINER  0X03
#define MTK       0X04

/* vtl touch IC define */
#define CT36X     0x01
#define CT360     0x02

/* xy data protocol */
#define OLD_PROTOCOL    0x01
#define NEW_PROTOCOL    0x02


/* vtl ts driver config */

/*platform config*/
#define PLATFORM COMMON

/*vtl ts driver name*/
#define DRIVER_NAME "vtl_ts"

/*vtl chip ID*/
#define CHIP_ID CT36X

#define XY_DATA_PROTOCOL NEW_PROTOCOL


/* maybe not use,please refer to the function
 * vtl_ts_config() in the file "vtl_ts.c"
 */
#define SCREEN_MAX_X    1024
#define SCREEN_MAX_y    600

#define TS_IRQ_GPIO_NUM           /* RK30_PIN4_PC2 */
#define TS_RST_GPIO_NUM           /* RK30_PIN4_PD0 */
#define TS_I2C_SPEED    400000    /* for rockchip  */


/* priate define and declare */
#if (CHIP_ID == CT360)
#define TOUCH_POINT_NUM    1
#elif (CHIP_ID == CT36X)
#define TOUCH_POINT_NUM    1
#endif


#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;

	/* Work thread settings */
	struct work_struct event_work;
	struct workqueue_struct *workqueue;

#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 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;
	int (*tp_enter_init)(void);
	void (*tp_exit_init)(int state);
};


struct ts_chip_info {
	unsigned char chip_id;
};

struct ts_info {

	struct ts_driver *driver;
	struct ts_config_info config_info;
	struct	ts_chip_info chip_info;
	union ts_xy_data xy_data;
};

#endif