1 | /*
|
---|
2 | * Copyright (c) 2011 Jan Vesely
|
---|
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 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup drvaudiosb16
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 | /** @file
|
---|
33 | * @brief SB16 DSP Command constants
|
---|
34 | */
|
---|
35 | #ifndef DRV_AUDIO_SB16_DSP_COMMANDS_H
|
---|
36 | #define DRV_AUDIO_SB16_DSP_COMMANDS_H
|
---|
37 |
|
---|
38 | /** See Sound Blaster Series HW programming Guide Chapter 6. */
|
---|
39 | typedef enum dsp_command {
|
---|
40 | /*
|
---|
41 | * Followed by unsigned byte of digital data,
|
---|
42 | * software controls sampling rate
|
---|
43 | */
|
---|
44 | DIRECT_8B_OUTPUT = 0x10,
|
---|
45 | /* Same as DIRECT_8B_OUTPUT but for input */
|
---|
46 | DIRECT_8B_INPUT = 0x20,
|
---|
47 |
|
---|
48 | /*
|
---|
49 | * Followed by time constant.
|
---|
50 | * TC = 65536 - (256 000 000 /
|
---|
51 | * (channels * sampling rate))
|
---|
52 | * Send only high byte
|
---|
53 | */
|
---|
54 | TRANSFER_TIME_CONSTANT = 0x40,
|
---|
55 |
|
---|
56 | /*
|
---|
57 | * Followed by length.high and length.low
|
---|
58 | * starts single-cycle DMA, length is -1
|
---|
59 | */
|
---|
60 | SINGLE_DMA_8B_OUTPUT = 0x14,
|
---|
61 | /*
|
---|
62 | * Same as SINGLE_DMA_8B_OUTPUT, but for
|
---|
63 | * input
|
---|
64 | */
|
---|
65 | SINGLE_DMA_8B_INPUT = 0x24,
|
---|
66 | /*
|
---|
67 | * Starts single-cycle DMA using
|
---|
68 | * Creative ADPSM 8->2 bit compressed
|
---|
69 | * data, Followed by length.low
|
---|
70 | * and length.high. Length is -1
|
---|
71 | */
|
---|
72 | SINGLE_DMA_8B_ADPCM_2B_OUT = 0x16,
|
---|
73 | /*
|
---|
74 | * Starts single-cycle DMA using
|
---|
75 | * DPSM 8->2 bit compressed data
|
---|
76 | * with reference byte.
|
---|
77 | * Followed by length.low and
|
---|
78 | * length.high. Length is -1
|
---|
79 | */
|
---|
80 | SINGLE_DMA_8B_ADPCM_2B_OUT_REF = 0x17,
|
---|
81 | /*
|
---|
82 | * Same as
|
---|
83 | * SINGLE_DMA_8B_ADPCM_2B_OUT
|
---|
84 | */
|
---|
85 | SINGLE_DMA_8B_ADPCM_4B_OUT = 0x74,
|
---|
86 | /*
|
---|
87 | * Same as
|
---|
88 | * SINGLE_DMA_8B_ADPCM_2B_OUT_REF
|
---|
89 | */
|
---|
90 | SINGLE_DMA_8B_ADPCM_4B_OUT_REF = 0x75,
|
---|
91 | /*
|
---|
92 | * Same as
|
---|
93 | * SINGLE_DMA_8B_ADPCM_2B_OUT
|
---|
94 | */
|
---|
95 | SINGLE_DMA_8B_ADPCM_3B_OUT = 0x76,
|
---|
96 | /*
|
---|
97 | * Same as
|
---|
98 | * SINGLE_DMA_8B_ADPCM_2B_OUT_REF
|
---|
99 | */
|
---|
100 | SINGLE_DMA_8B_ADPCM_3B_OUT_REF = 0x77,
|
---|
101 | /*
|
---|
102 | * Stop sending DMA request,
|
---|
103 | * works for SINGLE and AUTO
|
---|
104 | */
|
---|
105 | DMA_8B_PAUSE = 0xd0,
|
---|
106 | /* Resume transfers paused by DMA_8B_PAUSE */
|
---|
107 | DMA_8B_CONTINUE = 0xd4,
|
---|
108 |
|
---|
109 | /*
|
---|
110 | * Connect speaker via internal amplifier,
|
---|
111 | * has no effect on 4.xx
|
---|
112 | */
|
---|
113 | SPEAKER_ON = 0xd1,
|
---|
114 | /*
|
---|
115 | * Disconnect output from the amplifier,
|
---|
116 | * has no effect on 4.xx
|
---|
117 | */
|
---|
118 | SPEAKER_OFF = 0xd3,
|
---|
119 |
|
---|
120 | /* Read DSP for MIDI data */
|
---|
121 | MIDI_POLLING = 0x30,
|
---|
122 | /*
|
---|
123 | * Start interrupt mode, interrupt will be
|
---|
124 | * generated when there is in-bound data.
|
---|
125 | * To exit send again
|
---|
126 | */
|
---|
127 | MIDI_INTERRUPT = 0x31,
|
---|
128 | /* Followed by midi_data */
|
---|
129 | MIDI_OUTPUT = 0x38,
|
---|
130 |
|
---|
131 | /*
|
---|
132 | * Followed by duration.low, duration.high. Duration is -1
|
---|
133 | * In the units of sampling period. Generates interrupt
|
---|
134 | * at the end of period
|
---|
135 | */
|
---|
136 | PAUSE = 0x80,
|
---|
137 | /* Read 2 bytes, major and minor number */
|
---|
138 | DSP_VERSION = 0xe1,
|
---|
139 |
|
---|
140 | /*
|
---|
141 | * Starts auto-init DMA mode using 8-bit
|
---|
142 | * Interrupt after every block.
|
---|
143 | * To terminate, switch to single or use
|
---|
144 | * EXIT command
|
---|
145 | */
|
---|
146 | AUTO_DMA_8B_OUTPUT = 0x1c,
|
---|
147 | /* Same as AUTO_DMA_8B_OUTPUT, but for input */
|
---|
148 | AUTO_DMA_8B_INPUT = 0x2c,
|
---|
149 | /*
|
---|
150 | * Same as AUTO_DMA_8B_OUTPUT, but use
|
---|
151 | * 8->2bit ADPCM audio format
|
---|
152 | */
|
---|
153 | AUTO_DMA_8B_ADPCM_2B_REF = 0x1f,
|
---|
154 | /* Same as AUTO_DMA_8B_ADPCM_2B_REF */
|
---|
155 | AUTO_DMA_8B_ADPCM_4B_REF = 0x7d,
|
---|
156 | /* Same as AUTO_DMA_8B_ADPCM_2B_REF */
|
---|
157 | AUTO_DMA_8B_ADPCM_3B_REF = 0x7f,
|
---|
158 |
|
---|
159 | /* Ends DMA transfer and terminates I/O process */
|
---|
160 | DMA_8B_EXIT = 0xda,
|
---|
161 |
|
---|
162 | /*
|
---|
163 | * Followed by size.low, size.high
|
---|
164 | * Used with HIGH_SPEED AUTO_DMA
|
---|
165 | */
|
---|
166 | BLOCK_TRANSFER_SIZE = 0x48,
|
---|
167 | /*
|
---|
168 | * Start UART MIDI polling mode, read and
|
---|
169 | * write from/to DSP is interpreted as
|
---|
170 | * read/write from/to MIDI.
|
---|
171 | * To exit use reset signal. Note that reset
|
---|
172 | * will restore previous state and won't do
|
---|
173 | * complete reset
|
---|
174 | */
|
---|
175 | UART_MIDI_POLLING = 0x34,
|
---|
176 | /*
|
---|
177 | * Same as UART_MIDI_POLLING, but use
|
---|
178 | * interrupts instead of polling.
|
---|
179 | */
|
---|
180 | UART_MIDI_INTERRUPT = 0x35,
|
---|
181 | /*
|
---|
182 | * Add time stamp to inbound data, the
|
---|
183 | * order is time.low time.mid time.high
|
---|
184 | * data
|
---|
185 | */
|
---|
186 | UART_MIDI_POLLING_TS = 0x36,
|
---|
187 | /*
|
---|
188 | * Same as UART_MIDI_POLLING_TS, but use
|
---|
189 | * interrupts instead of polling
|
---|
190 | */
|
---|
191 | UART_MIDI_INTERRUPT_TS = 0x37,
|
---|
192 |
|
---|
193 | /* 0xff means amp is on, 0x00 means it's off */
|
---|
194 | SPEAKER_STATUS = 0xd8,
|
---|
195 |
|
---|
196 | /*
|
---|
197 | * DSP will generate interrupt after
|
---|
198 | * every block. No other commands are
|
---|
199 | * accepted in this mode. To exit
|
---|
200 | * the mode send RESET command.
|
---|
201 | * Note that reset will restore
|
---|
202 | * previous state.
|
---|
203 | */
|
---|
204 | AUTO_DMA_8B_HIGH_OUTPUT = 0x90,
|
---|
205 | /* Same as AUTO_DMA_8B_HIGH_OUTPUT */
|
---|
206 | AUTO_DMA_8B_HIGH_INPUT = 0x98,
|
---|
207 | /*
|
---|
208 | * Transfer one block and exit,
|
---|
209 | * generates interrupt
|
---|
210 | */
|
---|
211 | SINGLE_DMA_8B_HIGH_OUTPUT = 0x91,
|
---|
212 | /* Same as SINGLE_DMA_8B_HIGH_OUTPUT */
|
---|
213 | SINGLE_DMA_8B_HIGH_INPUT = 0x99,
|
---|
214 |
|
---|
215 | /* Mono mode is the default, only on 3.xx */
|
---|
216 | SET_MONO_INPUT = 0xa0,
|
---|
217 | /* Switch to stereo recording, only on 3.xx */
|
---|
218 | SET_STEREO_INPUT = 0xa8,
|
---|
219 |
|
---|
220 | /*
|
---|
221 | * Followed by sapling rate
|
---|
222 | * 5000 to 45000 Hz, inclusive
|
---|
223 | */
|
---|
224 | SET_SAMPLING_RATE_OUTPUT = 0x41,
|
---|
225 | /* Same as SET_SAMPLING_RATE_OUTPUT */
|
---|
226 | SET_SAMPLING_RATE_INPUT = 0x42,
|
---|
227 |
|
---|
228 | /*
|
---|
229 | * Followed by mode, size.low, size.high
|
---|
230 | * mode format is:
|
---|
231 | * 0x00 - unsigned mono
|
---|
232 | * 0x10 - signed mono
|
---|
233 | * 0x20 - unsigned stereo
|
---|
234 | * 0x30 - signed stereo
|
---|
235 | * Size is -1. Terminate AUTO_DMA by EXIT
|
---|
236 | * or switch to SINGLE_DMA
|
---|
237 | */
|
---|
238 | SINGLE_DMA_16B_DA = 0xb0,
|
---|
239 | SINGLE_DMA_16B_DA_FIFO = 0xb2,
|
---|
240 | AUTO_DMA_16B_DA = 0xb4,
|
---|
241 | AUTO_DMA_16B_DA_FIFO = 0xb6,
|
---|
242 | SINGLE_DMA_16B_AD = 0xb8,
|
---|
243 | SINGLE_DMA_16B_AD_FIFO = 0xba,
|
---|
244 | AUTO_DMA_16B_AD = 0xbc,
|
---|
245 | AUTO_DMA_16B_AD_FIFO = 0xbe,
|
---|
246 |
|
---|
247 | /*
|
---|
248 | * Followed by mode, size.low, size.high
|
---|
249 | * mode format is:
|
---|
250 | * 0x00 - unsigned mono
|
---|
251 | * 0x10 - signed mono
|
---|
252 | * 0x20 - unsigned stereo
|
---|
253 | * 0x30 - signed stereo
|
---|
254 | * Size is -1. Terminate AUTO_DMA by EXIT
|
---|
255 | * or switch to SINGLE_DMA
|
---|
256 | */
|
---|
257 | SINGLE_DMA_8B_DA = 0xc0,
|
---|
258 | SINGLE_DMA_8B_DA_FIFO = 0xc2,
|
---|
259 | AUTO_DMA_8B_DA = 0xc4,
|
---|
260 | AUTO_DMA_8B_DA_FIFO = 0xc6,
|
---|
261 | SINGLE_DMA_8B_AD = 0xc8,
|
---|
262 | SINGLE_DMA_8B_AD_FIFO = 0xca,
|
---|
263 | AUTO_DMA_8B_AD = 0xcc,
|
---|
264 | AUTO_DMA_8B_AD_FIFO = 0xce,
|
---|
265 |
|
---|
266 | /* Stop sending DMA request, both SINGLE and AUTO */
|
---|
267 | DMA_16B_PAUSE = 0xd5,
|
---|
268 | /* Resume requests paused by DMA_16B_PAUSE */
|
---|
269 | DMA_16B_CONTINUE = 0xd6,
|
---|
270 | /* Ends DMA transfer and terminates I/O process */
|
---|
271 | DMA_16B_EXIT = 0xd9,
|
---|
272 | } dsp_command_t;
|
---|
273 |
|
---|
274 | #define DSP_MODE_SIGNED 0x10
|
---|
275 | #define DSP_MODE_STEREO 0x20
|
---|
276 |
|
---|
277 | static inline const char *mode_to_str(uint8_t mode)
|
---|
278 | {
|
---|
279 | if (mode & 0xcf)
|
---|
280 | return "unknown";
|
---|
281 | static const char *names[] = {
|
---|
282 | "unsigned mono (8bit)",
|
---|
283 | "signed mono (16bit)",
|
---|
284 | "unsigned stereo (8bit)",
|
---|
285 | "signed stereo (16bit)",
|
---|
286 | };
|
---|
287 | return names[mode >> 4];
|
---|
288 | }
|
---|
289 |
|
---|
290 | #endif
|
---|
291 | /**
|
---|
292 | * @}
|
---|
293 | */
|
---|