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