vserver 1.9.3
[linux-2.6.git] / drivers / input / mouse / synaptics.c
1 /*
2  * Synaptics TouchPad PS/2 mouse driver
3  *
4  *   2003 Dmitry Torokhov <dtor@mail.ru>
5  *     Added support for pass-through port. Special thanks to Peter Berg Larsen
6  *     for explaining various Synaptics quirks.
7  *
8  *   2003 Peter Osterlund <petero2@telia.com>
9  *     Ported to 2.5 input device infrastructure.
10  *
11  *   Copyright (C) 2001 Stefan Gmeiner <riddlebox@freesurf.ch>
12  *     start merging tpconfig and gpm code to a xfree-input module
13  *     adding some changes and extensions (ex. 3rd and 4th button)
14  *
15  *   Copyright (c) 1997 C. Scott Ananian <cananian@alumni.priceton.edu>
16  *   Copyright (c) 1998-2000 Bruce Kalk <kall@compass.com>
17  *     code for the special synaptics commands (from the tpconfig-source)
18  *
19  * This program is free software; you can redistribute it and/or modify it
20  * under the terms of the GNU General Public License version 2 as published by
21  * the Free Software Foundation.
22  *
23  * Trademarks are the property of their respective owners.
24  */
25
26 #include <linux/module.h>
27 #include <linux/input.h>
28 #include <linux/serio.h>
29 #include "psmouse.h"
30 #include "synaptics.h"
31
32 /*
33  * The x/y limits are taken from the Synaptics TouchPad interfacing Guide,
34  * section 2.3.2, which says that they should be valid regardless of the
35  * actual size of the sensor.
36  */
37 #define XMIN_NOMINAL 1472
38 #define XMAX_NOMINAL 5472
39 #define YMIN_NOMINAL 1408
40 #define YMAX_NOMINAL 4448
41
42 /*****************************************************************************
43  *      Synaptics communications functions
44  ****************************************************************************/
45
46 /*
47  * Send a command to the synpatics touchpad by special commands
48  */
49 static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, unsigned char *param)
50 {
51         if (psmouse_sliced_command(psmouse, c))
52                 return -1;
53         if (psmouse_command(psmouse, param, PSMOUSE_CMD_GETINFO))
54                 return -1;
55         return 0;
56 }
57
58 /*
59  * Set the synaptics touchpad mode byte by special commands
60  */
61 static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode)
62 {
63         unsigned char param[1];
64
65         if (psmouse_sliced_command(psmouse, mode))
66                 return -1;
67         param[0] = SYN_PS_SET_MODE2;
68         if (psmouse_command(psmouse, param, PSMOUSE_CMD_SETRATE))
69                 return -1;
70         return 0;
71 }
72
73 /*
74  * Read the model-id bytes from the touchpad
75  * see also SYN_MODEL_* macros
76  */
77 static int synaptics_model_id(struct psmouse *psmouse)
78 {
79         struct synaptics_data *priv = psmouse->private;
80         unsigned char mi[3];
81
82         if (synaptics_send_cmd(psmouse, SYN_QUE_MODEL, mi))
83                 return -1;
84         priv->model_id = (mi[0]<<16) | (mi[1]<<8) | mi[2];
85         return 0;
86 }
87
88 /*
89  * Read the capability-bits from the touchpad
90  * see also the SYN_CAP_* macros
91  */
92 static int synaptics_capability(struct psmouse *psmouse)
93 {
94         struct synaptics_data *priv = psmouse->private;
95         unsigned char cap[3];
96
97         if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap))
98                 return -1;
99         priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2];
100         priv->ext_cap = 0;
101         if (!SYN_CAP_VALID(priv->capabilities))
102                 return -1;
103
104         /*
105          * Unless capExtended is set the rest of the flags should be ignored
106          */
107         if (!SYN_CAP_EXTENDED(priv->capabilities))
108                 priv->capabilities = 0;
109
110         if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 1) {
111                 if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) {
112                         printk(KERN_ERR "Synaptics claims to have extended capabilities,"
113                                " but I'm not able to read them.");
114                 } else {
115                         priv->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2];
116
117                         /*
118                          * if nExtBtn is greater than 8 it should be considered
119                          * invalid and treated as 0
120                          */
121                         if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) > 8)
122                                 priv->ext_cap &= 0xff0fff;
123                 }
124         }
125         return 0;
126 }
127
128 /*
129  * Identify Touchpad
130  * See also the SYN_ID_* macros
131  */
132 static int synaptics_identify(struct psmouse *psmouse)
133 {
134         struct synaptics_data *priv = psmouse->private;
135         unsigned char id[3];
136
137         if (synaptics_send_cmd(psmouse, SYN_QUE_IDENTIFY, id))
138                 return -1;
139         priv->identity = (id[0]<<16) | (id[1]<<8) | id[2];
140         if (SYN_ID_IS_SYNAPTICS(priv->identity))
141                 return 0;
142         return -1;
143 }
144
145 static void print_ident(struct synaptics_data *priv)
146 {
147         printk(KERN_INFO "Synaptics Touchpad, model: %ld\n", SYN_ID_MODEL(priv->identity));
148         printk(KERN_INFO " Firmware: %ld.%ld\n", SYN_ID_MAJOR(priv->identity),
149                SYN_ID_MINOR(priv->identity));
150         if (SYN_MODEL_ROT180(priv->model_id))
151                 printk(KERN_INFO " 180 degree mounted touchpad\n");
152         if (SYN_MODEL_PORTRAIT(priv->model_id))
153                 printk(KERN_INFO " portrait touchpad\n");
154         printk(KERN_INFO " Sensor: %ld\n", SYN_MODEL_SENSOR(priv->model_id));
155         if (SYN_MODEL_NEWABS(priv->model_id))
156                 printk(KERN_INFO " new absolute packet format\n");
157         if (SYN_MODEL_PEN(priv->model_id))
158                 printk(KERN_INFO " pen detection\n");
159
160         if (SYN_CAP_EXTENDED(priv->capabilities)) {
161                 printk(KERN_INFO " Touchpad has extended capability bits\n");
162                 if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap))
163                         printk(KERN_INFO " -> %d multi-buttons, i.e. besides standard buttons\n",
164                                (int)(SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)));
165                 if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
166                         printk(KERN_INFO " -> middle button\n");
167                 if (SYN_CAP_FOUR_BUTTON(priv->capabilities))
168                         printk(KERN_INFO " -> four buttons\n");
169                 if (SYN_CAP_MULTIFINGER(priv->capabilities))
170                         printk(KERN_INFO " -> multifinger detection\n");
171                 if (SYN_CAP_PALMDETECT(priv->capabilities))
172                         printk(KERN_INFO " -> palm detection\n");
173                 if (SYN_CAP_PASS_THROUGH(priv->capabilities))
174                         printk(KERN_INFO " -> pass-through port\n");
175         }
176 }
177
178 static int synaptics_query_hardware(struct psmouse *psmouse)
179 {
180         int retries = 0;
181
182         while ((retries++ < 3) && psmouse_reset(psmouse))
183                 printk(KERN_ERR "synaptics reset failed\n");
184
185         if (synaptics_identify(psmouse))
186                 return -1;
187         if (synaptics_model_id(psmouse))
188                 return -1;
189         if (synaptics_capability(psmouse))
190                 return -1;
191
192         return 0;
193 }
194
195 static int synaptics_set_mode(struct psmouse *psmouse, int mode)
196 {
197         struct synaptics_data *priv = psmouse->private;
198
199         mode |= SYN_BIT_ABSOLUTE_MODE;
200         if (psmouse_rate >= 80)
201                 mode |= SYN_BIT_HIGH_RATE;
202         if (SYN_ID_MAJOR(priv->identity) >= 4)
203                 mode |= SYN_BIT_DISABLE_GESTURE;
204         if (SYN_CAP_EXTENDED(priv->capabilities))
205                 mode |= SYN_BIT_W_MODE;
206         if (synaptics_mode_cmd(psmouse, mode))
207                 return -1;
208
209         return 0;
210 }
211
212 /*****************************************************************************
213  *      Synaptics pass-through PS/2 port support
214  ****************************************************************************/
215 static int synaptics_pt_write(struct serio *serio, unsigned char c)
216 {
217         struct psmouse *parent = serio->parent->private;
218         char rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */
219
220         if (psmouse_sliced_command(parent, c))
221                 return -1;
222         if (psmouse_command(parent, &rate_param, PSMOUSE_CMD_SETRATE))
223                 return -1;
224         return 0;
225 }
226
227 static inline int synaptics_is_pt_packet(unsigned char *buf)
228 {
229         return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4;
230 }
231
232 static void synaptics_pass_pt_packet(struct serio *ptport, unsigned char *packet)
233 {
234         struct psmouse *child = ptport->private;
235
236         if (child && child->state == PSMOUSE_ACTIVATED) {
237                 serio_interrupt(ptport, packet[1], 0, NULL);
238                 serio_interrupt(ptport, packet[4], 0, NULL);
239                 serio_interrupt(ptport, packet[5], 0, NULL);
240                 if (child->type >= PSMOUSE_GENPS)
241                         serio_interrupt(ptport, packet[2], 0, NULL);
242         } else
243                 serio_interrupt(ptport, packet[1], 0, NULL);
244 }
245
246 static void synaptics_pt_activate(struct psmouse *psmouse)
247 {
248         struct psmouse *child = psmouse->serio->child->private;
249
250         /* adjust the touchpad to child's choice of protocol */
251         if (child && child->type >= PSMOUSE_GENPS) {
252                 if (synaptics_set_mode(psmouse, SYN_BIT_FOUR_BYTE_CLIENT))
253                         printk(KERN_INFO "synaptics: failed to enable 4-byte guest protocol\n");
254         }
255 }
256
257 static void synaptics_pt_create(struct psmouse *psmouse)
258 {
259         struct serio *serio;
260
261         serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
262         if (!serio) {
263                 printk(KERN_ERR "synaptics: not enough memory to allocate pass-through port\n");
264                 return;
265         }
266
267         memset(serio, 0, sizeof(struct serio));
268
269         serio->type = SERIO_PS_PSTHRU;
270         strlcpy(serio->name, "Synaptics pass-through", sizeof(serio->name));
271         strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->name));
272         serio->write = synaptics_pt_write;
273         serio->parent = psmouse->serio;
274
275         psmouse->pt_activate = synaptics_pt_activate;
276
277         psmouse->serio->child = serio;
278 }
279
280 /*****************************************************************************
281  *      Functions to interpret the absolute mode packets
282  ****************************************************************************/
283
284 static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data *priv, struct synaptics_hw_state *hw)
285 {
286         memset(hw, 0, sizeof(struct synaptics_hw_state));
287
288         if (SYN_MODEL_NEWABS(priv->model_id)) {
289                 hw->x = (((buf[3] & 0x10) << 8) |
290                          ((buf[1] & 0x0f) << 8) |
291                          buf[4]);
292                 hw->y = (((buf[3] & 0x20) << 7) |
293                          ((buf[1] & 0xf0) << 4) |
294                          buf[5]);
295
296                 hw->z = buf[2];
297                 hw->w = (((buf[0] & 0x30) >> 2) |
298                          ((buf[0] & 0x04) >> 1) |
299                          ((buf[3] & 0x04) >> 2));
300
301                 hw->left  = (buf[0] & 0x01) ? 1 : 0;
302                 hw->right = (buf[0] & 0x02) ? 1 : 0;
303
304                 if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
305                         hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
306
307                 if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
308                         hw->up   = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
309                         hw->down = ((buf[0] ^ buf[3]) & 0x02) ? 1 : 0;
310                 }
311
312                 if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) &&
313                     ((buf[0] ^ buf[3]) & 0x02)) {
314                         switch (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) & ~0x01) {
315                         default:
316                                 /*
317                                  * if nExtBtn is greater than 8 it should be
318                                  * considered invalid and treated as 0
319                                  */
320                                 break;
321                         case 8:
322                                 hw->ext_buttons |= ((buf[5] & 0x08)) ? 0x80 : 0;
323                                 hw->ext_buttons |= ((buf[4] & 0x08)) ? 0x40 : 0;
324                         case 6:
325                                 hw->ext_buttons |= ((buf[5] & 0x04)) ? 0x20 : 0;
326                                 hw->ext_buttons |= ((buf[4] & 0x04)) ? 0x10 : 0;
327                         case 4:
328                                 hw->ext_buttons |= ((buf[5] & 0x02)) ? 0x08 : 0;
329                                 hw->ext_buttons |= ((buf[4] & 0x02)) ? 0x04 : 0;
330                         case 2:
331                                 hw->ext_buttons |= ((buf[5] & 0x01)) ? 0x02 : 0;
332                                 hw->ext_buttons |= ((buf[4] & 0x01)) ? 0x01 : 0;
333                         }
334                 }
335         } else {
336                 hw->x = (((buf[1] & 0x1f) << 8) | buf[2]);
337                 hw->y = (((buf[4] & 0x1f) << 8) | buf[5]);
338
339                 hw->z = (((buf[0] & 0x30) << 2) | (buf[3] & 0x3F));
340                 hw->w = (((buf[1] & 0x80) >> 4) | ((buf[0] & 0x04) >> 1));
341
342                 hw->left  = (buf[0] & 0x01) ? 1 : 0;
343                 hw->right = (buf[0] & 0x02) ? 1 : 0;
344         }
345 }
346
347 /*
348  *  called for each full received packet from the touchpad
349  */
350 static void synaptics_process_packet(struct psmouse *psmouse)
351 {
352         struct input_dev *dev = &psmouse->dev;
353         struct synaptics_data *priv = psmouse->private;
354         struct synaptics_hw_state hw;
355         int num_fingers;
356         int finger_width;
357         int i;
358
359         synaptics_parse_hw_state(psmouse->packet, priv, &hw);
360
361         if (hw.z > 0) {
362                 num_fingers = 1;
363                 finger_width = 5;
364                 if (SYN_CAP_EXTENDED(priv->capabilities)) {
365                         switch (hw.w) {
366                         case 0 ... 1:
367                                 if (SYN_CAP_MULTIFINGER(priv->capabilities))
368                                         num_fingers = hw.w + 2;
369                                 break;
370                         case 2:
371                                 if (SYN_MODEL_PEN(priv->model_id))
372                                         ;   /* Nothing, treat a pen as a single finger */
373                                 break;
374                         case 4 ... 15:
375                                 if (SYN_CAP_PALMDETECT(priv->capabilities))
376                                         finger_width = hw.w;
377                                 break;
378                         }
379                 }
380         } else {
381                 num_fingers = 0;
382                 finger_width = 0;
383         }
384
385         /* Post events
386          * BTN_TOUCH has to be first as mousedev relies on it when doing
387          * absolute -> relative conversion
388          */
389         if (hw.z > 30) input_report_key(dev, BTN_TOUCH, 1);
390         if (hw.z < 25) input_report_key(dev, BTN_TOUCH, 0);
391
392         if (hw.z > 0) {
393                 input_report_abs(dev, ABS_X, hw.x);
394                 input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - hw.y);
395         }
396         input_report_abs(dev, ABS_PRESSURE, hw.z);
397
398         input_report_abs(dev, ABS_TOOL_WIDTH, finger_width);
399         input_report_key(dev, BTN_TOOL_FINGER, num_fingers == 1);
400         input_report_key(dev, BTN_TOOL_DOUBLETAP, num_fingers == 2);
401         input_report_key(dev, BTN_TOOL_TRIPLETAP, num_fingers == 3);
402
403         input_report_key(dev, BTN_LEFT, hw.left);
404         input_report_key(dev, BTN_RIGHT, hw.right);
405
406         if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
407                 input_report_key(dev, BTN_MIDDLE, hw.middle);
408
409         if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
410                 input_report_key(dev, BTN_FORWARD, hw.up);
411                 input_report_key(dev, BTN_BACK, hw.down);
412         }
413
414         for (i = 0; i < SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap); i++)
415                 input_report_key(dev, BTN_0 + i, hw.ext_buttons & (1 << i));
416
417         input_sync(dev);
418 }
419
420 static int synaptics_validate_byte(unsigned char packet[], int idx, unsigned char pkt_type)
421 {
422         static unsigned char newabs_mask[]      = { 0xC8, 0x00, 0x00, 0xC8, 0x00 };
423         static unsigned char newabs_rel_mask[]  = { 0xC0, 0x00, 0x00, 0xC0, 0x00 };
424         static unsigned char newabs_rslt[]      = { 0x80, 0x00, 0x00, 0xC0, 0x00 };
425         static unsigned char oldabs_mask[]      = { 0xC0, 0x60, 0x00, 0xC0, 0x60 };
426         static unsigned char oldabs_rslt[]      = { 0xC0, 0x00, 0x00, 0x80, 0x00 };
427
428         if (idx < 0 || idx > 4)
429                 return 0;
430
431         switch (pkt_type) {
432                 case SYN_NEWABS:
433                 case SYN_NEWABS_RELAXED:
434                         return (packet[idx] & newabs_rel_mask[idx]) == newabs_rslt[idx];
435
436                 case SYN_NEWABS_STRICT:
437                         return (packet[idx] & newabs_mask[idx]) == newabs_rslt[idx];
438
439                 case SYN_OLDABS:
440                         return (packet[idx] & oldabs_mask[idx]) == oldabs_rslt[idx];
441
442                 default:
443                         printk(KERN_ERR "synaptics: unknown packet type %d\n", pkt_type);
444                         return 0;
445         }
446 }
447
448 static unsigned char synaptics_detect_pkt_type(struct psmouse *psmouse)
449 {
450         int i;
451
452         for (i = 0; i < 5; i++)
453                 if (!synaptics_validate_byte(psmouse->packet, i, SYN_NEWABS_STRICT)) {
454                         printk(KERN_INFO "synaptics: using relaxed packet validation\n");
455                         return SYN_NEWABS_RELAXED;
456                 }
457
458         return SYN_NEWABS_STRICT;
459 }
460
461 static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
462 {
463         struct input_dev *dev = &psmouse->dev;
464         struct synaptics_data *priv = psmouse->private;
465
466         input_regs(dev, regs);
467
468         if (psmouse->pktcnt >= 6) { /* Full packet received */
469                 if (unlikely(priv->pkt_type == SYN_NEWABS))
470                         priv->pkt_type = synaptics_detect_pkt_type(psmouse);
471
472                 if (SYN_CAP_PASS_THROUGH(priv->capabilities) && synaptics_is_pt_packet(psmouse->packet)) {
473                         if (psmouse->serio->child)
474                                 synaptics_pass_pt_packet(psmouse->serio->child, psmouse->packet);
475                 } else
476                         synaptics_process_packet(psmouse);
477
478                 return PSMOUSE_FULL_PACKET;
479         }
480
481         return synaptics_validate_byte(psmouse->packet, psmouse->pktcnt - 1, priv->pkt_type) ?
482                 PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA;
483 }
484
485 /*****************************************************************************
486  *      Driver initialization/cleanup functions
487  ****************************************************************************/
488 static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
489 {
490         int i;
491
492         set_bit(EV_ABS, dev->evbit);
493         input_set_abs_params(dev, ABS_X, XMIN_NOMINAL, XMAX_NOMINAL, 0, 0);
494         input_set_abs_params(dev, ABS_Y, YMIN_NOMINAL, YMAX_NOMINAL, 0, 0);
495         input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
496         set_bit(ABS_TOOL_WIDTH, dev->absbit);
497
498         set_bit(EV_KEY, dev->evbit);
499         set_bit(BTN_TOUCH, dev->keybit);
500         set_bit(BTN_TOOL_FINGER, dev->keybit);
501         set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
502         set_bit(BTN_TOOL_TRIPLETAP, dev->keybit);
503
504         set_bit(BTN_LEFT, dev->keybit);
505         set_bit(BTN_RIGHT, dev->keybit);
506
507         if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
508                 set_bit(BTN_MIDDLE, dev->keybit);
509
510         if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
511                 set_bit(BTN_FORWARD, dev->keybit);
512                 set_bit(BTN_BACK, dev->keybit);
513         }
514
515         for (i = 0; i < SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap); i++)
516                 set_bit(BTN_0 + i, dev->keybit);
517
518         clear_bit(EV_REL, dev->evbit);
519         clear_bit(REL_X, dev->relbit);
520         clear_bit(REL_Y, dev->relbit);
521 }
522
523 void synaptics_reset(struct psmouse *psmouse)
524 {
525         /* reset touchpad back to relative mode, gestures enabled */
526         synaptics_mode_cmd(psmouse, 0);
527 }
528
529 static void synaptics_disconnect(struct psmouse *psmouse)
530 {
531         synaptics_reset(psmouse);
532         kfree(psmouse->private);
533 }
534
535 static int synaptics_reconnect(struct psmouse *psmouse)
536 {
537         struct synaptics_data *priv = psmouse->private;
538         struct synaptics_data old_priv = *priv;
539
540         if (!synaptics_detect(psmouse))
541                 return -1;
542
543         if (synaptics_query_hardware(psmouse)) {
544                 printk(KERN_ERR "Unable to query Synaptics hardware.\n");
545                 return -1;
546         }
547
548         if (old_priv.identity != priv->identity ||
549             old_priv.model_id != priv->model_id ||
550             old_priv.capabilities != priv->capabilities ||
551             old_priv.ext_cap != priv->ext_cap)
552                 return -1;
553
554         if (synaptics_set_mode(psmouse, 0)) {
555                 printk(KERN_ERR "Unable to initialize Synaptics hardware.\n");
556                 return -1;
557         }
558
559         return 0;
560 }
561
562 int synaptics_detect(struct psmouse *psmouse)
563 {
564         unsigned char param[4];
565
566         param[0] = 0;
567
568         psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
569         psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
570         psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
571         psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
572         psmouse_command(psmouse, param, PSMOUSE_CMD_GETINFO);
573
574         return param[1] == 0x47;
575 }
576
577 int synaptics_init(struct psmouse *psmouse)
578 {
579         struct synaptics_data *priv;
580
581         psmouse->private = priv = kmalloc(sizeof(struct synaptics_data), GFP_KERNEL);
582         if (!priv)
583                 return -1;
584         memset(priv, 0, sizeof(struct synaptics_data));
585
586         if (synaptics_query_hardware(psmouse)) {
587                 printk(KERN_ERR "Unable to query Synaptics hardware.\n");
588                 goto init_fail;
589         }
590
591         if (synaptics_set_mode(psmouse, 0)) {
592                 printk(KERN_ERR "Unable to initialize Synaptics hardware.\n");
593                 goto init_fail;
594         }
595
596         priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;
597
598         if (SYN_CAP_PASS_THROUGH(priv->capabilities))
599                 synaptics_pt_create(psmouse);
600
601         print_ident(priv);
602         set_input_params(&psmouse->dev, priv);
603
604         psmouse->protocol_handler = synaptics_process_byte;
605         psmouse->disconnect = synaptics_disconnect;
606         psmouse->reconnect = synaptics_reconnect;
607
608         return 0;
609
610  init_fail:
611         kfree(priv);
612         return -1;
613 }
614
615