summaryrefslogtreecommitdiff
path: root/ANDROID_3.4.5/drivers/input/touchscreen/semisens/sn310m-touch-pdata.h
blob: fcf1e3c6d6920fd6ff64b2771fbac5fd32975c38 (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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/****************************************************************
 *
 * sn310m-touch-pdata.c
 *
 * Copyright (c) 2013 SEMISENS Co.,Ltd
 *      http://www.semisens.com
 *
 ****************************************************************/

#ifndef __TOUCH_PDATA_H
#define __TOUCH_PDATA_H

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

#include <linux/interrupt.h>

#ifndef errlog
#define errlog(fmt, args...) printk(KERN_ERR "[%s:%d]: " fmt, __FUNCTION__, __LINE__ ,## args)
#endif


//#define	DEBUG_TOUCH

#undef dbg
#ifdef DEBUG_TOUCH
#define dbg(fmt, args...) printk(KERN_ERR "[%s:%d]: " fmt, __FUNCTION__, __LINE__ ,## args)
#else
#define dbg(fmt, args...) 
#endif

#undef MSM_GPIO_TO_INT 
#define MSM_GPIO_TO_INT(a)	(a)




#define	I2C_TOUCH_NAME		"SN310M"
#define	I2C_SEND_MAX_SIZE	512			// I2C Send/Receive data max size

//--------------------------------------------
// Button struct (1 = press, 0 = release)
//--------------------------------------------
typedef struct button__t {
	unsigned char bt0_press	:1;		// lsb
	unsigned char bt1_press	:1;		
	unsigned char bt2_press	:1;
	unsigned char bt3_press	:1;
	unsigned char bt4_press	:1;
	unsigned char bt5_press	:1;
	unsigned char bt6_press	:1;
	unsigned char bt7_press	:1;		// msb
} __attribute__ ((packed)) button_t;

typedef union button__u {
	unsigned char	ubyte;
	button_t		bits;
} __attribute__ ((packed)) button_u;

//--------------------------------------------
// Touch Event type define
//--------------------------------------------
#define	TS_EVENT_UNKNOWN	0x00
#define	TS_EVENT_PRESS		0x01
#define	TS_EVENT_MOVE		0x02
#define	TS_EVENT_RELEASE	0x03

typedef struct finger__t {
	unsigned int status;	// true : ts data updated, false : no update data
	unsigned int event;		// ts event type
	unsigned int id;		// ts received id
	unsigned int x;			// ts data x
	unsigned int y;			// ts data y
	unsigned int area;		// ts finger area
	unsigned int pressure;	// ts finger pressure
} __attribute__ ((packed)) finger_t;

struct touch {
	int						irq;
	struct i2c_client		*client;
	struct touch_pdata		*pdata;
	struct input_dev		*input;
	char					phys[32];

	finger_t				*finger;		// finger data
	struct mutex			mutex;

	// sysfs control flags
	unsigned char			disabled;		// interrupt status
	unsigned char			fw_version;
	
	unsigned char			*fw_buf;
	unsigned int			fw_size;
	int						fw_status;

	// irq func used
	struct workqueue_struct	*work_queue;
	struct work_struct		work;
	
	// noise filter work
	struct delayed_work		filter_dwork;

#if	defined(CONFIG_HAS_EARLYSUSPEND)
	struct early_suspend	power;
#endif	
};

struct i2c_client;
struct input_dev;
struct device;

#define	IRQ_MODE_THREAD		0
#define	IRQ_MODE_NORMAL		1
#define	IRQ_MODE_POLLING	2

//--------------------------------------------
// IRQ type & trigger action
//--------------------------------------------
//
// IRQF_TRIGGER_RISING, IRQF_TRIGGER_FALLING, IRQF_TRIGGER_HIGH, IRQF_TRIGGER_LOW
// IRQF_DISABLED, IRQF_SHARED, IRQF_IRQPOLL, IRQF_ONESHOT, IRQF_NO_THREAD
//
//--------------------------------------------
struct touch_pdata {
	char	*name;					// input drv name

	int 	irq_gpio;				// irq gpio define
	int 	reset_gpio;				// reset gpio define
	int 	reset_level;			// reset level setting (1 = High reset, 0 = Low reset)

	int		irq_mode;				// IRQ_MODE_THREAD, IRQ_MODE_NORMAL, IRQ_MODE_POLLING
	int 	irq_flags;				// irq flags setup : Therad irq mode(IRQF_TRIGGER_HIGH | IRQF_ONESHOT)

	int		abs_max_x, abs_max_y;
	int 	abs_min_x, abs_min_y;
	
	int 	area_max, area_min;
	int		press_max, press_min;
	int		id_max, id_min;
	
	int		vendor, product, version;

	int		max_fingers;
	
	int		*keycode, keycnt;
	int		lcd_exchg;

	//--------------------------------------------
	// Control function 
	//--------------------------------------------
	void 		(*gpio_init)	(void);	// gpio early-init function

	irqreturn_t	(*irq_func)		(int irq, void *handle);
	void		(*touch_work)	(struct touch *ts);
	
	void 		(*report)		(struct touch *ts);
	void		(*key_report)	(struct touch *ts, unsigned char button_data);

	int			(*early_probe)	(struct touch *ts);
	int			(*probe)		(struct touch *ts);
	void		(*enable)		(struct touch *ts);
	void		(*disable)		(struct touch *ts);
	int 		(*input_open)	(struct input_dev *input);
	void		(*input_close)	(struct input_dev *input);

	void		(*event_clear)	(struct touch *ts);

#ifdef	CONFIG_HAS_EARLYSUSPEND
	void		(*resume)		(struct early_suspend *h);
	void		(*suspend)		(struct early_suspend *h);
#endif

	/* by limst, added to control power for touch IC */
	int			(*power)		(int on);

	//--------------------------------------------
	// I2C control function
	//--------------------------------------------
	int		(*i2c_write)		(struct i2c_client *client, unsigned char *cmd, unsigned int cmd_len, unsigned char *data, unsigned int len);
	int		(*i2c_read)			(struct i2c_client *client, unsigned char *cmd, unsigned int cmd_len, unsigned char *data, unsigned int len);

	//--------------------------------------------
	// Firmware update control function
	//--------------------------------------------
	char	*fw_filename;
	int		fw_filesize;

	int		(*i2c_boot_write)	(struct i2c_client *client, unsigned char *cmd, unsigned int cmd_len, unsigned char *data, unsigned int len);
	int		(*i2c_boot_read)	(struct i2c_client *client, unsigned char *cmd, unsigned int cmd_len, unsigned char *data, unsigned int len);
	int		(*fw_control)		(struct touch *ts, unsigned int fw_status);
	int		(*flash_firmware)	(struct device *dev, const char *fw_name);

	//--------------------------------------------
	// Calibration control function
	//--------------------------------------------
	int		(*calibration)		(struct touch *ts);
};

#endif // __TOUCH_PDATA_H