diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-01-09 02:38:23 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-01-09 02:38:23 -0500 |
commit | da733563be5a9da26fe81d9f007262d00b846e22 (patch) | |
tree | db28291df94a2043af2123911984c5c173da4e6f /drivers/input/mouse | |
parent | 6ccbcf2cb41131f8d56ef0723bf3f7c1f8486076 (diff) | |
parent | dab78d7924598ea4031663dd10db814e2e324928 (diff) |
Merge branch 'next' into for-linus
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r-- | drivers/input/mouse/alps.c | 1036 | ||||
-rw-r--r-- | drivers/input/mouse/alps.h | 19 | ||||
-rw-r--r-- | drivers/input/mouse/amimouse.c | 16 | ||||
-rw-r--r-- | drivers/input/mouse/elantech.c | 80 | ||||
-rw-r--r-- | drivers/input/mouse/elantech.h | 2 | ||||
-rw-r--r-- | drivers/input/mouse/gpio_mouse.c | 13 | ||||
-rw-r--r-- | drivers/input/mouse/hgpk.c | 18 | ||||
-rw-r--r-- | drivers/input/mouse/logips2pp.c | 9 | ||||
-rw-r--r-- | drivers/input/mouse/psmouse-base.c | 229 | ||||
-rw-r--r-- | drivers/input/mouse/psmouse.h | 3 | ||||
-rw-r--r-- | drivers/input/mouse/pxa930_trkball.c | 14 | ||||
-rw-r--r-- | drivers/input/mouse/sentelic.c | 43 | ||||
-rw-r--r-- | drivers/input/mouse/synaptics.c | 197 | ||||
-rw-r--r-- | drivers/input/mouse/synaptics.h | 5 | ||||
-rw-r--r-- | drivers/input/mouse/trackpoint.c | 17 |
15 files changed, 1407 insertions, 294 deletions
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 003587c71f43..bd87380bd879 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
@@ -17,13 +17,63 @@ | |||
17 | 17 | ||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/input.h> | 19 | #include <linux/input.h> |
20 | #include <linux/input/mt.h> | ||
20 | #include <linux/serio.h> | 21 | #include <linux/serio.h> |
21 | #include <linux/libps2.h> | 22 | #include <linux/libps2.h> |
22 | 23 | ||
23 | #include "psmouse.h" | 24 | #include "psmouse.h" |
24 | #include "alps.h" | 25 | #include "alps.h" |
25 | 26 | ||
26 | #define ALPS_OLDPROTO 0x01 /* old style input */ | 27 | /* |
28 | * Definitions for ALPS version 3 and 4 command mode protocol | ||
29 | */ | ||
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 | |||
36 | #define ALPS_CMD_NIBBLE_10 0x01f2 | ||
37 | |||
38 | static 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 | |||
57 | static 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 | |||
27 | #define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */ | 77 | #define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */ |
28 | #define ALPS_PASS 0x04 /* device has a pass-through port */ | 78 | #define ALPS_PASS 0x04 /* device has a pass-through port */ |
29 | 79 | ||
@@ -35,30 +85,33 @@ | |||
35 | 6-byte ALPS packet */ | 85 | 6-byte ALPS packet */ |
36 | 86 | ||
37 | static const struct alps_model_info alps_model_data[] = { | 87 | static const struct alps_model_info alps_model_data[] = { |
38 | { { 0x32, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */ | 88 | { { 0x32, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */ |
39 | { { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */ | 89 | { { 0x33, 0x02, 0x0a }, 0x00, ALPS_PROTO_V1, 0x88, 0xf8, 0 }, /* UMAX-530T */ |
40 | { { 0x53, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, | 90 | { { 0x53, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
41 | { { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, | 91 | { { 0x53, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
42 | { { 0x60, 0x03, 0xc8 }, 0xf8, 0xf8, 0 }, /* HP ze1115 */ | 92 | { { 0x60, 0x03, 0xc8 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, /* HP ze1115 */ |
43 | { { 0x63, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, | 93 | { { 0x63, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
44 | { { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, | 94 | { { 0x63, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
45 | { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */ | 95 | { { 0x63, 0x02, 0x28 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */ |
46 | { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */ | 96 | { { 0x63, 0x02, 0x3c }, 0x00, ALPS_PROTO_V2, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */ |
47 | { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */ | 97 | { { 0x63, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */ |
48 | { { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 }, | 98 | { { 0x63, 0x02, 0x64 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
49 | { { 0x63, 0x03, 0xc8 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D800 */ | 99 | { { 0x63, 0x03, 0xc8 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D800 */ |
50 | { { 0x73, 0x00, 0x0a }, 0xf8, 0xf8, ALPS_DUALPOINT }, /* ThinkPad R61 8918-5QG */ | 100 | { { 0x73, 0x00, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_DUALPOINT }, /* ThinkPad R61 8918-5QG */ |
51 | { { 0x73, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, | 101 | { { 0x73, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
52 | { { 0x73, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */ | 102 | { { 0x73, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */ |
53 | { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ | 103 | { { 0x20, 0x02, 0x0e }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ |
54 | { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, | 104 | { { 0x22, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, |
55 | { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ | 105 | { { 0x22, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ |
56 | /* Dell Latitude E5500, E6400, E6500, Precision M4400 */ | 106 | /* Dell Latitude E5500, E6400, E6500, Precision M4400 */ |
57 | { { 0x62, 0x02, 0x14 }, 0xcf, 0xcf, | 107 | { { 0x62, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, |
58 | ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, | 108 | ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, |
59 | { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */ | 109 | { { 0x73, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */ |
60 | { { 0x52, 0x01, 0x14 }, 0xff, 0xff, | 110 | { { 0x52, 0x01, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, |
61 | ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */ | 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 }, | ||
62 | }; | 115 | }; |
63 | 116 | ||
64 | /* | 117 | /* |
@@ -67,42 +120,7 @@ static const struct alps_model_info alps_model_data[] = { | |||
67 | * isn't valid per PS/2 spec. | 120 | * isn't valid per PS/2 spec. |
68 | */ | 121 | */ |
69 | 122 | ||
70 | /* | 123 | /* Packet formats are described in Documentation/input/alps.txt */ |
71 | * PS/2 packet format | ||
72 | * | ||
73 | * byte 0: 0 0 YSGN XSGN 1 M R L | ||
74 | * byte 1: X7 X6 X5 X4 X3 X2 X1 X0 | ||
75 | * byte 2: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 | ||
76 | * | ||
77 | * Note that the device never signals overflow condition. | ||
78 | * | ||
79 | * ALPS absolute Mode - new format | ||
80 | * | ||
81 | * byte 0: 1 ? ? ? 1 ? ? ? | ||
82 | * byte 1: 0 x6 x5 x4 x3 x2 x1 x0 | ||
83 | * byte 2: 0 x10 x9 x8 x7 ? fin ges | ||
84 | * byte 3: 0 y9 y8 y7 1 M R L | ||
85 | * byte 4: 0 y6 y5 y4 y3 y2 y1 y0 | ||
86 | * byte 5: 0 z6 z5 z4 z3 z2 z1 z0 | ||
87 | * | ||
88 | * Dualpoint device -- interleaved packet format | ||
89 | * | ||
90 | * byte 0: 1 1 0 0 1 1 1 1 | ||
91 | * byte 1: 0 x6 x5 x4 x3 x2 x1 x0 | ||
92 | * byte 2: 0 x10 x9 x8 x7 0 fin ges | ||
93 | * byte 3: 0 0 YSGN XSGN 1 1 1 1 | ||
94 | * byte 4: X7 X6 X5 X4 X3 X2 X1 X0 | ||
95 | * byte 5: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 | ||
96 | * byte 6: 0 y9 y8 y7 1 m r l | ||
97 | * byte 7: 0 y6 y5 y4 y3 y2 y1 y0 | ||
98 | * byte 8: 0 z6 z5 z4 z3 z2 z1 z0 | ||
99 | * | ||
100 | * CAPITALS = stick, miniscules = touchpad | ||
101 | * | ||
102 | * ?'s can have different meanings on different models, | ||
103 | * such as wheel rotation, extra buttons, stick buttons | ||
104 | * on a dualpoint, etc. | ||
105 | */ | ||
106 | 124 | ||
107 | static bool alps_is_valid_first_byte(const struct alps_model_info *model, | 125 | static bool alps_is_valid_first_byte(const struct alps_model_info *model, |
108 | unsigned char data) | 126 | unsigned char data) |
@@ -137,7 +155,7 @@ static void alps_report_buttons(struct psmouse *psmouse, | |||
137 | input_sync(dev2); | 155 | input_sync(dev2); |
138 | } | 156 | } |
139 | 157 | ||
140 | static void alps_process_packet(struct psmouse *psmouse) | 158 | static void alps_process_packet_v1_v2(struct psmouse *psmouse) |
141 | { | 159 | { |
142 | struct alps_data *priv = psmouse->private; | 160 | struct alps_data *priv = psmouse->private; |
143 | const struct alps_model_info *model = priv->i; | 161 | const struct alps_model_info *model = priv->i; |
@@ -147,7 +165,7 @@ static void alps_process_packet(struct psmouse *psmouse) | |||
147 | int x, y, z, ges, fin, left, right, middle; | 165 | int x, y, z, ges, fin, left, right, middle; |
148 | int back = 0, forward = 0; | 166 | int back = 0, forward = 0; |
149 | 167 | ||
150 | if (model->flags & ALPS_OLDPROTO) { | 168 | if (model->proto_version == ALPS_PROTO_V1) { |
151 | left = packet[2] & 0x10; | 169 | left = packet[2] & 0x10; |
152 | right = packet[2] & 0x08; | 170 | right = packet[2] & 0x08; |
153 | middle = 0; | 171 | middle = 0; |
@@ -239,6 +257,403 @@ static void alps_process_packet(struct psmouse *psmouse) | |||
239 | input_sync(dev); | 257 | input_sync(dev); |
240 | } | 258 | } |
241 | 259 | ||
260 | /* | ||
261 | * Process bitmap data from v3 and v4 protocols. Returns the number of | ||
262 | * fingers detected. A return value of 0 means at least one of the | ||
263 | * bitmaps was empty. | ||
264 | * | ||
265 | * The bitmaps don't have enough data to track fingers, so this function | ||
266 | * only generates points representing a bounding box of all contacts. | ||
267 | * These points are returned in x1, y1, x2, and y2 when the return value | ||
268 | * is greater than 0. | ||
269 | */ | ||
270 | static int alps_process_bitmap(unsigned int x_map, unsigned int y_map, | ||
271 | int *x1, int *y1, int *x2, int *y2) | ||
272 | { | ||
273 | struct alps_bitmap_point { | ||
274 | int start_bit; | ||
275 | int num_bits; | ||
276 | }; | ||
277 | |||
278 | int fingers_x = 0, fingers_y = 0, fingers; | ||
279 | int i, bit, prev_bit; | ||
280 | struct alps_bitmap_point x_low = {0,}, x_high = {0,}; | ||
281 | struct alps_bitmap_point y_low = {0,}, y_high = {0,}; | ||
282 | struct alps_bitmap_point *point; | ||
283 | |||
284 | if (!x_map || !y_map) | ||
285 | return 0; | ||
286 | |||
287 | *x1 = *y1 = *x2 = *y2 = 0; | ||
288 | |||
289 | prev_bit = 0; | ||
290 | point = &x_low; | ||
291 | for (i = 0; x_map != 0; i++, x_map >>= 1) { | ||
292 | bit = x_map & 1; | ||
293 | if (bit) { | ||
294 | if (!prev_bit) { | ||
295 | point->start_bit = i; | ||
296 | fingers_x++; | ||
297 | } | ||
298 | point->num_bits++; | ||
299 | } else { | ||
300 | if (prev_bit) | ||
301 | point = &x_high; | ||
302 | else | ||
303 | point->num_bits = 0; | ||
304 | } | ||
305 | prev_bit = bit; | ||
306 | } | ||
307 | |||
308 | /* | ||
309 | * y bitmap is reversed for what we need (lower positions are in | ||
310 | * higher bits), so we process from the top end. | ||
311 | */ | ||
312 | y_map = y_map << (sizeof(y_map) * BITS_PER_BYTE - ALPS_BITMAP_Y_BITS); | ||
313 | prev_bit = 0; | ||
314 | point = &y_low; | ||
315 | for (i = 0; y_map != 0; i++, y_map <<= 1) { | ||
316 | bit = y_map & (1 << (sizeof(y_map) * BITS_PER_BYTE - 1)); | ||
317 | if (bit) { | ||
318 | if (!prev_bit) { | ||
319 | point->start_bit = i; | ||
320 | fingers_y++; | ||
321 | } | ||
322 | point->num_bits++; | ||
323 | } else { | ||
324 | if (prev_bit) | ||
325 | point = &y_high; | ||
326 | else | ||
327 | point->num_bits = 0; | ||
328 | } | ||
329 | prev_bit = bit; | ||
330 | } | ||
331 | |||
332 | /* | ||
333 | * Fingers can overlap, so we use the maximum count of fingers | ||
334 | * on either axis as the finger count. | ||
335 | */ | ||
336 | fingers = max(fingers_x, fingers_y); | ||
337 | |||
338 | /* | ||
339 | * If total fingers is > 1 but either axis reports only a single | ||
340 | * contact, we have overlapping or adjacent fingers. For the | ||
341 | * purposes of creating a bounding box, divide the single contact | ||
342 | * (roughly) equally between the two points. | ||
343 | */ | ||
344 | if (fingers > 1) { | ||
345 | if (fingers_x == 1) { | ||
346 | i = x_low.num_bits / 2; | ||
347 | x_low.num_bits = x_low.num_bits - i; | ||
348 | x_high.start_bit = x_low.start_bit + i; | ||
349 | x_high.num_bits = max(i, 1); | ||
350 | } else if (fingers_y == 1) { | ||
351 | i = y_low.num_bits / 2; | ||
352 | y_low.num_bits = y_low.num_bits - i; | ||
353 | y_high.start_bit = y_low.start_bit + i; | ||
354 | y_high.num_bits = max(i, 1); | ||
355 | } | ||
356 | } | ||
357 | |||
358 | *x1 = (ALPS_V3_X_MAX * (2 * x_low.start_bit + x_low.num_bits - 1)) / | ||
359 | (2 * (ALPS_BITMAP_X_BITS - 1)); | ||
360 | *y1 = (ALPS_V3_Y_MAX * (2 * y_low.start_bit + y_low.num_bits - 1)) / | ||
361 | (2 * (ALPS_BITMAP_Y_BITS - 1)); | ||
362 | |||
363 | if (fingers > 1) { | ||
364 | *x2 = (ALPS_V3_X_MAX * (2 * x_high.start_bit + x_high.num_bits - 1)) / | ||
365 | (2 * (ALPS_BITMAP_X_BITS - 1)); | ||
366 | *y2 = (ALPS_V3_Y_MAX * (2 * y_high.start_bit + y_high.num_bits - 1)) / | ||
367 | (2 * (ALPS_BITMAP_Y_BITS - 1)); | ||
368 | } | ||
369 | |||
370 | return fingers; | ||
371 | } | ||
372 | |||
373 | static void alps_set_slot(struct input_dev *dev, int slot, bool active, | ||
374 | int x, int y) | ||
375 | { | ||
376 | input_mt_slot(dev, slot); | ||
377 | input_mt_report_slot_state(dev, MT_TOOL_FINGER, active); | ||
378 | if (active) { | ||
379 | input_report_abs(dev, ABS_MT_POSITION_X, x); | ||
380 | input_report_abs(dev, ABS_MT_POSITION_Y, y); | ||
381 | } | ||
382 | } | ||
383 | |||
384 | static void alps_report_semi_mt_data(struct input_dev *dev, int num_fingers, | ||
385 | int x1, int y1, int x2, int y2) | ||
386 | { | ||
387 | alps_set_slot(dev, 0, num_fingers != 0, x1, y1); | ||
388 | alps_set_slot(dev, 1, num_fingers == 2, x2, y2); | ||
389 | } | ||
390 | |||
391 | static void alps_process_trackstick_packet_v3(struct psmouse *psmouse) | ||
392 | { | ||
393 | struct alps_data *priv = psmouse->private; | ||
394 | unsigned char *packet = psmouse->packet; | ||
395 | struct input_dev *dev = priv->dev2; | ||
396 | int x, y, z, left, right, middle; | ||
397 | |||
398 | /* Sanity check packet */ | ||
399 | if (!(packet[0] & 0x40)) { | ||
400 | psmouse_dbg(psmouse, "Bad trackstick packet, discarding\n"); | ||
401 | return; | ||
402 | } | ||
403 | |||
404 | /* | ||
405 | * There's a special packet that seems to indicate the end | ||
406 | * of a stream of trackstick data. Filter these out. | ||
407 | */ | ||
408 | if (packet[1] == 0x7f && packet[2] == 0x7f && packet[4] == 0x7f) | ||
409 | return; | ||
410 | |||
411 | x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f)); | ||
412 | y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f)); | ||
413 | z = (packet[4] & 0x7c) >> 2; | ||
414 | |||
415 | /* | ||
416 | * The x and y values tend to be quite large, and when used | ||
417 | * alone the trackstick is difficult to use. Scale them down | ||
418 | * to compensate. | ||
419 | */ | ||
420 | x /= 8; | ||
421 | y /= 8; | ||
422 | |||
423 | input_report_rel(dev, REL_X, x); | ||
424 | input_report_rel(dev, REL_Y, -y); | ||
425 | |||
426 | /* | ||
427 | * Most ALPS models report the trackstick buttons in the touchpad | ||
428 | * packets, but a few report them here. No reliable way has been | ||
429 | * found to differentiate between the models upfront, so we enable | ||
430 | * the quirk in response to seeing a button press in the trackstick | ||
431 | * packet. | ||
432 | */ | ||
433 | left = packet[3] & 0x01; | ||
434 | right = packet[3] & 0x02; | ||
435 | middle = packet[3] & 0x04; | ||
436 | |||
437 | if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) && | ||
438 | (left || right || middle)) | ||
439 | priv->quirks |= ALPS_QUIRK_TRACKSTICK_BUTTONS; | ||
440 | |||
441 | if (priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) { | ||
442 | input_report_key(dev, BTN_LEFT, left); | ||
443 | input_report_key(dev, BTN_RIGHT, right); | ||
444 | input_report_key(dev, BTN_MIDDLE, middle); | ||
445 | } | ||
446 | |||
447 | input_sync(dev); | ||
448 | return; | ||
449 | } | ||
450 | |||
451 | static void alps_process_touchpad_packet_v3(struct psmouse *psmouse) | ||
452 | { | ||
453 | struct alps_data *priv = psmouse->private; | ||
454 | unsigned char *packet = psmouse->packet; | ||
455 | struct input_dev *dev = psmouse->dev; | ||
456 | struct input_dev *dev2 = priv->dev2; | ||
457 | int x, y, z; | ||
458 | int left, right, middle; | ||
459 | int x1 = 0, y1 = 0, x2 = 0, y2 = 0; | ||
460 | int fingers = 0, bmap_fingers; | ||
461 | unsigned int x_bitmap, y_bitmap; | ||
462 | |||
463 | /* | ||
464 | * There's no single feature of touchpad position and bitmap packets | ||
465 | * that can be used to distinguish between them. We rely on the fact | ||
466 | * that a bitmap packet should always follow a position packet with | ||
467 | * bit 6 of packet[4] set. | ||
468 | */ | ||
469 | if (priv->multi_packet) { | ||
470 | /* | ||
471 | * Sometimes a position packet will indicate a multi-packet | ||
472 | * sequence, but then what follows is another position | ||
473 | * packet. Check for this, and when it happens process the | ||
474 | * position packet as usual. | ||
475 | */ | ||
476 | if (packet[0] & 0x40) { | ||
477 | fingers = (packet[5] & 0x3) + 1; | ||
478 | x_bitmap = ((packet[4] & 0x7e) << 8) | | ||
479 | ((packet[1] & 0x7f) << 2) | | ||
480 | ((packet[0] & 0x30) >> 4); | ||
481 | y_bitmap = ((packet[3] & 0x70) << 4) | | ||
482 | ((packet[2] & 0x7f) << 1) | | ||
483 | (packet[4] & 0x01); | ||
484 | |||
485 | bmap_fingers = alps_process_bitmap(x_bitmap, y_bitmap, | ||
486 | &x1, &y1, &x2, &y2); | ||
487 | |||
488 | /* | ||
489 | * We shouldn't report more than one finger if | ||
490 | * we don't have two coordinates. | ||
491 | */ | ||
492 | if (fingers > 1 && bmap_fingers < 2) | ||
493 | fingers = bmap_fingers; | ||
494 | |||
495 | /* Now process position packet */ | ||
496 | packet = priv->multi_data; | ||
497 | } else { | ||
498 | priv->multi_packet = 0; | ||
499 | } | ||
500 | } | ||
501 | |||
502 | /* | ||
503 | * Bit 6 of byte 0 is not usually set in position packets. The only | ||
504 | * times it seems to be set is in situations where the data is | ||
505 | * suspect anyway, e.g. a palm resting flat on the touchpad. Given | ||
506 | * this combined with the fact that this bit is useful for filtering | ||
507 | * out misidentified bitmap packets, we reject anything with this | ||
508 | * bit set. | ||
509 | */ | ||
510 | if (packet[0] & 0x40) | ||
511 | return; | ||
512 | |||
513 | if (!priv->multi_packet && (packet[4] & 0x40)) { | ||
514 | priv->multi_packet = 1; | ||
515 | memcpy(priv->multi_data, packet, sizeof(priv->multi_data)); | ||
516 | return; | ||
517 | } | ||
518 | |||
519 | priv->multi_packet = 0; | ||
520 | |||
521 | left = packet[3] & 0x01; | ||
522 | right = packet[3] & 0x02; | ||
523 | middle = packet[3] & 0x04; | ||
524 | |||
525 | x = ((packet[1] & 0x7f) << 4) | ((packet[4] & 0x30) >> 2) | | ||
526 | ((packet[0] & 0x30) >> 4); | ||
527 | y = ((packet[2] & 0x7f) << 4) | (packet[4] & 0x0f); | ||
528 | z = packet[5] & 0x7f; | ||
529 | |||
530 | /* | ||
531 | * Sometimes the hardware sends a single packet with z = 0 | ||
532 | * in the middle of a stream. Real releases generate packets | ||
533 | * with x, y, and z all zero, so these seem to be flukes. | ||
534 | * Ignore them. | ||
535 | */ | ||
536 | if (x && y && !z) | ||
537 | return; | ||
538 | |||
539 | /* | ||
540 | * If we don't have MT data or the bitmaps were empty, we have | ||
541 | * to rely on ST data. | ||
542 | */ | ||
543 | if (!fingers) { | ||
544 | x1 = x; | ||
545 | y1 = y; | ||
546 | fingers = z > 0 ? 1 : 0; | ||
547 | } | ||
548 | |||
549 | if (z >= 64) | ||
550 | input_report_key(dev, BTN_TOUCH, 1); | ||
551 | else | ||
552 | input_report_key(dev, BTN_TOUCH, 0); | ||
553 | |||
554 | alps_report_semi_mt_data(dev, fingers, x1, y1, x2, y2); | ||
555 | |||
556 | input_report_key(dev, BTN_TOOL_FINGER, fingers == 1); | ||
557 | input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2); | ||
558 | input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3); | ||
559 | input_report_key(dev, BTN_TOOL_QUADTAP, fingers == 4); | ||
560 | |||
561 | input_report_key(dev, BTN_LEFT, left); | ||
562 | input_report_key(dev, BTN_RIGHT, right); | ||
563 | input_report_key(dev, BTN_MIDDLE, middle); | ||
564 | |||
565 | if (z > 0) { | ||
566 | input_report_abs(dev, ABS_X, x); | ||
567 | input_report_abs(dev, ABS_Y, y); | ||
568 | } | ||
569 | input_report_abs(dev, ABS_PRESSURE, z); | ||
570 | |||
571 | input_sync(dev); | ||
572 | |||
573 | if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) { | ||
574 | left = packet[3] & 0x10; | ||
575 | right = packet[3] & 0x20; | ||
576 | middle = packet[3] & 0x40; | ||
577 | |||
578 | input_report_key(dev2, BTN_LEFT, left); | ||
579 | input_report_key(dev2, BTN_RIGHT, right); | ||
580 | input_report_key(dev2, BTN_MIDDLE, middle); | ||
581 | input_sync(dev2); | ||
582 | } | ||
583 | } | ||
584 | |||
585 | static void alps_process_packet_v3(struct psmouse *psmouse) | ||
586 | { | ||
587 | unsigned char *packet = psmouse->packet; | ||
588 | |||
589 | /* | ||
590 | * v3 protocol packets come in three types, two representing | ||
591 | * touchpad data and one representing trackstick data. | ||
592 | * Trackstick packets seem to be distinguished by always | ||
593 | * having 0x3f in the last byte. This value has never been | ||
594 | * observed in the last byte of either of the other types | ||
595 | * of packets. | ||
596 | */ | ||
597 | if (packet[5] == 0x3f) { | ||
598 | alps_process_trackstick_packet_v3(psmouse); | ||
599 | return; | ||
600 | } | ||
601 | |||
602 | alps_process_touchpad_packet_v3(psmouse); | ||
603 | } | ||
604 | |||
605 | static void alps_process_packet_v4(struct psmouse *psmouse) | ||
606 | { | ||
607 | unsigned char *packet = psmouse->packet; | ||
608 | struct input_dev *dev = psmouse->dev; | ||
609 | int x, y, z; | ||
610 | int left, right; | ||
611 | |||
612 | left = packet[4] & 0x01; | ||
613 | right = packet[4] & 0x02; | ||
614 | |||
615 | x = ((packet[1] & 0x7f) << 4) | ((packet[3] & 0x30) >> 2) | | ||
616 | ((packet[0] & 0x30) >> 4); | ||
617 | y = ((packet[2] & 0x7f) << 4) | (packet[3] & 0x0f); | ||
618 | z = packet[5] & 0x7f; | ||
619 | |||
620 | if (z >= 64) | ||
621 | input_report_key(dev, BTN_TOUCH, 1); | ||
622 | else | ||
623 | input_report_key(dev, BTN_TOUCH, 0); | ||
624 | |||
625 | if (z > 0) { | ||
626 | input_report_abs(dev, ABS_X, x); | ||
627 | input_report_abs(dev, ABS_Y, y); | ||
628 | } | ||
629 | input_report_abs(dev, ABS_PRESSURE, z); | ||
630 | |||
631 | input_report_key(dev, BTN_TOOL_FINGER, z > 0); | ||
632 | input_report_key(dev, BTN_LEFT, left); | ||
633 | input_report_key(dev, BTN_RIGHT, right); | ||
634 | |||
635 | input_sync(dev); | ||
636 | } | ||
637 | |||
638 | static void alps_process_packet(struct psmouse *psmouse) | ||
639 | { | ||
640 | struct alps_data *priv = psmouse->private; | ||
641 | const struct alps_model_info *model = priv->i; | ||
642 | |||
643 | switch (model->proto_version) { | ||
644 | case ALPS_PROTO_V1: | ||
645 | case ALPS_PROTO_V2: | ||
646 | alps_process_packet_v1_v2(psmouse); | ||
647 | break; | ||
648 | case ALPS_PROTO_V3: | ||
649 | alps_process_packet_v3(psmouse); | ||
650 | break; | ||
651 | case ALPS_PROTO_V4: | ||
652 | alps_process_packet_v4(psmouse); | ||
653 | break; | ||
654 | } | ||
655 | } | ||
656 | |||
242 | static void alps_report_bare_ps2_packet(struct psmouse *psmouse, | 657 | static void alps_report_bare_ps2_packet(struct psmouse *psmouse, |
243 | unsigned char packet[], | 658 | unsigned char packet[], |
244 | bool report_buttons) | 659 | bool report_buttons) |
@@ -344,7 +759,7 @@ static void alps_flush_packet(unsigned long data) | |||
344 | 759 | ||
345 | serio_pause_rx(psmouse->ps2dev.serio); | 760 | serio_pause_rx(psmouse->ps2dev.serio); |
346 | 761 | ||
347 | if (psmouse->pktcnt == 6) { | 762 | if (psmouse->pktcnt == psmouse->pktsize) { |
348 | 763 | ||
349 | /* | 764 | /* |
350 | * We did not any more data in reasonable amount of time. | 765 | * We did not any more data in reasonable amount of time. |
@@ -395,8 +810,8 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse) | |||
395 | return PSMOUSE_BAD_DATA; | 810 | return PSMOUSE_BAD_DATA; |
396 | } | 811 | } |
397 | 812 | ||
398 | /* Bytes 2 - 6 should have 0 in the highest bit */ | 813 | /* Bytes 2 - pktsize should have 0 in the highest bit */ |
399 | if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 6 && | 814 | if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize && |
400 | (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) { | 815 | (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) { |
401 | psmouse_dbg(psmouse, "refusing packet[%i] = %x\n", | 816 | psmouse_dbg(psmouse, "refusing packet[%i] = %x\n", |
402 | psmouse->pktcnt - 1, | 817 | psmouse->pktcnt - 1, |
@@ -404,7 +819,7 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse) | |||
404 | return PSMOUSE_BAD_DATA; | 819 | return PSMOUSE_BAD_DATA; |
405 | } | 820 | } |
406 | 821 | ||
407 | if (psmouse->pktcnt == 6) { | 822 | if (psmouse->pktcnt == psmouse->pktsize) { |
408 | alps_process_packet(psmouse); | 823 | alps_process_packet(psmouse); |
409 | return PSMOUSE_FULL_PACKET; | 824 | return PSMOUSE_FULL_PACKET; |
410 | } | 825 | } |
@@ -412,11 +827,127 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse) | |||
412 | return PSMOUSE_GOOD_DATA; | 827 | return PSMOUSE_GOOD_DATA; |
413 | } | 828 | } |
414 | 829 | ||
830 | static int alps_command_mode_send_nibble(struct psmouse *psmouse, int nibble) | ||
831 | { | ||
832 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
833 | struct alps_data *priv = psmouse->private; | ||
834 | int command; | ||
835 | unsigned char *param; | ||
836 | unsigned char dummy[4]; | ||
837 | |||
838 | BUG_ON(nibble > 0xf); | ||
839 | |||
840 | command = priv->nibble_commands[nibble].command; | ||
841 | param = (command & 0x0f00) ? | ||
842 | dummy : (unsigned char *)&priv->nibble_commands[nibble].data; | ||
843 | |||
844 | if (ps2_command(ps2dev, param, command)) | ||
845 | return -1; | ||
846 | |||
847 | return 0; | ||
848 | } | ||
849 | |||
850 | static int alps_command_mode_set_addr(struct psmouse *psmouse, int addr) | ||
851 | { | ||
852 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
853 | struct alps_data *priv = psmouse->private; | ||
854 | int i, nibble; | ||
855 | |||
856 | if (ps2_command(ps2dev, NULL, priv->addr_command)) | ||
857 | return -1; | ||
858 | |||
859 | for (i = 12; i >= 0; i -= 4) { | ||
860 | nibble = (addr >> i) & 0xf; | ||
861 | if (alps_command_mode_send_nibble(psmouse, nibble)) | ||
862 | return -1; | ||
863 | } | ||
864 | |||
865 | return 0; | ||
866 | } | ||
867 | |||
868 | static int __alps_command_mode_read_reg(struct psmouse *psmouse, int addr) | ||
869 | { | ||
870 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
871 | unsigned char param[4]; | ||
872 | |||
873 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) | ||
874 | return -1; | ||
875 | |||
876 | /* | ||
877 | * The address being read is returned in the first two bytes | ||
878 | * of the result. Check that this address matches the expected | ||
879 | * address. | ||
880 | */ | ||
881 | if (addr != ((param[0] << 8) | param[1])) | ||
882 | return -1; | ||
883 | |||
884 | return param[2]; | ||
885 | } | ||
886 | |||
887 | static int alps_command_mode_read_reg(struct psmouse *psmouse, int addr) | ||
888 | { | ||
889 | if (alps_command_mode_set_addr(psmouse, addr)) | ||
890 | return -1; | ||
891 | return __alps_command_mode_read_reg(psmouse, addr); | ||
892 | } | ||
893 | |||
894 | static int __alps_command_mode_write_reg(struct psmouse *psmouse, u8 value) | ||
895 | { | ||
896 | if (alps_command_mode_send_nibble(psmouse, (value >> 4) & 0xf)) | ||
897 | return -1; | ||
898 | if (alps_command_mode_send_nibble(psmouse, value & 0xf)) | ||
899 | return -1; | ||
900 | return 0; | ||
901 | } | ||
902 | |||
903 | static int alps_command_mode_write_reg(struct psmouse *psmouse, int addr, | ||
904 | u8 value) | ||
905 | { | ||
906 | if (alps_command_mode_set_addr(psmouse, addr)) | ||
907 | return -1; | ||
908 | return __alps_command_mode_write_reg(psmouse, value); | ||
909 | } | ||
910 | |||
911 | static int alps_enter_command_mode(struct psmouse *psmouse, | ||
912 | unsigned char *resp) | ||
913 | { | ||
914 | unsigned char param[4]; | ||
915 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
916 | |||
917 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) || | ||
918 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) || | ||
919 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) || | ||
920 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { | ||
921 | psmouse_err(psmouse, "failed to enter command mode\n"); | ||
922 | return -1; | ||
923 | } | ||
924 | |||
925 | if (param[0] != 0x88 && param[1] != 0x07) { | ||
926 | psmouse_dbg(psmouse, | ||
927 | "unknown response while entering command mode: %2.2x %2.2x %2.2x\n", | ||
928 | param[0], param[1], param[2]); | ||
929 | return -1; | ||
930 | } | ||
931 | |||
932 | if (resp) | ||
933 | *resp = param[2]; | ||
934 | return 0; | ||
935 | } | ||
936 | |||
937 | static inline int alps_exit_command_mode(struct psmouse *psmouse) | ||
938 | { | ||
939 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
940 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSTREAM)) | ||
941 | return -1; | ||
942 | return 0; | ||
943 | } | ||
944 | |||
415 | static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version) | 945 | static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version) |
416 | { | 946 | { |
417 | struct ps2dev *ps2dev = &psmouse->ps2dev; | 947 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
418 | static const unsigned char rates[] = { 0, 10, 20, 40, 60, 80, 100, 200 }; | 948 | static const unsigned char rates[] = { 0, 10, 20, 40, 60, 80, 100, 200 }; |
419 | unsigned char param[4]; | 949 | unsigned char param[4]; |
950 | const struct alps_model_info *model = NULL; | ||
420 | int i; | 951 | int i; |
421 | 952 | ||
422 | /* | 953 | /* |
@@ -464,12 +995,41 @@ static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int | |||
464 | *version = (param[0] << 8) | (param[1] << 4) | i; | 995 | *version = (param[0] << 8) | (param[1] << 4) | i; |
465 | } | 996 | } |
466 | 997 | ||
467 | for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) | 998 | for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) { |
468 | if (!memcmp(param, alps_model_data[i].signature, | 999 | if (!memcmp(param, alps_model_data[i].signature, |
469 | sizeof(alps_model_data[i].signature))) | 1000 | sizeof(alps_model_data[i].signature))) { |
470 | return alps_model_data + i; | 1001 | model = alps_model_data + i; |
1002 | break; | ||
1003 | } | ||
1004 | } | ||
471 | 1005 | ||
472 | return NULL; | 1006 | if (model && model->proto_version > ALPS_PROTO_V2) { |
1007 | /* | ||
1008 | * Need to check command mode response to identify | ||
1009 | * model | ||
1010 | */ | ||
1011 | model = NULL; | ||
1012 | if (alps_enter_command_mode(psmouse, param)) { | ||
1013 | psmouse_warn(psmouse, | ||
1014 | "touchpad failed to enter command mode\n"); | ||
1015 | } else { | ||
1016 | for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) { | ||
1017 | if (alps_model_data[i].proto_version > ALPS_PROTO_V2 && | ||
1018 | alps_model_data[i].command_mode_resp == param[0]) { | ||
1019 | model = alps_model_data + i; | ||
1020 | break; | ||
1021 | } | ||
1022 | } | ||
1023 | alps_exit_command_mode(psmouse); | ||
1024 | |||
1025 | if (!model) | ||
1026 | psmouse_dbg(psmouse, | ||
1027 | "Unknown command mode response %2.2x\n", | ||
1028 | param[0]); | ||
1029 | } | ||
1030 | } | ||
1031 | |||
1032 | return model; | ||
473 | } | 1033 | } |
474 | 1034 | ||
475 | /* | 1035 | /* |
@@ -477,7 +1037,7 @@ static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int | |||
477 | * subsequent commands. It looks like glidepad is behind stickpointer, | 1037 | * subsequent commands. It looks like glidepad is behind stickpointer, |
478 | * I'd thought it would be other way around... | 1038 | * I'd thought it would be other way around... |
479 | */ | 1039 | */ |
480 | static int alps_passthrough_mode(struct psmouse *psmouse, bool enable) | 1040 | static int alps_passthrough_mode_v2(struct psmouse *psmouse, bool enable) |
481 | { | 1041 | { |
482 | struct ps2dev *ps2dev = &psmouse->ps2dev; | 1042 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
483 | int cmd = enable ? PSMOUSE_CMD_SETSCALE21 : PSMOUSE_CMD_SETSCALE11; | 1043 | int cmd = enable ? PSMOUSE_CMD_SETSCALE21 : PSMOUSE_CMD_SETSCALE11; |
@@ -494,7 +1054,7 @@ static int alps_passthrough_mode(struct psmouse *psmouse, bool enable) | |||
494 | return 0; | 1054 | return 0; |
495 | } | 1055 | } |
496 | 1056 | ||
497 | static int alps_absolute_mode(struct psmouse *psmouse) | 1057 | static int alps_absolute_mode_v1_v2(struct psmouse *psmouse) |
498 | { | 1058 | { |
499 | struct ps2dev *ps2dev = &psmouse->ps2dev; | 1059 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
500 | 1060 | ||
@@ -565,17 +1125,17 @@ static int alps_tap_mode(struct psmouse *psmouse, int enable) | |||
565 | static int alps_poll(struct psmouse *psmouse) | 1125 | static int alps_poll(struct psmouse *psmouse) |
566 | { | 1126 | { |
567 | struct alps_data *priv = psmouse->private; | 1127 | struct alps_data *priv = psmouse->private; |
568 | unsigned char buf[6]; | 1128 | unsigned char buf[sizeof(psmouse->packet)]; |
569 | bool poll_failed; | 1129 | bool poll_failed; |
570 | 1130 | ||
571 | if (priv->i->flags & ALPS_PASS) | 1131 | if (priv->i->flags & ALPS_PASS) |
572 | alps_passthrough_mode(psmouse, true); | 1132 | alps_passthrough_mode_v2(psmouse, true); |
573 | 1133 | ||
574 | poll_failed = ps2_command(&psmouse->ps2dev, buf, | 1134 | poll_failed = ps2_command(&psmouse->ps2dev, buf, |
575 | PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)) < 0; | 1135 | PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)) < 0; |
576 | 1136 | ||
577 | if (priv->i->flags & ALPS_PASS) | 1137 | if (priv->i->flags & ALPS_PASS) |
578 | alps_passthrough_mode(psmouse, false); | 1138 | alps_passthrough_mode_v2(psmouse, false); |
579 | 1139 | ||
580 | if (poll_failed || (buf[0] & priv->i->mask0) != priv->i->byte0) | 1140 | if (poll_failed || (buf[0] & priv->i->mask0) != priv->i->byte0) |
581 | return -1; | 1141 | return -1; |
@@ -592,13 +1152,13 @@ static int alps_poll(struct psmouse *psmouse) | |||
592 | return 0; | 1152 | return 0; |
593 | } | 1153 | } |
594 | 1154 | ||
595 | static int alps_hw_init(struct psmouse *psmouse) | 1155 | static int alps_hw_init_v1_v2(struct psmouse *psmouse) |
596 | { | 1156 | { |
597 | struct alps_data *priv = psmouse->private; | 1157 | struct alps_data *priv = psmouse->private; |
598 | const struct alps_model_info *model = priv->i; | 1158 | const struct alps_model_info *model = priv->i; |
599 | 1159 | ||
600 | if ((model->flags & ALPS_PASS) && | 1160 | if ((model->flags & ALPS_PASS) && |
601 | alps_passthrough_mode(psmouse, true)) { | 1161 | alps_passthrough_mode_v2(psmouse, true)) { |
602 | return -1; | 1162 | return -1; |
603 | } | 1163 | } |
604 | 1164 | ||
@@ -607,13 +1167,13 @@ static int alps_hw_init(struct psmouse *psmouse) | |||
607 | return -1; | 1167 | return -1; |
608 | } | 1168 | } |
609 | 1169 | ||
610 | if (alps_absolute_mode(psmouse)) { | 1170 | if (alps_absolute_mode_v1_v2(psmouse)) { |
611 | psmouse_err(psmouse, "Failed to enable absolute mode\n"); | 1171 | psmouse_err(psmouse, "Failed to enable absolute mode\n"); |
612 | return -1; | 1172 | return -1; |
613 | } | 1173 | } |
614 | 1174 | ||
615 | if ((model->flags & ALPS_PASS) && | 1175 | if ((model->flags & ALPS_PASS) && |
616 | alps_passthrough_mode(psmouse, false)) { | 1176 | alps_passthrough_mode_v2(psmouse, false)) { |
617 | return -1; | 1177 | return -1; |
618 | } | 1178 | } |
619 | 1179 | ||
@@ -626,6 +1186,297 @@ static int alps_hw_init(struct psmouse *psmouse) | |||
626 | return 0; | 1186 | return 0; |
627 | } | 1187 | } |
628 | 1188 | ||
1189 | /* | ||
1190 | * Enable or disable passthrough mode to the trackstick. Must be in | ||
1191 | * command mode when calling this function. | ||
1192 | */ | ||
1193 | static int alps_passthrough_mode_v3(struct psmouse *psmouse, bool enable) | ||
1194 | { | ||
1195 | int reg_val; | ||
1196 | |||
1197 | reg_val = alps_command_mode_read_reg(psmouse, 0x0008); | ||
1198 | if (reg_val == -1) | ||
1199 | return -1; | ||
1200 | |||
1201 | if (enable) | ||
1202 | reg_val |= 0x01; | ||
1203 | else | ||
1204 | reg_val &= ~0x01; | ||
1205 | |||
1206 | if (__alps_command_mode_write_reg(psmouse, reg_val)) | ||
1207 | return -1; | ||
1208 | |||
1209 | return 0; | ||
1210 | } | ||
1211 | |||
1212 | /* Must be in command mode when calling this function */ | ||
1213 | static int alps_absolute_mode_v3(struct psmouse *psmouse) | ||
1214 | { | ||
1215 | int reg_val; | ||
1216 | |||
1217 | reg_val = alps_command_mode_read_reg(psmouse, 0x0004); | ||
1218 | if (reg_val == -1) | ||
1219 | return -1; | ||
1220 | |||
1221 | reg_val |= 0x06; | ||
1222 | if (__alps_command_mode_write_reg(psmouse, reg_val)) | ||
1223 | return -1; | ||
1224 | |||
1225 | return 0; | ||
1226 | } | ||
1227 | |||
1228 | static int alps_hw_init_v3(struct psmouse *psmouse) | ||
1229 | { | ||
1230 | struct alps_data *priv = psmouse->private; | ||
1231 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
1232 | int reg_val; | ||
1233 | unsigned char param[4]; | ||
1234 | |||
1235 | priv->nibble_commands = alps_v3_nibble_commands; | ||
1236 | priv->addr_command = PSMOUSE_CMD_RESET_WRAP; | ||
1237 | |||
1238 | if (alps_enter_command_mode(psmouse, NULL)) | ||
1239 | goto error; | ||
1240 | |||
1241 | /* Check for trackstick */ | ||
1242 | reg_val = alps_command_mode_read_reg(psmouse, 0x0008); | ||
1243 | if (reg_val == -1) | ||
1244 | goto error; | ||
1245 | if (reg_val & 0x80) { | ||
1246 | if (alps_passthrough_mode_v3(psmouse, true)) | ||
1247 | goto error; | ||
1248 | if (alps_exit_command_mode(psmouse)) | ||
1249 | goto error; | ||
1250 | |||
1251 | /* | ||
1252 | * E7 report for the trackstick | ||
1253 | * | ||
1254 | * There have been reports of failures to seem to trace back | ||
1255 | * to the above trackstick check failing. When these occur | ||
1256 | * this E7 report fails, so when that happens we continue | ||
1257 | * with the assumption that there isn't a trackstick after | ||
1258 | * all. | ||
1259 | */ | ||
1260 | param[0] = 0x64; | ||
1261 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || | ||
1262 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || | ||
1263 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || | ||
1264 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { | ||
1265 | psmouse_warn(psmouse, "trackstick E7 report failed\n"); | ||
1266 | } else { | ||
1267 | psmouse_dbg(psmouse, | ||
1268 | "trackstick E7 report: %2.2x %2.2x %2.2x\n", | ||
1269 | param[0], param[1], param[2]); | ||
1270 | |||
1271 | /* | ||
1272 | * Not sure what this does, but it is absolutely | ||
1273 | * essential. Without it, the touchpad does not | ||
1274 | * work at all and the trackstick just emits normal | ||
1275 | * PS/2 packets. | ||
1276 | */ | ||
1277 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || | ||
1278 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || | ||
1279 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || | ||
1280 | alps_command_mode_send_nibble(psmouse, 0x9) || | ||
1281 | alps_command_mode_send_nibble(psmouse, 0x4)) { | ||
1282 | psmouse_err(psmouse, | ||
1283 | "Error sending magic E6 sequence\n"); | ||
1284 | goto error_passthrough; | ||
1285 | } | ||
1286 | } | ||
1287 | |||
1288 | if (alps_enter_command_mode(psmouse, NULL)) | ||
1289 | goto error_passthrough; | ||
1290 | if (alps_passthrough_mode_v3(psmouse, false)) | ||
1291 | goto error; | ||
1292 | } | ||
1293 | |||
1294 | if (alps_absolute_mode_v3(psmouse)) { | ||
1295 | psmouse_err(psmouse, "Failed to enter absolute mode\n"); | ||
1296 | goto error; | ||
1297 | } | ||
1298 | |||
1299 | reg_val = alps_command_mode_read_reg(psmouse, 0x0006); | ||
1300 | if (reg_val == -1) | ||
1301 | goto error; | ||
1302 | if (__alps_command_mode_write_reg(psmouse, reg_val | 0x01)) | ||
1303 | goto error; | ||
1304 | |||
1305 | reg_val = alps_command_mode_read_reg(psmouse, 0x0007); | ||
1306 | if (reg_val == -1) | ||
1307 | goto error; | ||
1308 | if (__alps_command_mode_write_reg(psmouse, reg_val | 0x01)) | ||
1309 | goto error; | ||
1310 | |||
1311 | if (alps_command_mode_read_reg(psmouse, 0x0144) == -1) | ||
1312 | goto error; | ||
1313 | if (__alps_command_mode_write_reg(psmouse, 0x04)) | ||
1314 | goto error; | ||
1315 | |||
1316 | if (alps_command_mode_read_reg(psmouse, 0x0159) == -1) | ||
1317 | goto error; | ||
1318 | if (__alps_command_mode_write_reg(psmouse, 0x03)) | ||
1319 | goto error; | ||
1320 | |||
1321 | if (alps_command_mode_read_reg(psmouse, 0x0163) == -1) | ||
1322 | goto error; | ||
1323 | if (alps_command_mode_write_reg(psmouse, 0x0163, 0x03)) | ||
1324 | goto error; | ||
1325 | |||
1326 | if (alps_command_mode_read_reg(psmouse, 0x0162) == -1) | ||
1327 | goto error; | ||
1328 | if (alps_command_mode_write_reg(psmouse, 0x0162, 0x04)) | ||
1329 | goto error; | ||
1330 | |||
1331 | /* | ||
1332 | * This ensures the trackstick packets are in the format | ||
1333 | * supported by this driver. If bit 1 isn't set the packet | ||
1334 | * format is different. | ||
1335 | */ | ||
1336 | if (alps_command_mode_write_reg(psmouse, 0x0008, 0x82)) | ||
1337 | goto error; | ||
1338 | |||
1339 | alps_exit_command_mode(psmouse); | ||
1340 | |||
1341 | /* Set rate and enable data reporting */ | ||
1342 | param[0] = 0x64; | ||
1343 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE) || | ||
1344 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) { | ||
1345 | psmouse_err(psmouse, "Failed to enable data reporting\n"); | ||
1346 | return -1; | ||
1347 | } | ||
1348 | |||
1349 | return 0; | ||
1350 | |||
1351 | error_passthrough: | ||
1352 | /* Something failed while in passthrough mode, so try to get out */ | ||
1353 | if (!alps_enter_command_mode(psmouse, NULL)) | ||
1354 | alps_passthrough_mode_v3(psmouse, false); | ||
1355 | error: | ||
1356 | /* | ||
1357 | * Leaving the touchpad in command mode will essentially render | ||
1358 | * it unusable until the machine reboots, so exit it here just | ||
1359 | * to be safe | ||
1360 | */ | ||
1361 | alps_exit_command_mode(psmouse); | ||
1362 | return -1; | ||
1363 | } | ||
1364 | |||
1365 | /* Must be in command mode when calling this function */ | ||
1366 | static int alps_absolute_mode_v4(struct psmouse *psmouse) | ||
1367 | { | ||
1368 | int reg_val; | ||
1369 | |||
1370 | reg_val = alps_command_mode_read_reg(psmouse, 0x0004); | ||
1371 | if (reg_val == -1) | ||
1372 | return -1; | ||
1373 | |||
1374 | reg_val |= 0x02; | ||
1375 | if (__alps_command_mode_write_reg(psmouse, reg_val)) | ||
1376 | return -1; | ||
1377 | |||
1378 | return 0; | ||
1379 | } | ||
1380 | |||
1381 | static int alps_hw_init_v4(struct psmouse *psmouse) | ||
1382 | { | ||
1383 | struct alps_data *priv = psmouse->private; | ||
1384 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
1385 | unsigned char param[4]; | ||
1386 | |||
1387 | priv->nibble_commands = alps_v4_nibble_commands; | ||
1388 | priv->addr_command = PSMOUSE_CMD_DISABLE; | ||
1389 | |||
1390 | if (alps_enter_command_mode(psmouse, NULL)) | ||
1391 | goto error; | ||
1392 | |||
1393 | if (alps_absolute_mode_v4(psmouse)) { | ||
1394 | psmouse_err(psmouse, "Failed to enter absolute mode\n"); | ||
1395 | goto error; | ||
1396 | } | ||
1397 | |||
1398 | if (alps_command_mode_write_reg(psmouse, 0x0007, 0x8c)) | ||
1399 | goto error; | ||
1400 | |||
1401 | if (alps_command_mode_write_reg(psmouse, 0x0149, 0x03)) | ||
1402 | goto error; | ||
1403 | |||
1404 | if (alps_command_mode_write_reg(psmouse, 0x0160, 0x03)) | ||
1405 | goto error; | ||
1406 | |||
1407 | if (alps_command_mode_write_reg(psmouse, 0x017f, 0x15)) | ||
1408 | goto error; | ||
1409 | |||
1410 | if (alps_command_mode_write_reg(psmouse, 0x0151, 0x01)) | ||
1411 | goto error; | ||
1412 | |||
1413 | if (alps_command_mode_write_reg(psmouse, 0x0168, 0x03)) | ||
1414 | goto error; | ||
1415 | |||
1416 | if (alps_command_mode_write_reg(psmouse, 0x014a, 0x03)) | ||
1417 | goto error; | ||
1418 | |||
1419 | if (alps_command_mode_write_reg(psmouse, 0x0161, 0x03)) | ||
1420 | goto error; | ||
1421 | |||
1422 | alps_exit_command_mode(psmouse); | ||
1423 | |||
1424 | /* | ||
1425 | * This sequence changes the output from a 9-byte to an | ||
1426 | * 8-byte format. All the same data seems to be present, | ||
1427 | * just in a more compact format. | ||
1428 | */ | ||
1429 | param[0] = 0xc8; | ||
1430 | param[1] = 0x64; | ||
1431 | param[2] = 0x50; | ||
1432 | if (ps2_command(ps2dev, ¶m[0], PSMOUSE_CMD_SETRATE) || | ||
1433 | ps2_command(ps2dev, ¶m[1], PSMOUSE_CMD_SETRATE) || | ||
1434 | ps2_command(ps2dev, ¶m[2], PSMOUSE_CMD_SETRATE) || | ||
1435 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETID)) | ||
1436 | return -1; | ||
1437 | |||
1438 | /* Set rate and enable data reporting */ | ||
1439 | param[0] = 0x64; | ||
1440 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE) || | ||
1441 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) { | ||
1442 | psmouse_err(psmouse, "Failed to enable data reporting\n"); | ||
1443 | return -1; | ||
1444 | } | ||
1445 | |||
1446 | return 0; | ||
1447 | |||
1448 | error: | ||
1449 | /* | ||
1450 | * Leaving the touchpad in command mode will essentially render | ||
1451 | * it unusable until the machine reboots, so exit it here just | ||
1452 | * to be safe | ||
1453 | */ | ||
1454 | alps_exit_command_mode(psmouse); | ||
1455 | return -1; | ||
1456 | } | ||
1457 | |||
1458 | static int alps_hw_init(struct psmouse *psmouse) | ||
1459 | { | ||
1460 | struct alps_data *priv = psmouse->private; | ||
1461 | const struct alps_model_info *model = priv->i; | ||
1462 | int ret = -1; | ||
1463 | |||
1464 | switch (model->proto_version) { | ||
1465 | case ALPS_PROTO_V1: | ||
1466 | case ALPS_PROTO_V2: | ||
1467 | ret = alps_hw_init_v1_v2(psmouse); | ||
1468 | break; | ||
1469 | case ALPS_PROTO_V3: | ||
1470 | ret = alps_hw_init_v3(psmouse); | ||
1471 | break; | ||
1472 | case ALPS_PROTO_V4: | ||
1473 | ret = alps_hw_init_v4(psmouse); | ||
1474 | break; | ||
1475 | } | ||
1476 | |||
1477 | return ret; | ||
1478 | } | ||
1479 | |||
629 | static int alps_reconnect(struct psmouse *psmouse) | 1480 | static int alps_reconnect(struct psmouse *psmouse) |
630 | { | 1481 | { |
631 | const struct alps_model_info *model; | 1482 | const struct alps_model_info *model; |
@@ -666,6 +1517,8 @@ int alps_init(struct psmouse *psmouse) | |||
666 | 1517 | ||
667 | psmouse->private = priv; | 1518 | psmouse->private = priv; |
668 | 1519 | ||
1520 | psmouse_reset(psmouse); | ||
1521 | |||
669 | model = alps_get_model(psmouse, &version); | 1522 | model = alps_get_model(psmouse, &version); |
670 | if (!model) | 1523 | if (!model) |
671 | goto init_fail; | 1524 | goto init_fail; |
@@ -693,8 +1546,29 @@ int alps_init(struct psmouse *psmouse) | |||
693 | BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT); | 1546 | BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT); |
694 | 1547 | ||
695 | dev1->evbit[BIT_WORD(EV_ABS)] |= BIT_MASK(EV_ABS); | 1548 | dev1->evbit[BIT_WORD(EV_ABS)] |= BIT_MASK(EV_ABS); |
696 | input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0); | 1549 | |
697 | input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0); | 1550 | switch (model->proto_version) { |
1551 | case ALPS_PROTO_V1: | ||
1552 | case ALPS_PROTO_V2: | ||
1553 | input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0); | ||
1554 | input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0); | ||
1555 | break; | ||
1556 | case ALPS_PROTO_V3: | ||
1557 | set_bit(INPUT_PROP_SEMI_MT, dev1->propbit); | ||
1558 | input_mt_init_slots(dev1, 2); | ||
1559 | input_set_abs_params(dev1, ABS_MT_POSITION_X, 0, ALPS_V3_X_MAX, 0, 0); | ||
1560 | input_set_abs_params(dev1, ABS_MT_POSITION_Y, 0, ALPS_V3_Y_MAX, 0, 0); | ||
1561 | |||
1562 | set_bit(BTN_TOOL_DOUBLETAP, dev1->keybit); | ||
1563 | set_bit(BTN_TOOL_TRIPLETAP, dev1->keybit); | ||
1564 | set_bit(BTN_TOOL_QUADTAP, dev1->keybit); | ||
1565 | /* fall through */ | ||
1566 | case ALPS_PROTO_V4: | ||
1567 | input_set_abs_params(dev1, ABS_X, 0, ALPS_V3_X_MAX, 0, 0); | ||
1568 | input_set_abs_params(dev1, ABS_Y, 0, ALPS_V3_Y_MAX, 0, 0); | ||
1569 | break; | ||
1570 | } | ||
1571 | |||
698 | input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0); | 1572 | input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0); |
699 | 1573 | ||
700 | if (model->flags & ALPS_WHEEL) { | 1574 | if (model->flags & ALPS_WHEEL) { |
@@ -737,7 +1611,7 @@ int alps_init(struct psmouse *psmouse) | |||
737 | psmouse->poll = alps_poll; | 1611 | psmouse->poll = alps_poll; |
738 | psmouse->disconnect = alps_disconnect; | 1612 | psmouse->disconnect = alps_disconnect; |
739 | psmouse->reconnect = alps_reconnect; | 1613 | psmouse->reconnect = alps_reconnect; |
740 | psmouse->pktsize = 6; | 1614 | psmouse->pktsize = model->proto_version == ALPS_PROTO_V4 ? 8 : 6; |
741 | 1615 | ||
742 | /* We are having trouble resyncing ALPS touchpads so disable it for now */ | 1616 | /* We are having trouble resyncing ALPS touchpads so disable it for now */ |
743 | psmouse->resync_time = 0; | 1617 | psmouse->resync_time = 0; |
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h index 904ed8b3c8be..a00a4ab92a0f 100644 --- a/drivers/input/mouse/alps.h +++ b/drivers/input/mouse/alps.h | |||
@@ -12,20 +12,39 @@ | |||
12 | #ifndef _ALPS_H | 12 | #ifndef _ALPS_H |
13 | #define _ALPS_H | 13 | #define _ALPS_H |
14 | 14 | ||
15 | #define ALPS_PROTO_V1 0 | ||
16 | #define ALPS_PROTO_V2 1 | ||
17 | #define ALPS_PROTO_V3 2 | ||
18 | #define ALPS_PROTO_V4 3 | ||
19 | |||
15 | struct alps_model_info { | 20 | struct alps_model_info { |
16 | unsigned char signature[3]; | 21 | unsigned char signature[3]; |
22 | unsigned char command_mode_resp; /* v3/v4 only */ | ||
23 | unsigned char proto_version; | ||
17 | unsigned char byte0, mask0; | 24 | unsigned char byte0, mask0; |
18 | unsigned char flags; | 25 | unsigned char flags; |
19 | }; | 26 | }; |
20 | 27 | ||
28 | struct alps_nibble_commands { | ||
29 | int command; | ||
30 | unsigned char data; | ||
31 | }; | ||
32 | |||
21 | struct alps_data { | 33 | struct alps_data { |
22 | struct input_dev *dev2; /* Relative device */ | 34 | struct input_dev *dev2; /* Relative device */ |
23 | char phys[32]; /* Phys */ | 35 | char phys[32]; /* Phys */ |
24 | const struct alps_model_info *i;/* Info */ | 36 | const struct alps_model_info *i;/* Info */ |
37 | const struct alps_nibble_commands *nibble_commands; | ||
38 | int addr_command; /* Command to set register address */ | ||
25 | int prev_fin; /* Finger bit from previous packet */ | 39 | int prev_fin; /* Finger bit from previous packet */ |
40 | int multi_packet; /* Multi-packet data in progress */ | ||
41 | unsigned char multi_data[6]; /* Saved multi-packet data */ | ||
42 | u8 quirks; | ||
26 | struct timer_list timer; | 43 | struct timer_list timer; |
27 | }; | 44 | }; |
28 | 45 | ||
46 | #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */ | ||
47 | |||
29 | #ifdef CONFIG_MOUSE_PS2_ALPS | 48 | #ifdef CONFIG_MOUSE_PS2_ALPS |
30 | int alps_detect(struct psmouse *psmouse, bool set_properties); | 49 | int alps_detect(struct psmouse *psmouse, bool set_properties); |
31 | int alps_init(struct psmouse *psmouse); | 50 | int alps_init(struct psmouse *psmouse); |
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c index ff5f61a0fd3a..39be7b82c046 100644 --- a/drivers/input/mouse/amimouse.c +++ b/drivers/input/mouse/amimouse.c | |||
@@ -140,25 +140,13 @@ static int __exit amimouse_remove(struct platform_device *pdev) | |||
140 | } | 140 | } |
141 | 141 | ||
142 | static struct platform_driver amimouse_driver = { | 142 | static struct platform_driver amimouse_driver = { |
143 | .probe = amimouse_probe, | ||
143 | .remove = __exit_p(amimouse_remove), | 144 | .remove = __exit_p(amimouse_remove), |
144 | .driver = { | 145 | .driver = { |
145 | .name = "amiga-mouse", | 146 | .name = "amiga-mouse", |
146 | .owner = THIS_MODULE, | 147 | .owner = THIS_MODULE, |
147 | }, | 148 | }, |
148 | }; | 149 | }; |
149 | 150 | module_platform_driver(amimouse_driver); | |
150 | static int __init amimouse_init(void) | ||
151 | { | ||
152 | return platform_driver_probe(&amimouse_driver, amimouse_probe); | ||
153 | } | ||
154 | |||
155 | module_init(amimouse_init); | ||
156 | |||
157 | static void __exit amimouse_exit(void) | ||
158 | { | ||
159 | platform_driver_unregister(&amimouse_driver); | ||
160 | } | ||
161 | |||
162 | module_exit(amimouse_exit); | ||
163 | 151 | ||
164 | MODULE_ALIAS("platform:amiga-mouse"); | 152 | MODULE_ALIAS("platform:amiga-mouse"); |
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index e2a9867c19d5..d2c0db159b18 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c | |||
@@ -43,6 +43,24 @@ static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, | |||
43 | } | 43 | } |
44 | 44 | ||
45 | /* | 45 | /* |
46 | * V3 and later support this fast command | ||
47 | */ | ||
48 | static int elantech_send_cmd(struct psmouse *psmouse, unsigned char c, | ||
49 | unsigned char *param) | ||
50 | { | ||
51 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
52 | |||
53 | if (ps2_command(ps2dev, NULL, ETP_PS2_CUSTOM_COMMAND) || | ||
54 | ps2_command(ps2dev, NULL, c) || | ||
55 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { | ||
56 | psmouse_err(psmouse, "%s query 0x%02x failed.\n", __func__, c); | ||
57 | return -1; | ||
58 | } | ||
59 | |||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | /* | ||
46 | * A retrying version of ps2_command | 64 | * A retrying version of ps2_command |
47 | */ | 65 | */ |
48 | static int elantech_ps2_command(struct psmouse *psmouse, | 66 | static int elantech_ps2_command(struct psmouse *psmouse, |
@@ -863,13 +881,13 @@ static int elantech_set_range(struct psmouse *psmouse, | |||
863 | i = (etd->fw_version > 0x020800 && | 881 | i = (etd->fw_version > 0x020800 && |
864 | etd->fw_version < 0x020900) ? 1 : 2; | 882 | etd->fw_version < 0x020900) ? 1 : 2; |
865 | 883 | ||
866 | if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param)) | 884 | if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) |
867 | return -1; | 885 | return -1; |
868 | 886 | ||
869 | fixed_dpi = param[1] & 0x10; | 887 | fixed_dpi = param[1] & 0x10; |
870 | 888 | ||
871 | if (((etd->fw_version >> 16) == 0x14) && fixed_dpi) { | 889 | if (((etd->fw_version >> 16) == 0x14) && fixed_dpi) { |
872 | if (synaptics_send_cmd(psmouse, ETP_SAMPLE_QUERY, param)) | 890 | if (etd->send_cmd(psmouse, ETP_SAMPLE_QUERY, param)) |
873 | return -1; | 891 | return -1; |
874 | 892 | ||
875 | *x_max = (etd->capabilities[1] - i) * param[1] / 2; | 893 | *x_max = (etd->capabilities[1] - i) * param[1] / 2; |
@@ -888,7 +906,7 @@ static int elantech_set_range(struct psmouse *psmouse, | |||
888 | break; | 906 | break; |
889 | 907 | ||
890 | case 3: | 908 | case 3: |
891 | if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param)) | 909 | if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) |
892 | return -1; | 910 | return -1; |
893 | 911 | ||
894 | *x_max = (0x0f & param[0]) << 8 | param[1]; | 912 | *x_max = (0x0f & param[0]) << 8 | param[1]; |
@@ -896,7 +914,7 @@ static int elantech_set_range(struct psmouse *psmouse, | |||
896 | break; | 914 | break; |
897 | 915 | ||
898 | case 4: | 916 | case 4: |
899 | if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param)) | 917 | if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) |
900 | return -1; | 918 | return -1; |
901 | 919 | ||
902 | *x_max = (0x0f & param[0]) << 8 | param[1]; | 920 | *x_max = (0x0f & param[0]) << 8 | param[1]; |
@@ -913,6 +931,30 @@ static int elantech_set_range(struct psmouse *psmouse, | |||
913 | } | 931 | } |
914 | 932 | ||
915 | /* | 933 | /* |
934 | * (value from firmware) * 10 + 790 = dpi | ||
935 | * we also have to convert dpi to dots/mm (*10/254 to avoid floating point) | ||
936 | */ | ||
937 | static unsigned int elantech_convert_res(unsigned int val) | ||
938 | { | ||
939 | return (val * 10 + 790) * 10 / 254; | ||
940 | } | ||
941 | |||
942 | static int elantech_get_resolution_v4(struct psmouse *psmouse, | ||
943 | unsigned int *x_res, | ||
944 | unsigned int *y_res) | ||
945 | { | ||
946 | unsigned char param[3]; | ||
947 | |||
948 | if (elantech_send_cmd(psmouse, ETP_RESOLUTION_QUERY, param)) | ||
949 | return -1; | ||
950 | |||
951 | *x_res = elantech_convert_res(param[1] & 0x0f); | ||
952 | *y_res = elantech_convert_res((param[1] & 0xf0) >> 4); | ||
953 | |||
954 | return 0; | ||
955 | } | ||
956 | |||
957 | /* | ||
916 | * Set the appropriate event bits for the input subsystem | 958 | * Set the appropriate event bits for the input subsystem |
917 | */ | 959 | */ |
918 | static int elantech_set_input_params(struct psmouse *psmouse) | 960 | static int elantech_set_input_params(struct psmouse *psmouse) |
@@ -920,6 +962,7 @@ static int elantech_set_input_params(struct psmouse *psmouse) | |||
920 | struct input_dev *dev = psmouse->dev; | 962 | struct input_dev *dev = psmouse->dev; |
921 | struct elantech_data *etd = psmouse->private; | 963 | struct elantech_data *etd = psmouse->private; |
922 | unsigned int x_min = 0, y_min = 0, x_max = 0, y_max = 0, width = 0; | 964 | unsigned int x_min = 0, y_min = 0, x_max = 0, y_max = 0, width = 0; |
965 | unsigned int x_res = 0, y_res = 0; | ||
923 | 966 | ||
924 | if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width)) | 967 | if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width)) |
925 | return -1; | 968 | return -1; |
@@ -967,10 +1010,20 @@ static int elantech_set_input_params(struct psmouse *psmouse) | |||
967 | break; | 1010 | break; |
968 | 1011 | ||
969 | case 4: | 1012 | case 4: |
1013 | if (elantech_get_resolution_v4(psmouse, &x_res, &y_res)) { | ||
1014 | /* | ||
1015 | * if query failed, print a warning and leave the values | ||
1016 | * zero to resemble synaptics.c behavior. | ||
1017 | */ | ||
1018 | psmouse_warn(psmouse, "couldn't query resolution data.\n"); | ||
1019 | } | ||
1020 | |||
970 | __set_bit(BTN_TOOL_QUADTAP, dev->keybit); | 1021 | __set_bit(BTN_TOOL_QUADTAP, dev->keybit); |
971 | /* For X to recognize me as touchpad. */ | 1022 | /* For X to recognize me as touchpad. */ |
972 | input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); | 1023 | input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); |
973 | input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0); | 1024 | input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0); |
1025 | input_abs_set_res(dev, ABS_X, x_res); | ||
1026 | input_abs_set_res(dev, ABS_Y, y_res); | ||
974 | /* | 1027 | /* |
975 | * range of pressure and width is the same as v2, | 1028 | * range of pressure and width is the same as v2, |
976 | * report ABS_PRESSURE, ABS_TOOL_WIDTH for compatibility. | 1029 | * report ABS_PRESSURE, ABS_TOOL_WIDTH for compatibility. |
@@ -983,6 +1036,8 @@ static int elantech_set_input_params(struct psmouse *psmouse) | |||
983 | input_mt_init_slots(dev, ETP_MAX_FINGERS); | 1036 | input_mt_init_slots(dev, ETP_MAX_FINGERS); |
984 | input_set_abs_params(dev, ABS_MT_POSITION_X, x_min, x_max, 0, 0); | 1037 | input_set_abs_params(dev, ABS_MT_POSITION_X, x_min, x_max, 0, 0); |
985 | input_set_abs_params(dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0); | 1038 | input_set_abs_params(dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0); |
1039 | input_abs_set_res(dev, ABS_MT_POSITION_X, x_res); | ||
1040 | input_abs_set_res(dev, ABS_MT_POSITION_Y, y_res); | ||
986 | input_set_abs_params(dev, ABS_MT_PRESSURE, ETP_PMIN_V2, | 1041 | input_set_abs_params(dev, ABS_MT_PRESSURE, ETP_PMIN_V2, |
987 | ETP_PMAX_V2, 0, 0); | 1042 | ETP_PMAX_V2, 0, 0); |
988 | /* | 1043 | /* |
@@ -1031,16 +1086,13 @@ static ssize_t elantech_set_int_attr(struct psmouse *psmouse, | |||
1031 | struct elantech_data *etd = psmouse->private; | 1086 | struct elantech_data *etd = psmouse->private; |
1032 | struct elantech_attr_data *attr = data; | 1087 | struct elantech_attr_data *attr = data; |
1033 | unsigned char *reg = (unsigned char *) etd + attr->field_offset; | 1088 | unsigned char *reg = (unsigned char *) etd + attr->field_offset; |
1034 | unsigned long value; | 1089 | unsigned char value; |
1035 | int err; | 1090 | int err; |
1036 | 1091 | ||
1037 | err = strict_strtoul(buf, 16, &value); | 1092 | err = kstrtou8(buf, 16, &value); |
1038 | if (err) | 1093 | if (err) |
1039 | return err; | 1094 | return err; |
1040 | 1095 | ||
1041 | if (value > 0xff) | ||
1042 | return -EINVAL; | ||
1043 | |||
1044 | /* Do we need to preserve some bits for version 2 hardware too? */ | 1096 | /* Do we need to preserve some bits for version 2 hardware too? */ |
1045 | if (etd->hw_version == 1) { | 1097 | if (etd->hw_version == 1) { |
1046 | if (attr->reg == 0x10) | 1098 | if (attr->reg == 0x10) |
@@ -1233,9 +1285,11 @@ static int elantech_set_properties(struct elantech_data *etd) | |||
1233 | } | 1285 | } |
1234 | } | 1286 | } |
1235 | 1287 | ||
1236 | /* | 1288 | /* decide which send_cmd we're gonna use early */ |
1237 | * Turn on packet checking by default. | 1289 | etd->send_cmd = etd->hw_version >= 3 ? elantech_send_cmd : |
1238 | */ | 1290 | synaptics_send_cmd; |
1291 | |||
1292 | /* Turn on packet checking by default */ | ||
1239 | etd->paritycheck = 1; | 1293 | etd->paritycheck = 1; |
1240 | 1294 | ||
1241 | /* | 1295 | /* |
@@ -1291,7 +1345,7 @@ int elantech_init(struct psmouse *psmouse) | |||
1291 | "assuming hardware version %d (with firmware version 0x%02x%02x%02x)\n", | 1345 | "assuming hardware version %d (with firmware version 0x%02x%02x%02x)\n", |
1292 | etd->hw_version, param[0], param[1], param[2]); | 1346 | etd->hw_version, param[0], param[1], param[2]); |
1293 | 1347 | ||
1294 | if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY, | 1348 | if (etd->send_cmd(psmouse, ETP_CAPABILITIES_QUERY, |
1295 | etd->capabilities)) { | 1349 | etd->capabilities)) { |
1296 | psmouse_err(psmouse, "failed to query capabilities.\n"); | 1350 | psmouse_err(psmouse, "failed to query capabilities.\n"); |
1297 | goto init_fail; | 1351 | goto init_fail; |
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h index 9e5f1aabea7e..46db3be45ac9 100644 --- a/drivers/input/mouse/elantech.h +++ b/drivers/input/mouse/elantech.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #define ETP_FW_VERSION_QUERY 0x01 | 20 | #define ETP_FW_VERSION_QUERY 0x01 |
21 | #define ETP_CAPABILITIES_QUERY 0x02 | 21 | #define ETP_CAPABILITIES_QUERY 0x02 |
22 | #define ETP_SAMPLE_QUERY 0x03 | 22 | #define ETP_SAMPLE_QUERY 0x03 |
23 | #define ETP_RESOLUTION_QUERY 0x04 | ||
23 | 24 | ||
24 | /* | 25 | /* |
25 | * Command values for register reading or writing | 26 | * Command values for register reading or writing |
@@ -135,6 +136,7 @@ struct elantech_data { | |||
135 | unsigned int width; | 136 | unsigned int width; |
136 | struct finger_pos mt[ETP_MAX_FINGERS]; | 137 | struct finger_pos mt[ETP_MAX_FINGERS]; |
137 | unsigned char parity[256]; | 138 | unsigned char parity[256]; |
139 | int (*send_cmd)(struct psmouse *psmouse, unsigned char c, unsigned char *param); | ||
138 | }; | 140 | }; |
139 | 141 | ||
140 | #ifdef CONFIG_MOUSE_PS2_ELANTECH | 142 | #ifdef CONFIG_MOUSE_PS2_ELANTECH |
diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c index 58902fbb9896..a9ad8e1402be 100644 --- a/drivers/input/mouse/gpio_mouse.c +++ b/drivers/input/mouse/gpio_mouse.c | |||
@@ -178,18 +178,7 @@ static struct platform_driver gpio_mouse_device_driver = { | |||
178 | .owner = THIS_MODULE, | 178 | .owner = THIS_MODULE, |
179 | } | 179 | } |
180 | }; | 180 | }; |
181 | 181 | module_platform_driver(gpio_mouse_device_driver); | |
182 | static int __init gpio_mouse_init(void) | ||
183 | { | ||
184 | return platform_driver_register(&gpio_mouse_device_driver); | ||
185 | } | ||
186 | module_init(gpio_mouse_init); | ||
187 | |||
188 | static void __exit gpio_mouse_exit(void) | ||
189 | { | ||
190 | platform_driver_unregister(&gpio_mouse_device_driver); | ||
191 | } | ||
192 | module_exit(gpio_mouse_exit); | ||
193 | 182 | ||
194 | MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>"); | 183 | MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>"); |
195 | MODULE_DESCRIPTION("GPIO mouse driver"); | 184 | MODULE_DESCRIPTION("GPIO mouse driver"); |
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c index 0470dd46b566..1c5d521de600 100644 --- a/drivers/input/mouse/hgpk.c +++ b/drivers/input/mouse/hgpk.c | |||
@@ -789,11 +789,14 @@ static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data, | |||
789 | const char *buf, size_t count) | 789 | const char *buf, size_t count) |
790 | { | 790 | { |
791 | struct hgpk_data *priv = psmouse->private; | 791 | struct hgpk_data *priv = psmouse->private; |
792 | unsigned long value; | 792 | unsigned int value; |
793 | int err; | 793 | int err; |
794 | 794 | ||
795 | err = strict_strtoul(buf, 10, &value); | 795 | err = kstrtouint(buf, 10, &value); |
796 | if (err || value > 1) | 796 | if (err) |
797 | return err; | ||
798 | |||
799 | if (value > 1) | ||
797 | return -EINVAL; | 800 | return -EINVAL; |
798 | 801 | ||
799 | if (value != priv->powered) { | 802 | if (value != priv->powered) { |
@@ -881,11 +884,14 @@ static ssize_t hgpk_trigger_recal(struct psmouse *psmouse, void *data, | |||
881 | const char *buf, size_t count) | 884 | const char *buf, size_t count) |
882 | { | 885 | { |
883 | struct hgpk_data *priv = psmouse->private; | 886 | struct hgpk_data *priv = psmouse->private; |
884 | unsigned long value; | 887 | unsigned int value; |
885 | int err; | 888 | int err; |
886 | 889 | ||
887 | err = strict_strtoul(buf, 10, &value); | 890 | err = kstrtouint(buf, 10, &value); |
888 | if (err || value != 1) | 891 | if (err) |
892 | return err; | ||
893 | |||
894 | if (value != 1) | ||
889 | return -EINVAL; | 895 | return -EINVAL; |
890 | 896 | ||
891 | /* | 897 | /* |
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index faac2c3bef74..84de2fc6acc1 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c | |||
@@ -155,9 +155,14 @@ static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse, | |||
155 | static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, | 155 | static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, |
156 | const char *buf, size_t count) | 156 | const char *buf, size_t count) |
157 | { | 157 | { |
158 | unsigned long value; | 158 | unsigned int value; |
159 | int err; | ||
159 | 160 | ||
160 | if (strict_strtoul(buf, 10, &value) || value > 1) | 161 | err = kstrtouint(buf, 10, &value); |
162 | if (err) | ||
163 | return err; | ||
164 | |||
165 | if (value > 1) | ||
161 | return -EINVAL; | 166 | return -EINVAL; |
162 | 167 | ||
163 | ps2pp_set_smartscroll(psmouse, value); | 168 | ps2pp_set_smartscroll(psmouse, value); |
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 9f352fbd7b4f..de7e8bc17b1f 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -127,7 +127,7 @@ struct psmouse_protocol { | |||
127 | * relevant events to the input module once full packet has arrived. | 127 | * relevant events to the input module once full packet has arrived. |
128 | */ | 128 | */ |
129 | 129 | ||
130 | static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse) | 130 | psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse) |
131 | { | 131 | { |
132 | struct input_dev *dev = psmouse->dev; | 132 | struct input_dev *dev = psmouse->dev; |
133 | unsigned char *packet = psmouse->packet; | 133 | unsigned char *packet = psmouse->packet; |
@@ -418,6 +418,49 @@ int psmouse_reset(struct psmouse *psmouse) | |||
418 | return 0; | 418 | return 0; |
419 | } | 419 | } |
420 | 420 | ||
421 | /* | ||
422 | * Here we set the mouse resolution. | ||
423 | */ | ||
424 | |||
425 | void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution) | ||
426 | { | ||
427 | static const unsigned char params[] = { 0, 1, 2, 2, 3 }; | ||
428 | unsigned char p; | ||
429 | |||
430 | if (resolution == 0 || resolution > 200) | ||
431 | resolution = 200; | ||
432 | |||
433 | p = params[resolution / 50]; | ||
434 | ps2_command(&psmouse->ps2dev, &p, PSMOUSE_CMD_SETRES); | ||
435 | psmouse->resolution = 25 << p; | ||
436 | } | ||
437 | |||
438 | /* | ||
439 | * Here we set the mouse report rate. | ||
440 | */ | ||
441 | |||
442 | static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate) | ||
443 | { | ||
444 | static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 }; | ||
445 | unsigned char r; | ||
446 | int i = 0; | ||
447 | |||
448 | while (rates[i] > rate) i++; | ||
449 | r = rates[i]; | ||
450 | ps2_command(&psmouse->ps2dev, &r, PSMOUSE_CMD_SETRATE); | ||
451 | psmouse->rate = r; | ||
452 | } | ||
453 | |||
454 | /* | ||
455 | * psmouse_poll() - default poll handler. Everyone except for ALPS uses it. | ||
456 | */ | ||
457 | |||
458 | static int psmouse_poll(struct psmouse *psmouse) | ||
459 | { | ||
460 | return ps2_command(&psmouse->ps2dev, psmouse->packet, | ||
461 | PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)); | ||
462 | } | ||
463 | |||
421 | 464 | ||
422 | /* | 465 | /* |
423 | * Genius NetMouse magic init. | 466 | * Genius NetMouse magic init. |
@@ -603,6 +646,56 @@ static int cortron_detect(struct psmouse *psmouse, bool set_properties) | |||
603 | } | 646 | } |
604 | 647 | ||
605 | /* | 648 | /* |
649 | * Apply default settings to the psmouse structure. Most of them will | ||
650 | * be overridden by individual protocol initialization routines. | ||
651 | */ | ||
652 | |||
653 | static void psmouse_apply_defaults(struct psmouse *psmouse) | ||
654 | { | ||
655 | struct input_dev *input_dev = psmouse->dev; | ||
656 | |||
657 | memset(input_dev->evbit, 0, sizeof(input_dev->evbit)); | ||
658 | memset(input_dev->keybit, 0, sizeof(input_dev->keybit)); | ||
659 | memset(input_dev->relbit, 0, sizeof(input_dev->relbit)); | ||
660 | memset(input_dev->absbit, 0, sizeof(input_dev->absbit)); | ||
661 | memset(input_dev->mscbit, 0, sizeof(input_dev->mscbit)); | ||
662 | |||
663 | __set_bit(EV_KEY, input_dev->evbit); | ||
664 | __set_bit(EV_REL, input_dev->evbit); | ||
665 | |||
666 | __set_bit(BTN_LEFT, input_dev->keybit); | ||
667 | __set_bit(BTN_RIGHT, input_dev->keybit); | ||
668 | |||
669 | __set_bit(REL_X, input_dev->relbit); | ||
670 | __set_bit(REL_Y, input_dev->relbit); | ||
671 | |||
672 | psmouse->set_rate = psmouse_set_rate; | ||
673 | psmouse->set_resolution = psmouse_set_resolution; | ||
674 | psmouse->poll = psmouse_poll; | ||
675 | psmouse->protocol_handler = psmouse_process_byte; | ||
676 | psmouse->pktsize = 3; | ||
677 | psmouse->reconnect = NULL; | ||
678 | psmouse->disconnect = NULL; | ||
679 | psmouse->cleanup = NULL; | ||
680 | psmouse->pt_activate = NULL; | ||
681 | psmouse->pt_deactivate = NULL; | ||
682 | } | ||
683 | |||
684 | /* | ||
685 | * Apply default settings to the psmouse structure and call specified | ||
686 | * protocol detection or initialization routine. | ||
687 | */ | ||
688 | static int psmouse_do_detect(int (*detect)(struct psmouse *psmouse, | ||
689 | bool set_properties), | ||
690 | struct psmouse *psmouse, bool set_properties) | ||
691 | { | ||
692 | if (set_properties) | ||
693 | psmouse_apply_defaults(psmouse); | ||
694 | |||
695 | return detect(psmouse, set_properties); | ||
696 | } | ||
697 | |||
698 | /* | ||
606 | * psmouse_extensions() probes for any extensions to the basic PS/2 protocol | 699 | * psmouse_extensions() probes for any extensions to the basic PS/2 protocol |
607 | * the mouse may have. | 700 | * the mouse may have. |
608 | */ | 701 | */ |
@@ -616,7 +709,7 @@ static int psmouse_extensions(struct psmouse *psmouse, | |||
616 | * We always check for lifebook because it does not disturb mouse | 709 | * We always check for lifebook because it does not disturb mouse |
617 | * (it only checks DMI information). | 710 | * (it only checks DMI information). |
618 | */ | 711 | */ |
619 | if (lifebook_detect(psmouse, set_properties) == 0) { | 712 | if (psmouse_do_detect(lifebook_detect, psmouse, set_properties) == 0) { |
620 | if (max_proto > PSMOUSE_IMEX) { | 713 | if (max_proto > PSMOUSE_IMEX) { |
621 | if (!set_properties || lifebook_init(psmouse) == 0) | 714 | if (!set_properties || lifebook_init(psmouse) == 0) |
622 | return PSMOUSE_LIFEBOOK; | 715 | return PSMOUSE_LIFEBOOK; |
@@ -628,15 +721,18 @@ static int psmouse_extensions(struct psmouse *psmouse, | |||
628 | * upsets the thinkingmouse). | 721 | * upsets the thinkingmouse). |
629 | */ | 722 | */ |
630 | 723 | ||
631 | if (max_proto > PSMOUSE_IMEX && thinking_detect(psmouse, set_properties) == 0) | 724 | if (max_proto > PSMOUSE_IMEX && |
725 | psmouse_do_detect(thinking_detect, psmouse, set_properties) == 0) { | ||
632 | return PSMOUSE_THINKPS; | 726 | return PSMOUSE_THINKPS; |
727 | } | ||
633 | 728 | ||
634 | /* | 729 | /* |
635 | * Try Synaptics TouchPad. Note that probing is done even if Synaptics protocol | 730 | * Try Synaptics TouchPad. Note that probing is done even if Synaptics protocol |
636 | * support is disabled in config - we need to know if it is synaptics so we | 731 | * support is disabled in config - we need to know if it is synaptics so we |
637 | * can reset it properly after probing for intellimouse. | 732 | * can reset it properly after probing for intellimouse. |
638 | */ | 733 | */ |
639 | if (max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse, set_properties) == 0) { | 734 | if (max_proto > PSMOUSE_PS2 && |
735 | psmouse_do_detect(synaptics_detect, psmouse, set_properties) == 0) { | ||
640 | synaptics_hardware = true; | 736 | synaptics_hardware = true; |
641 | 737 | ||
642 | if (max_proto > PSMOUSE_IMEX) { | 738 | if (max_proto > PSMOUSE_IMEX) { |
@@ -667,7 +763,8 @@ static int psmouse_extensions(struct psmouse *psmouse, | |||
667 | */ | 763 | */ |
668 | if (max_proto > PSMOUSE_IMEX) { | 764 | if (max_proto > PSMOUSE_IMEX) { |
669 | ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); | 765 | ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); |
670 | if (alps_detect(psmouse, set_properties) == 0) { | 766 | if (psmouse_do_detect(alps_detect, |
767 | psmouse, set_properties) == 0) { | ||
671 | if (!set_properties || alps_init(psmouse) == 0) | 768 | if (!set_properties || alps_init(psmouse) == 0) |
672 | return PSMOUSE_ALPS; | 769 | return PSMOUSE_ALPS; |
673 | /* | 770 | /* |
@@ -681,7 +778,7 @@ static int psmouse_extensions(struct psmouse *psmouse, | |||
681 | * Try OLPC HGPK touchpad. | 778 | * Try OLPC HGPK touchpad. |
682 | */ | 779 | */ |
683 | if (max_proto > PSMOUSE_IMEX && | 780 | if (max_proto > PSMOUSE_IMEX && |
684 | hgpk_detect(psmouse, set_properties) == 0) { | 781 | psmouse_do_detect(hgpk_detect, psmouse, set_properties) == 0) { |
685 | if (!set_properties || hgpk_init(psmouse) == 0) | 782 | if (!set_properties || hgpk_init(psmouse) == 0) |
686 | return PSMOUSE_HGPK; | 783 | return PSMOUSE_HGPK; |
687 | /* | 784 | /* |
@@ -694,7 +791,7 @@ static int psmouse_extensions(struct psmouse *psmouse, | |||
694 | * Try Elantech touchpad. | 791 | * Try Elantech touchpad. |
695 | */ | 792 | */ |
696 | if (max_proto > PSMOUSE_IMEX && | 793 | if (max_proto > PSMOUSE_IMEX && |
697 | elantech_detect(psmouse, set_properties) == 0) { | 794 | psmouse_do_detect(elantech_detect, psmouse, set_properties) == 0) { |
698 | if (!set_properties || elantech_init(psmouse) == 0) | 795 | if (!set_properties || elantech_init(psmouse) == 0) |
699 | return PSMOUSE_ELANTECH; | 796 | return PSMOUSE_ELANTECH; |
700 | /* | 797 | /* |
@@ -703,18 +800,21 @@ static int psmouse_extensions(struct psmouse *psmouse, | |||
703 | max_proto = PSMOUSE_IMEX; | 800 | max_proto = PSMOUSE_IMEX; |
704 | } | 801 | } |
705 | 802 | ||
706 | |||
707 | if (max_proto > PSMOUSE_IMEX) { | 803 | if (max_proto > PSMOUSE_IMEX) { |
708 | if (genius_detect(psmouse, set_properties) == 0) | 804 | if (psmouse_do_detect(genius_detect, |
805 | psmouse, set_properties) == 0) | ||
709 | return PSMOUSE_GENPS; | 806 | return PSMOUSE_GENPS; |
710 | 807 | ||
711 | if (ps2pp_init(psmouse, set_properties) == 0) | 808 | if (psmouse_do_detect(ps2pp_init, |
809 | psmouse, set_properties) == 0) | ||
712 | return PSMOUSE_PS2PP; | 810 | return PSMOUSE_PS2PP; |
713 | 811 | ||
714 | if (trackpoint_detect(psmouse, set_properties) == 0) | 812 | if (psmouse_do_detect(trackpoint_detect, |
813 | psmouse, set_properties) == 0) | ||
715 | return PSMOUSE_TRACKPOINT; | 814 | return PSMOUSE_TRACKPOINT; |
716 | 815 | ||
717 | if (touchkit_ps2_detect(psmouse, set_properties) == 0) | 816 | if (psmouse_do_detect(touchkit_ps2_detect, |
817 | psmouse, set_properties) == 0) | ||
718 | return PSMOUSE_TOUCHKIT_PS2; | 818 | return PSMOUSE_TOUCHKIT_PS2; |
719 | } | 819 | } |
720 | 820 | ||
@@ -723,7 +823,8 @@ static int psmouse_extensions(struct psmouse *psmouse, | |||
723 | * Trackpoint devices (causing TP_READ_ID command to time out). | 823 | * Trackpoint devices (causing TP_READ_ID command to time out). |
724 | */ | 824 | */ |
725 | if (max_proto > PSMOUSE_IMEX) { | 825 | if (max_proto > PSMOUSE_IMEX) { |
726 | if (fsp_detect(psmouse, set_properties) == 0) { | 826 | if (psmouse_do_detect(fsp_detect, |
827 | psmouse, set_properties) == 0) { | ||
727 | if (!set_properties || fsp_init(psmouse) == 0) | 828 | if (!set_properties || fsp_init(psmouse) == 0) |
728 | return PSMOUSE_FSP; | 829 | return PSMOUSE_FSP; |
729 | /* | 830 | /* |
@@ -741,17 +842,23 @@ static int psmouse_extensions(struct psmouse *psmouse, | |||
741 | ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); | 842 | ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); |
742 | psmouse_reset(psmouse); | 843 | psmouse_reset(psmouse); |
743 | 844 | ||
744 | if (max_proto >= PSMOUSE_IMEX && im_explorer_detect(psmouse, set_properties) == 0) | 845 | if (max_proto >= PSMOUSE_IMEX && |
846 | psmouse_do_detect(im_explorer_detect, | ||
847 | psmouse, set_properties) == 0) { | ||
745 | return PSMOUSE_IMEX; | 848 | return PSMOUSE_IMEX; |
849 | } | ||
746 | 850 | ||
747 | if (max_proto >= PSMOUSE_IMPS && intellimouse_detect(psmouse, set_properties) == 0) | 851 | if (max_proto >= PSMOUSE_IMPS && |
852 | psmouse_do_detect(intellimouse_detect, | ||
853 | psmouse, set_properties) == 0) { | ||
748 | return PSMOUSE_IMPS; | 854 | return PSMOUSE_IMPS; |
855 | } | ||
749 | 856 | ||
750 | /* | 857 | /* |
751 | * Okay, all failed, we have a standard mouse here. The number of the buttons | 858 | * Okay, all failed, we have a standard mouse here. The number of the buttons |
752 | * is still a question, though. We assume 3. | 859 | * is still a question, though. We assume 3. |
753 | */ | 860 | */ |
754 | ps2bare_detect(psmouse, set_properties); | 861 | psmouse_do_detect(ps2bare_detect, psmouse, set_properties); |
755 | 862 | ||
756 | if (synaptics_hardware) { | 863 | if (synaptics_hardware) { |
757 | /* | 864 | /* |
@@ -819,6 +926,13 @@ static const struct psmouse_protocol psmouse_protocols[] = { | |||
819 | .detect = synaptics_detect, | 926 | .detect = synaptics_detect, |
820 | .init = synaptics_init, | 927 | .init = synaptics_init, |
821 | }, | 928 | }, |
929 | { | ||
930 | .type = PSMOUSE_SYNAPTICS_RELATIVE, | ||
931 | .name = "SynRelPS/2", | ||
932 | .alias = "synaptics-relative", | ||
933 | .detect = synaptics_detect, | ||
934 | .init = synaptics_init_relative, | ||
935 | }, | ||
822 | #endif | 936 | #endif |
823 | #ifdef CONFIG_MOUSE_PS2_ALPS | 937 | #ifdef CONFIG_MOUSE_PS2_ALPS |
824 | { | 938 | { |
@@ -958,39 +1072,6 @@ static int psmouse_probe(struct psmouse *psmouse) | |||
958 | } | 1072 | } |
959 | 1073 | ||
960 | /* | 1074 | /* |
961 | * Here we set the mouse resolution. | ||
962 | */ | ||
963 | |||
964 | void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution) | ||
965 | { | ||
966 | static const unsigned char params[] = { 0, 1, 2, 2, 3 }; | ||
967 | unsigned char p; | ||
968 | |||
969 | if (resolution == 0 || resolution > 200) | ||
970 | resolution = 200; | ||
971 | |||
972 | p = params[resolution / 50]; | ||
973 | ps2_command(&psmouse->ps2dev, &p, PSMOUSE_CMD_SETRES); | ||
974 | psmouse->resolution = 25 << p; | ||
975 | } | ||
976 | |||
977 | /* | ||
978 | * Here we set the mouse report rate. | ||
979 | */ | ||
980 | |||
981 | static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate) | ||
982 | { | ||
983 | static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 }; | ||
984 | unsigned char r; | ||
985 | int i = 0; | ||
986 | |||
987 | while (rates[i] > rate) i++; | ||
988 | r = rates[i]; | ||
989 | ps2_command(&psmouse->ps2dev, &r, PSMOUSE_CMD_SETRATE); | ||
990 | psmouse->rate = r; | ||
991 | } | ||
992 | |||
993 | /* | ||
994 | * psmouse_initialize() initializes the mouse to a sane state. | 1075 | * psmouse_initialize() initializes the mouse to a sane state. |
995 | */ | 1076 | */ |
996 | 1077 | ||
@@ -1035,16 +1116,6 @@ static void psmouse_deactivate(struct psmouse *psmouse) | |||
1035 | psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); | 1116 | psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); |
1036 | } | 1117 | } |
1037 | 1118 | ||
1038 | /* | ||
1039 | * psmouse_poll() - default poll handler. Everyone except for ALPS uses it. | ||
1040 | */ | ||
1041 | |||
1042 | static int psmouse_poll(struct psmouse *psmouse) | ||
1043 | { | ||
1044 | return ps2_command(&psmouse->ps2dev, psmouse->packet, | ||
1045 | PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)); | ||
1046 | } | ||
1047 | |||
1048 | 1119 | ||
1049 | /* | 1120 | /* |
1050 | * psmouse_resync() attempts to re-validate current protocol. | 1121 | * psmouse_resync() attempts to re-validate current protocol. |
@@ -1245,18 +1316,9 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, | |||
1245 | 1316 | ||
1246 | input_dev->dev.parent = &psmouse->ps2dev.serio->dev; | 1317 | input_dev->dev.parent = &psmouse->ps2dev.serio->dev; |
1247 | 1318 | ||
1248 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); | ||
1249 | input_dev->keybit[BIT_WORD(BTN_MOUSE)] = | ||
1250 | BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT); | ||
1251 | input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); | ||
1252 | |||
1253 | psmouse->set_rate = psmouse_set_rate; | ||
1254 | psmouse->set_resolution = psmouse_set_resolution; | ||
1255 | psmouse->poll = psmouse_poll; | ||
1256 | psmouse->protocol_handler = psmouse_process_byte; | ||
1257 | psmouse->pktsize = 3; | ||
1258 | |||
1259 | if (proto && (proto->detect || proto->init)) { | 1319 | if (proto && (proto->detect || proto->init)) { |
1320 | psmouse_apply_defaults(psmouse); | ||
1321 | |||
1260 | if (proto->detect && proto->detect(psmouse, true) < 0) | 1322 | if (proto->detect && proto->detect(psmouse, true) < 0) |
1261 | return -1; | 1323 | return -1; |
1262 | 1324 | ||
@@ -1558,13 +1620,12 @@ static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char | |||
1558 | static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count) | 1620 | static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count) |
1559 | { | 1621 | { |
1560 | unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); | 1622 | unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); |
1561 | unsigned long value; | 1623 | unsigned int value; |
1562 | 1624 | int err; | |
1563 | if (strict_strtoul(buf, 10, &value)) | ||
1564 | return -EINVAL; | ||
1565 | 1625 | ||
1566 | if ((unsigned int)value != value) | 1626 | err = kstrtouint(buf, 10, &value); |
1567 | return -EINVAL; | 1627 | if (err) |
1628 | return err; | ||
1568 | 1629 | ||
1569 | *field = value; | 1630 | *field = value; |
1570 | 1631 | ||
@@ -1671,10 +1732,12 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co | |||
1671 | 1732 | ||
1672 | static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) | 1733 | static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) |
1673 | { | 1734 | { |
1674 | unsigned long value; | 1735 | unsigned int value; |
1736 | int err; | ||
1675 | 1737 | ||
1676 | if (strict_strtoul(buf, 10, &value)) | 1738 | err = kstrtouint(buf, 10, &value); |
1677 | return -EINVAL; | 1739 | if (err) |
1740 | return err; | ||
1678 | 1741 | ||
1679 | psmouse->set_rate(psmouse, value); | 1742 | psmouse->set_rate(psmouse, value); |
1680 | return count; | 1743 | return count; |
@@ -1682,10 +1745,12 @@ static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const | |||
1682 | 1745 | ||
1683 | static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) | 1746 | static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) |
1684 | { | 1747 | { |
1685 | unsigned long value; | 1748 | unsigned int value; |
1749 | int err; | ||
1686 | 1750 | ||
1687 | if (strict_strtoul(buf, 10, &value)) | 1751 | err = kstrtouint(buf, 10, &value); |
1688 | return -EINVAL; | 1752 | if (err) |
1753 | return err; | ||
1689 | 1754 | ||
1690 | psmouse->set_resolution(psmouse, value); | 1755 | psmouse->set_resolution(psmouse, value); |
1691 | return count; | 1756 | return count; |
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index 9b84b0c4e371..6a417092d010 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h | |||
@@ -8,6 +8,7 @@ | |||
8 | #define PSMOUSE_CMD_SETSTREAM 0x00ea | 8 | #define PSMOUSE_CMD_SETSTREAM 0x00ea |
9 | #define PSMOUSE_CMD_SETPOLL 0x00f0 | 9 | #define PSMOUSE_CMD_SETPOLL 0x00f0 |
10 | #define PSMOUSE_CMD_POLL 0x00eb /* caller sets number of bytes to receive */ | 10 | #define PSMOUSE_CMD_POLL 0x00eb /* caller sets number of bytes to receive */ |
11 | #define PSMOUSE_CMD_RESET_WRAP 0x00ec | ||
11 | #define PSMOUSE_CMD_GETID 0x02f2 | 12 | #define PSMOUSE_CMD_GETID 0x02f2 |
12 | #define PSMOUSE_CMD_SETRATE 0x10f3 | 13 | #define PSMOUSE_CMD_SETRATE 0x10f3 |
13 | #define PSMOUSE_CMD_ENABLE 0x00f4 | 14 | #define PSMOUSE_CMD_ENABLE 0x00f4 |
@@ -93,6 +94,7 @@ enum psmouse_type { | |||
93 | PSMOUSE_HGPK, | 94 | PSMOUSE_HGPK, |
94 | PSMOUSE_ELANTECH, | 95 | PSMOUSE_ELANTECH, |
95 | PSMOUSE_FSP, | 96 | PSMOUSE_FSP, |
97 | PSMOUSE_SYNAPTICS_RELATIVE, | ||
96 | PSMOUSE_AUTO /* This one should always be last */ | 98 | PSMOUSE_AUTO /* This one should always be last */ |
97 | }; | 99 | }; |
98 | 100 | ||
@@ -102,6 +104,7 @@ int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); | |||
102 | int psmouse_reset(struct psmouse *psmouse); | 104 | int psmouse_reset(struct psmouse *psmouse); |
103 | void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state); | 105 | void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state); |
104 | void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); | 106 | void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); |
107 | psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse); | ||
105 | 108 | ||
106 | struct psmouse_attribute { | 109 | struct psmouse_attribute { |
107 | struct device_attribute dattr; | 110 | struct device_attribute dattr; |
diff --git a/drivers/input/mouse/pxa930_trkball.c b/drivers/input/mouse/pxa930_trkball.c index ee3b0ca9d592..a9e4bfdf31f4 100644 --- a/drivers/input/mouse/pxa930_trkball.c +++ b/drivers/input/mouse/pxa930_trkball.c | |||
@@ -250,19 +250,7 @@ static struct platform_driver pxa930_trkball_driver = { | |||
250 | .probe = pxa930_trkball_probe, | 250 | .probe = pxa930_trkball_probe, |
251 | .remove = __devexit_p(pxa930_trkball_remove), | 251 | .remove = __devexit_p(pxa930_trkball_remove), |
252 | }; | 252 | }; |
253 | 253 | module_platform_driver(pxa930_trkball_driver); | |
254 | static int __init pxa930_trkball_init(void) | ||
255 | { | ||
256 | return platform_driver_register(&pxa930_trkball_driver); | ||
257 | } | ||
258 | |||
259 | static void __exit pxa930_trkball_exit(void) | ||
260 | { | ||
261 | platform_driver_unregister(&pxa930_trkball_driver); | ||
262 | } | ||
263 | |||
264 | module_init(pxa930_trkball_init); | ||
265 | module_exit(pxa930_trkball_exit); | ||
266 | 254 | ||
267 | MODULE_AUTHOR("Yong Yao <yaoyong@marvell.com>"); | 255 | MODULE_AUTHOR("Yong Yao <yaoyong@marvell.com>"); |
268 | MODULE_DESCRIPTION("PXA930 Trackball Mouse Driver"); | 256 | MODULE_DESCRIPTION("PXA930 Trackball Mouse Driver"); |
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c index 86d6f39178b0..e36847de7617 100644 --- a/drivers/input/mouse/sentelic.c +++ b/drivers/input/mouse/sentelic.c | |||
@@ -408,7 +408,7 @@ static int fsp_onpad_hscr(struct psmouse *psmouse, bool enable) | |||
408 | static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data, | 408 | static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data, |
409 | const char *buf, size_t count) | 409 | const char *buf, size_t count) |
410 | { | 410 | { |
411 | unsigned long reg, val; | 411 | int reg, val; |
412 | char *rest; | 412 | char *rest; |
413 | ssize_t retval; | 413 | ssize_t retval; |
414 | 414 | ||
@@ -416,7 +416,11 @@ static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data, | |||
416 | if (rest == buf || *rest != ' ' || reg > 0xff) | 416 | if (rest == buf || *rest != ' ' || reg > 0xff) |
417 | return -EINVAL; | 417 | return -EINVAL; |
418 | 418 | ||
419 | if (strict_strtoul(rest + 1, 16, &val) || val > 0xff) | 419 | retval = kstrtoint(rest + 1, 16, &val); |
420 | if (retval) | ||
421 | return retval; | ||
422 | |||
423 | if (val > 0xff) | ||
420 | return -EINVAL; | 424 | return -EINVAL; |
421 | 425 | ||
422 | if (fsp_reg_write_enable(psmouse, true)) | 426 | if (fsp_reg_write_enable(psmouse, true)) |
@@ -448,10 +452,13 @@ static ssize_t fsp_attr_set_getreg(struct psmouse *psmouse, void *data, | |||
448 | const char *buf, size_t count) | 452 | const char *buf, size_t count) |
449 | { | 453 | { |
450 | struct fsp_data *pad = psmouse->private; | 454 | struct fsp_data *pad = psmouse->private; |
451 | unsigned long reg; | 455 | int reg, val, err; |
452 | int val; | 456 | |
457 | err = kstrtoint(buf, 16, ®); | ||
458 | if (err) | ||
459 | return err; | ||
453 | 460 | ||
454 | if (strict_strtoul(buf, 16, ®) || reg > 0xff) | 461 | if (reg > 0xff) |
455 | return -EINVAL; | 462 | return -EINVAL; |
456 | 463 | ||
457 | if (fsp_reg_read(psmouse, reg, &val)) | 464 | if (fsp_reg_read(psmouse, reg, &val)) |
@@ -480,9 +487,13 @@ static ssize_t fsp_attr_show_pagereg(struct psmouse *psmouse, | |||
480 | static ssize_t fsp_attr_set_pagereg(struct psmouse *psmouse, void *data, | 487 | static ssize_t fsp_attr_set_pagereg(struct psmouse *psmouse, void *data, |
481 | const char *buf, size_t count) | 488 | const char *buf, size_t count) |
482 | { | 489 | { |
483 | unsigned long val; | 490 | int val, err; |
484 | 491 | ||
485 | if (strict_strtoul(buf, 16, &val) || val > 0xff) | 492 | err = kstrtoint(buf, 16, &val); |
493 | if (err) | ||
494 | return err; | ||
495 | |||
496 | if (val > 0xff) | ||
486 | return -EINVAL; | 497 | return -EINVAL; |
487 | 498 | ||
488 | if (fsp_page_reg_write(psmouse, val)) | 499 | if (fsp_page_reg_write(psmouse, val)) |
@@ -505,9 +516,14 @@ static ssize_t fsp_attr_show_vscroll(struct psmouse *psmouse, | |||
505 | static ssize_t fsp_attr_set_vscroll(struct psmouse *psmouse, void *data, | 516 | static ssize_t fsp_attr_set_vscroll(struct psmouse *psmouse, void *data, |
506 | const char *buf, size_t count) | 517 | const char *buf, size_t count) |
507 | { | 518 | { |
508 | unsigned long val; | 519 | unsigned int val; |
520 | int err; | ||
521 | |||
522 | err = kstrtouint(buf, 10, &val); | ||
523 | if (err) | ||
524 | return err; | ||
509 | 525 | ||
510 | if (strict_strtoul(buf, 10, &val) || val > 1) | 526 | if (val > 1) |
511 | return -EINVAL; | 527 | return -EINVAL; |
512 | 528 | ||
513 | fsp_onpad_vscr(psmouse, val); | 529 | fsp_onpad_vscr(psmouse, val); |
@@ -529,9 +545,14 @@ static ssize_t fsp_attr_show_hscroll(struct psmouse *psmouse, | |||
529 | static ssize_t fsp_attr_set_hscroll(struct psmouse *psmouse, void *data, | 545 | static ssize_t fsp_attr_set_hscroll(struct psmouse *psmouse, void *data, |
530 | const char *buf, size_t count) | 546 | const char *buf, size_t count) |
531 | { | 547 | { |
532 | unsigned long val; | 548 | unsigned int val; |
549 | int err; | ||
550 | |||
551 | err = kstrtouint(buf, 10, &val); | ||
552 | if (err) | ||
553 | return err; | ||
533 | 554 | ||
534 | if (strict_strtoul(buf, 10, &val) || val > 1) | 555 | if (val > 1) |
535 | return -EINVAL; | 556 | return -EINVAL; |
536 | 557 | ||
537 | fsp_onpad_hscr(psmouse, val); | 558 | fsp_onpad_hscr(psmouse, val); |
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index a6dcd18e9adf..8081a0a5d602 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c | |||
@@ -269,19 +269,49 @@ static int synaptics_query_hardware(struct psmouse *psmouse) | |||
269 | return 0; | 269 | return 0; |
270 | } | 270 | } |
271 | 271 | ||
272 | static int synaptics_set_absolute_mode(struct psmouse *psmouse) | 272 | static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) |
273 | { | ||
274 | static unsigned char param = 0xc8; | ||
275 | struct synaptics_data *priv = psmouse->private; | ||
276 | |||
277 | if (!SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) | ||
278 | return 0; | ||
279 | |||
280 | if (psmouse_sliced_command(psmouse, SYN_QUE_MODEL)) | ||
281 | return -1; | ||
282 | |||
283 | if (ps2_command(&psmouse->ps2dev, ¶m, PSMOUSE_CMD_SETRATE)) | ||
284 | return -1; | ||
285 | |||
286 | /* Advanced gesture mode also sends multi finger data */ | ||
287 | priv->capabilities |= BIT(1); | ||
288 | |||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | static int synaptics_set_mode(struct psmouse *psmouse) | ||
273 | { | 293 | { |
274 | struct synaptics_data *priv = psmouse->private; | 294 | struct synaptics_data *priv = psmouse->private; |
275 | 295 | ||
276 | priv->mode = SYN_BIT_ABSOLUTE_MODE; | 296 | priv->mode = 0; |
277 | if (SYN_ID_MAJOR(priv->identity) >= 4) | 297 | if (priv->absolute_mode) |
298 | priv->mode |= SYN_BIT_ABSOLUTE_MODE; | ||
299 | if (priv->disable_gesture) | ||
278 | priv->mode |= SYN_BIT_DISABLE_GESTURE; | 300 | priv->mode |= SYN_BIT_DISABLE_GESTURE; |
301 | if (psmouse->rate >= 80) | ||
302 | priv->mode |= SYN_BIT_HIGH_RATE; | ||
279 | if (SYN_CAP_EXTENDED(priv->capabilities)) | 303 | if (SYN_CAP_EXTENDED(priv->capabilities)) |
280 | priv->mode |= SYN_BIT_W_MODE; | 304 | priv->mode |= SYN_BIT_W_MODE; |
281 | 305 | ||
282 | if (synaptics_mode_cmd(psmouse, priv->mode)) | 306 | if (synaptics_mode_cmd(psmouse, priv->mode)) |
283 | return -1; | 307 | return -1; |
284 | 308 | ||
309 | if (priv->absolute_mode && | ||
310 | synaptics_set_advanced_gesture_mode(psmouse)) { | ||
311 | psmouse_err(psmouse, "Advanced gesture mode init failed.\n"); | ||
312 | return -1; | ||
313 | } | ||
314 | |||
285 | return 0; | 315 | return 0; |
286 | } | 316 | } |
287 | 317 | ||
@@ -300,26 +330,6 @@ static void synaptics_set_rate(struct psmouse *psmouse, unsigned int rate) | |||
300 | synaptics_mode_cmd(psmouse, priv->mode); | 330 | synaptics_mode_cmd(psmouse, priv->mode); |
301 | } | 331 | } |
302 | 332 | ||
303 | static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) | ||
304 | { | ||
305 | static unsigned char param = 0xc8; | ||
306 | struct synaptics_data *priv = psmouse->private; | ||
307 | |||
308 | if (!(SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) || | ||
309 | SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c))) | ||
310 | return 0; | ||
311 | |||
312 | if (psmouse_sliced_command(psmouse, SYN_QUE_MODEL)) | ||
313 | return -1; | ||
314 | if (ps2_command(&psmouse->ps2dev, ¶m, PSMOUSE_CMD_SETRATE)) | ||
315 | return -1; | ||
316 | |||
317 | /* Advanced gesture mode also sends multi finger data */ | ||
318 | priv->capabilities |= BIT(1); | ||
319 | |||
320 | return 0; | ||
321 | } | ||
322 | |||
323 | /***************************************************************************** | 333 | /***************************************************************************** |
324 | * Synaptics pass-through PS/2 port support | 334 | * Synaptics pass-through PS/2 port support |
325 | ****************************************************************************/ | 335 | ****************************************************************************/ |
@@ -1143,8 +1153,24 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) | |||
1143 | { | 1153 | { |
1144 | int i; | 1154 | int i; |
1145 | 1155 | ||
1156 | /* Things that apply to both modes */ | ||
1146 | __set_bit(INPUT_PROP_POINTER, dev->propbit); | 1157 | __set_bit(INPUT_PROP_POINTER, dev->propbit); |
1158 | __set_bit(EV_KEY, dev->evbit); | ||
1159 | __set_bit(BTN_LEFT, dev->keybit); | ||
1160 | __set_bit(BTN_RIGHT, dev->keybit); | ||
1147 | 1161 | ||
1162 | if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) | ||
1163 | __set_bit(BTN_MIDDLE, dev->keybit); | ||
1164 | |||
1165 | if (!priv->absolute_mode) { | ||
1166 | /* Relative mode */ | ||
1167 | __set_bit(EV_REL, dev->evbit); | ||
1168 | __set_bit(REL_X, dev->relbit); | ||
1169 | __set_bit(REL_Y, dev->relbit); | ||
1170 | return; | ||
1171 | } | ||
1172 | |||
1173 | /* Absolute mode */ | ||
1148 | __set_bit(EV_ABS, dev->evbit); | 1174 | __set_bit(EV_ABS, dev->evbit); |
1149 | set_abs_position_params(dev, priv, ABS_X, ABS_Y); | 1175 | set_abs_position_params(dev, priv, ABS_X, ABS_Y); |
1150 | input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); | 1176 | input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); |
@@ -1170,20 +1196,14 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) | |||
1170 | if (SYN_CAP_PALMDETECT(priv->capabilities)) | 1196 | if (SYN_CAP_PALMDETECT(priv->capabilities)) |
1171 | input_set_abs_params(dev, ABS_TOOL_WIDTH, 0, 15, 0, 0); | 1197 | input_set_abs_params(dev, ABS_TOOL_WIDTH, 0, 15, 0, 0); |
1172 | 1198 | ||
1173 | __set_bit(EV_KEY, dev->evbit); | ||
1174 | __set_bit(BTN_TOUCH, dev->keybit); | 1199 | __set_bit(BTN_TOUCH, dev->keybit); |
1175 | __set_bit(BTN_TOOL_FINGER, dev->keybit); | 1200 | __set_bit(BTN_TOOL_FINGER, dev->keybit); |
1176 | __set_bit(BTN_LEFT, dev->keybit); | ||
1177 | __set_bit(BTN_RIGHT, dev->keybit); | ||
1178 | 1201 | ||
1179 | if (SYN_CAP_MULTIFINGER(priv->capabilities)) { | 1202 | if (SYN_CAP_MULTIFINGER(priv->capabilities)) { |
1180 | __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit); | 1203 | __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit); |
1181 | __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit); | 1204 | __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit); |
1182 | } | 1205 | } |
1183 | 1206 | ||
1184 | if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) | ||
1185 | __set_bit(BTN_MIDDLE, dev->keybit); | ||
1186 | |||
1187 | if (SYN_CAP_FOUR_BUTTON(priv->capabilities) || | 1207 | if (SYN_CAP_FOUR_BUTTON(priv->capabilities) || |
1188 | SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) { | 1208 | SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) { |
1189 | __set_bit(BTN_FORWARD, dev->keybit); | 1209 | __set_bit(BTN_FORWARD, dev->keybit); |
@@ -1205,10 +1225,58 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) | |||
1205 | } | 1225 | } |
1206 | } | 1226 | } |
1207 | 1227 | ||
1228 | static ssize_t synaptics_show_disable_gesture(struct psmouse *psmouse, | ||
1229 | void *data, char *buf) | ||
1230 | { | ||
1231 | struct synaptics_data *priv = psmouse->private; | ||
1232 | |||
1233 | return sprintf(buf, "%c\n", priv->disable_gesture ? '1' : '0'); | ||
1234 | } | ||
1235 | |||
1236 | static ssize_t synaptics_set_disable_gesture(struct psmouse *psmouse, | ||
1237 | void *data, const char *buf, | ||
1238 | size_t len) | ||
1239 | { | ||
1240 | struct synaptics_data *priv = psmouse->private; | ||
1241 | unsigned int value; | ||
1242 | int err; | ||
1243 | |||
1244 | err = kstrtouint(buf, 10, &value); | ||
1245 | if (err) | ||
1246 | return err; | ||
1247 | |||
1248 | if (value > 1) | ||
1249 | return -EINVAL; | ||
1250 | |||
1251 | if (value == priv->disable_gesture) | ||
1252 | return len; | ||
1253 | |||
1254 | priv->disable_gesture = value; | ||
1255 | if (value) | ||
1256 | priv->mode |= SYN_BIT_DISABLE_GESTURE; | ||
1257 | else | ||
1258 | priv->mode &= ~SYN_BIT_DISABLE_GESTURE; | ||
1259 | |||
1260 | if (synaptics_mode_cmd(psmouse, priv->mode)) | ||
1261 | return -EIO; | ||
1262 | |||
1263 | return len; | ||
1264 | } | ||
1265 | |||
1266 | PSMOUSE_DEFINE_ATTR(disable_gesture, S_IWUSR | S_IRUGO, NULL, | ||
1267 | synaptics_show_disable_gesture, | ||
1268 | synaptics_set_disable_gesture); | ||
1269 | |||
1208 | static void synaptics_disconnect(struct psmouse *psmouse) | 1270 | static void synaptics_disconnect(struct psmouse *psmouse) |
1209 | { | 1271 | { |
1272 | struct synaptics_data *priv = psmouse->private; | ||
1273 | |||
1274 | if (!priv->absolute_mode && SYN_ID_DISGEST_SUPPORTED(priv->identity)) | ||
1275 | device_remove_file(&psmouse->ps2dev.serio->dev, | ||
1276 | &psmouse_attr_disable_gesture.dattr); | ||
1277 | |||
1210 | synaptics_reset(psmouse); | 1278 | synaptics_reset(psmouse); |
1211 | kfree(psmouse->private); | 1279 | kfree(priv); |
1212 | psmouse->private = NULL; | 1280 | psmouse->private = NULL; |
1213 | } | 1281 | } |
1214 | 1282 | ||
@@ -1245,17 +1313,11 @@ static int synaptics_reconnect(struct psmouse *psmouse) | |||
1245 | return -1; | 1313 | return -1; |
1246 | } | 1314 | } |
1247 | 1315 | ||
1248 | if (synaptics_set_absolute_mode(psmouse)) { | 1316 | if (synaptics_set_mode(psmouse)) { |
1249 | psmouse_err(psmouse, "Unable to initialize device.\n"); | 1317 | psmouse_err(psmouse, "Unable to initialize device.\n"); |
1250 | return -1; | 1318 | return -1; |
1251 | } | 1319 | } |
1252 | 1320 | ||
1253 | if (synaptics_set_advanced_gesture_mode(psmouse)) { | ||
1254 | psmouse_err(psmouse, | ||
1255 | "Advanced gesture mode reconnect failed.\n"); | ||
1256 | return -1; | ||
1257 | } | ||
1258 | |||
1259 | if (old_priv.identity != priv->identity || | 1321 | if (old_priv.identity != priv->identity || |
1260 | old_priv.model_id != priv->model_id || | 1322 | old_priv.model_id != priv->model_id || |
1261 | old_priv.capabilities != priv->capabilities || | 1323 | old_priv.capabilities != priv->capabilities || |
@@ -1332,20 +1394,18 @@ void __init synaptics_module_init(void) | |||
1332 | broken_olpc_ec = dmi_check_system(olpc_dmi_table); | 1394 | broken_olpc_ec = dmi_check_system(olpc_dmi_table); |
1333 | } | 1395 | } |
1334 | 1396 | ||
1335 | int synaptics_init(struct psmouse *psmouse) | 1397 | static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode) |
1336 | { | 1398 | { |
1337 | struct synaptics_data *priv; | 1399 | struct synaptics_data *priv; |
1400 | int err = -1; | ||
1338 | 1401 | ||
1339 | /* | 1402 | /* |
1340 | * The OLPC XO has issues with Synaptics' absolute mode; similarly to | 1403 | * The OLPC XO has issues with Synaptics' absolute mode; the constant |
1341 | * the HGPK, it quickly degrades and the hardware becomes jumpy and | 1404 | * packet spew overloads the EC such that key presses on the keyboard |
1342 | * overly sensitive. Not only that, but the constant packet spew | 1405 | * are missed. Given that, don't even attempt to use Absolute mode. |
1343 | * (even at a lowered 40pps rate) overloads the EC such that key | 1406 | * Relative mode seems to work just fine. |
1344 | * presses on the keyboard are missed. Given all of that, don't | ||
1345 | * even attempt to use Synaptics mode. Relative mode seems to work | ||
1346 | * just fine. | ||
1347 | */ | 1407 | */ |
1348 | if (broken_olpc_ec) { | 1408 | if (absolute_mode && broken_olpc_ec) { |
1349 | psmouse_info(psmouse, | 1409 | psmouse_info(psmouse, |
1350 | "OLPC XO detected, not enabling Synaptics protocol.\n"); | 1410 | "OLPC XO detected, not enabling Synaptics protocol.\n"); |
1351 | return -ENODEV; | 1411 | return -ENODEV; |
@@ -1362,13 +1422,12 @@ int synaptics_init(struct psmouse *psmouse) | |||
1362 | goto init_fail; | 1422 | goto init_fail; |
1363 | } | 1423 | } |
1364 | 1424 | ||
1365 | if (synaptics_set_absolute_mode(psmouse)) { | 1425 | priv->absolute_mode = absolute_mode; |
1366 | psmouse_err(psmouse, "Unable to initialize device.\n"); | 1426 | if (SYN_ID_DISGEST_SUPPORTED(priv->identity)) |
1367 | goto init_fail; | 1427 | priv->disable_gesture = true; |
1368 | } | ||
1369 | 1428 | ||
1370 | if (synaptics_set_advanced_gesture_mode(psmouse)) { | 1429 | if (synaptics_set_mode(psmouse)) { |
1371 | psmouse_err(psmouse, "Advanced gesture mode init failed.\n"); | 1430 | psmouse_err(psmouse, "Unable to initialize device.\n"); |
1372 | goto init_fail; | 1431 | goto init_fail; |
1373 | } | 1432 | } |
1374 | 1433 | ||
@@ -1393,12 +1452,19 @@ int synaptics_init(struct psmouse *psmouse) | |||
1393 | psmouse->model = ((priv->model_id & 0x00ff0000) >> 8) | | 1452 | psmouse->model = ((priv->model_id & 0x00ff0000) >> 8) | |
1394 | (priv->model_id & 0x000000ff); | 1453 | (priv->model_id & 0x000000ff); |
1395 | 1454 | ||
1396 | psmouse->protocol_handler = synaptics_process_byte; | 1455 | if (absolute_mode) { |
1456 | psmouse->protocol_handler = synaptics_process_byte; | ||
1457 | psmouse->pktsize = 6; | ||
1458 | } else { | ||
1459 | /* Relative mode follows standard PS/2 mouse protocol */ | ||
1460 | psmouse->protocol_handler = psmouse_process_byte; | ||
1461 | psmouse->pktsize = 3; | ||
1462 | } | ||
1463 | |||
1397 | psmouse->set_rate = synaptics_set_rate; | 1464 | psmouse->set_rate = synaptics_set_rate; |
1398 | psmouse->disconnect = synaptics_disconnect; | 1465 | psmouse->disconnect = synaptics_disconnect; |
1399 | psmouse->reconnect = synaptics_reconnect; | 1466 | psmouse->reconnect = synaptics_reconnect; |
1400 | psmouse->cleanup = synaptics_reset; | 1467 | psmouse->cleanup = synaptics_reset; |
1401 | psmouse->pktsize = 6; | ||
1402 | /* Synaptics can usually stay in sync without extra help */ | 1468 | /* Synaptics can usually stay in sync without extra help */ |
1403 | psmouse->resync_time = 0; | 1469 | psmouse->resync_time = 0; |
1404 | 1470 | ||
@@ -1417,11 +1483,32 @@ int synaptics_init(struct psmouse *psmouse) | |||
1417 | psmouse->rate = 40; | 1483 | psmouse->rate = 40; |
1418 | } | 1484 | } |
1419 | 1485 | ||
1486 | if (!priv->absolute_mode && SYN_ID_DISGEST_SUPPORTED(priv->identity)) { | ||
1487 | err = device_create_file(&psmouse->ps2dev.serio->dev, | ||
1488 | &psmouse_attr_disable_gesture.dattr); | ||
1489 | if (err) { | ||
1490 | psmouse_err(psmouse, | ||
1491 | "Failed to create disable_gesture attribute (%d)", | ||
1492 | err); | ||
1493 | goto init_fail; | ||
1494 | } | ||
1495 | } | ||
1496 | |||
1420 | return 0; | 1497 | return 0; |
1421 | 1498 | ||
1422 | init_fail: | 1499 | init_fail: |
1423 | kfree(priv); | 1500 | kfree(priv); |
1424 | return -1; | 1501 | return err; |
1502 | } | ||
1503 | |||
1504 | int synaptics_init(struct psmouse *psmouse) | ||
1505 | { | ||
1506 | return __synaptics_init(psmouse, true); | ||
1507 | } | ||
1508 | |||
1509 | int synaptics_init_relative(struct psmouse *psmouse) | ||
1510 | { | ||
1511 | return __synaptics_init(psmouse, false); | ||
1425 | } | 1512 | } |
1426 | 1513 | ||
1427 | bool synaptics_supported(void) | 1514 | bool synaptics_supported(void) |
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h index 622aea8dd7e0..fd26ccca13d7 100644 --- a/drivers/input/mouse/synaptics.h +++ b/drivers/input/mouse/synaptics.h | |||
@@ -100,6 +100,7 @@ | |||
100 | #define SYN_ID_MINOR(i) (((i) >> 16) & 0xff) | 100 | #define SYN_ID_MINOR(i) (((i) >> 16) & 0xff) |
101 | #define SYN_ID_FULL(i) ((SYN_ID_MAJOR(i) << 8) | SYN_ID_MINOR(i)) | 101 | #define SYN_ID_FULL(i) ((SYN_ID_MAJOR(i) << 8) | SYN_ID_MINOR(i)) |
102 | #define SYN_ID_IS_SYNAPTICS(i) ((((i) >> 8) & 0xff) == 0x47) | 102 | #define SYN_ID_IS_SYNAPTICS(i) ((((i) >> 8) & 0xff) == 0x47) |
103 | #define SYN_ID_DISGEST_SUPPORTED(i) (SYN_ID_MAJOR(i) >= 4) | ||
103 | 104 | ||
104 | /* synaptics special commands */ | 105 | /* synaptics special commands */ |
105 | #define SYN_PS_SET_MODE2 0x14 | 106 | #define SYN_PS_SET_MODE2 0x14 |
@@ -159,6 +160,9 @@ struct synaptics_data { | |||
159 | unsigned char mode; /* current mode byte */ | 160 | unsigned char mode; /* current mode byte */ |
160 | int scroll; | 161 | int scroll; |
161 | 162 | ||
163 | bool absolute_mode; /* run in Absolute mode */ | ||
164 | bool disable_gesture; /* disable gestures */ | ||
165 | |||
162 | struct serio *pt_port; /* Pass-through serio port */ | 166 | struct serio *pt_port; /* Pass-through serio port */ |
163 | 167 | ||
164 | struct synaptics_mt_state mt_state; /* Current mt finger state */ | 168 | struct synaptics_mt_state mt_state; /* Current mt finger state */ |
@@ -175,6 +179,7 @@ struct synaptics_data { | |||
175 | void synaptics_module_init(void); | 179 | void synaptics_module_init(void); |
176 | int synaptics_detect(struct psmouse *psmouse, bool set_properties); | 180 | int synaptics_detect(struct psmouse *psmouse, bool set_properties); |
177 | int synaptics_init(struct psmouse *psmouse); | 181 | int synaptics_init(struct psmouse *psmouse); |
182 | int synaptics_init_relative(struct psmouse *psmouse); | ||
178 | void synaptics_reset(struct psmouse *psmouse); | 183 | void synaptics_reset(struct psmouse *psmouse); |
179 | bool synaptics_supported(void); | 184 | bool synaptics_supported(void); |
180 | 185 | ||
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index 54b2fa892e19..22b218018137 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c | |||
@@ -89,10 +89,12 @@ static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data, | |||
89 | struct trackpoint_data *tp = psmouse->private; | 89 | struct trackpoint_data *tp = psmouse->private; |
90 | struct trackpoint_attr_data *attr = data; | 90 | struct trackpoint_attr_data *attr = data; |
91 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); | 91 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); |
92 | unsigned long value; | 92 | unsigned char value; |
93 | int err; | ||
93 | 94 | ||
94 | if (strict_strtoul(buf, 10, &value) || value > 255) | 95 | err = kstrtou8(buf, 10, &value); |
95 | return -EINVAL; | 96 | if (err) |
97 | return err; | ||
96 | 98 | ||
97 | *field = value; | 99 | *field = value; |
98 | trackpoint_write(&psmouse->ps2dev, attr->command, value); | 100 | trackpoint_write(&psmouse->ps2dev, attr->command, value); |
@@ -115,9 +117,14 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, | |||
115 | struct trackpoint_data *tp = psmouse->private; | 117 | struct trackpoint_data *tp = psmouse->private; |
116 | struct trackpoint_attr_data *attr = data; | 118 | struct trackpoint_attr_data *attr = data; |
117 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); | 119 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); |
118 | unsigned long value; | 120 | unsigned int value; |
121 | int err; | ||
122 | |||
123 | err = kstrtouint(buf, 10, &value); | ||
124 | if (err) | ||
125 | return err; | ||
119 | 126 | ||
120 | if (strict_strtoul(buf, 10, &value) || value > 1) | 127 | if (value > 1) |
121 | return -EINVAL; | 128 | return -EINVAL; |
122 | 129 | ||
123 | if (attr->inverted) | 130 | if (attr->inverted) |