[USBAUDIO]
[reactos.git] / reactos / drivers / usb / usbaudio / usbaudio.h
1 #pragma once
2
3 #include <ntddk.h>
4 #include <portcls.h>
5 #include <ksmedia.h>
6 #include <hubbusif.h>
7 #include <usbbusif.h>
8 #include <usbioctl.h>
9 #include <usb.h>
10 #include <usbdlib.h>
11 #include <debug.h>
12
13 #define USBAUDIO_TAG 'AbsU'
14 #define USB_AUDIO_CONTROL_TERMINAL_DESCRIPTOR_TYPE (0x24)
15
16 /* Universal Serial Bus Device Class Definition for Terminal Types Section 2.2 */
17 #define USB_AUDIO_STREAMING_TERMINAL_TYPE (0x0101)
18
19 #define USB_AUDIO_MICROPHONE_TERMINAL_TYPE (0x0201)
20 #define USB_AUDIO_DESKTOP_MICROPHONE_TERMINAL_TYPE (0x0202)
21 #define USB_AUDIO_PERSONAL_MICROPHONE_TERMINAL_TYPE (0x0203)
22 #define USB_AUDIO_OMMNI_MICROPHONE_TERMINAL_TYPE (0x0204)
23 #define USB_AUDIO_ARRAY_MICROPHONE_TERMINAL_TYPE (0x0205)
24 #define USB_AUDIO_ARRAY_PROCESSING_MICROPHONE_TERMINAL_TYPE (0x0206)
25
26 #define USB_AUDIO_SPEAKER_TERMINAL_TYPE (0x0301)
27 #define USB_HEADPHONES_SPEAKER_TERMINAL_TYPE (0x0302)
28 #define USB_AUDIO_HMDA_TERMINAL_TYPE (0x0303)
29 #define USB_AUDIO_DESKTOP_SPEAKER_TERMINAL_TYPE (0x0304)
30 #define USB_AUDIO_ROOM_SPEAKER_TERMINAL_TYPE (0x0305)
31 #define USB_AUDIO_COMMUNICATION_SPEAKER_TERMINAL_TYPE (0x0306)
32 #define USB_AUDIO_SUBWOOFER_TERMINAL_TYPE (0x0307)
33 #define USB_AUDIO_UNDEFINED_TERMINAL_TYPE (0xFFFF)
34
35 #define USB_AUDIO_INPUT_TERMINAL (0x02)
36 #define USB_AUDIO_OUTPUT_TERMINAL (0x03)
37
38 #include <pshpack1.h>
39
40 typedef struct
41 {
42 UCHAR bLength;
43 UCHAR bDescriptorType;
44 UCHAR bDescriptorSubtype;
45 USHORT bcdADC;
46 USHORT wTotalLength;
47 UCHAR bInCollection;
48 UCHAR baInterfaceNr;
49 }USB_AUDIO_CONTROL_INTERFACE_HEADER_DESCRIPTOR, *PUSB_AUDIO_CONTROL_INTERFACE_HEADER_DESCRIPTOR;
50
51 typedef struct
52 {
53 UCHAR bLength;
54 UCHAR bDescriptorType;
55 UCHAR bDescriptorSubtype;
56 UCHAR bTerminalID;
57 USHORT wTerminalType;
58 UCHAR bAssocTerminal;
59 UCHAR bSourceID;
60 UCHAR iTerminal;
61 }USB_AUDIO_CONTROL_OUTPUT_TERMINAL_DESCRIPTOR, *PUSB_AUDIO_CONTROL_OUTPUT_TERMINAL_DESCRIPTOR;
62
63
64 typedef struct
65 {
66 UCHAR bLength;
67 UCHAR bDescriptorType;
68 UCHAR bDescriptorSubtype;
69 UCHAR bTerminalID;
70 USHORT wTerminalType;
71 UCHAR bAssocTerminal;
72 UCHAR bNrChannels;
73 USHORT wChannelConfig;
74 UCHAR iChannelNames;
75 UCHAR iTerminal;
76 }USB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR, *PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR;
77
78 typedef struct
79 {
80 UCHAR bLength;
81 UCHAR bDescriptorType;
82 UCHAR bDescriptorSubtype;
83 UCHAR bTerminalLink;
84 UCHAR bDelay;
85 USHORT wFormatTag;
86 }USB_AUDIO_STREAMING_INTERFACE_DESCRIPTOR, *PUSB_AUDIO_STREAMING_INTERFACE_DESCRIPTOR;
87
88 typedef struct
89 {
90 UCHAR bLength;
91 UCHAR bDescriptorType;
92 UCHAR bDescriptorSubtype;
93 UCHAR bFormatType;
94 UCHAR bNrChannels;
95 UCHAR bSubframeSize;
96 UCHAR bBitResolution;
97 UCHAR bSamFreqType;
98 UCHAR tSamFreq[1];
99 }USB_AUDIO_STREAMING_FORMAT_TYPE_DESCRIPTOR, *PUSB_AUDIO_STREAMING_FORMAT_TYPE_DESCRIPTOR;
100
101 #include <poppack.h>
102
103 typedef struct __DEVICE_EXTENSION__
104 {
105 PDEVICE_OBJECT LowerDevice; /* lower device*/
106 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; /* usb configuration descriptor */
107 PUSB_DEVICE_DESCRIPTOR DeviceDescriptor; /* usb device descriptor */
108 PUSBD_INTERFACE_INFORMATION InterfaceInfo; /* interface information */
109 USBD_CONFIGURATION_HANDLE ConfigurationHandle; /* configuration handle */
110
111 }DEVICE_EXTENSION, *PDEVICE_EXTENSION;
112
113 typedef struct
114 {
115 PDEVICE_EXTENSION DeviceExtension; /* device extension */
116 PDEVICE_OBJECT LowerDevice; /* lower device*/
117
118 }FILTER_CONTEXT, *PFILTER_CONTEXT;
119
120 typedef struct
121 {
122 PDEVICE_EXTENSION DeviceExtension; /* device extension */
123 PDEVICE_OBJECT LowerDevice; /* lower device*/
124 LIST_ENTRY IrpListHead; /* irp list*/
125 LIST_ENTRY DoneIrpListHead; /* irp done list head */
126 KSPIN_LOCK IrpListLock; /* irp list lock*/
127 PUCHAR Buffer; /* iso buffer*/
128 ULONG BufferSize; /* iso buffer size */
129 PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor; /* interface descriptor */
130
131 }PIN_CONTEXT, *PPIN_CONTEXT;
132
133 /* filter.c */
134
135 NTSTATUS
136 NTAPI
137 USBAudioCreateFilterContext(
138 PKSDEVICE Device);
139
140 /* pool.c */
141 PVOID
142 NTAPI
143 AllocFunction(
144 IN ULONG ItemSize);
145
146 VOID
147 NTAPI
148 FreeFunction(
149 IN PVOID Item);
150
151 /* usbaudio.c */
152
153 NTSTATUS
154 SubmitUrbSync(
155 IN PDEVICE_OBJECT Device,
156 IN PURB Urb);
157
158 NTSTATUS
159 NTAPI
160 USBAudioAddDevice(
161 _In_ PKSDEVICE Device
162 );
163
164 NTSTATUS
165 NTAPI
166 USBAudioPnPStart(
167 _In_ PKSDEVICE Device,
168 _In_ PIRP Irp,
169 _In_opt_ PCM_RESOURCE_LIST TranslatedResourceList,
170 _In_opt_ PCM_RESOURCE_LIST UntranslatedResourceList
171 );
172
173 NTSTATUS
174 NTAPI
175 USBAudioPnPQueryStop(
176 _In_ PKSDEVICE Device,
177 _In_ PIRP Irp
178 );
179
180 VOID
181 NTAPI
182 USBAudioPnPCancelStop(
183 _In_ PKSDEVICE Device,
184 _In_ PIRP Irp
185 );
186
187 VOID
188 NTAPI
189 USBAudioPnPStop(
190 _In_ PKSDEVICE Device,
191 _In_ PIRP Irp
192 );
193
194 NTSTATUS
195 NTAPI
196 USBAudioPnPQueryRemove(
197 _In_ PKSDEVICE Device,
198 _In_ PIRP Irp
199 );
200
201 VOID
202 NTAPI
203 USBAudioPnPCancelRemove(
204 _In_ PKSDEVICE Device,
205 _In_ PIRP Irp
206 );
207
208 VOID
209 NTAPI
210 USBAudioPnPRemove(
211 _In_ PKSDEVICE Device,
212 _In_ PIRP Irp
213 );
214
215 NTSTATUS
216 NTAPI
217 USBAudioPnPQueryCapabilities(
218 _In_ PKSDEVICE Device,
219 _In_ PIRP Irp,
220 _Inout_ PDEVICE_CAPABILITIES Capabilities
221 );
222
223 VOID
224 NTAPI
225 USBAudioPnPSurpriseRemoval(
226 _In_ PKSDEVICE Device,
227 _In_ PIRP Irp
228 );
229
230 NTSTATUS
231 NTAPI
232 USBAudioPnPQueryPower(
233 _In_ PKSDEVICE Device,
234 _In_ PIRP Irp,
235 _In_ DEVICE_POWER_STATE DeviceTo,
236 _In_ DEVICE_POWER_STATE DeviceFrom,
237 _In_ SYSTEM_POWER_STATE SystemTo,
238 _In_ SYSTEM_POWER_STATE SystemFrom,
239 _In_ POWER_ACTION Action
240 );
241
242 VOID
243 NTAPI
244 USBAudioPnPSetPower(
245 _In_ PKSDEVICE Device,
246 _In_ PIRP Irp,
247 _In_ DEVICE_POWER_STATE To,
248 _In_ DEVICE_POWER_STATE From
249 );
250
251 /* pin.c*/
252
253 NTSTATUS
254 NTAPI
255 USBAudioPinCreate(
256 _In_ PKSPIN Pin,
257 _In_ PIRP Irp);
258
259 NTSTATUS
260 NTAPI
261 USBAudioPinClose(
262 _In_ PKSPIN Pin,
263 _In_ PIRP Irp);
264
265 NTSTATUS
266 NTAPI
267 USBAudioPinProcess(
268 _In_ PKSPIN Pin);
269
270 VOID
271 NTAPI
272 USBAudioPinReset(
273 _In_ PKSPIN Pin);
274
275 NTSTATUS
276 NTAPI
277 USBAudioPinSetDataFormat(
278 _In_ PKSPIN Pin,
279 _In_opt_ PKSDATAFORMAT OldFormat,
280 _In_opt_ PKSMULTIPLE_ITEM OldAttributeList,
281 _In_ const KSDATARANGE* DataRange,
282 _In_opt_ const KSATTRIBUTE_LIST* AttributeRange);
283
284 NTSTATUS
285 NTAPI
286 USBAudioPinSetDeviceState(
287 _In_ PKSPIN Pin,
288 _In_ KSSTATE ToState,
289 _In_ KSSTATE FromState);
290