Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > lucky.openbsd.tech

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2008, 12:34 PM
Mike Belopuhov
 
Posts: n/a
Default Updated joy(4) driver

Hi all,

This is an updated joy(4) driver from NetBSD.
It is untested since I have no joysticks themselves
Just hacked on boring evening.

If anybody is interested, you may apply the patch and add this lines
to your kernel config:

joy0 at isa? port 0x201
joy* at isapnp?
joy* at pci?

You may get something like this:

joy1 at pci0 dev 14 function 1 "Creative Labs PCI Gameport Joystick" rev 0x08
joy0 at isa0 port 0x201

The isapnp part is supposed to be the most flawy.

Cheers.


--- /dev/null Sun Jul 2 01:14:12 2006
+++ sys/dev/ic/joy.c Sat Jul 1 13:25:01 2006
@@ -0,0 +1,184 @@
+/* $OpenBSD$ */
+/* $NetBSD: joy.c,v 1.9 2005/12/11 12:21:27 christos Exp $ */
+
+/*-
+ * Copyright (c) 1995 Jean-Marc Zucconi
+ * All rights reserved.
+ *
+ * Ported to NetBSD by Matthieu Herrb <matthieu@laas.fr>
+ *
+ * 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
+ * in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/errno.h>
+#include <sys/conf.h>
+#include <machine/bus.h>
+
+#include <sys/joystick.h>
+#include <dev/ic/joyvar.h>
+
+/*
+ * The game port can manage 4 buttons and 4 variable resistors (usually 2
+ * joysticks, each with 2 buttons and 2 pots.) via the port at address 0x201.
+ * Getting the state of the buttons is done by reading the game port;
+ * buttons 1-4 correspond to bits 4-7 and resistors 1-4 (X1, Y1, X2, Y2)
+ * to bits 0-3. If button 1 (resp 2, 3, 4) is pressed, the bit 4 (resp 5,
+ * 6, 7) is set to 0 to get the value of a resistor, write the value 0xff
+ * at port and wait until the corresponding bit returns to 0.
+ */
+
+int joyopen(dev_t, int, int, struct proc *);
+int joyclose(dev_t, int, int, struct proc *);
+int joyread(dev_t, struct uio *, int);
+int joyioctl(dev_t, u_long, caddr_t, int, struct proc *);
+
+extern struct cfdriver joy_cd;
+
+
+void
+joyattach(struct joy_softc *sc)
+{
+ sc->timeout[0] = sc->timeout[1] = 0;
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, 0, 0xff);
+ DELAY(10000); /* 10 ms delay */
+ if ((bus_space_read_1(sc->sc_iot, sc->sc_ioh, 0) & 0x0f) != 0x0f)
+ printf("%s: joystick connected\n", sc->sc_dev.dv_xname);
+}
+
+int
+joyopen(dev_t dev, int flag, int mode, struct proc *p)
+{
+ int unit = JOYUNIT(dev);
+ int i = JOYPART(dev);
+ struct joy_softc *sc;
+
+ if (unit >= joy_cd.cd_ndevs)
+ return (ENXIO);
+ sc = joy_cd.cd_devs[unit];
+ if (sc == NULL)
+ return (ENXIO);
+
+ if (sc->timeout[i])
+ return (EBUSY);
+
+ sc->x_off[i] = sc->y_off[i] = 0;
+ sc->timeout[i] = JOY_TIMEOUT;
+ return (0);
+}
+
+int
+joyclose(dev_t dev, int flag, int mode, struct proc *p)
+{
+ int unit = JOYUNIT(dev);
+ int i = JOYPART(dev);
+ struct joy_softc *sc = joy_cd.cd_devs[unit];
+
+ sc->timeout[i] = 0;
+ return (0);
+}
+
+int
+joyread(dev_t dev, struct uio *uio, int flag)
+{
+ int unit = JOYUNIT(dev);
+ struct joy_softc *sc = joy_cd.cd_devs[unit];
+ bus_space_tag_t iot = sc->sc_iot;
+ bus_space_handle_t ioh = sc->sc_ioh;
+ struct joystick c;
+ int i, s;
+ struct timeval start, now, diff;
+ int state = 0, x = 0, y = 0;
+
+ s = splhigh(); /* XXX */
+ bus_space_write_1(iot, ioh, 0, 0xff);
+ microtime(&start);
+ now = start; /* structure assignment */
+ i = sc->timeout[JOYPART(dev)];
+ for (; {
+ timersub(&now, &start, &diff);
+ if (diff.tv_sec > 0 || diff.tv_usec > i)
+ break;
+ state = bus_space_read_1(iot, ioh, 0);
+ if (JOYPART(dev) == 1)
+ state >>= 2;
+ if (!x && !(state & 0x01))
+ x = diff.tv_usec;
+ if (!y && !(state & 0x02))
+ y = diff.tv_usec;
+ if (x && y)
+ break;
+ microtime(&now);
+ }
+ splx(s); /* XXX */
+
+ c.x = x ? sc->x_off[JOYPART(dev)] + x : 0x80000000;
+ c.y = y ? sc->y_off[JOYPART(dev)] + y : 0x80000000;
+ state >>= 4;
+ c.b1 = ~state & 1;
+ c.b2 = ~(state >> 1) & 1;
+ return (uiomove(&c, sizeof(struct joystick), uio));
+}
+
+int
+joyioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
+{
+ int unit = JOYUNIT(dev);
+ struct joy_softc *sc = joy_cd.cd_devs[unit];
+ int i = JOYPART(dev);
+ int x;
+
+ switch (cmd) {
+ case JOY_SETTIMEOUT:
+ x = *(int *)data;
+ if (x < 1 || x > 10000) /* 10ms maximum! */
+ return (EINVAL);
+ sc->timeout[i] = x;
+ break;
+ case JOY_GETTIMEOUT:
+ *(int *)data = sc->timeout[i];
+ break;
+ case JOY_SET_X_OFFSET:
+ sc->x_off[i] = *(int *)data;
+ break;
+ case JOY_SET_Y_OFFSET:
+ sc->y_off[i] = *(int *)data;
+ break;
+ case JOY_GET_X_OFFSET:
+ *(int *)data = sc->x_off[i];
+ break;
+ case JOY_GET_Y_OFFSET:
+ *(int *)data = sc->y_off[i];
+ break;
+ default:
+ return (ENXIO);
+ }
+ return 0;
+}
--- /dev/null Sun Jul 2 01:14:17 2006
+++ sys/dev/ic/joyvar.h Sat Jul 1 12:18:15 2006
@@ -0,0 +1,62 @@
+/* $OpenBSD$ */
+/* $NetBSD: joyvar.h,v 1.5 2005/12/11 12:21:27 christos Exp $ */
+
+/*-
+ * Copyright (c) 1995 Jean-Marc Zucconi
+ * All rights reserved.
+ *
+ * Ported to NetBSD by Matthieu Herrb <matthieu@laas.fr>
+ *
+ * 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
+ * in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
+ *
+ */
+
+#ifndef _JOYVAR_H_
+#define _JOYVAR_H_
+
+/*
+ * Data structures and prototypes used by joystick driver.
+ */
+
+#define JOYPART(d) (minor(d) & 1)
+#define JOYUNIT(d) (minor(d) >> 1)
+
+#ifndef JOY_TIMEOUT
+#define JOY_TIMEOUT 2000 /* 2 milliseconds */
+#endif
+
+#define JOY_NPORTS 1
+
+struct joy_softc {
+ struct device sc_dev;
+ bus_space_tag_t sc_iot;
+ bus_space_handle_t sc_ioh;
+ int x_off[2], y_off[2];
+ int timeout[2];
+};
+
+void joyattach(struct joy_softc *);
+int joydetach(struct joy_softc *, int);
+
+#endif /* ! _JOYVAR_H_ */
--- /dev/null Sun Jul 2 01:14:22 2006
+++ sys/dev/pci/joy_pci.c Sat Jul 1 12:17:18 2006
@@ -0,0 +1,142 @@
+/* $OpenBSD$ */
+/* $NetBSD: joy_pci.c,v 1.12 2005/12/11 12:22:50 christos Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Martin Husemann <martin@NetBSD.org>.
+ *
+ * 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.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 THE FOUNDATION OR CONTRIBUTORS
+ * 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>
+
+#include <sys/param.h>
+
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcidevs.h>
+
+#include <dev/ic/joyvar.h>
+
+int joy_pci_match(struct device *, void *, void *);
+void joy_pci_attach(struct device *, struct device *, void *);
+static int bar_is_io(pci_chipset_tag_t, pcitag_t, int);
+
+struct cfattach joy_pci_ca = {
+ sizeof(struct joy_softc), joy_pci_match, joy_pci_attach
+};
+
+struct cfdriver joy_cd = {
+ NULL, "joy", DV_DULL
+};
+
+int
+joy_pci_match(struct device *parent, void *match, void *aux)
+{
+ struct pci_attach_args *pa = aux;
+
+ if (PCI_CLASS(pa->pa_class) == PCI_CLASS_INPUT &&
+ PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_INPUT_GAMEPORT &&
+ PCI_INTERFACE(pa->pa_class) == 0x10)
+ return (1);
+
+ if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_CREATIVELABS &&
+ (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CREATIVELABS_SBJOY ||
+ PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CREATIVELABS_SBJOY2 ||
+ PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CREATIVELABS_SBJOY3)) {
+ return (1);
+ }
+
+ return (0);
+}
+
+/* check if this BAR assigns/requests IO space */
+static int
+bar_is_io(pci_chipset_tag_t pc, pcitag_t tag, int reg)
+{
+ pcireg_t address, mask;
+
+ address = pci_conf_read(pc, tag, reg);
+ pci_conf_write(pc, tag, reg, 0xffffffff);
+ mask = pci_conf_read(pc, tag, reg);
+ pci_conf_write(pc, tag, reg, address);
+
+ return (PCI_MAPREG_TYPE(address) == PCI_MAPREG_TYPE_IO &&
+ PCI_MAPREG_IO_SIZE(mask) > 0);
+}
+
+void
+joy_pci_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct joy_softc *sc = (struct joy_softc *)self;
+ struct pci_attach_args *pa = aux;
+ char devinfo[256];
+ bus_size_t mapsize;
+ int reg;
+
+ pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
+ printf("\n");
+
+ for (reg = PCI_MAPREG_START; reg < PCI_MAPREG_END;
+ reg += sizeof(pcireg_t))
+ if (bar_is_io(pa->pa_pc, pa->pa_tag, reg))
+ break;
+ if (reg >= PCI_MAPREG_END) {
+ printf("%s: violates PCI spec, no IO region found\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+
+ if (pci_mapreg_map(pa, reg, PCI_MAPREG_TYPE_IO, 0,
+ &sc->sc_iot, &sc->sc_ioh, NULL, &mapsize, 0) != 0) {
+ printf("%s: could not map IO space\n", sc->sc_dev.dv_xname);
+ return;
+ }
+
+ if (mapsize != 2) {
+ if (!bus_space_subregion(sc->sc_iot, sc->sc_ioh, 1, 1,
+ &sc->sc_ioh) < 0) {
+ printf("%s: error mapping subregion\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+ }
+
+ joyattach(sc);
+}
+
--- /dev/null Sun Jul 2 01:14:26 2006
+++ sys/dev/isa/joy_isa.c Sat Jul 1 14:00:01 2006
@@ -0,0 +1,114 @@
+/* $OpenBSD$ */
+/* $NetBSD: joy_isa.c,v 1.8 2005/12/11 12:22:03 christos Exp $ */
+
+/*-
+ * Copyright (c) 1995 Jean-Marc Zucconi
+ * All rights reserved.
+ *
+ * Ported to NetBSD by Matthieu Herrb <matthieu@laas.fr>. Additional
+ * modification by Jason R. Thorpe <thorpej@NetBSD.org>.
+ *
+ * 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
+ * in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+
+#include <dev/isa/isavar.h>
+
+#include <dev/ic/joyvar.h>
+
+
+int joy_isa_probe(struct device *, void *, void *);
+void joy_isa_attach(struct device *, struct device *, void *);
+
+struct cfattach joy_isa_ca = {
+ sizeof(struct joy_softc), joy_isa_probe, joy_isa_attach
+};
+
+int
+joy_isa_probe(struct device *parent, void *match, void *aux)
+{
+ struct isa_attach_args *ia = aux;
+ bus_space_tag_t iot;
+ bus_space_handle_t ioh;
+ int rval = 0;
+ int iobase;
+
+ iot = ia->ia_iot;
+ iobase = ia->ipa_io[0].base;
+
+ if (bus_space_map(iot, iobase, JOY_NPORTS, 0, &ioh)) {
+ printf(": can't map i/o space\n");
+ return (0);
+ }
+
+#ifdef WANT_JOYSTICK_CONNECTED
+ bus_space_write_1(iot, ioh, 0, 0xff);
+ DELAY(10000); /* 10 ms delay */
+ if ((bus_space_read_1(iot, ioh, 0) & 0x0f) != 0x0f)
+ rval = 1;
+#else
+ rval = 1;
+#endif
+
+ bus_space_unmap(iot, ioh, JOY_NPORTS);
+
+ if (rval) {
+ ia->ipa_nio = 1;
+ ia->ipa_io[0].length = JOY_NPORTS;
+
+ ia->ipa_nmem = 0;
+ ia->ipa_nirq = 0;
+ ia->ipa_ndrq = 0;
+ }
+ return (rval);
+}
+
+void
+joy_isa_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct joy_softc *sc = (struct joy_softc *) self;
+ struct isa_attach_args *ia = aux;
+ int iobase;
+
+ printf("\n");
+
+ sc->sc_iot = ia->ia_iot;
+ iobase = ia->ipa_io[0].base;;
+
+ if (bus_space_map(sc->sc_iot, iobase, JOY_NPORTS, 0, &sc->sc_ioh)) {
+ printf(": can't map i/o space\n");
+ return;
+ }
+
+ joyattach(sc);
+}
--- /dev/null Sun Jul 2 01:14:30 2006
+++ sys/dev/isa/joy_isapnp.c Sat Jul 1 14:24:47 2006
@@ -0,0 +1,105 @@
+/* $OpenBSD$ */
+/* $NetBSD: joy_isapnp.c,v 1.6 2005/12/11 12:22:16 christos Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * 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.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 THE FOUNDATION OR CONTRIBUTORS
+ * 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>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+
+#include <dev/isa/isavar.h>
+#include <dev/isa/isapnpreg.h>
+
+#include <dev/ic/joyvar.h>
+
+int joy_isapnp_probe(struct device *, void *, void *);
+void joy_isapnp_attach(struct device *, struct device *, void *);
+
+struct cfattach joy_isapnp_ca = {
+ sizeof(struct joy_softc), joy_isapnp_probe, joy_isapnp_attach
+};
+
+int
+joy_isapnp_probe(struct device *parent, void *match, void *aux)
+{
+ return (1);
+}
+
+void
+joy_isapnp_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct joy_softc *sc = (struct joy_softc *)self;
+ struct isa_attach_args *ipa = aux;
+ bus_space_handle_t ioh;
+ bus_space_handle_t nich;
+ bus_space_tag_t iot;
+ bus_space_tag_t memt;
+
+ nich = ipa->ipa_io[0].h;
+ iot = ipa->ia_iot;
+ memt = ipa->ia_memt;
+
+ printf("\n");
+
+ if (isapnp_config(iot, memt, ipa)) {
+ printf("%s: error in region allocation\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+
+ if (ipa->ipa_io[0].length == 8) {
+ if (bus_space_subregion(iot, nich, 1, 1, &ioh) < 0) {
+ printf("%s: error in region allocation\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+ } else
+ ioh = ipa->ipa_io[0].h;
+
+ sc->sc_iot = ipa->ia_iot;
+ sc->sc_ioh = ioh;
+
+ printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
+ ipa->ipa_devclass);
+
+ joyattach(sc);
+}
--- /dev/null Sun Jul 2 01:14:36 2006
+++ sys/sys/joystick.h Sat Jul 1 01:59:57 2006
@@ -0,0 +1,24 @@
+/* $OpenBSD$ */
+/* $NetBSD: joystick.h,v 1.2 2005/12/03 17:10:46 christos Exp $ */
+
+#ifndef _SYS_JOYSTICK_H_
+#define _SYS_JOYSTICK_H_
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+struct joystick {
+ int x;
+ int y;
+ int b1;
+ int b2;
+};
+
+#define JOY_SETTIMEOUT _IOW('J', 1, int) /* set timeout */
+#define JOY_GETTIMEOUT _IOR('J', 2, int) /* get timeout */
+#define JOY_SET_X_OFFSET _IOW('J', 3, int) /* set offset on X-axis */
+#define JOY_SET_Y_OFFSET _IOW('J', 4, int) /* set offset on Y-axis */
+#define JOY_GET_X_OFFSET _IOR('J', 5, int) /* get offset on X-axis */
+#define JOY_GET_Y_OFFSET _IOR('J', 6, int) /* get offset on Y-axis */
+
+#endif /* _SYS_JOYSTICK_H_ */
Index: sys/dev/pci/files.pci
================================================== =================
RCS file: /cvs/src/sys/dev/pci/files.pci,v
retrieving revision 1.209
diff -u -r1.209 files.pci
--- sys/dev/pci/files.pci 2006/06/29 22:14:41 1.209
+++ sys/dev/pci/files.pci 2006/07/01 21:15:23
@@ -164,6 +164,10 @@
attach auvia at pci
file dev/pci/auvia.c auvia

+# Game adapter (joystick)
+attach joy at pci with joy_pci
+file dev/pci/joy_pci.c joy_pci
+
# ICP Vortex GDT PCI RAID controllers
# device declaration in sys/conf/files
attach gdt at pci with gdt_pci
Index: sys/dev/isa/files.isa
================================================== =================
RCS file: /cvs/src/sys/dev/isa/files.isa,v
retrieving revision 1.94
diff -u -r1.94 files.isa
--- sys/dev/isa/files.isa 2006/03/26 20:19:53 1.94
+++ sys/dev/isa/files.isa 2006/07/01 21:15:23
@@ -374,6 +374,10 @@
attach lpt at isa with lpt_isa
file dev/isa/lpt_isa.c lpt_isa needs-flag

+# Game adapter (joystick)
+attach joy at isa with joy_isa
+file dev/isa/joy_isa.c joy_isa
+
# National Semiconductor LM78/79/81 and compatible hardware monitors
attach lm at isa with lm_isa
file dev/isa/lm78_isa.c lm_isa
Index: sys/dev/isa/files.isapnp
================================================== =================
RCS file: /cvs/src/sys/dev/isa/files.isapnp,v
retrieving revision 1.28
diff -u -r1.28 files.isapnp
--- sys/dev/isa/files.isapnp 2005/03/08 20:00:25 1.28
+++ sys/dev/isa/files.isapnp 2006/07/01 21:15:23
@@ -68,3 +68,7 @@
attach ym at isapnp with ym_isapnp
file dev/isa/ym.c ym_isapnp
file dev/isa/ym_isapnp.c ym_isapnp
+
+# Game adapter (joystick)
+attach joy at isapnp with joy_isapnp
+file dev/isa/joy_isapnp.c joy_isapnp
Index: sys/conf/files
================================================== =================
RCS file: /cvs/src/sys/conf/files,v
retrieving revision 1.379
diff -u -r1.379 files
--- sys/conf/files 2006/06/29 22:14:41 1.379
+++ sys/conf/files 2006/07/01 21:16:02
@@ -935,3 +935,8 @@
# NMEA0183 support
pseudo-device nmea: tty
file kern/tty_nmea.c nmea needs-flag
+
+# Game adapter (joystick)
+device joy
+file dev/ic/joy.c joy needs-flag
+
Index: sys/arch/i386/conf/files.i386
================================================== =================
RCS file: /cvs/src/sys/arch/i386/conf/files.i386,v
retrieving revision 1.149
diff -u -r1.149 files.i386
--- sys/arch/i386/conf/files.i386 2006/06/19 15:13:34 1.149
+++ sys/arch/i386/conf/files.i386 2006/07/01 21:16:23
@@ -234,12 +234,12 @@
attach pccom at isapnp with pccom_isapnp

# Game adapter (joystick)
-device joy
-file arch/i386/isa/joy.c joy needs-flag
-attach joy at isa with joy_isa
-file arch/i386/isa/joy_isa.c joy_isa
-attach joy at isapnp with joy_isapnp
-file arch/i386/isa/joy_isapnp.c joy_isapnp
+#device joy
+#file arch/i386/isa/joy.c joy needs-flag
+#attach joy at isa with joy_isa
+#file arch/i386/isa/joy_isa.c joy_isa
+#attach joy at isapnp with joy_isapnp
+#file arch/i386/isa/joy_isapnp.c joy_isapnp

#
# Compatibility modules

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:15 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886