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