source: mainline/uspace/drv/audio/sb16/dsp_commands.h@ 6233c4e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 6233c4e was 6233c4e, checked in by Jan Vesely <jano.vesely@…>, 14 years ago

sb16: Prettify debug output.

Add mode to string conversion.

  • Property mode set to 100644
File size: 8.4 KB
RevLine 
[b956810]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
[763444e]38/** See Sound Blaster Series HW programming Guide Chapter 6. */
[b956810]39typedef enum dsp_command {
[57542304]40 DIRECT_8B_OUTPUT = 0x10, /* Followed by unsigned byte of digital data,
[b956810]41 * software controls sampling rate */
[57542304]42 DIRECT_8B_INPUT = 0x20, /* Same as DIRECT_8B_OUTPUT but for input */
[b956810]43
44 TRANSFER_TIME_CONSTANT = 0x40, /* Followed by time constant.
45 * TC = 65536 - (256 000 000 /
46 * (channels * sampling rate))
47 * Send only high byte */
48
49 SINGLE_DMA_8B_OUTPUT = 0x14, /* Followed by length.high and length.low
50 * starts single-cycle DMA, length is -1 */
51 SINGLE_DMA_8B_INPUT = 0x24, /* Same as SINGLE_DMA_8B_OUTPUT, but for
52 * input */
53 SINGLE_DMA_8B_ADPCM_2B_OUT = 0x16, /* Starts single-cycle DMA using
54 * Creative ADPSM 8->2 bit compressed
55 * data, Followed by length.low
56 * and length.high. Length is -1 */
57 SINGLE_DMA_8B_ADPCM_2B_OUT_REF = 0x17, /* Starts single-cycle DMA using
58 * DPSM 8->2 bit compressed data
59 * with reference byte.
60 * Followed by length.low and
61 * length.high. Length is -1 */
62 SINGLE_DMA_8B_ADPCM_4B_OUT = 0x74, /* Same as
63 * SINGLE_DMA_8B_ADPCM_2B_OUT */
64 SINGLE_DMA_8B_ADPCM_4B_OUT_REF = 0x75, /* Same as
65 * SINGLE_DMA_8B_ADPCM_2B_OUT_REF
66 */
67 SINGLE_DMA_8B_ADPCM_3B_OUT = 0x76, /* Same as
68 * SINGLE_DMA_8B_ADPCM_2B_OUT */
69 SINGLE_DMA_8B_ADPCM_3B_OUT_REF = 0x77, /* Same as
70 * SINGLE_DMA_8B_ADPCM_2B_OUT_REF
71 */
72
73 DMA_8B_PAUSE = 0xd0, /* Stop sending DMA request,
74 * works for SINGLE and AUTO */
75 DMA_8B_CONTINUE = 0xd4, /* Resume transfers paused by DMA_8B_PAUSE */
76
77 SPEAKER_ON = 0xd1, /* Connect speaker via internal amplifier,
78 * has no effect on 4.xx */
79 SPEAKER_OFF = 0xd3, /* Disconnect output from the amplifier,
80 * has no effect on 4.xx */
81
82 MIDI_POLLING = 0x30, /* Read DSP for MIDI data */
83 MIDI_INTERRUPT = 0x31, /* Start interrupt mode, interrupt will be
84 * generated when there is in-bound data.
85 * To exit send again */
86 MIDI_OUTPUT = 0x38, /* Followed by midi_data */
87
88 PAUSE = 0x80, /* Followed by duration.low, duration.high. Duration is -1
89 * In the units of sampling period. Generates interrupt
90 * at the end of period */
91 DSP_VERSION = 0xe1, /* Read 2 bytes, major and minor number */
92
93 AUTO_DMA_8B_OUTPUT = 0x1c, /* Starts auto-init DMA mode using 8-bit
94 * Interrupt after every block.
95 * To terminate, switch to single or use
96 * EXIT command*/
97 AUTO_DMA_8B_INPUT = 0x2c, /* Same as AUTO_DMA_8B_OUTPUT, but for input*/
98 AUTO_DMA_8B_ADPCM_2B_REF = 0x1f, /* Same as AUTO_DMA_8B_OUTPUT, but use
99 * 8->2bit ADPCM audio format */
100 AUTO_DMA_8B_ADPCM_4B_REF = 0x7d, /* Same as AUTO_DMA_8B_ADPCM_2B_REF */
101 AUTO_DMA_8B_ADPCM_3B_REF = 0x7f, /* Same as AUTO_DMA_8B_ADPCM_2B_REF */
102
103 DMA_8B_EXIT = 0xda, /* Ends DMA transfer and terminates I/O process */
104
105 BLOCK_TRANSFER_SIZE = 0x48, /* Followed by size.low, size.high
106 * Used with HIGH_SPEED AUTO_DMA */
107
108 UART_MIDI_POLLING = 0x34, /* Start UART MIDI polling mode, read and
109 * write from/to DSP is interpreted as
110 * read/write from/to MIDI.
111 * To exit use reset signal. Note that reset
112 * will restore previous state and won't do
113 * complete reset */
114 UART_MIDI_INTERRUPT = 0x35, /* Same as UART_MIDI_POLLING, but use
115 * interrupts instead of polling. */
116 UART_MIDI_POLLING_TS = 0x36, /* Add time stamp to inbound data, the
117 * order is time.low time.mid time.high
118 * data */
119 UART_MIDI_INTERRUPT_TS = 0x37, /* Same as UART_MIDI_POLLING_TS, but use
120 * interrupts instead of polling */
121
122 SPEAKER_STATUS = 0xd8, /* 0xff means amp is on, 0x00 means it's off */
123
124 AUTO_DMA_8B_HIGH_OUTPUT = 0x90, /* DSP will generate interrupt after
125 * every block. No other commands are
126 * accepted in this mode. To exit
127 * the mode send RESET command.
128 * Note that reset will restore
129 * previous state. */
130 AUTO_DMA_8B_HIGH_INPUT = 0x98, /* Same as AUTO_DMA_8B_HIGH_OUTPUT */
131 SINGLE_DMA_8B_HIGH_OUTPUT = 0x91, /* Transfer one block and exit,
132 * generates interrupt */
133 SINGLE_DMA_8B_HIGH_INPUT = 0x99, /* Same as SINGLE_DMA_8B_HIGH_OUTPUT */
134
135 SET_MONO_INPUT = 0xa0, /* Mono mode is the default, only on 3.xx */
136 SET_STEREO_INPUT = 0xa8, /* switch to stereo recording, only on 3.xx */
137
138 SET_SAMPLING_RATE_OUTPUT = 0x41, /* Followed by sapling rate
139 * 5000 to 45000 Hz, inclusive */
140 SET_SAMPLING_RATE_INPUT = 0x42, /* Same as SET_SAMPLING_RATE_OUTPUT */
141
142 SINGLE_DMA_16B_DA = 0xb0, /* Followed by mode, size.low, size.high*/
143 SINGLE_DMA_16B_DA_FIFO = 0xb2,/* mode format is: */
[f14e6ea]144 AUTO_DMA_16B_DA = 0xb4, /* 0x00 - unsigned mono 8bit */
145 AUTO_DMA_16B_DA_FIFO = 0xb6, /* 0x10 - signed mono 16bit */
146 SINGLE_DMA_16B_AD = 0xb8, /* 0x20 - unsigned stereo 8bit */
147 SINGLE_DMA_16B_AD_FIFO = 0xba,/* 0x30 - signed stereo 16bit */
[b956810]148 AUTO_DMA_16B_AD = 0xbc, /* Size is -1. Terminate by EXIT */
149 AUTO_DMA_16B_AD_FIFO = 0xbe, /* or switch to SINGLE_DMA */
150
151 SINGLE_DMA_8B_DA = 0xc0, /* Followed by mode, size.low, size.high */
152 SINGLE_DMA_8B_DA_FIFO = 0xc2,/* mode format is: */
[f14e6ea]153 AUTO_DMA_8B_DA = 0xc4, /* 0x00 - unsigned mono 8bit */
154 AUTO_DMA_8B_DA_FIFO = 0xc6, /* 0x10 - signed mono 16bit */
155 SINGLE_DMA_8B_AD = 0xc8, /* 0x20 - unsigned stereo 8bit */
156 SINGLE_DMA_8B_AD_FIFO = 0xca,/* 0x30 - signed stereo 16bit */
[b956810]157 AUTO_DMA_8B_AD = 0xcc, /* Size is -1. Terminate by EXIT */
158 AUTO_DMA_8B_AD_FIFO = 0xce, /* or switch to SINGLE_DMA */
159
160 DMA_16B_PAUSE = 0xd5,/* Stop sending DMA request, both SINGLE and AUTO*/
161 DMA_16B_CONTINUE = 0xd6, /* Resume requests paused by DMA_16B_PAUSE */
162 DMA_16B_EXIT = 0xd9, /* Ends DMA transfer and terminates I/O process */
163} dsp_command_t;
[6233c4e]164/*----------------------------------------------------------------------------*/
165#define DSP_MODE_16BIT 0x10
166#define DSP_MODE_STEREO 0x20
167
168static inline const char * mode_to_str(uint8_t mode)
169{
170 if (mode & 0xcf)
171 return "unknown";
172 static const char * names[] = {
173 "unsigned mono (8bit)",
174 "signed mono (16bit)",
175 "unsigned stereo (8bit)",
176 "signed stereo (16bit)",
177 };
178 return names[mode >> 4];
179}
[b956810]180
181#endif
182/**
183 * @}
184 */
Note: See TracBrowser for help on using the repository browser.