This is a discussion on Updated joy(4) driver within the mailing.openbsd.tech forums, part of the OpenBSD category; --> Hi all, This is an updated joy(4) driver from NetBSD. It is untested since I have no joysticks themselves ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |