xref: /reactos/sdk/include/ddk/ntddsnd.h (revision c2c66aff)
1 /*
2     ReactOS Sound System
3     NT4 Multimedia Audio Support (ntddsnd.h)
4 
5     This file is in the public domain.
6 
7     Author:
8         Andrew Greenwood (andrew.greenwood@silverblade.co.uk)
9 
10     History:
11         24 May 2008 - Created
12         2 July 2008 - Added device names as seen from user-mode
13         5 July 2008 - Added macros for checking device type
14         14 Feb 2009 - Added base control codes for nonstandard extensions
15 
16     This file contains definitions and structures for Windows NT4 style
17     multimedia drivers. The NT4 DDK has these split across multiple header
18     files: NTDDSND.H, NTDDWAVE.H, NTDDMIDI.H, NTDDMIX.H and NTDDAUX.H
19 
20     Should you have an unstoppable urge to build an NT4 multimedia driver
21     against these headers, just create the other files listed above and make
22     them #include this one.
23 
24     There are also a number of additional enhancements within this file
25     not found in the originals (such as DOS device name strings and device
26     type IDs).
27 */
28 
29 #ifndef NTDDSND_H
30 #define NTDDSND_H
31 
32 #define SOUND_MAX_DEVICES           100
33 #define SOUND_MAX_DEVICE_NAME       80
34 
35 /*
36     Base control codes
37 */
38 
39 #define IOCTL_SOUND_BASE    FILE_DEVICE_SOUND
40 #define IOCTL_WAVE_BASE     0x0000
41 #define IOCTL_MIDI_BASE     0x0080
42 #define IOCTL_AUX_BASE      0x0100
43 #define IOCTL_MIX_BASE      0x0180
44 
45 /*
46     Helper macros for defining control codes
47 */
48 
49 #define WAVE_CTL_CODE(subcode, iomethod, access) \
50   CTL_CODE(FILE_DEVICE_SOUND, IOCTL_WAVE_BASE + subcode, iomethod, access)
51 
52 #define MIDI_CTL_CODE(subcode, iomethod, access) \
53   CTL_CODE(FILE_DEVICE_SOUND, IOCTL_MIDI_BASE + subcode, iomethod, access)
54 
55 #define MIX_CTL_CODE(subcode, iomethod, access) \
56   CTL_CODE(FILE_DEVICE_SOUND, IOCTL_MIX_BASE + subcode, iomethod, access)
57 
58 #define AUX_CTL_CODE(subcode, iomethod, access) \
59   CTL_CODE(FILE_DEVICE_SOUND, IOCTL_AUX_BASE + subcode, iomethod, access)
60 
61 /*
62     Wave device control codes
63 */
64 
65 #define IOCTL_WAVE_QUERY_FORMAT \
66   WAVE_CTL_CODE(0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
67 
68 #define IOCTL_WAVE_SET_FORMAT \
69   WAVE_CTL_CODE(0x0002, METHOD_BUFFERED, FILE_WRITE_ACCESS)
70 
71 #define IOCTL_WAVE_GET_CAPABILITIES \
72   WAVE_CTL_CODE(0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
73 
74 #define IOCTL_WAVE_SET_STATE \
75   WAVE_CTL_CODE(0x0004, METHOD_BUFFERED, FILE_WRITE_ACCESS)
76 
77 #define IOCTL_WAVE_GET_STATE \
78   WAVE_CTL_CODE(0x0005, METHOD_BUFFERED, FILE_WRITE_ACCESS)
79 
80 #define IOCTL_WAVE_GET_POSITION \
81   WAVE_CTL_CODE(0x0006, METHOD_BUFFERED, FILE_WRITE_ACCESS)
82 
83 #define IOCTL_WAVE_SET_VOLUME \
84   WAVE_CTL_CODE(0x0007, METHOD_BUFFERED, FILE_READ_ACCESS)
85 
86 #define IOCTL_WAVE_GET_VOLUME \
87   WAVE_CTL_CODE(0x0008, METHOD_BUFFERED, FILE_READ_ACCESS)
88 
89 #define IOCTL_WAVE_SET_PITCH \
90   WAVE_CTL_CODE(0x0009, METHOD_BUFFERED, FILE_WRITE_ACCESS)
91 
92 #define IOCTL_WAVE_GET_PITCH \
93   WAVE_CTL_CODE(0x000A, METHOD_BUFFERED, FILE_WRITE_ACCESS)
94 
95 #define IOCTL_WAVE_SET_PLAYBACK_RATE \
96   WAVE_CTL_CODE(0x000B, METHOD_BUFFERED, FILE_WRITE_ACCESS)
97 
98 #define IOCTL_WAVE_GET_PLAYBACK_RATE \
99   WAVE_CTL_CODE(0x000C, METHOD_BUFFERED, FILE_WRITE_ACCESS)
100 
101 #define IOCTL_WAVE_PLAY \
102   WAVE_CTL_CODE(0x000D, METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
103 
104 #define IOCTL_WAVE_RECORD \
105   WAVE_CTL_CODE(0x000E, METHOD_OUT_DIRECT, FILE_WRITE_ACCESS)
106 
107 #define IOCTL_WAVE_BREAK_LOOP \
108   WAVE_CTL_CODE(0x000F, METHOD_BUFFERED, FILE_WRITE_ACCESS)
109 
110 #define IOCTL_WAVE_SET_LOW_PRIORITY \
111   WAVE_CTL_CODE(0x0010, METHOD_BUFFERED, FILE_WRITE_ACCESS)
112 
113 #if DBG
114 /* Debug-only control code */
115 #define IOCTL_WAVE_SET_DEBUG_LEVEL \
116   WAVE_CTL_CODE(0x0040, METHOD_BUFFERED, FILE_READ_ACCESS)
117 #endif
118 
119 
120 /*
121     MIDI device control codes
122 */
123 
124 #define IOCTL_MIDI_GET_CAPABILITIES \
125   MIDI_CTL_CODE(0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
126 
127 #define IOCTL_MIDI_SET_STATE \
128   MIDI_CTL_CODE(0x0002, METHOD_BUFFERED, FILE_WRITE_ACCESS)
129 
130 #define IOCTL_MIDI_GET_STATE \
131   MIDI_CTL_CODE(0x0003, METHOD_BUFFERED, FILE_WRITE_ACCESS)
132 
133 #define IOCTL_MIDI_SET_VOLUME \
134   MIDI_CTL_CODE(0x0004, METHOD_BUFFERED, FILE_READ_ACCESS)
135 
136 #define IOCTL_MIDI_GET_VOLUME \
137   MIDI_CTL_CODE(0x0005, METHOD_BUFFERED, FILE_READ_ACCESS)
138 
139 #define IOCTL_MIDI_PLAY \
140   MIDI_CTL_CODE(0x0006, METHOD_NEITHER, FILE_WRITE_ACCESS)
141 
142 #define IOCTL_MIDI_RECORD \
143   MIDI_CTL_CODE(0x0007, METHOD_BUFFERED, FILE_WRITE_ACCESS)
144 
145 #define IOCTL_MIDI_CACHE_PATCHES \
146   MIDI_CTL_CODE(0x0008, METHOD_BUFFERED, FILE_WRITE_ACCESS)
147 
148 #define IOCTL_MIDI_CACHE_DRUM_PATCHES \
149   MIDI_CTL_CODE(0x0009, METHOD_BUFFERED, FILE_WRITE_ACCESS)
150 
151 #if DBG
152 /* Debug-only control code */
153 #define IOCTL_MIDI_SET_DEBUG_LEVEL \
154   WAVE_CTL_CODE(0x0040, METHOD_BUFFERED, FILE_READ_ACCESS)
155 #endif
156 
157 /*
158     Mixer device control codes
159 */
160 
161 #define IOCTL_MIX_GET_CONFIGURATION \
162   MIX_CTL_CODE(0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
163 
164 #define IOCTL_MIX_GET_CONTROL_DATA \
165   MIX_CTL_CODE(0x0002, METHOD_BUFFERED, FILE_READ_ACCESS)
166 
167 #define IOCTL_MIX_GET_LINE_DATA \
168   MIX_CTL_CODE(0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
169 
170 #define IOCTL_MIX_REQUEST_NOTIFY \
171   MIX_CTL_CODE(0x0004, METHOD_BUFFERED, FILE_READ_ACCESS)
172 
173 /*
174     Auxiliary device control codes
175 */
176 
177 #define IOCTL_AUX_GET_CAPABILITIES \
178   AUX_CTL_CODE(0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
179 
180 #define IOCTL_AUX_SET_VOLUME \
181   AUX_CTL_CODE(0x0002, METHOD_BUFFERED, FILE_READ_ACCESS)
182 
183 #define IOCTL_AUX_GET_VOLUME \
184   AUX_CTL_CODE(0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
185 
186 #define IOCTL_SOUND_GET_CHANGED_VOLUME \
187   AUX_CTL_CODE(0x0004, METHOD_BUFFERED, FILE_READ_ACCESS)
188 
189 /*
190     Wave structures & states
191 */
192 
193 #define WAVE_DD_MAX_VOLUME      0xFFFFFFFF
194 
195 typedef struct _WAVE_DD_VOLUME {
196   ULONG Left;
197   ULONG Right;
198 } WAVE_DD_VOLUME, *PWAVE_DD_VOLUME;
199 
200 typedef struct _WAVE_DD_PITCH {
201   ULONG Pitch;
202 } WAVE_DD_PITCH, *PWAVE_DD_PITCH;
203 
204 typedef struct _WAVE_DD_PLAYBACK_RATE {
205   ULONG Rate;
206 } WAVE_DD_PLAYBACK_RATE, *PWAVE_DD_PLAYBACK_RATE;
207 
208 /* IOCTL_WAVE_SET_STATE commands */
209 #define WAVE_DD_STOP        0x0001
210 #define WAVE_DD_PLAY        0x0002
211 #define WAVE_DD_RECORD      0x0003
212 #define WAVE_DD_RESET       0x0004
213 
214 /* IOCTL_WAVE_GET_STATE responses */
215 #define WAVE_DD_IDLE        0x0000
216 #define WAVE_DD_STOPPED     0x0001
217 #define WAVE_DD_PLAYING     0x0002
218 #define WAVE_DD_RECORDING   0x0003
219 
220 /*
221     MIDI structures & states
222 */
223 
224 typedef struct _MIDI_DD_INPUT_DATA {
225   LARGE_INTEGER Time;
226   UCHAR Data[sizeof(ULONG)];
227 } MIDI_DD_INPUT_DATA, *PMIDI_DD_INPUT_DATA;
228 
229 typedef struct _MIDI_DD_VOLUME {
230   ULONG Left;
231   ULONG Right;
232 } MIDI_DD_VOLUME, *PMIDI_DD_VOLUME;
233 
234 typedef struct _MIDI_DD_CACHE_PATCHES {
235   ULONG Bank;
236   ULONG Flags;
237   ULONG Patches[128];
238 } MIDI_DD_CACHE_PATCHES, *PMIDI_DD_CACHE_PATCHES;
239 
240 typedef struct _MIDI_DD_CACHE_DRUM_PATCHES {
241   ULONG Patch;
242   ULONG Flags;
243   ULONG DrumPatches[128];
244 } MIDI_DD_CACHE_DRUM_PATCHES, *PMIDI_DD_CACHE_DRUM_PATCHES;
245 
246 /* IOCTL_MIDI_SET_STATE commands */
247 #define MIDI_DD_STOP        0x0001
248 #define MIDI_DD_PLAY        0x0002
249 #define MIDI_DD_RECORD      0x0003
250 #define MIDI_DD_RESET       0x0004
251 
252 /* IOCTL_MIDI_GET_STATE responses */
253 #define MIDI_DD_IDLE        0x0000
254 #define MIDI_DD_STOPPED     0x0001
255 #define MIDI_DD_PLAYING     0x0002
256 #define MIDI_DD_RECORDING   0x0003
257 
258 /*
259     Mixer structures
260     TODO: This is incomplete (see NTDDMIX.H in NT4 DDK)
261 */
262 
263 typedef struct _MIXER_DD_READ_DATA {
264   ULONG Id;
265 } MIXER_DD_READ_DATA, *PMIXER_DD_READ_DATA;
266 
267 typedef struct _MIXER_DD_LINE_DATA {
268   ULONG fdwLine;
269 } MIXER_DD_LINE_DATA, *PMIXER_DD_LINE_DATA;
270 
271 /*
272     Auxiliary structures
273 */
274 
275 #define AUX_DD_MAX_VOLUME   0xFFFFFFFF
276 
277 typedef struct _AUX_DD_VOLUME {
278   ULONG Left;
279   ULONG Right;
280 } AUX_DD_VOLUME, *PAUX_DD_VOLUME;
281 
282 
283 #endif /* NTDDSND_H */
284