xref: /freebsd/sys/dev/sound/isa/sb.h (revision 0de89efe5c443f213c7ea28773ef2dc6cf3af2ed)
1 /*
2  * file: sbcard.h
3  */
4 
5 typedef struct _sbdev_info {
6 
7 } sbdev_info ;
8 
9 extern int sbc_major, sbc_minor ;
10 /*
11  * sound blaster registers
12  */
13 
14 #define DSP_RESET	(io_base + 0x6)
15 #define DSP_READ	(io_base + 0xA)
16 #define DSP_WRITE	(io_base + 0xC)
17 #define DSP_COMMAND	(io_base + 0xC)
18 #define DSP_STATUS	(io_base + 0xC)
19 #define DSP_DATA_AVAIL	(io_base + 0xE)
20 #define DSP_DATA_AVL16	(io_base + 0xF)
21 #define MIXER_ADDR	(io_base + 0x4)
22 #define MIXER_DATA	(io_base + 0x5)
23 #define OPL3_LEFT	(io_base + 0x0)
24 #define OPL3_RIGHT	(io_base + 0x2)
25 #define OPL3_BOTH	(io_base + 0x8)
26 
27 /*
28  * DSP Commands. There are many, and in many cases they are used explicitly
29  */
30 
31 #define	DSP_DAC8		0x10	/* direct DAC output */
32 #define	DSP_CMD_DAC8		0x14	/* single cycle 8-bit dma out */
33 #define	DSP_CMD_DAC2		0x16	/* 2-bit adpcm dma out (cont) */
34 #define	DSP_CMD_DAC2S		0x17	/* 2-bit adpcm dma out (start) */
35 
36 #define	DSP_CMD_DAC8_A		0x1c	/* auto 8-bit dma out */
37 #define	DSP_CMD_DAC2S_A		0x1f	/* auto 2-bit adpcm dma out (start) */
38 
39 #define	DSP_ADC8		0x20	/* direct ADC input */
40 
41 #define	DSP_CMD_ADC8		0x24	/* single cycle 8-bit dma in */
42 #define	DSP_CMD_ADC8_A		0x2c	/* auto 8-bit dma out */
43 
44 #define	DSP_CMD_O16		0xb0
45 #define	DSP_CMD_I16		0xb8
46 #define	DSP_CMD_O8		0xc0
47 #define	DSP_CMD_I8		0xc8
48 
49 #define	DSP_MODE_U8MONO		0x00
50 #define	DSP_MODE_U8STEREO	0x20
51 #define	DSP_MODE_S16MONO	0x10
52 #define	DSP_MODE_S16STEREO	0x30
53 
54 #define DSP_CMD_SPKON		0xD1
55 #define DSP_CMD_SPKOFF		0xD3
56 #define DSP_CMD_SPKR(on)	(0xD1 | (on ? 0:2))
57 #define DSP_CMD_DMAON		0xD0	/* ??? the comment says Halt DMA */
58 #define DSP_CMD_DMAOFF		0xD4	/* ??? comment says continue dma */
59 
60 #define	DSP_CMD_DMAHALT		0xD0
61 #define	DSP_CMD_TCONST		0x40	/* set time constant */
62 #define	DSP_CMD_HSSIZE		0x48	/* high speed dma count */
63 #define	DSP_CMD_HSDAC		0x91	/* high speed dac */
64 #define	DSP_CMD_HSADC		0x99	/* high speed adc */
65 
66 #define	DSP_CMD_GETVER		0xE1
67 #define	DSP_CMD_GETID		0xE7	/* return id bytes */
68 
69 	/* prepare for dma input */
70 #define	DSP_CMD_DMAMODE(stereo, bit16) (0xA0 | (stereo ? 8:0) | (bit16 ? 4:0))
71 
72 #define	DSP_CMD_OUT16		0x41	/* send parms for dma out on sb16 */
73 #define	DSP_CMD_IN16		0x42	/* send parms for dma in on sb16 */
74 #if 0 /*** unknown ***/
75 	/*
76 	 * D9 and D5 are used on the sb16 on close... maybe a reset of
77 	 * some subsystem ?
78 	 */
79 #define	DSP_CMD_D9		0xD9
80 #define	DSP_CMD_D5		0xD5
81 #define	DSP_CMD_FA		0xFA	/* get version from prosonic*/
82 #define	DSP_CMD_FB		0xFB	/* set irq/dma for prosonic*/
83 #endif
84 
85 /*
86  * in fact, for the SB16, dma commands are as follows:
87  *
88  *  cmd, mode, len_low, len_high.
89  *
90  * cmd is a combination of DSP_DMA16 or DSP_DMA8 and
91  */
92 
93 #define	DSP_DMA16		0xb0
94 #define	DSP_DMA8		0xc0
95 #   define DSP_F16_DAC		0x00
96 #   define DSP_F16_ADC		0x08
97 #   define DSP_F16_AUTO		0x04
98 #   define DSP_F16_FIFO_ON	0x02
99 
100 /*
101  * mode is a combination of the following:
102  */
103 #define DSP_F16_STEREO	0x20
104 #define DSP_F16_SIGNED	0x10
105 
106 #define IMODE_NONE		0
107 #define IMODE_OUTPUT		PCM_ENABLE_OUTPUT
108 #define IMODE_INPUT		PCM_ENABLE_INPUT
109 #define IMODE_INIT		3
110 #define IMODE_MIDI		4
111 
112 #define NORMAL_MIDI	0
113 #define UART_MIDI	1
114 
115 /*
116  * values used for bd_flags in SoundBlaster driver
117  */
118 #define	BD_F_HISPEED	0x0001	/* doing high speed ... */
119 
120 #define	BD_F_JAZZ16	0x0002	/* jazz16 detected */
121 #define	BD_F_JAZZ16_2	0x0004	/* jazz16 type 2 */
122 
123 #define	BD_F_DUP_MIDI	0x0008	/* duplex midi */
124 
125 #define	BD_F_MIX_MASK	0x0070	/* up to 8 mixers (I know of 3) */
126 #define	BD_F_MIX_CT1335	0x0010	/* CT1335		*/
127 #define	BD_F_MIX_CT1345	0x0020	/* CT1345		*/
128 #define	BD_F_MIX_CT1745	0x0030	/* CT1745		*/
129 
130 #define	BD_F_SB16	0x0100	/* this is a SB16 */
131 #define	BD_F_NOREC	0x0200	/* recording not supported on this board */
132 #define	BD_F_MIDIBUSY	0x0400	/* midi busy */
133 
134 
135 /*
136  * sound/sb_mixer.h
137  *
138  * Definitions for the SB Pro and SB16 mixers
139  *
140  * Copyright by Hannu Savolainen 1993
141  *
142  * Redistribution and use in source and binary forms, with or without
143  * modification, are permitted provided that the following conditions are
144  * met: 1. Redistributions of source code must retain the above copyright
145  * notice, this list of conditions and the following disclaimer. 2.
146  * Redistributions in binary form must reproduce the above copyright notice,
147  * this list of conditions and the following disclaimer in the documentation
148  * and/or other materials provided with the distribution.
149  *
150  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
151  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
152  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
153  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
154  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
155  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
156  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
157  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
158  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
159  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
160  * SUCH DAMAGE.
161  *
162  * Modified: Hunyue Yau	Jan 6 1994 Added defines for the Sound Galaxy NX Pro
163  * mixer.
164  *
165  */
166 
167 #define SBPRO_RECORDING_DEVICES	\
168     (SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD)
169 
170 /* Same as SB Pro, unless I find otherwise */
171 #define SGNXPRO_RECORDING_DEVICES SBPRO_RECORDING_DEVICES
172 
173 #define SBPRO_MIXER_DEVICES	\
174     (SOUND_MASK_SYNTH | SOUND_MASK_PCM | SOUND_MASK_LINE | SOUND_MASK_MIC | \
175      SOUND_MASK_CD | SOUND_MASK_VOLUME)
176 
177 /*
178  * SG NX Pro has treble and bass settings on the mixer. The 'speaker' channel
179  * is the COVOX/DisneySoundSource emulation volume control on the mixer. It
180  * does NOT control speaker volume. Should have own mask eventually?
181  */
182 #define SGNXPRO_MIXER_DEVICES	\
183     (SBPRO_MIXER_DEVICES | SOUND_MASK_BASS | \
184      SOUND_MASK_TREBLE | SOUND_MASK_SPEAKER )
185 
186 #define SB16_RECORDING_DEVICES	\
187     (SOUND_MASK_SYNTH | SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD)
188 
189 #define SB16_MIXER_DEVICES	\
190     (SOUND_MASK_SYNTH | SOUND_MASK_PCM | SOUND_MASK_SPEAKER | \
191      SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD | \
192      SOUND_MASK_IGAIN | SOUND_MASK_OGAIN | \
193      SOUND_MASK_VOLUME | SOUND_MASK_BASS | SOUND_MASK_TREBLE)
194 
195 /*
196  * Mixer registers
197  *
198  * NOTE!	RECORD_SRC == IN_FILTER
199  */
200 
201 /*
202  * Mixer registers of SB Pro
203  */
204 #define VOC_VOL		0x04
205 #define MIC_VOL		0x0A
206 #define MIC_MIX		0x0A
207 #define RECORD_SRC	0x0C
208 #define IN_FILTER	0x0C
209 #define OUT_FILTER	0x0E
210 #define MASTER_VOL	0x22
211 #define FM_VOL		0x26
212 #define CD_VOL		0x28
213 #define LINE_VOL	0x2E
214 #define IRQ_NR		0x80
215 #define DMA_NR		0x81
216 #define IRQ_STAT	0x82
217 
218 /*
219  * Additional registers on the SG NX Pro
220  */
221 #define COVOX_VOL	0x42
222 #define TREBLE_LVL	0x44
223 #define BASS_LVL	0x46
224 
225 #define FREQ_HI         (1 << 3)/* Use High-frequency ANFI filters */
226 #define FREQ_LOW        0	/* Use Low-frequency ANFI filters */
227 #define FILT_ON         0	/* Yes, 0 to turn it on, 1 for off */
228 #define FILT_OFF        (1 << 5)
229 
230 #define MONO_DAC	0x00
231 #define STEREO_DAC	0x02
232 
233 /*
234  * Mixer registers of SB16
235  */
236 #define SB16_IMASK_L	0x3d
237 #define SB16_IMASK_R	0x3e
238 #define SB16_OMASK	0x3c
239 
240 
241 #ifndef __SB_MIXER_C__
242 mixer_tab       sbpro_mix;
243 mixer_tab       sb16_mix;
244 #ifdef	__SGNXPRO__
245 mixer_tab       sgnxpro_mix;
246 #endif
247 static u_char sb16_recmasks_L[SOUND_MIXER_NRDEVICES];
248 static u_char sb16_recmasks_R[SOUND_MIXER_NRDEVICES];
249 #else /* __SB_MIXER_C__ defined */
250 mixer_tab       sbpro_mix = {
251     PMIX_ENT(SOUND_MIXER_VOLUME,  0x22, 7, 4, 0x22, 3, 4),
252     PMIX_ENT(SOUND_MIXER_BASS,    0x00, 0, 0, 0x00, 0, 0),
253     PMIX_ENT(SOUND_MIXER_TREBLE,  0x00, 0, 0, 0x00, 0, 0),
254     PMIX_ENT(SOUND_MIXER_SYNTH,   0x26, 7, 4, 0x26, 3, 4),
255     PMIX_ENT(SOUND_MIXER_PCM,     0x04, 7, 4, 0x04, 3, 4),
256     PMIX_ENT(SOUND_MIXER_SPEAKER, 0x00, 0, 0, 0x00, 0, 0),
257     PMIX_ENT(SOUND_MIXER_LINE,    0x2e, 7, 4, 0x2e, 3, 4),
258     PMIX_ENT(SOUND_MIXER_MIC,     0x0a, 2, 3, 0x00, 0, 0),
259     PMIX_ENT(SOUND_MIXER_CD,      0x28, 7, 4, 0x28, 3, 4),
260     PMIX_ENT(SOUND_MIXER_IMIX,    0x00, 0, 0, 0x00, 0, 0),
261     PMIX_ENT(SOUND_MIXER_ALTPCM,  0x00, 0, 0, 0x00, 0, 0),
262     PMIX_ENT(SOUND_MIXER_RECLEV,  0x00, 0, 0, 0x00, 0, 0)
263 };
264 
265 #ifdef	__SGNXPRO__
266 mixer_tab       sgnxpro_mix = {
267     PMIX_ENT(SOUND_MIXER_VOLUME,  0x22, 7, 4, 0x22, 3, 4),
268     PMIX_ENT(SOUND_MIXER_BASS,    0x46, 2, 3, 0x00, 0, 0),
269     PMIX_ENT(SOUND_MIXER_TREBLE,  0x44, 2, 3, 0x00, 0, 0),
270     PMIX_ENT(SOUND_MIXER_SYNTH,   0x26, 7, 4, 0x26, 3, 4),
271     PMIX_ENT(SOUND_MIXER_PCM,     0x04, 7, 4, 0x04, 3, 4),
272     PMIX_ENT(SOUND_MIXER_SPEAKER, 0x42, 2, 3, 0x00, 0, 0),
273     PMIX_ENT(SOUND_MIXER_LINE,    0x2e, 7, 4, 0x2e, 3, 4),
274     PMIX_ENT(SOUND_MIXER_MIC,     0x0a, 2, 3, 0x00, 0, 0),
275     PMIX_ENT(SOUND_MIXER_CD,      0x28, 7, 4, 0x28, 3, 4),
276     PMIX_ENT(SOUND_MIXER_IMIX,    0x00, 0, 0, 0x00, 0, 0),
277     PMIX_ENT(SOUND_MIXER_ALTPCM,  0x00, 0, 0, 0x00, 0, 0),
278     PMIX_ENT(SOUND_MIXER_RECLEV,  0x00, 0, 0, 0x00, 0, 0),
279     PMIX_ENT(SOUND_MIXER_IGAIN,   0x00, 0, 0, 0x00, 0, 0),
280     PMIX_ENT(SOUND_MIXER_OGAIN,   0x00, 0, 0, 0x00, 0, 0)
281 };
282 #endif
283 
284 mixer_tab       sb16_mix = {
285     PMIX_ENT(SOUND_MIXER_VOLUME,  0x30, 3, 5, 0x31, 3, 5),
286     PMIX_ENT(SOUND_MIXER_BASS,    0x46, 4, 4, 0x47, 4, 4),
287     PMIX_ENT(SOUND_MIXER_TREBLE,  0x44, 4, 4, 0x45, 4, 4),
288     PMIX_ENT(SOUND_MIXER_SYNTH,   0x34, 3, 5, 0x35, 3, 5),
289     PMIX_ENT(SOUND_MIXER_PCM,     0x32, 3, 5, 0x33, 3, 5),
290     PMIX_ENT(SOUND_MIXER_SPEAKER, 0x3b, 6, 2, 0x00, 0, 0),
291     PMIX_ENT(SOUND_MIXER_LINE,    0x38, 3, 5, 0x39, 3, 5),
292     PMIX_ENT(SOUND_MIXER_MIC,     0x3a, 3, 5, 0x00, 0, 0),
293     PMIX_ENT(SOUND_MIXER_CD,      0x36, 3, 5, 0x37, 3, 5),
294     PMIX_ENT(SOUND_MIXER_IMIX,    0x00, 0, 0, 0x00, 0, 0),
295     PMIX_ENT(SOUND_MIXER_ALTPCM,  0x00, 0, 0, 0x00, 0, 0),
296     PMIX_ENT(SOUND_MIXER_RECLEV,  0x3f, 6, 2, 0x40, 6, 2), /* Obsol,Use IGAIN*/
297     PMIX_ENT(SOUND_MIXER_IGAIN,   0x3f, 6, 2, 0x40, 6, 2),
298     PMIX_ENT(SOUND_MIXER_OGAIN,   0x41, 6, 2, 0x42, 6, 2)
299 };
300 
301 #ifdef SM_GAMES			/* Master volume is lower and PCM & FM
302 				 * volumes higher than with SB Pro. This
303 				 * improves the sound quality */
304 
305 static u_short levels[SOUND_MIXER_NRDEVICES] =
306 {
307 	0x2020,			/* Master Volume */
308 	0x4b4b,			/* Bass */
309 	0x4b4b,			/* Treble */
310 	0x6464,			/* FM */
311 	0x6464,			/* PCM */
312 	0x4b4b,			/* PC Speaker */
313 	0x4b4b,			/* Ext Line */
314 	0x0000,			/* Mic */
315 	0x4b4b,			/* CD */
316 	0x4b4b,			/* Recording monitor */
317 	0x4b4b,			/* SB PCM */
318 	0x4b4b,			/* Recording level */
319 	0x4b4b,			/* Input gain */
320 0x4b4b};			/* Output gain */
321 
322 #else				/* If the user selected just plain SB Pro */
323 
324 static u_short levels[SOUND_MIXER_NRDEVICES] =
325 {
326 	0x5a5a,			/* Master Volume */
327 	0x4b4b,			/* Bass */
328 	0x4b4b,			/* Treble */
329 	0x4b4b,			/* FM */
330 	0x4b4b,			/* PCM */
331 	0x4b4b,			/* PC Speaker */
332 	0x4b4b,			/* Ext Line */
333 	0x1010,			/* Mic */
334 	0x4b4b,			/* CD */
335 	0x4b4b,			/* Recording monitor */
336 	0x4b4b,			/* SB PCM */
337 	0x4b4b,			/* Recording level */
338 	0x4b4b,			/* Input gain */
339 0x4b4b};			/* Output gain */
340 #endif				/* SM_GAMES */
341 
342 static u_char sb16_recmasks_L[SOUND_MIXER_NRDEVICES] =
343 {
344 	0x00,			/* SOUND_MIXER_VOLUME	 */
345 	0x00,			/* SOUND_MIXER_BASS	 */
346 	0x00,			/* SOUND_MIXER_TREBLE	 */
347 	0x40,			/* SOUND_MIXER_SYNTH	 */
348 	0x00,			/* SOUND_MIXER_PCM	 */
349 	0x00,			/* SOUND_MIXER_SPEAKER	 */
350 	0x10,			/* SOUND_MIXER_LINE	 */
351 	0x01,			/* SOUND_MIXER_MIC	 */
352 	0x04,			/* SOUND_MIXER_CD	 */
353 	0x00,			/* SOUND_MIXER_IMIX	 */
354 	0x00,			/* SOUND_MIXER_ALTPCM	 */
355 	0x00,			/* SOUND_MIXER_RECLEV	 */
356 	0x00,			/* SOUND_MIXER_IGAIN	 */
357 	0x00			/* SOUND_MIXER_OGAIN	 */
358 };
359 
360 static u_char sb16_recmasks_R[SOUND_MIXER_NRDEVICES] =
361 {
362 	0x00,			/* SOUND_MIXER_VOLUME	 */
363 	0x00,			/* SOUND_MIXER_BASS	 */
364 	0x00,			/* SOUND_MIXER_TREBLE	 */
365 	0x20,			/* SOUND_MIXER_SYNTH	 */
366 	0x00,			/* SOUND_MIXER_PCM	 */
367 	0x00,			/* SOUND_MIXER_SPEAKER	 */
368 	0x08,			/* SOUND_MIXER_LINE	 */
369 	0x01,			/* SOUND_MIXER_MIC	 */
370 	0x02,			/* SOUND_MIXER_CD	 */
371 	0x00,			/* SOUND_MIXER_IMIX	 */
372 	0x00,			/* SOUND_MIXER_ALTPCM	 */
373 	0x00,			/* SOUND_MIXER_RECLEV	 */
374 	0x00,			/* SOUND_MIXER_IGAIN	 */
375 	0x00			/* SOUND_MIXER_OGAIN	 */
376 };
377 
378 /*
379  * Recording sources (SB Pro)
380  */
381 #endif /* __SB_MIXER_C__ */
382 
383 #define SRC_MIC         1	/* Select Microphone recording source */
384 #define SRC_CD          3	/* Select CD recording source */
385 #define SRC_LINE        7	/* Use Line-in for recording source */
386 
387 
388