1
2
3
4
5
6
7
8
9 #ifndef _ALPS_H
10 #define _ALPS_H
11
12 #include <linux/input/mt.h>
13
14 #define ALPS_PROTO_V1 0x100
15 #define ALPS_PROTO_V2 0x200
16 #define ALPS_PROTO_V3 0x300
17 #define ALPS_PROTO_V3_RUSHMORE 0x310
18 #define ALPS_PROTO_V4 0x400
19 #define ALPS_PROTO_V5 0x500
20 #define ALPS_PROTO_V6 0x600
21 #define ALPS_PROTO_V7 0x700
22 #define ALPS_PROTO_V8 0x800
23 #define ALPS_PROTO_V9 0x900
24
25 #define MAX_TOUCHES 4
26
27 #define DOLPHIN_COUNT_PER_ELECTRODE 64
28 #define DOLPHIN_PROFILE_XOFFSET 8
29 #define DOLPHIN_PROFILE_YOFFSET 1
30
31
32
33
34
35
36
37
38
39
40 enum SS4_PACKET_ID {
41 SS4_PACKET_ID_IDLE = 0,
42 SS4_PACKET_ID_ONE,
43 SS4_PACKET_ID_TWO,
44 SS4_PACKET_ID_MULTI,
45 SS4_PACKET_ID_STICK,
46 };
47
48 #define SS4_COUNT_PER_ELECTRODE 256
49 #define SS4_NUMSENSOR_XOFFSET 7
50 #define SS4_NUMSENSOR_YOFFSET 7
51 #define SS4_MIN_PITCH_MM 50
52
53 #define SS4_MASK_NORMAL_BUTTONS 0x07
54
55 #define SS4PLUS_COUNT_PER_ELECTRODE 128
56 #define SS4PLUS_NUMSENSOR_XOFFSET 16
57 #define SS4PLUS_NUMSENSOR_YOFFSET 5
58 #define SS4PLUS_MIN_PITCH_MM 37
59
60 #define IS_SS4PLUS_DEV(_b) (((_b[0]) == 0x73) && \
61 ((_b[1]) == 0x03) && \
62 ((_b[2]) == 0x28) \
63 )
64
65 #define SS4_IS_IDLE_V2(_b) (((_b[0]) == 0x18) && \
66 ((_b[1]) == 0x10) && \
67 ((_b[2]) == 0x00) && \
68 ((_b[3] & 0x88) == 0x08) && \
69 ((_b[4]) == 0x10) && \
70 ((_b[5]) == 0x00) \
71 )
72
73 #define SS4_1F_X_V2(_b) (((_b[0]) & 0x0007) | \
74 ((_b[1] << 3) & 0x0078) | \
75 ((_b[1] << 2) & 0x0380) | \
76 ((_b[2] << 5) & 0x1C00) \
77 )
78
79 #define SS4_1F_Y_V2(_b) (((_b[2]) & 0x000F) | \
80 ((_b[3] >> 2) & 0x0030) | \
81 ((_b[4] << 6) & 0x03C0) | \
82 ((_b[4] << 5) & 0x0C00) \
83 )
84
85 #define SS4_1F_Z_V2(_b) (((_b[5]) & 0x0F) | \
86 ((_b[5] >> 1) & 0x70) | \
87 ((_b[4]) & 0x80) \
88 )
89
90 #define SS4_1F_LFB_V2(_b) (((_b[2] >> 4) & 0x01) == 0x01)
91
92 #define SS4_MF_LF_V2(_b, _i) ((_b[1 + (_i) * 3] & 0x0004) == 0x0004)
93
94 #define SS4_BTN_V2(_b) ((_b[0] >> 5) & SS4_MASK_NORMAL_BUTTONS)
95
96 #define SS4_STD_MF_X_V2(_b, _i) (((_b[0 + (_i) * 3] << 5) & 0x00E0) | \
97 ((_b[1 + _i * 3] << 5) & 0x1F00) \
98 )
99
100 #define SS4_PLUS_STD_MF_X_V2(_b, _i) (((_b[0 + (_i) * 3] << 4) & 0x0070) | \
101 ((_b[1 + (_i) * 3] << 4) & 0x0F80) \
102 )
103
104 #define SS4_STD_MF_Y_V2(_b, _i) (((_b[1 + (_i) * 3] << 3) & 0x0010) | \
105 ((_b[2 + (_i) * 3] << 5) & 0x01E0) | \
106 ((_b[2 + (_i) * 3] << 4) & 0x0E00) \
107 )
108
109 #define SS4_BTL_MF_X_V2(_b, _i) (SS4_STD_MF_X_V2(_b, _i) | \
110 ((_b[0 + (_i) * 3] >> 3) & 0x0010) \
111 )
112
113 #define SS4_PLUS_BTL_MF_X_V2(_b, _i) (SS4_PLUS_STD_MF_X_V2(_b, _i) | \
114 ((_b[0 + (_i) * 3] >> 4) & 0x0008) \
115 )
116
117 #define SS4_BTL_MF_Y_V2(_b, _i) (SS4_STD_MF_Y_V2(_b, _i) | \
118 ((_b[0 + (_i) * 3] >> 3) & 0x0008) \
119 )
120
121 #define SS4_MF_Z_V2(_b, _i) (((_b[1 + (_i) * 3]) & 0x0001) | \
122 ((_b[1 + (_i) * 3] >> 1) & 0x0002) \
123 )
124
125 #define SS4_IS_MF_CONTINUE(_b) ((_b[2] & 0x10) == 0x10)
126 #define SS4_IS_5F_DETECTED(_b) ((_b[2] & 0x10) == 0x10)
127
128 #define SS4_TS_X_V2(_b) (s8)( \
129 ((_b[0] & 0x01) << 7) | \
130 (_b[1] & 0x7F) \
131 )
132
133 #define SS4_TS_Y_V2(_b) -(s8)( \
134 ((_b[3] & 0x01) << 7) | \
135 (_b[2] & 0x7F) \
136 )
137
138 #define SS4_TS_Z_V2(_b) (s8)(_b[4] & 0x7F)
139
140
141 #define SS4_MFPACKET_NO_AX 8160
142 #define SS4_MFPACKET_NO_AY 4080
143 #define SS4_MFPACKET_NO_AX_BL 8176
144 #define SS4_MFPACKET_NO_AY_BL 4088
145 #define SS4_PLUS_MFPACKET_NO_AX 4080
146 #define SS4_PLUS_MFPACKET_NO_AX_BL 4088
147
148
149
150
151
152
153
154
155
156
157 enum V7_PACKET_ID {
158 V7_PACKET_ID_IDLE,
159 V7_PACKET_ID_TWO,
160 V7_PACKET_ID_MULTI,
161 V7_PACKET_ID_NEW,
162 V7_PACKET_ID_UNKNOWN,
163 };
164
165
166
167
168
169
170
171
172
173
174 struct alps_protocol_info {
175 u16 version;
176 u8 byte0, mask0;
177 unsigned int flags;
178 };
179
180
181
182
183
184
185
186
187
188
189 struct alps_model_info {
190 u8 signature[3];
191 struct alps_protocol_info protocol_info;
192 };
193
194
195
196
197
198
199
200
201
202
203
204
205 struct alps_nibble_commands {
206 int command;
207 unsigned char data;
208 };
209
210 struct alps_bitmap_point {
211 int start_bit;
212 int num_bits;
213 };
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232 struct alps_fields {
233 unsigned int x_map;
234 unsigned int y_map;
235 unsigned int fingers;
236
237 int pressure;
238 struct input_mt_pos st;
239 struct input_mt_pos mt[MAX_TOUCHES];
240
241 unsigned int first_mp:1;
242 unsigned int is_mp:1;
243
244 unsigned int left:1;
245 unsigned int right:1;
246 unsigned int middle:1;
247
248 unsigned int ts_left:1;
249 unsigned int ts_right:1;
250 unsigned int ts_middle:1;
251 };
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286 struct alps_data {
287 struct psmouse *psmouse;
288 struct input_dev *dev2;
289 struct input_dev *dev3;
290 char phys2[32];
291 char phys3[32];
292 struct delayed_work dev3_register_work;
293
294
295 const struct alps_nibble_commands *nibble_commands;
296 int addr_command;
297 u16 proto_version;
298 u8 byte0, mask0;
299 u8 dev_id[3];
300 u8 fw_ver[3];
301 int flags;
302 int x_max;
303 int y_max;
304 int x_bits;
305 int y_bits;
306 unsigned int x_res;
307 unsigned int y_res;
308
309 int (*hw_init)(struct psmouse *psmouse);
310 void (*process_packet)(struct psmouse *psmouse);
311 int (*decode_fields)(struct alps_fields *f, unsigned char *p,
312 struct psmouse *psmouse);
313 void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1);
314
315 int prev_fin;
316 int multi_packet;
317 int second_touch;
318 unsigned char multi_data[6];
319 struct alps_fields f;
320 u8 quirks;
321 struct timer_list timer;
322 };
323
324 #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1
325
326 int alps_detect(struct psmouse *psmouse, bool set_properties);
327 int alps_init(struct psmouse *psmouse);
328
329 #endif