2 * Synaptics TouchPad PS/2 mouse driver
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.
8 * 2003 Peter Osterlund <petero2@telia.com>
9 * Ported to 2.5 input device infrastructure.
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)
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)
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.
23 * Trademarks are the property of their respective owners.
26 #include <linux/module.h>
27 #include <linux/delay.h>
28 #include <linux/dmi.h>
29 #include <linux/input/mt.h>
30 #include <linux/serio.h>
31 #include <linux/libps2.h>
32 #include <linux/slab.h>
34 #include "synaptics.h"
37 * The x/y limits are taken from the Synaptics TouchPad interfacing Guide,
38 * section 2.3.2, which says that they should be valid regardless of the
39 * actual size of the sensor.
40 * Note that newer firmware allows querying device for maximum useable
47 #define XMIN_NOMINAL 1472
48 #define XMAX_NOMINAL 5472
49 #define YMIN_NOMINAL 1408
50 #define YMAX_NOMINAL 4448
52 /* Size in bits of absolute position values reported by the hardware */
53 #define ABS_POS_BITS 13
56 * These values should represent the absolute maximum value that will
57 * be reported for a positive position value. Some Synaptics firmware
58 * uses this value to indicate a finger near the edge of the touchpad
59 * whose precise position cannot be determined.
61 * At least one touchpad is known to report positions in excess of this
62 * value which are actually negative values truncated to the 13-bit
63 * reporting range. These values have never been observed to be lower
64 * than 8184 (i.e. -8), so we treat all values greater than 8176 as
65 * negative and any other value as positive.
67 #define X_MAX_POSITIVE 8176
68 #define Y_MAX_POSITIVE 8176
70 /* maximum ABS_MT_POSITION displacement (in mm) */
73 /*****************************************************************************
74 * Stuff we need even when we do not want native Synaptics support
75 ****************************************************************************/
78 * Set the synaptics touchpad mode byte by special commands
80 static int synaptics_mode_cmd(struct psmouse
*psmouse
, unsigned char mode
)
82 unsigned char param
[1];
84 if (psmouse_sliced_command(psmouse
, mode
))
86 param
[0] = SYN_PS_SET_MODE2
;
87 if (ps2_command(&psmouse
->ps2dev
, param
, PSMOUSE_CMD_SETRATE
))
92 int synaptics_detect(struct psmouse
*psmouse
, bool set_properties
)
94 struct ps2dev
*ps2dev
= &psmouse
->ps2dev
;
95 unsigned char param
[4];
99 ps2_command(ps2dev
, param
, PSMOUSE_CMD_SETRES
);
100 ps2_command(ps2dev
, param
, PSMOUSE_CMD_SETRES
);
101 ps2_command(ps2dev
, param
, PSMOUSE_CMD_SETRES
);
102 ps2_command(ps2dev
, param
, PSMOUSE_CMD_SETRES
);
103 ps2_command(ps2dev
, param
, PSMOUSE_CMD_GETINFO
);
105 if (param
[1] != 0x47)
108 if (set_properties
) {
109 psmouse
->vendor
= "Synaptics";
110 psmouse
->name
= "TouchPad";
116 void synaptics_reset(struct psmouse
*psmouse
)
118 /* reset touchpad back to relative mode, gestures enabled */
119 synaptics_mode_cmd(psmouse
, 0);
122 #ifdef CONFIG_MOUSE_PS2_SYNAPTICS
124 static bool cr48_profile_sensor
;
126 #define ANY_BOARD_ID 0
127 struct min_max_quirk
{
128 const char * const *pnp_ids
;
130 unsigned long int min
, max
;
132 int x_min
, x_max
, y_min
, y_max
;
135 static const struct min_max_quirk min_max_pnpid_table
[] = {
137 (const char * const []){"LEN0033", NULL
},
138 {ANY_BOARD_ID
, ANY_BOARD_ID
},
139 1024, 5052, 2258, 4832
142 (const char * const []){"LEN0042", NULL
},
143 {ANY_BOARD_ID
, ANY_BOARD_ID
},
144 1232, 5710, 1156, 4696
147 (const char * const []){"LEN0034", "LEN0036", "LEN0037",
148 "LEN0039", "LEN2002", "LEN2004",
150 {ANY_BOARD_ID
, 2961},
151 1024, 5112, 2024, 4832
154 (const char * const []){"LEN2001", NULL
},
155 {ANY_BOARD_ID
, ANY_BOARD_ID
},
156 1024, 5022, 2508, 4832
159 (const char * const []){"LEN2006", NULL
},
161 1024, 5045, 2457, 4832
164 (const char * const []){"LEN2006", NULL
},
165 {ANY_BOARD_ID
, ANY_BOARD_ID
},
166 1264, 5675, 1171, 4688
171 /* This list has been kindly provided by Synaptics. */
172 static const char * const topbuttonpad_pnp_ids
[] = {
182 "LEN0033", /* Helix */
183 "LEN0034", /* T431s, L440, L540, T540, W540, X1 Carbon 2nd */
184 "LEN0035", /* X240 */
185 "LEN0036", /* T440 */
186 "LEN0037", /* X1 Carbon 2nd */
188 "LEN0039", /* T440s */
190 "LEN0042", /* Yoga */
195 "LEN2001", /* Edge E431 */
196 "LEN2002", /* Edge E531 */
198 "LEN2004", /* L440 */
200 "LEN2006", /* Edge E440/E540 */
209 /* This list has been kindly provided by Synaptics. */
210 static const char * const forcepad_pnp_ids
[] = {
216 /*****************************************************************************
217 * Synaptics communications functions
218 ****************************************************************************/
221 * Synaptics touchpads report the y coordinate from bottom to top, which is
222 * opposite from what userspace expects.
223 * This function is used to invert y before reporting.
225 static int synaptics_invert_y(int y
)
227 return YMAX_NOMINAL
+ YMIN_NOMINAL
- y
;
231 * Send a command to the synpatics touchpad by special commands
233 static int synaptics_send_cmd(struct psmouse
*psmouse
, unsigned char c
, unsigned char *param
)
235 if (psmouse_sliced_command(psmouse
, c
))
237 if (ps2_command(&psmouse
->ps2dev
, param
, PSMOUSE_CMD_GETINFO
))
243 * Read the model-id bytes from the touchpad
244 * see also SYN_MODEL_* macros
246 static int synaptics_model_id(struct psmouse
*psmouse
)
248 struct synaptics_data
*priv
= psmouse
->private;
251 if (synaptics_send_cmd(psmouse
, SYN_QUE_MODEL
, mi
))
253 priv
->model_id
= (mi
[0]<<16) | (mi
[1]<<8) | mi
[2];
257 static int synaptics_more_extended_queries(struct psmouse
*psmouse
)
259 struct synaptics_data
*priv
= psmouse
->private;
260 unsigned char buf
[3];
262 if (synaptics_send_cmd(psmouse
, SYN_QUE_MEXT_CAPAB_10
, buf
))
265 priv
->ext_cap_10
= (buf
[0]<<16) | (buf
[1]<<8) | buf
[2];
271 * Read the board id and the "More Extended Queries" from the touchpad
272 * The board id is encoded in the "QUERY MODES" response
274 static int synaptics_query_modes(struct psmouse
*psmouse
)
276 struct synaptics_data
*priv
= psmouse
->private;
277 unsigned char bid
[3];
279 /* firmwares prior 7.5 have no board_id encoded */
280 if (SYN_ID_FULL(priv
->identity
) < 0x705)
283 if (synaptics_send_cmd(psmouse
, SYN_QUE_MODES
, bid
))
285 priv
->board_id
= ((bid
[0] & 0xfc) << 6) | bid
[1];
287 if (SYN_MEXT_CAP_BIT(bid
[0]))
288 return synaptics_more_extended_queries(psmouse
);
294 * Read the firmware id from the touchpad
296 static int synaptics_firmware_id(struct psmouse
*psmouse
)
298 struct synaptics_data
*priv
= psmouse
->private;
299 unsigned char fwid
[3];
301 if (synaptics_send_cmd(psmouse
, SYN_QUE_FIRMWARE_ID
, fwid
))
303 priv
->firmware_id
= (fwid
[0] << 16) | (fwid
[1] << 8) | fwid
[2];
308 * Read the capability-bits from the touchpad
309 * see also the SYN_CAP_* macros
311 static int synaptics_capability(struct psmouse
*psmouse
)
313 struct synaptics_data
*priv
= psmouse
->private;
314 unsigned char cap
[3];
316 if (synaptics_send_cmd(psmouse
, SYN_QUE_CAPABILITIES
, cap
))
318 priv
->capabilities
= (cap
[0] << 16) | (cap
[1] << 8) | cap
[2];
319 priv
->ext_cap
= priv
->ext_cap_0c
= 0;
322 * Older firmwares had submodel ID fixed to 0x47
324 if (SYN_ID_FULL(priv
->identity
) < 0x705 &&
325 SYN_CAP_SUBMODEL_ID(priv
->capabilities
) != 0x47) {
330 * Unless capExtended is set the rest of the flags should be ignored
332 if (!SYN_CAP_EXTENDED(priv
->capabilities
))
333 priv
->capabilities
= 0;
335 if (SYN_EXT_CAP_REQUESTS(priv
->capabilities
) >= 1) {
336 if (synaptics_send_cmd(psmouse
, SYN_QUE_EXT_CAPAB
, cap
)) {
337 psmouse_warn(psmouse
,
338 "device claims to have extended capabilities, but I'm not able to read them.\n");
340 priv
->ext_cap
= (cap
[0] << 16) | (cap
[1] << 8) | cap
[2];
343 * if nExtBtn is greater than 8 it should be considered
344 * invalid and treated as 0
346 if (SYN_CAP_MULTI_BUTTON_NO(priv
->ext_cap
) > 8)
347 priv
->ext_cap
&= 0xff0fff;
351 if (SYN_EXT_CAP_REQUESTS(priv
->capabilities
) >= 4) {
352 if (synaptics_send_cmd(psmouse
, SYN_QUE_EXT_CAPAB_0C
, cap
)) {
353 psmouse_warn(psmouse
,
354 "device claims to have extended capability 0x0c, but I'm not able to read it.\n");
356 priv
->ext_cap_0c
= (cap
[0] << 16) | (cap
[1] << 8) | cap
[2];
365 * See also the SYN_ID_* macros
367 static int synaptics_identify(struct psmouse
*psmouse
)
369 struct synaptics_data
*priv
= psmouse
->private;
372 if (synaptics_send_cmd(psmouse
, SYN_QUE_IDENTIFY
, id
))
374 priv
->identity
= (id
[0]<<16) | (id
[1]<<8) | id
[2];
375 if (SYN_ID_IS_SYNAPTICS(priv
->identity
))
381 * Read touchpad resolution and maximum reported coordinates
382 * Resolution is left zero if touchpad does not support the query
385 static int synaptics_resolution(struct psmouse
*psmouse
)
387 struct synaptics_data
*priv
= psmouse
->private;
388 unsigned char resp
[3];
390 if (SYN_ID_MAJOR(priv
->identity
) < 4)
393 if (synaptics_send_cmd(psmouse
, SYN_QUE_RESOLUTION
, resp
) == 0) {
394 if (resp
[0] != 0 && (resp
[1] & 0x80) && resp
[2] != 0) {
395 priv
->x_res
= resp
[0]; /* x resolution in units/mm */
396 priv
->y_res
= resp
[2]; /* y resolution in units/mm */
400 if (SYN_EXT_CAP_REQUESTS(priv
->capabilities
) >= 5 &&
401 SYN_CAP_MAX_DIMENSIONS(priv
->ext_cap_0c
)) {
402 if (synaptics_send_cmd(psmouse
, SYN_QUE_EXT_MAX_COORDS
, resp
)) {
403 psmouse_warn(psmouse
,
404 "device claims to have max coordinates query, but I'm not able to read it.\n");
406 priv
->x_max
= (resp
[0] << 5) | ((resp
[1] & 0x0f) << 1);
407 priv
->y_max
= (resp
[2] << 5) | ((resp
[1] & 0xf0) >> 3);
408 psmouse_info(psmouse
,
409 "queried max coordinates: x [..%d], y [..%d]\n",
410 priv
->x_max
, priv
->y_max
);
414 if (SYN_CAP_MIN_DIMENSIONS(priv
->ext_cap_0c
) &&
415 (SYN_EXT_CAP_REQUESTS(priv
->capabilities
) >= 7 ||
417 * Firmware v8.1 does not report proper number of extended
418 * capabilities, but has been proven to report correct min
421 SYN_ID_FULL(priv
->identity
) == 0x801)) {
422 if (synaptics_send_cmd(psmouse
, SYN_QUE_EXT_MIN_COORDS
, resp
)) {
423 psmouse_warn(psmouse
,
424 "device claims to have min coordinates query, but I'm not able to read it.\n");
426 priv
->x_min
= (resp
[0] << 5) | ((resp
[1] & 0x0f) << 1);
427 priv
->y_min
= (resp
[2] << 5) | ((resp
[1] & 0xf0) >> 3);
428 psmouse_info(psmouse
,
429 "queried min coordinates: x [%d..], y [%d..]\n",
430 priv
->x_min
, priv
->y_min
);
438 * Apply quirk(s) if the hardware matches
441 static void synaptics_apply_quirks(struct psmouse
*psmouse
)
443 struct synaptics_data
*priv
= psmouse
->private;
446 for (i
= 0; min_max_pnpid_table
[i
].pnp_ids
; i
++) {
447 if (!psmouse_matches_pnp_id(psmouse
,
448 min_max_pnpid_table
[i
].pnp_ids
))
451 if (min_max_pnpid_table
[i
].board_id
.min
!= ANY_BOARD_ID
&&
452 priv
->board_id
< min_max_pnpid_table
[i
].board_id
.min
)
455 if (min_max_pnpid_table
[i
].board_id
.max
!= ANY_BOARD_ID
&&
456 priv
->board_id
> min_max_pnpid_table
[i
].board_id
.max
)
459 priv
->x_min
= min_max_pnpid_table
[i
].x_min
;
460 priv
->x_max
= min_max_pnpid_table
[i
].x_max
;
461 priv
->y_min
= min_max_pnpid_table
[i
].y_min
;
462 priv
->y_max
= min_max_pnpid_table
[i
].y_max
;
463 psmouse_info(psmouse
,
464 "quirked min/max coordinates: x [%d..%d], y [%d..%d]\n",
465 priv
->x_min
, priv
->x_max
,
466 priv
->y_min
, priv
->y_max
);
471 static int synaptics_query_hardware(struct psmouse
*psmouse
)
473 if (synaptics_identify(psmouse
))
475 if (synaptics_model_id(psmouse
))
477 if (synaptics_firmware_id(psmouse
))
479 if (synaptics_query_modes(psmouse
))
481 if (synaptics_capability(psmouse
))
483 if (synaptics_resolution(psmouse
))
486 synaptics_apply_quirks(psmouse
);
491 static int synaptics_set_advanced_gesture_mode(struct psmouse
*psmouse
)
493 static unsigned char param
= 0xc8;
494 struct synaptics_data
*priv
= psmouse
->private;
496 if (!(SYN_CAP_ADV_GESTURE(priv
->ext_cap_0c
) ||
497 SYN_CAP_IMAGE_SENSOR(priv
->ext_cap_0c
)))
500 if (psmouse_sliced_command(psmouse
, SYN_QUE_MODEL
))
503 if (ps2_command(&psmouse
->ps2dev
, ¶m
, PSMOUSE_CMD_SETRATE
))
506 /* Advanced gesture mode also sends multi finger data */
507 priv
->capabilities
|= BIT(1);
512 static int synaptics_set_mode(struct psmouse
*psmouse
)
514 struct synaptics_data
*priv
= psmouse
->private;
517 if (priv
->absolute_mode
)
518 priv
->mode
|= SYN_BIT_ABSOLUTE_MODE
;
519 if (priv
->disable_gesture
)
520 priv
->mode
|= SYN_BIT_DISABLE_GESTURE
;
521 if (psmouse
->rate
>= 80)
522 priv
->mode
|= SYN_BIT_HIGH_RATE
;
523 if (SYN_CAP_EXTENDED(priv
->capabilities
))
524 priv
->mode
|= SYN_BIT_W_MODE
;
526 if (synaptics_mode_cmd(psmouse
, priv
->mode
))
529 if (priv
->absolute_mode
&&
530 synaptics_set_advanced_gesture_mode(psmouse
)) {
531 psmouse_err(psmouse
, "Advanced gesture mode init failed.\n");
538 static void synaptics_set_rate(struct psmouse
*psmouse
, unsigned int rate
)
540 struct synaptics_data
*priv
= psmouse
->private;
543 priv
->mode
|= SYN_BIT_HIGH_RATE
;
546 priv
->mode
&= ~SYN_BIT_HIGH_RATE
;
550 synaptics_mode_cmd(psmouse
, priv
->mode
);
553 /*****************************************************************************
554 * Synaptics pass-through PS/2 port support
555 ****************************************************************************/
556 static int synaptics_pt_write(struct serio
*serio
, unsigned char c
)
558 struct psmouse
*parent
= serio_get_drvdata(serio
->parent
);
559 char rate_param
= SYN_PS_CLIENT_CMD
; /* indicates that we want pass-through port */
561 if (psmouse_sliced_command(parent
, c
))
563 if (ps2_command(&parent
->ps2dev
, &rate_param
, PSMOUSE_CMD_SETRATE
))
568 static int synaptics_pt_start(struct serio
*serio
)
570 struct psmouse
*parent
= serio_get_drvdata(serio
->parent
);
571 struct synaptics_data
*priv
= parent
->private;
573 serio_pause_rx(parent
->ps2dev
.serio
);
574 priv
->pt_port
= serio
;
575 serio_continue_rx(parent
->ps2dev
.serio
);
580 static void synaptics_pt_stop(struct serio
*serio
)
582 struct psmouse
*parent
= serio_get_drvdata(serio
->parent
);
583 struct synaptics_data
*priv
= parent
->private;
585 serio_pause_rx(parent
->ps2dev
.serio
);
586 priv
->pt_port
= NULL
;
587 serio_continue_rx(parent
->ps2dev
.serio
);
590 static int synaptics_is_pt_packet(unsigned char *buf
)
592 return (buf
[0] & 0xFC) == 0x84 && (buf
[3] & 0xCC) == 0xC4;
595 static void synaptics_pass_pt_packet(struct psmouse
*psmouse
,
596 struct serio
*ptport
,
597 unsigned char *packet
)
599 struct synaptics_data
*priv
= psmouse
->private;
600 struct psmouse
*child
= serio_get_drvdata(ptport
);
602 if (child
&& child
->state
== PSMOUSE_ACTIVATED
) {
603 serio_interrupt(ptport
, packet
[1] | priv
->pt_buttons
, 0);
604 serio_interrupt(ptport
, packet
[4], 0);
605 serio_interrupt(ptport
, packet
[5], 0);
606 if (child
->pktsize
== 4)
607 serio_interrupt(ptport
, packet
[2], 0);
609 serio_interrupt(ptport
, packet
[1], 0);
613 static void synaptics_pt_activate(struct psmouse
*psmouse
)
615 struct synaptics_data
*priv
= psmouse
->private;
616 struct psmouse
*child
= serio_get_drvdata(priv
->pt_port
);
618 /* adjust the touchpad to child's choice of protocol */
620 if (child
->pktsize
== 4)
621 priv
->mode
|= SYN_BIT_FOUR_BYTE_CLIENT
;
623 priv
->mode
&= ~SYN_BIT_FOUR_BYTE_CLIENT
;
625 if (synaptics_mode_cmd(psmouse
, priv
->mode
))
626 psmouse_warn(psmouse
,
627 "failed to switch guest protocol\n");
631 static void synaptics_pt_create(struct psmouse
*psmouse
)
635 serio
= kzalloc(sizeof(struct serio
), GFP_KERNEL
);
638 "not enough memory for pass-through port\n");
642 serio
->id
.type
= SERIO_PS_PSTHRU
;
643 strlcpy(serio
->name
, "Synaptics pass-through", sizeof(serio
->name
));
644 strlcpy(serio
->phys
, "synaptics-pt/serio0", sizeof(serio
->name
));
645 serio
->write
= synaptics_pt_write
;
646 serio
->start
= synaptics_pt_start
;
647 serio
->stop
= synaptics_pt_stop
;
648 serio
->parent
= psmouse
->ps2dev
.serio
;
650 psmouse
->pt_activate
= synaptics_pt_activate
;
652 psmouse_info(psmouse
, "serio: %s port at %s\n",
653 serio
->name
, psmouse
->phys
);
654 serio_register_port(serio
);
657 /*****************************************************************************
658 * Functions to interpret the absolute mode packets
659 ****************************************************************************/
661 static void synaptics_parse_agm(const unsigned char buf
[],
662 struct synaptics_data
*priv
,
663 struct synaptics_hw_state
*hw
)
665 struct synaptics_hw_state
*agm
= &priv
->agm
;
668 agm_packet_type
= (buf
[5] & 0x30) >> 4;
669 switch (agm_packet_type
) {
671 /* Gesture packet: (x, y, z) half resolution */
673 agm
->x
= (((buf
[4] & 0x0f) << 8) | buf
[1]) << 1;
674 agm
->y
= (((buf
[4] & 0xf0) << 4) | buf
[2]) << 1;
675 agm
->z
= ((buf
[3] & 0x30) | (buf
[5] & 0x0f)) << 1;
679 /* AGM-CONTACT packet: we are only interested in the count */
680 priv
->agm_count
= buf
[1];
688 static void synaptics_parse_ext_buttons(const unsigned char buf
[],
689 struct synaptics_data
*priv
,
690 struct synaptics_hw_state
*hw
)
692 unsigned int ext_bits
=
693 (SYN_CAP_MULTI_BUTTON_NO(priv
->ext_cap
) + 1) >> 1;
694 unsigned int ext_mask
= GENMASK(ext_bits
- 1, 0);
696 hw
->ext_buttons
= buf
[4] & ext_mask
;
697 hw
->ext_buttons
|= (buf
[5] & ext_mask
) << ext_bits
;
700 static int synaptics_parse_hw_state(const unsigned char buf
[],
701 struct synaptics_data
*priv
,
702 struct synaptics_hw_state
*hw
)
704 memset(hw
, 0, sizeof(struct synaptics_hw_state
));
706 if (SYN_MODEL_NEWABS(priv
->model_id
)) {
707 hw
->w
= (((buf
[0] & 0x30) >> 2) |
708 ((buf
[0] & 0x04) >> 1) |
709 ((buf
[3] & 0x04) >> 2));
711 if ((SYN_CAP_ADV_GESTURE(priv
->ext_cap_0c
) ||
712 SYN_CAP_IMAGE_SENSOR(priv
->ext_cap_0c
)) &&
714 synaptics_parse_agm(buf
, priv
, hw
);
718 hw
->x
= (((buf
[3] & 0x10) << 8) |
719 ((buf
[1] & 0x0f) << 8) |
721 hw
->y
= (((buf
[3] & 0x20) << 7) |
722 ((buf
[1] & 0xf0) << 4) |
726 hw
->left
= (buf
[0] & 0x01) ? 1 : 0;
727 hw
->right
= (buf
[0] & 0x02) ? 1 : 0;
729 if (priv
->is_forcepad
) {
731 * ForcePads, like Clickpads, use middle button
732 * bits to report primary button clicks.
733 * Unfortunately they report primary button not
734 * only when user presses on the pad above certain
735 * threshold, but also when there are more than one
736 * finger on the touchpad, which interferes with
737 * out multi-finger gestures.
741 priv
->press
= priv
->report_press
= false;
742 } else if (hw
->w
>= 4 && ((buf
[0] ^ buf
[3]) & 0x01)) {
744 * Single-finger touch with pressure above
745 * the threshold. If pressure stays long
746 * enough, we'll start reporting primary
747 * button. We rely on the device continuing
748 * sending data even if finger does not
752 priv
->press_start
= jiffies
;
754 } else if (time_after(jiffies
,
756 msecs_to_jiffies(50))) {
757 priv
->report_press
= true;
763 hw
->left
= priv
->report_press
;
765 } else if (SYN_CAP_CLICKPAD(priv
->ext_cap_0c
)) {
767 * Clickpad's button is transmitted as middle button,
768 * however, since it is primary button, we will report
771 hw
->left
= ((buf
[0] ^ buf
[3]) & 0x01) ? 1 : 0;
773 } else if (SYN_CAP_MIDDLE_BUTTON(priv
->capabilities
)) {
774 hw
->middle
= ((buf
[0] ^ buf
[3]) & 0x01) ? 1 : 0;
776 hw
->scroll
= (signed char)(buf
[1]);
779 if (SYN_CAP_FOUR_BUTTON(priv
->capabilities
)) {
780 hw
->up
= ((buf
[0] ^ buf
[3]) & 0x01) ? 1 : 0;
781 hw
->down
= ((buf
[0] ^ buf
[3]) & 0x02) ? 1 : 0;
784 if (SYN_CAP_MULTI_BUTTON_NO(priv
->ext_cap
) > 0 &&
785 ((buf
[0] ^ buf
[3]) & 0x02)) {
786 synaptics_parse_ext_buttons(buf
, priv
, hw
);
789 hw
->x
= (((buf
[1] & 0x1f) << 8) | buf
[2]);
790 hw
->y
= (((buf
[4] & 0x1f) << 8) | buf
[5]);
792 hw
->z
= (((buf
[0] & 0x30) << 2) | (buf
[3] & 0x3F));
793 hw
->w
= (((buf
[1] & 0x80) >> 4) | ((buf
[0] & 0x04) >> 1));
795 hw
->left
= (buf
[0] & 0x01) ? 1 : 0;
796 hw
->right
= (buf
[0] & 0x02) ? 1 : 0;
800 * Convert wrap-around values to negative. (X|Y)_MAX_POSITIVE
801 * is used by some firmware to indicate a finger at the edge of
802 * the touchpad whose precise position cannot be determined, so
803 * convert these values to the maximum axis value.
805 if (hw
->x
> X_MAX_POSITIVE
)
806 hw
->x
-= 1 << ABS_POS_BITS
;
807 else if (hw
->x
== X_MAX_POSITIVE
)
810 if (hw
->y
> Y_MAX_POSITIVE
)
811 hw
->y
-= 1 << ABS_POS_BITS
;
812 else if (hw
->y
== Y_MAX_POSITIVE
)
818 static void synaptics_report_semi_mt_slot(struct input_dev
*dev
, int slot
,
819 bool active
, int x
, int y
)
821 input_mt_slot(dev
, slot
);
822 input_mt_report_slot_state(dev
, MT_TOOL_FINGER
, active
);
824 input_report_abs(dev
, ABS_MT_POSITION_X
, x
);
825 input_report_abs(dev
, ABS_MT_POSITION_Y
, synaptics_invert_y(y
));
829 static void synaptics_report_semi_mt_data(struct input_dev
*dev
,
830 const struct synaptics_hw_state
*a
,
831 const struct synaptics_hw_state
*b
,
834 if (num_fingers
>= 2) {
835 synaptics_report_semi_mt_slot(dev
, 0, true, min(a
->x
, b
->x
),
837 synaptics_report_semi_mt_slot(dev
, 1, true, max(a
->x
, b
->x
),
839 } else if (num_fingers
== 1) {
840 synaptics_report_semi_mt_slot(dev
, 0, true, a
->x
, a
->y
);
841 synaptics_report_semi_mt_slot(dev
, 1, false, 0, 0);
843 synaptics_report_semi_mt_slot(dev
, 0, false, 0, 0);
844 synaptics_report_semi_mt_slot(dev
, 1, false, 0, 0);
848 static void synaptics_report_ext_buttons(struct psmouse
*psmouse
,
849 const struct synaptics_hw_state
*hw
)
851 struct input_dev
*dev
= psmouse
->dev
;
852 struct synaptics_data
*priv
= psmouse
->private;
853 int ext_bits
= (SYN_CAP_MULTI_BUTTON_NO(priv
->ext_cap
) + 1) >> 1;
854 char buf
[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
857 if (!SYN_CAP_MULTI_BUTTON_NO(priv
->ext_cap
))
860 /* Bug in FW 8.1, buttons are reported only when ExtBit is 1 */
861 if (SYN_ID_FULL(priv
->identity
) == 0x801 &&
862 !((psmouse
->packet
[0] ^ psmouse
->packet
[3]) & 0x02))
865 if (!SYN_CAP_EXT_BUTTONS_STICK(priv
->ext_cap_10
)) {
866 for (i
= 0; i
< ext_bits
; i
++) {
867 input_report_key(dev
, BTN_0
+ 2 * i
,
868 hw
->ext_buttons
& (1 << i
));
869 input_report_key(dev
, BTN_1
+ 2 * i
,
870 hw
->ext_buttons
& (1 << (i
+ ext_bits
)));
876 * This generation of touchpads has the trackstick buttons
877 * physically wired to the touchpad. Re-route them through
878 * the pass-through interface.
883 /* The trackstick expects at most 3 buttons */
884 priv
->pt_buttons
= SYN_CAP_EXT_BUTTON_STICK_L(hw
->ext_buttons
) |
885 SYN_CAP_EXT_BUTTON_STICK_R(hw
->ext_buttons
) << 1 |
886 SYN_CAP_EXT_BUTTON_STICK_M(hw
->ext_buttons
) << 2;
888 synaptics_pass_pt_packet(psmouse
, priv
->pt_port
, buf
);
891 static void synaptics_report_buttons(struct psmouse
*psmouse
,
892 const struct synaptics_hw_state
*hw
)
894 struct input_dev
*dev
= psmouse
->dev
;
895 struct synaptics_data
*priv
= psmouse
->private;
897 input_report_key(dev
, BTN_LEFT
, hw
->left
);
898 input_report_key(dev
, BTN_RIGHT
, hw
->right
);
900 if (SYN_CAP_MIDDLE_BUTTON(priv
->capabilities
))
901 input_report_key(dev
, BTN_MIDDLE
, hw
->middle
);
903 if (SYN_CAP_FOUR_BUTTON(priv
->capabilities
)) {
904 input_report_key(dev
, BTN_FORWARD
, hw
->up
);
905 input_report_key(dev
, BTN_BACK
, hw
->down
);
908 synaptics_report_ext_buttons(psmouse
, hw
);
911 static void synaptics_report_mt_data(struct psmouse
*psmouse
,
912 const struct synaptics_hw_state
*sgm
,
915 struct input_dev
*dev
= psmouse
->dev
;
916 struct synaptics_data
*priv
= psmouse
->private;
917 const struct synaptics_hw_state
*hw
[2] = { sgm
, &priv
->agm
};
918 struct input_mt_pos pos
[2];
919 int slot
[2], nsemi
, i
;
921 nsemi
= clamp_val(num_fingers
, 0, 2);
923 for (i
= 0; i
< nsemi
; i
++) {
925 pos
[i
].y
= synaptics_invert_y(hw
[i
]->y
);
928 input_mt_assign_slots(dev
, slot
, pos
, nsemi
, DMAX
* priv
->x_res
);
930 for (i
= 0; i
< nsemi
; i
++) {
931 input_mt_slot(dev
, slot
[i
]);
932 input_mt_report_slot_state(dev
, MT_TOOL_FINGER
, true);
933 input_report_abs(dev
, ABS_MT_POSITION_X
, pos
[i
].x
);
934 input_report_abs(dev
, ABS_MT_POSITION_Y
, pos
[i
].y
);
935 input_report_abs(dev
, ABS_MT_PRESSURE
, hw
[i
]->z
);
938 input_mt_drop_unused(dev
);
940 /* Don't use active slot count to generate BTN_TOOL events. */
941 input_mt_report_pointer_emulation(dev
, false);
943 /* Send the number of fingers reported by touchpad itself. */
944 input_mt_report_finger_count(dev
, num_fingers
);
946 synaptics_report_buttons(psmouse
, sgm
);
951 static void synaptics_image_sensor_process(struct psmouse
*psmouse
,
952 struct synaptics_hw_state
*sgm
)
954 struct synaptics_data
*priv
= psmouse
->private;
958 * Update mt_state using the new finger count and current mt_state.
962 else if (sgm
->w
>= 4)
964 else if (sgm
->w
== 0)
966 else if (sgm
->w
== 1)
967 num_fingers
= priv
->agm_count
? priv
->agm_count
: 3;
971 /* Send resulting input events to user space */
972 synaptics_report_mt_data(psmouse
, sgm
, num_fingers
);
976 * called for each full received packet from the touchpad
978 static void synaptics_process_packet(struct psmouse
*psmouse
)
980 struct input_dev
*dev
= psmouse
->dev
;
981 struct synaptics_data
*priv
= psmouse
->private;
982 struct synaptics_hw_state hw
;
986 if (synaptics_parse_hw_state(psmouse
->packet
, priv
, &hw
))
989 if (SYN_CAP_IMAGE_SENSOR(priv
->ext_cap_0c
)) {
990 synaptics_image_sensor_process(psmouse
, &hw
);
995 priv
->scroll
+= hw
.scroll
;
997 while (priv
->scroll
>= 4) {
998 input_report_key(dev
, BTN_BACK
, !hw
.down
);
1000 input_report_key(dev
, BTN_BACK
, hw
.down
);
1004 while (priv
->scroll
<= -4) {
1005 input_report_key(dev
, BTN_FORWARD
, !hw
.up
);
1007 input_report_key(dev
, BTN_FORWARD
, hw
.up
);
1014 if (hw
.z
> 0 && hw
.x
> 1) {
1017 if (SYN_CAP_EXTENDED(priv
->capabilities
)) {
1020 if (SYN_CAP_MULTIFINGER(priv
->capabilities
))
1021 num_fingers
= hw
.w
+ 2;
1024 if (SYN_MODEL_PEN(priv
->model_id
))
1025 ; /* Nothing, treat a pen as a single finger */
1028 if (SYN_CAP_PALMDETECT(priv
->capabilities
))
1029 finger_width
= hw
.w
;
1038 if (cr48_profile_sensor
) {
1039 synaptics_report_mt_data(psmouse
, &hw
, num_fingers
);
1043 if (SYN_CAP_ADV_GESTURE(priv
->ext_cap_0c
))
1044 synaptics_report_semi_mt_data(dev
, &hw
, &priv
->agm
,
1048 * BTN_TOUCH has to be first as mousedev relies on it when doing
1049 * absolute -> relative conversion
1051 if (hw
.z
> 30) input_report_key(dev
, BTN_TOUCH
, 1);
1052 if (hw
.z
< 25) input_report_key(dev
, BTN_TOUCH
, 0);
1054 if (num_fingers
> 0) {
1055 input_report_abs(dev
, ABS_X
, hw
.x
);
1056 input_report_abs(dev
, ABS_Y
, synaptics_invert_y(hw
.y
));
1058 input_report_abs(dev
, ABS_PRESSURE
, hw
.z
);
1060 if (SYN_CAP_PALMDETECT(priv
->capabilities
))
1061 input_report_abs(dev
, ABS_TOOL_WIDTH
, finger_width
);
1063 input_report_key(dev
, BTN_TOOL_FINGER
, num_fingers
== 1);
1064 if (SYN_CAP_MULTIFINGER(priv
->capabilities
)) {
1065 input_report_key(dev
, BTN_TOOL_DOUBLETAP
, num_fingers
== 2);
1066 input_report_key(dev
, BTN_TOOL_TRIPLETAP
, num_fingers
== 3);
1069 synaptics_report_buttons(psmouse
, &hw
);
1074 static int synaptics_validate_byte(struct psmouse
*psmouse
,
1075 int idx
, unsigned char pkt_type
)
1077 static const unsigned char newabs_mask
[] = { 0xC8, 0x00, 0x00, 0xC8, 0x00 };
1078 static const unsigned char newabs_rel_mask
[] = { 0xC0, 0x00, 0x00, 0xC0, 0x00 };
1079 static const unsigned char newabs_rslt
[] = { 0x80, 0x00, 0x00, 0xC0, 0x00 };
1080 static const unsigned char oldabs_mask
[] = { 0xC0, 0x60, 0x00, 0xC0, 0x60 };
1081 static const unsigned char oldabs_rslt
[] = { 0xC0, 0x00, 0x00, 0x80, 0x00 };
1082 const char *packet
= psmouse
->packet
;
1084 if (idx
< 0 || idx
> 4)
1090 case SYN_NEWABS_RELAXED
:
1091 return (packet
[idx
] & newabs_rel_mask
[idx
]) == newabs_rslt
[idx
];
1093 case SYN_NEWABS_STRICT
:
1094 return (packet
[idx
] & newabs_mask
[idx
]) == newabs_rslt
[idx
];
1097 return (packet
[idx
] & oldabs_mask
[idx
]) == oldabs_rslt
[idx
];
1100 psmouse_err(psmouse
, "unknown packet type %d\n", pkt_type
);
1105 static unsigned char synaptics_detect_pkt_type(struct psmouse
*psmouse
)
1109 for (i
= 0; i
< 5; i
++)
1110 if (!synaptics_validate_byte(psmouse
, i
, SYN_NEWABS_STRICT
)) {
1111 psmouse_info(psmouse
, "using relaxed packet validation\n");
1112 return SYN_NEWABS_RELAXED
;
1115 return SYN_NEWABS_STRICT
;
1118 static psmouse_ret_t
synaptics_process_byte(struct psmouse
*psmouse
)
1120 struct synaptics_data
*priv
= psmouse
->private;
1122 if (psmouse
->pktcnt
>= 6) { /* Full packet received */
1123 if (unlikely(priv
->pkt_type
== SYN_NEWABS
))
1124 priv
->pkt_type
= synaptics_detect_pkt_type(psmouse
);
1126 if (SYN_CAP_PASS_THROUGH(priv
->capabilities
) &&
1127 synaptics_is_pt_packet(psmouse
->packet
)) {
1129 synaptics_pass_pt_packet(psmouse
, priv
->pt_port
,
1132 synaptics_process_packet(psmouse
);
1134 return PSMOUSE_FULL_PACKET
;
1137 return synaptics_validate_byte(psmouse
, psmouse
->pktcnt
- 1, priv
->pkt_type
) ?
1138 PSMOUSE_GOOD_DATA
: PSMOUSE_BAD_DATA
;
1141 /*****************************************************************************
1142 * Driver initialization/cleanup functions
1143 ****************************************************************************/
1144 static void set_abs_position_params(struct input_dev
*dev
,
1145 struct synaptics_data
*priv
, int x_code
,
1148 int x_min
= priv
->x_min
?: XMIN_NOMINAL
;
1149 int x_max
= priv
->x_max
?: XMAX_NOMINAL
;
1150 int y_min
= priv
->y_min
?: YMIN_NOMINAL
;
1151 int y_max
= priv
->y_max
?: YMAX_NOMINAL
;
1152 int fuzz
= SYN_CAP_REDUCED_FILTERING(priv
->ext_cap_0c
) ?
1153 SYN_REDUCED_FILTER_FUZZ
: 0;
1155 input_set_abs_params(dev
, x_code
, x_min
, x_max
, fuzz
, 0);
1156 input_set_abs_params(dev
, y_code
, y_min
, y_max
, fuzz
, 0);
1157 input_abs_set_res(dev
, x_code
, priv
->x_res
);
1158 input_abs_set_res(dev
, y_code
, priv
->y_res
);
1161 static void set_input_params(struct psmouse
*psmouse
,
1162 struct synaptics_data
*priv
)
1164 struct input_dev
*dev
= psmouse
->dev
;
1167 /* Things that apply to both modes */
1168 __set_bit(INPUT_PROP_POINTER
, dev
->propbit
);
1169 __set_bit(EV_KEY
, dev
->evbit
);
1170 __set_bit(BTN_LEFT
, dev
->keybit
);
1171 __set_bit(BTN_RIGHT
, dev
->keybit
);
1173 if (SYN_CAP_MIDDLE_BUTTON(priv
->capabilities
))
1174 __set_bit(BTN_MIDDLE
, dev
->keybit
);
1176 if (!priv
->absolute_mode
) {
1178 __set_bit(EV_REL
, dev
->evbit
);
1179 __set_bit(REL_X
, dev
->relbit
);
1180 __set_bit(REL_Y
, dev
->relbit
);
1185 __set_bit(EV_ABS
, dev
->evbit
);
1186 set_abs_position_params(dev
, priv
, ABS_X
, ABS_Y
);
1187 input_set_abs_params(dev
, ABS_PRESSURE
, 0, 255, 0, 0);
1189 if (cr48_profile_sensor
)
1190 input_set_abs_params(dev
, ABS_MT_PRESSURE
, 0, 255, 0, 0);
1192 if (SYN_CAP_IMAGE_SENSOR(priv
->ext_cap_0c
)) {
1193 set_abs_position_params(dev
, priv
, ABS_MT_POSITION_X
,
1195 /* Image sensors can report per-contact pressure */
1196 input_set_abs_params(dev
, ABS_MT_PRESSURE
, 0, 255, 0, 0);
1197 input_mt_init_slots(dev
, 3, INPUT_MT_POINTER
| INPUT_MT_TRACK
);
1199 /* Image sensors can signal 4 and 5 finger clicks */
1200 __set_bit(BTN_TOOL_QUADTAP
, dev
->keybit
);
1201 __set_bit(BTN_TOOL_QUINTTAP
, dev
->keybit
);
1202 } else if (SYN_CAP_ADV_GESTURE(priv
->ext_cap_0c
)) {
1203 set_abs_position_params(dev
, priv
, ABS_MT_POSITION_X
,
1206 * Profile sensor in CR-48 tracks contacts reasonably well,
1207 * other non-image sensors with AGM use semi-mt.
1209 input_mt_init_slots(dev
, 2,
1211 (cr48_profile_sensor
?
1212 INPUT_MT_TRACK
: INPUT_MT_SEMI_MT
));
1215 if (SYN_CAP_PALMDETECT(priv
->capabilities
))
1216 input_set_abs_params(dev
, ABS_TOOL_WIDTH
, 0, 15, 0, 0);
1218 __set_bit(BTN_TOUCH
, dev
->keybit
);
1219 __set_bit(BTN_TOOL_FINGER
, dev
->keybit
);
1221 if (SYN_CAP_MULTIFINGER(priv
->capabilities
)) {
1222 __set_bit(BTN_TOOL_DOUBLETAP
, dev
->keybit
);
1223 __set_bit(BTN_TOOL_TRIPLETAP
, dev
->keybit
);
1226 if (SYN_CAP_FOUR_BUTTON(priv
->capabilities
) ||
1227 SYN_CAP_MIDDLE_BUTTON(priv
->capabilities
)) {
1228 __set_bit(BTN_FORWARD
, dev
->keybit
);
1229 __set_bit(BTN_BACK
, dev
->keybit
);
1232 if (!SYN_CAP_EXT_BUTTONS_STICK(priv
->ext_cap_10
))
1233 for (i
= 0; i
< SYN_CAP_MULTI_BUTTON_NO(priv
->ext_cap
); i
++)
1234 __set_bit(BTN_0
+ i
, dev
->keybit
);
1236 __clear_bit(EV_REL
, dev
->evbit
);
1237 __clear_bit(REL_X
, dev
->relbit
);
1238 __clear_bit(REL_Y
, dev
->relbit
);
1240 if (SYN_CAP_CLICKPAD(priv
->ext_cap_0c
)) {
1241 __set_bit(INPUT_PROP_BUTTONPAD
, dev
->propbit
);
1242 if (psmouse_matches_pnp_id(psmouse
, topbuttonpad_pnp_ids
) &&
1243 !SYN_CAP_EXT_BUTTONS_STICK(priv
->ext_cap_10
))
1244 __set_bit(INPUT_PROP_TOPBUTTONPAD
, dev
->propbit
);
1245 /* Clickpads report only left button */
1246 __clear_bit(BTN_RIGHT
, dev
->keybit
);
1247 __clear_bit(BTN_MIDDLE
, dev
->keybit
);
1251 static ssize_t
synaptics_show_disable_gesture(struct psmouse
*psmouse
,
1252 void *data
, char *buf
)
1254 struct synaptics_data
*priv
= psmouse
->private;
1256 return sprintf(buf
, "%c\n", priv
->disable_gesture
? '1' : '0');
1259 static ssize_t
synaptics_set_disable_gesture(struct psmouse
*psmouse
,
1260 void *data
, const char *buf
,
1263 struct synaptics_data
*priv
= psmouse
->private;
1267 err
= kstrtouint(buf
, 10, &value
);
1274 if (value
== priv
->disable_gesture
)
1277 priv
->disable_gesture
= value
;
1279 priv
->mode
|= SYN_BIT_DISABLE_GESTURE
;
1281 priv
->mode
&= ~SYN_BIT_DISABLE_GESTURE
;
1283 if (synaptics_mode_cmd(psmouse
, priv
->mode
))
1289 PSMOUSE_DEFINE_ATTR(disable_gesture
, S_IWUSR
| S_IRUGO
, NULL
,
1290 synaptics_show_disable_gesture
,
1291 synaptics_set_disable_gesture
);
1293 static void synaptics_disconnect(struct psmouse
*psmouse
)
1295 struct synaptics_data
*priv
= psmouse
->private;
1297 if (!priv
->absolute_mode
&& SYN_ID_DISGEST_SUPPORTED(priv
->identity
))
1298 device_remove_file(&psmouse
->ps2dev
.serio
->dev
,
1299 &psmouse_attr_disable_gesture
.dattr
);
1301 synaptics_reset(psmouse
);
1303 psmouse
->private = NULL
;
1306 static int synaptics_reconnect(struct psmouse
*psmouse
)
1308 struct synaptics_data
*priv
= psmouse
->private;
1309 struct synaptics_data old_priv
= *priv
;
1310 unsigned char param
[2];
1315 psmouse_reset(psmouse
);
1318 * On some boxes, right after resuming, the touchpad
1319 * needs some time to finish initializing (I assume
1320 * it needs time to calibrate) and start responding
1321 * to Synaptics-specific queries, so let's wait a
1326 ps2_command(&psmouse
->ps2dev
, param
, PSMOUSE_CMD_GETID
);
1327 error
= synaptics_detect(psmouse
, 0);
1328 } while (error
&& ++retry
< 3);
1334 psmouse_dbg(psmouse
, "reconnected after %d tries\n", retry
);
1336 if (synaptics_query_hardware(psmouse
)) {
1337 psmouse_err(psmouse
, "Unable to query device.\n");
1341 if (synaptics_set_mode(psmouse
)) {
1342 psmouse_err(psmouse
, "Unable to initialize device.\n");
1346 if (old_priv
.identity
!= priv
->identity
||
1347 old_priv
.model_id
!= priv
->model_id
||
1348 old_priv
.capabilities
!= priv
->capabilities
||
1349 old_priv
.ext_cap
!= priv
->ext_cap
) {
1350 psmouse_err(psmouse
,
1351 "hardware appears to be different: id(%ld-%ld), model(%ld-%ld), caps(%lx-%lx), ext(%lx-%lx).\n",
1352 old_priv
.identity
, priv
->identity
,
1353 old_priv
.model_id
, priv
->model_id
,
1354 old_priv
.capabilities
, priv
->capabilities
,
1355 old_priv
.ext_cap
, priv
->ext_cap
);
1362 static bool impaired_toshiba_kbc
;
1364 static const struct dmi_system_id toshiba_dmi_table
[] __initconst
= {
1365 #if defined(CONFIG_DMI) && defined(CONFIG_X86)
1367 /* Toshiba Satellite */
1369 DMI_MATCH(DMI_SYS_VENDOR
, "TOSHIBA"),
1370 DMI_MATCH(DMI_PRODUCT_NAME
, "Satellite"),
1374 /* Toshiba Dynabook */
1376 DMI_MATCH(DMI_SYS_VENDOR
, "TOSHIBA"),
1377 DMI_MATCH(DMI_PRODUCT_NAME
, "dynabook"),
1381 /* Toshiba Portege M300 */
1383 DMI_MATCH(DMI_SYS_VENDOR
, "TOSHIBA"),
1384 DMI_MATCH(DMI_PRODUCT_NAME
, "PORTEGE M300"),
1389 /* Toshiba Portege M300 */
1391 DMI_MATCH(DMI_SYS_VENDOR
, "TOSHIBA"),
1392 DMI_MATCH(DMI_PRODUCT_NAME
, "Portable PC"),
1393 DMI_MATCH(DMI_PRODUCT_VERSION
, "Version 1.0"),
1401 static bool broken_olpc_ec
;
1403 static const struct dmi_system_id olpc_dmi_table
[] __initconst
= {
1404 #if defined(CONFIG_DMI) && defined(CONFIG_OLPC)
1406 /* OLPC XO-1 or XO-1.5 */
1408 DMI_MATCH(DMI_SYS_VENDOR
, "OLPC"),
1409 DMI_MATCH(DMI_PRODUCT_NAME
, "XO"),
1416 static const struct dmi_system_id __initconst cr48_dmi_table
[] = {
1417 #if defined(CONFIG_DMI) && defined(CONFIG_X86)
1419 /* Cr-48 Chromebook (Codename Mario) */
1421 DMI_MATCH(DMI_SYS_VENDOR
, "IEC"),
1422 DMI_MATCH(DMI_PRODUCT_NAME
, "Mario"),
1429 void __init
synaptics_module_init(void)
1431 impaired_toshiba_kbc
= dmi_check_system(toshiba_dmi_table
);
1432 broken_olpc_ec
= dmi_check_system(olpc_dmi_table
);
1433 cr48_profile_sensor
= dmi_check_system(cr48_dmi_table
);
1436 static int __synaptics_init(struct psmouse
*psmouse
, bool absolute_mode
)
1438 struct synaptics_data
*priv
;
1442 * The OLPC XO has issues with Synaptics' absolute mode; the constant
1443 * packet spew overloads the EC such that key presses on the keyboard
1444 * are missed. Given that, don't even attempt to use Absolute mode.
1445 * Relative mode seems to work just fine.
1447 if (absolute_mode
&& broken_olpc_ec
) {
1448 psmouse_info(psmouse
,
1449 "OLPC XO detected, not enabling Synaptics protocol.\n");
1453 psmouse
->private = priv
= kzalloc(sizeof(struct synaptics_data
), GFP_KERNEL
);
1457 psmouse_reset(psmouse
);
1459 if (synaptics_query_hardware(psmouse
)) {
1460 psmouse_err(psmouse
, "Unable to query device.\n");
1464 priv
->absolute_mode
= absolute_mode
;
1465 if (SYN_ID_DISGEST_SUPPORTED(priv
->identity
))
1466 priv
->disable_gesture
= true;
1469 * Unfortunately ForcePad capability is not exported over PS/2,
1470 * so we have to resort to checking PNP IDs.
1472 priv
->is_forcepad
= psmouse_matches_pnp_id(psmouse
, forcepad_pnp_ids
);
1474 if (synaptics_set_mode(psmouse
)) {
1475 psmouse_err(psmouse
, "Unable to initialize device.\n");
1479 priv
->pkt_type
= SYN_MODEL_NEWABS(priv
->model_id
) ? SYN_NEWABS
: SYN_OLDABS
;
1481 psmouse_info(psmouse
,
1482 "Touchpad model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx, board id: %lu, fw id: %lu\n",
1483 SYN_ID_MODEL(priv
->identity
),
1484 SYN_ID_MAJOR(priv
->identity
), SYN_ID_MINOR(priv
->identity
),
1486 priv
->capabilities
, priv
->ext_cap
, priv
->ext_cap_0c
,
1487 priv
->board_id
, priv
->firmware_id
);
1489 set_input_params(psmouse
, priv
);
1492 * Encode touchpad model so that it can be used to set
1493 * input device->id.version and be visible to userspace.
1494 * Because version is __u16 we have to drop something.
1495 * Hardware info bits seem to be good candidates as they
1496 * are documented to be for Synaptics corp. internal use.
1498 psmouse
->model
= ((priv
->model_id
& 0x00ff0000) >> 8) |
1499 (priv
->model_id
& 0x000000ff);
1501 if (absolute_mode
) {
1502 psmouse
->protocol_handler
= synaptics_process_byte
;
1503 psmouse
->pktsize
= 6;
1505 /* Relative mode follows standard PS/2 mouse protocol */
1506 psmouse
->protocol_handler
= psmouse_process_byte
;
1507 psmouse
->pktsize
= 3;
1510 psmouse
->set_rate
= synaptics_set_rate
;
1511 psmouse
->disconnect
= synaptics_disconnect
;
1512 psmouse
->reconnect
= synaptics_reconnect
;
1513 psmouse
->cleanup
= synaptics_reset
;
1514 /* Synaptics can usually stay in sync without extra help */
1515 psmouse
->resync_time
= 0;
1517 if (SYN_CAP_PASS_THROUGH(priv
->capabilities
))
1518 synaptics_pt_create(psmouse
);
1521 * Toshiba's KBC seems to have trouble handling data from
1522 * Synaptics at full rate. Switch to a lower rate (roughly
1523 * the same rate as a standard PS/2 mouse).
1525 if (psmouse
->rate
>= 80 && impaired_toshiba_kbc
) {
1526 psmouse_info(psmouse
,
1527 "Toshiba %s detected, limiting rate to 40pps.\n",
1528 dmi_get_system_info(DMI_PRODUCT_NAME
));
1532 if (!priv
->absolute_mode
&& SYN_ID_DISGEST_SUPPORTED(priv
->identity
)) {
1533 err
= device_create_file(&psmouse
->ps2dev
.serio
->dev
,
1534 &psmouse_attr_disable_gesture
.dattr
);
1536 psmouse_err(psmouse
,
1537 "Failed to create disable_gesture attribute (%d)",
1550 int synaptics_init(struct psmouse
*psmouse
)
1552 return __synaptics_init(psmouse
, true);
1555 int synaptics_init_relative(struct psmouse
*psmouse
)
1557 return __synaptics_init(psmouse
, false);
1560 #else /* CONFIG_MOUSE_PS2_SYNAPTICS */
1562 void __init
synaptics_module_init(void)
1566 int synaptics_init(struct psmouse
*psmouse
)
1571 #endif /* CONFIG_MOUSE_PS2_SYNAPTICS */