sbreg.h revision 1.3 1 /*
2 * Copyright (c) 1991-1993 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the Computer Systems
16 * Engineering Group at Lawrence Berkeley Laboratory.
17 * 4. Neither the name of the University nor of the Laboratory may be used
18 * to endorse or promote products derived from this software without
19 * specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * From: Header: sbreg.h,v 1.3 93/07/18 14:07:28 mccanne Exp (LBL)
34 * $Id: sbreg.h,v 1.3 1994/09/16 23:48:22 mycroft Exp $
35 */
36
37 /*
38 * SoundBlaster register definitions.
39 * See "The Developer Kit for Sound Blaster Series, User's Guide" for more
40 * complete information (avialable from Creative Labs, Inc.). We refer
41 * to this documentation as "SBK".
42 *
43 * We handle two types of cards: the basic SB version 2.0+, and
44 * the SB PRO. There are several distinct pieces of the hardware:
45 *
46 * joystick port (independent of I/O base address)
47 * FM synth (stereo on PRO)
48 * mixer (PRO only)
49 * DSP (sic)
50 * CD-ROM (PRO only)
51 *
52 * The MIDI capabilities are handled by the DSP unit.
53 */
54
55 /*
56 * Address map. The SoundBlaster can be configured (via jumpers) for
57 * either base I/O address 0x220 or 0x240. The encodings below give
58 * the offsets to specific SB ports. SBP stands for SB port offset.
59 */
60 #ifdef SBPRO
61 #define SBP_LFM_STATUS 0 /* R left FM status port */
62 #define SBP_LFM_ADDR 0 /* W left FM address register */
63 #define SBP_LFM_DATA 1 /* RW left FM data port */
64 #define SBP_RFM_STATUS 2 /* R right FM status port */
65 #define SBP_RFM_ADDR 2 /* W right FM address register */
66 #define SBP_RFM_DATA 3 /* RW right FM data port */
67 #endif
68 #define SBP_FM_STATUS 8 /* R FM status port */
69 #define SBP_FM_ADDR 8 /* W FM address register */
70 #define SBP_FM_DATA 9 /* RW FM data port */
71 #ifdef SBPRO
72 #define SBP_MIXER_ADDR 4 /* W mixer address register */
73 #define SBP_MIXER_DATA 5 /* RW mixer data port */
74 #endif
75 #define SBP_DSP_RESET 6 /* W reset port */
76 #define SB_MAGIC 0xaa /* card outputs on successful reset */
77 #define SBP_DSP_READ 10 /* R read port */
78 #define SBP_DSP_WRITE 12 /* W write port */
79 #define SBP_DSP_WSTAT 12 /* R write status */
80 #define SBP_DSP_RSTAT 14 /* R read status */
81 #define SB_DSP_BUSY 0x80
82 #define SB_DSP_READY 0x80
83 #ifdef SBPRO
84 #define SBP_CDROM_DATA 16 /* RW send cmds/recv data */
85 #define SBP_CDROM_STATUS 17 /* R status port */
86 #define SBP_CDROM_RESET 18 /* W reset register */
87 #define SBP_CDROM_ENABLE 19 /* W enable register */
88 #endif
89 #ifdef SBPRO
90 #define SB_NPORT 24
91 #else
92 #define SB_NPORT 16
93 #endif
94
95 /*
96 * DSP commands. This unit handles MIDI and audio capabilities.
97 * The DSP can be reset, data/commands can be read or written to it,
98 * and it can generate interrupts. Interrupts are generated for MIDI
99 * input or DMA completion. They seem to have neglected the fact
100 * that it would be nice to have a MIDI transmission complete interrupt.
101 * Worse, the DMA engine is half-duplex. This means you need to do
102 * (timed) programmed I/O to be able to record and play simulataneously.
103 */
104 #define SB_DSP_DACWRITE 0x10 /* programmed I/O write to DAC */
105 #define SB_DSP_WDMA 0x14 /* begin 8-bit linear DMA output */
106 #define SB_DSP_WDMA_2 0x16 /* begin 2-bit ADPCM DMA output */
107 #define SB_DSP_ADCREAD 0x20 /* programmed I/O read from ADC */
108 #define SB_DSP_RDMA 0x24 /* begin 8-bit linear DMA input */
109 #define SB_MIDI_POLL 0x30 /* initiate a polling read for MIDI */
110 #define SB_MIDI_READ 0x31 /* read a MIDI byte on recv intr */
111 #define SB_MIDI_UART_POLL 0x34 /* enter UART mode w/ read polling */
112 #define SB_MIDI_UART_INTR 0x35 /* enter UART mode w/ read intrs */
113 #define SB_MIDI_WRITE 0x38 /* write a MIDI byte (non-UART mode) */
114 #define SB_DSP_TIMECONST 0x40 /* set ADAC time constant */
115 #define SB_DSP_BLOCKSIZE 0x48 /* set blk size for high speed xfer */
116 #define SB_DSP_WDMA_4 0x74 /* begin 4-bit ADPCM DMA output */
117 #define SB_DSP_WDMA_2_6 0x76 /* begin 2.6-bit ADPCM DMA output */
118 #define SB_DSP_SILENCE 0x80 /* send a block of silence */
119 #define SB_DSP_HS_OUTPUT 0x91 /* set high speed mode for wdma */
120 #define SB_DSP_HS_INPUT 0x99 /* set high speed mode for rdma */
121 #define SB_DSP_HALT 0xd0 /* temporarilty suspend DMA */
122 #define SB_DSP_SPKR_ON 0xd1 /* turn speaker on */
123 #define SB_DSP_SPKR_OFF 0xd3 /* turn speaker off */
124 #define SB_DSP_CONT 0xd4 /* continue suspended DMA */
125 #define SB_DSP_RD_SPKR 0xd8 /* get speaker status */
126 #define SB_SPKR_OFF 0x00
127 #define SB_SPKR_ON 0xff
128 #define SB_DSP_VERSION 0xe1 /* get version number */
129
130 /*
131 * The ADPCM encodings are differential, meaning each sample represents
132 * a difference to add to a running sum. The inital value is called the
133 * reference, or reference byte. Any of the ADPCM DMA transfers can specify
134 * that the given transfer begins with a reference byte by or'ing
135 * in the bit below.
136 */
137 #define SB_DSP_REFERENCE 1
138
139 /*
140 * Macros to detect valid hardware configuration data.
141 */
142 #ifdef SBPRO
143 #define SB_IRQ_VALID(mask) ((mask) & 0x04a4) /* IRQ 2,5,7,10 */
144 #define SB_DRQ_VALID(chan) ((chan) == 0 || (chan) == 1 || (chan) == 3)
145 #else /* !SBPRO */
146 #define SB_IRQ_VALID(mask) ((mask) & 0x00ac) /* IRQ 2,3,5,7 */
147 #define SB_DRQ_VALID(chan) ((chan) == 1)
148 #endif /* !SBPRO */
149 #define SB_BASE_VALID(base) ((base) == 0x220 || (base) == 0x240)
150
151 #define SB_INPUT_RATE 0
152 #define SB_OUTPUT_RATE 1
153
154