Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/iomd Substantial overhaul of the wsqms driver:



details:   https://anonhg.NetBSD.org/src/rev/067074f5a345
branches:  trunk
changeset: 533048:067074f5a345
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Wed Jun 19 23:02:58 2002 +0000

description:
Substantial overhaul of the wsqms driver:
Use a callout rather than hanging off the VSYNC interrupt.
Don't emit WSMOUSE_INPUT_ABSOLUTE events, since this isn't an absolute device.
Handle counter wrap-around sensibly, rather than limiting counts.
Don't gratuitously copy sc->sc_dev onto itself at attach time.

diffstat:

 sys/arch/arm/iomd/wsqms.c      |  45 ++++++++++++++++-------------------------
 sys/arch/arm/iomd/wsqms_iomd.c |  25 +----------------------
 sys/arch/arm/iomd/wsqmsvar.h   |   8 +-----
 3 files changed, 21 insertions(+), 57 deletions(-)

diffs (197 lines):

diff -r e2caa5d352f6 -r 067074f5a345 sys/arch/arm/iomd/wsqms.c
--- a/sys/arch/arm/iomd/wsqms.c Wed Jun 19 22:42:02 2002 +0000
+++ b/sys/arch/arm/iomd/wsqms.c Wed Jun 19 23:02:58 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsqms.c,v 1.4 2002/04/04 01:03:23 reinoud Exp $ */
+/* $NetBSD: wsqms.c,v 1.5 2002/06/19 23:02:58 bjh21 Exp $ */
 
 /*-
  * Copyright (c) 2001 Reinoud Zandijk
@@ -44,9 +44,11 @@
 
 #include <sys/param.h>
 
+#include <sys/callout.h>
 #include <sys/device.h>
 #include <sys/errno.h> 
 #include <sys/ioctl.h>
+#include <sys/kernel.h>
 #include <sys/malloc.h>
 #include <sys/proc.h>
 #include <sys/syslog.h> 
@@ -74,6 +76,7 @@
 static int wsqms_enable                __P((void *cookie));
 static int wsqms_ioctl         __P((void *cookie, u_long cmd, caddr_t data, int flag, struct proc *p));
 static void wsqms_disable      __P((void *cookie));
+static void wsqms_intr         __P((void *arg));
 
 
 static struct wsmouse_accessops wsqms_accessops = {
@@ -95,6 +98,8 @@
        printf("\n");
 
        sc->sc_wsmousedev = config_found(self, &wsmouseargs, wsmousedevprint);
+
+       callout_init(&sc->sc_callout);
 }
 
 
@@ -106,9 +111,7 @@
 
        sc->sc_flags |= WSQMS_ENABLED;
 
-       /* enable interrupts */
-       sc->sc_intenable(sc, 1);
-
+       callout_reset(&sc->sc_callout, hz / 100, wsqms_intr, sc);
        return 0;
 }
 
@@ -121,8 +124,7 @@
 
        sc->sc_flags &= ~WSQMS_ENABLED;
 
-       /* disable interrupts */
-       sc->sc_intenable(sc, 0);
+       callout_stop(&sc->sc_callout);
 }
 
 
@@ -144,47 +146,36 @@
 }
 
 
-/* We can really put in the mouse XY as absolutes ? */
-int
+static void
 wsqms_intr(arg)
        void *arg;
 {
        struct wsqms_softc *sc = arg;
        int x, y, b;
+       int dx, dy;
 
        x = bus_space_read_4(sc->sc_iot, sc->sc_ioh, QMS_MOUSEX) & 0xffff;
        y = bus_space_read_4(sc->sc_iot, sc->sc_ioh, QMS_MOUSEY) & 0xffff;
        b = bus_space_read_1(sc->sc_iot, sc->sc_butioh, QMS_BUTTONS) & 0x70;
-       b >>= 4;
-       if (x & 0x8000) x |= 0xffff0000;
-       if (y & 0x8000) y |= 0xffff0000;
 
        /* patch up the buttons */
+       b >>= 4;
        b = ~( ((b & 1)<<2) | (b & 2) | ((b & 4)>>2));
 
        if ((x != sc->lastx) || (y != sc->lasty) || (b != sc->lastb)) {
-               /* do we have to bound x and y ? => yes */
-               if (x < -MAX_XYREG) x = -MAX_XYREG;
-               if (x >  MAX_XYREG) x =  MAX_XYREG;
-               if (y < -MAX_XYREG) y = -MAX_XYREG;
-               if (y >  MAX_XYREG) y =  MAX_XYREG;
-
-               /* write the bounded values back */
-               bus_space_write_4(sc->sc_iot, sc->sc_ioh, QMS_MOUSEX, x);
-               bus_space_write_4(sc->sc_iot, sc->sc_ioh, QMS_MOUSEY, y);
-
-               wsmouse_input(sc->sc_wsmousedev, b, x - sc->lastx, y - sc->lasty, 0,
-                               WSMOUSE_INPUT_DELTA);
-               wsmouse_input(sc->sc_wsmousedev, b, x, y, 0,
-                               WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y);
+               dx = (x - sc->lastx) & 0xffff;
+               if (dx >= 0x8000) dx -= 0x10000;
+               dy = (y - sc->lasty) & 0xffff;
+               if (dy >= 0x8000) dy -= 0x10000;
+               wsmouse_input(sc->sc_wsmousedev, b, dx, dy, 0,
+                   WSMOUSE_INPUT_DELTA);
 
                /* save old values */
                sc->lastx = x;
                sc->lasty = y;
                sc->lastb = b;
        };
-
-       return (0);     /* pass on */
+       callout_reset(&sc->sc_callout, hz / 100, wsqms_intr, sc);
 }
 
 
