// SPDX-License-Identifier: GPL-2.0-only/* * 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) * * 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/rmi.h>#include <linux/i2c.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 /* maximum ABS_MT_POSITION displacement (in mm) */#define DMAX 10 /***************************************************************************** * 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, u8 mode){ u8 param[1]; int error; error = ps2_sliced_command(&psmouse->ps2dev, mode); if (error) return error; param[0] = SYN_PS_SET_MODE2; error = ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE); if (error) return error; return 0;} int synaptics_detect(struct psmouse *psmouse, bool set_properties){ struct ps2dev *ps2dev = &psmouse->ps2dev; u8 param[4] = { 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);} #if defined(CONFIG_MOUSE_PS2_SYNAPTICS) || \ defined(CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS) /* This list has been kindly provided by Synaptics. */static const char * const topbuttonpad_pnp_ids[] = { "LEN0017", "LEN0018", "LEN0019", "LEN0023", "LEN002A", "LEN002B", "LEN002C", "LEN002D", "LEN002E", "LEN0033", /* Helix */ "LEN0034", /* T431s, L440, L540, T540, W540, X1 Carbon 2nd */ "LEN0035", /* X240 */ "LEN0036", /* T440 */ "LEN0037", /* X1 Carbon 2nd */ "LEN0038", "LEN0039", /* T440s */ "LEN0041", "LEN0042", /* Yoga */ "LEN0045", "LEN0047", "LEN2000", /* S540 */ "LEN2001", /* Edge E431 */ "LEN2002", /* Edge E531 */ "LEN2003", "LEN2004", /* L440 */ "LEN2005", "LEN2006", /* Edge E440/E540 */ "LEN2007", "LEN2008", "LEN2009", "LEN200A", "LEN200B", NULL}; #ifdef CONFIG_MOUSE_PS2_SYNAPTICS_SMBUSstatic const char * const smbus_pnp_ids[] = { /* all of the topbuttonpad_pnp_ids are valid, we just add some extras */ "DLL0597", /* Dell Inspiron 3521 */ "DLL060d", /* Dell Precision M3800 */ "LEN0048", /* X1 Carbon 3 */ "LEN0046", /* X250 */ "LEN0049", /* Yoga 11e */ "LEN004a", /* W541 */ "LEN005b", /* P50 */ "LEN005e", /* T560 */ "LEN006c", /* T470s */ "LEN007a", /* T470s */ "LEN0071", /* T480 */ "LEN0072", /* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ "LEN0073", /* X1 Carbon G5 (Elantech) */ "LEN0091", /* X1 Carbon 6 */ "LEN0092", /* X1 Carbon 6 */ "LEN0093", /* T480 */ "LEN0096", /* X280 */ "LEN0097", /* X280 -> ALPS trackpoint */ "LEN0099", /* X1 Extreme Gen 1 / P1 Gen 1 */ "LEN009b", /* T580 */ "LEN0402", /* X1 Extreme Gen 2 / P1 Gen 2 */ "LEN040f", /* P1 Gen 3 */ "LEN0411", /* L14 Gen 1 */ "LEN200f", /* T450s */ "LEN2044", /* L470 */ "LEN2054", /* E480 */ "LEN2055", /* E580 */ "LEN2058", /* E490 */ "LEN2068", /* T14 Gen 1 */ "SYN1221", /* TUXEDO InfinityBook Pro 14 v5 */ "SYN3003", /* HP EliteBook 850 G1 */ "SYN3015", /* HP EliteBook 840 G2 */ "SYN3052", /* HP EliteBook 840 G4 */ "SYN3221", /* HP 15-ay000 */ "SYN323d", /* HP Spectre X360 13-w013dx */ "SYN3257", /* HP Envy 13-ad105ng */ "TOS01f6", /* Dynabook Portege X30L-G */ "TOS0213", /* Dynabook Portege X30-D */ NULL};#endif static const char * const forcepad_pnp_ids[] = { "SYN300D", "SYN3014", NULL}; /* * Send a command to the synaptics touchpad by special commands */static int synaptics_send_cmd(struct psmouse *psmouse, u8 cmd, u8 *param){ int error; error = ps2_sliced_command(&psmouse->ps2dev, cmd); if (error) return error; error = ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO); if (error) return error; return 0;} static int synaptics_query_int(struct psmouse *psmouse, u8 query_cmd, u32 *val){ int error; union { __be32 be_val; char buf[4]; } resp = { 0 }; error = synaptics_send_cmd(psmouse, query_cmd, resp.buf + 1); if (error) return error; *val = be32_to_cpu(resp.be_val); return 0;} /* * Identify Touchpad * See also the SYN_ID_* macros */static int synaptics_identify(struct psmouse *psmouse, struct synaptics_device_info *info){ int error; error = synaptics_query_int(psmouse, SYN_QUE_IDENTIFY, &info->identity); if (error) return error; return SYN_ID_IS_SYNAPTICS(info->identity) ? 0 : -ENXIO;} /* * Read the model-id bytes from the touchpad * see also SYN_MODEL_* macros */static int synaptics_model_id(struct psmouse *psmouse, struct synaptics_device_info *info){ return synaptics_query_int(psmouse, SYN_QUE_MODEL, &info->model_id);} /* * Read the firmware id from the touchpad */static int synaptics_firmware_id(struct psmouse *psmouse, struct synaptics_device_info *info){ return synaptics_query_int(psmouse, SYN_QUE_FIRMWARE_ID, &info->firmware_id);} /* * Read the board id and the "More Extended Queries" from the touchpad * The board id is encoded in the "QUERY MODES" response */static int synaptics_query_modes(struct psmouse *psmouse, struct synaptics_device_info *info){ u8 bid[3]; int error; /* firmwares prior 7.5 have no board_id encoded */ if (SYN_ID_FULL(info->identity) < 0x705) return 0; error = synaptics_send_cmd(psmouse, SYN_QUE_MODES, bid); if (error) return error; info->board_id = ((bid[0] & 0xfc) << 6) | bid[1]; if (SYN_MEXT_CAP_BIT(bid[0])) return synaptics_query_int(psmouse, SYN_QUE_MEXT_CAPAB_10, &info->ext_cap_10); return 0;} /* * Read the capability-bits from the touchpad * see also the SYN_CAP_* macros */static int synaptics_capability(struct psmouse *psmouse, struct synaptics_device_info *info){ int error; error = synaptics_query_int(psmouse, SYN_QUE_CAPABILITIES, &info->capabilities); if (error) return error; info->ext_cap = info->ext_cap_0c = 0; /* * Older firmwares had submodel ID fixed to 0x47 */ if (SYN_ID_FULL(info->identity) < 0x705 && SYN_CAP_SUBMODEL_ID(info->capabilities) != 0x47) { return -ENXIO; } /* * Unless capExtended is set the rest of the flags should be ignored */ if (!SYN_CAP_EXTENDED(info->capabilities)) info->capabilities = 0; if (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 1) { error = synaptics_query_int(psmouse, SYN_QUE_EXT_CAPAB, &info->ext_cap); if (error) { psmouse_warn(psmouse, "device claims to have extended capabilities, but I'm not able to read them.\n"); } else { /* * if nExtBtn is greater than 8 it should be considered * invalid and treated as 0 */ if (SYN_CAP_MULTI_BUTTON_NO(info->ext_cap) > 8) info->ext_cap &= ~SYN_CAP_MB_MASK; } } if (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 4) { error = synaptics_query_int(psmouse, SYN_QUE_EXT_CAPAB_0C, &info->ext_cap_0c); if (error) psmouse_warn(psmouse, "device claims to have extended capability 0x0c, but I'm not able to read it.\n"); } return 0;} /* * 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_device_info *info){ u8 resp[3]; int error; if (SYN_ID_MAJOR(info->identity) < 4) return 0; error = synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, resp); if (!error) { if (resp[0] != 0 && (resp[1] & 0x80) && resp[2] != 0) { info->x_res = resp[0]; /* x resolution in units/mm */ info->y_res = resp[2]; /* y resolution in units/mm */ } } if (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 5 && SYN_CAP_MAX_DIMENSIONS(info->ext_cap_0c)) { error = synaptics_send_cmd(psmouse, SYN_QUE_EXT_MAX_COORDS, resp); if (error) { psmouse_warn(psmouse, "device claims to have max coordinates query, but I'm not able to read it.\n"); } else { info->x_max = (resp[0] << 5) | ((resp[1] & 0x0f) << 1); info->y_max = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3); psmouse_info(psmouse, "queried max coordinates: x [..%d], y [..%d]\n", info->x_max, info->y_max); } } if (SYN_CAP_MIN_DIMENSIONS(info->ext_cap_0c) && (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 7 || /* * Firmware v8.1 does not report proper number of extended * capabilities, but has been proven to report correct min * coordinates. */ SYN_ID_FULL(info->identity) == 0x801)) { error = synaptics_send_cmd(psmouse, SYN_QUE_EXT_MIN_COORDS, resp); if (error) { psmouse_warn(psmouse, "device claims to have min coordinates query, but I'm not able to read it.\n"); } else { info->x_min = (resp[0] << 5) | ((resp[1] & 0x0f) << 1); info->y_min = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3); psmouse_info(psmouse, "queried min coordinates: x [%d..], y [%d..]\n", info->x_min, info->y_min); } } return 0;} static int synaptics_query_hardware(struct psmouse *psmouse, struct synaptics_device_info *info){ int error; memset(info, 0, sizeof(*info)); error = synaptics_identify(psmouse, info); if (error) return error; error = synaptics_model_id(psmouse, info); if (error) return error; error = synaptics_firmware_id(psmouse, info); if (error) return error; error = synaptics_query_modes(psmouse, info); if (error) return error; error = synaptics_capability(psmouse, info); if (error) return error; error = synaptics_resolution(psmouse, info); if (error) return error; return 0;} #endif /* CONFIG_MOUSE_PS2_SYNAPTICS || CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS */ #ifdef CONFIG_MOUSE_PS2_SYNAPTICS static bool cr48_profile_sensor; #define ANY_BOARD_ID 0struct min_max_quirk { const char * const *pnp_ids; struct { u32 min, max; } board_id; u32 x_min, x_max, y_min, y_max;}; static const struct min_max_quirk min_max_pnpid_table[] = { { (const char * const []){"LEN0033", NULL}, {ANY_BOARD_ID, ANY_BOARD_ID}, 1024, 5052, 2258, 4832 }, { (const char * const []){"LEN0042", NULL}, {ANY_BOARD_ID, ANY_BOARD_ID}, 1232, 5710, 1156, 4696 }, { (const char * const []){"LEN0034", "LEN0036", "LEN0037", "LEN0039", "LEN2002", "LEN2004", NULL}, {ANY_BOARD_ID, 2961}, 1024, 5112, 2024, 4832 }, { (const char * const []){"LEN2000", NULL}, {ANY_BOARD_ID, ANY_BOARD_ID},Lines 1–500 of 1945. Load more
// SPDX-License-Identifier: GPL-2.0-only /* * 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) * * 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/rmi.h> #include <linux/i2c.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 /* maximum ABS_MT_POSITION displacement (in mm) */ #define DMAX 10 /***************************************************************************** * 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, u8 mode) { u8 param[1]; int error; error = ps2_sliced_command(&psmouse->ps2dev, mode); if (error) return error; param[0] = SYN_PS_SET_MODE2; error = ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE); if (error) return error; return 0; } int synaptics_detect(struct psmouse *psmouse, bool set_properties) { struct ps2dev *ps2dev = &psmouse->ps2dev; u8 param[4] = { 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); } #if defined(CONFIG_MOUSE_PS2_SYNAPTICS) || \ defined(CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS) /* This list has been kindly provided by Synaptics. */ static const char * const topbuttonpad_pnp_ids[] = { "LEN0017", "LEN0018", "LEN0019", "LEN0023", "LEN002A", "LEN002B", "LEN002C", "LEN002D", "LEN002E", "LEN0033", /* Helix */ "LEN0034", /* T431s, L440, L540, T540, W540, X1 Carbon 2nd */ "LEN0035", /* X240 */ "LEN0036", /* T440 */ "LEN0037", /* X1 Carbon 2nd */ "LEN0038", "LEN0039", /* T440s */ "LEN0041", "LEN0042", /* Yoga */ "LEN0045", "LEN0047", "LEN2000", /* S540 */ "LEN2001", /* Edge E431 */ "LEN2002", /* Edge E531 */ "LEN2003", "LEN2004", /* L440 */ "LEN2005", "LEN2006", /* Edge E440/E540 */ "LEN2007", "LEN2008", "LEN2009", "LEN200A", "LEN200B", NULL }; #ifdef CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS static const char * const smbus_pnp_ids[] = { /* all of the topbuttonpad_pnp_ids are valid, we just add some extras */ "DLL0597", /* Dell Inspiron 3521 */ "DLL060d", /* Dell Precision M3800 */ "LEN0048", /* X1 Carbon 3 */ "LEN0046", /* X250 */ "LEN0049", /* Yoga 11e */ "LEN004a", /* W541 */ "LEN005b", /* P50 */ "LEN005e", /* T560 */ "LEN006c", /* T470s */ "LEN007a", /* T470s */ "LEN0071", /* T480 */ "LEN0072", /* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ "LEN0073", /* X1 Carbon G5 (Elantech) */ "LEN0091", /* X1 Carbon 6 */ "LEN0092", /* X1 Carbon 6 */ "LEN0093", /* T480 */ "LEN0096", /* X280 */ "LEN0097", /* X280 -> ALPS trackpoint */ "LEN0099", /* X1 Extreme Gen 1 / P1 Gen 1 */ "LEN009b", /* T580 */ "LEN0402", /* X1 Extreme Gen 2 / P1 Gen 2 */ "LEN040f", /* P1 Gen 3 */ "LEN0411", /* L14 Gen 1 */ "LEN200f", /* T450s */ "LEN2044", /* L470 */ "LEN2054", /* E480 */ "LEN2055", /* E580 */ "LEN2058", /* E490 */ "LEN2068", /* T14 Gen 1 */ "SYN1221", /* TUXEDO InfinityBook Pro 14 v5 */ "SYN3003", /* HP EliteBook 850 G1 */ "SYN3015", /* HP EliteBook 840 G2 */ "SYN3052", /* HP EliteBook 840 G4 */ "SYN3221", /* HP 15-ay000 */ "SYN323d", /* HP Spectre X360 13-w013dx */ "SYN3257", /* HP Envy 13-ad105ng */ "TOS01f6", /* Dynabook Portege X30L-G */ "TOS0213", /* Dynabook Portege X30-D */ NULL }; #endif static const char * const forcepad_pnp_ids[] = { "SYN300D", "SYN3014", NULL }; /* * Send a command to the synaptics touchpad by special commands */ static int synaptics_send_cmd(struct psmouse *psmouse, u8 cmd, u8 *param) { int error; error = ps2_sliced_command(&psmouse->ps2dev, cmd); if (error) return error; error = ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO); if (error) return error; return 0; } static int synaptics_query_int(struct psmouse *psmouse, u8 query_cmd, u32 *val) { int error; union { __be32 be_val; char buf[4]; } resp = { 0 }; error = synaptics_send_cmd(psmouse, query_cmd, resp.buf + 1); if (error) return error; *val = be32_to_cpu(resp.be_val); return 0; } /* * Identify Touchpad * See also the SYN_ID_* macros */ static int synaptics_identify(struct psmouse *psmouse, struct synaptics_device_info *info) { int error; error = synaptics_query_int(psmouse, SYN_QUE_IDENTIFY, &info->identity); if (error) return error; return SYN_ID_IS_SYNAPTICS(info->identity) ? 0 : -ENXIO; } /* * Read the model-id bytes from the touchpad * see also SYN_MODEL_* macros */ static int synaptics_model_id(struct psmouse *psmouse, struct synaptics_device_info *info) { return synaptics_query_int(psmouse, SYN_QUE_MODEL, &info->model_id); } /* * Read the firmware id from the touchpad */ static int synaptics_firmware_id(struct psmouse *psmouse, struct synaptics_device_info *info) { return synaptics_query_int(psmouse, SYN_QUE_FIRMWARE_ID, &info->firmware_id); } /* * Read the board id and the "More Extended Queries" from the touchpad * The board id is encoded in the "QUERY MODES" response */ static int synaptics_query_modes(struct psmouse *psmouse, struct synaptics_device_info *info) { u8 bid[3]; int error; /* firmwares prior 7.5 have no board_id encoded */ if (SYN_ID_FULL(info->identity) < 0x705) return 0; error = synaptics_send_cmd(psmouse, SYN_QUE_MODES, bid); if (error) return error; info->board_id = ((bid[0] & 0xfc) << 6) | bid[1]; if (SYN_MEXT_CAP_BIT(bid[0])) return synaptics_query_int(psmouse, SYN_QUE_MEXT_CAPAB_10, &info->ext_cap_10); return 0; } /* * Read the capability-bits from the touchpad * see also the SYN_CAP_* macros */ static int synaptics_capability(struct psmouse *psmouse, struct synaptics_device_info *info) { int error; error = synaptics_query_int(psmouse, SYN_QUE_CAPABILITIES, &info->capabilities); if (error) return error; info->ext_cap = info->ext_cap_0c = 0; /* * Older firmwares had submodel ID fixed to 0x47 */ if (SYN_ID_FULL(info->identity) < 0x705 && SYN_CAP_SUBMODEL_ID(info->capabilities) != 0x47) { return -ENXIO; } /* * Unless capExtended is set the rest of the flags should be ignored */ if (!SYN_CAP_EXTENDED(info->capabilities)) info->capabilities = 0; if (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 1) { error = synaptics_query_int(psmouse, SYN_QUE_EXT_CAPAB, &info->ext_cap); if (error) { psmouse_warn(psmouse, "device claims to have extended capabilities, but I'm not able to read them.\n"); } else { /* * if nExtBtn is greater than 8 it should be considered * invalid and treated as 0 */ if (SYN_CAP_MULTI_BUTTON_NO(info->ext_cap) > 8) info->ext_cap &= ~SYN_CAP_MB_MASK; } } if (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 4) { error = synaptics_query_int(psmouse, SYN_QUE_EXT_CAPAB_0C, &info->ext_cap_0c); if (error) psmouse_warn(psmouse, "device claims to have extended capability 0x0c, but I'm not able to read it.\n"); } return 0; } /* * 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_device_info *info) { u8 resp[3]; int error; if (SYN_ID_MAJOR(info->identity) < 4) return 0; error = synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, resp); if (!error) { if (resp[0] != 0 && (resp[1] & 0x80) && resp[2] != 0) { info->x_res = resp[0]; /* x resolution in units/mm */ info->y_res = resp[2]; /* y resolution in units/mm */ } } if (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 5 && SYN_CAP_MAX_DIMENSIONS(info->ext_cap_0c)) { error = synaptics_send_cmd(psmouse, SYN_QUE_EXT_MAX_COORDS, resp); if (error) { psmouse_warn(psmouse, "device claims to have max coordinates query, but I'm not able to read it.\n"); } else { info->x_max = (resp[0] << 5) | ((resp[1] & 0x0f) << 1); info->y_max = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3); psmouse_info(psmouse, "queried max coordinates: x [..%d], y [..%d]\n", info->x_max, info->y_max); } } if (SYN_CAP_MIN_DIMENSIONS(info->ext_cap_0c) && (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 7 || /* * Firmware v8.1 does not report proper number of extended * capabilities, but has been proven to report correct min * coordinates. */ SYN_ID_FULL(info->identity) == 0x801)) { error = synaptics_send_cmd(psmouse, SYN_QUE_EXT_MIN_COORDS, resp); if (error) { psmouse_warn(psmouse, "device claims to have min coordinates query, but I'm not able to read it.\n"); } else { info->x_min = (resp[0] << 5) | ((resp[1] & 0x0f) << 1); info->y_min = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3); psmouse_info(psmouse, "queried min coordinates: x [%d..], y [%d..]\n", info->x_min, info->y_min); } } return 0; } static int synaptics_query_hardware(struct psmouse *psmouse, struct synaptics_device_info *info) { int error; memset(info, 0, sizeof(*info)); error = synaptics_identify(psmouse, info); if (error) return error; error = synaptics_model_id(psmouse, info); if (error) return error; error = synaptics_firmware_id(psmouse, info); if (error) return error; error = synaptics_query_modes(psmouse, info); if (error) return error; error = synaptics_capability(psmouse, info); if (error) return error; error = synaptics_resolution(psmouse, info); if (error) return error; return 0; } #endif /* CONFIG_MOUSE_PS2_SYNAPTICS || CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS */ #ifdef CONFIG_MOUSE_PS2_SYNAPTICS static bool cr48_profile_sensor; #define ANY_BOARD_ID 0 struct min_max_quirk { const char * const *pnp_ids; struct { u32 min, max; } board_id; u32 x_min, x_max, y_min, y_max; }; static const struct min_max_quirk min_max_pnpid_table[] = { { (const char * const []){"LEN0033", NULL}, {ANY_BOARD_ID, ANY_BOARD_ID}, 1024, 5052, 2258, 4832 }, { (const char * const []){"LEN0042", NULL}, {ANY_BOARD_ID, ANY_BOARD_ID}, 1232, 5710, 1156, 4696 }, { (const char * const []){"LEN0034", "LEN0036", "LEN0037", "LEN0039", "LEN2002", "LEN2004", NULL}, {ANY_BOARD_ID, 2961}, 1024, 5112, 2024, 4832 }, { (const char * const []){"LEN2000", NULL}, {ANY_BOARD_ID, ANY_BOARD_ID},