aboutsummaryrefslogtreecommitdiff
path: root/include/linux/max1187x.h
blob: e292347d1eb4e3b90a0de4f9977848f05df55b04 (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
/* include/linux/max1187x.h
 *
 * Copyright (c)2012 Maxim Integrated Products, Inc.
 *
 * Driver Version: 3.0.7
 * Release Date: Feb 22, 2013
 *
 * 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.
 *
 */

#ifndef __MAX1187X_H
#define __MAX1187X_H

#define MAX1187X_NAME   "max1187x"
#define MAX1187X_TOUCH  MAX1187X_NAME "_touchscreen_0"
#define MAX1187X_KEY    MAX1187X_NAME "_key_0"
#define MAX1187X_LOG_NAME	"[TP] "

#define MAX_WORDS_COMMAND  9  
#define MAX_WORDS_REPORT   245  
#define MAX_WORDS_COMMAND_ALL  (15 * MAX_WORDS_COMMAND)  

#define MAX1187X_NUM_FW_MAPPINGS_MAX    5
#define MAX1187X_TOUCH_COUNT_MAX        10
#define MAX1187X_TOUCH_REPORT_RAW       0x0800
#define MAX1187X_TOUCH_REPORT_BASIC     0x0801
#define MAX1187X_TOUCH_REPORT_EXTENDED  0x0802
#define MAX_REPORT_READERS		5
#define DEBUG_STRING_LEN_MAX 60
#define MAX_FW_RETRIES 5

#define MAX1187X_PI 205887 

#define MAX1187X_TOUCH_CONFIG_MAX		65
#define MAX1187X_CALIB_TABLE_MAX		74
#define MAX1187X_PRIVATE_CONFIG_MAX		34
#define MAX1187X_LOOKUP_TABLE_MAX		8
#define MAX1187X_IMAGE_FACTOR_MAX		460

#define MAX1187X_NO_BASELINE   0
#define MAX1187X_FIX_BASELINE  1
#define MAX1187X_AUTO_BASELINE 2

struct max1187x_touch_report_header {
	u16 header;
	u16 report_id;
	u16 report_size;
	u16 touch_count:4;
	u16 touch_status:4;
	u16 reserved0:5;
	u16 cycles:1;
	u16 reserved1:2;
	u16 button0:1;
	u16 button1:1;
	u16 button2:1;
	u16 button3:1;
	u16 reserved2:12;
	u16 framecounter;
};

struct max1187x_touch_report_basic {
	u16 finger_id:4;
	u16 reserved0:4;
	u16 finger_status:4;
	u16 reserved1:4;
	u16 x:12;
	u16 reserved2:4;
	u16 y:12;
	u16 reserved3:4;
	u16 z;
};

struct max1187x_touch_report_extended {
	u16 finger_id:4;
	u16 reserved0:4;
	u16 finger_status:4;
	u16 reserved1:4;
	u16 x:12;
	u16 reserved2:4;
	u16 y:12;
	u16 reserved3:4;
	u16 z;
	s16 xspeed;
	s16 yspeed;
	s8 xpixel;
	s8 ypixel;
	u16 area;
	u16 xmin;
	u16 xmax;
	u16 ymin;
	u16 ymax;
};

struct max1187x_board_config {
	u16                         config_id;
	u16                         chip_id;
	u8                          major_ver;
	u8                          minor_ver;
	u8                          protocol_ver;
	u16                         vendor_pin;
	u16                         config_touch[MAX1187X_TOUCH_CONFIG_MAX];
	u16                         config_cal[MAX1187X_CALIB_TABLE_MAX];
	u16                         config_private[MAX1187X_PRIVATE_CONFIG_MAX];
	u16                         config_lin_x[MAX1187X_LOOKUP_TABLE_MAX];
	u16                         config_lin_y[MAX1187X_LOOKUP_TABLE_MAX];
	u16                         config_ifactor[MAX1187X_IMAGE_FACTOR_MAX];
};

struct max1187x_virtual_key {
	int index;
	int keycode;
	int x_position;
	int y_position;
};

struct max1187x_fw_mapping {
	u32				chip_id;
	char			*filename;
	u32				filesize;
	u32				filecrc16;
	u32				file_codesize;
};

struct max1187x_pdata {
	struct max1187x_board_config *fw_config;
	u32			gpio_tirq;
	u32			gpio_reset;
	u32			num_fw_mappings;
	struct max1187x_fw_mapping  fw_mapping[MAX1187X_NUM_FW_MAPPINGS_MAX];
	u32			defaults_allow;
	u32			default_config_id;
	u32			default_chip_id;
	u32			i2c_words;
	#define MAX1187X_REVERSE_X  0x0001
	#define MAX1187X_REVERSE_Y  0x0002
	#define MAX1187X_SWAP_XY    0x0004
	u32			coordinate_settings;
	u32			panel_min_x;
	u32			panel_max_x;
	u32			panel_min_y;
	u32			panel_max_y;
	u32			lcd_x;
	u32			lcd_y;
	u32			num_rows;
	u32			num_cols;
	#define MAX1187X_PROTOCOL_A        0
	#define MAX1187X_PROTOCOL_B        1
	#define MAX1187X_PROTOCOL_CUSTOM1  2
	u16			input_protocol;
	#define MAX1187X_UPDATE_NONE       0
	#define MAX1187X_UPDATE_BIN        1
	#define MAX1187X_UPDATE_CONFIG     2
	#define MAX1187X_UPDATE_BOTH       3
	u8			update_feature;
	u8			support_htc_event;
	u16			tw_mask;
	u32			button_code0;
	u32			button_code1;
	u32			button_code2;
	u32			button_code3;
	#define MAX1187X_REPORT_MODE_BASIC	1
	#define MAX1187X_REPORT_MODE_EXTEND	2
	u8			report_mode;
	struct max1187x_virtual_key *button_data;
};

#endif