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