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