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