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