Author: janderwald
Date: Wed Jul 1 18:44:31 2009
New Revision: 41725
URL:
http://svn.reactos.org/svn/reactos?rev=41725&view=rev
Log:
- Partly Implement StreamClassReadWriteConfig
- Allocate a HwInstance buffer which is passed to each instantiated filter instance
Modified:
trunk/reactos/drivers/wdm/audio/legacy/stream/driver.c
trunk/reactos/drivers/wdm/audio/legacy/stream/filter.c
trunk/reactos/drivers/wdm/audio/legacy/stream/stream.spec
Modified: trunk/reactos/drivers/wdm/audio/legacy/stream/driver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/s…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/stream/driver.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/stream/driver.c [iso-8859-1] Wed Jul 1
18:44:31 2009
@@ -290,6 +290,7 @@
IN PVOID HwDeviceExtension)
{
PSTREAM_DEVICE_EXTENSION DeviceExtension;
+
/* Get our DeviceExtension */
DeviceExtension = (PSTREAM_DEVICE_EXTENSION) ((ULONG_PTR)HwDeviceExtension -
sizeof(STREAM_DEVICE_EXTENSION));
ASSERT(DeviceExtension->DeviceExtension == HwDeviceExtension);
@@ -297,3 +298,97 @@
return DeviceExtension->DmaCommonBuffer;
}
+NTSTATUS
+NTAPI
+StreamClassRWCompletion(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ IN PVOID Context)
+{
+ PIO_STATUS_BLOCK IoStatusBlock = (PIO_STATUS_BLOCK)Context;
+
+ IoStatusBlock->Information = Irp->IoStatus.Information;
+ IoStatusBlock->Status = Irp->IoStatus.Status;
+
+ return STATUS_SUCCESS;
+}
+
+/*
+ *@implemented
+ */
+BOOLEAN
+STREAMAPI
+StreamClassReadWriteConfig(
+ IN PVOID HwDeviceExtension,
+ IN BOOLEAN Read,
+ IN PVOID Buffer,
+ IN ULONG OffSet,
+ IN ULONG Length)
+{
+ PIRP Irp;
+ ULONG MajorFunction;
+ KEVENT Event;
+ PSTREAM_DEVICE_EXTENSION DeviceExtension;
+ LARGE_INTEGER Offset;
+ IO_STATUS_BLOCK StatusBlock;
+ NTSTATUS Status;
+
+ /* Get our DeviceExtension */
+ DeviceExtension = (PSTREAM_DEVICE_EXTENSION) ((ULONG_PTR)HwDeviceExtension -
sizeof(STREAM_DEVICE_EXTENSION));
+ ASSERT(DeviceExtension->DeviceExtension == HwDeviceExtension);
+
+ if (Read)
+ {
+ /* Zero input buffer */
+ RtlZeroMemory(Buffer, Length);
+ }
+
+ /* Set request type */
+ MajorFunction = (Read ? IRP_MJ_READ : IRP_MJ_WRITE);
+
+ /* Initialize event */
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+ /* Set offset */
+ Offset.QuadPart = OffSet;
+
+ /* Pre-init status block */
+ StatusBlock.Status = STATUS_NOT_SUPPORTED;
+
+ /* Create Irp */
+ Irp = IoBuildSynchronousFsdRequest(MajorFunction,
+ DeviceExtension->LowerDeviceObject, /* Verify
*/
+ Buffer,
+ Length,
+ &Offset,
+ &Event,
+ &StatusBlock);
+
+ if (!Irp)
+ {
+ /* Failed to allocate memory */
+ return FALSE;
+ }
+
+ /* Setup a completion routine */
+ IoSetCompletionRoutine(Irp, StreamClassRWCompletion, (PVOID)&Event, TRUE, TRUE,
TRUE);
+
+ /* Call driver */
+ Status = IoCallDriver(DeviceExtension->LowerDeviceObject, Irp);
+
+ if (Status == STATUS_PENDING)
+ {
+ /* Request is pending, wait for result */
+ KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+ /* Fetch result */
+ Status = StatusBlock.Status;
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ return FALSE;
+ }
+
+ /* FIXME Handle Length != InputLength */
+ return TRUE;
+}
Modified: trunk/reactos/drivers/wdm/audio/legacy/stream/filter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/s…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/stream/filter.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/stream/filter.c [iso-8859-1] Wed Jul 1
18:44:31 2009
@@ -102,6 +102,7 @@
PKSOBJECT_CREATE_ITEM CreateItem;
PIO_STACK_LOCATION IoStack;
HW_STREAM_REQUEST_BLOCK_EXT RequestBlock;
+ PVOID HwInstanceExtension = NULL;
/* Get device extension */
DeviceExtension = (PSTREAM_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
@@ -119,11 +120,23 @@
{
/* driver supports more than one filter instance */
RtlZeroMemory(&RequestBlock, sizeof(HW_STREAM_REQUEST_BLOCK_EXT));
+
+ /* allocate instance extension */
+ HwInstanceExtension = ExAllocatePool(NonPagedPool,
DeviceExtension->DriverExtension->Data.FilterInstanceExtensionSize);
+ if (!HwInstanceExtension)
+ {
+ /* Not enough memory */
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Zero instance extension */
+ RtlZeroMemory(HwInstanceExtension,
DeviceExtension->DriverExtension->Data.FilterInstanceExtensionSize);
/* set up request block */
RequestBlock.Block.Command = SRB_OPEN_DEVICE_INSTANCE;
RequestBlock.Block.HwDeviceExtension = DeviceExtension->DeviceExtension;
RequestBlock.Block.Irp = Irp;
+ RequestBlock.Block.HwInstanceExtension = HwInstanceExtension;
KeInitializeEvent(&RequestBlock.Event, SynchronizationEvent, FALSE);
/*FIXME SYNCHRONIZATION */
@@ -139,6 +152,7 @@
if (!NT_SUCCESS(RequestBlock.Block.Status))
{
/* Resource is not available */
+ ExFreePool(HwInstanceExtension);
return RequestBlock.Block.Status;
}
}
@@ -162,8 +176,17 @@
{
/* Failed to create header */
ExFreePool(CreateItem);
+ if (HwInstanceExtension)
+ {
+ /* free instance buffer */
+ ExFreePool(HwInstanceExtension);
+ }
return Status;
}
+
+ /* Store instance buffer in file object context */
+ IoStack->FileObject->FsContext2 = HwInstanceExtension;
+
/* Increment total instance count */
InterlockedIncrement(&DeviceExtension->InstanceCount);
/* Return result */
Modified: trunk/reactos/drivers/wdm/audio/legacy/stream/stream.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/s…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/stream/stream.spec [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/stream/stream.spec [iso-8859-1] Wed Jul 1
18:44:31 2009
@@ -5,4 +5,5 @@
@ stdcall StreamClassDebugAssert(long long ptr long)
@ cdecl StreamClassDebugPrint (long str)
@ cdecl StreamClassDeviceNotification(long ptr)
-@ stdcall StreamClassGetDmaBuffer(ptr)
+@ stdcall StreamClassGetDmaBuffer(ptr)
+@ stdcall StreamClassReadWriteConfig(ptr long ptr long long)