--- stable/sys/dev/atkbdc/orig 2015-12-01 08:36:40.731288000 +0100 +++ stable/sys/dev/atkbdc/psm.c 2015-12-01 08:48:37.394017000 +0100 @@ -458,7 +458,8 @@ u_char *); /* vendor specific features */ -typedef int probefunc_t(KBDC, struct psm_softc *); +enum probearg { PROBE, REINIT }; +typedef int probefunc_t(struct psm_softc *, enum probearg); static int mouse_id_proc1(KBDC, int, int, int *); static int mouse_ext_command(KBDC, int); @@ -876,7 +877,7 @@ /* Re-enable the mouse. */ for (i = 0; vendortype[i].probefunc != NULL; ++i) if (vendortype[i].model == sc->hw.model) - (*vendortype[i].probefunc)(sc->kbdc, NULL); + (*vendortype[i].probefunc)(sc, REINIT); /* set mouse parameters */ if (mode != (mousemode_t *)NULL) { @@ -887,13 +888,6 @@ set_mouse_resolution(kbdc, mode->resolution); set_mouse_scaling(kbdc, 1); set_mouse_mode(kbdc); - - /* - * Trackpoint settings are lost on resume. - * Restore them here. - */ - if (sc->tphw > 0) - set_trackpoint_parameters(sc); } /* Record sync on the next data packet we see. */ @@ -1383,7 +1377,7 @@ /* other parameters */ for (i = 0; vendortype[i].probefunc != NULL; ++i) - if ((*vendortype[i].probefunc)(sc->kbdc, sc)) { + if ((*vendortype[i].probefunc)(sc, PROBE)) { if (verbose >= 2) printf("psm%d: found %s\n", unit, model_name(vendortype[i].model)); @@ -3710,8 +3704,9 @@ #ifdef notyet /* Logitech MouseMan Cordless II */ static int -enable_lcordless(KDBC kbdc, struct psm_softc *sc) +enable_lcordless(struct psm_softc *sc, enum probearg arg) { + KBDC kbdc = sc->kbdc; int status[3]; int ch; @@ -3732,8 +3727,9 @@ /* Genius NetScroll Mouse, MouseSystems SmartScroll Mouse */ static int -enable_groller(KBDC kbdc, struct psm_softc *sc) +enable_groller(struct psm_softc *sc, enum probearg arg) { + KBDC kbdc = sc->kbdc; int status[3]; /* @@ -3762,15 +3758,16 @@ if ((status[1] != '3') || (status[2] != 'D')) return (FALSE); /* FIXME: SmartScroll Mouse has 5 buttons! XXX */ - if (sc != NULL) + if (arg == PROBE) sc->hw.buttons = 4; return (TRUE); } /* Genius NetMouse/NetMouse Pro, ASCII Mie Mouse, NetScroll Optical */ static int -enable_gmouse(KBDC kbdc, struct psm_softc *sc) +enable_gmouse(struct psm_softc *sc, enum probearg arg) { + KBDC kbdc = sc->kbdc; int status[3]; /* @@ -3792,8 +3789,9 @@ /* ALPS GlidePoint */ static int -enable_aglide(KBDC kbdc, struct psm_softc *sc) +enable_aglide(struct psm_softc *sc, enum probearg arg) { + KBDC kbdc = sc->kbdc; int status[3]; /* @@ -3814,9 +3812,10 @@ /* Kensington ThinkingMouse/Trackball */ static int -enable_kmouse(KBDC kbdc, struct psm_softc *sc) +enable_kmouse(struct psm_softc *sc, enum probearg arg) { static u_char rate[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20 }; + KBDC kbdc = sc->kbdc; int status[3]; int id1; int id2; @@ -3867,8 +3866,9 @@ /* Logitech MouseMan+/FirstMouse+, IBM ScrollPoint Mouse */ static int -enable_mmanplus(KBDC kbdc, struct psm_softc *sc) +enable_mmanplus(struct psm_softc *sc, enum probearg arg) { + KBDC kbdc = sc->kbdc; int data[3]; /* the special sequence to enable the fourth button and the roller. */ @@ -3909,7 +3909,7 @@ if (MOUSE_PS2PLUS_PACKET_TYPE(data) != 0) return (FALSE); - if (sc != NULL) { + if (arg == PROBE) { sc->hw.hwid &= 0x00ff; sc->hw.hwid |= data[2] << 8; /* save model ID */ } @@ -3925,8 +3925,9 @@ /* MS IntelliMouse Explorer */ static int -enable_msexplorer(KBDC kbdc, struct psm_softc *sc) +enable_msexplorer(struct psm_softc *sc, enum probearg arg) { + KBDC kbdc = sc->kbdc; static u_char rate0[] = { 200, 100, 80, }; static u_char rate1[] = { 200, 200, 80, }; int id; @@ -3937,7 +3938,7 @@ * straight to Explorer mode, but need to be set to Intelli mode * first. */ - enable_msintelli(kbdc, sc); + enable_msintelli(sc, arg); /* the special sequence to enable the extra buttons and the roller. */ for (i = 0; i < sizeof(rate1)/sizeof(rate1[0]); ++i) @@ -3948,7 +3949,7 @@ if (id != PSM_EXPLORER_ID) return (FALSE); - if (sc != NULL) { + if (arg == PROBE) { sc->hw.buttons = 5; /* IntelliMouse Explorer XXX */ sc->hw.hwid = id; } @@ -3971,15 +3972,15 @@ return (TRUE); } -/* MS IntelliMouse */ +/* + * MS IntelliMouse + * Logitech MouseMan+ and FirstMouse+ will also respond to this + * probe routine and act like IntelliMouse. + */ static int -enable_msintelli(KBDC kbdc, struct psm_softc *sc) +enable_msintelli(struct psm_softc *sc, enum probearg arg) { - /* - * Logitech MouseMan+ and FirstMouse+ will also respond to this - * probe routine and act like IntelliMouse. - */ - + KBDC kbdc = sc->kbdc; static u_char rate[] = { 200, 100, 80, }; int id; int i; @@ -3993,7 +3994,7 @@ if (id != PSM_INTELLI_ID) return (FALSE); - if (sc != NULL) { + if (arg == PROBE) { sc->hw.buttons = 3; sc->hw.hwid = id; } @@ -4001,15 +4002,15 @@ return (TRUE); } -/* A4 Tech 4D Mouse */ +/* + * A4 Tech 4D Mouse + * Newer wheel mice from A4 Tech may use the 4D+ protocol. + */ static int -enable_4dmouse(KBDC kbdc, struct psm_softc *sc) +enable_4dmouse(struct psm_softc *sc, enum probearg arg) { - /* - * Newer wheel mice from A4 Tech may use the 4D+ protocol. - */ - static u_char rate[] = { 200, 100, 80, 60, 40, 20 }; + KBDC kbdc = sc->kbdc; int id; int i; @@ -4025,7 +4026,7 @@ if (id != PSM_4DMOUSE_ID) return (FALSE); - if (sc != NULL) { + if (arg == PROBE) { sc->hw.buttons = 3; /* XXX some 4D mice have 4? */ sc->hw.hwid = id; } @@ -4033,14 +4034,15 @@ return (TRUE); } -/* A4 Tech 4D+ Mouse */ +/* + * A4 Tech 4D+ Mouse + * Newer wheel mice from A4 Tech seem to use this protocol. + * Older models are recognized as either 4D Mouse or IntelliMouse. + */ static int -enable_4dplus(KBDC kbdc, struct psm_softc *sc) +enable_4dplus(struct psm_softc *sc, enum probearg arg) { - /* - * Newer wheel mice from A4 Tech seem to use this protocol. - * Older models are recognized as either 4D Mouse or IntelliMouse. - */ + KBDC kbdc = sc->kbdc; int id; /* @@ -4063,7 +4065,7 @@ return (FALSE); } - if (sc != NULL) { + if (arg == PROBE) { sc->hw.buttons = (id == PSM_4DPLUS_ID) ? 4 : 3; sc->hw.hwid = id; } @@ -4484,8 +4486,9 @@ } static int -enable_synaptics(KBDC kbdc, struct psm_softc *sc) +enable_synaptics(struct psm_softc *sc, enum probearg arg) { + KBDC kbdc = sc->kbdc; synapticshw_t synhw; int status[3]; int buttons; @@ -4690,7 +4693,7 @@ return (FALSE); } - if (sc != NULL) + if (arg == PROBE) sc->synhw = synhw; if (!synaptics_support) return (FALSE); @@ -4701,14 +4704,15 @@ /* "Commit" the Set Mode Byte command sent above. */ set_mouse_sampling_rate(kbdc, 20); + if (trackpoint_support && synhw.capPassthrough) { + synaptics_passthrough_on(sc); + enable_trackpoint(sc, arg); + synaptics_passthrough_off(sc); + } + VLOG(3, (LOG_DEBUG, "synaptics: END init (%d buttons)\n", buttons)); - if (sc != NULL) { - if (trackpoint_support && synhw.capPassthrough) { - synaptics_passthrough_on(sc); - enable_trackpoint(kbdc, sc); - synaptics_passthrough_off(sc); - } + if (arg == PROBE) { /* Create sysctl tree. */ synaptics_sysctl_create_tree(sc); sc->hw.buttons = buttons; @@ -4966,8 +4970,9 @@ } static int -enable_trackpoint(KBDC kbdc, struct psm_softc *sc) +enable_trackpoint(struct psm_softc *sc, enum probearg arg) { + KBDC kbdc = sc->kbdc; int id; if (send_aux_command(kbdc, 0xe1) != PSM_ACK || @@ -4981,10 +4986,8 @@ if (!trackpoint_support) return (FALSE); - if (sc != NULL) { - /* Create sysctl tree. */ + if (arg == PROBE) { trackpoint_sysctl_create_tree(sc); - /* * Don't overwrite hwid and buttons when we are * a guest device. @@ -4995,13 +4998,16 @@ } } + set_trackpoint_parameters(sc); + return (TRUE); } /* Interlink electronics VersaPad */ static int -enable_versapad(KBDC kbdc, struct psm_softc *sc) +enable_versapad(struct psm_softc *sc, enum probearg arg) { + KBDC kbdc = sc->kbdc; int data[3]; set_mouse_resolution(kbdc, PSMD_RES_MEDIUM_HIGH); /* set res. 2 */