ReactOS 0.4.16-dev-297-gc569aee
sbdsp.h
Go to the documentation of this file.
1/*
2 ReactOS Sound System
3 Sound Blaster DSP support
4
5 Author:
6 Andrew Greenwood (silverblade@reactos.org)
7
8 History:
9 26 May 2008 - Created
10
11 Notes:
12 Where timeouts are concerned, a value of 0 is interpreted as "forever".
13*/
14
15#ifndef ROS_SOUND_SBDSP_H
16#define ROS_SOUND_SBDSP_H
17
18/*
19 Product versions
20 DSP 1.0, 1.5, 2.0, 2.01 correspond with respective Sound Blaster versions.
21 DSP 3.xx is Sound Blaster Pro
22 DSP 4.xx is Sound Blaster 16
23*/
24
25#define SOUND_BLASTER_1_0 L"Sound Blaster 1.0"
26#define SOUND_BLASTER_1_5 L"Sound Blaster 1.5"
27#define SOUND_BLASTER_2_0 L"Sound Blaster 2.0"
28#define SOUND_BLASTER_PRO L"Sound Blaster Pro"
29#define SOUND_BLASTER_16 L"Sound Blaster 16"
30
31
32/*
33 Sound Blaster ports I/O
34*/
35#define READ_SB_FM1_STATUS(bp) READ_PORT_UCHAR((PUCHAR) bp)
36#define WRITE_SB_FM1_REGISTER(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp, x)
37#define WRITE_SB_FM1_DATA(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0x01, x)
38
39#define READ_SB_AFM_STATUS(bp) READ_PORT_UCHAR((PUCHAR) bp+0x02)
40#define WRITE_SB_AFM_REGISTER(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0x02, x)
41#define WRITE_SB_AFM_DATA(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0x03, x)
42
43#define WRITE_SB_MIXER_REGISTER(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0x04, x)
44#define READ_SB_MIXER_DATA(bp) READ_PORT_UCHAR((PUCHAR) bp+0x05)
45#define WRITE_SB_MIXER_DATA(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0x05, x)
46
47#define WRITE_SB_DSP_RESET(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0x06, x)
48
49#define READ_SB_FM2_STATUS(bp) READ_PORT_UCHAR((PUCHAR) bp+0x08)
50#define WRITE_SB_FM2_REGISTER(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0x08, x)
51#define WRITE_SB_FM2_DATA(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0x09, x)
52
53#define READ_SB_DSP_DATA(bp) READ_PORT_UCHAR((PUCHAR) bp+0x0A)
54#define WRITE_SB_DSP_DATA(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0x0C, x)
55#define WRITE_SB_DSP_COMMAND(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0x0C, x)
56
57/* Clear to send */
58#define SB_DSP_CLEAR_TO_SEND(bp) \
59 ( ! (READ_PORT_UCHAR((PUCHAR) bp+0x0C) & 0x80 ) )
60
61/* Data available for reading */
62#define SB_DSP_DATA_AVAILABLE(bp) \
63 ( READ_PORT_UCHAR((PUCHAR) bp+0x0E) & 0x80 )
64
65
66#define SB_DSP_READY 0xAA
67
68/*
69 Sound Blaster DSP commands
70 (partial list)
71*/
72#define SB_DSP_OUTPUT_RATE 0x41
73#define SB_DSP_INPUT_RATE 0x42
74#define SB_DSP_BLOCK_SIZE 0x48
75#define SB_DSP_SPEAKER_ON 0xD1
76#define SB_DSP_SPEAKER_OFF 0xD3
77#define SB_DSP_SPEAKER_STATUS 0xD8
78#define SB_DSP_VERSION 0xE1
79
80/*
81 Mixer lines (legacy)
82*/
83#define SB_MIX_VOC_LEVEL 0x04
84#define SB_MIX_LEGACY_MIC_LEVEL 0x0A
85#define SB_MIX_MASTER_LEVEL 0x22
86#define SB_MIX_FM_LEVEL 0x26
87#define SB_MIX_CD_LEVEL 0x28
88#define SB_MIX_LINE_LEVEL 0x2E
89
90/*
91 Mixer lines
92*/
93#define SB_MIX_RESET 0x00
94#define SB_MIX_MASTER_LEFT_LEVEL 0x30
95#define SB_MIX_MASTER_RIGHT_LEVEL 0x31
96#define SB_MIX_VOC_LEFT_LEVEL 0x32
97#define SB_MIX_VOC_RIGHT_LEVEL 0x33
98#define SB_MIX_MIDI_LEFT_LEVEL 0x34
99#define SB_MIX_MIDI_RIGHT_LEVEL 0x35
100#define SB_MIX_CD_LEFT_LEVEL 0x36
101#define SB_MIX_CD_RIGHT_LEVEL 0x37
102#define SB_MIX_LINE_LEFT_LEVEL 0x38
103#define SB_MIX_LINE_RIGHT_LEVEL 0x39
104#define SB_MIX_MIC_LEVEL 0x3A
105#define SB_MIX_PC_SPEAKER_LEVEL 0x3B
106#define SB_MIX_OUTPUT_SWITCHES 0x3C
107#define SB_MIX_INPUT_LEFT_SWITCHES 0x3D
108#define SB_MIX_INPUT_RIGHT_SWITCHES 0x3E
109#define SB_MIX_INPUT_LEFT_GAIN 0x3F
110#define SB_MIX_INPUT_RIGHT_GAIN 0x40
111#define SB_MIX_OUTPUT_LEFT_GAIN 0x41
112#define SB_MIX_OUTPUT_RIGHT_GAIN 0x42
113#define SB_MIX_AGC 0x43
114#define SB_MIX_TREBLE_LEFT_LEVEL 0x44
115#define SB_MIX_TREBLE_RIGHT_LEVEL 0x45
116#define SB_MIX_BASS_LEFT_LEVEL 0x46
117#define SB_MIX_BASS_RIGHT_LEVEL 0x47
118
119/*
120 Mixer switches
121 (are these correct?)
122*/
123#define SB_MIX_MIDI_LEFT_SWITCH 0x01
124#define SB_MIX_MIDI_RIGHT_SWITCH 0x02
125#define SB_MIX_LINE_LEFT_SWITCH 0x04
126#define SB_MIX_LINE_RIGHT_SWITCH 0x08
127#define SB_MIX_CD_LEFT_SWITCH 0x10
128#define SB_MIX_CD_RIGHT_SWITCH 0x20
129#define SB_MIX_MIC_SWITCH 0x40
130
131
132/*
133 Reset the Sound Blaster DSP.
134*/
137 IN PUCHAR BasePort,
139
140/*
141 Wait for the Sound Blaster DSP to be ready for data to be written to it.
142*/
145 IN PUCHAR BasePort,
147
148/*
149 Wait for data to be ready for reading from the Sound Blaster DSP.
150*/
153 IN PUCHAR BasePort,
155
156/*
157 Wait for the Sound Blaster DSP to be ready for data to be written to it,
158 then (providing it becomes ready within the timeout period), write the
159 data to it.
160*/
163 IN PUCHAR BasePort,
164 IN UCHAR DataByte,
166
167/*
168 Wait for the Sound Blaster DSP to be ready for data to be read from it,
169 then read the data from it into the pointer supplied as DataByte. If
170 the timeout is exceeded, DataByte will not be modified.
171*/
174 IN PUCHAR BasePort,
175 OUT PUCHAR DataByte,
177
178/*
179 This can only be called immediately after a reset has been issued. The
180 major version and minor version are returned in MajorVersion and
181 MinorVersion, respectively.
182
183 The timeout applies to each DSP read/write performed. Note that the
184 data pointed to by MajorVersion may still fail if the retrieval of
185 MinorVersion times out.
186*/
189 IN PUCHAR BasePort,
193
194/*
195 Turn the speaker on.
196*/
199 IN PUCHAR BasePort,
201
202/*
203 Turn the speaker off.
204*/
207 IN PUCHAR BasePort,
209
210/*
211 Obtains the speaker status, storing the result in IsEnabled. This will be
212 TRUE if the speaker is enabled, otherwise FALSE.
213*/
216 IN PUCHAR BasePort,
219
220/*
221 Validate the input sample rate. The major and minor versions are required
222 to determine the capabilities of the card.
223*/
228 IN USHORT Rate,
229 IN BOOLEAN Stereo);
230
231/*
232 Validate the output sample rate. The major and minor versions are required
233 to determine the capabilities of the card.
234*/
239 IN USHORT Rate,
240 IN BOOLEAN Stereo);
241
242/*
243 Set the output/playback rate
244 * DSP 4.xx only
245*/
248 IN PUCHAR BasePort,
249 IN USHORT Rate,
251
252/*
253 Set the input/record rate
254 * DSP 4.xx only
255*/
258 IN PUCHAR BasePort,
259 IN USHORT Rate,
261
262
263/*
264 Reset the mixer
265*/
266VOID
267SbMixerReset(IN PUCHAR BasePort);
268
269/*
270 Pack mixer level data
271*/
274 IN UCHAR Line,
275 IN UCHAR Level,
276 OUT PUCHAR PackedLevel);
277
278/*
279 Unpack mixer level data
280*/
283 IN UCHAR Line,
284 IN UCHAR PackedLevel,
286
287/*
288 Set a mixer line level
289*/
292 IN PUCHAR BasePort,
293 IN UCHAR Line,
294 IN UCHAR Level);
295
296/*
297 Get a mixer line level
298*/
301 IN PUCHAR BasePort,
302 IN UCHAR Line,
304
305/*
306 Enable automatic gain control
307*/
308VOID
309SbMixerEnableAGC(IN PUCHAR BasePort);
310
311/*
312 Disable automatic gain control
313*/
314VOID
315SbMixerDisableAGC(IN PUCHAR BasePort);
316
317/*
318 Retrieve the current state of the automatic gain control
319*/
322
323
324#endif
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
ULONG MajorVersion
Definition: ros_glue.cpp:4
ULONG MinorVersion
Definition: ros_glue.cpp:5
return pProvider IsEnabled(ProviderControl)
unsigned short USHORT
Definition: pedump.c:61
static ULONG Timeout
Definition: ping.c:61
BOOLEAN SbDspIsValidOutputRate(IN UCHAR MajorVersion, IN UCHAR MinorVersion, IN USHORT Rate, IN BOOLEAN Stereo)
Definition: rate.c:56
BOOLEAN SbMixerIsAGCEnabled(IN PUCHAR BasePort)
Definition: mixer.c:238
NTSTATUS SbDspReset(IN PUCHAR BasePort, IN ULONG Timeout)
Definition: dsp_io.c:19
NTSTATUS SbMixerUnpackLevelData(IN UCHAR Line, IN UCHAR PackedLevel, OUT PUCHAR Level)
Definition: mixer.c:96
NTSTATUS SbDspEnableSpeaker(IN PUCHAR BasePort, IN ULONG Timeout)
Definition: speaker.c:19
VOID SbMixerEnableAGC(IN PUCHAR BasePort)
Definition: mixer.c:222
NTSTATUS SbDspDisableSpeaker(IN PUCHAR BasePort, IN ULONG Timeout)
Definition: speaker.c:27
NTSTATUS SbDspWaitToRead(IN PUCHAR BasePort, IN ULONG Timeout)
Definition: dsp_io.c:81
NTSTATUS SbDsp4SetOutputRate(IN PUCHAR BasePort, IN USHORT Rate, IN ULONG Timeout)
Definition: rate.c:117
NTSTATUS SbDspWaitToWrite(IN PUCHAR BasePort, IN ULONG Timeout)
Definition: dsp_io.c:63
NTSTATUS SbDspWrite(IN PUCHAR BasePort, IN UCHAR DataByte, IN ULONG Timeout)
Definition: dsp_io.c:99
NTSTATUS SbDspRead(IN PUCHAR BasePort, OUT PUCHAR DataByte, IN ULONG Timeout)
Definition: dsp_io.c:120
NTSTATUS SbDspIsSpeakerEnabled(IN PUCHAR BasePort, OUT PBOOLEAN IsEnabled, IN ULONG Timeout)
Definition: speaker.c:38
NTSTATUS SbMixerSetLevel(IN PUCHAR BasePort, IN UCHAR Line, IN UCHAR Level)
Definition: mixer.c:151
NTSTATUS SbMixerPackLevelData(IN UCHAR Line, IN UCHAR Level, OUT PUCHAR PackedLevel)
Definition: mixer.c:31
BOOLEAN SbDspIsValidInputRate(IN UCHAR MajorVersion, IN UCHAR MinorVersion, IN USHORT Rate, IN BOOLEAN Stereo)
Definition: rate.c:19
VOID SbMixerReset(IN PUCHAR BasePort)
Definition: mixer.c:24
NTSTATUS SbDsp4SetInputRate(IN PUCHAR BasePort, IN USHORT Rate, IN ULONG Timeout)
Definition: rate.c:135
NTSTATUS SbMixerGetLevel(IN PUCHAR BasePort, IN UCHAR Line, OUT PUCHAR Level)
Definition: mixer.c:185
VOID SbMixerDisableAGC(IN PUCHAR BasePort)
Definition: mixer.c:230
NTSTATUS SbDspGetVersion(IN PUCHAR BasePort, OUT PUCHAR MajorVersion, OUT PUCHAR MinorVersion, IN ULONG Timeout)
Definition: version.c:19
Definition: ncftp.h:79
unsigned char * PBOOLEAN
Definition: typedefs.h:53
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
unsigned char UCHAR
Definition: xmlstorage.h:181