Source-Changes-HG archive

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

[src/trunk]: src add wscons support to amiga mouse



details:   https://anonhg.NetBSD.org/src/rev/d84606b83307
branches:  trunk
changeset: 552271:d84606b83307
user:      jandberg <jandberg%NetBSD.org@localhost>
date:      Mon Sep 22 18:17:30 2003 +0000

description:
add wscons support to amiga mouse

diffstat:

 etc/etc.amiga/MAKEDEV            |   14 +++-
 sys/arch/amiga/conf/files.amiga  |    4 +-
 sys/arch/amiga/conf/majors.amiga |    3 +-
 sys/arch/amiga/dev/ms.c          |  122 ++++++++++++++++++++++++++++++++++++++-
 4 files changed, 136 insertions(+), 7 deletions(-)

diffs (270 lines):

diff -r 3586fd2a5702 -r d84606b83307 etc/etc.amiga/MAKEDEV
--- a/etc/etc.amiga/MAKEDEV     Mon Sep 22 17:53:46 2003 +0000
+++ b/etc/etc.amiga/MAKEDEV     Mon Sep 22 18:17:30 2003 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#      $NetBSD: MAKEDEV,v 1.92 2003/09/19 11:11:43 pooka Exp $
+#      $NetBSD: MAKEDEV,v 1.93 2003/09/22 18:17:30 jandberg Exp $
 #
 # Copyright (c) 1990 The Regents of the University of California.
 # All rights reserved.
@@ -75,6 +75,7 @@
 #
 # Pointing devices:
 #      mouse*  Amiga mice
+#      wsmouse* wscons mouse events
 #
 # Terminal ports:
 #      tty00   standard serial port
@@ -495,7 +496,7 @@
 
 wscons)
        makedev ttyE0 ttyE1 ttyE2 ttyE3 ttyE4 ttyE5 ttyE6 ttyE7
-#      makedev wsmouse0 wsmouse1 wsmouse2 wsmouse3
+       makedev wsmouse0 wsmouse1 wsmouse2 wsmouse3
        makedev wskbd0 wskbd1 wskbd2 wskbd3
        makedev ttyEcfg
        ;;
@@ -513,6 +514,15 @@
        mknod ttyE$unit c $chr $unit
        ;;
 
+wsmouse*)
+       unit=${i#wsmouse}
+       wsmouse=wsmouse$unit
+       major=61
+       rm -f $wsmouse
+       mknod $wsmouse c $major $unit
+       chmod 600 $wsmouse
+       ;;
+
 wskbd*)
        unit=${i#wskbd}
        wskbd=wskbd$unit
diff -r 3586fd2a5702 -r d84606b83307 sys/arch/amiga/conf/files.amiga
--- a/sys/arch/amiga/conf/files.amiga   Mon Sep 22 17:53:46 2003 +0000
+++ b/sys/arch/amiga/conf/files.amiga   Mon Sep 22 18:17:30 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amiga,v 1.131 2003/07/27 01:17:40 thorpej Exp $
+#      $NetBSD: files.amiga,v 1.132 2003/09/22 18:17:31 jandberg Exp $
 
 # maxpartitions must be first item in files.${ARCH}.newconf
 maxpartitions 16                       # NOTE THAT AMIGA IS SPECIAL!
@@ -114,7 +114,7 @@
 file   arch/amiga/dev/toccata.c        toccata
 
 # mouse
-device ms: event
+device ms: event, wsmousedev
 attach ms at mainbus
 file   arch/amiga/dev/ms.c             ms needs-flag
 
diff -r 3586fd2a5702 -r d84606b83307 sys/arch/amiga/conf/majors.amiga
--- a/sys/arch/amiga/conf/majors.amiga  Mon Sep 22 17:53:46 2003 +0000
+++ b/sys/arch/amiga/conf/majors.amiga  Mon Sep 22 18:17:30 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: majors.amiga,v 1.6 2003/08/22 05:06:47 itojun Exp $
+#      $NetBSD: majors.amiga,v 1.7 2003/09/22 18:17:31 jandberg Exp $
 #
 # Device majors for amiga
 #
@@ -57,3 +57,4 @@
 device-major   ksyms           char 58                 ksyms
 device-major   pf              char 59                 pf
 device-major   crypto          char 60                 opencrypto
+device-major   wsmouse         char 61                 wsmouse
diff -r 3586fd2a5702 -r d84606b83307 sys/arch/amiga/dev/ms.c
--- a/sys/arch/amiga/dev/ms.c   Mon Sep 22 17:53:46 2003 +0000
+++ b/sys/arch/amiga/dev/ms.c   Mon Sep 22 18:17:30 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ms.c,v 1.27 2003/09/21 19:16:49 jdolecek Exp $ */
+/*     $NetBSD: ms.c,v 1.28 2003/09/22 18:17:31 jandberg Exp $ */
 
 /*
  * based on:
@@ -45,12 +45,22 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.27 2003/09/21 19:16:49 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.28 2003/09/22 18:17:31 jandberg Exp $");
 
 /*
  * Mouse driver.
+ *
+ * wscons aware. Attaches two wsmouse devices, one for each port.
+ * Also still exports its own device entry points so it is possible
+ * to open this and read firm_events.
+ * The events go only to one place at a time:
+ * - When somebody has opened a ms device directly wsmouse cannot be activated.
+ *   (when wsmouse is opened it calls ms_enable to activate)
+ * - When feeding events to wsmouse open of ms device will fail.
  */
 
+#include "wsmouse.h"
+
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/ioctl.h>
@@ -70,6 +80,11 @@
 #include <amiga/amiga/cia.h>
 #include <amiga/amiga/device.h>
 
+#if NWSMOUSE > 0
+#include <dev/wscons/wsmousevar.h>
+#include <dev/wscons/wsconsio.h>
+#endif
+
 void msattach(struct device *, struct device *, void *);
 int msmatch(struct device *, struct cfdata *, void *);
 
@@ -87,6 +102,10 @@
        int     ms_dy;             /* delta-y */
        volatile int ms_ready;     /* event queue is ready */
        struct  evvar ms_events;   /* event queue state */
+#if NWSMOUSE > 0
+       struct device *ms_wsmousedev; /* wsmouse device */
+       int     ms_wsenabled;      /* feeding events to wscons */
+#endif
 };
 
 #define        MS_NPORTS       2
