41daedef8cad0284ab7d771895c462b03c9dad6f
[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 PUCHAR Buffer; /* iso buffer*/
126 ULONG BufferSize; /* iso buffer size */
127 PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor; /* interface descriptor */
128
129 }PIN_CONTEXT, *PPIN_CONTEXT;
130
131 /* filter.c */
132
133 NTSTATUS
134 NTAPI
135 USBAudioCreateFilterContext(
136 PKSDEVICE Device);
137
138 /* pool.c */
139 PVOID
140 NTAPI
141 AllocFunction(
142 IN ULONG ItemSize);
143
144 VOID
145 NTAPI
146 FreeFunction(
147 IN PVOID Item);
148
149 /* usbaudio.c */
150
151 NTSTATUS
152 SubmitUrbSync(
153 IN PDEVICE_OBJECT Device,
154 IN PURB Urb);
155
156 NTSTATUS
157 NTAPI
158 USBAudioAddDevice(
159 _In_ PKSDEVICE Device
160 );
161
162 NTSTATUS
163 NTAPI
164 USBAudioPnPStart(
165 _In_ PKSDEVICE Device,
166 _In_ PIRP Irp,
167 _In_opt_ PCM_RESOURCE_LIST TranslatedResourceList,
168 _In_opt_ PCM_RESOURCE_LIST UntranslatedResourceList
169 );
170
171 NTSTATUS
172 NTAPI
173 USBAudioPnPQueryStop(
174 _In_ PKSDEVICE Device,
175 _In_ PIRP Irp
176 );
177
178 VOID
179 NTAPI
180 USBAudioPnPCancelStop(
181 _In_ PKSDEVICE Device,
182 _In_ PIRP Irp
183 );
184
185 VOID
186 NTAPI
187 USBAudioPnPStop(
188 _In_ PKSDEVICE Device,
189 _In_ PIRP Irp
190 );
191
192 NTSTATUS
193 NTAPI
194 USBAudioPnPQueryRemove(
195 _In_ PKSDEVICE Device,
196 _In_ PIRP Irp
197 );
198
199 VOID
200 NTAPI
201 USBAudioPnPCancelRemove(
202 _In_ PKSDEVICE Device,
203 _In_ PIRP Irp
204 );
205
206 VOID
207 NTAPI
208 USBAudioPnPRemove(
209 _In_ PKSDEVICE Device,
210 _In_ PIRP Irp
211 );
212
213 NTSTATUS
214 NTAPI
215 USBAudioPnPQueryCapabilities(
216 _In_ PKSDEVICE Device,
217 _In_ PIRP Irp,
218 _Inout_ PDEVICE_CAPABILITIES Capabilities
219 );
220
221 VOID
222 NTAPI
223 USBAudioPnPSurpriseRemoval(
224 _In_ PKSDEVICE Device,
225 _In_ PIRP Irp
226 );
227
228 NTSTATUS
229 NTAPI
230 USBAudioPnPQueryPower(
231 _In_ PKSDEVICE Device,
232 _In_ PIRP Irp,
233 _In_ DEVICE_POWER_STATE DeviceTo,
234 _In_ DEVICE_POWER_STATE DeviceFrom,
235 _In_ SYSTEM_POWER_STATE SystemTo,
236 _In_ SYSTEM_POWER_STATE SystemFrom,
237 _In_ POWER_ACTION Action
238 );
239
240 VOID
241 NTAPI
242 USBAudioPnPSetPower(
243 _In_ PKSDEVICE Device,
244 _In_ PIRP Irp,
245 _In_ DEVICE_POWER_STATE To,
246 _In_ DEVICE_POWER_STATE From
247 );
248
249 /* pin.c*/
250
251 NTSTATUS
252 NTAPI
253 USBAudioPinCreate(
254 _In_ PKSPIN Pin,
255 _In_ PIRP Irp);
256
257 NTSTATUS
258 NTAPI
259 USBAudioPinClose(
260 _In_ PKSPIN Pin,
261 _In_ PIRP Irp);
262
263 NTSTATUS
264 NTAPI
265 USBAudioPinProcess(
266 _In_ PKSPIN Pin);
267
268 VOID
269 NTAPI
270 USBAudioPinReset(
271 _In_ PKSPIN Pin);
272
273 NTSTATUS
274 NTAPI
275 USBAudioPinSetDataFormat(
276 _In_ PKSPIN Pin,
277 _In_opt_ PKSDATAFORMAT OldFormat,
278 _In_opt_ PKSMULTIPLE_ITEM OldAttributeList,
279 _In_ const KSDATARANGE* DataRange,
280 _In_opt_ const KSATTRIBUTE_LIST* AttributeRange);
281
282 NTSTATUS
283 NTAPI
284 USBAudioPinSetDeviceState(
285 _In_ PKSPIN Pin,
286 _In_ KSSTATE ToState,
287 _In_ KSSTATE FromState);
288