sb.h revision 129180
1/*
2 * file: sbcard.h
3 * $FreeBSD: head/sys/dev/sound/isa/sb.h 129180 2004-05-13 11:32:54Z truckman $
4 */
5
6#ifndef SB_H
7#define SB_H
8
9struct sbc_softc;
10void sbc_lock(struct sbc_softc *);
11void sbc_lockassert(struct sbc_softc *);
12void sbc_unlock(struct sbc_softc *);
13
14/*
15 * sound blaster registers
16 */
17
18#define SBDSP_RST	0x6
19#define DSP_READ	0xA
20#define DSP_WRITE	0xC
21#define SBDSP_CMD	0xC
22#define SBDSP_STATUS	0xC
23#define DSP_DATA_AVAIL	0xE
24#define DSP_DATA_AVL16	0xF
25
26#define SB_MIX_ADDR	0x4
27#define SB_MIX_DATA	0x5
28#if 0
29#define OPL3_LEFT	(io_base + 0x0)
30#define OPL3_RIGHT	(io_base + 0x2)
31#define OPL3_BOTH	(io_base + 0x8)
32#endif
33
34/*
35 * DSP Commands. There are many, and in many cases they are used explicitly
36 */
37
38/* these are not used except for programmed I/O (not in this driver) */
39#define	DSP_DAC8		0x10	/* direct DAC output */
40#define	DSP_ADC8		0x20	/* direct ADC input */
41
42/* these should be used in the SB 1.0 */
43#define	DSP_CMD_DAC8		0x14	/* single cycle 8-bit dma out */
44#define	DSP_CMD_ADC8		0x24	/* single cycle 8-bit dma in */
45
46/* these should be used in the SB 2.0 and 2.01 */
47#define	DSP_CMD_DAC8_AUTO	0x1c	/* auto 8-bit dma out */
48#define	DSP_CMD_ADC8_AUTO	0x2c	/* auto 8-bit dma out */
49
50#define	DSP_CMD_HSSIZE		0x48	/* high speed dma count */
51#define	DSP_CMD_HSDAC_AUTO	0x90	/* high speed dac, auto */
52#define DSP_CMD_HSADC_AUTO      0x98    /* high speed adc, auto */
53
54/* SBPro commands. Some cards (JAZZ, SMW) also support 16 bits */
55
56	/* prepare for dma input */
57#define	DSP_CMD_DMAMODE(stereo, bit16) (0xA0 | (stereo ? 8:0) | (bit16 ? 4:0))
58
59#define	DSP_CMD_DAC2		0x16	/* 2-bit adpcm dma out (cont) */
60#define	DSP_CMD_DAC2S		0x17	/* 2-bit adpcm dma out (start) */
61
62#define	DSP_CMD_DAC2S_AUTO	0x1f	/* auto 2-bit adpcm dma out (start) */
63
64
65/* SB16 commands */
66#define	DSP_CMD_O16		0xb0
67#define	DSP_CMD_I16		0xb8
68#define	DSP_CMD_O8		0xc0
69#define	DSP_CMD_I8		0xc8
70
71#define	DSP_MODE_U8MONO		0x00
72#define	DSP_MODE_U8STEREO	0x20
73#define	DSP_MODE_S16MONO	0x10
74#define	DSP_MODE_S16STEREO	0x30
75
76#define DSP_CMD_SPKON		0xD1
77#define DSP_CMD_SPKOFF		0xD3
78#define DSP_CMD_SPKR(on)	(0xD1 | (on ? 0:2))
79
80#define	DSP_CMD_DMAPAUSE_8	0xD0
81#define	DSP_CMD_DMAPAUSE_16	0xD5
82#define	DSP_CMD_DMAEXIT_8	0xDA
83#define	DSP_CMD_DMAEXIT_16	0xD9
84#define	DSP_CMD_TCONST		0x40	/* set time constant */
85#define	DSP_CMD_HSDAC		0x91	/* high speed dac */
86#define DSP_CMD_HSADC           0x99    /* high speed adc */
87
88#define	DSP_CMD_GETVER		0xE1
89#define	DSP_CMD_GETID		0xE7	/* return id bytes */
90
91
92#define	DSP_CMD_OUT16		0x41	/* send parms for dma out on sb16 */
93#define	DSP_CMD_IN16		0x42	/* send parms for dma in on sb16 */
94#if 0 /*** unknown ***/
95#define	DSP_CMD_FA		0xFA	/* get version from prosonic*/
96#define	DSP_CMD_FB		0xFB	/* set irq/dma for prosonic*/
97#endif
98
99/*
100 * in fact, for the SB16, dma commands are as follows:
101 *
102 *  cmd, mode, len_low, len_high.
103 *
104 * cmd is a combination of DSP_DMA16 or DSP_DMA8 and
105 */
106
107#define	DSP_DMA16		0xb0
108#define	DSP_DMA8		0xc0
109#   define DSP_F16_DAC		0x00
110#   define DSP_F16_ADC		0x08
111#   define DSP_F16_AUTO		0x04
112#   define DSP_F16_FIFO_ON	0x02
113
114/*
115 * mode is a combination of the following:
116 */
117#define DSP_F16_STEREO	0x20
118#define DSP_F16_SIGNED	0x10
119
120#define IMODE_NONE		0
121#define IMODE_OUTPUT		PCM_ENABLE_OUTPUT
122#define IMODE_INPUT		PCM_ENABLE_INPUT
123#define IMODE_INIT		3
124#define IMODE_MIDI		4
125
126#define NORMAL_MIDI	0
127#define UART_MIDI	1
128
129/*
130 * values used for bd_flags in SoundBlaster driver
131 */
132#define	BD_F_HISPEED	0x0001	/* doing high speed ... */
133
134#if 0
135#define	BD_F_JAZZ16	0x0002	/* jazz16 detected */
136#define	BD_F_JAZZ16_2	0x0004	/* jazz16 type 2 */
137#endif
138
139#define	BD_F_DUP_MIDI	0x0008	/* duplex midi */
140
141#define	BD_F_MIX_MASK	0x0070	/* up to 8 mixers (I know of 3) */
142#define	BD_F_MIX_CT1335	0x0010	/* CT1335		*/
143#define	BD_F_MIX_CT1345	0x0020	/* CT1345		*/
144#define	BD_F_MIX_CT1745	0x0030	/* CT1745		*/
145
146#define	BD_F_SB16	0x0100	/* this is a SB16 */
147#define	BD_F_SB16X	0x0200	/* this is a vibra16X or clone */
148#if 0
149#define	BD_F_MIDIBUSY	0x0400	/* midi busy */
150#endif
151#define	BD_F_ESS	0x0800	/* this is an ESS chip */
152#define BD_F_DMARUN	0x2000
153#define BD_F_DMARUN2	0x4000
154
155/*
156 * Mixer registers of SB Pro
157 */
158#define VOC_VOL		0x04
159#define MIC_VOL		0x0A
160#define MIC_MIX		0x0A
161#define RECORD_SRC	0x0C
162#define IN_FILTER	0x0C
163#define OUT_FILTER	0x0E
164#define MASTER_VOL	0x22
165#define FM_VOL		0x26
166#define CD_VOL		0x28
167#define LINE_VOL	0x2E
168#define IRQ_NR		0x80
169#define DMA_NR		0x81
170#define IRQ_STAT	0x82
171
172/*
173 * Additional registers on the SG NX Pro
174 */
175#define COVOX_VOL	0x42
176#define TREBLE_LVL	0x44
177#define BASS_LVL	0x46
178
179#define FREQ_HI         (1 << 3)/* Use High-frequency ANFI filters */
180#define FREQ_LOW        0	/* Use Low-frequency ANFI filters */
181#define FILT_ON         0	/* Yes, 0 to turn it on, 1 for off */
182#define FILT_OFF        (1 << 5)
183
184#define MONO_DAC	0x00
185#define STEREO_DAC	0x02
186
187/*
188 * Mixer registers of SB16
189 */
190#define SB16_IMASK_L	0x3d
191#define SB16_IMASK_R	0x3e
192#define SB16_OMASK	0x3c
193#endif
194