ReactOS 0.4.15-dev-8102-g108db8f
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)\
48DEFINE_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)\
61DEFINE_KSPROPERTY_TABLE(TopologySet) {\
62 DEFINE_KSPROPERTY_ITEM_AUDIO_MUTE(Handler)\
63}
64
65#include <pshpack1.h>
66
67typedef struct
68{
77
78typedef struct
79{
89
90
91typedef struct
92{
104
105typedef struct
106{
113 UCHAR bmaControls[1];
116
117typedef struct
118{
124 UCHAR baSourceID[1];
131
132typedef struct
133{
139 UCHAR baSourceID[1];
142
143
144typedef struct
145{
153
154typedef struct
155{
164 UCHAR tSamFreq[1];
166
167#include <poppack.h>
168
169typedef struct
170{
173 ULONG Nodes[20];
175
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 */
183 PNODE_CONTEXT NodeContext; /* node context */
184 ULONG NodeContextCount; /* node context count */
186
187typedef struct
188{
189 PDEVICE_EXTENSION DeviceExtension; /* device extension */
190 PDEVICE_OBJECT LowerDevice; /* lower device*/
191
193
194typedef 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 */
207 PKSWORKER CaptureWorker; /* capture worker */
209 PKSWORKER StarvationWorker; /* capture worker */
211
212/* filter.c */
213
215NTAPI
217 PKSDEVICE Device);
218
221 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
222 IN ULONG Index);
223
224/* pool.c */
225PVOID
226NTAPI
229
230VOID
231NTAPI
233 IN PVOID Item);
234
235VOID
236NTAPI
238 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
239 OUT PULONG NonStreamingTerminalDescriptorCount,
240 OUT PULONG TotalTerminalDescriptorCount);
241
242/* usbaudio.c */
243
247 IN PURB Urb);
248
250NTAPI
252 _In_ PKSDEVICE Device
253);
254
256NTAPI
258 _In_ PKSDEVICE Device,
259 _In_ PIRP Irp,
260 _In_opt_ PCM_RESOURCE_LIST TranslatedResourceList,
261 _In_opt_ PCM_RESOURCE_LIST UntranslatedResourceList
262);
263
265NTAPI
267 _In_ PKSDEVICE Device,
269);
270
271VOID
272NTAPI
274 _In_ PKSDEVICE Device,
276);
277
278VOID
279NTAPI
281 _In_ PKSDEVICE Device,
283);
284
286NTAPI
288 _In_ PKSDEVICE Device,
290);
291
292VOID
293NTAPI
295 _In_ PKSDEVICE Device,
297);
298
299VOID
300NTAPI
302 _In_ PKSDEVICE Device,
304);
305
307NTAPI
309 _In_ PKSDEVICE Device,
310 _In_ PIRP Irp,
312);
313
314VOID
315NTAPI
317 _In_ PKSDEVICE Device,
319);
320
322NTAPI
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
333VOID
334NTAPI
336 _In_ PKSDEVICE Device,
337 _In_ PIRP Irp,
340);
341
342/* pin.c*/
343
345NTAPI
348 _In_ PIRP Irp,
350 _In_ PKSDATARANGE DataRange,
351 _In_ PKSDATARANGE MatchingDataRange,
352 _In_ ULONG DataBufferSize,
355
357NTAPI
360 IN PIRP Irp,
362
364NTAPI
367 IN PIRP Irp,
369
371NTAPI
373 _In_ PKSPIN Pin,
374 _In_ PIRP Irp);
375
377NTAPI
379 _In_ PKSPIN Pin,
380 _In_ PIRP Irp);
381
383NTAPI
385 _In_ PKSPIN Pin);
386
387VOID
388NTAPI
390 _In_ PKSPIN Pin);
391
393NTAPI
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
402NTAPI
404 _In_ PKSPIN Pin,
405 _In_ KSSTATE ToState,
406 _In_ KSSTATE FromState);
407
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:427
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
KSSTATE
Definition: ks.h:1214
#define _Inout_
Definition: ms_sal.h:378
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
POWER_ACTION
Definition: ntpoapi.h:122
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
enum _SYSTEM_POWER_STATE SYSTEM_POWER_STATE
unsigned short USHORT
Definition: pedump.c:61
static UCHAR ItemSize[4]
Definition: parser.c:16
PDEVICE_OBJECT LowerDevice
Definition: usbaudio.h:190
PDEVICE_EXTENSION DeviceExtension
Definition: usbaudio.h:189
Definition: ks.h:642
ULONG NodeCount
Definition: usbaudio.h:172
PUSB_COMMON_DESCRIPTOR Descriptor
Definition: usbaudio.h:171
WORK_QUEUE_ITEM StarvationWorkItem
Definition: usbaudio.h:208
ULONG BufferOffset
Definition: usbaudio.h:203
WORK_QUEUE_ITEM CaptureWorkItem
Definition: usbaudio.h:206
LIST_ENTRY IrpListHead
Definition: usbaudio.h:198
PKSWORKER StarvationWorker
Definition: usbaudio.h:209
ULONG BufferLength
Definition: usbaudio.h:204
PUCHAR Buffer
Definition: usbaudio.h:201
ULONG BufferSize
Definition: usbaudio.h:202
PKSWORKER CaptureWorker
Definition: usbaudio.h:207
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: usbaudio.h:205
PDEVICE_EXTENSION DeviceExtension
Definition: usbaudio.h:196
KSPIN_LOCK IrpListLock
Definition: usbaudio.h:200
PDEVICE_OBJECT LowerDevice
Definition: usbaudio.h:197
LIST_ENTRY DoneIrpListHead
Definition: usbaudio.h:199
Definition: typedefs.h:120
Definition: usb.h:529
PNODE_CONTEXT NodeContext
Definition: usbaudio.h:183
PUSBD_INTERFACE_INFORMATION InterfaceInfo
Definition: usbaudio.h:181
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
Definition: usbaudio.h:179
PUSB_DEVICE_DESCRIPTOR DeviceDescriptor
Definition: usbaudio.h:180
USBD_CONFIGURATION_HANDLE ConfigurationHandle
Definition: usbaudio.h:182
PDEVICE_OBJECT LowerDevice
Definition: usbaudio.h:178
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
NTSTATUS NTAPI USBAudioPinCreate(_In_ PKSPIN Pin, _In_ PIRP Irp)
Definition: pin.c:764
struct USB_AUDIO_CONTROL_OUTPUT_TERMINAL_DESCRIPTOR * PUSB_AUDIO_CONTROL_OUTPUT_TERMINAL_DESCRIPTOR
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
PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR UsbAudioGetStreamingTerminalDescriptorByIndex(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, IN ULONG Index)
Definition: filter.c:1063
VOID NTAPI CountTerminalUnits(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, OUT PULONG NonStreamingTerminalDescriptorCount, OUT PULONG TotalTerminalDescriptorCount)
Definition: filter.c:970
struct __DEVICE_EXTENSION__ DEVICE_EXTENSION
VOID NTAPI USBAudioPinReset(_In_ PKSPIN Pin)
Definition: pin.c:1290
struct USB_AUDIO_CONTROL_FEATURE_UNIT_DESCRIPTOR * PUSB_AUDIO_CONTROL_FEATURE_UNIT_DESCRIPTOR
struct FILTER_CONTEXT * PFILTER_CONTEXT
struct PIN_CONTEXT * PPIN_CONTEXT
NTSTATUS NTAPI USBAudioPnPQueryStop(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:337
NTSTATUS NTAPI USBAudioPnPQueryRemove(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:366
struct NODE_CONTEXT * PNODE_CONTEXT
struct __DEVICE_EXTENSION__ * PDEVICE_EXTENSION
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
VOID NTAPI USBAudioPnPStop(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:356
struct USB_AUDIO_CONTROL_SELECTOR_UNIT_DESCRIPTOR * PUSB_AUDIO_CONTROL_SELECTOR_UNIT_DESCRIPTOR
NTSTATUS SubmitUrbSync(IN PDEVICE_OBJECT Device, IN PURB Urb)
Definition: usbaudio.c:37
struct USB_AUDIO_CONTROL_INTERFACE_HEADER_DESCRIPTOR * PUSB_AUDIO_CONTROL_INTERFACE_HEADER_DESCRIPTOR
VOID NTAPI USBAudioPnPCancelRemove(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:377
NTSTATUS NTAPI USBAudioPinProcess(_In_ PKSPIN Pin)
Definition: pin.c:1270
NTSTATUS NTAPI USBAudioAddDevice(_In_ PKSDEVICE Device)
Definition: usbaudio.c:287
struct USB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR * PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR
NTSTATUS NTAPI UsbAudioCaptureComplete(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: pin.c:909
VOID NTAPI USBAudioPnPSurpriseRemoval(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:408
struct USB_AUDIO_CONTROL_MIXER_UNIT_DESCRIPTOR * PUSB_AUDIO_CONTROL_MIXER_UNIT_DESCRIPTOR
NTSTATUS NTAPI USBAudioPinClose(_In_ PKSPIN Pin, _In_ PIRP Irp)
Definition: pin.c:843
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
NTSTATUS NTAPI USBAudioCreateFilterContext(PKSDEVICE Device)
Definition: filter.c:1525
NTSTATUS NTAPI USBAudioPnPQueryCapabilities(_In_ PKSDEVICE Device, _In_ PIRP Irp, _Inout_ PDEVICE_CAPABILITIES Capabilities)
Definition: usbaudio.c:396
struct USB_AUDIO_STREAMING_FORMAT_TYPE_DESCRIPTOR * PUSB_AUDIO_STREAMING_FORMAT_TYPE_DESCRIPTOR
struct USB_AUDIO_STREAMING_INTERFACE_DESCRIPTOR * PUSB_AUDIO_STREAMING_INTERFACE_DESCRIPTOR
PVOID NTAPI AllocFunction(IN ULONG ItemSize)
Definition: hid.c:45
NTSTATUS NTAPI USBAudioPinSetDeviceState(_In_ PKSPIN Pin, _In_ KSSTATE ToState, _In_ KSSTATE FromState)
Definition: pin.c:1392
NTSTATUS NTAPI UsbAudioRenderComplete(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: pin.c:853
VOID NTAPI FreeFunction(IN PVOID Item)
Definition: hid.c:53
VOID NTAPI USBAudioPnPCancelStop(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:347
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
VOID NTAPI USBAudioPnPSetPower(_In_ PKSDEVICE Device, _In_ PIRP Irp, _In_ DEVICE_POWER_STATE To, _In_ DEVICE_POWER_STATE From)
Definition: usbaudio.c:433
VOID NTAPI USBAudioPnPRemove(_In_ PKSDEVICE Device, _In_ PIRP Irp)
Definition: usbaudio.c:386
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965
unsigned char UCHAR
Definition: xmlstorage.h:181