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