xref: /haiku/src/add-ons/kernel/drivers/audio/sb16/hardware.h (revision 633b979176e71d21ae1fa2311ec7a1e1ba9a7b1d)
1 /*
2  * @(#)hardware.h  1.0 1998/12/22 Carlos Hasan (chasan@dcc.uchile.cl)
3  *
4  * Hardware definitions for the Sound Blaster 16 device driver.
5  *
6  * Copyright (C) 1998 Carlos Hasan. All Rights Reserved.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  */
13 
14 #ifndef __HARDWARE_H
15 #define __HARDWARE_H
16 
17 /*****************************************************************************
18  * SOUND BLASTER 16 PLUG-AND-PLAY DEVICE IDENTIFIERS
19  *****************************************************************************/
20 
21 /*****************************************************************************
22  * ==========================================================================
23  * Product ID	Description
24  * ==========================================================================
25  * CTL0001	Creative Sound Blaster 16 Plug and Play
26  *
27  * CTL0021	Creative AWE32 Wavetable MIDI
28  * CTL0022	Creative AWE64 Wavetable MIDI
29  * CTL0023	Creative AWE64 Gold Wavetable MIDI
30  * CTL0024	Creative AWE64 Compatible Wavetable MIDI
31  *
32  * CTL0031	Creative AWE32 16-bit Audio (SB16 compatible)
33  *
34  * CTL0041	Creative SB16 Value Plug and Play (V16CL/V32D/V32G)
35  * CTL0042	Creative SB AWE32 Plug and Play
36  * CTL0043	Creative ViBRA 16X Plug and Play
37  * CTL0044	Creative SB AWE64 Gold Plug and Play
38  * CTL0045	Creative SB AWE64
39  * CTL0046	Creative SB AWE64 Compatible Plug and Play
40  * CTL0047	Creative SB16 Plug and Play
41  * CTL0048	Creative SB AWE64 Gold Plug and Play
42  *
43  * CTL0051	Creative 3D Stereo Enhancement
44  *
45  * CTL00F0	Creative ViBRA 16X Plug and Play
46  *
47  * CTL7001	Creative Programmable Game Port
48  * CTL7002	Creative Programmable Game Port
49  * CTL7005	Creative Programmable Game Port (1 I/O)
50  *
51  * CTL8001	SB Legacy Device
52  * PNPB003	SB16 Legacy Device
53  *
54  * ==========================================================================
55  * Serial  Card Name                       Device Name    Vendor ID Device ID
56  * ==========================================================================
57  * CT3980  Creative SB AWE32 PnP           Audio          CTL0042   CTL0031
58  *                                         WaveTable      CTL0042   CTL0021
59  *                                         Game           CTL0042   CTL7001
60  *                                         IDE            CTL0042   CTL2011
61  *
62  * CT2230  Creative ViBRA 16X PnP          Audio          CTL00f0   CTL0043
63  *                                         Game           CTL00f0   CTL7005
64  */
65 
66 #define PNP_ISA_PRODUCT_ID(ch0, ch1, ch2, prod, rev) \
67 (((ch0 & 0x1f) <<  2) | ((ch1 & 0x18) >> 3) | \
68  ((ch1 & 0x07) << 13) | ((ch2 & 0x1f) << 8) | \
69  ((prod & 0xff0) << 12) | ((prod & 0x00f) << 28) | ((rev & 0xf) << 24))
70 
71 #define PNP_IS_SB16_DEVICE(id) \
72     (((id & 0xf0ffffff) == PNP_ISA_PRODUCT_ID('C', 'T', 'L', 0x000, 0x0)) || \
73      ((id & 0xf0ffffff) == PNP_ISA_PRODUCT_ID('C', 'T', 'L', 0x003, 0x0)) || \
74      ((id & 0xf0ffffff) == PNP_ISA_PRODUCT_ID('C', 'T', 'L', 0x004, 0x0)))
75 
76 /*****************************************************************************
77  * SOUND BLASTER 16 HARDWARE SPECIFICATIONS
78  *****************************************************************************/
79 
80 /*****************************************************************************
81  * Sound Blaster 16 DSP I/O port register offsets
82  */
83     enum {
84 	SB16_MIXER_ADDRESS      = 0x004,
85 	SB16_MIXER_DATA         = 0x005,
86 	SB16_CODEC_RESET        = 0x006,
87 	SB16_CODEC_READ_DATA    = 0x00a,
88 	SB16_CODEC_WRITE_DATA   = 0x00c,
89 	SB16_CODEC_WRITE_STATUS = 0x00c,
90 	SB16_CODEC_READ_STATUS  = 0x00e,
91 	SB16_CODEC_ACK_8_BIT    = 0x00e,
92 	SB16_CODEC_ACK_16_BIT   = 0x00f
93     };
94 
95 /*****************************************************************************
96  * Sound Blaster 16 DSP programming commands
97  */
98 enum {
99     SB16_SPEAKER_ENABLE     = 0xd1,
100     SB16_SPEAKER_DISABLE    = 0xd3,
101     SB16_SPEAKER_STATUS     = 0xd8,
102 
103     SB16_PLAYBACK_RATE      = 0x41,
104     SB16_CAPTURE_RATE       = 0x42,
105 
106     SB16_PLAYBACK_8_BIT     = 0xc6,
107     SB16_CAPTURE_8_BIT      = 0xce,
108     SB16_DMA_DISABLE_8_BIT  = 0xd0,
109     SB16_DMA_ENABLE_8_BIT   = 0xd4,
110     SB16_DMA_EXIT_8_BIT     = 0xda,
111 
112     SB16_PLAYBACK_16_BIT    = 0xb6,
113     SB16_CAPTURE_16_BIT     = 0xbe,
114     SB16_DMA_DISABLE_16_BIT = 0xd5,
115     SB16_DMA_ENABLE_16_BIT  = 0xd6,
116     SB16_DMA_EXIT_16_BIT    = 0xd9,
117 
118     SB16_CODEC_VERSION      = 0xe1
119 };
120 
121 /*****************************************************************************
122  * Sound Blaster 16 mixer indirect registers
123  */
124 enum {
125     SB16_MIXER_RESET        = 0x00,
126 
127     SB16_LINE_OUT_LEFT      = 0x30,
128     SB16_LINE_OUT_RIGHT     = 0x31,
129 
130     SB16_DAC_LEFT           = 0x32,
131     SB16_DAC_RIGHT          = 0x33,
132 
133     SB16_SYNTH_LEFT         = 0x34,
134     SB16_SYNTH_RIGHT        = 0x35,
135 
136     SB16_CD_LEFT            = 0x36,
137     SB16_CD_RIGHT           = 0x37,
138 
139     SB16_LINE_IN_LEFT       = 0x38,
140     SB16_LINE_IN_RIGHT      = 0x39,
141 
142     SB16_MIC                = 0x3a,
143     SB16_PC_BEEP            = 0x3b,
144 
145     SB16_OUTPUT_MUX         = 0x3c,
146 
147     SB16_INPUT_MUX_LEFT     = 0x3d,
148     SB16_INPUT_MUX_RIGHT    = 0x3e,
149 
150     SB16_ADC_GAIN_LEFT      = 0x3f,
151     SB16_ADC_GAIN_RIGHT     = 0x40,
152 
153     SB16_DAC_GAIN_LEFT      = 0x41,
154     SB16_DAC_GAIN_RIGHT     = 0x42,
155 
156     SB16_MIC_BOOST          = 0x43,
157 
158     SB16_TREBLE_LEFT        = 0x44,
159     SB16_TREBLE_RIGHT       = 0x45,
160 
161     SB16_BASS_LEFT          = 0x46,
162     SB16_BASS_RIGHT         = 0x47,
163 
164     SB16_IRQ_SETUP          = 0x80,
165     SB16_DMA_SETUP          = 0x81,
166     SB16_IRQ_STATUS         = 0x82,
167 
168     SB16_STEREO_ENHANCEMENT = 0x90
169 };
170 
171 /*****************************************************************************
172  * Sound Blaster 16 playback and capture sample formats
173  */
174 enum {
175     B_SB16_FORMAT_UNSIGNED  = 0x00,
176     B_SB16_FORMAT_SIGNED    = 0x10,
177     B_SB16_FORMAT_MONO      = 0x00,
178     B_SB16_FORMAT_STEREO    = 0x20
179 };
180 
181 /*****************************************************************************
182  * Sound Blaster 16 playback and capture control bits
183  */
184 enum {
185     B_SB16_MUX_SYNTH_LEFT   = 0x20,
186     B_SB16_MUX_SYNTH_RIGHT  = 0x40,
187     B_SB16_MUX_LINE_LEFT    = 0x10,
188     B_SB16_MUX_LINE_RIGHT   = 0x08,
189     B_SB16_MUX_CD_LEFT      = 0x04,
190     B_SB16_MUX_CD_RIGHT     = 0x02,
191     B_SB16_MUX_MIC          = 0x01,
192     B_SB16_MUX_ALL_LEFT     = 0x35,
193     B_SB16_MUX_ALL_RIGHT    = 0x4b
194 };
195 
196 /*****************************************************************************
197  * Sound Blaster 16 Stereo Enhancenment
198  */
199 enum {
200     B_SB16_SE_ENABLE        = 0x01,
201     B_SB16_SE_DETECT_ENABLE = 0x40,
202     B_SB16_SE_DETECT_STATUS = 0x80
203 };
204 
205 /*****************************************************************************
206  * Sound Blaster 16 DSP I/O port delays
207  */
208 enum {
209     SB16_CODEC_IO_DELAY     = 200000,
210     SB16_CODEC_RESET_DELAY  = 200
211 };
212 
213 /*****************************************************************************
214  * Sound Blaster 16 DMA low memory buffer
215  */
216 typedef struct {
217     area_id area;
218     char *address;
219     int size;
220 } hw_dma_buffer;
221 
222 /*****************************************************************************
223  * SOUND BLASTER 16 MPU-401 MIDI PORT HARDWARE SPECIFICATIONS
224  *****************************************************************************/
225 
226 /*****************************************************************************
227  * Sound Blaster 16 MPU-401 I/O port register offsets
228  */
229 enum {
230     MPU401_DATA           = 0x000,
231     MPU401_STATUS         = 0x001,
232     MPU401_COMMAND        = 0x001
233 };
234 
235 /*****************************************************************************
236  * Sound Blaster 16 MPU-401 status register bit fields
237  */
238 enum {
239     B_MPU401_WRITE_BUSY   = 0x40,
240     B_MPU401_READ_BUSY    = 0x80
241 };
242 
243 /*****************************************************************************
244  * Sound Blaster 16 MPU-401 MIDI port commands
245  */
246 enum {
247     MPU401_CMD_RESET      = 0xff,
248     MPU401_CMD_UART_MODE  = 0x3f
249 };
250 
251 /*****************************************************************************
252  * Sound Blaster 16 MPU-401 port timeout and latency
253  */
254 enum {
255     MPU401_IO_LATENCY     = 1000,
256     MPU401_IO_TIMEOUT     = 10000
257 };
258 
259 #endif
260