/* * Synaptics TouchPad PS/2 mouse driver * * 2003 Dmitry Torokhov <dtor@mail.ru> * Added support for pass-through port. Special thanks to Peter Berg Larsen * for explaining various Synaptics quirks. * * 2003 Peter Osterlund <petero2@telia.com> * Ported to 2.5 input device infrastructure. * * Copyright (C) 2001 Stefan Gmeiner <riddlebox@freesurf.ch> * start merging tpconfig and gpm code to a xfree-input module * adding some changes and extensions (ex. 3rd and 4th button) * * Copyright (c) 1997 C. Scott Ananian <cananian@alumni.priceton.edu> * Copyright (c) 1998-2000 Bruce Kalk <kall@compass.com> * code for the special synaptics commands (from the tpconfig-source) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * * Trademarks are the property of their respective owners. */ #include <linux/module.h>#include <linux/delay.h>#include <linux/dmi.h>#include <linux/input/mt.h>#include <linux/serio.h>#include <linux/libps2.h>#include <linux/slab.h>#include "psmouse.h"#include "synaptics.h" /* * The x/y limits are taken from the Synaptics TouchPad interfacing Guide, * section 2.3.2, which says that they should be valid regardless of the * actual size of the sensor. * Note that newer firmware allows querying device for maximum useable * coordinates. */#define XMIN 0#define XMAX 6143#define YMIN 0#define YMAX 6143#define XMIN_NOMINAL 1472#define XMAX_NOMINAL 5472#define YMIN_NOMINAL 1408#define YMAX_NOMINAL 4448 /* Size in bits of absolute position values reported by the hardware */#define ABS_POS_BITS 13 /* * These values should represent the absolute maximum value that will * be reported for a positive position value. Some Synaptics firmware * uses this value to indicate a finger near the edge of the touchpad * whose precise position cannot be determined. * * At least one touchpad is known to report positions in excess of this * value which are actually negative values truncated to the 13-bit * reporting range. These values have never been observed to be lower * than 8184 (i.e. -8), so we treat all values greater than 8176 as * negative and any other value as positive. */#define X_MAX_POSITIVE 8176#define Y_MAX_POSITIVE 8176 /***************************************************************************** * Stuff we need even when we do not want native Synaptics support ****************************************************************************/ /* * Set the synaptics touchpad mode byte by special commands */static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode){ unsigned char param[1]; if (psmouse_sliced_command(psmouse, mode)) return -1; param[0] = SYN_PS_SET_MODE2; if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE)) return -1; return 0;} int synaptics_detect(struct psmouse *psmouse, bool set_properties){ struct ps2dev *ps2dev = &psmouse->ps2dev; unsigned char param[4]; param[0] = 0; ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO); if (param[1] != 0x47) return -ENODEV; if (set_properties) { psmouse->vendor = "Synaptics"; psmouse->name = "TouchPad"; } return 0;} void synaptics_reset(struct psmouse *psmouse){ /* reset touchpad back to relative mode, gestures enabled */ synaptics_mode_cmd(psmouse, 0);} #ifdef CONFIG_MOUSE_PS2_SYNAPTICS /***************************************************************************** * Synaptics communications functions ****************************************************************************/ /* * Synaptics touchpads report the y coordinate from bottom to top, which is * opposite from what userspace expects. * This function is used to invert y before reporting. */static int synaptics_invert_y(int y){ return YMAX_NOMINAL + YMIN_NOMINAL - y;} /* * Send a command to the synpatics touchpad by special commands */static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, unsigned char *param){ if (psmouse_sliced_command(psmouse, c)) return -1; if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) return -1; return 0;} /* * Read the model-id bytes from the touchpad * see also SYN_MODEL_* macros */static int synaptics_model_id(struct psmouse *psmouse){ struct synaptics_data *priv = psmouse->private; unsigned char mi[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_MODEL, mi)) return -1; priv->model_id = (mi[0]<<16) | (mi[1]<<8) | mi[2]; return 0;} /* * Read the board id from the touchpad * The board id is encoded in the "QUERY MODES" response */static int synaptics_board_id(struct psmouse *psmouse){ struct synaptics_data *priv = psmouse->private; unsigned char bid[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_MODES, bid)) return -1; priv->board_id = ((bid[0] & 0xfc) << 6) | bid[1]; return 0;} /* * Read the firmware id from the touchpad */static int synaptics_firmware_id(struct psmouse *psmouse){ struct synaptics_data *priv = psmouse->private; unsigned char fwid[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_FIRMWARE_ID, fwid)) return -1; priv->firmware_id = (fwid[0] << 16) | (fwid[1] << 8) | fwid[2]; return 0;} /* * Read the capability-bits from the touchpad * see also the SYN_CAP_* macros */static int synaptics_capability(struct psmouse *psmouse){ struct synaptics_data *priv = psmouse->private; unsigned char cap[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap)) return -1; priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2]; priv->ext_cap = priv->ext_cap_0c = 0; /* * Older firmwares had submodel ID fixed to 0x47 */ if (SYN_ID_FULL(priv->identity) < 0x705 && SYN_CAP_SUBMODEL_ID(priv->capabilities) != 0x47) { return -1; } /* * Unless capExtended is set the rest of the flags should be ignored */ if (!SYN_CAP_EXTENDED(priv->capabilities)) priv->capabilities = 0; if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 1) { if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) { psmouse_warn(psmouse, "device claims to have extended capabilities, but I'm not able to read them.\n"); } else { priv->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2]; /* * if nExtBtn is greater than 8 it should be considered * invalid and treated as 0 */ if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) > 8) priv->ext_cap &= 0xff0fff; } } if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 4) { if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB_0C, cap)) { psmouse_warn(psmouse, "device claims to have extended capability 0x0c, but I'm not able to read it.\n"); } else { priv->ext_cap_0c = (cap[0] << 16) | (cap[1] << 8) | cap[2]; } } return 0;} /* * Identify Touchpad * See also the SYN_ID_* macros */static int synaptics_identify(struct psmouse *psmouse){ struct synaptics_data *priv = psmouse->private; unsigned char id[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_IDENTIFY, id)) return -1; priv->identity = (id[0]<<16) | (id[1]<<8) | id[2]; if (SYN_ID_IS_SYNAPTICS(priv->identity)) return 0; return -1;} /* * Read touchpad resolution and maximum reported coordinates * Resolution is left zero if touchpad does not support the query */static int synaptics_resolution(struct psmouse *psmouse){ struct synaptics_data *priv = psmouse->private; unsigned char resp[3]; if (SYN_ID_MAJOR(priv->identity) < 4) return 0; if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, resp) == 0) { if (resp[0] != 0 && (resp[1] & 0x80) && resp[2] != 0) { priv->x_res = resp[0]; /* x resolution in units/mm */ priv->y_res = resp[2]; /* y resolution in units/mm */ } } if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 5 && SYN_CAP_MAX_DIMENSIONS(priv->ext_cap_0c)) { if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MAX_COORDS, resp)) { psmouse_warn(psmouse, "device claims to have max coordinates query, but I'm not able to read it.\n"); } else { priv->x_max = (resp[0] << 5) | ((resp[1] & 0x0f) << 1); priv->y_max = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3); } } if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 && SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c)) { if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MIN_COORDS, resp)) { psmouse_warn(psmouse, "device claims to have min coordinates query, but I'm not able to read it.\n"); } else { priv->x_min = (resp[0] << 5) | ((resp[1] & 0x0f) << 1); priv->y_min = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3); } } return 0;} static int synaptics_query_hardware(struct psmouse *psmouse){ if (synaptics_identify(psmouse)) return -1; if (synaptics_model_id(psmouse)) return -1; if (synaptics_firmware_id(psmouse)) return -1; if (synaptics_board_id(psmouse)) return -1; if (synaptics_capability(psmouse)) return -1; if (synaptics_resolution(psmouse)) return -1; return 0;} static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse){ static unsigned char param = 0xc8; struct synaptics_data *priv = psmouse->private; if (!(SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) || SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c))) return 0; if (psmouse_sliced_command(psmouse, SYN_QUE_MODEL)) return -1; if (ps2_command(&psmouse->ps2dev, ¶m, PSMOUSE_CMD_SETRATE)) return -1; /* Advanced gesture mode also sends multi finger data */ priv->capabilities |= BIT(1); return 0;} static int synaptics_set_mode(struct psmouse *psmouse){ struct synaptics_data *priv = psmouse->private; priv->mode = 0; if (priv->absolute_mode) priv->mode |= SYN_BIT_ABSOLUTE_MODE; if (priv->disable_gesture) priv->mode |= SYN_BIT_DISABLE_GESTURE; if (psmouse->rate >= 80) priv->mode |= SYN_BIT_HIGH_RATE; if (SYN_CAP_EXTENDED(priv->capabilities)) priv->mode |= SYN_BIT_W_MODE; if (synaptics_mode_cmd(psmouse, priv->mode)) return -1; if (priv->absolute_mode && synaptics_set_advanced_gesture_mode(psmouse)) { psmouse_err(psmouse, "Advanced gesture mode init failed.\n"); return -1; } return 0;} static void synaptics_set_rate(struct psmouse *psmouse, unsigned int rate){ struct synaptics_data *priv = psmouse->private; if (rate >= 80) { priv->mode |= SYN_BIT_HIGH_RATE; psmouse->rate = 80; } else { priv->mode &= ~SYN_BIT_HIGH_RATE; psmouse->rate = 40; } synaptics_mode_cmd(psmouse, priv->mode);} /***************************************************************************** * Synaptics pass-through PS/2 port support ****************************************************************************/static int synaptics_pt_write(struct serio *serio, unsigned char c){ struct psmouse *parent = serio_get_drvdata(serio->parent); char rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */ if (psmouse_sliced_command(parent, c)) return -1; if (ps2_command(&parent->ps2dev, &rate_param, PSMOUSE_CMD_SETRATE)) return -1; return 0;} static int synaptics_pt_start(struct serio *serio){ struct psmouse *parent = serio_get_drvdata(serio->parent); struct synaptics_data *priv = parent->private; serio_pause_rx(parent->ps2dev.serio); priv->pt_port = serio; serio_continue_rx(parent->ps2dev.serio); return 0;} static void synaptics_pt_stop(struct serio *serio){ struct psmouse *parent = serio_get_drvdata(serio->parent); struct synaptics_data *priv = parent->private; serio_pause_rx(parent->ps2dev.serio); priv->pt_port = NULL; serio_continue_rx(parent->ps2dev.serio);} static int synaptics_is_pt_packet(unsigned char *buf){ return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4;} static void synaptics_pass_pt_packet(struct serio *ptport, unsigned char *packet){ struct psmouse *child = serio_get_drvdata(ptport); if (child && child->state == PSMOUSE_ACTIVATED) { serio_interrupt(ptport, packet[1], 0); serio_interrupt(ptport, packet[4], 0); serio_interrupt(ptport, packet[5], 0); if (child->pktsize == 4) serio_interrupt(ptport, packet[2], 0); } else serio_interrupt(ptport, packet[1], 0);} static void synaptics_pt_activate(struct psmouse *psmouse){ struct synaptics_data *priv = psmouse->private; struct psmouse *child = serio_get_drvdata(priv->pt_port); /* adjust the touchpad to child's choice of protocol */ if (child) { if (child->pktsize == 4) priv->mode |= SYN_BIT_FOUR_BYTE_CLIENT; else priv->mode &= ~SYN_BIT_FOUR_BYTE_CLIENT; if (synaptics_mode_cmd(psmouse, priv->mode)) psmouse_warn(psmouse, "failed to switch guest protocol\n"); }} static void synaptics_pt_create(struct psmouse *psmouse){ struct serio *serio; serio = kzalloc(sizeof(struct serio), GFP_KERNEL); if (!serio) { psmouse_err(psmouse, "not enough memory for pass-through port\n"); return; } serio->id.type = SERIO_PS_PSTHRU; strlcpy(serio->name, "Synaptics pass-through", sizeof(serio->name)); strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->name)); serio->write = synaptics_pt_write; serio->start = synaptics_pt_start; serio->stop = synaptics_pt_stop; serio->parent = psmouse->ps2dev.serio; psmouse->pt_activate = synaptics_pt_activate; psmouse_info(psmouse, "serio: %s port at %s\n", serio->name, psmouse->phys); serio_register_port(serio);} /***************************************************************************** * Functions to interpret the absolute mode packets ****************************************************************************/ static void synaptics_mt_state_set(struct synaptics_mt_state *state, int count, int sgm, int agm){ state->count = count; state->sgm = sgm; state->agm = agm;} static void synaptics_parse_agm(const unsigned char buf[],Lines 1–500 of 1633. Load more
/* * Synaptics TouchPad PS/2 mouse driver * * 2003 Dmitry Torokhov <dtor@mail.ru> * Added support for pass-through port. Special thanks to Peter Berg Larsen * for explaining various Synaptics quirks. * * 2003 Peter Osterlund <petero2@telia.com> * Ported to 2.5 input device infrastructure. * * Copyright (C) 2001 Stefan Gmeiner <riddlebox@freesurf.ch> * start merging tpconfig and gpm code to a xfree-input module * adding some changes and extensions (ex. 3rd and 4th button) * * Copyright (c) 1997 C. Scott Ananian <cananian@alumni.priceton.edu> * Copyright (c) 1998-2000 Bruce Kalk <kall@compass.com> * code for the special synaptics commands (from the tpconfig-source) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * * Trademarks are the property of their respective owners. */ #include <linux/module.h> #include <linux/delay.h> #include <linux/dmi.h> #include <linux/input/mt.h> #include <linux/serio.h> #include <linux/libps2.h> #include <linux/slab.h> #include "psmouse.h" #include "synaptics.h" /* * The x/y limits are taken from the Synaptics TouchPad interfacing Guide, * section 2.3.2, which says that they should be valid regardless of the * actual size of the sensor. * Note that newer firmware allows querying device for maximum useable * coordinates. */ #define XMIN 0 #define XMAX 6143 #define YMIN 0 #define YMAX 6143 #define XMIN_NOMINAL 1472 #define XMAX_NOMINAL 5472 #define YMIN_NOMINAL 1408 #define YMAX_NOMINAL 4448 /* Size in bits of absolute position values reported by the hardware */ #define ABS_POS_BITS 13 /* * These values should represent the absolute maximum value that will * be reported for a positive position value. Some Synaptics firmware * uses this value to indicate a finger near the edge of the touchpad * whose precise position cannot be determined. * * At least one touchpad is known to report positions in excess of this * value which are actually negative values truncated to the 13-bit * reporting range. These values have never been observed to be lower * than 8184 (i.e. -8), so we treat all values greater than 8176 as * negative and any other value as positive. */ #define X_MAX_POSITIVE 8176 #define Y_MAX_POSITIVE 8176 /***************************************************************************** * Stuff we need even when we do not want native Synaptics support ****************************************************************************/ /* * Set the synaptics touchpad mode byte by special commands */ static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode) { unsigned char param[1]; if (psmouse_sliced_command(psmouse, mode)) return -1; param[0] = SYN_PS_SET_MODE2; if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE)) return -1; return 0; } int synaptics_detect(struct psmouse *psmouse, bool set_properties) { struct ps2dev *ps2dev = &psmouse->ps2dev; unsigned char param[4]; param[0] = 0; ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO); if (param[1] != 0x47) return -ENODEV; if (set_properties) { psmouse->vendor = "Synaptics"; psmouse->name = "TouchPad"; } return 0; } void synaptics_reset(struct psmouse *psmouse) { /* reset touchpad back to relative mode, gestures enabled */ synaptics_mode_cmd(psmouse, 0); } #ifdef CONFIG_MOUSE_PS2_SYNAPTICS /***************************************************************************** * Synaptics communications functions ****************************************************************************/ /* * Synaptics touchpads report the y coordinate from bottom to top, which is * opposite from what userspace expects. * This function is used to invert y before reporting. */ static int synaptics_invert_y(int y) { return YMAX_NOMINAL + YMIN_NOMINAL - y; } /* * Send a command to the synpatics touchpad by special commands */ static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, unsigned char *param) { if (psmouse_sliced_command(psmouse, c)) return -1; if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) return -1; return 0; } /* * Read the model-id bytes from the touchpad * see also SYN_MODEL_* macros */ static int synaptics_model_id(struct psmouse *psmouse) { struct synaptics_data *priv = psmouse->private; unsigned char mi[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_MODEL, mi)) return -1; priv->model_id = (mi[0]<<16) | (mi[1]<<8) | mi[2]; return 0; } /* * Read the board id from the touchpad * The board id is encoded in the "QUERY MODES" response */ static int synaptics_board_id(struct psmouse *psmouse) { struct synaptics_data *priv = psmouse->private; unsigned char bid[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_MODES, bid)) return -1; priv->board_id = ((bid[0] & 0xfc) << 6) | bid[1]; return 0; } /* * Read the firmware id from the touchpad */ static int synaptics_firmware_id(struct psmouse *psmouse) { struct synaptics_data *priv = psmouse->private; unsigned char fwid[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_FIRMWARE_ID, fwid)) return -1; priv->firmware_id = (fwid[0] << 16) | (fwid[1] << 8) | fwid[2]; return 0; } /* * Read the capability-bits from the touchpad * see also the SYN_CAP_* macros */ static int synaptics_capability(struct psmouse *psmouse) { struct synaptics_data *priv = psmouse->private; unsigned char cap[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap)) return -1; priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2]; priv->ext_cap = priv->ext_cap_0c = 0; /* * Older firmwares had submodel ID fixed to 0x47 */ if (SYN_ID_FULL(priv->identity) < 0x705 && SYN_CAP_SUBMODEL_ID(priv->capabilities) != 0x47) { return -1; } /* * Unless capExtended is set the rest of the flags should be ignored */ if (!SYN_CAP_EXTENDED(priv->capabilities)) priv->capabilities = 0; if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 1) { if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) { psmouse_warn(psmouse, "device claims to have extended capabilities, but I'm not able to read them.\n"); } else { priv->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2]; /* * if nExtBtn is greater than 8 it should be considered * invalid and treated as 0 */ if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) > 8) priv->ext_cap &= 0xff0fff; } } if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 4) { if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB_0C, cap)) { psmouse_warn(psmouse, "device claims to have extended capability 0x0c, but I'm not able to read it.\n"); } else { priv->ext_cap_0c = (cap[0] << 16) | (cap[1] << 8) | cap[2]; } } return 0; } /* * Identify Touchpad * See also the SYN_ID_* macros */ static int synaptics_identify(struct psmouse *psmouse) { struct synaptics_data *priv = psmouse->private; unsigned char id[3]; if (synaptics_send_cmd(psmouse, SYN_QUE_IDENTIFY, id)) return -1; priv->identity = (id[0]<<16) | (id[1]<<8) | id[2]; if (SYN_ID_IS_SYNAPTICS(priv->identity)) return 0; return -1; } /* * Read touchpad resolution and maximum reported coordinates * Resolution is left zero if touchpad does not support the query */ static int synaptics_resolution(struct psmouse *psmouse) { struct synaptics_data *priv = psmouse->private; unsigned char resp[3]; if (SYN_ID_MAJOR(priv->identity) < 4) return 0; if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, resp) == 0) { if (resp[0] != 0 && (resp[1] & 0x80) && resp[2] != 0) { priv->x_res = resp[0]; /* x resolution in units/mm */ priv->y_res = resp[2]; /* y resolution in units/mm */ } } if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 5 && SYN_CAP_MAX_DIMENSIONS(priv->ext_cap_0c)) { if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MAX_COORDS, resp)) { psmouse_warn(psmouse, "device claims to have max coordinates query, but I'm not able to read it.\n"); } else { priv->x_max = (resp[0] << 5) | ((resp[1] & 0x0f) << 1); priv->y_max = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3); } } if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 && SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c)) { if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MIN_COORDS, resp)) { psmouse_warn(psmouse, "device claims to have min coordinates query, but I'm not able to read it.\n"); } else { priv->x_min = (resp[0] << 5) | ((resp[1] & 0x0f) << 1); priv->y_min = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3); } } return 0; } static int synaptics_query_hardware(struct psmouse *psmouse) { if (synaptics_identify(psmouse)) return -1; if (synaptics_model_id(psmouse)) return -1; if (synaptics_firmware_id(psmouse)) return -1; if (synaptics_board_id(psmouse)) return -1; if (synaptics_capability(psmouse)) return -1; if (synaptics_resolution(psmouse)) return -1; return 0; } static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) { static unsigned char param = 0xc8; struct synaptics_data *priv = psmouse->private; if (!(SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) || SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c))) return 0; if (psmouse_sliced_command(psmouse, SYN_QUE_MODEL)) return -1; if (ps2_command(&psmouse->ps2dev, ¶m, PSMOUSE_CMD_SETRATE)) return -1; /* Advanced gesture mode also sends multi finger data */ priv->capabilities |= BIT(1); return 0; } static int synaptics_set_mode(struct psmouse *psmouse) { struct synaptics_data *priv = psmouse->private; priv->mode = 0; if (priv->absolute_mode) priv->mode |= SYN_BIT_ABSOLUTE_MODE; if (priv->disable_gesture) priv->mode |= SYN_BIT_DISABLE_GESTURE; if (psmouse->rate >= 80) priv->mode |= SYN_BIT_HIGH_RATE; if (SYN_CAP_EXTENDED(priv->capabilities)) priv->mode |= SYN_BIT_W_MODE; if (synaptics_mode_cmd(psmouse, priv->mode)) return -1; if (priv->absolute_mode && synaptics_set_advanced_gesture_mode(psmouse)) { psmouse_err(psmouse, "Advanced gesture mode init failed.\n"); return -1; } return 0; } static void synaptics_set_rate(struct psmouse *psmouse, unsigned int rate) { struct synaptics_data *priv = psmouse->private; if (rate >= 80) { priv->mode |= SYN_BIT_HIGH_RATE; psmouse->rate = 80; } else { priv->mode &= ~SYN_BIT_HIGH_RATE; psmouse->rate = 40; } synaptics_mode_cmd(psmouse, priv->mode); } /***************************************************************************** * Synaptics pass-through PS/2 port support ****************************************************************************/ static int synaptics_pt_write(struct serio *serio, unsigned char c) { struct psmouse *parent = serio_get_drvdata(serio->parent); char rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */ if (psmouse_sliced_command(parent, c)) return -1; if (ps2_command(&parent->ps2dev, &rate_param, PSMOUSE_CMD_SETRATE)) return -1; return 0; } static int synaptics_pt_start(struct serio *serio) { struct psmouse *parent = serio_get_drvdata(serio->parent); struct synaptics_data *priv = parent->private; serio_pause_rx(parent->ps2dev.serio); priv->pt_port = serio; serio_continue_rx(parent->ps2dev.serio); return 0; } static void synaptics_pt_stop(struct serio *serio) { struct psmouse *parent = serio_get_drvdata(serio->parent); struct synaptics_data *priv = parent->private; serio_pause_rx(parent->ps2dev.serio); priv->pt_port = NULL; serio_continue_rx(parent->ps2dev.serio); } static int synaptics_is_pt_packet(unsigned char *buf) { return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4; } static void synaptics_pass_pt_packet(struct serio *ptport, unsigned char *packet) { struct psmouse *child = serio_get_drvdata(ptport); if (child && child->state == PSMOUSE_ACTIVATED) { serio_interrupt(ptport, packet[1], 0); serio_interrupt(ptport, packet[4], 0); serio_interrupt(ptport, packet[5], 0); if (child->pktsize == 4) serio_interrupt(ptport, packet[2], 0); } else serio_interrupt(ptport, packet[1], 0); } static void synaptics_pt_activate(struct psmouse *psmouse) { struct synaptics_data *priv = psmouse->private; struct psmouse *child = serio_get_drvdata(priv->pt_port); /* adjust the touchpad to child's choice of protocol */ if (child) { if (child->pktsize == 4) priv->mode |= SYN_BIT_FOUR_BYTE_CLIENT; else priv->mode &= ~SYN_BIT_FOUR_BYTE_CLIENT; if (synaptics_mode_cmd(psmouse, priv->mode)) psmouse_warn(psmouse, "failed to switch guest protocol\n"); } } static void synaptics_pt_create(struct psmouse *psmouse) { struct serio *serio; serio = kzalloc(sizeof(struct serio), GFP_KERNEL); if (!serio) { psmouse_err(psmouse, "not enough memory for pass-through port\n"); return; } serio->id.type = SERIO_PS_PSTHRU; strlcpy(serio->name, "Synaptics pass-through", sizeof(serio->name)); strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->name)); serio->write = synaptics_pt_write; serio->start = synaptics_pt_start; serio->stop = synaptics_pt_stop; serio->parent = psmouse->ps2dev.serio; psmouse->pt_activate = synaptics_pt_activate; psmouse_info(psmouse, "serio: %s port at %s\n", serio->name, psmouse->phys); serio_register_port(serio); } /***************************************************************************** * Functions to interpret the absolute mode packets ****************************************************************************/ static void synaptics_mt_state_set(struct synaptics_mt_state *state, int count, int sgm, int agm) { state->count = count; state->sgm = sgm; state->agm = agm; } static void synaptics_parse_agm(const unsigned char buf[],