ReactOS  0.4.15-dev-494-g1d8c567
usbaudio.h
Go to the documentation of this file.
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 #define DEFINE_KSPROPERTY_ITEM_AUDIO_VOLUME(Handler)\
39  DEFINE_KSPROPERTY_ITEM(\
40  KSPROPERTY_AUDIO_VOLUMELEVEL,\
41  (Handler),\
42  sizeof(KSNODEPROPERTY_AUDIO_CHANNEL),\
43  sizeof(LONG),\
44  (Handler), NULL, 0, NULL, NULL, 0)
45 
46 
47 #define DEFINE_KSPROPERTY_TABLE_AUDIO_VOLUME(TopologySet, Handler)\
48 DEFINE_KSPROPERTY_TABLE(TopologySet) {\
49  DEFINE_KSPROPERTY_ITEM_AUDIO_VOLUME(Handler)\
50 }
51 
52 #define DEFINE_KSPROPERTY_ITEM_AUDIO_MUTE(Handler)\
53  DEFINE_KSPROPERTY_ITEM(\
54  KSPROPERTY_AUDIO_MUTE,\
55  (Handler),\
56  sizeof(KSNODEPROPERTY_AUDIO_CHANNEL),\
57  sizeof(BOOL),\
58  (Handler), NULL, 0, NULL, NULL, 0)
59 
60 #define DEFINE_KSPROPERTY_TABLE_AUDIO_MUTE(TopologySet, Handler)\
61 DEFINE_KSPROPERTY_TABLE(TopologySet) {\
62  DEFINE_KSPROPERTY_ITEM_AUDIO_MUTE(Handler)\
63 }
64 
65 #include <pshpack1.h>
66 
67 typedef struct
68 {
77 
78 typedef struct
79 {
89 
90 
91 typedef struct
92 {
104 
105 typedef struct
106 {
113  UCHAR bmaControls[1];
116 
117 typedef struct
118 {
124  UCHAR baSourceID[1];
131 
132 typedef struct
133 {
139  UCHAR baSourceID[1];
142 
143 
144 typedef struct
145 {
153 
154 typedef struct
155 {
164  UCHAR tSamFreq[1];
166 
167 #include <poppack.h>
168 
169 typedef struct
170 {
173  ULONG Nodes[20];
175 
176 typedef struct __DEVICE_EXTENSION__
177 {
178  PDEVICE_OBJECT LowerDevice; /* lower device*/
179  PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; /* usb configuration descriptor */
180  PUSB_DEVICE_DESCRIPTOR DeviceDescriptor; /* usb device descriptor */
181  PUSBD_INTERFACE_INFORMATION InterfaceInfo; /* interface information */
182  USBD_CONFIGURATION_HANDLE ConfigurationHandle; /* configuration handle */
183  PNODE_CONTEXT NodeContext; /* node context */
184  ULONG NodeContextCount; /* node context count */
186 
187 typedef struct
188 {
189  PDEVICE_EXTENSION DeviceExtension; /* device extension */
190  PDEVICE_OBJECT LowerDevice; /* lower device*/
191 
193 
194 typedef struct
195 {
196  PDEVICE_EXTENSION DeviceExtension; /* device extension */
197  PDEVICE_OBJECT LowerDevice; /* lower device*/
198  LIST_ENTRY IrpListHead; /* irp list*/
199  LIST_ENTRY DoneIrpListHead; /* irp done list head */
200  KSPIN_LOCK IrpListLock; /* irp list lock*/
201  PUCHAR Buffer; /* iso buffer*/
202  ULONG BufferSize; /* iso buffer size */
203  ULONG BufferOffset; /* buffer offset */
204  ULONG BufferLength; /* remaining render bytes */
205  PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor; /* interface descriptor */
207  PKSWORKER CaptureWorker; /* capture worker */
209  PKSWORKER StarvationWorker; /* capture worker */
211 
212 /* filter.c */
213 
214 NTSTATUS
215 NTAPI
217  PKSDEVICE Device);
218 
221  IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
222  IN ULONG Index);
223 
224 /* pool.c */
225 PVOID
226 NTAPI
228  IN ULONG ItemSize);
229 
230 VOID
231 NTAPI
233  IN PVOID Item);
234 
235 VOID
236 NTAPI
238  IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
239  OUT PULONG NonStreamingTerminalDescriptorCount,
240  OUT PULONG TotalTerminalDescriptorCount);
241 
242 /* usbaudio.c */
243 
244 NTSTATUS
247  IN PURB Urb);
248 
249 NTSTATUS
250 NTAPI
252  _In_ PKSDEVICE Device
253 );
254 
255 NTSTATUS
256 NTAPI
258  _In_ PKSDEVICE Device,
259  _In_ PIRP Irp,
260  _In_opt_ PCM_RESOURCE_LIST TranslatedResourceList,
261  _In_opt_ PCM_RESOURCE_LIST UntranslatedResourceList
262 );
263 
264 NTSTATUS
265 NTAPI
267  _In_ PKSDEVICE Device,
268  _In_ PIRP Irp
269 );
270 
271 VOID
272 NTAPI
274  _In_ PKSDEVICE Device,
275  _In_ PIRP Irp
276 );
277 
278 VOID
279 NTAPI
281  _In_ PKSDEVICE Device,
282  _In_ PIRP Irp
283 );
284 
285 NTSTATUS
286 NTAPI
288  _In_ PKSDEVICE Device,
289  _In_ PIRP Irp
290 );
291 
292 VOID
293 NTAPI
295  _In_ PKSDEVICE Device,
296  _In_ PIRP Irp
297 );
298 
299 VOID
300 NTAPI
302  _In_ PKSDEVICE Device,
303  _In_ PIRP Irp
304 );
305 
306 NTSTATUS
307 NTAPI
309  _In_ PKSDEVICE Device,
310  _In_ PIRP Irp,
312 );
313 
314 VOID
315 NTAPI
317  _In_ PKSDEVICE Device,
318  _In_ PIRP Irp
319 );
320 
321 NTSTATUS
322 NTAPI
324  _In_ PKSDEVICE Device,
325  _In_ PIRP Irp,
326  _In_ DEVICE_POWER_STATE DeviceTo,
327  _In_ DEVICE_POWER_STATE DeviceFrom,
328  _In_ SYSTEM_POWER_STATE SystemTo,
329  _In_ SYSTEM_POWER_STATE SystemFrom,
331 );
332 
333 VOID
334 NTAPI
336  _In_ PKSDEVICE Device,
337  _In_ PIRP Irp,
340 );
341 
342 /* pin.c*/
343 
344 NTSTATUS
345 NTAPI
348  _In_ PIRP Irp,
349  _In_ PKSP_PIN Pin,
350  _In_ PKSDATARANGE DataRange,
351  _In_ PKSDATARANGE MatchingDataRange,
352  _In_ ULONG DataBufferSize,
353  _Out_ PVOID Data,
355 
356 NTSTATUS
357 NTAPI
360  IN PIRP Irp,
361  IN PVOID Context);
362 
363 NTSTATUS
364 NTAPI
367  IN PIRP Irp,
368  IN PVOID Context);
369 
370 NTSTATUS
371 NTAPI
373  _In_ PKSPIN Pin,
374  _In_ PIRP Irp);
375 
376 NTSTATUS
377 NTAPI
379  _In_ PKSPIN Pin,
380  _In_ PIRP Irp);
381 
382 NTSTATUS
383 NTAPI
385  _In_ PKSPIN Pin);
386 
387 VOID
388 NTAPI
390  _In_ PKSPIN Pin);
391 
392 NTSTATUS
393 NTAPI
395  _In_ PKSPIN Pin,
396  _In_opt_ PKSDATAFORMAT OldFormat,
397  _In_opt_ PKSMULTIPLE_ITEM OldAttributeList,
398  _In_ const KSDATARANGE* DataRange,
399  _In_opt_ const KSATTRIBUTE_LIST* AttributeRange);
400 
401 NTSTATUS
402 NTAPI
404  _In_ PKSPIN Pin,
405  _In_ KSSTATE ToState,
406  _In_ KSSTATE FromState);
407 
VOID NTAPI CountTerminalUnits(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, OUT PULONG NonStreamingTerminalDescriptorCount, OUT PULONG TotalTerminalDescriptorCount)
Definition: filter.c:970
#define IN
Definition: typedefs.h:39
struct USB_AUDIO_CONTROL_SELECTOR_UNIT_DESCRIPTOR * PUSB_AUDIO_CONTROL_SELECTOR_UNIT_DESCRIPTOR
NTSTATUS NTAPI USBAudioPinProcess(_In_ PKSPIN Pin)
Definition: pin.c:1270
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2029
PKSWORKER CaptureWorker
Definition: usbaudio.h:207
PNODE_CONTEXT NodeContext
Definition: usbaudio.h:183
NTSTATUS NTAPI UsbAudioCaptureComplete(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: pin.c:909
_In_ PIRP Irp
Definition: csq.h:116
PDEVICE_OBJECT LowerDevice
Definition: usbaudio.h:197
struct USB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR * PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR
NTSTATUS NTAPI USBAudioPnPQueryPower(_In_ PKSDEVICE Device, _In_ PIRP Irp, _In_ DEVICE_POWER_STATE DeviceTo, _In_ DEVICE_POWER_STATE DeviceFrom, _In_ SYSTEM_POWER_STATE SystemTo, _In_ SYSTEM_POWER_STATE SystemFrom, _In_ POWER_ACTION Action)
Definition: usbaudio.c:418
struct USB_AUDIO_STREAMING_FORMAT_TYPE_DESCRIPTOR * PUSB_AUDIO_STREAMING_FORMAT_TYPE_DESCRIPTOR
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
struct __DEVICE_EXTENSION__ * PDEVICE_EXTENSION
struct USB_AUDIO_CONTROL_FEATURE_UNIT_DESCRIPTOR * PUSB_AUDIO_CONTROL_FEATURE_UNIT_DESCRIPTOR
VOID NTAPI USBAudioPinReset(_In_ PKSPIN Pin)
Definition: pin.c:1290
PVOID NTAPI AllocFunction(IN ULONG ItemSize)
Definition: hid.c:45
VOID NTAPI USBAudioPnPSetPower(_In_ PKSDEVICE Device, _In_ PIRP Irp, _In_ DEVICE_POWER_STATE To, _In_ DEVICE_POWER_STATE From)
Definition: usbaudio.c:433
ULONG BufferOffset
Definition: usbaudio.h:203
PUCHAR Buffer
Definition: usbaudio.h:201
NTSTATUS NTAPI USBAudioPinCreate(_In_ PKSPIN Pin, _In_ PIRP Irp)
Definition: pin.c:764
PDEVICE_OBJECT LowerDevice
Definition: usbaudio.h:178
enum _SYSTEM_POWER_STATE SYSTEM_POWER_STATE
PDEVICE_EXTENSION DeviceExtension
Definition: usbaudio.h:196
#define _In_opt_
Definition: no_sal2.h:213
VOID NTAPI USBAudioPnPRemove(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:386
PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR UsbAudioGetStreamingTerminalDescriptorByIndex(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, IN ULONG Index)
Definition: filter.c:1063
LIST_ENTRY IrpListHead
Definition: usbaudio.h:198
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
struct NODE_CONTEXT * PNODE_CONTEXT
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
NTSTATUS SubmitUrbSync(IN PDEVICE_OBJECT Device, IN PURB Urb)
Definition: usbaudio.c:37
NTSTATUS NTAPI USBAudioPinClose(_In_ PKSPIN Pin, _In_ PIRP Irp)
Definition: pin.c:843
WORK_QUEUE_ITEM CaptureWorkItem
Definition: usbaudio.h:206
#define _Out_
Definition: no_sal2.h:323
struct FILTER_CONTEXT * PFILTER_CONTEXT
ULONG BufferSize
Definition: usbaudio.h:202
struct USB_AUDIO_CONTROL_MIXER_UNIT_DESCRIPTOR * PUSB_AUDIO_CONTROL_MIXER_UNIT_DESCRIPTOR
VOID NTAPI USBAudioPnPSurpriseRemoval(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:408
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
Definition: ks.h:642
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:424
PDEVICE_OBJECT LowerDevice
Definition: usbaudio.h:190
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: usbaudio.h:205
PUSB_COMMON_DESCRIPTOR Descriptor
Definition: usbaudio.h:171
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG Action
Definition: fsrtlfuncs.h:738
NTSTATUS NTAPI USBAudioPnPQueryCapabilities(_In_ PKSDEVICE Device, _In_ PIRP Irp, _Inout_ PDEVICE_CAPABILITIES Capabilities)
Definition: usbaudio.c:396
NTSTATUS NTAPI USBAudioPnPQueryRemove(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:366
VOID NTAPI USBAudioPnPCancelStop(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:347
NTSTATUS NTAPI USBAudioAddDevice(_In_ PKSDEVICE Device)
Definition: usbaudio.c:287
static const UCHAR Index[8]
Definition: usbohci.c:18
NTSTATUS NTAPI UsbAudioPinDataIntersect(_In_ PVOID Context, _In_ PIRP Irp, _In_ PKSP_PIN Pin, _In_ PKSDATARANGE DataRange, _In_ PKSDATARANGE MatchingDataRange, _In_ ULONG DataBufferSize, _Out_ PVOID Data, _Out_ PULONG DataSize)
Definition: pin.c:1416
VOID NTAPI FreeFunction(IN PVOID Item)
Definition: hid.c:53
#define _Inout_
Definition: no_sal2.h:244
NTSTATUS NTAPI USBAudioPinSetDataFormat(_In_ PKSPIN Pin, _In_opt_ PKSDATAFORMAT OldFormat, _In_opt_ PKSMULTIPLE_ITEM OldAttributeList, _In_ const KSDATARANGE *DataRange, _In_opt_ const KSATTRIBUTE_LIST *AttributeRange)
Definition: pin.c:1298
struct USB_AUDIO_CONTROL_OUTPUT_TERMINAL_DESCRIPTOR * PUSB_AUDIO_CONTROL_OUTPUT_TERMINAL_DESCRIPTOR
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID NTAPI USBAudioPnPStop(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:356
POWER_ACTION
Definition: ntpoapi.h:122
NTSTATUS NTAPI USBAudioPinSetDeviceState(_In_ PKSPIN Pin, _In_ KSSTATE ToState, _In_ KSSTATE FromState)
Definition: pin.c:1392
NTSTATUS NTAPI USBAudioCreateFilterContext(PKSDEVICE Device)
Definition: filter.c:1525
struct PIN_CONTEXT * PPIN_CONTEXT
Definition: typedefs.h:118
ULONG NodeCount
Definition: usbaudio.h:172
static UCHAR ItemSize[4]
Definition: parser.c:16
ULONG BufferLength
Definition: usbaudio.h:204
* PDEVICE_CAPABILITIES
Definition: iotypes.h:930
NTSTATUS NTAPI USBAudioPnPQueryStop(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:337
#define _In_
Definition: no_sal2.h:204
struct USB_AUDIO_CONTROL_INTERFACE_HEADER_DESCRIPTOR * PUSB_AUDIO_CONTROL_INTERFACE_HEADER_DESCRIPTOR
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
KSSTATE
Definition: ks.h:1214
Definition: usb.h:529
unsigned short USHORT
Definition: pedump.c:61
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
NTSTATUS NTAPI UsbAudioRenderComplete(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: pin.c:853
USBD_CONFIGURATION_HANDLE ConfigurationHandle
Definition: usbaudio.h:182
PUSB_DEVICE_DESCRIPTOR DeviceDescriptor
Definition: usbaudio.h:180
unsigned int * PULONG
Definition: retypes.h:1
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
Definition: usbaudio.h:179
PKSWORKER StarvationWorker
Definition: usbaudio.h:209
PDEVICE_EXTENSION DeviceExtension
Definition: usbaudio.h:189
WORK_QUEUE_ITEM StarvationWorkItem
Definition: usbaudio.h:208
struct USB_AUDIO_STREAMING_INTERFACE_DESCRIPTOR * PUSB_AUDIO_STREAMING_INTERFACE_DESCRIPTOR
#define OUT
Definition: typedefs.h:40
struct __DEVICE_EXTENSION__ DEVICE_EXTENSION
KSPIN_LOCK IrpListLock
Definition: usbaudio.h:200
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI USBAudioPnPStart(_In_ PKSDEVICE Device, _In_ PIRP Irp, _In_opt_ PCM_RESOURCE_LIST TranslatedResourceList, _In_opt_ PCM_RESOURCE_LIST UntranslatedResourceList)
Definition: usbaudio.c:297
PUSBD_INTERFACE_INFORMATION InterfaceInfo
Definition: usbaudio.h:181
LIST_ENTRY DoneIrpListHead
Definition: usbaudio.h:199
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751
VOID NTAPI USBAudioPnPCancelRemove(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:377