cvs commit: src/sys/isa psm.c

Brian Somers brian at Awfulhak.org
Sat Aug 21 11:57:22 PDT 2004


On Thu, 19 Aug 2004 08:43:30 -0600, "Justin T. Gibbs" <gibbs at scsiguy.com> wrote:
> > This breaks my mouse badly - it never syncs now and just flies all over the
> > screen doing damage when it's touched.
> 
> Can you provide psm debug output for your mouse?  #define DEBUG to 1
> in psm.c.

Replied here in case others are seeing the problem.

In psm.c 1.79, the setting of sc->mode.syncmask[1] is deferred 'till the
first data packet is received in psmintr().  Functionally this doesn't
change the behaviour of /dev/psm0... except...

After the probe & attach of psm, moused opens /dev/psm and does a few
ioctls.  One of these is ioctl(MOUSE_GETMODE):

    if (ioctl(rodent.mfd, MOUSE_GETMODE, &rodent.mode) == 0) {
	....
        cur_proto[0] = rodent.mode.syncmask[0]; /* header byte bit mask */
        cur_proto[1] = rodent.mode.syncmask[1]; /* header bit pattern */
    }

Later, moused says:

    if (pBufP == 0 && (rBuf & cur_proto[0]) != cur_proto[1])
        return 0;
        
    /* is there an extra data byte? */
    if (pBufP >= cur_proto[4] && (rBuf & cur_proto[0]) != cur_proto[1])
    {
        /*
         * Hack for Logitech MouseMan Mouse - Middle button
         *
	.....

Because syncmask[1] hasn't yet been set (given that you weren't twiddling
your mouse between psmprobe() and psmioctl(), we end up with cur_proto[0]
== 0x08 and cur_proto[1] == 0x00 and get stuck in both of the if clauses
above resulting in somewhat erratic mouse movement.


I'm not sure why these changes (psm 1.79) would have made things work for
you - perhaps you're booting your machine with the KVM pointing somewhere
else and as a result, avoiding doing the data read in psmprobe() is fixing
the problems result?  If so do we need to do a similar tweak to moused to
defer the recording of cur_proto[1]?


BTW, while I was in there I noticed this:

    if (sc->config & PSM_CONFIG_NOCHECKSYNC)
        sc->dflt_mode.syncmask[0] = 0;
    else
        sc->dflt_mode.syncmask[0] = vendortype[i].syncmask;
    if (sc->config & PSM_CONFIG_FORCETAP)
        sc->mode.syncmask[0] &= ~MOUSE_PS2_TAP;
        ^^^^^^^^^^^^^^^^^^^^
    sc->dflt_mode.syncmask[1] = 0;      /* syncbits */
    sc->mode = sc->dflt_mode;
    sc->mode.packetsize = vendortype[i].packetsize;

which looks somewhat bogus as the whole sc->mode structure is overwritten
two lines later!  Perhaps it should be dflt_mode.syncmask[0] that's tweaked?


Also, the use of sc->syncerrors seems broken.  It's never reset to zero
so the first time it needs to resync after a kvm switch it kind-of works
where it drops the first byte in the sequence and continues reading the
packet, but after that it'll never work because sc->syncerrors is too big.

I'm loathe to change any of this as I don't know anything about the format
of these mouse packets and haven't got a big enough variety of mice to
test changes on.

-- 
Brian <brian at Awfulhak.org>                        <brian@[uk.]FreeBSD.org>
      <http://www.Awfulhak.org>                   <brian@[uk.]OpenBSD.org>
Don't _EVER_ lose your sense of humour !


More information about the cvs-all mailing list