Moving bugs@ and Matthieu to BCC, addings tech@. Since no one else has fixed this yet, I did. This bug is a combination or two things. 1.) When a wsmouse goes away on a KVM, it becomes detached, but not disconnected, and 2.) some mice still have things to be read (or think they do) when they're detached. Wskbd does the right thing here, and disconnects from wsdisplay when the keyboard detached. >From the code, it looks like wsmux also does the right thing. However, the wskbd disconnect mechanism is tied to the console/console keyboard mechanism. Having a console mouse as a concept does not make much sense (except moused?), however this was the easiest code path to hook into.
Problems I need to solve: 1.) Why does my mouse not attach to a wsmux? My dmesg is currently full of garbage, how can I get a clean dmesg (other than rebooting). Also, how do I debug why my mouse isn't attaching to a wsmux appropriately? >From reading the wscons code, it seems like this would be the best solution to my problem, and remove the need for this patch. 2.) What is the proper codepath to hook into during the ums detach to trigger the disconnect? I wasn't having luck figuring out the right place to skip faking a console mouse. Can someone with experience in the usb/wscons stack chime in here? 3.) The mouse ends up starting disconnected with this patch, and needs a KVM toggle back and forth to get a connect triggered on top of an attach. What did I mess up while attaching here? Diff linked and inlined: http://ix.io/A2u --- Index: sys/dev/hid/hidms.c =================================================================== RCS file: /cvs/src/sys/dev/hid/hidms.c,v retrieving revision 1.3 diff -u -p -u -p -r1.3 hidms.c --- sys/dev/hid/hidms.c 22 May 2016 22:06:11 -0000 1.3 +++ sys/dev/hid/hidms.c 20 Sep 2017 01:49:39 -0000 @@ -61,6 +61,8 @@ int hidmsdebug = 0; #define MOUSE_FLAGS_MASK (HIO_CONST | HIO_RELATIVE) #define NOTMOUSE(f) (((f) & MOUSE_FLAGS_MASK) != HIO_RELATIVE) +int hidms_is_console; + int hidms_setup(struct device *self, struct hidms *ms, uint32_t quirks, int id, void *desc, int dlen) @@ -259,7 +261,7 @@ hidms_setup(struct device *self, struct } void -hidms_attach(struct hidms *ms, const struct wsmouse_accessops *ops) +hidms_attach(struct hidms *ms, const struct wsmouse_accessops *ops, int console) { struct wsmousedev_attach_args a; #ifdef HIDMS_DEBUG Index: sys/dev/hid/hidmsvar.h =================================================================== RCS file: /cvs/src/sys/dev/hid/hidmsvar.h,v retrieving revision 1.1 diff -u -p -u -p -r1.1 hidmsvar.h --- sys/dev/hid/hidmsvar.h 8 Jan 2016 15:54:13 -0000 1.1 +++ sys/dev/hid/hidmsvar.h 20 Sep 2017 01:49:39 -0000 @@ -69,11 +69,13 @@ struct hidms { struct hid_location sc_loc_w; struct hid_location sc_loc_btn[MAX_BUTTONS]; + char sc_console_mouse; /* we are the console mouse */ + struct tsscale sc_tsscale; int sc_rawmode; }; -void hidms_attach(struct hidms *, const struct wsmouse_accessops *); +void hidms_attach(struct hidms *, const struct wsmouse_accessops *, int console); int hidms_detach(struct hidms *, int); void hidms_disable(struct hidms *); int hidms_enable(struct hidms *); Index: sys/dev/i2c/iatp.c =================================================================== RCS file: /cvs/src/sys/dev/i2c/iatp.c,v retrieving revision 1.3 diff -u -p -u -p -r1.3 iatp.c --- sys/dev/i2c/iatp.c 24 Sep 2016 18:32:18 -0000 1.3 +++ sys/dev/i2c/iatp.c 20 Sep 2017 01:49:39 -0000 @@ -196,7 +196,7 @@ int iatp_detach(struct device *, int); int iatp_activate(struct device *, int); int iatp_ioctl(void *, u_long, caddr_t, int, struct proc *); -int iatp_enable(void *); +int iatp_enable(void *, int); void iatp_disable(void *); int iatp_read_reg(struct iatp_softc *, uint16_t, size_t, void *); @@ -319,7 +319,7 @@ iatp_activate(struct device *self, int a } int -iatp_enable(void *v) +iatp_enable(void *v, int on /* unused */) { struct iatp_softc *sc = v; Index: sys/dev/i2c/ims.c =================================================================== RCS file: /cvs/src/sys/dev/i2c/ims.c,v retrieving revision 1.1 diff -u -p -u -p -r1.1 ims.c --- sys/dev/i2c/ims.c 12 Jan 2016 01:11:15 -0000 1.1 +++ sys/dev/i2c/ims.c 20 Sep 2017 01:49:39 -0000 @@ -39,7 +39,7 @@ struct ims_softc { void ims_intr(struct ihidev *addr, void *ibuf, u_int len); -int ims_enable(void *); +int ims_enable(void *, int); void ims_disable(void *); int ims_ioctl(void *, u_long, caddr_t, int, struct proc *); @@ -110,7 +110,7 @@ ims_attach(struct device *parent, struct if (hidms_setup(self, ms, 0, iha->reportid, desc, size) != 0) return; - hidms_attach(ms, &ims_accessops); + hidms_attach(ms, &ims_accessops, 0); } int @@ -133,7 +133,7 @@ ims_intr(struct ihidev *addr, void *buf, } int -ims_enable(void *v) +ims_enable(void *v, int on /* unused */) { struct ims_softc *sc = v; struct hidms *ms = &sc->sc_ms; Index: sys/dev/i2c/imt.c =================================================================== RCS file: /cvs/src/sys/dev/i2c/imt.c,v retrieving revision 1.2 diff -u -p -u -p -r1.2 imt.c --- sys/dev/i2c/imt.c 23 Jul 2017 22:39:11 -0000 1.2 +++ sys/dev/i2c/imt.c 20 Sep 2017 01:49:39 -0000 @@ -44,7 +44,7 @@ struct imt_softc { int sc_rep_cap; }; -int imt_enable(void *); +int imt_enable(void *, int); int imt_open(struct ihidev *); void imt_intr(struct ihidev *, void *, u_int); void imt_disable(void *); @@ -206,7 +206,7 @@ imt_intr(struct ihidev *dev, void *buf, } int -imt_enable(void *v) +imt_enable(void *v, int on /* unused */) { struct imt_softc *sc = v; struct hidmt *mt = &sc->sc_mt; Index: sys/dev/pckbc/pms.c =================================================================== RCS file: /cvs/src/sys/dev/pckbc/pms.c,v retrieving revision 1.80 diff -u -p -u -p -r1.80 pms.c --- sys/dev/pckbc/pms.c 26 Aug 2017 18:34:04 -0000 1.80 +++ sys/dev/pckbc/pms.c 20 Sep 2017 01:49:39 -0000 @@ -242,11 +242,11 @@ void pmsinput(void *, int); int pms_change_state(struct pms_softc *, int, int); int pms_ioctl(void *, u_long, caddr_t, int, struct proc *); -int pms_enable(void *); +int pms_enable(void *, int); void pms_disable(void *); int pms_sec_ioctl(void *, u_long, caddr_t, int, struct proc *); -int pms_sec_enable(void *); +int pms_sec_enable(void *, int); void pms_sec_disable(void *); int pms_cmd(struct pms_softc *, u_char *, int, u_char *, int); @@ -774,7 +774,7 @@ pms_change_state(struct pms_softc *sc, i } int -pms_enable(void *v) +pms_enable(void *v, int on /* unused */) { struct pms_softc *sc = v; int rv; @@ -808,8 +808,9 @@ pms_ioctl(void *v, u_long cmd, caddr_t d } int -pms_sec_enable(void *v) +pms_sec_enable(void *v, int on /* unused */) { + /* XXX: aaron: does this break mice on resume? */ struct pms_softc *sc = v; int rv; Index: sys/dev/usb/ubcmtp.c =================================================================== RCS file: /cvs/src/sys/dev/usb/ubcmtp.c,v retrieving revision 1.17 diff -u -p -u -p -r1.17 ubcmtp.c --- sys/dev/usb/ubcmtp.c 6 Jun 2017 21:53:07 -0000 1.17 +++ sys/dev/usb/ubcmtp.c 20 Sep 2017 01:49:39 -0000 @@ -354,7 +354,7 @@ struct ubcmtp_softc { int btn; }; -int ubcmtp_enable(void *); +int ubcmtp_enable(void *, int); void ubcmtp_disable(void *); int ubcmtp_ioctl(void *, unsigned long, caddr_t, int, struct proc *); int ubcmtp_raw_mode(struct ubcmtp_softc *, int); @@ -535,7 +535,7 @@ ubcmtp_configure(struct ubcmtp_softc *sc } int -ubcmtp_enable(void *v) +ubcmtp_enable(void *v, int on /* unused */) { struct ubcmtp_softc *sc = v; Index: sys/dev/usb/ums.c =================================================================== RCS file: /cvs/src/sys/dev/usb/ums.c,v retrieving revision 1.43 diff -u -p -u -p -r1.43 ums.c --- sys/dev/usb/ums.c 12 Jan 2016 19:16:21 -0000 1.43 +++ sys/dev/usb/ums.c 20 Sep 2017 01:49:39 -0000 @@ -62,7 +62,7 @@ struct ums_softc { void ums_intr(struct uhidev *addr, void *ibuf, u_int len); -int ums_enable(void *); +int ums_enable(void *, int); void ums_disable(void *); int ums_ioctl(void *, u_long, caddr_t, int, struct proc *); @@ -167,7 +167,16 @@ ums_attach(struct device *parent, struct ms->sc_loc_btn[2].pos = 2; } - hidms_attach(ms, &ums_accessops); + hidms_attach(ms, &ums_accessops, 1); + + //printf(" ---> ms->sc_console_mouse thinks: %d\n", ms->sc_console_mouse); + //if (ms->sc_console_mouse) { + /* We are always a console mouse */ + if (1) { + //DPRINTF(("ums_attach: console mouse sc=%p\n", sc)); + wsmouse_cnattach(); + ums_enable(sc, 1); + } } int @@ -190,7 +199,7 @@ ums_intr(struct uhidev *addr, void *buf, } int -ums_enable(void *v) +ums_enable(void *v, int on /* unused */) { struct ums_softc *sc = v; struct hidms *ms = &sc->sc_ms; Index: sys/dev/usb/uts.c =================================================================== RCS file: /cvs/src/sys/dev/usb/uts.c,v retrieving revision 1.40 diff -u -p -u -p -r1.40 uts.c --- sys/dev/usb/uts.c 8 Apr 2017 02:57:25 -0000 1.40 +++ sys/dev/usb/uts.c 20 Sep 2017 01:49:39 -0000 @@ -95,7 +95,7 @@ const struct usb_devno uts_devs[] = { void uts_intr(struct usbd_xfer *, void *, usbd_status); void uts_get_pos(void *addr, struct uts_pos *tp); -int uts_enable(void *); +int uts_enable(void *, int); void uts_disable(void *); int uts_ioctl(void *, u_long, caddr_t, int, struct proc *); @@ -249,7 +249,7 @@ uts_activate(struct device *self, int ac } int -uts_enable(void *v) +uts_enable(void *v, int on /* unused */) { struct uts_softc *sc = v; int err; Index: sys/dev/usb/uwacom.c =================================================================== RCS file: /cvs/src/sys/dev/usb/uwacom.c,v retrieving revision 1.1 diff -u -p -u -p -r1.1 uwacom.c --- sys/dev/usb/uwacom.c 12 Sep 2016 08:12:06 -0000 1.1 +++ sys/dev/usb/uwacom.c 20 Sep 2017 01:49:39 -0000 @@ -53,7 +53,7 @@ int uwacom_match(struct device *, void * void uwacom_attach(struct device *, struct device *, void *); int uwacom_detach(struct device *, int); void uwacom_intr(struct uhidev *, void *, u_int); -int uwacom_enable(void *); +int uwacom_enable(void *, int); void uwacom_disable(void *); int uwacom_ioctl(void *, u_long, caddr_t, int, struct proc *); @@ -132,7 +132,7 @@ uwacom_attach(struct device *parent, str sc->sc_loc_tip_press.pos = 43; sc->sc_loc_tip_press.size = 8; - hidms_attach(ms, &uwacom_accessops); + hidms_attach(ms, &uwacom_accessops, 0); } int @@ -182,7 +182,7 @@ uwacom_intr(struct uhidev *addr, void *b } int -uwacom_enable(void *v) +uwacom_enable(void *v, int on /* unused */) { struct uwacom_softc *sc = v; struct hidms *ms = &sc->sc_ms; Index: sys/dev/wscons/wscons_callbacks.h =================================================================== RCS file: /cvs/src/sys/dev/wscons/wscons_callbacks.h,v retrieving revision 1.9 diff -u -p -u -p -r1.9 wscons_callbacks.h --- sys/dev/wscons/wscons_callbacks.h 18 Oct 2013 22:06:40 -0000 1.9 +++ sys/dev/wscons/wscons_callbacks.h 20 Sep 2017 01:49:39 -0000 @@ -37,6 +37,7 @@ struct wsevsrc; * Calls to the display interface from the glue code. */ void wsdisplay_set_console_kbd(struct wsevsrc *); +void wsdisplay_set_console_mouse(struct wsevsrc *); /* * Calls to the display interface from the keyboard interface. @@ -65,3 +66,9 @@ int wsdisplay_param(struct device*, u_lo struct wsevsrc *wskbd_set_console_display(struct device *, struct wsevsrc *); int wskbd_set_display(struct device *, struct device *); int wskbd_pickfree(void); +/* + * Calls to the mouse interface from the glue code. + */ +struct wsevsrc *wsmouse_set_console_display(struct device *, struct wsevsrc *); +int wsmouse_set_display(struct device *, struct device *); +int wsmouse_pickfree(void); Index: sys/dev/wscons/wsdisplay.c =================================================================== RCS file: /cvs/src/sys/dev/wscons/wsdisplay.c,v retrieving revision 1.129 diff -u -p -u -p -r1.129 wsdisplay.c --- sys/dev/wscons/wsdisplay.c 19 Jul 2017 20:12:54 -0000 1.129 +++ sys/dev/wscons/wsdisplay.c 20 Sep 2017 01:49:39 -0000 @@ -58,6 +58,7 @@ #include "wsdisplay.h" #include "wskbd.h" +#include "wsmouse.h" #include "wsmux.h" #if NWSKBD > 0 @@ -184,6 +185,10 @@ struct wsdisplay_softc { #endif #endif /* NWSKBD > 0 */ +#if NWSMOUSE > 0 + struct wsevsrc *sc_mouse; +#endif + #ifdef HAVE_WSMOUSED_SUPPORT char *sc_copybuffer; u_int sc_copybuffer_size; @@ -629,6 +634,32 @@ wsdisplay_common_detach(struct wsdisplay } #endif +#if NWSMOUSE > 0 + if (sc->sc_input != NULL) { +#if NWSMUX > 0 + /* + * If we are the display of the mux we are attached to, + * disconnect all input devices from us. + */ + if (sc->sc_mouse->me_dispdv == &sc->sc_dv) { + if ((rc = wsmux_set_display((struct wsmux_softc *) + sc->sc_mouse, NULL)) != 0) + return (rc); + } + + /* + * XXX + * If we created a standalone mux (dmux), we should destroy it + * there, but there is currently no support for this in wsmux. + */ +#else + if ((rc = wsmouse_set_display((struct device *)sc->sc_mouse, + NULL)) != 0) + return (rc); +#endif + } +#endif + return (0); } @@ -670,8 +701,9 @@ wsdisplay_common_attach(struct wsdisplay u_int defaultscreens) { int i, start = 0; -#if NWSKBD > 0 +#if NWSKBD > 0 || NWSMOUSE > 0 struct wsevsrc *kme; + struct wsevsrc *mme; #if NWSMUX > 0 struct wsmux_softc *mux; @@ -719,13 +751,22 @@ wsdisplay_common_attach(struct wsdisplay #endif #endif +#if NWSMOUSE > 0 + mme = wsmouse_set_console_display(&sc->sc_dv, sc->sc_input); + if (mme != NULL) + printf(", using %s", mme->me_dv.dv_xname); +#if NWSMUX == 0 + sc->sc_input = kme; +#endif +#endif + sc->sc_focusidx = 0; sc->sc_focus = sc->sc_scr[0]; start = 1; } printf("\n"); -#if NWSKBD > 0 && NWSMUX > 0 +#if (NWSKBD > 0 || NWSMOUSE > 0) && NWSMUX > 0 /* * If this mux did not have a display device yet, volunteer for * the job. @@ -767,8 +808,8 @@ wsdisplay_common_attach(struct wsdisplay #if NWSKBD > 0 && NWSMUX == 0 if (console == 0) { /* - * In the non-wsmux world, always connect wskbd0 and wsdisplay0 - * together. + * In the non-wsmux world, always connect wskbd0, wsmouse0, + * and wsdisplay0 together. */ extern struct cfdriver wskbd_cd; @@ -780,6 +821,22 @@ wsdisplay_common_attach(struct wsdisplay } } #endif + +#if NWSMOUSE > 0 && NWSMUX == 0 + if (console == 0) { + /* + * In the non-wsmux world, always connect wskbd0, wsmouse0, + * and wsdisplay0 together. + */ + extern struct cfdriver wsmouse_cd; + + if (wsmouse_cd.cd_ndevs != 0 && sc->sc_dv.dv_unit == 0) { + if (wsdisplay_set_mouse(&sc->sc_dv, + (struct wsevsrc *)wsmouse_cd.cd_devs[0]) == 0) + wsmouse_set_display(wsmouse_cd.cd_devs[0], + &sc->sc_dv); + } +#endif } void @@ -1342,6 +1399,8 @@ wsdisplay_cfg_ioctl(struct wsdisplay_sof #define d ((struct wsmux_device *)data) if (d->idx == -1 && d->type == WSMUX_KBD) d->idx = wskbd_pickfree(); + if (d->idx == -1 && d->type == WSMUX_MOUSE) + d->idx = wsmouse_pickfree(); #undef d /* FALLTHROUGH */ case WSMUXIO_INJECTEVENT: @@ -2052,6 +2111,43 @@ wsdisplay_set_kbd(struct device *disp, s #endif #endif /* NWSKBD > 0 */ + +#if NWSMOUSE > 0 +void +wsdisplay_set_console_mouse(struct wsevsrc *src) +{ + if (wsdisplay_console_device == NULL) { + src->me_dispdv = NULL; + return; + } +#if NWSMUX > 0 + if (wsmux_attach_sc((struct wsmux_softc *) + wsdisplay_console_device->sc_input, src)) { + src->me_dispdv = NULL; + return; + } +#else + wsdisplay_console_device->sc_mouse = src; +#endif + src->me_dispdv = &wsdisplay_console_device->sc_dv; +} + +#if NWSMUX == 0 +int +wsdisplay_set_mouse(struct device *disp, struct wsevsrc *mouse) +{ + struct wsdisplay_softc *sc = (struct wsdisplay_softc *)disp; + + if (sc->sc_input != NULL) + return (EBUSY); + + sc->sc_mouse = mouse; + + return (0); +} +#endif + +#endif /* NWSMOUSE > 0 */ /* * Console interface. Index: sys/dev/wscons/wsmouse.c =================================================================== RCS file: /cvs/src/sys/dev/wscons/wsmouse.c,v retrieving revision 1.40 diff -u -p -u -p -r1.40 wsmouse.c --- sys/dev/wscons/wsmouse.c 16 Jul 2017 18:30:24 -0000 1.40 +++ sys/dev/wscons/wsmouse.c 20 Sep 2017 01:49:39 -0000 @@ -111,6 +111,7 @@ #include <dev/wscons/wsmousevar.h> #include <dev/wscons/wseventvar.h> #include <dev/wscons/wsmouseinput.h> +#include <dev/wscons/wscons_callbacks.h> #include <dev/rndvar.h> #include "wsmux.h" @@ -134,6 +135,8 @@ struct wsmouse_softc { const struct wsmouse_accessops *sc_accessops; void *sc_accesscookie; + int sc_isconsole; + struct wsmouseinput sc_input; int sc_refcnt; @@ -166,13 +169,24 @@ struct cfattach wsmouse_ca = { wsmouse_detach, wsmouse_activate }; -#if NWSMUX > 0 +#if NWSMUX > 0 || NWSDISPLAY > 0 struct wssrcops wsmouse_srcops = { WSMUX_MOUSE, - wsmouse_mux_open, wsmouse_mux_close, wsmousedoioctl, NULL, NULL + wsmouse_mux_open, wsmouse_mux_close, wsmousedoioctl, + NULL, +#if NWSDISPLAY > 0 + wsmouse_set_display +#else + NULL +#endif }; #endif +#if NWSDISPLAY > 0 +static int wsmouse_console_initted; +static struct wsmouse_softc *wsmouse_console_device; +#endif + /* * Print function (for parent devices). */ @@ -205,8 +219,10 @@ wsmouse_attach(struct device *parent, st sc->sc_input.evar = &sc->sc_base.me_evp; -#if NWSMUX > 0 +#if NWSMUX > 0 || NWSDISPLAY > 0 sc->sc_base.me_ops = &wsmouse_srcops; +#endif +#if NWSMUX > 0 mux = sc->sc_base.me_dv.dv_cfdata->wsmousedevcf_mux; if (mux >= 0) { error = wsmux_attach_sc(wsmux_getmux(mux), &sc->sc_base); @@ -220,9 +236,59 @@ wsmouse_attach(struct device *parent, st if (sc->sc_base.me_dv.dv_cfdata->wsmousedevcf_mux >= 0) printf(" (mux ignored)"); #endif + + printf("\n"); #endif /* NWSMUX > 0 */ + if (ap->console) { + //KASSERT(wsmouse_console_initted); + //KASSERT(wsmouse_console_device == NULL); + + wsmouse_console_device = sc; + + printf(": console mouse"); +#if NWSDISPLAY > 0 + wsdisplay_set_console_mouse(&sc->sc_base); /* sets sc_displaydv */ + if (sc->sc_displaydv != NULL) + printf(", using %s", sc->sc_displaydv->dv_xname); +#endif + } printf("\n"); + +#if NWSDISPLAY > 0 && NWSMUX == 0 + if (ap->console == 0) { + /* + * In the non-wsmux world, always connect wsmouse0 and wsdisplay0 + * together + */ + extern struct cfdriver wsdisplay_cd; + + if (wsdisplay_cd.cs_ndevs != 0 && self->dv_unti == 0) { + if (wsmouse_set_display(self, + wsdisplay_cd.cd_devs[0]) == 0) + wsdisplay_set_mouse(wsdisplay_cd.cd_devs[0], + (struct wsevsrc *)sc); + } + } +#endif +} + +void +wsmouse_cnattach(void) +{ + + //KASSERT(!wsmouse_console_initted); + + wsmouse_console_initted = 1; +} + +void +wsmouse_cndetach(void) +{ + //KASSERT(wsmouse_console_initted); + + wsmouse_console_device = NULL; + wsmouse_console_initted = 0; } int @@ -291,6 +357,21 @@ wsmouse_detach(struct device *self, int } int +wsmouse_enable(struct wsmouse_softc *sc, int on) +{ + int error; + +#if NWSDISPLAY > 0 + if (sc->sc_displaydv != NULL) + return (0); +#endif + + error = (*sc->sc_accessops->enable)(sc->sc_accesscookie, on); + DPRINTF(("wsmouse_enable: sc=%p on=%d res=%d\n", sc, on, error)); + return (error); +} + +int wsmouseopen(dev_t dev, int flags, int mode, struct proc *p) { struct wsmouse_softc *sc; @@ -382,7 +463,7 @@ wsmousedoopen(struct wsmouse_softc *sc, wsmouse_input_reset(&sc->sc_input); /* enable the device, and punt if that's not possible */ - return (*sc->sc_accessops->enable)(sc->sc_accesscookie); + return (*sc->sc_accessops->enable)(sc->sc_accesscookie, 1); } int @@ -527,6 +608,78 @@ wsmouse_do_ioctl(struct wsmouse_softc *s data, flag, p); return (error != -1 ? error : ENOTTY); } + +#if NWSDISPLAY > 0 + +int wsmouse_pickfree(void) +{ + int i; + struct wsmouse_softc *sc; + + for (i = 0; i < wsmouse_cd.cd_ndevs; i++) { + if ((sc = wsmouse_cd.cd_devs[i]) == NULL) + continue; + if (sc->sc_displaydv == NULL) + return (i); + } + return (-1); +} + +struct wsevsrc * +wsmouse_set_console_display(struct device *displaydv, struct wsevsrc *me) +{ + struct wsmouse_softc *sc = wsmouse_console_device; + + if (sc == NULL) + return (NULL); + sc->sc_displaydv = displaydv; +#if NWSMUX > 0 + //(void)wsmouse_attach_sc((struct wsmux_softc *)me, &sc->sc_base); +#endif + return (&sc->sc_base); +} + +int +wsmouse_set_display(struct device *dv, struct device *displaydv) +{ + struct wsmouse_softc *sc = (struct wsmouse_softc *)dv; + struct device *odisplaydv; + int error; + + DPRINTF(("wsmouse_set_display: %s odisp=%p disp=%p cons=%d\n", + dv->dv_xname, sc->sc_displaydv, displaydv, + sc->sc_isconsole)); + + if (sc->sc_isconsole) + return (EBUSY); + + if (displaydv != NULL) { + if (sc->sc_displaydv != NULL) + return (EBUSY); + } else { + if (sc->sc_displaydv == NULL) + return (ENXIO); + } + + odisplaydv = sc->sc_displaydv; + sc->sc_displaydv = NULL; + error = wsmouse_enable(sc, displaydv != NULL); + sc->sc_displaydv = displaydv; + if (error) { + sc->sc_displaydv = odisplaydv; + return (error); + } + + if (displaydv) + printf("%s: connecting to %s\n", + sc->sc_base.me_dv.dv_xname, displaydv->dv_xname); + else + printf("%s: disconnecting from %s\n", + sc->sc_base.me_dv.dv_xname, odisplaydv->dv_xname); + + return (0); +} +#endif /* NWSDISPLAY > 0 */ int wsmousepoll(dev_t dev, int events, struct proc *p) Index: sys/dev/wscons/wsmousevar.h =================================================================== RCS file: /cvs/src/sys/dev/wscons/wsmousevar.h,v retrieving revision 1.15 diff -u -p -u -p -r1.15 wsmousevar.h --- sys/dev/wscons/wsmousevar.h 18 Jun 2017 13:21:48 -0000 1.15 +++ sys/dev/wscons/wsmousevar.h 20 Sep 2017 01:49:39 -0000 @@ -63,7 +63,7 @@ * with these functions, which is passed to them when they are invoked. */ struct wsmouse_accessops { - int (*enable)(void *); + int (*enable)(void *, int); int (*ioctl)(void *v, u_long cmd, caddr_t data, int flag, struct proc *p); void (*disable)(void *); @@ -74,11 +74,19 @@ struct wsmouse_accessops { * wsmouse units. */ struct wsmousedev_attach_args { + int console; /* is it console? */ + const struct wsmouse_accessops *accessops; /* access ops */ void *accesscookie; /* access cookie */ }; #define wsmousedevcf_mux cf_loc[WSMOUSEDEVCF_MUX] + +/* + * Autoconfiguration helper functions. + */ +void wsmouse_cnattach(void); +void wsmouse_cndetach(void); /* * Autoconfiguration helper functions. On Wed, Feb 18, 2015, at 18:39, Aaron Fineman wrote: > On Tue, Feb 17, 2015, at 03:25 AM, Matthieu Herrb wrote: > > On Mon, Feb 16, 2015 at 07:47:54PM -0500, Aaron Fineman wrote: > > > > > > > On Feb 16, 2015, at 18:59, Matthieu Herrb <matth...@herrb.eu> wrote: > > > > > > > >> On Mon, Feb 16, 2015 at 06:49:30PM -0500, Aaron Fineman wrote: > > > >> Hello, > > > >> > > > >> The KVM switch produces no output when switched away on the console. > > > >> Waving it around while focused produces the expected events, but it > > > >> stays silent while switched away. For what it's worth, the device is > > > >> this one: > > > >> http://www.newegg.com/Product/Product.aspx?Item=N82E16817182157&cm_re=rkv-2uc-_-17-182-157-_-Product > > > >> > > > >> I'm going to try a longer capture while switched away to see if it's > > > >> time based. > > > > > > > > Can you try to run it with /dev/wsmouuse1 as parameter ? > > > > > > This instantly fills it up with the following lines, repeating. > > > > > > read: Input/output error > > > unknown event type 0x0, value 0x0 > > > > > > > Ok. I've just commited a change to the xf86-input-ws driver that will > > no longer log I/O errors to /var/log/Xorg.0.log by default. > > > > However you will still see X eating 100% of CPU while switched away on > > the KVM (and possibly after coming back, until you also do a switch to > > a text mode console and back). This needs a more intrusive change, I'm > > not sure I can get it ready for OpenBSD 5.7. > > > > -- > > Matthieu Herrb > > Thanks, this works as described, including the need to flip to text mode > and back. > > If you make changes after 5.7, feel free to ping me as a tester.