Input: ALPS - move {addr,nibble}_command settings into alps_set_defaults()
[deliverable/linux.git] / drivers / input / mouse / alps.c
CommitLineData
1da177e4
LT
1/*
2 * ALPS touchpad PS/2 mouse driver
3 *
4 * Copyright (c) 2003 Neil Brown <neilb@cse.unsw.edu.au>
963f626d 5 * Copyright (c) 2003-2005 Peter Osterlund <petero2@telia.com>
1da177e4
LT
6 * Copyright (c) 2004 Dmitry Torokhov <dtor@mail.ru>
7 * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>
1d9f2626 8 * Copyright (c) 2009 Sebastian Kapfer <sebastian_kapfer@gmx.net>
1da177e4
LT
9 *
10 * ALPS detection, tap switching and status querying info is taken from
11 * tpconfig utility (by C. Scott Ananian and Bruce Kall).
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License version 2 as published by
15 * the Free Software Foundation.
16 */
17
5a0e3ad6 18#include <linux/slab.h>
1da177e4 19#include <linux/input.h>
01ce661f 20#include <linux/input/mt.h>
1da177e4
LT
21#include <linux/serio.h>
22#include <linux/libps2.h>
23
24#include "psmouse.h"
25#include "alps.h"
26
25bded7c
SF
27/*
28 * Definitions for ALPS version 3 and 4 command mode protocol
29 */
01ce661f
SF
30#define ALPS_V3_X_MAX 2000
31#define ALPS_V3_Y_MAX 1400
32
33#define ALPS_BITMAP_X_BITS 15
34#define ALPS_BITMAP_Y_BITS 11
35
25bded7c
SF
36#define ALPS_CMD_NIBBLE_10 0x01f2
37
38static const struct alps_nibble_commands alps_v3_nibble_commands[] = {
39 { PSMOUSE_CMD_SETPOLL, 0x00 }, /* 0 */
40 { PSMOUSE_CMD_RESET_DIS, 0x00 }, /* 1 */
41 { PSMOUSE_CMD_SETSCALE21, 0x00 }, /* 2 */
42 { PSMOUSE_CMD_SETRATE, 0x0a }, /* 3 */
43 { PSMOUSE_CMD_SETRATE, 0x14 }, /* 4 */
44 { PSMOUSE_CMD_SETRATE, 0x28 }, /* 5 */
45 { PSMOUSE_CMD_SETRATE, 0x3c }, /* 6 */
46 { PSMOUSE_CMD_SETRATE, 0x50 }, /* 7 */
47 { PSMOUSE_CMD_SETRATE, 0x64 }, /* 8 */
48 { PSMOUSE_CMD_SETRATE, 0xc8 }, /* 9 */
49 { ALPS_CMD_NIBBLE_10, 0x00 }, /* a */
50 { PSMOUSE_CMD_SETRES, 0x00 }, /* b */
51 { PSMOUSE_CMD_SETRES, 0x01 }, /* c */
52 { PSMOUSE_CMD_SETRES, 0x02 }, /* d */
53 { PSMOUSE_CMD_SETRES, 0x03 }, /* e */
54 { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */
55};
56
57static const struct alps_nibble_commands alps_v4_nibble_commands[] = {
58 { PSMOUSE_CMD_ENABLE, 0x00 }, /* 0 */
59 { PSMOUSE_CMD_RESET_DIS, 0x00 }, /* 1 */
60 { PSMOUSE_CMD_SETSCALE21, 0x00 }, /* 2 */
61 { PSMOUSE_CMD_SETRATE, 0x0a }, /* 3 */
62 { PSMOUSE_CMD_SETRATE, 0x14 }, /* 4 */
63 { PSMOUSE_CMD_SETRATE, 0x28 }, /* 5 */
64 { PSMOUSE_CMD_SETRATE, 0x3c }, /* 6 */
65 { PSMOUSE_CMD_SETRATE, 0x50 }, /* 7 */
66 { PSMOUSE_CMD_SETRATE, 0x64 }, /* 8 */
67 { PSMOUSE_CMD_SETRATE, 0xc8 }, /* 9 */
68 { ALPS_CMD_NIBBLE_10, 0x00 }, /* a */
69 { PSMOUSE_CMD_SETRES, 0x00 }, /* b */
70 { PSMOUSE_CMD_SETRES, 0x01 }, /* c */
71 { PSMOUSE_CMD_SETRES, 0x02 }, /* d */
72 { PSMOUSE_CMD_SETRES, 0x03 }, /* e */
73 { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */
74};
75
76
71bb21b6
ML
77#define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */
78#define ALPS_PASS 0x04 /* device has a pass-through port */
79
80#define ALPS_WHEEL 0x08 /* hardware wheel present */
81#define ALPS_FW_BK_1 0x10 /* front & back buttons present */
82#define ALPS_FW_BK_2 0x20 /* front & back buttons present */
83#define ALPS_FOUR_BUTTONS 0x40 /* 4 direction button present */
1d9f2626
SK
84#define ALPS_PS2_INTERLEAVED 0x80 /* 3-byte PS/2 packet interleaved with
85 6-byte ALPS packet */
1da177e4 86
e38de678 87static const struct alps_model_info alps_model_data[] = {
25bded7c
SF
88 { { 0x32, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */
89 { { 0x33, 0x02, 0x0a }, 0x00, ALPS_PROTO_V1, 0x88, 0xf8, 0 }, /* UMAX-530T */
90 { { 0x53, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
91 { { 0x53, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
92 { { 0x60, 0x03, 0xc8 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, /* HP ze1115 */
93 { { 0x63, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
94 { { 0x63, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
95 { { 0x63, 0x02, 0x28 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */
96 { { 0x63, 0x02, 0x3c }, 0x00, ALPS_PROTO_V2, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */
97 { { 0x63, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */
98 { { 0x63, 0x02, 0x64 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
99 { { 0x63, 0x03, 0xc8 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D800 */
100 { { 0x73, 0x00, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_DUALPOINT }, /* ThinkPad R61 8918-5QG */
101 { { 0x73, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
102 { { 0x73, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */
103 { { 0x20, 0x02, 0x0e }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */
104 { { 0x22, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT },
105 { { 0x22, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */
1d9f2626 106 /* Dell Latitude E5500, E6400, E6500, Precision M4400 */
25bded7c 107 { { 0x62, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf,
1d9f2626 108 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED },
25bded7c
SF
109 { { 0x73, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */
110 { { 0x52, 0x01, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff,
111 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */
112 { { 0x73, 0x02, 0x64 }, 0x9b, ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT },
113 { { 0x73, 0x02, 0x64 }, 0x9d, ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT },
114 { { 0x73, 0x02, 0x64 }, 0x8a, ALPS_PROTO_V4, 0x8f, 0x8f, 0 },
1da177e4
LT
115};
116
24af5cb9
KC
117static void alps_set_abs_params_st(struct alps_data *priv,
118 struct input_dev *dev1);
119static void alps_set_abs_params_mt(struct alps_data *priv,
120 struct input_dev *dev1);
121
1da177e4
LT
122/*
123 * XXX - this entry is suspicious. First byte has zero lower nibble,
124 * which is what a normal mouse would report. Also, the value 0x0e
125 * isn't valid per PS/2 spec.
126 */
127
d4b347b2 128/* Packet formats are described in Documentation/input/alps.txt */
1da177e4 129
99df65e7 130static bool alps_is_valid_first_byte(struct alps_data *priv,
1d9f2626
SK
131 unsigned char data)
132{
99df65e7 133 return (data & priv->mask0) == priv->byte0;
1d9f2626
SK
134}
135
136static void alps_report_buttons(struct psmouse *psmouse,
137 struct input_dev *dev1, struct input_dev *dev2,
138 int left, int right, int middle)
139{
c91ed059
MB
140 struct input_dev *dev;
141
142 /*
143 * If shared button has already been reported on the
144 * other device (dev2) then this event should be also
145 * sent through that device.
146 */
147 dev = test_bit(BTN_LEFT, dev2->key) ? dev2 : dev1;
148 input_report_key(dev, BTN_LEFT, left);
149
150 dev = test_bit(BTN_RIGHT, dev2->key) ? dev2 : dev1;
151 input_report_key(dev, BTN_RIGHT, right);
152
153 dev = test_bit(BTN_MIDDLE, dev2->key) ? dev2 : dev1;
154 input_report_key(dev, BTN_MIDDLE, middle);
155
156 /*
157 * Sync the _other_ device now, we'll do the first
158 * device later once we report the rest of the events.
159 */
160 input_sync(dev2);
1d9f2626
SK
161}
162
25bded7c 163static void alps_process_packet_v1_v2(struct psmouse *psmouse)
1da177e4
LT
164{
165 struct alps_data *priv = psmouse->private;
166 unsigned char *packet = psmouse->packet;
2e5b636b
DT
167 struct input_dev *dev = psmouse->dev;
168 struct input_dev *dev2 = priv->dev2;
1da177e4 169 int x, y, z, ges, fin, left, right, middle;
c30b4c10 170 int back = 0, forward = 0;
1da177e4 171
99df65e7 172 if (priv->proto_version == ALPS_PROTO_V1) {
d2f4012f
YM
173 left = packet[2] & 0x10;
174 right = packet[2] & 0x08;
1da177e4
LT
175 middle = 0;
176 x = packet[1] | ((packet[0] & 0x07) << 7);
177 y = packet[4] | ((packet[3] & 0x07) << 7);
178 z = packet[5];
179 } else {
180 left = packet[3] & 1;
181 right = packet[3] & 2;
182 middle = packet[3] & 4;
183 x = packet[1] | ((packet[2] & 0x78) << (7 - 3));
184 y = packet[4] | ((packet[3] & 0x70) << (7 - 4));
185 z = packet[5];
186 }
187
99df65e7 188 if (priv->flags & ALPS_FW_BK_1) {
3c00bb96
LK
189 back = packet[0] & 0x10;
190 forward = packet[2] & 4;
c30b4c10
ICR
191 }
192
99df65e7 193 if (priv->flags & ALPS_FW_BK_2) {
c30b4c10
ICR
194 back = packet[3] & 4;
195 forward = packet[2] & 4;
196 if ((middle = forward && back))
197 forward = back = 0;
198 }
199
1da177e4
LT
200 ges = packet[2] & 1;
201 fin = packet[2] & 2;
202
99df65e7 203 if ((priv->flags & ALPS_DUALPOINT) && z == 127) {
1da177e4
LT
204 input_report_rel(dev2, REL_X, (x > 383 ? (x - 768) : x));
205 input_report_rel(dev2, REL_Y, -(y > 255 ? (y - 512) : y));
d7ed5d88 206
1d9f2626 207 alps_report_buttons(psmouse, dev2, dev, left, right, middle);
d7ed5d88 208
1da177e4
LT
209 input_sync(dev2);
210 return;
211 }
212
1d9f2626 213 alps_report_buttons(psmouse, dev, dev2, left, right, middle);
d7ed5d88 214
1da177e4 215 /* Convert hardware tap to a reasonable Z value */
71bb21b6
ML
216 if (ges && !fin)
217 z = 40;
1da177e4
LT
218
219 /*
220 * A "tap and drag" operation is reported by the hardware as a transition
221 * from (!fin && ges) to (fin && ges). This should be translated to the
222 * sequence Z>0, Z==0, Z>0, so the Z==0 event has to be generated manually.
223 */
224 if (ges && fin && !priv->prev_fin) {
225 input_report_abs(dev, ABS_X, x);
226 input_report_abs(dev, ABS_Y, y);
227 input_report_abs(dev, ABS_PRESSURE, 0);
228 input_report_key(dev, BTN_TOOL_FINGER, 0);
229 input_sync(dev);
230 }
231 priv->prev_fin = fin;
232
71bb21b6
ML
233 if (z > 30)
234 input_report_key(dev, BTN_TOUCH, 1);
235 if (z < 25)
236 input_report_key(dev, BTN_TOUCH, 0);
1da177e4
LT
237
238 if (z > 0) {
239 input_report_abs(dev, ABS_X, x);
240 input_report_abs(dev, ABS_Y, y);
241 }
242
243 input_report_abs(dev, ABS_PRESSURE, z);
244 input_report_key(dev, BTN_TOOL_FINGER, z > 0);
245
99df65e7 246 if (priv->flags & ALPS_WHEEL)
e6c047b9 247 input_report_rel(dev, REL_WHEEL, ((packet[2] << 1) & 0x08) - ((packet[0] >> 4) & 0x07));
1da177e4 248
99df65e7 249 if (priv->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) {
c30b4c10
ICR
250 input_report_key(dev, BTN_FORWARD, forward);
251 input_report_key(dev, BTN_BACK, back);
1da177e4
LT
252 }
253
99df65e7 254 if (priv->flags & ALPS_FOUR_BUTTONS) {
71bb21b6
ML
255 input_report_key(dev, BTN_0, packet[2] & 4);
256 input_report_key(dev, BTN_1, packet[0] & 0x10);
257 input_report_key(dev, BTN_2, packet[3] & 4);
258 input_report_key(dev, BTN_3, packet[0] & 0x20);
259 }
260
1da177e4
LT
261 input_sync(dev);
262}
263
01ce661f
SF
264/*
265 * Process bitmap data from v3 and v4 protocols. Returns the number of
266 * fingers detected. A return value of 0 means at least one of the
267 * bitmaps was empty.
268 *
269 * The bitmaps don't have enough data to track fingers, so this function
270 * only generates points representing a bounding box of all contacts.
271 * These points are returned in x1, y1, x2, and y2 when the return value
272 * is greater than 0.
273 */
274static int alps_process_bitmap(unsigned int x_map, unsigned int y_map,
275 int *x1, int *y1, int *x2, int *y2)
276{
277 struct alps_bitmap_point {
278 int start_bit;
279 int num_bits;
280 };
281
282 int fingers_x = 0, fingers_y = 0, fingers;
283 int i, bit, prev_bit;
284 struct alps_bitmap_point x_low = {0,}, x_high = {0,};
285 struct alps_bitmap_point y_low = {0,}, y_high = {0,};
286 struct alps_bitmap_point *point;
287
288 if (!x_map || !y_map)
289 return 0;
290
291 *x1 = *y1 = *x2 = *y2 = 0;
292
293 prev_bit = 0;
294 point = &x_low;
295 for (i = 0; x_map != 0; i++, x_map >>= 1) {
296 bit = x_map & 1;
297 if (bit) {
298 if (!prev_bit) {
299 point->start_bit = i;
300 fingers_x++;
301 }
302 point->num_bits++;
303 } else {
304 if (prev_bit)
305 point = &x_high;
306 else
307 point->num_bits = 0;
308 }
309 prev_bit = bit;
310 }
311
312 /*
313 * y bitmap is reversed for what we need (lower positions are in
314 * higher bits), so we process from the top end.
315 */
316 y_map = y_map << (sizeof(y_map) * BITS_PER_BYTE - ALPS_BITMAP_Y_BITS);
317 prev_bit = 0;
318 point = &y_low;
319 for (i = 0; y_map != 0; i++, y_map <<= 1) {
320 bit = y_map & (1 << (sizeof(y_map) * BITS_PER_BYTE - 1));
321 if (bit) {
322 if (!prev_bit) {
323 point->start_bit = i;
324 fingers_y++;
325 }
326 point->num_bits++;
327 } else {
328 if (prev_bit)
329 point = &y_high;
330 else
331 point->num_bits = 0;
332 }
333 prev_bit = bit;
334 }
335
336 /*
337 * Fingers can overlap, so we use the maximum count of fingers
338 * on either axis as the finger count.
339 */
340 fingers = max(fingers_x, fingers_y);
341
342 /*
343 * If total fingers is > 1 but either axis reports only a single
344 * contact, we have overlapping or adjacent fingers. For the
345 * purposes of creating a bounding box, divide the single contact
346 * (roughly) equally between the two points.
347 */
348 if (fingers > 1) {
349 if (fingers_x == 1) {
350 i = x_low.num_bits / 2;
351 x_low.num_bits = x_low.num_bits - i;
352 x_high.start_bit = x_low.start_bit + i;
353 x_high.num_bits = max(i, 1);
354 } else if (fingers_y == 1) {
355 i = y_low.num_bits / 2;
356 y_low.num_bits = y_low.num_bits - i;
357 y_high.start_bit = y_low.start_bit + i;
358 y_high.num_bits = max(i, 1);
359 }
360 }
361
362 *x1 = (ALPS_V3_X_MAX * (2 * x_low.start_bit + x_low.num_bits - 1)) /
363 (2 * (ALPS_BITMAP_X_BITS - 1));
364 *y1 = (ALPS_V3_Y_MAX * (2 * y_low.start_bit + y_low.num_bits - 1)) /
365 (2 * (ALPS_BITMAP_Y_BITS - 1));
366
367 if (fingers > 1) {
368 *x2 = (ALPS_V3_X_MAX * (2 * x_high.start_bit + x_high.num_bits - 1)) /
369 (2 * (ALPS_BITMAP_X_BITS - 1));
370 *y2 = (ALPS_V3_Y_MAX * (2 * y_high.start_bit + y_high.num_bits - 1)) /
371 (2 * (ALPS_BITMAP_Y_BITS - 1));
372 }
373
374 return fingers;
375}
376
377static void alps_set_slot(struct input_dev *dev, int slot, bool active,
378 int x, int y)
379{
380 input_mt_slot(dev, slot);
381 input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
382 if (active) {
383 input_report_abs(dev, ABS_MT_POSITION_X, x);
384 input_report_abs(dev, ABS_MT_POSITION_Y, y);
385 }
386}
387
388static void alps_report_semi_mt_data(struct input_dev *dev, int num_fingers,
389 int x1, int y1, int x2, int y2)
390{
391 alps_set_slot(dev, 0, num_fingers != 0, x1, y1);
392 alps_set_slot(dev, 1, num_fingers == 2, x2, y2);
393}
394
25bded7c
SF
395static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
396{
397 struct alps_data *priv = psmouse->private;
398 unsigned char *packet = psmouse->packet;
399 struct input_dev *dev = priv->dev2;
400 int x, y, z, left, right, middle;
401
402 /* Sanity check packet */
403 if (!(packet[0] & 0x40)) {
404 psmouse_dbg(psmouse, "Bad trackstick packet, discarding\n");
405 return;
406 }
407
408 /*
409 * There's a special packet that seems to indicate the end
410 * of a stream of trackstick data. Filter these out.
411 */
412 if (packet[1] == 0x7f && packet[2] == 0x7f && packet[4] == 0x7f)
413 return;
414
415 x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f));
416 y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f));
417 z = (packet[4] & 0x7c) >> 2;
418
419 /*
420 * The x and y values tend to be quite large, and when used
421 * alone the trackstick is difficult to use. Scale them down
422 * to compensate.
423 */
424 x /= 8;
425 y /= 8;
426
427 input_report_rel(dev, REL_X, x);
428 input_report_rel(dev, REL_Y, -y);
429
430 /*
431 * Most ALPS models report the trackstick buttons in the touchpad
432 * packets, but a few report them here. No reliable way has been
433 * found to differentiate between the models upfront, so we enable
434 * the quirk in response to seeing a button press in the trackstick
435 * packet.
436 */
437 left = packet[3] & 0x01;
438 right = packet[3] & 0x02;
439 middle = packet[3] & 0x04;
440
441 if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) &&
442 (left || right || middle))
443 priv->quirks |= ALPS_QUIRK_TRACKSTICK_BUTTONS;
444
445 if (priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) {
446 input_report_key(dev, BTN_LEFT, left);
447 input_report_key(dev, BTN_RIGHT, right);
448 input_report_key(dev, BTN_MIDDLE, middle);
449 }
450
451 input_sync(dev);
452 return;
453}
454
455static void alps_process_touchpad_packet_v3(struct psmouse *psmouse)
456{
457 struct alps_data *priv = psmouse->private;
458 unsigned char *packet = psmouse->packet;
459 struct input_dev *dev = psmouse->dev;
460 struct input_dev *dev2 = priv->dev2;
461 int x, y, z;
462 int left, right, middle;
01ce661f
SF
463 int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
464 int fingers = 0, bmap_fingers;
465 unsigned int x_bitmap, y_bitmap;
25bded7c
SF
466
467 /*
01ce661f
SF
468 * There's no single feature of touchpad position and bitmap packets
469 * that can be used to distinguish between them. We rely on the fact
470 * that a bitmap packet should always follow a position packet with
471 * bit 6 of packet[4] set.
25bded7c
SF
472 */
473 if (priv->multi_packet) {
25bded7c
SF
474 /*
475 * Sometimes a position packet will indicate a multi-packet
476 * sequence, but then what follows is another position
477 * packet. Check for this, and when it happens process the
478 * position packet as usual.
479 */
480 if (packet[0] & 0x40) {
01ce661f
SF
481 fingers = (packet[5] & 0x3) + 1;
482 x_bitmap = ((packet[4] & 0x7e) << 8) |
483 ((packet[1] & 0x7f) << 2) |
484 ((packet[0] & 0x30) >> 4);
485 y_bitmap = ((packet[3] & 0x70) << 4) |
486 ((packet[2] & 0x7f) << 1) |
487 (packet[4] & 0x01);
488
489 bmap_fingers = alps_process_bitmap(x_bitmap, y_bitmap,
490 &x1, &y1, &x2, &y2);
491
25bded7c 492 /*
01ce661f
SF
493 * We shouldn't report more than one finger if
494 * we don't have two coordinates.
25bded7c 495 */
01ce661f
SF
496 if (fingers > 1 && bmap_fingers < 2)
497 fingers = bmap_fingers;
498
499 /* Now process position packet */
500 packet = priv->multi_data;
501 } else {
502 priv->multi_packet = 0;
25bded7c
SF
503 }
504 }
505
01ce661f
SF
506 /*
507 * Bit 6 of byte 0 is not usually set in position packets. The only
508 * times it seems to be set is in situations where the data is
509 * suspect anyway, e.g. a palm resting flat on the touchpad. Given
510 * this combined with the fact that this bit is useful for filtering
511 * out misidentified bitmap packets, we reject anything with this
512 * bit set.
513 */
514 if (packet[0] & 0x40)
515 return;
516
517 if (!priv->multi_packet && (packet[4] & 0x40)) {
25bded7c 518 priv->multi_packet = 1;
01ce661f
SF
519 memcpy(priv->multi_data, packet, sizeof(priv->multi_data));
520 return;
521 }
522
523 priv->multi_packet = 0;
25bded7c
SF
524
525 left = packet[3] & 0x01;
526 right = packet[3] & 0x02;
527 middle = packet[3] & 0x04;
528
529 x = ((packet[1] & 0x7f) << 4) | ((packet[4] & 0x30) >> 2) |
530 ((packet[0] & 0x30) >> 4);
531 y = ((packet[2] & 0x7f) << 4) | (packet[4] & 0x0f);
532 z = packet[5] & 0x7f;
533
534 /*
535 * Sometimes the hardware sends a single packet with z = 0
536 * in the middle of a stream. Real releases generate packets
537 * with x, y, and z all zero, so these seem to be flukes.
538 * Ignore them.
539 */
540 if (x && y && !z)
541 return;
542
01ce661f
SF
543 /*
544 * If we don't have MT data or the bitmaps were empty, we have
545 * to rely on ST data.
546 */
547 if (!fingers) {
548 x1 = x;
549 y1 = y;
550 fingers = z > 0 ? 1 : 0;
551 }
552
25bded7c
SF
553 if (z >= 64)
554 input_report_key(dev, BTN_TOUCH, 1);
555 else
556 input_report_key(dev, BTN_TOUCH, 0);
557
01ce661f
SF
558 alps_report_semi_mt_data(dev, fingers, x1, y1, x2, y2);
559
616575c2 560 input_mt_report_finger_count(dev, fingers);
01ce661f
SF
561
562 input_report_key(dev, BTN_LEFT, left);
563 input_report_key(dev, BTN_RIGHT, right);
564 input_report_key(dev, BTN_MIDDLE, middle);
565
25bded7c
SF
566 if (z > 0) {
567 input_report_abs(dev, ABS_X, x);
568 input_report_abs(dev, ABS_Y, y);
569 }
570 input_report_abs(dev, ABS_PRESSURE, z);
571
25bded7c
SF
572 input_sync(dev);
573
574 if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) {
575 left = packet[3] & 0x10;
576 right = packet[3] & 0x20;
577 middle = packet[3] & 0x40;
578
579 input_report_key(dev2, BTN_LEFT, left);
580 input_report_key(dev2, BTN_RIGHT, right);
581 input_report_key(dev2, BTN_MIDDLE, middle);
582 input_sync(dev2);
583 }
584}
585
586static void alps_process_packet_v3(struct psmouse *psmouse)
587{
588 unsigned char *packet = psmouse->packet;
589
590 /*
591 * v3 protocol packets come in three types, two representing
592 * touchpad data and one representing trackstick data.
593 * Trackstick packets seem to be distinguished by always
594 * having 0x3f in the last byte. This value has never been
595 * observed in the last byte of either of the other types
596 * of packets.
597 */
598 if (packet[5] == 0x3f) {
599 alps_process_trackstick_packet_v3(psmouse);
600 return;
601 }
602
603 alps_process_touchpad_packet_v3(psmouse);
604}
605
606static void alps_process_packet_v4(struct psmouse *psmouse)
607{
3b7e09fa 608 struct alps_data *priv = psmouse->private;
25bded7c
SF
609 unsigned char *packet = psmouse->packet;
610 struct input_dev *dev = psmouse->dev;
3b7e09fa 611 int offset;
25bded7c
SF
612 int x, y, z;
613 int left, right;
3b7e09fa
GP
614 int x1, y1, x2, y2;
615 int fingers = 0;
616 unsigned int x_bitmap, y_bitmap;
617
618 /*
619 * v4 has a 6-byte encoding for bitmap data, but this data is
620 * broken up between 3 normal packets. Use priv->multi_packet to
621 * track our position in the bitmap packet.
622 */
623 if (packet[6] & 0x40) {
624 /* sync, reset position */
625 priv->multi_packet = 0;
626 }
627
628 if (WARN_ON_ONCE(priv->multi_packet > 2))
629 return;
630
631 offset = 2 * priv->multi_packet;
632 priv->multi_data[offset] = packet[6];
633 priv->multi_data[offset + 1] = packet[7];
634
635 if (++priv->multi_packet > 2) {
636 priv->multi_packet = 0;
637
638 x_bitmap = ((priv->multi_data[2] & 0x1f) << 10) |
639 ((priv->multi_data[3] & 0x60) << 3) |
640 ((priv->multi_data[0] & 0x3f) << 2) |
641 ((priv->multi_data[1] & 0x60) >> 5);
642 y_bitmap = ((priv->multi_data[5] & 0x01) << 10) |
643 ((priv->multi_data[3] & 0x1f) << 5) |
644 (priv->multi_data[1] & 0x1f);
645
646 fingers = alps_process_bitmap(x_bitmap, y_bitmap,
647 &x1, &y1, &x2, &y2);
648
649 /* Store MT data.*/
650 priv->fingers = fingers;
651 priv->x1 = x1;
652 priv->x2 = x2;
653 priv->y1 = y1;
654 priv->y2 = y2;
655 }
25bded7c
SF
656
657 left = packet[4] & 0x01;
658 right = packet[4] & 0x02;
659
660 x = ((packet[1] & 0x7f) << 4) | ((packet[3] & 0x30) >> 2) |
661 ((packet[0] & 0x30) >> 4);
662 y = ((packet[2] & 0x7f) << 4) | (packet[3] & 0x0f);
663 z = packet[5] & 0x7f;
664
3b7e09fa
GP
665 /*
666 * If there were no contacts in the bitmap, use ST
667 * points in MT reports.
668 * If there were two contacts or more, report MT data.
669 */
670 if (priv->fingers < 2) {
671 x1 = x;
672 y1 = y;
673 fingers = z > 0 ? 1 : 0;
674 } else {
675 fingers = priv->fingers;
676 x1 = priv->x1;
677 x2 = priv->x2;
678 y1 = priv->y1;
679 y2 = priv->y2;
680 }
681
25bded7c
SF
682 if (z >= 64)
683 input_report_key(dev, BTN_TOUCH, 1);
684 else
685 input_report_key(dev, BTN_TOUCH, 0);
686
3b7e09fa
GP
687 alps_report_semi_mt_data(dev, fingers, x1, y1, x2, y2);
688
616575c2 689 input_mt_report_finger_count(dev, fingers);
3b7e09fa
GP
690
691 input_report_key(dev, BTN_LEFT, left);
692 input_report_key(dev, BTN_RIGHT, right);
693
25bded7c
SF
694 if (z > 0) {
695 input_report_abs(dev, ABS_X, x);
696 input_report_abs(dev, ABS_Y, y);
697 }
698 input_report_abs(dev, ABS_PRESSURE, z);
699
25bded7c
SF
700 input_sync(dev);
701}
702
1d9f2626
SK
703static void alps_report_bare_ps2_packet(struct psmouse *psmouse,
704 unsigned char packet[],
705 bool report_buttons)
706{
707 struct alps_data *priv = psmouse->private;
708 struct input_dev *dev2 = priv->dev2;
709
710 if (report_buttons)
711 alps_report_buttons(psmouse, dev2, psmouse->dev,
712 packet[0] & 1, packet[0] & 2, packet[0] & 4);
713
714 input_report_rel(dev2, REL_X,
715 packet[1] ? packet[1] - ((packet[0] << 4) & 0x100) : 0);
716 input_report_rel(dev2, REL_Y,
717 packet[2] ? ((packet[0] << 3) & 0x100) - packet[2] : 0);
718
719 input_sync(dev2);
720}
721
722static psmouse_ret_t alps_handle_interleaved_ps2(struct psmouse *psmouse)
723{
724 struct alps_data *priv = psmouse->private;
725
726 if (psmouse->pktcnt < 6)
727 return PSMOUSE_GOOD_DATA;
728
729 if (psmouse->pktcnt == 6) {
730 /*
731 * Start a timer to flush the packet if it ends up last
732 * 6-byte packet in the stream. Timer needs to fire
733 * psmouse core times out itself. 20 ms should be enough
734 * to decide if we are getting more data or not.
735 */
736 mod_timer(&priv->timer, jiffies + msecs_to_jiffies(20));
737 return PSMOUSE_GOOD_DATA;
738 }
739
740 del_timer(&priv->timer);
741
742 if (psmouse->packet[6] & 0x80) {
743
744 /*
745 * Highest bit is set - that means we either had
746 * complete ALPS packet and this is start of the
747 * next packet or we got garbage.
748 */
749
750 if (((psmouse->packet[3] |
751 psmouse->packet[4] |
752 psmouse->packet[5]) & 0x80) ||
99df65e7 753 (!alps_is_valid_first_byte(priv, psmouse->packet[6]))) {
b5d21704 754 psmouse_dbg(psmouse,
3b112923
AS
755 "refusing packet %4ph (suspected interleaved ps/2)\n",
756 psmouse->packet + 3);
1d9f2626
SK
757 return PSMOUSE_BAD_DATA;
758 }
759
24af5cb9 760 priv->process_packet(psmouse);
1d9f2626
SK
761
762 /* Continue with the next packet */
763 psmouse->packet[0] = psmouse->packet[6];
764 psmouse->pktcnt = 1;
765
766 } else {
767
768 /*
769 * High bit is 0 - that means that we indeed got a PS/2
770 * packet in the middle of ALPS packet.
771 *
772 * There is also possibility that we got 6-byte ALPS
773 * packet followed by 3-byte packet from trackpoint. We
774 * can not distinguish between these 2 scenarios but
b5d21704 775 * because the latter is unlikely to happen in course of
1d9f2626
SK
776 * normal operation (user would need to press all
777 * buttons on the pad and start moving trackpoint
778 * without touching the pad surface) we assume former.
779 * Even if we are wrong the wost thing that would happen
780 * the cursor would jump but we should not get protocol
b5d21704 781 * de-synchronization.
1d9f2626
SK
782 */
783
784 alps_report_bare_ps2_packet(psmouse, &psmouse->packet[3],
785 false);
786
787 /*
788 * Continue with the standard ALPS protocol handling,
789 * but make sure we won't process it as an interleaved
790 * packet again, which may happen if all buttons are
791 * pressed. To avoid this let's reset the 4th bit which
792 * is normally 1.
793 */
794 psmouse->packet[3] = psmouse->packet[6] & 0xf7;
795 psmouse->pktcnt = 4;
796 }
797
798 return PSMOUSE_GOOD_DATA;
799}
800
801static void alps_flush_packet(unsigned long data)
802{
803 struct psmouse *psmouse = (struct psmouse *)data;
24af5cb9 804 struct alps_data *priv = psmouse->private;
1d9f2626
SK
805
806 serio_pause_rx(psmouse->ps2dev.serio);
807
b46615fe 808 if (psmouse->pktcnt == psmouse->pktsize) {
1d9f2626
SK
809
810 /*
811 * We did not any more data in reasonable amount of time.
812 * Validate the last 3 bytes and process as a standard
813 * ALPS packet.
814 */
815 if ((psmouse->packet[3] |
816 psmouse->packet[4] |
817 psmouse->packet[5]) & 0x80) {
b5d21704 818 psmouse_dbg(psmouse,
3b112923
AS
819 "refusing packet %3ph (suspected interleaved ps/2)\n",
820 psmouse->packet + 3);
1d9f2626 821 } else {
24af5cb9 822 priv->process_packet(psmouse);
1d9f2626
SK
823 }
824 psmouse->pktcnt = 0;
825 }
826
827 serio_continue_rx(psmouse->ps2dev.serio);
828}
829
7d12e780 830static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
1da177e4
LT
831{
832 struct alps_data *priv = psmouse->private;
833
834 if ((psmouse->packet[0] & 0xc8) == 0x08) { /* PS/2 packet */
835 if (psmouse->pktcnt == 3) {
1d9f2626
SK
836 alps_report_bare_ps2_packet(psmouse, psmouse->packet,
837 true);
1da177e4
LT
838 return PSMOUSE_FULL_PACKET;
839 }
840 return PSMOUSE_GOOD_DATA;
841 }
842
1d9f2626
SK
843 /* Check for PS/2 packet stuffed in the middle of ALPS packet. */
844
99df65e7 845 if ((priv->flags & ALPS_PS2_INTERLEAVED) &&
1d9f2626
SK
846 psmouse->pktcnt >= 4 && (psmouse->packet[3] & 0x0f) == 0x0f) {
847 return alps_handle_interleaved_ps2(psmouse);
848 }
849
99df65e7 850 if (!alps_is_valid_first_byte(priv, psmouse->packet[0])) {
b5d21704
DT
851 psmouse_dbg(psmouse,
852 "refusing packet[0] = %x (mask0 = %x, byte0 = %x)\n",
99df65e7 853 psmouse->packet[0], priv->mask0, priv->byte0);
1da177e4 854 return PSMOUSE_BAD_DATA;
1d9f2626 855 }
1da177e4 856
b46615fe
SF
857 /* Bytes 2 - pktsize should have 0 in the highest bit */
858 if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize &&
1d9f2626 859 (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
b5d21704
DT
860 psmouse_dbg(psmouse, "refusing packet[%i] = %x\n",
861 psmouse->pktcnt - 1,
862 psmouse->packet[psmouse->pktcnt - 1]);
1da177e4 863 return PSMOUSE_BAD_DATA;
1d9f2626 864 }
1da177e4 865
b46615fe 866 if (psmouse->pktcnt == psmouse->pktsize) {
24af5cb9 867 priv->process_packet(psmouse);
1da177e4
LT
868 return PSMOUSE_FULL_PACKET;
869 }
870
871 return PSMOUSE_GOOD_DATA;
872}
873
25bded7c
SF
874static int alps_command_mode_send_nibble(struct psmouse *psmouse, int nibble)
875{
876 struct ps2dev *ps2dev = &psmouse->ps2dev;
877 struct alps_data *priv = psmouse->private;
878 int command;
879 unsigned char *param;
880 unsigned char dummy[4];
881
882 BUG_ON(nibble > 0xf);
883
884 command = priv->nibble_commands[nibble].command;
885 param = (command & 0x0f00) ?
886 dummy : (unsigned char *)&priv->nibble_commands[nibble].data;
887
888 if (ps2_command(ps2dev, param, command))
889 return -1;
890
891 return 0;
892}
893
894static int alps_command_mode_set_addr(struct psmouse *psmouse, int addr)
895{
896 struct ps2dev *ps2dev = &psmouse->ps2dev;
897 struct alps_data *priv = psmouse->private;
898 int i, nibble;
899
900 if (ps2_command(ps2dev, NULL, priv->addr_command))
901 return -1;
902
903 for (i = 12; i >= 0; i -= 4) {
904 nibble = (addr >> i) & 0xf;
905 if (alps_command_mode_send_nibble(psmouse, nibble))
906 return -1;
907 }
908
909 return 0;
910}
911
912static int __alps_command_mode_read_reg(struct psmouse *psmouse, int addr)
913{
914 struct ps2dev *ps2dev = &psmouse->ps2dev;
915 unsigned char param[4];
916
917 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
918 return -1;
919
920 /*
921 * The address being read is returned in the first two bytes
922 * of the result. Check that this address matches the expected
923 * address.
924 */
925 if (addr != ((param[0] << 8) | param[1]))
926 return -1;
927
928 return param[2];
929}
930
931static int alps_command_mode_read_reg(struct psmouse *psmouse, int addr)
932{
933 if (alps_command_mode_set_addr(psmouse, addr))
934 return -1;
935 return __alps_command_mode_read_reg(psmouse, addr);
936}
937
938static int __alps_command_mode_write_reg(struct psmouse *psmouse, u8 value)
939{
940 if (alps_command_mode_send_nibble(psmouse, (value >> 4) & 0xf))
941 return -1;
942 if (alps_command_mode_send_nibble(psmouse, value & 0xf))
943 return -1;
944 return 0;
945}
946
947static int alps_command_mode_write_reg(struct psmouse *psmouse, int addr,
948 u8 value)
949{
950 if (alps_command_mode_set_addr(psmouse, addr))
951 return -1;
952 return __alps_command_mode_write_reg(psmouse, value);
953}
954
24ba9707
KC
955static int alps_rpt_cmd(struct psmouse *psmouse, int init_command,
956 int repeated_command, unsigned char *param)
957{
958 struct ps2dev *ps2dev = &psmouse->ps2dev;
959
960 param[0] = 0;
961 if (init_command && ps2_command(ps2dev, param, init_command))
962 return -EIO;
963
964 if (ps2_command(ps2dev, NULL, repeated_command) ||
965 ps2_command(ps2dev, NULL, repeated_command) ||
966 ps2_command(ps2dev, NULL, repeated_command))
967 return -EIO;
968
969 param[0] = param[1] = param[2] = 0xff;
970 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
971 return -EIO;
972
973 psmouse_dbg(psmouse, "%2.2X report: %2.2x %2.2x %2.2x\n",
974 repeated_command, param[0], param[1], param[2]);
975 return 0;
976}
977
25bded7c
SF
978static int alps_enter_command_mode(struct psmouse *psmouse,
979 unsigned char *resp)
980{
981 unsigned char param[4];
25bded7c 982
24ba9707 983 if (alps_rpt_cmd(psmouse, 0, PSMOUSE_CMD_RESET_WRAP, param)) {
25bded7c
SF
984 psmouse_err(psmouse, "failed to enter command mode\n");
985 return -1;
986 }
987
988 if (param[0] != 0x88 && param[1] != 0x07) {
989 psmouse_dbg(psmouse,
24ba9707 990 "unknown response while entering command mode\n");
25bded7c
SF
991 return -1;
992 }
993
994 if (resp)
995 *resp = param[2];
996 return 0;
997}
998
999static inline int alps_exit_command_mode(struct psmouse *psmouse)
1000{
1001 struct ps2dev *ps2dev = &psmouse->ps2dev;
1002 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSTREAM))
1003 return -1;
1004 return 0;
1005}
1006
1da177e4
LT
1007/*
1008 * For DualPoint devices select the device that should respond to
1009 * subsequent commands. It looks like glidepad is behind stickpointer,
1010 * I'd thought it would be other way around...
1011 */
25bded7c 1012static int alps_passthrough_mode_v2(struct psmouse *psmouse, bool enable)
1da177e4
LT
1013{
1014 struct ps2dev *ps2dev = &psmouse->ps2dev;
1da177e4
LT
1015 int cmd = enable ? PSMOUSE_CMD_SETSCALE21 : PSMOUSE_CMD_SETSCALE11;
1016
1017 if (ps2_command(ps2dev, NULL, cmd) ||
1018 ps2_command(ps2dev, NULL, cmd) ||
1019 ps2_command(ps2dev, NULL, cmd) ||
1020 ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE))
1021 return -1;
1022
1023 /* we may get 3 more bytes, just ignore them */
c611763d 1024 ps2_drain(ps2dev, 3, 100);
1da177e4
LT
1025
1026 return 0;
1027}
1028
25bded7c 1029static int alps_absolute_mode_v1_v2(struct psmouse *psmouse)
1da177e4
LT
1030{
1031 struct ps2dev *ps2dev = &psmouse->ps2dev;
1032
1033 /* Try ALPS magic knock - 4 disable before enable */
1034 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
1035 ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
1036 ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
1037 ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
1038 ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE))
1039 return -1;
1040
1041 /*
1042 * Switch mouse to poll (remote) mode so motion data will not
1043 * get in our way
1044 */
1045 return ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETPOLL);
1046}
1047
1048static int alps_get_status(struct psmouse *psmouse, char *param)
1049{
1da177e4 1050 /* Get status: 0xF5 0xF5 0xF5 0xE9 */
24ba9707 1051 if (alps_rpt_cmd(psmouse, 0, PSMOUSE_CMD_DISABLE, param))
1da177e4
LT
1052 return -1;
1053
1da177e4
LT
1054 return 0;
1055}
1056
1057/*
1058 * Turn touchpad tapping on or off. The sequences are:
1059 * 0xE9 0xF5 0xF5 0xF3 0x0A to enable,
1060 * 0xE9 0xF5 0xF5 0xE8 0x00 to disable.
1061 * My guess that 0xE9 (GetInfo) is here as a sync point.
1062 * For models that also have stickpointer (DualPoints) its tapping
1063 * is controlled separately (0xE6 0xE6 0xE6 0xF3 0x14|0x0A) but
1064 * we don't fiddle with it.
1065 */
1066static int alps_tap_mode(struct psmouse *psmouse, int enable)
1067{
1068 struct ps2dev *ps2dev = &psmouse->ps2dev;
1069 int cmd = enable ? PSMOUSE_CMD_SETRATE : PSMOUSE_CMD_SETRES;
1070 unsigned char tap_arg = enable ? 0x0A : 0x00;
1071 unsigned char param[4];
1072
1073 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO) ||
1074 ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
1075 ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
1076 ps2_command(ps2dev, &tap_arg, cmd))
1077 return -1;
1078
1079 if (alps_get_status(psmouse, param))
1080 return -1;
1081
1082 return 0;
1083}
1084
f0d5c6f4
DT
1085/*
1086 * alps_poll() - poll the touchpad for current motion packet.
1087 * Used in resync.
1088 */
1089static int alps_poll(struct psmouse *psmouse)
1090{
1091 struct alps_data *priv = psmouse->private;
b46615fe 1092 unsigned char buf[sizeof(psmouse->packet)];
b7802c5c 1093 bool poll_failed;
f0d5c6f4 1094
99df65e7 1095 if (priv->flags & ALPS_PASS)
25bded7c 1096 alps_passthrough_mode_v2(psmouse, true);
f0d5c6f4
DT
1097
1098 poll_failed = ps2_command(&psmouse->ps2dev, buf,
1099 PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)) < 0;
1100
99df65e7 1101 if (priv->flags & ALPS_PASS)
25bded7c 1102 alps_passthrough_mode_v2(psmouse, false);
f0d5c6f4 1103
99df65e7 1104 if (poll_failed || (buf[0] & priv->mask0) != priv->byte0)
f0d5c6f4
DT
1105 return -1;
1106
1107 if ((psmouse->badbyte & 0xc8) == 0x08) {
1108/*
1109 * Poll the track stick ...
1110 */
1111 if (ps2_command(&psmouse->ps2dev, buf, PSMOUSE_CMD_POLL | (3 << 8)))
1112 return -1;
1113 }
1114
1115 memcpy(psmouse->packet, buf, sizeof(buf));
1116 return 0;
1117}
1118
25bded7c 1119static int alps_hw_init_v1_v2(struct psmouse *psmouse)
1da177e4
LT
1120{
1121 struct alps_data *priv = psmouse->private;
f3a5c73d 1122
99df65e7 1123 if ((priv->flags & ALPS_PASS) &&
25bded7c 1124 alps_passthrough_mode_v2(psmouse, true)) {
1da177e4 1125 return -1;
b7802c5c 1126 }
1da177e4 1127
b7802c5c 1128 if (alps_tap_mode(psmouse, true)) {
b5d21704 1129 psmouse_warn(psmouse, "Failed to enable hardware tapping\n");
1da177e4 1130 return -1;
963f626d 1131 }
1da177e4 1132
25bded7c 1133 if (alps_absolute_mode_v1_v2(psmouse)) {
b5d21704 1134 psmouse_err(psmouse, "Failed to enable absolute mode\n");
1da177e4
LT
1135 return -1;
1136 }
1137
99df65e7 1138 if ((priv->flags & ALPS_PASS) &&
25bded7c 1139 alps_passthrough_mode_v2(psmouse, false)) {
1da177e4 1140 return -1;
b7802c5c 1141 }
1da177e4 1142
1e0c5b12
DT
1143 /* ALPS needs stream mode, otherwise it won't report any data */
1144 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSTREAM)) {
b5d21704 1145 psmouse_err(psmouse, "Failed to enable stream mode\n");
1e0c5b12
DT
1146 return -1;
1147 }
1148
1149 return 0;
1150}
1151
25bded7c
SF
1152/*
1153 * Enable or disable passthrough mode to the trackstick. Must be in
1154 * command mode when calling this function.
1155 */
1156static int alps_passthrough_mode_v3(struct psmouse *psmouse, bool enable)
1157{
1158 int reg_val;
1159
1160 reg_val = alps_command_mode_read_reg(psmouse, 0x0008);
1161 if (reg_val == -1)
1162 return -1;
1163
1164 if (enable)
1165 reg_val |= 0x01;
1166 else
1167 reg_val &= ~0x01;
1168
1169 if (__alps_command_mode_write_reg(psmouse, reg_val))
1170 return -1;
1171
1172 return 0;
1173}
1174
1175/* Must be in command mode when calling this function */
1176static int alps_absolute_mode_v3(struct psmouse *psmouse)
1177{
1178 int reg_val;
1179
1180 reg_val = alps_command_mode_read_reg(psmouse, 0x0004);
1181 if (reg_val == -1)
1182 return -1;
1183
1184 reg_val |= 0x06;
1185 if (__alps_command_mode_write_reg(psmouse, reg_val))
1186 return -1;
1187
1188 return 0;
1189}
1190
1191static int alps_hw_init_v3(struct psmouse *psmouse)
1192{
25bded7c
SF
1193 struct ps2dev *ps2dev = &psmouse->ps2dev;
1194 int reg_val;
1195 unsigned char param[4];
1196
25bded7c
SF
1197 if (alps_enter_command_mode(psmouse, NULL))
1198 goto error;
1199
1200 /* Check for trackstick */
1201 reg_val = alps_command_mode_read_reg(psmouse, 0x0008);
1202 if (reg_val == -1)
1203 goto error;
1204 if (reg_val & 0x80) {
1205 if (alps_passthrough_mode_v3(psmouse, true))
1206 goto error;
1207 if (alps_exit_command_mode(psmouse))
1208 goto error;
1209
1210 /*
1211 * E7 report for the trackstick
1212 *
1213 * There have been reports of failures to seem to trace back
1214 * to the above trackstick check failing. When these occur
1215 * this E7 report fails, so when that happens we continue
1216 * with the assumption that there isn't a trackstick after
1217 * all.
1218 */
1219 param[0] = 0x64;
1220 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
1221 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
1222 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
1223 ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {
1224 psmouse_warn(psmouse, "trackstick E7 report failed\n");
1225 } else {
1226 psmouse_dbg(psmouse,
1227 "trackstick E7 report: %2.2x %2.2x %2.2x\n",
1228 param[0], param[1], param[2]);
1229
1230 /*
1231 * Not sure what this does, but it is absolutely
1232 * essential. Without it, the touchpad does not
1233 * work at all and the trackstick just emits normal
1234 * PS/2 packets.
1235 */
1236 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
1237 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
1238 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
1239 alps_command_mode_send_nibble(psmouse, 0x9) ||
1240 alps_command_mode_send_nibble(psmouse, 0x4)) {
1241 psmouse_err(psmouse,
1242 "Error sending magic E6 sequence\n");
1243 goto error_passthrough;
1244 }
1245 }
1246
1247 if (alps_enter_command_mode(psmouse, NULL))
1248 goto error_passthrough;
1249 if (alps_passthrough_mode_v3(psmouse, false))
1250 goto error;
1251 }
1252
1253 if (alps_absolute_mode_v3(psmouse)) {
1254 psmouse_err(psmouse, "Failed to enter absolute mode\n");
1255 goto error;
1256 }
1257
1258 reg_val = alps_command_mode_read_reg(psmouse, 0x0006);
1259 if (reg_val == -1)
1260 goto error;
1261 if (__alps_command_mode_write_reg(psmouse, reg_val | 0x01))
1262 goto error;
1263
1264 reg_val = alps_command_mode_read_reg(psmouse, 0x0007);
1265 if (reg_val == -1)
1266 goto error;
1267 if (__alps_command_mode_write_reg(psmouse, reg_val | 0x01))
1268 goto error;
1269
1270 if (alps_command_mode_read_reg(psmouse, 0x0144) == -1)
1271 goto error;
1272 if (__alps_command_mode_write_reg(psmouse, 0x04))
1273 goto error;
1274
1275 if (alps_command_mode_read_reg(psmouse, 0x0159) == -1)
1276 goto error;
1277 if (__alps_command_mode_write_reg(psmouse, 0x03))
1278 goto error;
1279
1280 if (alps_command_mode_read_reg(psmouse, 0x0163) == -1)
1281 goto error;
1282 if (alps_command_mode_write_reg(psmouse, 0x0163, 0x03))
1283 goto error;
1284
1285 if (alps_command_mode_read_reg(psmouse, 0x0162) == -1)
1286 goto error;
1287 if (alps_command_mode_write_reg(psmouse, 0x0162, 0x04))
1288 goto error;
1289
1290 /*
1291 * This ensures the trackstick packets are in the format
1292 * supported by this driver. If bit 1 isn't set the packet
1293 * format is different.
1294 */
1295 if (alps_command_mode_write_reg(psmouse, 0x0008, 0x82))
1296 goto error;
1297
1298 alps_exit_command_mode(psmouse);
1299
1300 /* Set rate and enable data reporting */
1301 param[0] = 0x64;
1302 if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE) ||
1303 ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) {
1304 psmouse_err(psmouse, "Failed to enable data reporting\n");
1305 return -1;
1306 }
1307
1308 return 0;
1309
1310error_passthrough:
1311 /* Something failed while in passthrough mode, so try to get out */
1312 if (!alps_enter_command_mode(psmouse, NULL))
1313 alps_passthrough_mode_v3(psmouse, false);
1314error:
1315 /*
1316 * Leaving the touchpad in command mode will essentially render
1317 * it unusable until the machine reboots, so exit it here just
1318 * to be safe
1319 */
1320 alps_exit_command_mode(psmouse);
1321 return -1;
1322}
1323
1324/* Must be in command mode when calling this function */
1325static int alps_absolute_mode_v4(struct psmouse *psmouse)
1326{
1327 int reg_val;
1328
1329 reg_val = alps_command_mode_read_reg(psmouse, 0x0004);
1330 if (reg_val == -1)
1331 return -1;
1332
1333 reg_val |= 0x02;
1334 if (__alps_command_mode_write_reg(psmouse, reg_val))
1335 return -1;
1336
1337 return 0;
1338}
1339
1340static int alps_hw_init_v4(struct psmouse *psmouse)
1341{
25bded7c
SF
1342 struct ps2dev *ps2dev = &psmouse->ps2dev;
1343 unsigned char param[4];
1344
25bded7c
SF
1345 if (alps_enter_command_mode(psmouse, NULL))
1346 goto error;
1347
1348 if (alps_absolute_mode_v4(psmouse)) {
1349 psmouse_err(psmouse, "Failed to enter absolute mode\n");
1350 goto error;
1351 }
1352
1353 if (alps_command_mode_write_reg(psmouse, 0x0007, 0x8c))
1354 goto error;
1355
1356 if (alps_command_mode_write_reg(psmouse, 0x0149, 0x03))
1357 goto error;
1358
1359 if (alps_command_mode_write_reg(psmouse, 0x0160, 0x03))
1360 goto error;
1361
1362 if (alps_command_mode_write_reg(psmouse, 0x017f, 0x15))
1363 goto error;
1364
1365 if (alps_command_mode_write_reg(psmouse, 0x0151, 0x01))
1366 goto error;
1367
1368 if (alps_command_mode_write_reg(psmouse, 0x0168, 0x03))
1369 goto error;
1370
1371 if (alps_command_mode_write_reg(psmouse, 0x014a, 0x03))
1372 goto error;
1373
1374 if (alps_command_mode_write_reg(psmouse, 0x0161, 0x03))
1375 goto error;
1376
1377 alps_exit_command_mode(psmouse);
1378
1379 /*
1380 * This sequence changes the output from a 9-byte to an
1381 * 8-byte format. All the same data seems to be present,
1382 * just in a more compact format.
1383 */
1384 param[0] = 0xc8;
1385 param[1] = 0x64;
1386 param[2] = 0x50;
1387 if (ps2_command(ps2dev, &param[0], PSMOUSE_CMD_SETRATE) ||
1388 ps2_command(ps2dev, &param[1], PSMOUSE_CMD_SETRATE) ||
1389 ps2_command(ps2dev, &param[2], PSMOUSE_CMD_SETRATE) ||
1390 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID))
1391 return -1;
1392
1393 /* Set rate and enable data reporting */
1394 param[0] = 0x64;
1395 if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE) ||
1396 ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) {
1397 psmouse_err(psmouse, "Failed to enable data reporting\n");
1398 return -1;
1399 }
1400
1401 return 0;
1402
1403error:
1404 /*
1405 * Leaving the touchpad in command mode will essentially render
1406 * it unusable until the machine reboots, so exit it here just
1407 * to be safe
1408 */
1409 alps_exit_command_mode(psmouse);
1410 return -1;
1411}
1412
24af5cb9 1413static void alps_set_defaults(struct alps_data *priv)
25bded7c 1414{
99df65e7 1415 switch (priv->proto_version) {
25bded7c
SF
1416 case ALPS_PROTO_V1:
1417 case ALPS_PROTO_V2:
24af5cb9
KC
1418 priv->hw_init = alps_hw_init_v1_v2;
1419 priv->process_packet = alps_process_packet_v1_v2;
1420 priv->set_abs_params = alps_set_abs_params_st;
25bded7c
SF
1421 break;
1422 case ALPS_PROTO_V3:
24af5cb9
KC
1423 priv->hw_init = alps_hw_init_v3;
1424 priv->process_packet = alps_process_packet_v3;
1425 priv->set_abs_params = alps_set_abs_params_mt;
50e8b216
KC
1426 priv->nibble_commands = alps_v3_nibble_commands;
1427 priv->addr_command = PSMOUSE_CMD_RESET_WRAP;
25bded7c
SF
1428 break;
1429 case ALPS_PROTO_V4:
24af5cb9
KC
1430 priv->hw_init = alps_hw_init_v4;
1431 priv->process_packet = alps_process_packet_v4;
1432 priv->set_abs_params = alps_set_abs_params_mt;
50e8b216
KC
1433 priv->nibble_commands = alps_v4_nibble_commands;
1434 priv->addr_command = PSMOUSE_CMD_DISABLE;
25bded7c
SF
1435 break;
1436 }
25bded7c
SF
1437}
1438
b5d6b851
KC
1439static int alps_match_table(struct psmouse *psmouse, struct alps_data *priv,
1440 unsigned char *e7, unsigned char *ec)
2e992cc0 1441{
b5d6b851 1442 const struct alps_model_info *model;
2e992cc0
KC
1443 int i;
1444
b5d6b851
KC
1445 for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) {
1446 model = &alps_model_data[i];
1447
1448 if (!memcmp(e7, model->signature, sizeof(model->signature)) &&
1449 (!model->command_mode_resp ||
1450 model->command_mode_resp == ec[2])) {
1451
1452 priv->proto_version = model->proto_version;
24af5cb9
KC
1453 alps_set_defaults(priv);
1454
b5d6b851
KC
1455 priv->flags = model->flags;
1456 priv->byte0 = model->byte0;
1457 priv->mask0 = model->mask0;
1458
1459 return 0;
1460 }
1461 }
1462
1463 return -EINVAL;
1464}
1465
1466static int alps_identify(struct psmouse *psmouse, struct alps_data *priv)
1467{
1468 unsigned char e6[4], e7[4], ec[4];
1469
2e992cc0
KC
1470 /*
1471 * First try "E6 report".
1472 * ALPS should return 0,0,10 or 0,0,100 if no buttons are pressed.
1473 * The bits 0-2 of the first byte will be 1s if some buttons are
1474 * pressed.
1475 */
b5d6b851
KC
1476 if (alps_rpt_cmd(psmouse, PSMOUSE_CMD_SETRES,
1477 PSMOUSE_CMD_SETSCALE11, e6))
1478 return -EIO;
2e992cc0 1479
b5d6b851
KC
1480 if ((e6[0] & 0xf8) != 0 || e6[1] != 0 || (e6[2] != 10 && e6[2] != 100))
1481 return -EINVAL;
2e992cc0
KC
1482
1483 /*
b5d6b851
KC
1484 * Now get the "E7" and "EC" reports. These will uniquely identify
1485 * most ALPS touchpads.
2e992cc0 1486 */
b5d6b851
KC
1487 if (alps_rpt_cmd(psmouse, PSMOUSE_CMD_SETRES,
1488 PSMOUSE_CMD_SETSCALE21, e7) ||
1489 alps_rpt_cmd(psmouse, PSMOUSE_CMD_SETRES,
1490 PSMOUSE_CMD_RESET_WRAP, ec) ||
1491 alps_exit_command_mode(psmouse))
1492 return -EIO;
2e992cc0 1493
b5d6b851
KC
1494 if (alps_match_table(psmouse, priv, e7, ec) == 0)
1495 return 0;
2e992cc0 1496
b5d6b851
KC
1497 psmouse_info(psmouse,
1498 "Unknown ALPS touchpad: E7=%2.2x %2.2x %2.2x, EC=%2.2x %2.2x %2.2x\n",
1499 e7[0], e7[1], e7[2], ec[0], ec[1], ec[2]);
2e992cc0 1500
b5d6b851 1501 return -EINVAL;
2e992cc0
KC
1502}
1503
1e0c5b12
DT
1504static int alps_reconnect(struct psmouse *psmouse)
1505{
b5d6b851 1506 struct alps_data *priv = psmouse->private;
71bb21b6 1507
1e0c5b12
DT
1508 psmouse_reset(psmouse);
1509
b5d6b851 1510 if (alps_identify(psmouse, priv) < 0)
1e0c5b12
DT
1511 return -1;
1512
24af5cb9 1513 return priv->hw_init(psmouse);
1da177e4
LT
1514}
1515
1516static void alps_disconnect(struct psmouse *psmouse)
1517{
1518 struct alps_data *priv = psmouse->private;
2e5b636b 1519
1da177e4 1520 psmouse_reset(psmouse);
1d9f2626 1521 del_timer_sync(&priv->timer);
2e5b636b 1522 input_unregister_device(priv->dev2);
1da177e4
LT
1523 kfree(priv);
1524}
1525
24af5cb9
KC
1526static void alps_set_abs_params_st(struct alps_data *priv,
1527 struct input_dev *dev1)
1528{
1529 input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0);
1530 input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0);
1531}
1532
1533static void alps_set_abs_params_mt(struct alps_data *priv,
1534 struct input_dev *dev1)
1535{
1536 set_bit(INPUT_PROP_SEMI_MT, dev1->propbit);
1537 input_mt_init_slots(dev1, 2, 0);
1538 input_set_abs_params(dev1, ABS_MT_POSITION_X, 0, ALPS_V3_X_MAX, 0, 0);
1539 input_set_abs_params(dev1, ABS_MT_POSITION_Y, 0, ALPS_V3_Y_MAX, 0, 0);
1540
1541 set_bit(BTN_TOOL_DOUBLETAP, dev1->keybit);
1542 set_bit(BTN_TOOL_TRIPLETAP, dev1->keybit);
1543 set_bit(BTN_TOOL_QUADTAP, dev1->keybit);
1544
1545 input_set_abs_params(dev1, ABS_X, 0, ALPS_V3_X_MAX, 0, 0);
1546 input_set_abs_params(dev1, ABS_Y, 0, ALPS_V3_Y_MAX, 0, 0);
1547}
1548
1da177e4
LT
1549int alps_init(struct psmouse *psmouse)
1550{
1551 struct alps_data *priv;
2e5b636b 1552 struct input_dev *dev1 = psmouse->dev, *dev2;
1da177e4 1553
f42649e8 1554 priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL);
2e5b636b
DT
1555 dev2 = input_allocate_device();
1556 if (!priv || !dev2)
1da177e4 1557 goto init_fail;
2e5b636b
DT
1558
1559 priv->dev2 = dev2;
1d9f2626
SK
1560 setup_timer(&priv->timer, alps_flush_packet, (unsigned long)psmouse);
1561
1e0c5b12 1562 psmouse->private = priv;
1da177e4 1563
25bded7c
SF
1564 psmouse_reset(psmouse);
1565
b5d6b851 1566 if (alps_identify(psmouse, priv) < 0)
71bb21b6
ML
1567 goto init_fail;
1568
24af5cb9 1569 if (priv->hw_init(psmouse))
1da177e4
LT
1570 goto init_fail;
1571
7105d2ea
DT
1572 /*
1573 * Undo part of setup done for us by psmouse core since touchpad
1574 * is not a relative device.
1575 */
1576 __clear_bit(EV_REL, dev1->evbit);
1577 __clear_bit(REL_X, dev1->relbit);
1578 __clear_bit(REL_Y, dev1->relbit);
1579
1580 /*
1581 * Now set up our capabilities.
1582 */
7b19ada2
JS
1583 dev1->evbit[BIT_WORD(EV_KEY)] |= BIT_MASK(EV_KEY);
1584 dev1->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH);
1585 dev1->keybit[BIT_WORD(BTN_TOOL_FINGER)] |= BIT_MASK(BTN_TOOL_FINGER);
71bb21b6
ML
1586 dev1->keybit[BIT_WORD(BTN_LEFT)] |=
1587 BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT);
1da177e4 1588
7b19ada2 1589 dev1->evbit[BIT_WORD(EV_ABS)] |= BIT_MASK(EV_ABS);
25bded7c 1590
24af5cb9 1591 priv->set_abs_params(priv, dev1);
2e5b636b 1592 input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0);
1da177e4 1593
99df65e7 1594 if (priv->flags & ALPS_WHEEL) {
7b19ada2
JS
1595 dev1->evbit[BIT_WORD(EV_REL)] |= BIT_MASK(EV_REL);
1596 dev1->relbit[BIT_WORD(REL_WHEEL)] |= BIT_MASK(REL_WHEEL);
1da177e4
LT
1597 }
1598
99df65e7 1599 if (priv->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) {
7b19ada2
JS
1600 dev1->keybit[BIT_WORD(BTN_FORWARD)] |= BIT_MASK(BTN_FORWARD);
1601 dev1->keybit[BIT_WORD(BTN_BACK)] |= BIT_MASK(BTN_BACK);
1da177e4
LT
1602 }
1603
99df65e7 1604 if (priv->flags & ALPS_FOUR_BUTTONS) {
71bb21b6
ML
1605 dev1->keybit[BIT_WORD(BTN_0)] |= BIT_MASK(BTN_0);
1606 dev1->keybit[BIT_WORD(BTN_1)] |= BIT_MASK(BTN_1);
1607 dev1->keybit[BIT_WORD(BTN_2)] |= BIT_MASK(BTN_2);
1608 dev1->keybit[BIT_WORD(BTN_3)] |= BIT_MASK(BTN_3);
1609 } else {
1610 dev1->keybit[BIT_WORD(BTN_MIDDLE)] |= BIT_MASK(BTN_MIDDLE);
1611 }
1612
08ffce45 1613 snprintf(priv->phys, sizeof(priv->phys), "%s/input1", psmouse->ps2dev.serio->phys);
2e5b636b 1614 dev2->phys = priv->phys;
99df65e7
KC
1615 dev2->name = (priv->flags & ALPS_DUALPOINT) ?
1616 "DualPoint Stick" : "PS/2 Mouse";
2e5b636b
DT
1617 dev2->id.bustype = BUS_I8042;
1618 dev2->id.vendor = 0x0002;
1619 dev2->id.product = PSMOUSE_ALPS;
1620 dev2->id.version = 0x0000;
1db3a345 1621 dev2->dev.parent = &psmouse->ps2dev.serio->dev;
1da177e4 1622
7b19ada2 1623 dev2->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
71bb21b6
ML
1624 dev2->relbit[BIT_WORD(REL_X)] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
1625 dev2->keybit[BIT_WORD(BTN_LEFT)] =
1626 BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
1da177e4 1627
f42649e8
DT
1628 if (input_register_device(priv->dev2))
1629 goto init_fail;
1da177e4
LT
1630
1631 psmouse->protocol_handler = alps_process_byte;
f0d5c6f4 1632 psmouse->poll = alps_poll;
1da177e4
LT
1633 psmouse->disconnect = alps_disconnect;
1634 psmouse->reconnect = alps_reconnect;
99df65e7 1635 psmouse->pktsize = priv->proto_version == ALPS_PROTO_V4 ? 8 : 6;
1da177e4 1636
f0d5c6f4
DT
1637 /* We are having trouble resyncing ALPS touchpads so disable it for now */
1638 psmouse->resync_time = 0;
1639
1da177e4
LT
1640 return 0;
1641
1642init_fail:
f42649e8 1643 psmouse_reset(psmouse);
2e5b636b 1644 input_free_device(dev2);
1da177e4 1645 kfree(priv);
1e0c5b12 1646 psmouse->private = NULL;
1da177e4
LT
1647 return -1;
1648}
1649
b7802c5c 1650int alps_detect(struct psmouse *psmouse, bool set_properties)
1da177e4 1651{
b5d6b851 1652 struct alps_data dummy;
1da177e4 1653
b5d6b851 1654 if (alps_identify(psmouse, &dummy) < 0)
1da177e4
LT
1655 return -1;
1656
1657 if (set_properties) {
1658 psmouse->vendor = "ALPS";
b5d6b851 1659 psmouse->name = dummy.flags & ALPS_DUALPOINT ?
968ac842 1660 "DualPoint TouchPad" : "GlidePoint";
b5d6b851 1661 psmouse->model = dummy.proto_version << 8;
1da177e4
LT
1662 }
1663 return 0;
1664}
1665
This page took 0.51772 seconds and 5 git commands to generate.