2 * PROJECT: ReactOS Universal Audio Class Driver
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/usb/usbaudio/filter.c
5 * PURPOSE: USB Audio device driver.
7 * Johannes Anderwald (johannes.anderwald@reactos.org)
13 BuildUSBAudioFilterTopology(
17 return STATUS_NOT_IMPLEMENTED
;
22 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
,
23 OUT PULONG NonStreamingTerminalDescriptorCount
,
24 OUT PULONG TotalTerminalDescriptorCount
)
26 PUSB_INTERFACE_DESCRIPTOR Descriptor
;
27 PUSB_AUDIO_CONTROL_INTERFACE_HEADER_DESCRIPTOR InterfaceHeaderDescriptor
;
28 PUSB_COMMON_DESCRIPTOR CommonDescriptor
;
29 PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR InputTerminalDescriptor
;
30 ULONG NonStreamingTerminalCount
= 0;
31 ULONG TotalTerminalCount
= 0;
33 for(Descriptor
= USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor
, ConfigurationDescriptor
, -1, -1, USB_DEVICE_CLASS_AUDIO
, -1, -1);
35 Descriptor
= USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor
, (PVOID
)((ULONG_PTR
)Descriptor
+ Descriptor
->bLength
), -1, -1, USB_DEVICE_CLASS_AUDIO
, -1, -1))
37 if (Descriptor
->bInterfaceSubClass
== 0x01) /* AUDIO_CONTROL */
39 InterfaceHeaderDescriptor
= USBD_ParseDescriptors(ConfigurationDescriptor
, ConfigurationDescriptor
->wTotalLength
, Descriptor
, USB_AUDIO_CONTROL_TERMINAL_DESCRIPTOR_TYPE
);
40 if (InterfaceHeaderDescriptor
!= NULL
)
42 CommonDescriptor
= USBD_ParseDescriptors(InterfaceHeaderDescriptor
, InterfaceHeaderDescriptor
->wTotalLength
, (PVOID
)((ULONG_PTR
)InterfaceHeaderDescriptor
+ InterfaceHeaderDescriptor
->bLength
), USB_AUDIO_CONTROL_TERMINAL_DESCRIPTOR_TYPE
);
43 while (CommonDescriptor
)
45 InputTerminalDescriptor
= (PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR
)CommonDescriptor
;
46 if (InputTerminalDescriptor
->bDescriptorSubtype
== 0x02 /* INPUT TERMINAL*/ || InputTerminalDescriptor
->bDescriptorSubtype
== 0x03 /* OUTPUT_TERMINAL*/)
48 if (InputTerminalDescriptor
->wTerminalType
!= USB_AUDIO_STREAMING_TERMINAL_TYPE
)
50 NonStreamingTerminalCount
++;
57 else if (Descriptor
->bInterfaceSubClass
== 0x03) /* MIDI_STREAMING */
62 *NonStreamingTerminalDescriptorCount
= NonStreamingTerminalCount
;
63 *TotalTerminalDescriptorCount
= TotalTerminalCount
;
68 USBAudioPinBuildDescriptors(
70 PKSPIN_DESCRIPTOR_EX
*PinDescriptors
,
71 PULONG PinDescriptorsCount
,
72 PULONG PinDescriptorSize
)
75 return STATUS_NOT_IMPLEMENTED
;
79 USBAudioInitComponentId(
81 IN PKSCOMPONENTID ComponentId
)
83 PDEVICE_EXTENSION DeviceExtension
;
85 /* get device extension */
86 DeviceExtension
= Device
->Context
;
88 INIT_USBAUDIO_MID(&ComponentId
->Manufacturer
, DeviceExtension
->DeviceDescriptor
->idVendor
);
89 INIT_USBAUDIO_PID(&ComponentId
->Product
, DeviceExtension
->DeviceDescriptor
->idProduct
);
92 return STATUS_NOT_IMPLEMENTED
;
98 USBAudioCreateFilterContext(
101 KSFILTER_DESCRIPTOR FilterDescriptor
;
102 PKSCOMPONENTID ComponentId
;
105 /* clear filter descriptor */
106 RtlZeroMemory(&FilterDescriptor
, sizeof(KSFILTER_DESCRIPTOR
));
108 /* init filter descriptor*/
109 FilterDescriptor
.Version
= KSFILTER_DESCRIPTOR_VERSION
;
110 FilterDescriptor
.ReferenceGuid
= &KSNAME_Filter
;
112 /* init component id*/
113 ComponentId
= AllocFunction(sizeof(KSCOMPONENTID
));
117 return STATUS_INSUFFICIENT_RESOURCES
;
119 Status
= USBAudioInitComponentId(Device
, ComponentId
);
120 if (!NT_SUCCESS(Status
))
123 //FreeFunction(ComponentId);
126 FilterDescriptor
.ComponentId
= ComponentId
;
128 /* build pin descriptors */
129 Status
= USBAudioPinBuildDescriptors(Device
, (PKSPIN_DESCRIPTOR_EX
*)&FilterDescriptor
.PinDescriptors
, &FilterDescriptor
.PinDescriptorsCount
, &FilterDescriptor
.PinDescriptorSize
);
130 if (!NT_SUCCESS(Status
))
133 FreeFunction(ComponentId
);
138 Status
= BuildUSBAudioFilterTopology(Device
);
139 if (!NT_SUCCESS(Status
))
142 FreeFunction(ComponentId
);