diff -r e2caa5d352f6 -r 067074f5a345 sys/arch/arm/iomd/wsqms_iomd.c
--- a/sys/arch/arm/iomd/wsqms_iomd.c    Wed Jun 19 22:42:02 2002 +0000
+++ b/sys/arch/arm/iomd/wsqms_iomd.c    Wed Jun 19 23:02:58 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsqms_iomd.c,v 1.2 2001/11/27 01:03:53 thorpej Exp $   */
+/*     $NetBSD: wsqms_iomd.c,v 1.3 2002/06/19 23:02:58 bjh21 Exp $     */
 
 /*-
  * Copyright (c) 2001 Reinoud Zandijk
@@ -56,7 +56,6 @@
 
 static int  wsqms_iomd_probe     __P((struct device *, struct cfdata *, void *));
 static void wsqms_iomd_attach    __P((struct device *, struct device *, void *));
-static void wsqms_iomd_intenable __P((struct wsqms_softc *sc, int enable));
 
 
 struct cfattach wsqms_iomd_ca = {
@@ -88,33 +87,11 @@
        struct wsqms_softc *sc = (void *)self;
        struct qms_attach_args *qa = aux;
 
-       sc->sc_device = *self;
-
        sc->sc_iot = qa->qa_iot;
        sc->sc_ioh = qa->qa_ioh;
        sc->sc_butioh = qa->qa_ioh_but;
-       sc->sc_irqnum = qa->qa_irq;
-
-       sc->sc_intenable = wsqms_iomd_intenable;
 
        wsqms_attach(sc, self);
 }
 
-
-static void
-wsqms_iomd_intenable(sc, enable)
-       struct wsqms_softc *sc;
-       int enable;
-{
-       if (enable) {
-               sc->sc_ih = intr_claim(sc->sc_irqnum, IPL_TTY, "wsqms", wsqms_intr, sc);
-               if (!sc->sc_ih)
-                       panic("%s: Cannot claim interrupt\n", sc->sc_device.dv_xname);
-       } else {
-               if (intr_release(sc->sc_ih) != 0)
-                       panic("%s: Cannot release IRQ\n", sc->sc_device.dv_xname);
-       }
-}
-
-
 /* End of wsqms_iomd.c */
diff -r e2caa5d352f6 -r 067074f5a345 sys/arch/arm/iomd/wsqmsvar.h
--- a/sys/arch/arm/iomd/wsqmsvar.h      Wed Jun 19 22:42:02 2002 +0000
+++ b/sys/arch/arm/iomd/wsqmsvar.h      Wed Jun 19 23:02:58 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsqmsvar.h,v 1.1 2001/10/05 22:27:44 reinoud Exp $ */
+/* $NetBSD: wsqmsvar.h,v 1.2 2002/06/19 23:02:58 bjh21 Exp $ */
 
 /*-
  * Copyright (c) 2001 Reinoud Zandijk
@@ -53,10 +53,7 @@
        bus_space_handle_t sc_ioh;      /* bus handle for XY */
        bus_space_handle_t sc_butioh;   /* bus handle for buttons */
 
-       /* interupt handler switch function + goo */
-       void (*sc_intenable) __P((struct wsqms_softc *, int));
-       void *sc_ih;                    /* interrupt pointer */
-       int   sc_irqnum;                /* IRQ number */
+       struct callout sc_callout;
 
 #define WSQMS_ENABLED 0x01
        int sc_flags;
@@ -69,7 +66,6 @@
 
 /* function prototypes */
 extern void wsqms_attach       __P((struct wsqms_softc *sc, struct device *));
-extern int  wsqms_intr         __P((void *arg));
 
 
 /* End of wsqmsvar.h */



Home | Main Index | Thread Index | Old Index