Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pckbc Move psm.c and psmreg.h to pms.c and pmsreg.h, ...



details:   https://anonhg.NetBSD.org/src/rev/eeb7a3ec0d6a
branches:  trunk
changeset: 525950:eeb7a3ec0d6a
user:      wiz <wiz%NetBSD.org@localhost>
date:      Mon Apr 22 10:44:46 2002 +0000

description:
Move psm.c and psmreg.h to pms.c and pmsreg.h, since they contain the
pms (not psm) driver.
Fix a debugging message to print the correct function name.

Approved by Christos.

diffstat:

 sys/dev/pckbc/files.pckbc |    4 +-
 sys/dev/pckbc/pms.c       |  580 ++++++++++++++++++++++++++++++++++++++++++++++
 sys/dev/pckbc/pmsreg.h    |   19 +
 sys/dev/pckbc/psm.c       |  580 ----------------------------------------------
 sys/dev/pckbc/psmreg.h    |   19 -
 5 files changed, 601 insertions(+), 601 deletions(-)

diffs (truncated from 1229 to 300 lines):

diff -r 422635f1d42f -r eeb7a3ec0d6a sys/dev/pckbc/files.pckbc
--- a/sys/dev/pckbc/files.pckbc Mon Apr 22 10:08:41 2002 +0000
+++ b/sys/dev/pckbc/files.pckbc Mon Apr 22 10:44:46 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.pckbc,v 1.9 2002/04/14 01:45:29 mycroft Exp $
+# $NetBSD: files.pckbc,v 1.10 2002/04/22 10:44:46 wiz Exp $
 # devices attached at pckbc, for use with wscons
 
 device pckbd: wskbddev
@@ -9,4 +9,4 @@
 
 device pms: wsmousedev
 attach pms at pckbc
