···119119 enum psmouse_type type;120120 bool maxproto;121121 bool ignore_parity; /* Protocol should ignore parity errors from KBC */122122+ bool try_passthru; /* Try protocol also on passthrough ports */122123 const char *name;123124 const char *alias;124125 int (*detect)(struct psmouse *, bool);···130129 * psmouse_process_byte() analyzes the PS/2 data stream and reports131130 * relevant events to the input module once full packet has arrived.132131 */133133-134132psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)135133{136134 struct input_dev *dev = psmouse->dev;···138138 if (psmouse->pktcnt < psmouse->pktsize)139139 return PSMOUSE_GOOD_DATA;140140141141-/*142142- * Full packet accumulated, process it143143- */141141+ /* Full packet accumulated, process it */144142145145-/*146146- * Scroll wheel on IntelliMice, scroll buttons on NetMice147147- */148148-149149- if (psmouse->type == PSMOUSE_IMPS || psmouse->type == PSMOUSE_GENPS)143143+ switch (psmouse->type) {144144+ case PSMOUSE_IMPS:145145+ /* IntelliMouse has scroll wheel */150146 input_report_rel(dev, REL_WHEEL, -(signed char) packet[3]);147147+ break;151148152152-/*153153- * Scroll wheel and buttons on IntelliMouse Explorer154154- */155155-156156- if (psmouse->type == PSMOUSE_IMEX) {149149+ case PSMOUSE_IMEX:150150+ /* Scroll wheel and buttons on IntelliMouse Explorer */157151 switch (packet[3] & 0xC0) {158152 case 0x80: /* vertical scroll on IntelliMouse Explorer 4.0 */159153 input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 32) - (int) (packet[3] & 31));···162168 input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1);163169 break;164170 }165165- }171171+ break;166172167167-/*168168- * Extra buttons on Genius NewNet 3D169169- */173173+ case PSMOUSE_GENPS:174174+ /* Report scroll buttons on NetMice */175175+ input_report_rel(dev, REL_WHEEL, -(signed char) packet[3]);170176171171- if (psmouse->type == PSMOUSE_GENPS) {177177+ /* Extra buttons on Genius NewNet 3D */172178 input_report_key(dev, BTN_SIDE, (packet[0] >> 6) & 1);173179 input_report_key(dev, BTN_EXTRA, (packet[0] >> 7) & 1);174174- }180180+ break;175181176176-/*177177- * Extra button on ThinkingMouse178178- */179179- if (psmouse->type == PSMOUSE_THINKPS) {182182+ case PSMOUSE_THINKPS:183183+ /* Extra button on ThinkingMouse */180184 input_report_key(dev, BTN_EXTRA, (packet[0] >> 3) & 1);181181- /* Without this bit of weirdness moving up gives wildly high Y changes. */182182- packet[1] |= (packet[0] & 0x40) << 1;183183- }184185185185-/*186186- * Cortron PS2 Trackball reports SIDE button on the 4th bit of the first187187- * byte.188188- */189189- if (psmouse->type == PSMOUSE_CORTRON) {186186+ /*187187+ * Without this bit of weirdness moving up gives wildly188188+ * high Y changes.189189+ */190190+ packet[1] |= (packet[0] & 0x40) << 1;191191+ break;192192+193193+ case PSMOUSE_CORTRON:194194+ /*195195+ * Cortron PS2 Trackball reports SIDE button in the196196+ * 4th bit of the first byte.197197+ */190198 input_report_key(dev, BTN_SIDE, (packet[0] >> 3) & 1);191199 packet[0] |= 0x08;200200+ break;201201+202202+ default:203203+ break;192204 }193205194194-/*195195- * Generic PS/2 Mouse196196- */197197-206206+ /* Generic PS/2 Mouse */198207 input_report_key(dev, BTN_LEFT, packet[0] & 1);199208 input_report_key(dev, BTN_MIDDLE, (packet[0] >> 2) & 1);200209 input_report_key(dev, BTN_RIGHT, (packet[0] >> 1) & 1);···219222/*220223 * __psmouse_set_state() sets new psmouse state and resets all flags.221224 */222222-223225static inline void __psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state)224226{225227 psmouse->state = new_state;···227231 psmouse->last = jiffies;228232}229233230230-231234/*232235 * psmouse_set_state() sets new psmouse state and resets all flags and233236 * counters while holding serio lock so fighting with interrupt handler234237 * is not a concern.235238 */236236-237239void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state)238240{239241 serio_pause_rx(psmouse->ps2dev.serio);···243249 * psmouse_handle_byte() processes one byte of the input data stream244250 * by calling corresponding protocol handler.245251 */246246-247252static int psmouse_handle_byte(struct psmouse *psmouse)248253{249254 psmouse_ret_t rc = psmouse->protocol_handler(psmouse);···285292 * psmouse_interrupt() handles incoming characters, either passing them286293 * for normal processing or gathering them as command response.287294 */288288-289295static irqreturn_t psmouse_interrupt(struct serio *serio,290296 unsigned char data, unsigned int flags)291297{···327335 }328336329337 psmouse->packet[psmouse->pktcnt++] = data;330330-/*331331- * Check if this is a new device announcement (0xAA 0x00)332332- */338338+339339+ /* Check if this is a new device announcement (0xAA 0x00) */333340 if (unlikely(psmouse->packet[0] == PSMOUSE_RET_BAT && psmouse->pktcnt <= 2)) {334341 if (psmouse->pktcnt == 1) {335342 psmouse->last = jiffies;···342351 serio_reconnect(serio);343352 goto out;344353 }345345-/*346346- * Not a new device, try processing first byte normally347347- */354354+355355+ /* Not a new device, try processing first byte normally */348356 psmouse->pktcnt = 1;349357 if (psmouse_handle_byte(psmouse))350358 goto out;···351361 psmouse->packet[psmouse->pktcnt++] = data;352362 }353363354354-/*355355- * See if we need to force resync because mouse was idle for too long356356- */364364+ /*365365+ * See if we need to force resync because mouse was idle for366366+ * too long.367367+ */357368 if (psmouse->state == PSMOUSE_ACTIVATED &&358369 psmouse->pktcnt == 1 && psmouse->resync_time &&359370 time_after(jiffies, psmouse->last + psmouse->resync_time * HZ)) {···370379 out:371380 return IRQ_HANDLED;372381}373373-374382375383/*376384 * psmouse_sliced_command() sends an extended PS/2 command to the mouse···394404 return 0;395405}396406397397-398407/*399408 * psmouse_reset() resets the mouse into power-on state.400409 */···413424/*414425 * Here we set the mouse resolution.415426 */416416-417427void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution)418428{419429 static const unsigned char params[] = { 0, 1, 2, 2, 3 };···429441/*430442 * Here we set the mouse report rate.431443 */432432-433444static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate)434445{435446 static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 };···444457/*445458 * Here we set the mouse scaling.446459 */447447-448460static void psmouse_set_scale(struct psmouse *psmouse, enum psmouse_scale scale)449461{450462 ps2_command(&psmouse->ps2dev, NULL,···454468/*455469 * psmouse_poll() - default poll handler. Everyone except for ALPS uses it.456470 */457457-458471static int psmouse_poll(struct psmouse *psmouse)459472{460473 return ps2_command(&psmouse->ps2dev, psmouse->packet,···587602 if (param[0] != 4)588603 return -1;589604590590-/* Magic to enable horizontal scrolling on IntelliMouse 4.0 */605605+ /* Magic to enable horizontal scrolling on IntelliMouse 4.0 */591606 param[0] = 200;592607 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);593608 param[0] = 80;···657672 if (!psmouse->name)658673 psmouse->name = "Mouse";659674660660-/*661661- * We have no way of figuring true number of buttons so let's662662- * assume that the device has 3.663663- */675675+ /*676676+ * We have no way of figuring true number of buttons so let's677677+ * assume that the device has 3.678678+ */664679 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);665680 }666681···684699 return 0;685700}686701687687-/*688688- * Apply default settings to the psmouse structure. Most of them will689689- * be overridden by individual protocol initialization routines.690690- */691691-692692-static void psmouse_apply_defaults(struct psmouse *psmouse)693693-{694694- struct input_dev *input_dev = psmouse->dev;695695-696696- memset(input_dev->evbit, 0, sizeof(input_dev->evbit));697697- memset(input_dev->keybit, 0, sizeof(input_dev->keybit));698698- memset(input_dev->relbit, 0, sizeof(input_dev->relbit));699699- memset(input_dev->absbit, 0, sizeof(input_dev->absbit));700700- memset(input_dev->mscbit, 0, sizeof(input_dev->mscbit));701701-702702- __set_bit(EV_KEY, input_dev->evbit);703703- __set_bit(EV_REL, input_dev->evbit);704704-705705- __set_bit(BTN_LEFT, input_dev->keybit);706706- __set_bit(BTN_RIGHT, input_dev->keybit);707707-708708- __set_bit(REL_X, input_dev->relbit);709709- __set_bit(REL_Y, input_dev->relbit);710710-711711- __set_bit(INPUT_PROP_POINTER, input_dev->propbit);712712-713713- psmouse->set_rate = psmouse_set_rate;714714- psmouse->set_resolution = psmouse_set_resolution;715715- psmouse->set_scale = psmouse_set_scale;716716- psmouse->poll = psmouse_poll;717717- psmouse->protocol_handler = psmouse_process_byte;718718- psmouse->pktsize = 3;719719- psmouse->reconnect = NULL;720720- psmouse->disconnect = NULL;721721- psmouse->cleanup = NULL;722722- psmouse->pt_activate = NULL;723723- psmouse->pt_deactivate = NULL;724724-}725725-726726-/*727727- * Apply default settings to the psmouse structure and call specified728728- * protocol detection or initialization routine.729729- */730730-static int psmouse_do_detect(int (*detect)(struct psmouse *psmouse,731731- bool set_properties),732732- struct psmouse *psmouse, bool set_properties)733733-{734734- if (set_properties)735735- psmouse_apply_defaults(psmouse);736736-737737- return detect(psmouse, set_properties);738738-}739739-740740-/*741741- * psmouse_extensions() probes for any extensions to the basic PS/2 protocol742742- * the mouse may have.743743- */744744-745745-static int psmouse_extensions(struct psmouse *psmouse,746746- unsigned int max_proto, bool set_properties)747747-{748748- bool synaptics_hardware = false;749749-750750-/* Always check for focaltech, this is safe as it uses pnp-id matching */751751- if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) {752752- if (max_proto > PSMOUSE_IMEX) {753753- if (!set_properties || focaltech_init(psmouse) == 0) {754754- if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH))755755- return PSMOUSE_FOCALTECH;756756- /*757757- * Note that we need to also restrict758758- * psmouse_max_proto so that psmouse_initialize()759759- * does not try to reset rate and resolution,760760- * because even that upsets the device.761761- */762762- psmouse_max_proto = PSMOUSE_PS2;763763- return PSMOUSE_PS2;764764- }765765- }766766- }767767-768768-/*769769- * We always check for lifebook because it does not disturb mouse770770- * (it only checks DMI information).771771- */772772- if (psmouse_do_detect(lifebook_detect, psmouse, set_properties) == 0) {773773- if (max_proto > PSMOUSE_IMEX) {774774- if (!set_properties || lifebook_init(psmouse) == 0)775775- return PSMOUSE_LIFEBOOK;776776- }777777- }778778-779779- if (psmouse_do_detect(vmmouse_detect, psmouse, set_properties) == 0) {780780- if (max_proto > PSMOUSE_IMEX) {781781- if (!set_properties || vmmouse_init(psmouse) == 0)782782- return PSMOUSE_VMMOUSE;783783- }784784- }785785-786786-/*787787- * Try Kensington ThinkingMouse (we try first, because synaptics probe788788- * upsets the thinkingmouse).789789- */790790-791791- if (max_proto > PSMOUSE_IMEX &&792792- psmouse_do_detect(thinking_detect, psmouse, set_properties) == 0) {793793- return PSMOUSE_THINKPS;794794- }795795-796796-/*797797- * Try Synaptics TouchPad. Note that probing is done even if Synaptics protocol798798- * support is disabled in config - we need to know if it is synaptics so we799799- * can reset it properly after probing for intellimouse.800800- */801801- if (max_proto > PSMOUSE_PS2 &&802802- psmouse_do_detect(synaptics_detect, psmouse, set_properties) == 0) {803803- synaptics_hardware = true;804804-805805- if (max_proto > PSMOUSE_IMEX) {806806-/*807807- * Try activating protocol, but check if support is enabled first, since808808- * we try detecting Synaptics even when protocol is disabled.809809- */810810- if (IS_ENABLED(CONFIG_MOUSE_PS2_SYNAPTICS) &&811811- (!set_properties || synaptics_init(psmouse) == 0)) {812812- return PSMOUSE_SYNAPTICS;813813- }814814-815815-/*816816- * Some Synaptics touchpads can emulate extended protocols (like IMPS/2).817817- * Unfortunately Logitech/Genius probes confuse some firmware versions so818818- * we'll have to skip them.819819- */820820- max_proto = PSMOUSE_IMEX;821821- }822822-/*823823- * Make sure that touchpad is in relative mode, gestures (taps) are enabled824824- */825825- synaptics_reset(psmouse);826826- }827827-828828-/*829829- * Try Cypress Trackpad.830830- * Must try it before Finger Sensing Pad because Finger Sensing Pad probe831831- * upsets some modules of Cypress Trackpads.832832- */833833- if (max_proto > PSMOUSE_IMEX &&834834- cypress_detect(psmouse, set_properties) == 0) {835835- if (IS_ENABLED(CONFIG_MOUSE_PS2_CYPRESS)) {836836- if (cypress_init(psmouse) == 0)837837- return PSMOUSE_CYPRESS;838838-839839- /*840840- * Finger Sensing Pad probe upsets some modules of841841- * Cypress Trackpad, must avoid Finger Sensing Pad842842- * probe if Cypress Trackpad device detected.843843- */844844- return PSMOUSE_PS2;845845- }846846-847847- max_proto = PSMOUSE_IMEX;848848- }849849-850850-/*851851- * Try ALPS TouchPad852852- */853853- if (max_proto > PSMOUSE_IMEX) {854854- ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);855855- if (psmouse_do_detect(alps_detect,856856- psmouse, set_properties) == 0) {857857- if (!set_properties || alps_init(psmouse) == 0)858858- return PSMOUSE_ALPS;859859-/*860860- * Init failed, try basic relative protocols861861- */862862- max_proto = PSMOUSE_IMEX;863863- }864864- }865865-866866-/*867867- * Try OLPC HGPK touchpad.868868- */869869- if (max_proto > PSMOUSE_IMEX &&870870- psmouse_do_detect(hgpk_detect, psmouse, set_properties) == 0) {871871- if (!set_properties || hgpk_init(psmouse) == 0)872872- return PSMOUSE_HGPK;873873-/*874874- * Init failed, try basic relative protocols875875- */876876- max_proto = PSMOUSE_IMEX;877877- }878878-879879-/*880880- * Try Elantech touchpad.881881- */882882- if (max_proto > PSMOUSE_IMEX &&883883- psmouse_do_detect(elantech_detect, psmouse, set_properties) == 0) {884884- if (!set_properties || elantech_init(psmouse) == 0)885885- return PSMOUSE_ELANTECH;886886-/*887887- * Init failed, try basic relative protocols888888- */889889- max_proto = PSMOUSE_IMEX;890890- }891891-892892- if (max_proto > PSMOUSE_IMEX) {893893- if (psmouse_do_detect(genius_detect,894894- psmouse, set_properties) == 0)895895- return PSMOUSE_GENPS;896896-897897- if (psmouse_do_detect(ps2pp_init,898898- psmouse, set_properties) == 0)899899- return PSMOUSE_PS2PP;900900-901901- if (psmouse_do_detect(trackpoint_detect,902902- psmouse, set_properties) == 0)903903- return PSMOUSE_TRACKPOINT;904904-905905- if (psmouse_do_detect(touchkit_ps2_detect,906906- psmouse, set_properties) == 0)907907- return PSMOUSE_TOUCHKIT_PS2;908908- }909909-910910-/*911911- * Try Finger Sensing Pad. We do it here because its probe upsets912912- * Trackpoint devices (causing TP_READ_ID command to time out).913913- */914914- if (max_proto > PSMOUSE_IMEX) {915915- if (psmouse_do_detect(fsp_detect,916916- psmouse, set_properties) == 0) {917917- if (!set_properties || fsp_init(psmouse) == 0)918918- return PSMOUSE_FSP;919919-/*920920- * Init failed, try basic relative protocols921921- */922922- max_proto = PSMOUSE_IMEX;923923- }924924- }925925-926926-/*927927- * Reset to defaults in case the device got confused by extended928928- * protocol probes. Note that we follow up with full reset because929929- * some mice put themselves to sleep when they see PSMOUSE_RESET_DIS.930930- */931931- ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);932932- psmouse_reset(psmouse);933933-934934- if (max_proto >= PSMOUSE_IMEX &&935935- psmouse_do_detect(im_explorer_detect,936936- psmouse, set_properties) == 0) {937937- return PSMOUSE_IMEX;938938- }939939-940940- if (max_proto >= PSMOUSE_IMPS &&941941- psmouse_do_detect(intellimouse_detect,942942- psmouse, set_properties) == 0) {943943- return PSMOUSE_IMPS;944944- }945945-946946-/*947947- * Okay, all failed, we have a standard mouse here. The number of the buttons948948- * is still a question, though. We assume 3.949949- */950950- psmouse_do_detect(ps2bare_detect, psmouse, set_properties);951951-952952- if (synaptics_hardware) {953953-/*954954- * We detected Synaptics hardware but it did not respond to IMPS/2 probes.955955- * We need to reset the touchpad because if there is a track point on the956956- * pass through port it could get disabled while probing for protocol957957- * extensions.958958- */959959- psmouse_reset(psmouse);960960- }961961-962962- return PSMOUSE_PS2;963963-}964964-965702static const struct psmouse_protocol psmouse_protocols[] = {966703 {967704 .type = PSMOUSE_PS2,···692985 .maxproto = true,693986 .ignore_parity = true,694987 .detect = ps2bare_detect,988988+ .try_passthru = true,695989 },696990#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP697991 {698992 .type = PSMOUSE_PS2PP,699993 .name = "PS2++",700994 .alias = "logitech",701701- .detect = ps2pp_init,995995+ .detect = ps2pp_detect,702996 },703997#endif704998 {···7301022 .maxproto = true,7311023 .ignore_parity = true,7321024 .detect = intellimouse_detect,10251025+ .try_passthru = true,7331026 },7341027 {7351028 .type = PSMOUSE_IMEX,···7391030 .maxproto = true,7401031 .ignore_parity = true,7411032 .detect = im_explorer_detect,10331033+ .try_passthru = true,7421034 },7431035#ifdef CONFIG_MOUSE_PS2_SYNAPTICS7441036 {···7711061 .type = PSMOUSE_LIFEBOOK,7721062 .name = "LBPS/2",7731063 .alias = "lifebook",10641064+ .detect = lifebook_detect,7741065 .init = lifebook_init,7751066 },7761067#endif···7811070 .name = "TPPS/2",7821071 .alias = "trackpoint",7831072 .detect = trackpoint_detect,10731073+ .try_passthru = true,7841074 },7851075#endif7861076#ifdef CONFIG_MOUSE_PS2_TOUCHKIT···8501138 },8511139};8521140853853-static const struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type)11411141+static const struct psmouse_protocol *__psmouse_protocol_by_type(enum psmouse_type type)8541142{8551143 int i;85611448571145 for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++)8581146 if (psmouse_protocols[i].type == type)8591147 return &psmouse_protocols[i];11481148+11491149+ return NULL;11501150+}11511151+11521152+static const struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type)11531153+{11541154+ const struct psmouse_protocol *proto;11551155+11561156+ proto = __psmouse_protocol_by_type(type);11571157+ if (proto)11581158+ return proto;86011598611160 WARN_ON(1);8621161 return &psmouse_protocols[0];···8891166 return NULL;8901167}891116811691169+/*11701170+ * Apply default settings to the psmouse structure. Most of them will11711171+ * be overridden by individual protocol initialization routines.11721172+ */11731173+static void psmouse_apply_defaults(struct psmouse *psmouse)11741174+{11751175+ struct input_dev *input_dev = psmouse->dev;11761176+11771177+ memset(input_dev->evbit, 0, sizeof(input_dev->evbit));11781178+ memset(input_dev->keybit, 0, sizeof(input_dev->keybit));11791179+ memset(input_dev->relbit, 0, sizeof(input_dev->relbit));11801180+ memset(input_dev->absbit, 0, sizeof(input_dev->absbit));11811181+ memset(input_dev->mscbit, 0, sizeof(input_dev->mscbit));11821182+11831183+ __set_bit(EV_KEY, input_dev->evbit);11841184+ __set_bit(EV_REL, input_dev->evbit);11851185+11861186+ __set_bit(BTN_LEFT, input_dev->keybit);11871187+ __set_bit(BTN_RIGHT, input_dev->keybit);11881188+11891189+ __set_bit(REL_X, input_dev->relbit);11901190+ __set_bit(REL_Y, input_dev->relbit);11911191+11921192+ __set_bit(INPUT_PROP_POINTER, input_dev->propbit);11931193+11941194+ psmouse->set_rate = psmouse_set_rate;11951195+ psmouse->set_resolution = psmouse_set_resolution;11961196+ psmouse->set_scale = psmouse_set_scale;11971197+ psmouse->poll = psmouse_poll;11981198+ psmouse->protocol_handler = psmouse_process_byte;11991199+ psmouse->pktsize = 3;12001200+ psmouse->reconnect = NULL;12011201+ psmouse->disconnect = NULL;12021202+ psmouse->cleanup = NULL;12031203+ psmouse->pt_activate = NULL;12041204+ psmouse->pt_deactivate = NULL;12051205+}12061206+12071207+static bool psmouse_try_protocol(struct psmouse *psmouse,12081208+ enum psmouse_type type,12091209+ unsigned int *max_proto,12101210+ bool set_properties, bool init_allowed)12111211+{12121212+ const struct psmouse_protocol *proto;12131213+12141214+ proto = __psmouse_protocol_by_type(type);12151215+ if (!proto)12161216+ return false;12171217+12181218+ if (psmouse->ps2dev.serio->id.type == SERIO_PS_PSTHRU &&12191219+ !proto->try_passthru) {12201220+ return false;12211221+ }12221222+12231223+ if (set_properties)12241224+ psmouse_apply_defaults(psmouse);12251225+12261226+ if (proto->detect(psmouse, set_properties) != 0)12271227+ return false;12281228+12291229+ if (set_properties && proto->init && init_allowed) {12301230+ if (proto->init(psmouse) != 0) {12311231+ /*12321232+ * We detected device, but init failed. Adjust12331233+ * max_proto so we only try standard protocols.12341234+ */12351235+ if (*max_proto > PSMOUSE_IMEX)12361236+ *max_proto = PSMOUSE_IMEX;12371237+12381238+ return false;12391239+ }12401240+ }12411241+12421242+ return true;12431243+}12441244+12451245+/*12461246+ * psmouse_extensions() probes for any extensions to the basic PS/2 protocol12471247+ * the mouse may have.12481248+ */12491249+static int psmouse_extensions(struct psmouse *psmouse,12501250+ unsigned int max_proto, bool set_properties)12511251+{12521252+ bool synaptics_hardware = false;12531253+12541254+ /*12551255+ * Always check for focaltech, this is safe as it uses pnp-id12561256+ * matching.12571257+ */12581258+ if (psmouse_try_protocol(psmouse, PSMOUSE_FOCALTECH,12591259+ &max_proto, set_properties, false)) {12601260+ if (max_proto > PSMOUSE_IMEX &&12611261+ IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH) &&12621262+ (!set_properties || focaltech_init(psmouse) == 0)) {12631263+ return PSMOUSE_FOCALTECH;12641264+ }12651265+ /*12661266+ * Restrict psmouse_max_proto so that psmouse_initialize()12671267+ * does not try to reset rate and resolution, because even12681268+ * that upsets the device.12691269+ * This also causes us to basically fall through to basic12701270+ * protocol detection, where we fully reset the mouse,12711271+ * and set it up as bare PS/2 protocol device.12721272+ */12731273+ psmouse_max_proto = max_proto = PSMOUSE_PS2;12741274+ }12751275+12761276+ /*12771277+ * We always check for LifeBook because it does not disturb mouse12781278+ * (it only checks DMI information).12791279+ */12801280+ if (psmouse_try_protocol(psmouse, PSMOUSE_LIFEBOOK, &max_proto,12811281+ set_properties, max_proto > PSMOUSE_IMEX))12821282+ return PSMOUSE_LIFEBOOK;12831283+12841284+ if (psmouse_try_protocol(psmouse, PSMOUSE_VMMOUSE, &max_proto,12851285+ set_properties, max_proto > PSMOUSE_IMEX))12861286+ return PSMOUSE_VMMOUSE;12871287+12881288+ /*12891289+ * Try Kensington ThinkingMouse (we try first, because Synaptics12901290+ * probe upsets the ThinkingMouse).12911291+ */12921292+ if (max_proto > PSMOUSE_IMEX &&12931293+ psmouse_try_protocol(psmouse, PSMOUSE_THINKPS, &max_proto,12941294+ set_properties, true)) {12951295+ return PSMOUSE_THINKPS;12961296+ }12971297+12981298+ /*12991299+ * Try Synaptics TouchPad. Note that probing is done even if13001300+ * Synaptics protocol support is disabled in config - we need to13011301+ * know if it is Synaptics so we can reset it properly after13021302+ * probing for IntelliMouse.13031303+ */13041304+ if (max_proto > PSMOUSE_PS2 &&13051305+ psmouse_try_protocol(psmouse, PSMOUSE_SYNAPTICS, &max_proto,13061306+ set_properties, false)) {13071307+ synaptics_hardware = true;13081308+13091309+ if (max_proto > PSMOUSE_IMEX) {13101310+ /*13111311+ * Try activating protocol, but check if support is13121312+ * enabled first, since we try detecting Synaptics13131313+ * even when protocol is disabled.13141314+ */13151315+ if (IS_ENABLED(CONFIG_MOUSE_PS2_SYNAPTICS) &&13161316+ (!set_properties || synaptics_init(psmouse) == 0)) {13171317+ return PSMOUSE_SYNAPTICS;13181318+ }13191319+13201320+ /*13211321+ * Some Synaptics touchpads can emulate extended13221322+ * protocols (like IMPS/2). Unfortunately13231323+ * Logitech/Genius probes confuse some firmware13241324+ * versions so we'll have to skip them.13251325+ */13261326+ max_proto = PSMOUSE_IMEX;13271327+ }13281328+13291329+ /*13301330+ * Make sure that touchpad is in relative mode, gestures13311331+ * (taps) are enabled.13321332+ */13331333+ synaptics_reset(psmouse);13341334+ }13351335+13361336+ /*13371337+ * Try Cypress Trackpad. We must try it before Finger Sensing Pad13381338+ * because Finger Sensing Pad probe upsets some modules of Cypress13391339+ * Trackpads.13401340+ */13411341+ if (max_proto > PSMOUSE_IMEX &&13421342+ psmouse_try_protocol(psmouse, PSMOUSE_CYPRESS, &max_proto,13431343+ set_properties, true)) {13441344+ return PSMOUSE_CYPRESS;13451345+ }13461346+13471347+ /* Try ALPS TouchPad */13481348+ if (max_proto > PSMOUSE_IMEX) {13491349+ ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);13501350+ if (psmouse_try_protocol(psmouse, PSMOUSE_ALPS,13511351+ &max_proto, set_properties, true))13521352+ return PSMOUSE_ALPS;13531353+ }13541354+13551355+ /* Try OLPC HGPK touchpad */13561356+ if (max_proto > PSMOUSE_IMEX &&13571357+ psmouse_try_protocol(psmouse, PSMOUSE_HGPK, &max_proto,13581358+ set_properties, true)) {13591359+ return PSMOUSE_HGPK;13601360+ }13611361+13621362+ /* Try Elantech touchpad */13631363+ if (max_proto > PSMOUSE_IMEX &&13641364+ psmouse_try_protocol(psmouse, PSMOUSE_ELANTECH,13651365+ &max_proto, set_properties, true)) {13661366+ return PSMOUSE_ELANTECH;13671367+ }13681368+13691369+ if (max_proto > PSMOUSE_IMEX) {13701370+ if (psmouse_try_protocol(psmouse, PSMOUSE_GENPS,13711371+ &max_proto, set_properties, true))13721372+ return PSMOUSE_GENPS;13731373+13741374+ if (psmouse_try_protocol(psmouse, PSMOUSE_PS2PP,13751375+ &max_proto, set_properties, true))13761376+ return PSMOUSE_PS2PP;13771377+13781378+ if (psmouse_try_protocol(psmouse, PSMOUSE_TRACKPOINT,13791379+ &max_proto, set_properties, true))13801380+ return PSMOUSE_TRACKPOINT;13811381+13821382+ if (psmouse_try_protocol(psmouse, PSMOUSE_TOUCHKIT_PS2,13831383+ &max_proto, set_properties, true))13841384+ return PSMOUSE_TOUCHKIT_PS2;13851385+ }13861386+13871387+ /*13881388+ * Try Finger Sensing Pad. We do it here because its probe upsets13891389+ * Trackpoint devices (causing TP_READ_ID command to time out).13901390+ */13911391+ if (max_proto > PSMOUSE_IMEX &&13921392+ psmouse_try_protocol(psmouse, PSMOUSE_FSP,13931393+ &max_proto, set_properties, true)) {13941394+ return PSMOUSE_FSP;13951395+ }13961396+13971397+ /*13981398+ * Reset to defaults in case the device got confused by extended13991399+ * protocol probes. Note that we follow up with full reset because14001400+ * some mice put themselves to sleep when they see PSMOUSE_RESET_DIS.14011401+ */14021402+ ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);14031403+ psmouse_reset(psmouse);14041404+14051405+ if (max_proto >= PSMOUSE_IMEX &&14061406+ psmouse_try_protocol(psmouse, PSMOUSE_IMEX,14071407+ &max_proto, set_properties, true)) {14081408+ return PSMOUSE_IMEX;14091409+ }14101410+14111411+ if (max_proto >= PSMOUSE_IMPS &&14121412+ psmouse_try_protocol(psmouse, PSMOUSE_IMPS,14131413+ &max_proto, set_properties, true)) {14141414+ return PSMOUSE_IMPS;14151415+ }14161416+14171417+ /*14181418+ * Okay, all failed, we have a standard mouse here. The number of14191419+ * the buttons is still a question, though. We assume 3.14201420+ */14211421+ psmouse_try_protocol(psmouse, PSMOUSE_PS2,14221422+ &max_proto, set_properties, true);14231423+14241424+ if (synaptics_hardware) {14251425+ /*14261426+ * We detected Synaptics hardware but it did not respond to14271427+ * IMPS/2 probes. We need to reset the touchpad because if14281428+ * there is a track point on the pass through port it could14291429+ * get disabled while probing for protocol extensions.14301430+ */14311431+ psmouse_reset(psmouse);14321432+ }14331433+14341434+ return PSMOUSE_PS2;14351435+}89214368931437/*8941438 * psmouse_probe() probes for a PS/2 mouse.8951439 */896896-8971440static int psmouse_probe(struct psmouse *psmouse)8981441{8991442 struct ps2dev *ps2dev = &psmouse->ps2dev;9001443 unsigned char param[2];9011444902902-/*903903- * First, we check if it's a mouse. It should send 0x00 or 0x03904904- * in case of an IntelliMouse in 4-byte mode or 0x04 for IM Explorer.905905- * Sunrex K8561 IR Keyboard/Mouse reports 0xff on second and subsequent906906- * ID queries, probably due to a firmware bug.907907- */908908-14451445+ /*14461446+ * First, we check if it's a mouse. It should send 0x00 or 0x03 in14471447+ * case of an IntelliMouse in 4-byte mode or 0x04 for IM Explorer.14481448+ * Sunrex K8561 IR Keyboard/Mouse reports 0xff on second and14491449+ * subsequent ID queries, probably due to a firmware bug.14501450+ */9091451 param[0] = 0xa5;9101452 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETID))9111453 return -1;···11791191 param[0] != 0x04 && param[0] != 0xff)11801192 return -1;1181119311821182-/*11831183- * Then we reset and disable the mouse so that it doesn't generate events.11841184- */11851185-11941194+ /*11951195+ * Then we reset and disable the mouse so that it doesn't generate11961196+ * events.11971197+ */11861198 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_DIS))11871199 psmouse_warn(psmouse, "Failed to reset mouse on %s\n",11881200 ps2dev->serio->phys);···11931205/*11941206 * psmouse_initialize() initializes the mouse to a sane state.11951207 */11961196-11971208static void psmouse_initialize(struct psmouse *psmouse)11981209{11991199-/*12001200- * We set the mouse report rate, resolution and scaling.12011201- */12021202-12101210+ /*12111211+ * We set the mouse report rate, resolution and scaling.12121212+ */12031213 if (psmouse_max_proto != PSMOUSE_PS2) {12041214 psmouse->set_rate(psmouse, psmouse->rate);12051215 psmouse->set_resolution(psmouse, psmouse->resolution);···12081222/*12091223 * psmouse_activate() enables the mouse so that we get motion reports from it.12101224 */12111211-12121225int psmouse_activate(struct psmouse *psmouse)12131226{12141227 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE)) {···12211236}1222123712231238/*12241224- * psmouse_deactivate() puts the mouse into poll mode so that we don't get motion12251225- * reports from it unless we explicitly request it.12391239+ * psmouse_deactivate() puts the mouse into poll mode so that we don't get12401240+ * motion reports from it unless we explicitly request it.12261241 */12271227-12281242int psmouse_deactivate(struct psmouse *psmouse)12291243{12301244 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_DISABLE)) {···12361252 return 0;12371253}1238125412391239-12401255/*12411256 * psmouse_resync() attempts to re-validate current protocol.12421257 */12431243-12441258static void psmouse_resync(struct work_struct *work)12451259{12461260 struct psmouse *parent = NULL, *psmouse =···12581276 psmouse_deactivate(parent);12591277 }1260127812611261-/*12621262- * Some mice don't ACK commands sent while they are in the middle of12631263- * transmitting motion packet. To avoid delay we use ps2_sendbyte()12641264- * instead of ps2_command() which would wait for 200ms for an ACK12651265- * that may never come.12661266- * As an additional quirk ALPS touchpads may not only forget to ACK12671267- * disable command but will stop reporting taps, so if we see that12681268- * mouse at least once ACKs disable we will do full reconnect if ACK12691269- * is missing.12701270- */12791279+ /*12801280+ * Some mice don't ACK commands sent while they are in the middle of12811281+ * transmitting motion packet. To avoid delay we use ps2_sendbyte()12821282+ * instead of ps2_command() which would wait for 200ms for an ACK12831283+ * that may never come.12841284+ * As an additional quirk ALPS touchpads may not only forget to ACK12851285+ * disable command but will stop reporting taps, so if we see that12861286+ * mouse at least once ACKs disable we will do full reconnect if ACK12871287+ * is missing.12881288+ */12711289 psmouse->num_resyncs++;1272129012731291 if (ps2_sendbyte(&psmouse->ps2dev, PSMOUSE_CMD_DISABLE, 20)) {···12761294 } else12771295 psmouse->acks_disable_command = true;1278129612791279-/*12801280- * Poll the mouse. If it was reset the packet will be shorter than12811281- * psmouse->pktsize and ps2_command will fail. We do not expect and12821282- * do not handle scenario when mouse "upgrades" its protocol while12831283- * disconnected since it would require additional delay. If we ever12841284- * see a mouse that does it we'll adjust the code.12851285- */12971297+ /*12981298+ * Poll the mouse. If it was reset the packet will be shorter than12991299+ * psmouse->pktsize and ps2_command will fail. We do not expect and13001300+ * do not handle scenario when mouse "upgrades" its protocol while13011301+ * disconnected since it would require additional delay. If we ever13021302+ * see a mouse that does it we'll adjust the code.13031303+ */12861304 if (!failed) {12871305 if (psmouse->poll(psmouse))12881306 failed = true;···12991317 psmouse_set_state(psmouse, PSMOUSE_RESYNCING);13001318 }13011319 }13021302-/*13031303- * Now try to enable mouse. We try to do that even if poll failed and also13041304- * repeat our attempts 5 times, otherwise we may be left out with disabled13051305- * mouse.13061306- */13201320+13211321+ /*13221322+ * Now try to enable mouse. We try to do that even if poll failed13231323+ * and also repeat our attempts 5 times, otherwise we may be left13241324+ * out with disabled mouse.13251325+ */13071326 for (i = 0; i < 5; i++) {13081327 if (!ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE)) {13091328 enabled = true;···13361353/*13371354 * psmouse_cleanup() resets the mouse into power-on state.13381355 */13391339-13401356static void psmouse_cleanup(struct serio *serio)13411357{13421358 struct psmouse *psmouse = serio_get_drvdata(serio);···13601378 if (psmouse->cleanup)13611379 psmouse->cleanup(psmouse);1362138013631363-/*13641364- * Reset the mouse to defaults (bare PS/2 protocol).13651365- */13811381+ /*13821382+ * Reset the mouse to defaults (bare PS/2 protocol).13831383+ */13661384 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);1367138513681368-/*13691369- * Some boxes, such as HP nx7400, get terribly confused if mouse13701370- * is not fully enabled before suspending/shutting down.13711371- */13861386+ /*13871387+ * Some boxes, such as HP nx7400, get terribly confused if mouse13881388+ * is not fully enabled before suspending/shutting down.13891389+ */13721390 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);1373139113741392 if (parent) {···13841402/*13851403 * psmouse_disconnect() closes and frees.13861404 */13871387-13881405static void psmouse_disconnect(struct serio *serio)13891406{13901407 struct psmouse *psmouse, *parent = NULL;···15821601 retval = error;15831602 goto out;15841603}15851585-1586160415871605static int psmouse_reconnect(struct serio *serio)15881606{