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