Author: janderwald
Date: Mon Sep 19 18:40:44 2016
New Revision: 72744
URL:
http://svn.reactos.org/svn/reactos?rev=72744&view=rev
Log:
[USBAUDIO]
- fix minor bugs
- start implementing filter context
Modified:
trunk/reactos/drivers/usb/usbaudio/filter.c
trunk/reactos/drivers/usb/usbaudio/usbaudio.c
trunk/reactos/drivers/usb/usbaudio/usbaudio.h
Modified: trunk/reactos/drivers/usb/usbaudio/filter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbaudio/filte…
==============================================================================
--- trunk/reactos/drivers/usb/usbaudio/filter.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbaudio/filter.c [iso-8859-1] Mon Sep 19 18:40:44 2016
@@ -15,6 +15,53 @@
{
UNIMPLEMENTED
return STATUS_NOT_IMPLEMENTED;
+}
+
+VOID
+CountTerminalUnits(
+ IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
+ OUT PULONG NonStreamingTerminalDescriptorCount,
+ OUT PULONG TotalTerminalDescriptorCount)
+{
+ PUSB_INTERFACE_DESCRIPTOR Descriptor;
+ PUSB_AUDIO_CONTROL_INTERFACE_HEADER_DESCRIPTOR InterfaceHeaderDescriptor;
+ PUSB_COMMON_DESCRIPTOR CommonDescriptor;
+ PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR InputTerminalDescriptor;
+ ULONG NonStreamingTerminalCount = 0;
+ ULONG TotalTerminalCount = 0;
+
+ for(Descriptor = USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor,
ConfigurationDescriptor, -1, -1, USB_DEVICE_CLASS_AUDIO, -1, -1);
+ Descriptor != NULL;
+ Descriptor = USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor,
(PVOID)((ULONG_PTR)Descriptor + Descriptor->bLength), -1, -1, USB_DEVICE_CLASS_AUDIO,
-1, -1))
+ {
+ if (Descriptor->bInterfaceSubClass == 0x01) /* AUDIO_CONTROL */
+ {
+ InterfaceHeaderDescriptor = USBD_ParseDescriptors(ConfigurationDescriptor,
ConfigurationDescriptor->wTotalLength, Descriptor,
USB_AUDIO_CONTROL_TERMINAL_DESCRIPTOR_TYPE);
+ if (InterfaceHeaderDescriptor != NULL)
+ {
+ CommonDescriptor = USBD_ParseDescriptors(InterfaceHeaderDescriptor,
InterfaceHeaderDescriptor->wTotalLength, (PVOID)((ULONG_PTR)InterfaceHeaderDescriptor +
InterfaceHeaderDescriptor->bLength), USB_AUDIO_CONTROL_TERMINAL_DESCRIPTOR_TYPE);
+ while (CommonDescriptor)
+ {
+ InputTerminalDescriptor =
(PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR)CommonDescriptor;
+ if (InputTerminalDescriptor->bDescriptorSubtype == 0x02 /* INPUT
TERMINAL*/ || InputTerminalDescriptor->bDescriptorSubtype == 0x03 /*
OUTPUT_TERMINAL*/)
+ {
+ if (InputTerminalDescriptor->wTerminalType !=
USB_AUDIO_STREAMING_TERMINAL_TYPE)
+ {
+ NonStreamingTerminalCount++;
+ }
+ TotalTerminalCount++;
+ }
+ }
+ }
+ }
+ else if (Descriptor->bInterfaceSubClass == 0x03) /* MIDI_STREAMING */
+ {
+ UNIMPLEMENTED
+ }
+ }
+ *NonStreamingTerminalDescriptorCount = NonStreamingTerminalCount;
+ *TotalTerminalDescriptorCount = TotalTerminalCount;
+
}
NTSTATUS
@@ -41,6 +88,7 @@
INIT_USBAUDIO_MID(&ComponentId->Manufacturer,
DeviceExtension->DeviceDescriptor->idVendor);
INIT_USBAUDIO_PID(&ComponentId->Product,
DeviceExtension->DeviceDescriptor->idProduct);
+ UNIMPLEMENTED
return STATUS_NOT_IMPLEMENTED;
}
@@ -66,14 +114,14 @@
if (!ComponentId)
{
/* no memory */
- return USBD_STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INSUFFICIENT_RESOURCES;
}
Status = USBAudioInitComponentId(Device, ComponentId);
if (!NT_SUCCESS(Status))
{
/* failed*/
- FreeFunction(ComponentId);
- return Status;
+ //FreeFunction(ComponentId);
+ //return Status;
}
FilterDescriptor.ComponentId = ComponentId;
Modified: trunk/reactos/drivers/usb/usbaudio/usbaudio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbaudio/usbau…
==============================================================================
--- trunk/reactos/drivers/usb/usbaudio/usbaudio.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbaudio/usbaudio.c [iso-8859-1] Mon Sep 19 18:40:44 2016
@@ -246,7 +246,7 @@
}
/* build descriptor request */
- UsbBuildGetDescriptorRequest(Urb, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
USB_DEVICE_DESCRIPTOR_TYPE, 0, 0, ConfigurationDescriptor, NULL,
sizeof(USB_CONFIGURATION_DESCRIPTOR), NULL);
+ UsbBuildGetDescriptorRequest(Urb, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
USB_CONFIGURATION_DESCRIPTOR_TYPE, 0, 0, ConfigurationDescriptor, NULL,
sizeof(USB_CONFIGURATION_DESCRIPTOR), NULL);
/* submit urb */
Status = SubmitUrbSync(Device, Urb);
@@ -276,7 +276,7 @@
}
/* build descriptor request */
- UsbBuildGetDescriptorRequest(Urb, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
USB_DEVICE_DESCRIPTOR_TYPE, 0, 0, ConfigurationDescriptor, NULL, Length, NULL);
+ UsbBuildGetDescriptorRequest(Urb, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
USB_CONFIGURATION_DESCRIPTOR_TYPE, 0, 0, ConfigurationDescriptor, NULL, Length, NULL);
/* submit urb */
Status = SubmitUrbSync(Device, Urb);
@@ -349,7 +349,7 @@
if (NT_SUCCESS(Status))
{
/* TODO build filter topology and pin descriptors and retrieve interface */
- UNIMPLEMENTED
+ Status = USBAudioCreateFilterContext(Device);
}
}
Modified: trunk/reactos/drivers/usb/usbaudio/usbaudio.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbaudio/usbau…
==============================================================================
--- trunk/reactos/drivers/usb/usbaudio/usbaudio.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbaudio/usbaudio.h [iso-8859-1] Mon Sep 19 18:40:44 2016
@@ -11,6 +11,68 @@
#include <debug.h>
#define USBAUDIO_TAG 'AbsU'
+#define USB_AUDIO_CONTROL_TERMINAL_DESCRIPTOR_TYPE (0x24)
+
+/* Universal Serial Bus Device Class Definition for Terminal Types Section 2.2 */
+#define USB_AUDIO_STREAMING_TERMINAL_TYPE (0x0101)
+
+#define USB_AUDIO_MICROPHONE_TERMINAL_TYPE (0x0201)
+#define USB_AUDIO_DESKTOP_MICROPHONE_TERMINAL_TYPE (0x0202)
+#define USB_AUDIO_PERSONAL_MICROPHONE_TERMINAL_TYPE (0x0203)
+#define USB_AUDIO_OMMNI_MICROPHONE_TERMINAL_TYPE (0x0204)
+#define USB_AUDIO_ARRAY_MICROPHONE_TERMINAL_TYPE (0x0205)
+#define USB_AUDIO_ARRAY_PROCESSING_MICROPHONE_TERMINAL_TYPE (0x0206)
+
+#define USB_AUDIO_SPEAKER_TERMINAL_TYPE (0x0301)
+#define USB_HEADPHONES_SPEAKER_TERMINAL_TYPE (0x0302)
+#define USB_AUDIO_HMDA_TERMINAL_TYPE (0x0303)
+#define USB_AUDIO_DESKTOP_SPEAKER_TERMINAL_TYPE (0x0304)
+#define USB_AUDIO_ROOM_SPEAKER_TERMINAL_TYPE (0x0305)
+#define USB_AUDIO_COMMUNICATION_SPEAKER_TERMINAL_TYPE (0x0306)
+#define USB_AUDIO_SUBWOOFER_TERMINAL_TYPE (0x0307)
+#define USB_AUDIO_UNDEFINED_TERMINAL_TYPE (0xFFFF)
+
+
+#include <pshpack1.h>
+
+typedef struct
+{
+ UCHAR bLength;
+ UCHAR bDescriptorType;
+ UCHAR bDescriptorSubtype;
+ USHORT bcdADC;
+ USHORT wTotalLength;
+ UCHAR bInCollection;
+ UCHAR baInterfaceNr;
+}USB_AUDIO_CONTROL_INTERFACE_HEADER_DESCRIPTOR,
*PUSB_AUDIO_CONTROL_INTERFACE_HEADER_DESCRIPTOR;
+
+typedef struct
+{
+ UCHAR bLength;
+ UCHAR bDescriptorType;
+ UCHAR bDescriptorSubtype;
+ UCHAR bTerminalID;
+ USHORT wTerminalType;
+ UCHAR bAssocTerminal;
+ UCHAR bSourceID;
+ UCHAR iTerminal;
+}USB_AUDIO_CONTROL_OUTPUT_TERMINAL_DESCRIPTOR,
*PUSB_AUDIO_CONTROL_OUTPUT_TERMINAL_DESCRIPTOR;
+
+
+typedef struct
+{
+ UCHAR bLength;
+ UCHAR bDescriptorType;
+ UCHAR bDescriptorSubtype;
+ UCHAR bTerminalID;
+ USHORT wTerminalType;
+ UCHAR bAssocTerminal;
+ UCHAR bNrChannels;
+ USHORT wChannelConfig;
+ UCHAR iChannelNames;
+ UCHAR iTerminal;
+}USB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR,
*PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR;
+#include <poppack.h>
typedef struct __DEVICE_EXTENSION__
{
@@ -21,6 +83,13 @@
USBD_CONFIGURATION_HANDLE ConfigurationHandle; /* configuration handle
*/
}DEVICE_EXTENSION, *PDEVICE_EXTENSION;
+
+/* filter.c */
+
+NTSTATUS
+NTAPI
+USBAudioCreateFilterContext(
+ PKSDEVICE Device);
/* pool.c */
PVOID