Author: janderwald
Date: Tue Sep 27 19:20:00 2016
New Revision: 72832
URL:
http://svn.reactos.org/svn/reactos?rev=72832&view=rev
Log:
[USBAUDIO]
- implement USBAudioFilterCreate
- partly implement USBAudioPinCreate, USBAudioPinSetDataFormat
Modified:
trunk/reactos/drivers/usb/usbaudio/filter.c
trunk/reactos/drivers/usb/usbaudio/guid.c
trunk/reactos/drivers/usb/usbaudio/pin.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] Tue Sep 27 19:20:00 2016
@@ -107,7 +107,38 @@
PKSFILTER Filter,
PIRP Irp)
{
- UNIMPLEMENTED
+ PKSFILTERFACTORY FilterFactory;
+ PKSDEVICE Device;
+ PFILTER_CONTEXT FilterContext;
+
+ FilterFactory = KsGetParent(Filter);
+ if (FilterFactory == NULL)
+ {
+ /* invalid parameter */
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ Device = KsGetParent(FilterFactory);
+ if (Device == NULL)
+ {
+ /* invalid parameter */
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* alloc filter context */
+ FilterContext = AllocFunction(sizeof(FILTER_CONTEXT));
+ if (FilterContext == NULL)
+ {
+ /* no memory */
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* init context */
+ FilterContext->DeviceExtension = Device->Context;
+ FilterContext->LowerDevice = Device->NextDeviceObject;
+ Filter->Context = FilterContext;
+
+ KsAddItemToObjectBag(Filter->Bag, FilterContext, ExFreePool);
return STATUS_SUCCESS;
}
Modified: trunk/reactos/drivers/usb/usbaudio/guid.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbaudio/guid.…
==============================================================================
--- trunk/reactos/drivers/usb/usbaudio/guid.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbaudio/guid.c [iso-8859-1] Tue Sep 27 19:20:00 2016
@@ -1,9 +1,8 @@
/* DO NOT USE THE PRECOMPILED HEADER FOR THIS FILE! */
//#include <wdm.h>
+#include <initguid.h>
#include <portcls.h>
-
-#include <initguid.h>
#include <wdmguid.h>
#include <ksmedia.h>
#include <hubbusif.h>
Modified: trunk/reactos/drivers/usb/usbaudio/pin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbaudio/pin.c…
==============================================================================
--- trunk/reactos/drivers/usb/usbaudio/pin.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbaudio/pin.c [iso-8859-1] Tue Sep 27 19:20:00 2016
@@ -9,13 +9,45 @@
#include "usbaudio.h"
+GUID GUID2_KSDATAFORMAT_TYPE_AUDIO = { STATIC_KSDATAFORMAT_TYPE_AUDIO };
+GUID GUID2_KSDATAFORMAT_SUBTYPE_PCM = { STATIC_KSDATAFORMAT_SUBTYPE_PCM };
+GUID GUID2_KSDATAFORMAT_SPECIFIER_WAVEFORMATEX = {
STATIC_KSDATAFORMAT_SPECIFIER_WAVEFORMATEX };
+
NTSTATUS
NTAPI
USBAudioPinCreate(
_In_ PKSPIN Pin,
_In_ PIRP Irp)
{
- UNIMPLEMENTED
+ PKSFILTER Filter;
+ PFILTER_CONTEXT FilterContext;
+ PPIN_CONTEXT PinContext;
+
+ Filter = KsPinGetParentFilter(Pin);
+ if (Filter == NULL)
+ {
+ /* invalid parameter */
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* get filter context */
+ FilterContext = Filter->Context;
+
+ /* allocate pin context */
+ PinContext = AllocFunction(sizeof(PIN_CONTEXT));
+ if (!PinContext)
+ {
+ /* no memory*/
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* init pin context */
+ PinContext->DeviceExtension = FilterContext->DeviceExtension;
+ PinContext->LowerDevice = FilterContext->LowerDevice;
+
+ /* store pin context*/
+ Pin->Context = PinContext;
+
return STATUS_SUCCESS;
}
@@ -57,10 +89,71 @@
_In_ const KSDATARANGE* DataRange,
_In_opt_ const KSATTRIBUTE_LIST* AttributeRange)
{
- UNIMPLEMENTED
- return STATUS_SUCCESS;
+ PURB Urb;
+ PUCHAR SampleRateBuffer;
+ PPIN_CONTEXT PinContext;
+ NTSTATUS Status;
+ PKSDATAFORMAT_WAVEFORMATEX WaveFormatEx;
+
+ /* allocate sample rate buffer */
+ SampleRateBuffer = AllocFunction(sizeof(ULONG));
+ if (!SampleRateBuffer)
+ {
+ /* no memory */
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ if (IsEqualGUIDAligned(&Pin->ConnectionFormat->MajorFormat,
&GUID2_KSDATAFORMAT_TYPE_AUDIO) &&
+ IsEqualGUIDAligned(&Pin->ConnectionFormat->SubFormat,
&GUID2_KSDATAFORMAT_SUBTYPE_PCM) &&
+ IsEqualGUIDAligned(&Pin->ConnectionFormat->Specifier,
&GUID2_KSDATAFORMAT_SPECIFIER_WAVEFORMATEX))
+ {
+ WaveFormatEx = (PKSDATAFORMAT_WAVEFORMATEX)Pin->ConnectionFormat;
+ SampleRateBuffer[0] = (WaveFormatEx->WaveFormatEx.nSamplesPerSec >> 16)
& 0xFF;
+ SampleRateBuffer[1] = (WaveFormatEx->WaveFormatEx.nSamplesPerSec >> 8)
& 0xFF;
+ SampleRateBuffer[2] = (WaveFormatEx->WaveFormatEx.nSamplesPerSec >> 0)
& 0xFF;
+ }
+ else
+ {
+ /* not supported yet*/
+ UNIMPLEMENTED;
+ FreeFunction(SampleRateBuffer);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* allocate urb */
+ Urb = AllocFunction(sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));
+ if (!Urb)
+ {
+ /* no memory */
+ FreeFunction(SampleRateBuffer);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* format urb */
+ UsbBuildVendorRequest(Urb,
+ URB_FUNCTION_CLASS_ENDPOINT,
+ sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST),
+ USBD_TRANSFER_DIRECTION_OUT,
+ 0,
+ 0x01,
+ 0x100,
+ 0x81, //bEndpointAddress
+ SampleRateBuffer,
+ NULL,
+ 3,
+ NULL);
+
+ /* get pin context */
+ PinContext = Pin->Context;
+ DbgBreakPoint();
+ /* submit urb */
+ Status = SubmitUrbSync(PinContext->LowerDevice, Urb);
+
+ DPRINT1("USBAudioPinSetDataFormat Pin %p Status %x\n", Pin, Status);
+ FreeFunction(Urb);
+ FreeFunction(SampleRateBuffer);
+ return Status;
}
-
NTSTATUS
NTAPI
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] Tue Sep 27 19:20:00 2016
@@ -34,27 +34,12 @@
};
NTSTATUS
-NTAPI
-USBAudioCancelCompleteSynch(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- /* signal event */
- KeSetEvent(Context, 0, FALSE);
-
- /* done */
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-NTSTATUS
SubmitUrbSync(
- IN PKSDEVICE Device,
+ IN PDEVICE_OBJECT DeviceObject,
IN PURB Urb)
{
PIRP Irp;
KEVENT Event;
- PDEVICE_EXTENSION DeviceExtension;
IO_STATUS_BLOCK IoStatus;
PIO_STACK_LOCATION IoStack;
NTSTATUS Status;
@@ -62,12 +47,9 @@
// init event
KeInitializeEvent(&Event, NotificationEvent, FALSE);
- // get device extension
- DeviceExtension = (PDEVICE_EXTENSION)Device->Context;
-
// build irp
Irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_SUBMIT_URB,
- DeviceExtension->LowerDevice,
+ DeviceObject,
NULL,
0,
NULL,
@@ -90,11 +72,8 @@
// store urb
IoStack->Parameters.Others.Argument1 = Urb;
- // set completion routine
- IoSetCompletionRoutine(Irp, USBAudioCancelCompleteSynch, &Event, TRUE, TRUE,
TRUE);
-
// call driver
- Status = IoCallDriver(DeviceExtension->LowerDevice, Irp);
+ Status = IoCallDriver(DeviceObject, Irp);
// wait for the request to finish
if (Status == STATUS_PENDING)
@@ -169,8 +148,11 @@
return STATUS_INSUFFICIENT_RESOURCES;
}
+ /* device extension */
+ DeviceExtension = Device->Context;
+
/* submit configuration urb */
- Status = SubmitUrbSync(Device, Urb);
+ Status = SubmitUrbSync(DeviceExtension->LowerDevice, Urb);
if (!NT_SUCCESS(Status))
{
/* free resources */
@@ -180,7 +162,6 @@
}
/* store configuration handle */
- DeviceExtension = Device->Context;
DeviceExtension->ConfigurationHandle =
Urb->UrbSelectConfiguration.ConfigurationHandle;
/* alloc interface info */
@@ -205,6 +186,9 @@
NTSTATUS Status;
ULONG Length;
+ /* get device extension */
+ DeviceExtension = Device->Context;
+
/* allocate urb */
Urb = AllocFunction(sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST));
if (!Urb)
@@ -226,7 +210,7 @@
UsbBuildGetDescriptorRequest(Urb, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
USB_DEVICE_DESCRIPTOR_TYPE, 0, 0, DeviceDescriptor, NULL, sizeof(USB_DEVICE_DESCRIPTOR),
NULL);
/* submit urb */
- Status = SubmitUrbSync(Device, Urb);
+ Status = SubmitUrbSync(DeviceExtension->LowerDevice, Urb);
if (!NT_SUCCESS(Status))
{
/* free resources */
@@ -249,7 +233,7 @@
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);
+ Status = SubmitUrbSync(DeviceExtension->LowerDevice, Urb);
if (!NT_SUCCESS(Status))
{
/* free resources */
@@ -279,7 +263,7 @@
UsbBuildGetDescriptorRequest(Urb, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
USB_CONFIGURATION_DESCRIPTOR_TYPE, 0, 0, ConfigurationDescriptor, NULL, Length, NULL);
/* submit urb */
- Status = SubmitUrbSync(Device, Urb);
+ Status = SubmitUrbSync(DeviceExtension->LowerDevice, Urb);
/* free urb */
FreeFunction(Urb);
@@ -298,7 +282,7 @@
Status = USBAudioSelectConfiguration(Device, ConfigurationDescriptor);
if (NT_SUCCESS(Status))
{
- DeviceExtension = Device->Context;
+
DeviceExtension->ConfigurationDescriptor = ConfigurationDescriptor;
DeviceExtension->DeviceDescriptor = DeviceDescriptor;
}
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] Tue Sep 27 19:20:00 2016
@@ -110,6 +110,20 @@
}DEVICE_EXTENSION, *PDEVICE_EXTENSION;
+typedef struct
+{
+ PDEVICE_EXTENSION DeviceExtension; /* device extension */
+ PDEVICE_OBJECT LowerDevice; /* lower device*/
+
+}FILTER_CONTEXT, *PFILTER_CONTEXT;
+
+typedef struct
+{
+ PDEVICE_EXTENSION DeviceExtension; /* device extension */
+ PDEVICE_OBJECT LowerDevice; /* lower device*/
+
+}PIN_CONTEXT, *PPIN_CONTEXT;
+
/* filter.c */
NTSTATUS
@@ -129,6 +143,11 @@
IN PVOID Item);
/* usbaudio.c */
+
+NTSTATUS
+SubmitUrbSync(
+ IN PDEVICE_OBJECT Device,
+ IN PURB Urb);
NTSTATUS
NTAPI