xref: /freebsd/sys/dev/sound/isa/sb.h (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 1997,1998 Luigi Rizzo
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #ifndef SB_H
30 #define SB_H
31 
32 struct sbc_softc;
33 void sbc_lock(struct sbc_softc *);
34 void sbc_lockassert(struct sbc_softc *);
35 void sbc_unlock(struct sbc_softc *);
36 
37 /*
38  * sound blaster registers
39  */
40 
41 #define SBDSP_RST	0x6
42 #define DSP_READ	0xA
43 #define DSP_WRITE	0xC
44 #define SBDSP_CMD	0xC
45 #define SBDSP_STATUS	0xC
46 #define DSP_DATA_AVAIL	0xE
47 #define DSP_DATA_AVL16	0xF
48 
49 #define SB_MIX_ADDR	0x4
50 #define SB_MIX_DATA	0x5
51 #if 0
52 #define OPL3_LEFT	(io_base + 0x0)
53 #define OPL3_RIGHT	(io_base + 0x2)
54 #define OPL3_BOTH	(io_base + 0x8)
55 #endif
56 
57 /*
58  * DSP Commands. There are many, and in many cases they are used explicitly
59  */
60 
61 /* these are not used except for programmed I/O (not in this driver) */
62 #define	DSP_DAC8		0x10	/* direct DAC output */
63 #define	DSP_ADC8		0x20	/* direct ADC input */
64 
65 /* these should be used in the SB 1.0 */
66 #define	DSP_CMD_DAC8		0x14	/* single cycle 8-bit dma out */
67 #define	DSP_CMD_ADC8		0x24	/* single cycle 8-bit dma in */
68 
69 /* these should be used in the SB 2.0 and 2.01 */
70 #define	DSP_CMD_DAC8_AUTO	0x1c	/* auto 8-bit dma out */
71 #define	DSP_CMD_ADC8_AUTO	0x2c	/* auto 8-bit dma out */
72 
73 #define	DSP_CMD_HSSIZE		0x48	/* high speed dma count */
74 #define	DSP_CMD_HSDAC_AUTO	0x90	/* high speed dac, auto */
75 #define DSP_CMD_HSADC_AUTO      0x98    /* high speed adc, auto */
76 
77 /* SBPro commands. Some cards (JAZZ, SMW) also support 16 bits */
78 
79 	/* prepare for dma input */
80 #define	DSP_CMD_DMAMODE(stereo, bit16) (0xA0 | (stereo ? 8:0) | (bit16 ? 4:0))
81 
82 #define	DSP_CMD_DAC2		0x16	/* 2-bit adpcm dma out (cont) */
83 #define	DSP_CMD_DAC2S		0x17	/* 2-bit adpcm dma out (start) */
84 
85 #define	DSP_CMD_DAC2S_AUTO	0x1f	/* auto 2-bit adpcm dma out (start) */
86 
87 /* SB16 commands */
88 #define	DSP_CMD_O16		0xb0
89 #define	DSP_CMD_I16		0xb8
90 #define	DSP_CMD_O8		0xc0
91 #define	DSP_CMD_I8		0xc8
92 
93 #define	DSP_MODE_U8MONO		0x00
94 #define	DSP_MODE_U8STEREO	0x20
95 #define	DSP_MODE_S16MONO	0x10
96 #define	DSP_MODE_S16STEREO	0x30
97 
98 #define DSP_CMD_SPKON		0xD1
99 #define DSP_CMD_SPKOFF		0xD3
100 #define DSP_CMD_SPKR(on)	(0xD1 | (on ? 0:2))
101 
102 #define	DSP_CMD_DMAPAUSE_8	0xD0
103 #define	DSP_CMD_DMAPAUSE_16	0xD5
104 #define	DSP_CMD_DMAEXIT_8	0xDA
105 #define	DSP_CMD_DMAEXIT_16	0xD9
106 #define	DSP_CMD_TCONST		0x40	/* set time constant */
107 #define	DSP_CMD_HSDAC		0x91	/* high speed dac */
108 #define DSP_CMD_HSADC           0x99    /* high speed adc */
109 
110 #define	DSP_CMD_GETVER		0xE1
111 #define	DSP_CMD_GETID		0xE7	/* return id bytes */
112 
113 #define	DSP_CMD_OUT16		0x41	/* send parms for dma out on sb16 */
114 #define	DSP_CMD_IN16		0x42	/* send parms for dma in on sb16 */
115 #if 0 /*** unknown ***/
116 #define	DSP_CMD_FA		0xFA	/* get version from prosonic*/
117 #define	DSP_CMD_FB		0xFB	/* set irq/dma for prosonic*/
118 #endif
119 
120 /*
121  * in fact, for the SB16, dma commands are as follows:
122  *
123  *  cmd, mode, len_low, len_high.
124  *
125  * cmd is a combination of DSP_DMA16 or DSP_DMA8 and
126  */
127 
128 #define	DSP_DMA16		0xb0
129 #define	DSP_DMA8		0xc0
130 #   define DSP_F16_DAC		0x00
131 #   define DSP_F16_ADC		0x08
132 #   define DSP_F16_AUTO		0x04
133 #   define DSP_F16_FIFO_ON	0x02
134 
135 /*
136  * mode is a combination of the following:
137  */
138 #define DSP_F16_STEREO	0x20
139 #define DSP_F16_SIGNED	0x10
140 
141 #define IMODE_NONE		0
142 #define IMODE_OUTPUT		PCM_ENABLE_OUTPUT
143 #define IMODE_INPUT		PCM_ENABLE_INPUT
144 #define IMODE_INIT		3
145 #define IMODE_MIDI		4
146 
147 #define NORMAL_MIDI	0
148 #define UART_MIDI	1
149 
150 /*
151  * values used for bd_flags in SoundBlaster driver
152  */
153 #define	BD_F_HISPEED	0x0001	/* doing high speed ... */
154 
155 #if 0
156 #define	BD_F_JAZZ16	0x0002	/* jazz16 detected */
157 #define	BD_F_JAZZ16_2	0x0004	/* jazz16 type 2 */
158 #endif
159 
160 #define	BD_F_DUP_MIDI	0x0008	/* duplex midi */
161 
162 #define	BD_F_MIX_MASK	0x0070	/* up to 8 mixers (I know of 3) */
163 #define	BD_F_MIX_CT1335	0x0010	/* CT1335		*/
164 #define	BD_F_MIX_CT1345	0x0020	/* CT1345		*/
165 #define	BD_F_MIX_CT1745	0x0030	/* CT1745		*/
166 
167 #define	BD_F_SB16	0x0100	/* this is a SB16 */
168 #define	BD_F_SB16X	0x0200	/* this is a vibra16X or clone */
169 #if 0
170 #define	BD_F_MIDIBUSY	0x0400	/* midi busy */
171 #endif
172 #define	BD_F_ESS	0x0800	/* this is an ESS chip */
173 #define BD_F_DMARUN	0x2000
174 #define BD_F_DMARUN2	0x4000
175 
176 /*
177  * Mixer registers of SB Pro
178  */
179 #define VOC_VOL		0x04
180 #define MIC_VOL		0x0A
181 #define MIC_MIX		0x0A
182 #define RECORD_SRC	0x0C
183 #define IN_FILTER	0x0C
184 #define OUT_FILTER	0x0E
185 #define MASTER_VOL	0x22
186 #define FM_VOL		0x26
187 #define CD_VOL		0x28
188 #define LINE_VOL	0x2E
189 #define IRQ_NR		0x80
190 #define DMA_NR		0x81
191 #define IRQ_STAT	0x82
192 
193 /*
194  * Additional registers on the SG NX Pro
195  */
196 #define COVOX_VOL	0x42
197 #define TREBLE_LVL	0x44
198 #define BASS_LVL	0x46
199 
200 #define FREQ_HI         (1 << 3)/* Use High-frequency ANFI filters */
201 #define FREQ_LOW        0	/* Use Low-frequency ANFI filters */
202 #define FILT_ON         0	/* Yes, 0 to turn it on, 1 for off */
203 #define FILT_OFF        (1 << 5)
204 
205 #define MONO_DAC	0x00
206 #define STEREO_DAC	0x02
207 
208 /*
209  * Mixer registers of SB16
210  */
211 #define SB16_IMASK_L	0x3d
212 #define SB16_IMASK_R	0x3e
213 #define SB16_OMASK	0x3c
214 #endif
215