sbdspvar.h revision 1.32 1 /* $NetBSD: sbdspvar.h,v 1.32 1997/10/16 23:35:03 augustss Exp $ */
2
3 /*
4 * Copyright (c) 1991-1993 Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the Computer Systems
18 * Engineering Group at Lawrence Berkeley Laboratory.
19 * 4. Neither the name of the University nor of the Laboratory may be used
20 * to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 */
36
37 #define SB_MASTER_VOL 0
38 #define SB_MIDI_VOL 1
39 #define SB_CD_VOL 2
40 #define SB_VOICE_VOL 3
41 #define SB_OUTPUT_CLASS 4
42
43 #define SB_MIC_VOL 5
44 #define SB_LINE_IN_VOL 6
45 #define SB_RECORD_SOURCE 7
46 #define SB_TREBLE 8
47 #define SB_BASS 9
48 #define SB_RECORD_CLASS 10
49 #define SB_INPUT_CLASS 11
50
51 #define SB_PCSPEAKER 12
52 #define SB_INPUT_GAIN 13
53 #define SB_OUTPUT_GAIN 14
54 #define SB_AGC 15
55 #define SB_EQUALIZATION_CLASS 16
56
57 #define SB_CD_IN_MUTE 17
58 #define SB_MIC_IN_MUTE 18
59 #define SB_LINE_IN_MUTE 19
60 #define SB_MIDI_IN_MUTE 20
61
62 #define SB_CD_SWAP 21
63 #define SB_MIC_SWAP 22
64 #define SB_LINE_SWAP 23
65 #define SB_MIDI_SWAP 24
66
67 #define SB_CD_OUT_MUTE 25
68 #define SB_MIC_OUT_MUTE 26
69 #define SB_LINE_OUT_MUTE 27
70
71 #define SB_NDEVS 28
72
73 #define SB_IS_IN_MUTE(x) ((x) < SB_CD_SWAP)
74
75 /*
76 * Software state, per SoundBlaster card.
77 * The soundblaster has multiple functionality, which we must demultiplex.
78 * One approach is to have one major device number for the soundblaster card,
79 * and use different minor numbers to indicate which hardware function
80 * we want. This would make for one large driver. Instead our approach
81 * is to partition the design into a set of drivers that share an underlying
82 * piece of hardware. Most things are hard to share, for example, the audio
83 * and midi ports. For audio, we might want to mix two processes' signals,
84 * and for midi we might want to merge streams (this is hard due to
85 * running status). Moreover, we should be able to re-use the high-level
86 * modules with other kinds of hardware. In this module, we only handle the
87 * most basic communications with the sb card.
88 */
89 struct sbdsp_softc {
90 struct device sc_dev; /* base device */
91 struct isadev sc_id; /* ISA device */
92 isa_chipset_tag_t sc_ic;
93 bus_space_tag_t sc_iot; /* tag */
94 bus_space_handle_t sc_ioh; /* handle */
95 void *sc_ih; /* interrupt vectoring */
96
97 int sc_iobase; /* I/O port base address */
98 int sc_irq; /* interrupt */
99 int sc_drq8; /* DMA (8-bit) */
100 int sc_drq16; /* DMA (16-bit) */
101
102 struct device *sc_isa; /* pointer to ISA parent */
103
104 u_short sc_open; /* reference count of open calls */
105 int sc_openflags; /* flags used on open */
106 u_char sc_fullduplex; /* can do full duplex */
107
108 u_char gain[SB_NDEVS][2]; /* kept in input levels */
109 #define SB_LEFT 0
110 #define SB_RIGHT 1
111 #define SB_LR 0
112
113 u_int out_port; /* output port */
114 u_int in_mask; /* input ports */
115 u_int in_port; /* XXX needed for MI interface */
116 u_int in_filter; /* one of SB_TREBLE_EQ, SB_BASS_EQ, 0 */
117
118 u_int spkr_state; /* non-null is on */
119
120 struct sbdsp_state {
121 u_int rate; /* Sample rate */
122 u_char tc; /* Time constant */
123 struct sbmode *modep;
124 u_char bmode;
125 int dmachan; /* DMA channel */
126 u_char run;
127 #define SB_NOTRUNNING 0 /* Not running, not initialized */
128 #define SB_DMARUNNING 1 /* DMA has been initialized */
129 #define SB_PCMRUNNING 2 /* DMA&PCM running (looping mode) */
130 #define SB_RUNNING 3 /* non-looping mode */
131 } sc_i, sc_o; /* Input and output state */
132
133 u_long sc_interrupts; /* number of interrupts taken */
134 void (*sc_intr8)(void*); /* dma completion intr handler */
135 void *sc_arg8; /* arg for sc_intr8() */
136 void (*sc_intr16)(void*); /* dma completion intr handler */
137 void *sc_arg16; /* arg for sc_intr16() */
138 void (*sc_mintr)(void*, int);/* midi input intr handler */
139
140 u_int sc_mixer_model;
141 #define SBM_NONE 0
142 #define SBM_CT1335 1
143 #define SBM_CT1345 2
144 #define SBM_CT1XX5 3
145 #define SBM_CT1745 4
146 #define ISSBM1745(x) ((x)->sc_mixer_model >= SBM_CT1XX5)
147
148 u_int sc_model; /* DSP model */
149 #define SB_UNK -1
150 #define SB_1 0 /* original SB */
151 #define SB_20 1 /* SB 2 */
152 #define SB_2x 2 /* SB 2, new version */
153 #define SB_PRO 3 /* SB Pro */
154 #define SB_JAZZ 4 /* Jazz 16 */
155 #define SB_16 5 /* SB 16 */
156 #define SB_32 6 /* SB AWE 32 */
157 #define SB_64 7 /* SB AWE 64 */
158
159 #define SB_NAMES { "SB_1", "SB_2.0", "SB_2.x", "SB_Pro", "Jazz_16", "SB_16", "SB_AWE_32", "SB_AWE_64" }
160
161 u_int sc_version; /* DSP version */
162 #define SBVER_MAJOR(v) (((v)>>8) & 0xff)
163 #define SBVER_MINOR(v) ((v)&0xff)
164 };
165
166 #define ISSBPRO(sc) ((sc)->sc_model == SB_PRO || (sc)->sc_model == SB_JAZZ)
167 #define ISSBPROCLASS(sc) ((sc)->sc_model >= SB_PRO)
168 #define ISSB16CLASS(sc) ((sc)->sc_model >= SB_16)
169
170 #ifdef _KERNEL
171 int sbdsp_open __P((void *, int));
172 void sbdsp_close __P((void *));
173
174 int sbdsp_probe __P((struct sbdsp_softc *));
175 void sbdsp_attach __P((struct sbdsp_softc *));
176
177 int sbdsp_set_in_gain __P((void *, u_int, u_char));
178 int sbdsp_set_in_gain_real __P((void *, u_int, u_char));
179 int sbdsp_get_in_gain __P((void *));
180 int sbdsp_set_out_gain __P((void *, u_int, u_char));
181 int sbdsp_set_out_gain_real __P((void *, u_int, u_char));
182 int sbdsp_get_out_gain __P((void *));
183 int sbdsp_set_monitor_gain __P((void *, u_int));
184 int sbdsp_get_monitor_gain __P((void *));
185 int sbdsp_query_encoding __P((void *, struct audio_encoding *));
186 int sbdsp_set_params __P((void *, int, int, struct audio_params *, struct audio_params *));
187 int sbdsp_round_blocksize __P((void *, int));
188 int sbdsp_set_out_port __P((void *, int));
189 int sbdsp_get_out_port __P((void *));
190 int sbdsp_set_in_port __P((void *, int));
191 int sbdsp_get_in_port __P((void *));
192 int sbdsp_get_avail_in_ports __P((void *));
193 int sbdsp_get_avail_out_ports __P((void *));
194 int sbdsp_speaker_ctl __P((void *, int));
195
196 int sbdsp_commit __P((void *));
197 int sbdsp_dma_init_input __P((void *, void *, int));
198 int sbdsp_dma_init_output __P((void *, void *, int));
199 int sbdsp_dma_output __P((void *, void *, int, void (*)(void *), void*));
200 int sbdsp_dma_input __P((void *, void *, int, void (*)(void *), void*));
201
202 int sbdsp_haltdma __P((void *));
203 int sbdsp_contdma __P((void *));
204
205 void sbdsp_compress __P((int, u_char *, int));
206 void sbdsp_expand __P((int, u_char *, int));
207
208 int sbdsp_reset __P((struct sbdsp_softc *));
209 void sbdsp_spkron __P((struct sbdsp_softc *));
210 void sbdsp_spkroff __P((struct sbdsp_softc *));
211
212 int sbdsp_wdsp __P((struct sbdsp_softc *, int v));
213 int sbdsp_rdsp __P((struct sbdsp_softc *));
214
215 int sbdsp_intr __P((void *));
216
217 int sbdsp_set_sr __P((struct sbdsp_softc *, u_long *, int));
218
219 void sbdsp_mix_write __P((struct sbdsp_softc *, int, int));
220 int sbdsp_mix_read __P((struct sbdsp_softc *, int));
221
222 int sbdsp_mixer_set_port __P((void *, mixer_ctrl_t *));
223 int sbdsp_mixer_get_port __P((void *, mixer_ctrl_t *));
224 int sbdsp_mixer_query_devinfo __P((void *, mixer_devinfo_t *));
225
226 void *sb_malloc __P((void *, unsigned long, int, int));
227 void sb_free __P((void *, void *, int));
228 unsigned long sb_round __P((void *, unsigned long));
229 int sb_mappage __P((void *, void *, int, int));
230
231 int sbdsp_get_props __P((void *));
232
233 #endif
234