-file   dev/pckbc/psm.c                 pms
+file   dev/pckbc/pms.c                 pms
diff -r 422635f1d42f -r eeb7a3ec0d6a sys/dev/pckbc/pms.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pckbc/pms.c       Mon Apr 22 10:44:46 2002 +0000
@@ -0,0 +1,580 @@
+/* $NetBSD: pms.c,v 1.1 2002/04/22 10:44:47 wiz Exp $ */
+
+/*-
+ * Copyright (c) 1994 Charles M. Hannum.
+ * Copyright (c) 1992, 1993 Erik Forsberg.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.1 2002/04/22 10:44:47 wiz Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/ioctl.h>
+#include <sys/kthread.h>
+
+#include <machine/bus.h>
+
+#include <dev/ic/pckbcvar.h>
+
+#include <dev/pckbc/pmsreg.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsmousevar.h>
+
+#ifdef PMSDEBUG
+int pmsdebug = 1;
+#define DPRINTF(x)      if (pmsdebug) printf x
+#else
+#define DPRINTF(x)
+#endif
+
+enum pms_type { PMS_UNKNOWN, PMS_STANDARD, PMS_SCROLL3, PMS_SCROLL5 };
+
+struct pms_protocol {
+       int rates[3];
+       int response;
+       const char *name;
+} pms_protocols[] = {
+       { { 0, 0, 0 }, 0, "unknown protocol" },
+       { { 0, 0, 0 }, 0, "no scroll wheel (3 buttons)" },
+       { { 200, 100, 80 }, 3, "scroll wheel (3 buttons)" },
+       { { 200, 200, 80 }, 4, "scroll wheel (5 buttons)" }
+};
+
+enum pms_type tries[] = {
+       PMS_SCROLL5, PMS_SCROLL3, PMS_STANDARD, PMS_UNKNOWN
+};
+
+struct pms_softc {             /* driver status information */
+       struct device sc_dev;
+
+       pckbc_tag_t sc_kbctag;
+       int sc_kbcslot;
+
+       int sc_enabled;         /* input enabled? */
+#ifndef PMS_DISABLE_POWERHOOK
+       void *sc_powerhook;     /* cookie from power hook */
+#endif /* !PMS_DISABLE_POWERHOOK */
+       int inputstate;
+       u_int buttons;          /* mouse button status */
+       enum pms_type protocol;
+       unsigned char packet[4];
+       struct timeval last, current;
+
+       struct device *sc_wsmousedev;
+       struct proc *sc_event_thread;
+       int sc_reset_flag;
+};
+
+int pmsprobe __P((struct device *, struct cfdata *, void *));
+void pmsattach __P((struct device *, struct device *, void *));
+void pmsinput __P((void *, int));
+
+struct cfattach pms_ca = {
+       sizeof(struct pms_softc), pmsprobe, pmsattach,
+};
+
+static int     pms_protocol __P((pckbc_tag_t, pckbc_slot_t));
+static void    do_enable __P((struct pms_softc *));
+static void    do_disable __P((struct pms_softc *));
+static void    pms_reset_thread __P((void*));
+static void    pms_spawn_reset_thread __P((void*));
+int    pms_enable __P((void *));
+int    pms_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
+void   pms_disable __P((void *));
+#ifndef PMS_DISABLE_POWERHOOK
+void   pms_power __P((int, void *));
+#endif /* !PMS_DISABLE_POWERHOOK */
+
+const struct wsmouse_accessops pms_accessops = {
+       pms_enable,
+       pms_ioctl,
+       pms_disable,
+};
+
+static int
+pms_protocol(tag, slot)
+       pckbc_tag_t tag;
+       pckbc_slot_t slot;
+{
+       u_char cmd[2], resp[1];
+       int i, j, res;
+       struct pms_protocol *p;
+
+       for (j = 0; j < sizeof(tries) / sizeof(tries[0]); ++j) {
+               p = &pms_protocols[tries[j]];
+               if (!p->rates[0])
+                       break;
+               cmd[0] = PMS_SET_SAMPLE;
+               for (i = 0; i < 3; i++) {
+                       cmd[1] = p->rates[i];
+                       res = pckbc_poll_cmd(tag, slot, cmd, 2, 0, 0, 0);
+                       if (res)
+                               return PMS_STANDARD;
+               }
+
+               cmd[0] = PMS_SEND_DEV_ID;
+               res = pckbc_poll_cmd(tag, slot, cmd, 1, 1, resp, 0);
+               if (res)
+                       return 0;
+               if (resp[0] == p->response) {
+                       DPRINTF(("pms_protocol: found mouse protocol %d\n",
+                               tries[j]));
+                       return tries[j];
+               }
+       }
+       DPRINTF(("pms_protocol: standard PS/2 protocol (no scroll wheel)\n"));
+       return PMS_STANDARD;
+}
+
+int
+pmsprobe(parent, match, aux)
+       struct device *parent;
+       struct cfdata *match;
+       void *aux;
+{
+       struct pckbc_attach_args *pa = aux;
+       u_char cmd[1], resp[2];
+       int res;
+
+       if (pa->pa_slot != PCKBC_AUX_SLOT)
+               return (0);
+
+       /* Flush any garbage. */
+       pckbc_flush(pa->pa_tag, pa->pa_slot);
+
+       /* reset the device */
+       cmd[0] = PMS_RESET;
+       res = pckbc_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 2, resp, 1);
+       if (res) {
+#ifdef DEBUG
+               printf("pmsprobe: reset error %d\n", res);
+#endif
+               return (0);
+       }
+       if (resp[0] != PMS_RSTDONE) {
+               printf("pmsprobe: reset response 0x%x\n", resp[0]);
+               return (0);
+       }
+
+       /* get type number (0 = mouse) */
+       if (resp[1] != 0) {
+#ifdef DEBUG
+               printf("pmsprobe: type 0x%x\n", resp[1]);
+#endif
+               return (0);
+       }
+
+       return (10);
+}
+
+void
+pmsattach(parent, self, aux)
+       struct device *parent, *self;
+       void *aux;
+{
+       struct pms_softc *sc = (void *)self;
+       struct pckbc_attach_args *pa = aux;
+       struct wsmousedev_attach_args a;
+       u_char cmd[1], resp[2];
+       int res;
+
+       sc->sc_kbctag = pa->pa_tag;
+       sc->sc_kbcslot = pa->pa_slot;
+
+       printf("\n");
+
+       /* Flush any garbage. */
+       pckbc_flush(pa->pa_tag, pa->pa_slot);
+
+       /* reset the device */
+       cmd[0] = PMS_RESET;
+       res = pckbc_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 2, resp, 1);
+#ifdef DEBUG
+       if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) {
+               printf("pmsattach: reset error\n");
+               return;
+       }
+#endif
+       sc->inputstate = 0;
+       sc->buttons = 0;
+
+       pckbc_set_inputhandler(sc->sc_kbctag, sc->sc_kbcslot,
+                              pmsinput, sc, sc->sc_dev.dv_xname);
+
+       a.accessops = &pms_accessops;
+       a.accesscookie = sc;
+
+       /*
+        * Attach the wsmouse, saving a handle to it.
+        * Note that we don't need to check this pointer against NULL
+        * here or in pmsintr, because if this fails pms_enable() will
+        * never be called, so pmsinput() will never be called.
+        */
+       sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
+
+       /* no interrupts until enabled */
+       cmd[0] = PMS_DEV_DISABLE;
+       res = pckbc_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 0, 0, 0);
+       if (res)
+               printf("pmsattach: disable error\n");
+       pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 0);
+
+       sc->sc_reset_flag = 0;
+
+       kthread_create(pms_spawn_reset_thread, sc);
+
+#ifndef PMS_DISABLE_POWERHOOK
+       sc->sc_powerhook = powerhook_establish(pms_power, sc);
+#endif /* !PMS_DISABLE_POWERHOOK */
+}
+
+static void
+do_enable(sc)
+       struct pms_softc *sc;
+{
+       u_char cmd[1];
+       int res;
+#ifdef PMS_PREFER_PROTOCOL
+       int i;
+#endif
+
+       sc->inputstate = 0;
+       sc->buttons = 0;
+
+       pckbc_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 1);
+
+       cmd[0] = PMS_DEV_ENABLE;
+       res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd, 1, 0, 1, 0);
+       if (res)
+               printf("pms_enable: command error %d\n", res);
+
+       sc->protocol = pms_protocol(sc->sc_kbctag, sc->sc_kbcslot);
+       DPRINTF(("pms_enable: using %s protocol\n",
+           pms_protocols[sc->protocol].name));
+#if 0
+       {
+               u_char scmd[2];
+
+               scmd[0] = PMS_SET_RES;
+               scmd[1] = 3; /* 8 counts/mm */
+               res = pckbc_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, scmd,



Home | Main Index | Thread Index | Old Index