Source-Changes-HG archive

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

[src/chs-ubc2]: src/sys/dev Update from trunk.



details:   https://anonhg.NetBSD.org/src/rev/e4d799c5fb28
branches:  chs-ubc2
changeset: 471434:e4d799c5fb28
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Aug 02 22:03:54 1999 +0000

description:
Update from trunk.

diffstat:

 sys/dev/pci/eap.c         |    14 +-
 sys/dev/pci/eso.c         |  1823 +++++++++++++++++++++++++++++++++++++++++++++
 sys/dev/pci/esoreg.h      |   244 ++++++
 sys/dev/pci/esovar.h      |   139 +++
 sys/dev/pci/if_epic_pci.c |    44 +-
 sys/dev/pci/if_ex_pci.c   |     4 +-
 sys/dev/pci/ncr.c         |     6 +-
 sys/dev/pci/opl_eso.c     |   101 ++
 sys/dev/pci/pucdata.c     |   418 +++++++++-
 sys/dev/pcmcia/pcmciadevs |    17 +-
 10 files changed, 2766 insertions(+), 44 deletions(-)

diffs (truncated from 3020 to 300 lines):

diff -r e9224b3e3e16 -r e4d799c5fb28 sys/dev/pci/eap.c
--- a/sys/dev/pci/eap.c Mon Aug 02 22:03:20 1999 +0000
+++ b/sys/dev/pci/eap.c Mon Aug 02 22:03:54 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eap.c,v 1.25 1999/02/18 07:59:30 mycroft Exp $ */
+/*     $NetBSD: eap.c,v 1.25.4.1 1999/08/02 22:03:54 thorpej Exp $     */
 
 /*
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -1298,13 +1298,13 @@
        int pool;
 {
        struct eap_softc *sc = addr;
-       struct eap_dma **p;
+       struct eap_dma **pp, *p;
 
-       for (p = &sc->sc_dmas; *p; p = &(*p)->next) {
-               if (KERNADDR(*p) == ptr) {
-                       eap_freemem(sc, *p);
-                       *p = (*p)->next;
-                       free(*p, pool);
+       for (pp = &sc->sc_dmas; (p = *pp) != NULL; pp = &p->next) {
+               if (KERNADDR(p) == ptr) {
+                       eap_freemem(sc, p);
+                       *pp = p->next;
+                       free(p, pool);
                        return;
                }
        }
diff -r e9224b3e3e16 -r e4d799c5fb28 sys/dev/pci/eso.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/eso.c Mon Aug 02 22:03:54 1999 +0000
@@ -0,0 +1,1823 @@
+/*     $NetBSD: eso.c,v 1.3.2.2 1999/08/02 22:03:56 thorpej Exp $      */
+
+/*
+ * Copyright (c) 1999 Klaus J. Klein
+ * 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.
+ * 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.
+ */
+
+/*
+ * ESS Technology Inc. Solo-1 PCI AudioDrive (ES1938/1946) device driver.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/device.h>
+#include <sys/proc.h>
+
+#include <dev/pci/pcidevs.h>
+#include <dev/pci/pcivar.h>
+
+#include <sys/audioio.h>
+#include <dev/audio_if.h>
+#include <dev/midi_if.h>
+
+#include <dev/mulaw.h>
+#include <dev/auconv.h>
+
+#include <dev/ic/mpuvar.h>
+#include <dev/ic/i8237reg.h>
+#include <dev/pci/esoreg.h>
+#include <dev/pci/esovar.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#if BYTE_ORDER == BIG_ENDIAN
+#include <machine/bswap.h>
+#define htopci(x) bswap32(x)
+#define pcitoh(x) bswap32(x)
+#else
+#define htopci(x) (x)
+#define pcitoh(x) (x)
+#endif
+
+
+#if defined(AUDIO_DEBUG) || defined(DEBUG)
+#define DPRINTF(x) printf x
+#else
+#define DPRINTF(x)
+#endif
+
+struct eso_dma {
+       bus_dmamap_t            ed_map;
+       caddr_t                 ed_addr;
+       bus_dma_segment_t       ed_segs[1];
+       int                     ed_nsegs;
+       size_t                  ed_size;
+       struct eso_dma *        ed_next;
+};
+
+#define KVADDR(dma)    ((void *)(dma)->ed_addr)
+#define DMAADDR(dma)   ((dma)->ed_map->dm_segs[0].ds_addr)
+
+/* Autoconfiguration interface */
+static int eso_match __P((struct device *, struct cfdata *, void *));
+static void eso_attach __P((struct device *, struct device *, void *));
+static void eso_defer __P((struct device *));
+
+struct cfattach eso_ca = {
+       sizeof (struct eso_softc), eso_match, eso_attach
+};
+
+/* PCI interface */
+static int eso_intr __P((void *));
+
+/* MI audio layer interface */
+static int     eso_open __P((void *, int));
+static void    eso_close __P((void *));
+static int     eso_query_encoding __P((void *, struct audio_encoding *));
+static int     eso_set_params __P((void *, int, int, struct audio_params *,
+                   struct audio_params *));
+static int     eso_round_blocksize __P((void *, int));
+static int     eso_halt_output __P((void *));
+static int     eso_halt_input __P((void *));
+static int     eso_getdev __P((void *, struct audio_device *));
+static int     eso_set_port __P((void *, mixer_ctrl_t *));
+static int     eso_get_port __P((void *, mixer_ctrl_t *));
+static int     eso_query_devinfo __P((void *, mixer_devinfo_t *));
+static void *  eso_allocm __P((void *, int, size_t, int, int));
+static void    eso_freem __P((void *, void *, int));
+static size_t  eso_round_buffersize __P((void *, int, size_t));
+static int     eso_mappage __P((void *, void *, int, int));
+static int     eso_get_props __P((void *));
+static int     eso_trigger_output __P((void *, void *, void *, int,
+                   void (*)(void *), void *, struct audio_params *));
+static int     eso_trigger_input __P((void *, void *, void *, int,
+                   void (*)(void *), void *, struct audio_params *));
+
+static struct audio_hw_if eso_hw_if = {
+       eso_open,
+       eso_close,
+       NULL,                   /* drain */
+       eso_query_encoding,
+       eso_set_params,
+       eso_round_blocksize,
+       NULL,                   /* commit_settings */
+       NULL,                   /* init_output */
+       NULL,                   /* init_input */
+       NULL,                   /* start_output */
+       NULL,                   /* start_input */
+       eso_halt_output,
+       eso_halt_input,
+       NULL,                   /* speaker_ctl */
+       eso_getdev,
+       NULL,                   /* setfd */
+       eso_set_port,
+       eso_get_port,
+       eso_query_devinfo,
+       eso_allocm,
+       eso_freem,
+       eso_round_buffersize,
+       eso_mappage,
+       eso_get_props,
+       eso_trigger_output,
+       eso_trigger_input
+};
+
+static const char * const eso_rev2model[] = {
+       "ES1938",
+       "ES1946"
+};
+
+
+/*
+ * Utility routines
+ */
+/* Register access etc. */
+static uint8_t eso_read_ctlreg __P((struct eso_softc *, uint8_t));
+static uint8_t eso_read_mixreg __P((struct eso_softc *, uint8_t));
+static uint8_t eso_read_rdr __P((struct eso_softc *));
+static int     eso_reset __P((struct eso_softc *));
+static void    eso_set_gain __P((struct eso_softc *, unsigned int));
+static int     eso_set_recsrc __P((struct eso_softc *, unsigned int));
+static void    eso_write_cmd __P((struct eso_softc *, uint8_t));
+static void    eso_write_ctlreg __P((struct eso_softc *, uint8_t, uint8_t));
+static void    eso_write_mixreg __P((struct eso_softc *, uint8_t, uint8_t));
+/* DMA memory allocation */
+static int     eso_allocmem __P((struct eso_softc *, size_t, size_t, size_t,
+                   int, struct eso_dma *));
+static void    eso_freemem __P((struct eso_softc *, struct eso_dma *));
+
+
+static int
+eso_match(parent, match, aux)
+       struct device *parent;
+       struct cfdata *match;
+       void *aux;
+{
+       struct pci_attach_args *pa = aux;
+
+       if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ESSTECH &&
+           PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ESSTECH_SOLO1)
+               return (1);
+
+       return (0);
+}
+
+static void
+eso_attach(parent, self, aux)
+       struct device *parent, *self;
+       void *aux;
+{
+       struct eso_softc *sc = (struct eso_softc *)self;
+       struct pci_attach_args *pa = aux;
+       struct audio_attach_args aa;
+       pci_intr_handle_t ih;
+       bus_addr_t vcbase;
+       const char *intrstring;
+       int idx;
+       uint8_t a2mode;
+
+       sc->sc_revision = PCI_REVISION(pa->pa_class);
+
+       printf(": ESS Solo-1 PCI AudioDrive ");
+       if (sc->sc_revision <=
+           sizeof (eso_rev2model) / sizeof (eso_rev2model[0]))
+               printf("%s\n", eso_rev2model[sc->sc_revision]);
+       else
+               printf("(unknown rev. 0x%02x)\n", sc->sc_revision);
+
+       /* Map I/O registers. */
+       if (pci_mapreg_map(pa, ESO_PCI_BAR_IO, PCI_MAPREG_TYPE_IO, 0,
+           &sc->sc_iot, &sc->sc_ioh, NULL, NULL)) {
+               printf("%s: can't map I/O space\n", sc->sc_dev.dv_xname);
+               return;
+       }
+       if (pci_mapreg_map(pa, ESO_PCI_BAR_SB, PCI_MAPREG_TYPE_IO, 0,
+           &sc->sc_sb_iot, &sc->sc_sb_ioh, NULL, NULL)) {
+               printf("%s: can't map SB I/O space\n", sc->sc_dev.dv_xname);
+               return;
+       }
+       if (pci_mapreg_map(pa, ESO_PCI_BAR_VC, PCI_MAPREG_TYPE_IO, 0,
+           &sc->sc_dmac_iot, &sc->sc_dmac_ioh, &vcbase, &sc->sc_vcsize)) {
+               printf("%s: can't map VC I/O space\n", sc->sc_dev.dv_xname);
+               /* Don't bail out yet: we can map it later, see below. */
+               vcbase = 0;
+               sc->sc_vcsize = 0x10; /* From the data sheet. */
+       }
+
+       if (pci_mapreg_map(pa, ESO_PCI_BAR_MPU, PCI_MAPREG_TYPE_IO, 0,
+           &sc->sc_mpu_iot, &sc->sc_mpu_ioh, NULL, NULL)) {
+               printf("%s: can't map MPU I/O space\n", sc->sc_dev.dv_xname);
+               return;
+       }
+       if (pci_mapreg_map(pa, ESO_PCI_BAR_GAME, PCI_MAPREG_TYPE_IO, 0,
+           &sc->sc_game_iot, &sc->sc_game_ioh, NULL, NULL)) {
+               printf("%s: can't map Game I/O space\n", sc->sc_dev.dv_xname);
+               return;
+       }
+
+       sc->sc_dmat = pa->pa_dmat;
+       sc->sc_dmas = NULL;
+       sc->sc_dmac_configured = 0;
+
+       /* Enable bus mastering. */
+       pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
+           pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG) |
+           PCI_COMMAND_MASTER_ENABLE);
+
+       /* Reset the device; bail out upon failure. */
+       if (eso_reset(sc) != 0) {
+               printf("%s: can't reset\n", sc->sc_dev.dv_xname);
+               return;
+       }
+       
+       /* Select the DMA/IRQ policy: DDMA, ISA IRQ emulation disabled. */
+       pci_conf_write(pa->pa_pc, pa->pa_tag, ESO_PCI_S1C,
+           pci_conf_read(pa->pa_pc, pa->pa_tag, ESO_PCI_S1C) &
+           ~(ESO_PCI_S1C_IRQP_MASK | ESO_PCI_S1C_DMAP_MASK));
+
+       /* Enable the relevant DMA interrupts. */
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, ESO_IO_IRQCTL,
+           ESO_IO_IRQCTL_A1IRQ | ESO_IO_IRQCTL_A2IRQ);



Home | Main Index | Thread Index | Old Index