sb.h revision 302408
1173412Skevlo/*-
278344Sobrien * Copyright (c) 1997,1998 Luigi Rizzo
378344Sobrien * All rights reserved.
478344Sobrien *
578344Sobrien * Redistribution and use in source and binary forms, with or without
678344Sobrien * modification, are permitted provided that the following conditions
778344Sobrien * are met:
878344Sobrien * 1. Redistributions of source code must retain the above copyright
978344Sobrien *    notice, this list of conditions and the following disclaimer.
1078344Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1178344Sobrien *    notice, this list of conditions and the following disclaimer in the
1278344Sobrien *    documentation and/or other materials provided with the distribution.
1378344Sobrien *
1478344Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1578344Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1678344Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1778344Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1878344Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1978344Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2078344Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2178344Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2278344Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2378344Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2478344Sobrien * SUCH DAMAGE.
2578344Sobrien *
2678344Sobrien * $FreeBSD: stable/11/sys/dev/sound/isa/sb.h 166425 2007-02-02 13:33:35Z joel $
2778344Sobrien */
2878344Sobrien
2978344Sobrien#ifndef SB_H
3078344Sobrien#define SB_H
3178344Sobrien
3278344Sobrienstruct sbc_softc;
3378344Sobrienvoid sbc_lock(struct sbc_softc *);
3478344Sobrienvoid sbc_lockassert(struct sbc_softc *);
3578344Sobrienvoid sbc_unlock(struct sbc_softc *);
3678344Sobrien
3778344Sobrien/*
3878344Sobrien * sound blaster registers
3978344Sobrien */
4078344Sobrien
4178344Sobrien#define SBDSP_RST	0x6
4278344Sobrien#define DSP_READ	0xA
4378344Sobrien#define DSP_WRITE	0xC
4478344Sobrien#define SBDSP_CMD	0xC
4578344Sobrien#define SBDSP_STATUS	0xC
4678344Sobrien#define DSP_DATA_AVAIL	0xE
4778344Sobrien#define DSP_DATA_AVL16	0xF
4878344Sobrien
4978344Sobrien#define SB_MIX_ADDR	0x4
5078344Sobrien#define SB_MIX_DATA	0x5
5178344Sobrien#if 0
5278344Sobrien#define OPL3_LEFT	(io_base + 0x0)
5378344Sobrien#define OPL3_RIGHT	(io_base + 0x2)
54173412Skevlo#define OPL3_BOTH	(io_base + 0x8)
5578344Sobrien#endif
5678344Sobrien
5778344Sobrien/*
5878344Sobrien * DSP Commands. There are many, and in many cases they are used explicitly
5978344Sobrien */
6078344Sobrien
6178344Sobrien/* these are not used except for programmed I/O (not in this driver) */
6278344Sobrien#define	DSP_DAC8		0x10	/* direct DAC output */
6378344Sobrien#define	DSP_ADC8		0x20	/* direct ADC input */
6478344Sobrien
6578344Sobrien/* these should be used in the SB 1.0 */
6678344Sobrien#define	DSP_CMD_DAC8		0x14	/* single cycle 8-bit dma out */
6778344Sobrien#define	DSP_CMD_ADC8		0x24	/* single cycle 8-bit dma in */
6878344Sobrien
6978344Sobrien/* these should be used in the SB 2.0 and 2.01 */
7078344Sobrien#define	DSP_CMD_DAC8_AUTO	0x1c	/* auto 8-bit dma out */
7178344Sobrien#define	DSP_CMD_ADC8_AUTO	0x2c	/* auto 8-bit dma out */
7278344Sobrien
7378344Sobrien#define	DSP_CMD_HSSIZE		0x48	/* high speed dma count */
7478344Sobrien#define	DSP_CMD_HSDAC_AUTO	0x90	/* high speed dac, auto */
7578344Sobrien#define DSP_CMD_HSADC_AUTO      0x98    /* high speed adc, auto */
7678344Sobrien
7778344Sobrien/* SBPro commands. Some cards (JAZZ, SMW) also support 16 bits */
7878344Sobrien
7978344Sobrien	/* prepare for dma input */
8078344Sobrien#define	DSP_CMD_DMAMODE(stereo, bit16) (0xA0 | (stereo ? 8:0) | (bit16 ? 4:0))
8178344Sobrien
8278344Sobrien#define	DSP_CMD_DAC2		0x16	/* 2-bit adpcm dma out (cont) */
8378344Sobrien#define	DSP_CMD_DAC2S		0x17	/* 2-bit adpcm dma out (start) */
8478344Sobrien
8578344Sobrien#define	DSP_CMD_DAC2S_AUTO	0x1f	/* auto 2-bit adpcm dma out (start) */
8678344Sobrien
8778344Sobrien
8878344Sobrien/* SB16 commands */
8978344Sobrien#define	DSP_CMD_O16		0xb0
9078344Sobrien#define	DSP_CMD_I16		0xb8
9178344Sobrien#define	DSP_CMD_O8		0xc0
9278344Sobrien#define	DSP_CMD_I8		0xc8
9378344Sobrien
9478344Sobrien#define	DSP_MODE_U8MONO		0x00
9578344Sobrien#define	DSP_MODE_U8STEREO	0x20
9678344Sobrien#define	DSP_MODE_S16MONO	0x10
9778344Sobrien#define	DSP_MODE_S16STEREO	0x30
9878344Sobrien
9978344Sobrien#define DSP_CMD_SPKON		0xD1
10078344Sobrien#define DSP_CMD_SPKOFF		0xD3
10178344Sobrien#define DSP_CMD_SPKR(on)	(0xD1 | (on ? 0:2))
10278344Sobrien
10378344Sobrien#define	DSP_CMD_DMAPAUSE_8	0xD0
10478344Sobrien#define	DSP_CMD_DMAPAUSE_16	0xD5
10578344Sobrien#define	DSP_CMD_DMAEXIT_8	0xDA
10678344Sobrien#define	DSP_CMD_DMAEXIT_16	0xD9
10778344Sobrien#define	DSP_CMD_TCONST		0x40	/* set time constant */
10878344Sobrien#define	DSP_CMD_HSDAC		0x91	/* high speed dac */
10978344Sobrien#define DSP_CMD_HSADC           0x99    /* high speed adc */
11078344Sobrien
11178344Sobrien#define	DSP_CMD_GETVER		0xE1
11278344Sobrien#define	DSP_CMD_GETID		0xE7	/* return id bytes */
11378344Sobrien
11478344Sobrien
11578344Sobrien#define	DSP_CMD_OUT16		0x41	/* send parms for dma out on sb16 */
11678344Sobrien#define	DSP_CMD_IN16		0x42	/* send parms for dma in on sb16 */
11778344Sobrien#if 0 /*** unknown ***/
11878344Sobrien#define	DSP_CMD_FA		0xFA	/* get version from prosonic*/
11978344Sobrien#define	DSP_CMD_FB		0xFB	/* set irq/dma for prosonic*/
12078344Sobrien#endif
12178344Sobrien
12278344Sobrien/*
12378344Sobrien * in fact, for the SB16, dma commands are as follows:
12478344Sobrien *
125 *  cmd, mode, len_low, len_high.
126 *
127 * cmd is a combination of DSP_DMA16 or DSP_DMA8 and
128 */
129
130#define	DSP_DMA16		0xb0
131#define	DSP_DMA8		0xc0
132#   define DSP_F16_DAC		0x00
133#   define DSP_F16_ADC		0x08
134#   define DSP_F16_AUTO		0x04
135#   define DSP_F16_FIFO_ON	0x02
136
137/*
138 * mode is a combination of the following:
139 */
140#define DSP_F16_STEREO	0x20
141#define DSP_F16_SIGNED	0x10
142
143#define IMODE_NONE		0
144#define IMODE_OUTPUT		PCM_ENABLE_OUTPUT
145#define IMODE_INPUT		PCM_ENABLE_INPUT
146#define IMODE_INIT		3
147#define IMODE_MIDI		4
148
149#define NORMAL_MIDI	0
150#define UART_MIDI	1
151
152/*
153 * values used for bd_flags in SoundBlaster driver
154 */
155#define	BD_F_HISPEED	0x0001	/* doing high speed ... */
156
157#if 0
158#define	BD_F_JAZZ16	0x0002	/* jazz16 detected */
159#define	BD_F_JAZZ16_2	0x0004	/* jazz16 type 2 */
160#endif
161
162#define	BD_F_DUP_MIDI	0x0008	/* duplex midi */
163
164#define	BD_F_MIX_MASK	0x0070	/* up to 8 mixers (I know of 3) */
165#define	BD_F_MIX_CT1335	0x0010	/* CT1335		*/
166#define	BD_F_MIX_CT1345	0x0020	/* CT1345		*/
167#define	BD_F_MIX_CT1745	0x0030	/* CT1745		*/
168
169#define	BD_F_SB16	0x0100	/* this is a SB16 */
170#define	BD_F_SB16X	0x0200	/* this is a vibra16X or clone */
171#if 0
172#define	BD_F_MIDIBUSY	0x0400	/* midi busy */
173#endif
174#define	BD_F_ESS	0x0800	/* this is an ESS chip */
175#define BD_F_DMARUN	0x2000
176#define BD_F_DMARUN2	0x4000
177
178/*
179 * Mixer registers of SB Pro
180 */
181#define VOC_VOL		0x04
182#define MIC_VOL		0x0A
183#define MIC_MIX		0x0A
184#define RECORD_SRC	0x0C
185#define IN_FILTER	0x0C
186#define OUT_FILTER	0x0E
187#define MASTER_VOL	0x22
188#define FM_VOL		0x26
189#define CD_VOL		0x28
190#define LINE_VOL	0x2E
191#define IRQ_NR		0x80
192#define DMA_NR		0x81
193#define IRQ_STAT	0x82
194
195/*
196 * Additional registers on the SG NX Pro
197 */
198#define COVOX_VOL	0x42
199#define TREBLE_LVL	0x44
200#define BASS_LVL	0x46
201
202#define FREQ_HI         (1 << 3)/* Use High-frequency ANFI filters */
203#define FREQ_LOW        0	/* Use Low-frequency ANFI filters */
204#define FILT_ON         0	/* Yes, 0 to turn it on, 1 for off */
205#define FILT_OFF        (1 << 5)
206
207#define MONO_DAC	0x00
208#define STEREO_DAC	0x02
209
210/*
211 * Mixer registers of SB16
212 */
213#define SB16_IMASK_L	0x3d
214#define SB16_IMASK_R	0x3e
215#define SB16_OMASK	0x3c
216#endif
217