Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r2088 - genpatches-2.6/trunk/3.3
Date: Tue, 07 Feb 2012 19:12:03
Message-Id: 20120207191151.685532004B@flycatcher.gentoo.org
1 Author: mpagano
2 Date: 2012-02-07 19:11:50 +0000 (Tue, 07 Feb 2012)
3 New Revision: 2088
4
5 Removed:
6 genpatches-2.6/trunk/3.3/2600_Input-ALPS-synaptics-touchpad.patch
7 Modified:
8 genpatches-2.6/trunk/3.3/0000_README
9 Log:
10 Remove redundant patch
11
12 Modified: genpatches-2.6/trunk/3.3/0000_README
13 ===================================================================
14 --- genpatches-2.6/trunk/3.3/0000_README 2012-02-07 18:48:43 UTC (rev 2087)
15 +++ genpatches-2.6/trunk/3.3/0000_README 2012-02-07 19:11:50 UTC (rev 2088)
16 @@ -44,10 +44,6 @@
17 From: Alexey Shvetsov <alexxy@g.o>
18 Desc: Zero copy for infiniband psm userspace driver
19
20 -Patch: 2600_Input-ALPS-synaptics-touchpad.patch
21 -From: http://bugs.gentoo.org/show_bug.cgi?id=318567
22 -Desc: ALPS Touchpad Patchset
23 -
24 Patch: 4200_fbcondecor-0.9.6.patch
25 From: http://dev.gentoo.org/~spock
26 Desc: Bootsplash successor by Michal Januszewski ported by Alexxy
27
28 Deleted: genpatches-2.6/trunk/3.3/2600_Input-ALPS-synaptics-touchpad.patch
29 ===================================================================
30 --- genpatches-2.6/trunk/3.3/2600_Input-ALPS-synaptics-touchpad.patch 2012-02-07 18:48:43 UTC (rev 2087)
31 +++ genpatches-2.6/trunk/3.3/2600_Input-ALPS-synaptics-touchpad.patch 2012-02-07 19:11:50 UTC (rev 2088)
32 @@ -1,1267 +0,0 @@
33 -Only in linux-3.2/Documentation/input: alps.txt
34 -diff -ur linux-3.2.old/drivers/input/mouse/alps.c linux-3.2/drivers/input/mouse/alps.c
35 ---- linux-3.2.old/drivers/input/mouse/alps.c 2012-01-04 17:55:44.000000000 -0600
36 -+++ linux-3.2/drivers/input/mouse/alps.c 2012-01-05 18:53:42.231275880 -0600
37 -@@ -17,13 +17,63 @@
38 -
39 - #include <linux/slab.h>
40 - #include <linux/input.h>
41 -+#include <linux/input/mt.h>
42 - #include <linux/serio.h>
43 - #include <linux/libps2.h>
44 -
45 - #include "psmouse.h"
46 - #include "alps.h"
47 -
48 --#define ALPS_OLDPROTO 0x01 /* old style input */
49 -+/*
50 -+ * Definitions for ALPS version 3 and 4 command mode protocol
51 -+ */
52 -+#define ALPS_V3_X_MAX 2000
53 -+#define ALPS_V3_Y_MAX 1400
54 -+
55 -+#define ALPS_BITMAP_X_BITS 15
56 -+#define ALPS_BITMAP_Y_BITS 11
57 -+
58 -+#define ALPS_CMD_NIBBLE_10 0x01f2
59 -+
60 -+static const struct alps_nibble_commands alps_v3_nibble_commands[] = {
61 -+ { PSMOUSE_CMD_SETPOLL, 0x00 }, /* 0 */
62 -+ { PSMOUSE_CMD_RESET_DIS, 0x00 }, /* 1 */
63 -+ { PSMOUSE_CMD_SETSCALE21, 0x00 }, /* 2 */
64 -+ { PSMOUSE_CMD_SETRATE, 0x0a }, /* 3 */
65 -+ { PSMOUSE_CMD_SETRATE, 0x14 }, /* 4 */
66 -+ { PSMOUSE_CMD_SETRATE, 0x28 }, /* 5 */
67 -+ { PSMOUSE_CMD_SETRATE, 0x3c }, /* 6 */
68 -+ { PSMOUSE_CMD_SETRATE, 0x50 }, /* 7 */
69 -+ { PSMOUSE_CMD_SETRATE, 0x64 }, /* 8 */
70 -+ { PSMOUSE_CMD_SETRATE, 0xc8 }, /* 9 */
71 -+ { ALPS_CMD_NIBBLE_10, 0x00 }, /* a */
72 -+ { PSMOUSE_CMD_SETRES, 0x00 }, /* b */
73 -+ { PSMOUSE_CMD_SETRES, 0x01 }, /* c */
74 -+ { PSMOUSE_CMD_SETRES, 0x02 }, /* d */
75 -+ { PSMOUSE_CMD_SETRES, 0x03 }, /* e */
76 -+ { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */
77 -+};
78 -+
79 -+static const struct alps_nibble_commands alps_v4_nibble_commands[] = {
80 -+ { PSMOUSE_CMD_ENABLE, 0x00 }, /* 0 */
81 -+ { PSMOUSE_CMD_RESET_DIS, 0x00 }, /* 1 */
82 -+ { PSMOUSE_CMD_SETSCALE21, 0x00 }, /* 2 */
83 -+ { PSMOUSE_CMD_SETRATE, 0x0a }, /* 3 */
84 -+ { PSMOUSE_CMD_SETRATE, 0x14 }, /* 4 */
85 -+ { PSMOUSE_CMD_SETRATE, 0x28 }, /* 5 */
86 -+ { PSMOUSE_CMD_SETRATE, 0x3c }, /* 6 */
87 -+ { PSMOUSE_CMD_SETRATE, 0x50 }, /* 7 */
88 -+ { PSMOUSE_CMD_SETRATE, 0x64 }, /* 8 */
89 -+ { PSMOUSE_CMD_SETRATE, 0xc8 }, /* 9 */
90 -+ { ALPS_CMD_NIBBLE_10, 0x00 }, /* a */
91 -+ { PSMOUSE_CMD_SETRES, 0x00 }, /* b */
92 -+ { PSMOUSE_CMD_SETRES, 0x01 }, /* c */
93 -+ { PSMOUSE_CMD_SETRES, 0x02 }, /* d */
94 -+ { PSMOUSE_CMD_SETRES, 0x03 }, /* e */
95 -+ { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */
96 -+};
97 -+
98 -+
99 - #define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */
100 - #define ALPS_PASS 0x04 /* device has a pass-through port */
101 -
102 -@@ -35,30 +85,33 @@
103 - 6-byte ALPS packet */
104 -
105 - static const struct alps_model_info alps_model_data[] = {
106 -- { { 0x32, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */
107 -- { { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */
108 -- { { 0x53, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
109 -- { { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 },
110 -- { { 0x60, 0x03, 0xc8 }, 0xf8, 0xf8, 0 }, /* HP ze1115 */
111 -- { { 0x63, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
112 -- { { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 },
113 -- { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */
114 -- { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */
115 -- { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */
116 -- { { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 },
117 -- { { 0x63, 0x03, 0xc8 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D800 */
118 -- { { 0x73, 0x00, 0x0a }, 0xf8, 0xf8, ALPS_DUALPOINT }, /* ThinkPad R61 8918-5QG */
119 -- { { 0x73, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
120 -- { { 0x73, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */
121 -- { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */
122 -- { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT },
123 -- { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */
124 -+ { { 0x32, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */
125 -+ { { 0x33, 0x02, 0x0a }, 0x00, ALPS_PROTO_V1, 0x88, 0xf8, 0 }, /* UMAX-530T */
126 -+ { { 0x53, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
127 -+ { { 0x53, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
128 -+ { { 0x60, 0x03, 0xc8 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, /* HP ze1115 */
129 -+ { { 0x63, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
130 -+ { { 0x63, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
131 -+ { { 0x63, 0x02, 0x28 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */
132 -+ { { 0x63, 0x02, 0x3c }, 0x00, ALPS_PROTO_V2, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */
133 -+ { { 0x63, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */
134 -+ { { 0x63, 0x02, 0x64 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
135 -+ { { 0x63, 0x03, 0xc8 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D800 */
136 -+ { { 0x73, 0x00, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_DUALPOINT }, /* ThinkPad R61 8918-5QG */
137 -+ { { 0x73, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 },
138 -+ { { 0x73, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */
139 -+ { { 0x20, 0x02, 0x0e }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */
140 -+ { { 0x22, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT },
141 -+ { { 0x22, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */
142 - /* Dell Latitude E5500, E6400, E6500, Precision M4400 */
143 -- { { 0x62, 0x02, 0x14 }, 0xcf, 0xcf,
144 -+ { { 0x62, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf,
145 - ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED },
146 -- { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */
147 -- { { 0x52, 0x01, 0x14 }, 0xff, 0xff,
148 -- ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */
149 -+ { { 0x73, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */
150 -+ { { 0x52, 0x01, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff,
151 -+ ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */
152 -+ { { 0x73, 0x02, 0x64 }, 0x9b, ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT },
153 -+ { { 0x73, 0x02, 0x64 }, 0x9d, ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT },
154 -+ { { 0x73, 0x02, 0x64 }, 0x8a, ALPS_PROTO_V4, 0x8f, 0x8f, 0 },
155 - };
156 -
157 - /*
158 -@@ -67,42 +120,7 @@
159 - * isn't valid per PS/2 spec.
160 - */
161 -
162 --/*
163 -- * PS/2 packet format
164 -- *
165 -- * byte 0: 0 0 YSGN XSGN 1 M R L
166 -- * byte 1: X7 X6 X5 X4 X3 X2 X1 X0
167 -- * byte 2: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
168 -- *
169 -- * Note that the device never signals overflow condition.
170 -- *
171 -- * ALPS absolute Mode - new format
172 -- *
173 -- * byte 0: 1 ? ? ? 1 ? ? ?
174 -- * byte 1: 0 x6 x5 x4 x3 x2 x1 x0
175 -- * byte 2: 0 x10 x9 x8 x7 ? fin ges
176 -- * byte 3: 0 y9 y8 y7 1 M R L
177 -- * byte 4: 0 y6 y5 y4 y3 y2 y1 y0
178 -- * byte 5: 0 z6 z5 z4 z3 z2 z1 z0
179 -- *
180 -- * Dualpoint device -- interleaved packet format
181 -- *
182 -- * byte 0: 1 1 0 0 1 1 1 1
183 -- * byte 1: 0 x6 x5 x4 x3 x2 x1 x0
184 -- * byte 2: 0 x10 x9 x8 x7 0 fin ges
185 -- * byte 3: 0 0 YSGN XSGN 1 1 1 1
186 -- * byte 4: X7 X6 X5 X4 X3 X2 X1 X0
187 -- * byte 5: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
188 -- * byte 6: 0 y9 y8 y7 1 m r l
189 -- * byte 7: 0 y6 y5 y4 y3 y2 y1 y0
190 -- * byte 8: 0 z6 z5 z4 z3 z2 z1 z0
191 -- *
192 -- * CAPITALS = stick, miniscules = touchpad
193 -- *
194 -- * ?'s can have different meanings on different models,
195 -- * such as wheel rotation, extra buttons, stick buttons
196 -- * on a dualpoint, etc.
197 -- */
198 -+/* Packet formats are described in Documentation/input/alps.txt */
199 -
200 - static bool alps_is_valid_first_byte(const struct alps_model_info *model,
201 - unsigned char data)
202 -@@ -137,7 +155,7 @@
203 - input_sync(dev2);
204 - }
205 -
206 --static void alps_process_packet(struct psmouse *psmouse)
207 -+static void alps_process_packet_v1_v2(struct psmouse *psmouse)
208 - {
209 - struct alps_data *priv = psmouse->private;
210 - const struct alps_model_info *model = priv->i;
211 -@@ -147,7 +165,7 @@
212 - int x, y, z, ges, fin, left, right, middle;
213 - int back = 0, forward = 0;
214 -
215 -- if (model->flags & ALPS_OLDPROTO) {
216 -+ if (model->proto_version == ALPS_PROTO_V1) {
217 - left = packet[2] & 0x10;
218 - right = packet[2] & 0x08;
219 - middle = 0;
220 -@@ -239,6 +257,403 @@
221 - input_sync(dev);
222 - }
223 -
224 -+/*
225 -+ * Process bitmap data from v3 and v4 protocols. Returns the number of
226 -+ * fingers detected. A return value of 0 means at least one of the
227 -+ * bitmaps was empty.
228 -+ *
229 -+ * The bitmaps don't have enough data to track fingers, so this function
230 -+ * only generates points representing a bounding box of all contacts.
231 -+ * These points are returned in x1, y1, x2, and y2 when the return value
232 -+ * is greater than 0.
233 -+ */
234 -+static int alps_process_bitmap(unsigned int x_map, unsigned int y_map,
235 -+ int *x1, int *y1, int *x2, int *y2)
236 -+{
237 -+ struct alps_bitmap_point {
238 -+ int start_bit;
239 -+ int num_bits;
240 -+ };
241 -+
242 -+ int fingers_x = 0, fingers_y = 0, fingers;
243 -+ int i, bit, prev_bit;
244 -+ struct alps_bitmap_point x_low = {0,}, x_high = {0,};
245 -+ struct alps_bitmap_point y_low = {0,}, y_high = {0,};
246 -+ struct alps_bitmap_point *point;
247 -+
248 -+ if (!x_map || !y_map)
249 -+ return 0;
250 -+
251 -+ *x1 = *y1 = *x2 = *y2 = 0;
252 -+
253 -+ prev_bit = 0;
254 -+ point = &x_low;
255 -+ for (i = 0; x_map != 0; i++, x_map >>= 1) {
256 -+ bit = x_map & 1;
257 -+ if (bit) {
258 -+ if (!prev_bit) {
259 -+ point->start_bit = i;
260 -+ fingers_x++;
261 -+ }
262 -+ point->num_bits++;
263 -+ } else {
264 -+ if (prev_bit)
265 -+ point = &x_high;
266 -+ else
267 -+ point->num_bits = 0;
268 -+ }
269 -+ prev_bit = bit;
270 -+ }
271 -+
272 -+ /*
273 -+ * y bitmap is reversed for what we need (lower positions are in
274 -+ * higher bits), so we process from the top end.
275 -+ */
276 -+ y_map = y_map << (sizeof(y_map) * BITS_PER_BYTE - ALPS_BITMAP_Y_BITS);
277 -+ prev_bit = 0;
278 -+ point = &y_low;
279 -+ for (i = 0; y_map != 0; i++, y_map <<= 1) {
280 -+ bit = y_map & (1 << (sizeof(y_map) * BITS_PER_BYTE - 1));
281 -+ if (bit) {
282 -+ if (!prev_bit) {
283 -+ point->start_bit = i;
284 -+ fingers_y++;
285 -+ }
286 -+ point->num_bits++;
287 -+ } else {
288 -+ if (prev_bit)
289 -+ point = &y_high;
290 -+ else
291 -+ point->num_bits = 0;
292 -+ }
293 -+ prev_bit = bit;
294 -+ }
295 -+
296 -+ /*
297 -+ * Fingers can overlap, so we use the maximum count of fingers
298 -+ * on either axis as the finger count.
299 -+ */
300 -+ fingers = max(fingers_x, fingers_y);
301 -+
302 -+ /*
303 -+ * If total fingers is > 1 but either axis reports only a single
304 -+ * contact, we have overlapping or adjacent fingers. For the
305 -+ * purposes of creating a bounding box, divide the single contact
306 -+ * (roughly) equally between the two points.
307 -+ */
308 -+ if (fingers > 1) {
309 -+ if (fingers_x == 1) {
310 -+ i = x_low.num_bits / 2;
311 -+ x_low.num_bits = x_low.num_bits - i;
312 -+ x_high.start_bit = x_low.start_bit + i;
313 -+ x_high.num_bits = max(i, 1);
314 -+ } else if (fingers_y == 1) {
315 -+ i = y_low.num_bits / 2;
316 -+ y_low.num_bits = y_low.num_bits - i;
317 -+ y_high.start_bit = y_low.start_bit + i;
318 -+ y_high.num_bits = max(i, 1);
319 -+ }
320 -+ }
321 -+
322 -+ *x1 = (ALPS_V3_X_MAX * (2 * x_low.start_bit + x_low.num_bits - 1)) /
323 -+ (2 * (ALPS_BITMAP_X_BITS - 1));
324 -+ *y1 = (ALPS_V3_Y_MAX * (2 * y_low.start_bit + y_low.num_bits - 1)) /
325 -+ (2 * (ALPS_BITMAP_Y_BITS - 1));
326 -+
327 -+ if (fingers > 1) {
328 -+ *x2 = (ALPS_V3_X_MAX * (2 * x_high.start_bit + x_high.num_bits - 1)) /
329 -+ (2 * (ALPS_BITMAP_X_BITS - 1));
330 -+ *y2 = (ALPS_V3_Y_MAX * (2 * y_high.start_bit + y_high.num_bits - 1)) /
331 -+ (2 * (ALPS_BITMAP_Y_BITS - 1));
332 -+ }
333 -+
334 -+ return fingers;
335 -+}
336 -+
337 -+static void alps_set_slot(struct input_dev *dev, int slot, bool active,
338 -+ int x, int y)
339 -+{
340 -+ input_mt_slot(dev, slot);
341 -+ input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
342 -+ if (active) {
343 -+ input_report_abs(dev, ABS_MT_POSITION_X, x);
344 -+ input_report_abs(dev, ABS_MT_POSITION_Y, y);
345 -+ }
346 -+}
347 -+
348 -+static void alps_report_semi_mt_data(struct input_dev *dev, int num_fingers,
349 -+ int x1, int y1, int x2, int y2)
350 -+{
351 -+ alps_set_slot(dev, 0, num_fingers != 0, x1, y1);
352 -+ alps_set_slot(dev, 1, num_fingers == 2, x2, y2);
353 -+}
354 -+
355 -+static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
356 -+{
357 -+ struct alps_data *priv = psmouse->private;
358 -+ unsigned char *packet = psmouse->packet;
359 -+ struct input_dev *dev = priv->dev2;
360 -+ int x, y, z, left, right, middle;
361 -+
362 -+ /* Sanity check packet */
363 -+ if (!(packet[0] & 0x40)) {
364 -+ psmouse_dbg(psmouse, "Bad trackstick packet, discarding\n");
365 -+ return;
366 -+ }
367 -+
368 -+ /*
369 -+ * There's a special packet that seems to indicate the end
370 -+ * of a stream of trackstick data. Filter these out.
371 -+ */
372 -+ if (packet[1] == 0x7f && packet[2] == 0x7f && packet[4] == 0x7f)
373 -+ return;
374 -+
375 -+ x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f));
376 -+ y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f));
377 -+ z = (packet[4] & 0x7c) >> 2;
378 -+
379 -+ /*
380 -+ * The x and y values tend to be quite large, and when used
381 -+ * alone the trackstick is difficult to use. Scale them down
382 -+ * to compensate.
383 -+ */
384 -+ x /= 8;
385 -+ y /= 8;
386 -+
387 -+ input_report_rel(dev, REL_X, x);
388 -+ input_report_rel(dev, REL_Y, -y);
389 -+
390 -+ /*
391 -+ * Most ALPS models report the trackstick buttons in the touchpad
392 -+ * packets, but a few report them here. No reliable way has been
393 -+ * found to differentiate between the models upfront, so we enable
394 -+ * the quirk in response to seeing a button press in the trackstick
395 -+ * packet.
396 -+ */
397 -+ left = packet[3] & 0x01;
398 -+ right = packet[3] & 0x02;
399 -+ middle = packet[3] & 0x04;
400 -+
401 -+ if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) &&
402 -+ (left || right || middle))
403 -+ priv->quirks |= ALPS_QUIRK_TRACKSTICK_BUTTONS;
404 -+
405 -+ if (priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) {
406 -+ input_report_key(dev, BTN_LEFT, left);
407 -+ input_report_key(dev, BTN_RIGHT, right);
408 -+ input_report_key(dev, BTN_MIDDLE, middle);
409 -+ }
410 -+
411 -+ input_sync(dev);
412 -+ return;
413 -+}
414 -+
415 -+static void alps_process_touchpad_packet_v3(struct psmouse *psmouse)
416 -+{
417 -+ struct alps_data *priv = psmouse->private;
418 -+ unsigned char *packet = psmouse->packet;
419 -+ struct input_dev *dev = psmouse->dev;
420 -+ struct input_dev *dev2 = priv->dev2;
421 -+ int x, y, z;
422 -+ int left, right, middle;
423 -+ int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
424 -+ int fingers = 0, bmap_fingers;
425 -+ unsigned int x_bitmap, y_bitmap;
426 -+
427 -+ /*
428 -+ * There's no single feature of touchpad position and bitmap packets
429 -+ * that can be used to distinguish between them. We rely on the fact
430 -+ * that a bitmap packet should always follow a position packet with
431 -+ * bit 6 of packet[4] set.
432 -+ */
433 -+ if (priv->multi_packet) {
434 -+ /*
435 -+ * Sometimes a position packet will indicate a multi-packet
436 -+ * sequence, but then what follows is another position
437 -+ * packet. Check for this, and when it happens process the
438 -+ * position packet as usual.
439 -+ */
440 -+ if (packet[0] & 0x40) {
441 -+ fingers = (packet[5] & 0x3) + 1;
442 -+ x_bitmap = ((packet[4] & 0x7e) << 8) |
443 -+ ((packet[1] & 0x7f) << 2) |
444 -+ ((packet[0] & 0x30) >> 4);
445 -+ y_bitmap = ((packet[3] & 0x70) << 4) |
446 -+ ((packet[2] & 0x7f) << 1) |
447 -+ (packet[4] & 0x01);
448 -+
449 -+ bmap_fingers = alps_process_bitmap(x_bitmap, y_bitmap,
450 -+ &x1, &y1, &x2, &y2);
451 -+
452 -+ /*
453 -+ * We shouldn't report more than one finger if
454 -+ * we don't have two coordinates.
455 -+ */
456 -+ if (fingers > 1 && bmap_fingers < 2)
457 -+ fingers = bmap_fingers;
458 -+
459 -+ /* Now process position packet */
460 -+ packet = priv->multi_data;
461 -+ } else {
462 -+ priv->multi_packet = 0;
463 -+ }
464 -+ }
465 -+
466 -+ /*
467 -+ * Bit 6 of byte 0 is not usually set in position packets. The only
468 -+ * times it seems to be set is in situations where the data is
469 -+ * suspect anyway, e.g. a palm resting flat on the touchpad. Given
470 -+ * this combined with the fact that this bit is useful for filtering
471 -+ * out misidentified bitmap packets, we reject anything with this
472 -+ * bit set.
473 -+ */
474 -+ if (packet[0] & 0x40)
475 -+ return;
476 -+
477 -+ if (!priv->multi_packet && (packet[4] & 0x40)) {
478 -+ priv->multi_packet = 1;
479 -+ memcpy(priv->multi_data, packet, sizeof(priv->multi_data));
480 -+ return;
481 -+ }
482 -+
483 -+ priv->multi_packet = 0;
484 -+
485 -+ left = packet[3] & 0x01;
486 -+ right = packet[3] & 0x02;
487 -+ middle = packet[3] & 0x04;
488 -+
489 -+ x = ((packet[1] & 0x7f) << 4) | ((packet[4] & 0x30) >> 2) |
490 -+ ((packet[0] & 0x30) >> 4);
491 -+ y = ((packet[2] & 0x7f) << 4) | (packet[4] & 0x0f);
492 -+ z = packet[5] & 0x7f;
493 -+
494 -+ /*
495 -+ * Sometimes the hardware sends a single packet with z = 0
496 -+ * in the middle of a stream. Real releases generate packets
497 -+ * with x, y, and z all zero, so these seem to be flukes.
498 -+ * Ignore them.
499 -+ */
500 -+ if (x && y && !z)
501 -+ return;
502 -+
503 -+ /*
504 -+ * If we don't have MT data or the bitmaps were empty, we have
505 -+ * to rely on ST data.
506 -+ */
507 -+ if (!fingers) {
508 -+ x1 = x;
509 -+ y1 = y;
510 -+ fingers = z > 0 ? 1 : 0;
511 -+ }
512 -+
513 -+ if (z >= 64)
514 -+ input_report_key(dev, BTN_TOUCH, 1);
515 -+ else
516 -+ input_report_key(dev, BTN_TOUCH, 0);
517 -+
518 -+ alps_report_semi_mt_data(dev, fingers, x1, y1, x2, y2);
519 -+
520 -+ input_report_key(dev, BTN_TOOL_FINGER, fingers == 1);
521 -+ input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2);
522 -+ input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3);
523 -+ input_report_key(dev, BTN_TOOL_QUADTAP, fingers == 4);
524 -+
525 -+ input_report_key(dev, BTN_LEFT, left);
526 -+ input_report_key(dev, BTN_RIGHT, right);
527 -+ input_report_key(dev, BTN_MIDDLE, middle);
528 -+
529 -+ if (z > 0) {
530 -+ input_report_abs(dev, ABS_X, x);
531 -+ input_report_abs(dev, ABS_Y, y);
532 -+ }
533 -+ input_report_abs(dev, ABS_PRESSURE, z);
534 -+
535 -+ input_sync(dev);
536 -+
537 -+ if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) {
538 -+ left = packet[3] & 0x10;
539 -+ right = packet[3] & 0x20;
540 -+ middle = packet[3] & 0x40;
541 -+
542 -+ input_report_key(dev2, BTN_LEFT, left);
543 -+ input_report_key(dev2, BTN_RIGHT, right);
544 -+ input_report_key(dev2, BTN_MIDDLE, middle);
545 -+ input_sync(dev2);
546 -+ }
547 -+}
548 -+
549 -+static void alps_process_packet_v3(struct psmouse *psmouse)
550 -+{
551 -+ unsigned char *packet = psmouse->packet;
552 -+
553 -+ /*
554 -+ * v3 protocol packets come in three types, two representing
555 -+ * touchpad data and one representing trackstick data.
556 -+ * Trackstick packets seem to be distinguished by always
557 -+ * having 0x3f in the last byte. This value has never been
558 -+ * observed in the last byte of either of the other types
559 -+ * of packets.
560 -+ */
561 -+ if (packet[5] == 0x3f) {
562 -+ alps_process_trackstick_packet_v3(psmouse);
563 -+ return;
564 -+ }
565 -+
566 -+ alps_process_touchpad_packet_v3(psmouse);
567 -+}
568 -+
569 -+static void alps_process_packet_v4(struct psmouse *psmouse)
570 -+{
571 -+ unsigned char *packet = psmouse->packet;
572 -+ struct input_dev *dev = psmouse->dev;
573 -+ int x, y, z;
574 -+ int left, right;
575 -+
576 -+ left = packet[4] & 0x01;
577 -+ right = packet[4] & 0x02;
578 -+
579 -+ x = ((packet[1] & 0x7f) << 4) | ((packet[3] & 0x30) >> 2) |
580 -+ ((packet[0] & 0x30) >> 4);
581 -+ y = ((packet[2] & 0x7f) << 4) | (packet[3] & 0x0f);
582 -+ z = packet[5] & 0x7f;
583 -+
584 -+ if (z >= 64)
585 -+ input_report_key(dev, BTN_TOUCH, 1);
586 -+ else
587 -+ input_report_key(dev, BTN_TOUCH, 0);
588 -+
589 -+ if (z > 0) {
590 -+ input_report_abs(dev, ABS_X, x);
591 -+ input_report_abs(dev, ABS_Y, y);
592 -+ }
593 -+ input_report_abs(dev, ABS_PRESSURE, z);
594 -+
595 -+ input_report_key(dev, BTN_TOOL_FINGER, z > 0);
596 -+ input_report_key(dev, BTN_LEFT, left);
597 -+ input_report_key(dev, BTN_RIGHT, right);
598 -+
599 -+ input_sync(dev);
600 -+}
601 -+
602 -+static void alps_process_packet(struct psmouse *psmouse)
603 -+{
604 -+ struct alps_data *priv = psmouse->private;
605 -+ const struct alps_model_info *model = priv->i;
606 -+
607 -+ switch (model->proto_version) {
608 -+ case ALPS_PROTO_V1:
609 -+ case ALPS_PROTO_V2:
610 -+ alps_process_packet_v1_v2(psmouse);
611 -+ break;
612 -+ case ALPS_PROTO_V3:
613 -+ alps_process_packet_v3(psmouse);
614 -+ break;
615 -+ case ALPS_PROTO_V4:
616 -+ alps_process_packet_v4(psmouse);
617 -+ break;
618 -+ }
619 -+}
620 -+
621 - static void alps_report_bare_ps2_packet(struct psmouse *psmouse,
622 - unsigned char packet[],
623 - bool report_buttons)
624 -@@ -344,7 +759,7 @@
625 -
626 - serio_pause_rx(psmouse->ps2dev.serio);
627 -
628 -- if (psmouse->pktcnt == 6) {
629 -+ if (psmouse->pktcnt == psmouse->pktsize) {
630 -
631 - /*
632 - * We did not any more data in reasonable amount of time.
633 -@@ -395,8 +810,8 @@
634 - return PSMOUSE_BAD_DATA;
635 - }
636 -
637 -- /* Bytes 2 - 6 should have 0 in the highest bit */
638 -- if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 6 &&
639 -+ /* Bytes 2 - pktsize should have 0 in the highest bit */
640 -+ if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize &&
641 - (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
642 - psmouse_dbg(psmouse, "refusing packet[%i] = %x\n",
643 - psmouse->pktcnt - 1,
644 -@@ -404,7 +819,7 @@
645 - return PSMOUSE_BAD_DATA;
646 - }
647 -
648 -- if (psmouse->pktcnt == 6) {
649 -+ if (psmouse->pktcnt == psmouse->pktsize) {
650 - alps_process_packet(psmouse);
651 - return PSMOUSE_FULL_PACKET;
652 - }
653 -@@ -412,11 +827,127 @@
654 - return PSMOUSE_GOOD_DATA;
655 - }
656 -
657 -+static int alps_command_mode_send_nibble(struct psmouse *psmouse, int nibble)
658 -+{
659 -+ struct ps2dev *ps2dev = &psmouse->ps2dev;
660 -+ struct alps_data *priv = psmouse->private;
661 -+ int command;
662 -+ unsigned char *param;
663 -+ unsigned char dummy[4];
664 -+
665 -+ BUG_ON(nibble > 0xf);
666 -+
667 -+ command = priv->nibble_commands[nibble].command;
668 -+ param = (command & 0x0f00) ?
669 -+ dummy : (unsigned char *)&priv->nibble_commands[nibble].data;
670 -+
671 -+ if (ps2_command(ps2dev, param, command))
672 -+ return -1;
673 -+
674 -+ return 0;
675 -+}
676 -+
677 -+static int alps_command_mode_set_addr(struct psmouse *psmouse, int addr)
678 -+{
679 -+ struct ps2dev *ps2dev = &psmouse->ps2dev;
680 -+ struct alps_data *priv = psmouse->private;
681 -+ int i, nibble;
682 -+
683 -+ if (ps2_command(ps2dev, NULL, priv->addr_command))
684 -+ return -1;
685 -+
686 -+ for (i = 12; i >= 0; i -= 4) {
687 -+ nibble = (addr >> i) & 0xf;
688 -+ if (alps_command_mode_send_nibble(psmouse, nibble))
689 -+ return -1;
690 -+ }
691 -+
692 -+ return 0;
693 -+}
694 -+
695 -+static int __alps_command_mode_read_reg(struct psmouse *psmouse, int addr)
696 -+{
697 -+ struct ps2dev *ps2dev = &psmouse->ps2dev;
698 -+ unsigned char param[4];
699 -+
700 -+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
701 -+ return -1;
702 -+
703 -+ /*
704 -+ * The address being read is returned in the first two bytes
705 -+ * of the result. Check that this address matches the expected
706 -+ * address.
707 -+ */
708 -+ if (addr != ((param[0] << 8) | param[1]))
709 -+ return -1;
710 -+
711 -+ return param[2];
712 -+}
713 -+
714 -+static int alps_command_mode_read_reg(struct psmouse *psmouse, int addr)
715 -+{
716 -+ if (alps_command_mode_set_addr(psmouse, addr))
717 -+ return -1;
718 -+ return __alps_command_mode_read_reg(psmouse, addr);
719 -+}
720 -+
721 -+static int __alps_command_mode_write_reg(struct psmouse *psmouse, u8 value)
722 -+{
723 -+ if (alps_command_mode_send_nibble(psmouse, (value >> 4) & 0xf))
724 -+ return -1;
725 -+ if (alps_command_mode_send_nibble(psmouse, value & 0xf))
726 -+ return -1;
727 -+ return 0;
728 -+}
729 -+
730 -+static int alps_command_mode_write_reg(struct psmouse *psmouse, int addr,
731 -+ u8 value)
732 -+{
733 -+ if (alps_command_mode_set_addr(psmouse, addr))
734 -+ return -1;
735 -+ return __alps_command_mode_write_reg(psmouse, value);
736 -+}
737 -+
738 -+static int alps_enter_command_mode(struct psmouse *psmouse,
739 -+ unsigned char *resp)
740 -+{
741 -+ unsigned char param[4];
742 -+ struct ps2dev *ps2dev = &psmouse->ps2dev;
743 -+
744 -+ if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) ||
745 -+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) ||
746 -+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) ||
747 -+ ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {
748 -+ psmouse_err(psmouse, "failed to enter command mode\n");
749 -+ return -1;
750 -+ }
751 -+
752 -+ if (param[0] != 0x88 && param[1] != 0x07) {
753 -+ psmouse_dbg(psmouse,
754 -+ "unknown response while entering command mode: %2.2x %2.2x %2.2x\n",
755 -+ param[0], param[1], param[2]);
756 -+ return -1;
757 -+ }
758 -+
759 -+ if (resp)
760 -+ *resp = param[2];
761 -+ return 0;
762 -+}
763 -+
764 -+static inline int alps_exit_command_mode(struct psmouse *psmouse)
765 -+{
766 -+ struct ps2dev *ps2dev = &psmouse->ps2dev;
767 -+ if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSTREAM))
768 -+ return -1;
769 -+ return 0;
770 -+}
771 -+
772 - static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version)
773 - {
774 - struct ps2dev *ps2dev = &psmouse->ps2dev;
775 - static const unsigned char rates[] = { 0, 10, 20, 40, 60, 80, 100, 200 };
776 - unsigned char param[4];
777 -+ const struct alps_model_info *model = NULL;
778 - int i;
779 -
780 - /*
781 -@@ -464,12 +995,41 @@
782 - *version = (param[0] << 8) | (param[1] << 4) | i;
783 - }
784 -
785 -- for (i = 0; i < ARRAY_SIZE(alps_model_data); i++)
786 -+ for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) {
787 - if (!memcmp(param, alps_model_data[i].signature,
788 -- sizeof(alps_model_data[i].signature)))
789 -- return alps_model_data + i;
790 -+ sizeof(alps_model_data[i].signature))) {
791 -+ model = alps_model_data + i;
792 -+ break;
793 -+ }
794 -+ }
795 -+
796 -+ if (model && model->proto_version > ALPS_PROTO_V2) {
797 -+ /*
798 -+ * Need to check command mode response to identify
799 -+ * model
800 -+ */
801 -+ model = NULL;
802 -+ if (alps_enter_command_mode(psmouse, param)) {
803 -+ psmouse_warn(psmouse,
804 -+ "touchpad failed to enter command mode\n");
805 -+ } else {
806 -+ for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) {
807 -+ if (alps_model_data[i].proto_version > ALPS_PROTO_V2 &&
808 -+ alps_model_data[i].command_mode_resp == param[0]) {
809 -+ model = alps_model_data + i;
810 -+ break;
811 -+ }
812 -+ }
813 -+ alps_exit_command_mode(psmouse);
814 -+
815 -+ if (!model)
816 -+ psmouse_dbg(psmouse,
817 -+ "Unknown command mode response %2.2x\n",
818 -+ param[0]);
819 -+ }
820 -+ }
821 -
822 -- return NULL;
823 -+ return model;
824 - }
825 -
826 - /*
827 -@@ -477,7 +1037,7 @@
828 - * subsequent commands. It looks like glidepad is behind stickpointer,
829 - * I'd thought it would be other way around...
830 - */
831 --static int alps_passthrough_mode(struct psmouse *psmouse, bool enable)
832 -+static int alps_passthrough_mode_v2(struct psmouse *psmouse, bool enable)
833 - {
834 - struct ps2dev *ps2dev = &psmouse->ps2dev;
835 - int cmd = enable ? PSMOUSE_CMD_SETSCALE21 : PSMOUSE_CMD_SETSCALE11;
836 -@@ -494,7 +1054,7 @@
837 - return 0;
838 - }
839 -
840 --static int alps_absolute_mode(struct psmouse *psmouse)
841 -+static int alps_absolute_mode_v1_v2(struct psmouse *psmouse)
842 - {
843 - struct ps2dev *ps2dev = &psmouse->ps2dev;
844 -
845 -@@ -565,17 +1125,17 @@
846 - static int alps_poll(struct psmouse *psmouse)
847 - {
848 - struct alps_data *priv = psmouse->private;
849 -- unsigned char buf[6];
850 -+ unsigned char buf[sizeof(psmouse->packet)];
851 - bool poll_failed;
852 -
853 - if (priv->i->flags & ALPS_PASS)
854 -- alps_passthrough_mode(psmouse, true);
855 -+ alps_passthrough_mode_v2(psmouse, true);
856 -
857 - poll_failed = ps2_command(&psmouse->ps2dev, buf,
858 - PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)) < 0;
859 -
860 - if (priv->i->flags & ALPS_PASS)
861 -- alps_passthrough_mode(psmouse, false);
862 -+ alps_passthrough_mode_v2(psmouse, false);
863 -
864 - if (poll_failed || (buf[0] & priv->i->mask0) != priv->i->byte0)
865 - return -1;
866 -@@ -592,13 +1152,13 @@
867 - return 0;
868 - }
869 -
870 --static int alps_hw_init(struct psmouse *psmouse)
871 -+static int alps_hw_init_v1_v2(struct psmouse *psmouse)
872 - {
873 - struct alps_data *priv = psmouse->private;
874 - const struct alps_model_info *model = priv->i;
875 -
876 - if ((model->flags & ALPS_PASS) &&
877 -- alps_passthrough_mode(psmouse, true)) {
878 -+ alps_passthrough_mode_v2(psmouse, true)) {
879 - return -1;
880 - }
881 -
882 -@@ -607,13 +1167,13 @@
883 - return -1;
884 - }
885 -
886 -- if (alps_absolute_mode(psmouse)) {
887 -+ if (alps_absolute_mode_v1_v2(psmouse)) {
888 - psmouse_err(psmouse, "Failed to enable absolute mode\n");
889 - return -1;
890 - }
891 -
892 - if ((model->flags & ALPS_PASS) &&
893 -- alps_passthrough_mode(psmouse, false)) {
894 -+ alps_passthrough_mode_v2(psmouse, false)) {
895 - return -1;
896 - }
897 -
898 -@@ -626,6 +1186,297 @@
899 - return 0;
900 - }
901 -
902 -+/*
903 -+ * Enable or disable passthrough mode to the trackstick. Must be in
904 -+ * command mode when calling this function.
905 -+ */
906 -+static int alps_passthrough_mode_v3(struct psmouse *psmouse, bool enable)
907 -+{
908 -+ int reg_val;
909 -+
910 -+ reg_val = alps_command_mode_read_reg(psmouse, 0x0008);
911 -+ if (reg_val == -1)
912 -+ return -1;
913 -+
914 -+ if (enable)
915 -+ reg_val |= 0x01;
916 -+ else
917 -+ reg_val &= ~0x01;
918 -+
919 -+ if (__alps_command_mode_write_reg(psmouse, reg_val))
920 -+ return -1;
921 -+
922 -+ return 0;
923 -+}
924 -+
925 -+/* Must be in command mode when calling this function */
926 -+static int alps_absolute_mode_v3(struct psmouse *psmouse)
927 -+{
928 -+ int reg_val;
929 -+
930 -+ reg_val = alps_command_mode_read_reg(psmouse, 0x0004);
931 -+ if (reg_val == -1)
932 -+ return -1;
933 -+
934 -+ reg_val |= 0x06;
935 -+ if (__alps_command_mode_write_reg(psmouse, reg_val))
936 -+ return -1;
937 -+
938 -+ return 0;
939 -+}
940 -+
941 -+static int alps_hw_init_v3(struct psmouse *psmouse)
942 -+{
943 -+ struct alps_data *priv = psmouse->private;
944 -+ struct ps2dev *ps2dev = &psmouse->ps2dev;
945 -+ int reg_val;
946 -+ unsigned char param[4];
947 -+
948 -+ priv->nibble_commands = alps_v3_nibble_commands;
949 -+ priv->addr_command = PSMOUSE_CMD_RESET_WRAP;
950 -+
951 -+ if (alps_enter_command_mode(psmouse, NULL))
952 -+ goto error;
953 -+
954 -+ /* Check for trackstick */
955 -+ reg_val = alps_command_mode_read_reg(psmouse, 0x0008);
956 -+ if (reg_val == -1)
957 -+ goto error;
958 -+ if (reg_val & 0x80) {
959 -+ if (alps_passthrough_mode_v3(psmouse, true))
960 -+ goto error;
961 -+ if (alps_exit_command_mode(psmouse))
962 -+ goto error;
963 -+
964 -+ /*
965 -+ * E7 report for the trackstick
966 -+ *
967 -+ * There have been reports of failures to seem to trace back
968 -+ * to the above trackstick check failing. When these occur
969 -+ * this E7 report fails, so when that happens we continue
970 -+ * with the assumption that there isn't a trackstick after
971 -+ * all.
972 -+ */
973 -+ param[0] = 0x64;
974 -+ if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
975 -+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
976 -+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
977 -+ ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {
978 -+ psmouse_warn(psmouse, "trackstick E7 report failed\n");
979 -+ } else {
980 -+ psmouse_dbg(psmouse,
981 -+ "trackstick E7 report: %2.2x %2.2x %2.2x\n",
982 -+ param[0], param[1], param[2]);
983 -+
984 -+ /*
985 -+ * Not sure what this does, but it is absolutely
986 -+ * essential. Without it, the touchpad does not
987 -+ * work at all and the trackstick just emits normal
988 -+ * PS/2 packets.
989 -+ */
990 -+ if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
991 -+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
992 -+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
993 -+ alps_command_mode_send_nibble(psmouse, 0x9) ||
994 -+ alps_command_mode_send_nibble(psmouse, 0x4)) {
995 -+ psmouse_err(psmouse,
996 -+ "Error sending magic E6 sequence\n");
997 -+ goto error_passthrough;
998 -+ }
999 -+ }
1000 -+
1001 -+ if (alps_enter_command_mode(psmouse, NULL))
1002 -+ goto error_passthrough;
1003 -+ if (alps_passthrough_mode_v3(psmouse, false))
1004 -+ goto error;
1005 -+ }
1006 -+
1007 -+ if (alps_absolute_mode_v3(psmouse)) {
1008 -+ psmouse_err(psmouse, "Failed to enter absolute mode\n");
1009 -+ goto error;
1010 -+ }
1011 -+
1012 -+ reg_val = alps_command_mode_read_reg(psmouse, 0x0006);
1013 -+ if (reg_val == -1)
1014 -+ goto error;
1015 -+ if (__alps_command_mode_write_reg(psmouse, reg_val | 0x01))
1016 -+ goto error;
1017 -+
1018 -+ reg_val = alps_command_mode_read_reg(psmouse, 0x0007);
1019 -+ if (reg_val == -1)
1020 -+ goto error;
1021 -+ if (__alps_command_mode_write_reg(psmouse, reg_val | 0x01))
1022 -+ goto error;
1023 -+
1024 -+ if (alps_command_mode_read_reg(psmouse, 0x0144) == -1)
1025 -+ goto error;
1026 -+ if (__alps_command_mode_write_reg(psmouse, 0x04))
1027 -+ goto error;
1028 -+
1029 -+ if (alps_command_mode_read_reg(psmouse, 0x0159) == -1)
1030 -+ goto error;
1031 -+ if (__alps_command_mode_write_reg(psmouse, 0x03))
1032 -+ goto error;
1033 -+
1034 -+ if (alps_command_mode_read_reg(psmouse, 0x0163) == -1)
1035 -+ goto error;
1036 -+ if (alps_command_mode_write_reg(psmouse, 0x0163, 0x03))
1037 -+ goto error;
1038 -+
1039 -+ if (alps_command_mode_read_reg(psmouse, 0x0162) == -1)
1040 -+ goto error;
1041 -+ if (alps_command_mode_write_reg(psmouse, 0x0162, 0x04))
1042 -+ goto error;
1043 -+
1044 -+ /*
1045 -+ * This ensures the trackstick packets are in the format
1046 -+ * supported by this driver. If bit 1 isn't set the packet
1047 -+ * format is different.
1048 -+ */
1049 -+ if (alps_command_mode_write_reg(psmouse, 0x0008, 0x82))
1050 -+ goto error;
1051 -+
1052 -+ alps_exit_command_mode(psmouse);
1053 -+
1054 -+ /* Set rate and enable data reporting */
1055 -+ param[0] = 0x64;
1056 -+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE) ||
1057 -+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) {
1058 -+ psmouse_err(psmouse, "Failed to enable data reporting\n");
1059 -+ return -1;
1060 -+ }
1061 -+
1062 -+ return 0;
1063 -+
1064 -+error_passthrough:
1065 -+ /* Something failed while in passthrough mode, so try to get out */
1066 -+ if (!alps_enter_command_mode(psmouse, NULL))
1067 -+ alps_passthrough_mode_v3(psmouse, false);
1068 -+error:
1069 -+ /*
1070 -+ * Leaving the touchpad in command mode will essentially render
1071 -+ * it unusable until the machine reboots, so exit it here just
1072 -+ * to be safe
1073 -+ */
1074 -+ alps_exit_command_mode(psmouse);
1075 -+ return -1;
1076 -+}
1077 -+
1078 -+/* Must be in command mode when calling this function */
1079 -+static int alps_absolute_mode_v4(struct psmouse *psmouse)
1080 -+{
1081 -+ int reg_val;
1082 -+
1083 -+ reg_val = alps_command_mode_read_reg(psmouse, 0x0004);
1084 -+ if (reg_val == -1)
1085 -+ return -1;
1086 -+
1087 -+ reg_val |= 0x02;
1088 -+ if (__alps_command_mode_write_reg(psmouse, reg_val))
1089 -+ return -1;
1090 -+
1091 -+ return 0;
1092 -+}
1093 -+
1094 -+static int alps_hw_init_v4(struct psmouse *psmouse)
1095 -+{
1096 -+ struct alps_data *priv = psmouse->private;
1097 -+ struct ps2dev *ps2dev = &psmouse->ps2dev;
1098 -+ unsigned char param[4];
1099 -+
1100 -+ priv->nibble_commands = alps_v4_nibble_commands;
1101 -+ priv->addr_command = PSMOUSE_CMD_DISABLE;
1102 -+
1103 -+ if (alps_enter_command_mode(psmouse, NULL))
1104 -+ goto error;
1105 -+
1106 -+ if (alps_absolute_mode_v4(psmouse)) {
1107 -+ psmouse_err(psmouse, "Failed to enter absolute mode\n");
1108 -+ goto error;
1109 -+ }
1110 -+
1111 -+ if (alps_command_mode_write_reg(psmouse, 0x0007, 0x8c))
1112 -+ goto error;
1113 -+
1114 -+ if (alps_command_mode_write_reg(psmouse, 0x0149, 0x03))
1115 -+ goto error;
1116 -+
1117 -+ if (alps_command_mode_write_reg(psmouse, 0x0160, 0x03))
1118 -+ goto error;
1119 -+
1120 -+ if (alps_command_mode_write_reg(psmouse, 0x017f, 0x15))
1121 -+ goto error;
1122 -+
1123 -+ if (alps_command_mode_write_reg(psmouse, 0x0151, 0x01))
1124 -+ goto error;
1125 -+
1126 -+ if (alps_command_mode_write_reg(psmouse, 0x0168, 0x03))
1127 -+ goto error;
1128 -+
1129 -+ if (alps_command_mode_write_reg(psmouse, 0x014a, 0x03))
1130 -+ goto error;
1131 -+
1132 -+ if (alps_command_mode_write_reg(psmouse, 0x0161, 0x03))
1133 -+ goto error;
1134 -+
1135 -+ alps_exit_command_mode(psmouse);
1136 -+
1137 -+ /*
1138 -+ * This sequence changes the output from a 9-byte to an
1139 -+ * 8-byte format. All the same data seems to be present,
1140 -+ * just in a more compact format.
1141 -+ */
1142 -+ param[0] = 0xc8;
1143 -+ param[1] = 0x64;
1144 -+ param[2] = 0x50;
1145 -+ if (ps2_command(ps2dev, &param[0], PSMOUSE_CMD_SETRATE) ||
1146 -+ ps2_command(ps2dev, &param[1], PSMOUSE_CMD_SETRATE) ||
1147 -+ ps2_command(ps2dev, &param[2], PSMOUSE_CMD_SETRATE) ||
1148 -+ ps2_command(ps2dev, param, PSMOUSE_CMD_GETID))
1149 -+ return -1;
1150 -+
1151 -+ /* Set rate and enable data reporting */
1152 -+ param[0] = 0x64;
1153 -+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE) ||
1154 -+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) {
1155 -+ psmouse_err(psmouse, "Failed to enable data reporting\n");
1156 -+ return -1;
1157 -+ }
1158 -+
1159 -+ return 0;
1160 -+
1161 -+error:
1162 -+ /*
1163 -+ * Leaving the touchpad in command mode will essentially render
1164 -+ * it unusable until the machine reboots, so exit it here just
1165 -+ * to be safe
1166 -+ */
1167 -+ alps_exit_command_mode(psmouse);
1168 -+ return -1;
1169 -+}
1170 -+
1171 -+static int alps_hw_init(struct psmouse *psmouse)
1172 -+{
1173 -+ struct alps_data *priv = psmouse->private;
1174 -+ const struct alps_model_info *model = priv->i;
1175 -+ int ret = -1;
1176 -+
1177 -+ switch (model->proto_version) {
1178 -+ case ALPS_PROTO_V1:
1179 -+ case ALPS_PROTO_V2:
1180 -+ ret = alps_hw_init_v1_v2(psmouse);
1181 -+ break;
1182 -+ case ALPS_PROTO_V3:
1183 -+ ret = alps_hw_init_v3(psmouse);
1184 -+ break;
1185 -+ case ALPS_PROTO_V4:
1186 -+ ret = alps_hw_init_v4(psmouse);
1187 -+ break;
1188 -+ }
1189 -+
1190 -+ return ret;
1191 -+}
1192 -+
1193 - static int alps_reconnect(struct psmouse *psmouse)
1194 - {
1195 - const struct alps_model_info *model;
1196 -@@ -666,6 +1517,8 @@
1197 -
1198 - psmouse->private = priv;
1199 -
1200 -+ psmouse_reset(psmouse);
1201 -+
1202 - model = alps_get_model(psmouse, &version);
1203 - if (!model)
1204 - goto init_fail;
1205 -@@ -693,8 +1546,29 @@
1206 - BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT);
1207 -
1208 - dev1->evbit[BIT_WORD(EV_ABS)] |= BIT_MASK(EV_ABS);
1209 -- input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0);
1210 -- input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0);
1211 -+
1212 -+ switch (model->proto_version) {
1213 -+ case ALPS_PROTO_V1:
1214 -+ case ALPS_PROTO_V2:
1215 -+ input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0);
1216 -+ input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0);
1217 -+ break;
1218 -+ case ALPS_PROTO_V3:
1219 -+ set_bit(INPUT_PROP_SEMI_MT, dev1->propbit);
1220 -+ input_mt_init_slots(dev1, 2);
1221 -+ input_set_abs_params(dev1, ABS_MT_POSITION_X, 0, ALPS_V3_X_MAX, 0, 0);
1222 -+ input_set_abs_params(dev1, ABS_MT_POSITION_Y, 0, ALPS_V3_Y_MAX, 0, 0);
1223 -+
1224 -+ set_bit(BTN_TOOL_DOUBLETAP, dev1->keybit);
1225 -+ set_bit(BTN_TOOL_TRIPLETAP, dev1->keybit);
1226 -+ set_bit(BTN_TOOL_QUADTAP, dev1->keybit);
1227 -+ /* fall through */
1228 -+ case ALPS_PROTO_V4:
1229 -+ input_set_abs_params(dev1, ABS_X, 0, ALPS_V3_X_MAX, 0, 0);
1230 -+ input_set_abs_params(dev1, ABS_Y, 0, ALPS_V3_Y_MAX, 0, 0);
1231 -+ break;
1232 -+ }
1233 -+
1234 - input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0);
1235 -
1236 - if (model->flags & ALPS_WHEEL) {
1237 -@@ -737,7 +1611,7 @@
1238 - psmouse->poll = alps_poll;
1239 - psmouse->disconnect = alps_disconnect;
1240 - psmouse->reconnect = alps_reconnect;
1241 -- psmouse->pktsize = 6;
1242 -+ psmouse->pktsize = model->proto_version == ALPS_PROTO_V4 ? 8 : 6;
1243 -
1244 - /* We are having trouble resyncing ALPS touchpads so disable it for now */
1245 - psmouse->resync_time = 0;
1246 -diff -ur linux-3.2.old/drivers/input/mouse/alps.h linux-3.2/drivers/input/mouse/alps.h
1247 ---- linux-3.2.old/drivers/input/mouse/alps.h 2012-01-04 17:55:44.000000000 -0600
1248 -+++ linux-3.2/drivers/input/mouse/alps.h 2012-01-05 18:53:42.235275879 -0600
1249 -@@ -12,20 +12,39 @@
1250 - #ifndef _ALPS_H
1251 - #define _ALPS_H
1252 -
1253 -+#define ALPS_PROTO_V1 0
1254 -+#define ALPS_PROTO_V2 1
1255 -+#define ALPS_PROTO_V3 2
1256 -+#define ALPS_PROTO_V4 3
1257 -+
1258 - struct alps_model_info {
1259 - unsigned char signature[3];
1260 -+ unsigned char command_mode_resp; /* v3/v4 only */
1261 -+ unsigned char proto_version;
1262 - unsigned char byte0, mask0;
1263 - unsigned char flags;
1264 - };
1265 -
1266 -+struct alps_nibble_commands {
1267 -+ int command;
1268 -+ unsigned char data;
1269 -+};
1270 -+
1271 - struct alps_data {
1272 - struct input_dev *dev2; /* Relative device */
1273 - char phys[32]; /* Phys */
1274 - const struct alps_model_info *i;/* Info */
1275 -+ const struct alps_nibble_commands *nibble_commands;
1276 -+ int addr_command; /* Command to set register address */
1277 - int prev_fin; /* Finger bit from previous packet */
1278 -+ int multi_packet; /* Multi-packet data in progress */
1279 -+ unsigned char multi_data[6]; /* Saved multi-packet data */
1280 -+ u8 quirks;
1281 - struct timer_list timer;
1282 - };
1283 -
1284 -+#define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */
1285 -+
1286 - #ifdef CONFIG_MOUSE_PS2_ALPS
1287 - int alps_detect(struct psmouse *psmouse, bool set_properties);
1288 - int alps_init(struct psmouse *psmouse);
1289 -diff -ur linux-3.2.old/drivers/input/mouse/psmouse.h linux-3.2/drivers/input/mouse/psmouse.h
1290 ---- linux-3.2.old/drivers/input/mouse/psmouse.h 2012-01-04 17:55:44.000000000 -0600
1291 -+++ linux-3.2/drivers/input/mouse/psmouse.h 2012-01-05 18:53:42.231275880 -0600
1292 -@@ -8,6 +8,7 @@
1293 - #define PSMOUSE_CMD_SETSTREAM 0x00ea
1294 - #define PSMOUSE_CMD_SETPOLL 0x00f0
1295 - #define PSMOUSE_CMD_POLL 0x00eb /* caller sets number of bytes to receive */
1296 -+#define PSMOUSE_CMD_RESET_WRAP 0x00ec
1297 - #define PSMOUSE_CMD_GETID 0x02f2
1298 - #define PSMOUSE_CMD_SETRATE 0x10f3
1299 - #define PSMOUSE_CMD_ENABLE 0x00f4