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