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