sbdspvar.h revision 1.30 1 /* $NetBSD: sbdspvar.h,v 1.30 1997/08/24 23:50:42 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
50 #define SB_PCSPEAKER 11
51 #define SB_INPUT_GAIN 12
52 #define SB_OUTPUT_GAIN 13
53 #define SB_AGC 14
54 #define SB_INPUT_CLASS 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
106 u_char gain[SB_NDEVS][2]; /* kept in input levels */
107 #define SB_LEFT 0
108 #define SB_RIGHT 1
109 #define SB_LR 0
110
111 u_int out_port; /* output port */
112 u_int in_mask; /* input ports */
113 u_int in_port; /* XXX needed for MI interface */
114 u_int in_filter; /* one of SB_TREBLE_EQ, SB_BASS_EQ, 0 */
115
116 u_int spkr_state; /* non-null is on */
117
118 u_int sc_irate; /* Sample rate for input */
119 u_int sc_orate; /* ...and output */
120 u_char sc_itc;
121 u_char sc_otc;
122
123 struct sbmode *sc_imodep;
124 struct sbmode *sc_omodep;
125 u_char sc_ibmode;
126 u_char sc_obmode;
127
128 u_long sc_interrupts; /* number of interrupts taken */
129 void (*sc_intr)(void*); /* dma completion intr handler */
130 void (*sc_mintr)(void*, int);/* midi input intr handler */
131 void *sc_arg; /* arg for sc_intr() */
132
133 int dmaflags;
134 caddr_t dmaaddr;
135 vm_size_t dmacnt;
136 int dmachan; /* active DMA channel */
137
138 int sc_dmadir; /* DMA direction */
139 #define SB_DMA_NONE 0
140 #define SB_DMA_IN 1
141 #define SB_DMA_OUT 2
142
143 u_int sc_mixer_model;
144 #define SBM_NONE 0
145 #define SBM_CT1335 1
146 #define SBM_CT1345 2
147 #define SBM_CT1XX5 3
148 #define SBM_CT1745 4
149 #define ISSBM1745(x) ((x)->sc_mixer_model >= SBM_CT1XX5)
150
151 u_int sc_model; /* DSP model */
152 #define SB_UNK -1
153 #define SB_1 0 /* original SB */
154 #define SB_20 1 /* SB 2 */
155 #define SB_2x 2 /* SB 2, new version */
156 #define SB_PRO 3 /* SB Pro */
157 #define SB_JAZZ 4 /* Jazz 16 */
158 #define SB_16 5 /* SB 16 */
159 #define SB_32 6 /* SB AWE 32 */
160 #define SB_64 7 /* SB AWE 64 */
161
162 #define SB_NAMES { "SB_1", "SB_2.0", "SB_2.x", "SB_Pro", "Jazz_16", "SB_16", "SB_AWE_32", "SB_AWE_64" }
163
164 u_int sc_version; /* DSP version */
165 #define SBVER_MAJOR(v) (((v)>>8) & 0xff)
166 #define SBVER_MINOR(v) ((v)&0xff)
167 };
168
169 #define ISSBPRO(sc) ((sc)->sc_model == SB_PRO || (sc)->sc_model == SB_JAZZ)
170 #define ISSBPROCLASS(sc) ((sc)->sc_model >= SB_PRO)
171 #define ISSB16CLASS(sc) ((sc)->sc_model >= SB_16)
172
173 #ifdef _KERNEL
174 int sbdsp_open __P((void *, int));
175 void sbdsp_close __P((void *));
176
177 int sbdsp_probe __P((struct sbdsp_softc *));
178 void sbdsp_attach __P((struct sbdsp_softc *));
179
180 int sbdsp_set_in_gain __P((void *, u_int, u_char));
181 int sbdsp_set_in_gain_real __P((void *, u_int, u_char));
182 int sbdsp_get_in_gain __P((void *));
183 int sbdsp_set_out_gain __P((void *, u_int, u_char));
184 int sbdsp_set_out_gain_real __P((void *, u_int, u_char));
185 int sbdsp_get_out_gain __P((void *));
186 int sbdsp_set_monitor_gain __P((void *, u_int));
187 int sbdsp_get_monitor_gain __P((void *));
188 int sbdsp_query_encoding __P((void *, struct audio_encoding *));
189 int sbdsp_set_params __P((void *, int, int, struct audio_params *, struct audio_params *));
190 int sbdsp_round_blocksize __P((void *, int));
191 int sbdsp_set_out_port __P((void *, int));
192 int sbdsp_get_out_port __P((void *));
193 int sbdsp_set_in_port __P((void *, int));
194 int sbdsp_get_in_port __P((void *));
195 int sbdsp_get_avail_in_ports __P((void *));
196 int sbdsp_get_avail_out_ports __P((void *));
197 int sbdsp_speaker_ctl __P((void *, int));
198
199 int sbdsp_dma_init_input __P((void *, void *, int));
200 int sbdsp_dma_init_output __P((void *, void *, int));
201 int sbdsp_dma_output __P((void *, void *, int, void (*)(void *), void*));
202 int sbdsp_dma_input __P((void *, void *, int, void (*)(void *), void*));
203
204 int sbdsp_haltdma __P((void *));
205 int sbdsp_contdma __P((void *));
206
207 void sbdsp_compress __P((int, u_char *, int));
208 void sbdsp_expand __P((int, u_char *, int));
209
210 int sbdsp_reset __P((struct sbdsp_softc *));
211 void sbdsp_spkron __P((struct sbdsp_softc *));
212 void sbdsp_spkroff __P((struct sbdsp_softc *));
213
214 int sbdsp_wdsp __P((struct sbdsp_softc *, int v));
215 int sbdsp_rdsp __P((struct sbdsp_softc *));
216
217 int sbdsp_intr __P((void *));
218
219 int sbdsp_set_sr __P((struct sbdsp_softc *, u_long *, int));
220
221 void sbdsp_mix_write __P((struct sbdsp_softc *, int, int));
222 int sbdsp_mix_read __P((struct sbdsp_softc *, int));
223
224 int sbdsp_mixer_set_port __P((void *, mixer_ctrl_t *));
225 int sbdsp_mixer_get_port __P((void *, mixer_ctrl_t *));
226 int sbdsp_mixer_query_devinfo __P((void *, mixer_devinfo_t *));
227
228 void *sb_malloc __P((void *, unsigned long, int, int));
229 void sb_free __P((void *, void *, int));
230 unsigned long sb_round __P((void *, unsigned long));
231 int sb_mappage __P((void *, void *, int, int));
232
233 int sbdsp_get_props __P((void *));
234
235 #endif
236