patch-2_6_7-vs1_9_1_12
[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 *port, unsigned char c)
216 {
217         struct psmouse *parent = port->driver;
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) {
237                 if (child->state == PSMOUSE_ACTIVATED) {
238                         serio_interrupt(ptport, packet[1], 0, NULL);
239                         serio_interrupt(ptport, packet[4], 0, NULL);
240                         serio_interrupt(ptport, packet[5], 0, NULL);
241                         if (child->type >= PSMOUSE_GENPS)
242                                 serio_interrupt(ptport, packet[2], 0, NULL);
243                 } else if (child->state != PSMOUSE_IGNORE) {
244                         serio_interrupt(ptport, packet[1], 0, NULL);
245                 }
246         }
247 }
248
249 static void synaptics_pt_activate(struct psmouse *psmouse)
250 {
251         struct psmouse *child = psmouse->ptport->serio.private;
252
253         /* adjust the touchpad to child's choice of protocol */
254         if (child && child->type >= PSMOUSE_GENPS) {
255                 if (synaptics_set_mode(psmouse, SYN_BIT_FOUR_BYTE_CLIENT))
256                         printk(KERN_INFO "synaptics: failed to enable 4-byte guest protocol\n");
257         }
258 }
259
260 static void synaptics_pt_create(struct psmouse *psmouse)
261 {
262         struct psmouse_ptport *port;
263
264         psmouse->ptport = port = kmalloc(sizeof(struct psmouse_ptport), GFP_KERNEL);
265         if (!port) {
266                 printk(KERN_ERR "synaptics: not enough memory to allocate pass-through port\n");
267                 return;
268         }
269
270         memset(port, 0, sizeof(struct psmouse_ptport));
271
272         port->serio.type = SERIO_PS_PSTHRU;
273         port->serio.name = "Synaptics pass-through";
274         port->serio.phys = "synaptics-pt/serio0";
275         port->serio.write = synaptics_pt_write;
276         port->serio.driver = psmouse;
277
278         port->activate = synaptics_pt_activate;
279 }
280
281 /*****************************************************************************
282  *      Functions to interpret the absolute mode packets
283  ****************************************************************************/
284
285 static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data *priv, struct synaptics_hw_state *hw)
286 {
287         memset(hw, 0, sizeof(struct synaptics_hw_state));
288
289         if (SYN_MODEL_NEWABS(priv->model_id)) {
290                 hw->x = (((buf[3] & 0x10) << 8) |
291                          ((buf[1] & 0x0f) << 8) |
292                          buf[4]);
293                 hw->y = (((buf[3] & 0x20) << 7) |
294                          ((buf[1] & 0xf0) << 4) |
295                          buf[5]);
296
297                 hw->z = buf[2];
298                 hw->w = (((buf[0] & 0x30) >> 2) |
299                          ((buf[0] & 0x04) >> 1) |
300                          ((buf[3] & 0x04) >> 2));
301
302                 hw->left  = (buf[0] & 0x01) ? 1 : 0;
303                 hw->right = (buf[0] & 0x02) ? 1 : 0;
304
305                 if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
306                         hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
307
308                 if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
309                         hw->up   = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
310                         hw->down = ((buf[0] ^ buf[3]) & 0x02) ? 1 : 0;
311                 }
312
313                 if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) &&
314                     ((buf[0] ^ buf[3]) & 0x02)) {
315                         switch (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) & ~0x01) {
316                         default:
317                                 /*
318                                  * if nExtBtn is greater than 8 it should be
319                                  * considered invalid and treated as 0
320                                  */
321                                 break;
322                         case 8:
323                                 hw->ext_buttons |= ((buf[5] & 0x08)) ? 0x80 : 0;
324                                 hw->ext_buttons |= ((buf[4] & 0x08)) ? 0x40 : 0;
325                         case 6:
326                                 hw->ext_buttons |= ((buf[5] & 0x04)) ? 0x20 : 0;
327                                 hw->ext_buttons |= ((buf[4] & 0x04)) ? 0x10 : 0;
328                         case 4:
329                                 hw->ext_buttons |= ((buf[5] & 0x02)) ? 0x08 : 0;
330                                 hw->ext_buttons |= ((buf[4] & 0x02)) ? 0x04 : 0;
331                         case 2:
332                                 hw->ext_buttons |= ((buf[5] & 0x01)) ? 0x02 : 0;
333                                 hw->ext_buttons |= ((buf[4] & 0x01)) ? 0x01 : 0;
334                         }
335                 }
336         } else {
337                 hw->x = (((buf[1] & 0x1f) << 8) | buf[2]);
338                 hw->y = (((buf[4] & 0x1f) << 8) | buf[5]);
339
340                 hw->z = (((buf[0] & 0x30) << 2) | (buf[3] & 0x3F));
341                 hw->w = (((buf[1] & 0x80) >> 4) | ((buf[0] & 0x04) >> 1));
342
343                 hw->left  = (buf[0] & 0x01) ? 1 : 0;
344                 hw->right = (buf[0] & 0x02) ? 1 : 0;
345         }
346 }
347
348 /*
349  *  called for each full received packet from the touchpad
350  */
351 static void synaptics_process_packet(struct psmouse *psmouse)
352 {
353         struct input_dev *dev = &psmouse->dev;
354         struct synaptics_data *priv = psmouse->private;
355         struct synaptics_hw_state hw;
356         int num_fingers;
357         int finger_width;
358         int i;
359
360         synaptics_parse_hw_state(psmouse->packet, priv, &hw);
361
362         if (hw.z > 0) {
363                 num_fingers = 1;
364                 finger_width = 5;
365                 if (SYN_CAP_EXTENDED(priv->capabilities)) {
366                         switch (hw.w) {
367                         case 0 ... 1:
368                                 if (SYN_CAP_MULTIFINGER(priv->capabilities))
369                                         num_fingers = hw.w + 2;
370                                 break;
371                         case 2:
372                                 if (SYN_MODEL_PEN(priv->model_id))
373                                         ;   /* Nothing, treat a pen as a single finger */
374                                 break;
375                         case 4 ... 15:
376                                 if (SYN_CAP_PALMDETECT(priv->capabilities))
377                                         finger_width = hw.w;
378                                 break;
379                         }
380                 }
381         } else {
382                 num_fingers = 0;
383                 finger_width = 0;
384         }
385
386         /* Post events
387          * BTN_TOUCH has to be first as mousedev relies on it when doing
388          * absolute -> relative conversion
389          */
390         if (hw.z > 30) input_report_key(dev, BTN_TOUCH, 1);
391         if (hw.z < 25) input_report_key(dev, BTN_TOUCH, 0);
392
393         if (hw.z > 0) {
394                 input_report_abs(dev, ABS_X, hw.x);
395                 input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - hw.y);
396         }
397         input_report_abs(dev, ABS_PRESSURE, hw.z);
398
399         input_report_abs(dev, ABS_TOOL_WIDTH, finger_width);
400         input_report_key(dev, BTN_TOOL_FINGER, num_fingers == 1);
401         input_report_key(dev, BTN_TOOL_DOUBLETAP, num_fingers == 2);
402         input_report_key(dev, BTN_TOOL_TRIPLETAP, num_fingers == 3);
403
404         input_report_key(dev, BTN_LEFT, hw.left);
405         input_report_key(dev, BTN_RIGHT, hw.right);
406
407         if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
408                 input_report_key(dev, BTN_MIDDLE, hw.middle);
409
410         if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) {
411                 input_report_key(dev, BTN_FORWARD, hw.up);
412                 input_report_key(dev, BTN_BACK, hw.down);
413         }
414
415         for (i = 0; i < SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap); i++)
416                 input_report_key(dev, BTN_0 + i, hw.ext_buttons & (1 << i));
417
418         input_sync(dev);
419 }
420
421 static int synaptics_validate_byte(unsigned char packet[], int idx, unsigned char pkt_type)
422 {
423         static unsigned char newabs_mask[]      = { 0xC8, 0x00, 0x00, 0xC8, 0x00 };
424         static unsigned char newabs_rel_mask[]  = { 0xC0, 0x00, 0x00, 0xC0, 0x00 };
425         static unsigned char newabs_rslt[]      = { 0x80, 0x00, 0x00, 0xC0, 0x00 };
426         static unsigned char oldabs_mask[]      = { 0xC0, 0x60, 0x00, 0xC0, 0x60 };
427         static unsigned char oldabs_rslt[]      = { 0xC0, 0x00, 0x00, 0x80, 0x00 };
428
429         if (idx < 0 || idx > 4)
430                 return 0;
431
432         switch (pkt_type) {
433                 case SYN_NEWABS:
434                 case SYN_NEWABS_RELAXED:
435                         return (packet[idx] & newabs_rel_mask[idx]) == newabs_rslt[idx];
436
437                 case SYN_NEWABS_STRICT:
438                         return (packet[idx] & newabs_mask[idx]) == newabs_rslt[idx];
439
440                 case SYN_OLDABS:
441                         return (packet[idx] & oldabs_mask[idx]) == oldabs_rslt[idx];
442
443                 default:
444                         printk(KERN_ERR "synaptics: unknown packet type %d\n", pkt_type);
445                         return 0;
446         }
447 }
448
449 static unsigned char synaptics_detect_pkt_type(struct psmouse *psmouse)
450 {
451         int i;
452
453         for (i = 0; i < 5; i++)
454                 if (!synaptics_validate_byte(psmouse->packet, i, SYN_NEWABS_STRICT)) {
455                         printk(KERN_INFO "synaptics: using relaxed packet validation\n");
456                         return SYN_NEWABS_RELAXED;
457                 }
458
459         return SYN_NEWABS_STRICT;
460 }
461
462 static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
463 {
464         struct input_dev *dev = &psmouse->dev;
465         struct synaptics_data *priv = psmouse->private;
466
467         input_regs(dev, regs);
468
469         if (psmouse->pktcnt >= 6) { /* Full packet received */
470                 if (unlikely(priv->pkt_type == SYN_NEWABS))
471                         priv->pkt_type = synaptics_detect_pkt_type(psmouse);
472
473                 if (psmouse->ptport && psmouse->ptport->serio.dev && synaptics_is_pt_packet(psmouse->packet))
474                         synaptics_pass_pt_packet(&psmouse->ptport->serio, 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