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