1 /* $OpenBSD: gus_isapnp.c,v 1.11 2024/05/28 09:27:08 jsg Exp $ */ 2 /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ 3 4 /*- 5 * Copyright (c) 1996 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Ken Hornstein and John Kohl. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 /* 34 * 35 * TODO: 36 * . figure out why mixer activity while sound is playing causes problems 37 * (phantom interrupts?) 38 * . figure out a better deinterleave strategy that avoids sucking up 39 * CPU, memory and cache bandwidth. (Maybe a special encoding? 40 * Maybe use the double-speed sampling/hardware deinterleave trick 41 * from the GUS SDK?) A 486/33 isn't quite fast enough to keep 42 * up with 44.1kHz 16-bit stereo output without some drop-outs. 43 * . use CS4231 for 16-bit sampling, for a-law and mu-law playback. 44 * . actually test full-duplex sampling(recording) and playback. 45 */ 46 47 /* 48 * Gravis UltraSound driver 49 * 50 * For more detailed information, see the GUS developers' kit 51 * available on the net at: 52 * 53 * ftp://freedom.nmsu.edu/pub/ultrasound/gravis/util/ 54 * gusdkXXX.zip (developers' kit--get rev 2.22 or later) 55 * See ultrawrd.doc inside--it's MS Word (ick), but it's the bible 56 * 57 */ 58 59 /* 60 * The GUS Max has a slightly strange set of connections between the CS4231 61 * and the GF1 and the DMA interconnects. It's set up so that the CS4231 can 62 * be playing while the GF1 is loading patches from the system. 63 * 64 * Here's a recreation of the DMA interconnect diagram: 65 * 66 * GF1 67 * +---------+ digital 68 * | | record ASIC 69 * | |--------------+ 70 * | | | +--------+ 71 * | | play (dram) | +----+ | | 72 * | |--------------(------|-\ | | +-+ | 73 * +---------+ | | >-|----|---|C|--|------ dma chan 1 74 * | +---|-/ | | +-+ | 75 * | | +----+ | | | 76 * | | +----+ | | | 77 * +---------+ +-+ +--(---|-\ | | | | 78 * | | play |8| | | >-|----|----+---|------ dma chan 2 79 * | ---C----|--------|/|------(---|-/ | | | 80 * | ^ |record |1| | +----+ | | 81 * | | | /----|6|------+ +--------+ 82 * | ---+----|--/ +-+ 83 * +---------+ 84 * CS4231 8-to-16 bit bus conversion, if needed 85 * 86 * 87 * "C" is an optional combiner. 88 * 89 */ 90 91 #include <sys/param.h> 92 #include <sys/systm.h> 93 #include <sys/errno.h> 94 #include <sys/ioctl.h> 95 #include <sys/syslog.h> 96 #include <sys/device.h> 97 #include <sys/buf.h> 98 #include <sys/fcntl.h> 99 #include <sys/malloc.h> 100 #include <sys/kernel.h> 101 #include <sys/timeout.h> 102 103 #include <machine/cpu.h> 104 #include <machine/intr.h> 105 #include <machine/bus.h> 106 #include <machine/cpufunc.h> 107 #include <sys/audioio.h> 108 #include <dev/audio_if.h> 109 110 #include <dev/isa/isavar.h> 111 #include <dev/isa/isadmavar.h> 112 113 #include <dev/ic/ics2101reg.h> 114 #include <dev/ic/cs4231reg.h> 115 #include <dev/ic/ad1848reg.h> 116 #include <dev/isa/ics2101var.h> 117 #include <dev/isa/ad1848var.h> 118 #include "gusreg.h" 119 #include "gusvar.h" 120 121 int gus_isapnp_match(struct device *, void *, void *); 122 void gus_isapnp_attach(struct device *, struct device *, void *); 123 124 const struct cfattach gus_isapnp_ca = { 125 sizeof(struct gus_softc), gus_isapnp_match, gus_isapnp_attach 126 }; 127 128 /* 129 * Probe for the GUS hardware. 130 */ 131 int 132 gus_isapnp_match(struct device *parent, void *match, void *aux) 133 { 134 return 1; 135 } 136 137 void 138 gus_isapnp_attach(struct device *parent, struct device *self, void *aux) 139 { 140 struct gus_softc *sc = (void *) self; 141 struct isa_attach_args *ipa = aux; 142 143 sc->sc_iot = ipa->ia_iot; 144 sc->sc_iobase = ipa->ia_iobase; 145 146 sc->sc_ioh1 = ipa->ipa_io[0].h; /* p2xr */ 147 sc->sc_ioh2 = ipa->ipa_io[1].h; /* p3xr */ 148 sc->sc_ioh3 = ipa->ipa_io[2].h; /* codec/mixer */ 149 sc->sc_ioh4 = (bus_space_handle_t)NULL; /* midi */ 150 151 sc->sc_irq = ipa->ipa_irq[0].num; 152 sc->sc_drq = ipa->ipa_drq[1].num; 153 sc->sc_recdrq = ipa->ipa_drq[0].num; 154 sc->sc_isa = parent->dv_parent; 155 156 gus_subattach(sc, ipa); 157 } 158