@@ -127,6 +146,21 @@
 #define        MS_DEV2MSPORT(d) \
     (&(((struct ms_softc *)getsoftc(ms_cd, MS_UNIT(d)))->sc_ports[MS_PORT(d)]))
 
+#if NWSMOUSE > 0
+/*
+ * Callbacks for wscons.
+ */
+static int ms_wscons_enable(void *);
+static int ms_wscons_ioctl(void *, u_long, caddr_t, int, struct proc *);
+static void ms_wscons_disable(void *);
+
+static struct wsmouse_accessops ms_wscons_accessops = {
+       ms_wscons_enable,
+       ms_wscons_ioctl,
+       ms_wscons_disable
+};
+#endif
+
 int
 msmatch(struct device *pdp, struct cfdata *cfp, void *auxp)
 {
@@ -143,6 +177,9 @@
 void
 msattach(struct device *pdp, struct device *dp, void *auxp)
 {
+#if NWSMOUSE > 0
+       struct wsmousedev_attach_args waa;
+#endif
        struct ms_softc *sc = (void *) dp;
        int i;
 
@@ -150,6 +187,14 @@
        for (i = 0; i < MS_NPORTS; i++) {
                sc->sc_ports[i].ms_portno = i;
                callout_init(&sc->sc_ports[i].ms_intr_ch);
+#if NWSMOUSE > 0
+               waa.accessops = &ms_wscons_accessops;
+               waa.accesscookie = &sc->sc_ports[i];
+               
+               sc->sc_ports[i].ms_wsenabled = 0;
+               sc->sc_ports[i].ms_wsmousedev = 
+                   config_found(dp, &waa, wsmousedevprint);
+#endif
        }
 }
 
@@ -258,6 +303,31 @@
        ms->ms_dy = dy;
        ms->ms_mb = mb;
 
+#if NWSMOUSE > 0
+       /*
+        * If we have attached wsmouse and we are not opened
+        * directly then pass events to wscons.
+        */
+       if (ms->ms_wsmousedev && ms->ms_wsenabled)
+       {
+               int buttons = 0;
+
+               if (mb & 4)
+                       buttons |= 1;
+               if (mb & 2)
+                       buttons |= 2;
+               if (mb & 1)
+                       buttons |= 4;
+
+               wsmouse_input(ms->ms_wsmousedev, 
+                             buttons,
+                             dx,
+                             -dy,
+                             0,
+                             WSMOUSE_INPUT_DELTA);
+
+       } else
+#endif
        if (dx || dy || ms->ms_ub != ms->ms_mb) {
                /*
                 * We have at least one event (mouse button, delta-X, or
@@ -373,6 +443,11 @@
        if (ms->ms_events.ev_io)
                return(EBUSY);
 
+#if NWSMOUSE > 0
+       /* don't allow opening when sending events to wsmouse */
+       if (ms->ms_wsenabled)
+               return EBUSY;
+#endif
        /* initialize potgo bits for mouse mode */
        custom.potgo = custom.potgor | (0xf00 << (port * 4));
 
@@ -460,3 +535,46 @@
 
        return (ev_kqfilter(&ms->ms_events, kn));
 }
+
+#if NWSMOUSE > 0
+
+static int
+ms_wscons_ioctl(void *cookie, u_long cmd, caddr_t data, int flag, 
+               struct proc *p)
+{
+       switch(cmd) {
+       case WSMOUSEIO_GTYPE:
+               *(u_int*)data = WSMOUSE_TYPE_AMIGA;
+               return (0);
+       }
+
+       return -1;
+}
+
+static int
+ms_wscons_enable(void *cookie)
+{
+       struct ms_port *port = cookie;
+
+       /* somebody reading events from us directly? */
+       if (port->ms_events.ev_io)
+               return EBUSY;
+
+       port->ms_wsenabled = 1;
+       ms_enable(port);
+
+       return 0;
+}
+
+static void
+ms_wscons_disable(void *cookie)
+{
+       struct ms_port *port = cookie;
+
+       if (port->ms_wsenabled)
+               ms_disable(port);
+       port->ms_wsenabled = 0;
+}
+
+#endif
+



Home | Main Index | Thread Index | Old Index