Author: janderwald
Date: Sat Aug 22 00:46:18 2009
New Revision: 42837
URL:
http://svn.reactos.org/svn/reactos?rev=42837&view=rev
Log:
[KS]
- Store input buffer in Irp->AssociatedIrp.SystemBuffer
- Add check
[PORTCLS]
- Add support for DirectKs
Modified:
trunk/reactos/drivers/ksfilter/ks/api.c
trunk/reactos/drivers/ksfilter/ks/irp.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
trunk/reactos/drivers/wdm/audio/sysaudio/pin.c
Modified: trunk/reactos/drivers/ksfilter/ks/api.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/api.c?…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/api.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/api.c [iso-8859-1] Sat Aug 22 00:46:18 2009
@@ -1155,9 +1155,18 @@
}
- /* HACK */
+ /* Store Fileobject */
IoStack = IoGetNextIrpStackLocation(Irp);
IoStack->FileObject = FileObject;
+
+ if (IoControl == IOCTL_KS_WRITE_STREAM)
+ {
+ Irp->AssociatedIrp.SystemBuffer = OutBuffer;
+ }
+ else if (IoControl == IOCTL_KS_READ_STREAM)
+ {
+ Irp->AssociatedIrp.SystemBuffer = InBuffer;
+ }
IoSetCompletionRoutine(Irp, KspSynchronousIoControlDeviceCompletion,
(PVOID)&IoStatusBlock, TRUE, TRUE, TRUE);
Modified: trunk/reactos/drivers/ksfilter/ks/irp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/irp.c?…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/irp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/irp.c [iso-8859-1] Sat Aug 22 00:46:18 2009
@@ -1854,6 +1854,8 @@
DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
/* get device header */
DeviceHeader = DeviceExtension->DeviceHeader;
+
+ ASSERT(IoStack->FileObject);
/* get object header */
ObjectHeader = (PKSIOBJECT_HEADER) IoStack->FileObject->FsContext;
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c [iso-8859-1] Sat Aug 22
00:46:18 2009
@@ -118,24 +118,44 @@
IN PIRP Irp)
{
PKSSTREAM_HEADER Header;
- //PIO_STACK_LOCATION IoStack;
- IIrpQueueImpl * This = (IIrpQueueImpl*)iface;
-
-#if 0
+ NTSTATUS Status = STATUS_SUCCESS;
+ PIO_STACK_LOCATION IoStack;
+ IIrpQueueImpl * This = (IIrpQueueImpl*)iface;
+
/* get current irp stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
- ASSERT(IoStack->Parameters.DeviceIoControl.InputBufferLength >=
sizeof(KSSTREAM_HEADER));
-
- /* get stream header */
- Header = (KSSTREAM_HEADER*)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
-#else
- /* HACK get stream header */
- Header = (KSSTREAM_HEADER*)Buffer;
-
- /* HACK untill stream probing is ready */
+ if (!Buffer)
+ {
+ /* probe the stream irp */
+ Status = KsProbeStreamIrp(Irp, KSSTREAM_WRITE | KSPROBE_ALLOCATEMDL |
KSPROBE_PROBEANDLOCK | KSPROBE_ALLOWFORMATCHANGE | KSPROBE_SYSTEMADDRESS, 0);
+
+ /* check for success */
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("KsProbeStreamIrp failed with %x\n", Status);
+ return Status;
+ }
+
+ /* get the stream header */
+ Header = (PKSSTREAM_HEADER)Irp->AssociatedIrp.SystemBuffer;
+ ASSERT(Header);
+ ASSERT(Irp->MdlAddress);
+
+ if (Irp->RequestorMode != KernelMode)
+ {
+ /* use allocated mdl */
+ Header->Data = MmGetSystemAddressForMdlSafe(Irp->MdlAddress,
NormalPagePriority);
+ }
+ }
+ else
+ {
+ /* HACK */
+ Header = (PKSSTREAM_HEADER)Buffer;
+ }
+
+ /* HACK */
Irp->Tail.Overlay.DriverContext[2] = (PVOID)Header;
-#endif
/* sanity check */
ASSERT(Header);
@@ -156,7 +176,7 @@
KsAddIrpToCancelableQueue(&This->IrpList, &This->IrpListLock, Irp,
KsListEntryTail, NULL);
/* done */
- return STATUS_SUCCESS;
+ return Status;
}
NTSTATUS
@@ -281,10 +301,10 @@
This->Irp->IoStatus.Information = StreamHeader->FrameExtent;
/* free stream data, no tag as wdmaud.drv does it atm */
- ExFreePool(StreamHeader->Data);
+ //ExFreePool(StreamHeader->Data);
/* free stream header, no tag as wdmaud.drv allocates it atm */
- ExFreePool(StreamHeader);
+ //ExFreePool(StreamHeader);
/* complete the request */
IoCompleteRequest(This->Irp, IO_SOUND_INCREMENT);
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c [iso-8859-1]
(original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.c [iso-8859-1] Sat Aug
22 00:46:18 2009
@@ -640,15 +640,7 @@
Status = This->IrpQueue->lpVtbl->AddMapping(This->IrpQueue, NULL, 0,
Irp);
- /* check if pin is in run state */
- if (This->State != KSSTATE_RUN)
- {
- /* HACK set pin into run state if caller forgot it */
- SetStreamState(This, KSSTATE_RUN);
- DPRINT1("Starting stream with %lu mappings Status %x\n",
This->IrpQueue->lpVtbl->NumMappings(This->IrpQueue), Status);
- }
-
- return Status;
+ return STATUS_PENDING;
}
/*
@@ -911,7 +903,7 @@
OUT PIO_STATUS_BLOCK StatusBlock,
IN PDEVICE_OBJECT DeviceObject)
{
- return FALSE;
+ return KsDispatchFastIoDeviceControlFailure(FileObject, Wait, InputBuffer,
InputBufferLength, OutputBuffer, OutputBufferLength, IoControlCode, StatusBlock,
DeviceObject);
}
/*
Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/w…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] Sat Aug 22
00:46:18 2009
@@ -1105,8 +1105,8 @@
/* now build the irp */
LowerIrp = IoBuildAsynchronousFsdRequest (IRP_MJ_WRITE,
IoGetRelatedDeviceObject(FileObject),
- Packet,
- sizeof(KSSTREAM_HEADER),
+ Packet,
+ sizeof(KSSTREAM_HEADER),
&Offset,
NULL);
@@ -1120,6 +1120,12 @@
return SetIrpIoStatus(Irp, STATUS_INSUFFICIENT_RESOURCES, 0);
}
+ /* get next stack location */
+ IoStack = IoGetNextIrpStackLocation(LowerIrp);
+
+ /* attach file object */
+ IoStack->FileObject = FileObject;
+
/* set a completion routine */
IoSetCompletionRoutine(LowerIrp, WdmAudWriteCompletion, (PVOID)Irp, TRUE, TRUE,
TRUE);
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/pin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/sysaudio/pin.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/sysaudio/pin.c [iso-8859-1] Sat Aug 22 00:46:18 2009
@@ -129,6 +129,7 @@
PDISPATCH_CONTEXT Context;
PIO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
+ PVOID Buffer;
NTSTATUS Status;
ULONG BytesReturned;
@@ -159,14 +160,25 @@
return Status;
}
+ Buffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
+
+ if (!Buffer)
+ {
+ /* insufficient resources */
+ Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
+ /* Complete the irp */
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+
/* call the portcls audio pin */
Status = KsSynchronousIoControlDevice(FileObject, KernelMode, IOCTL_KS_WRITE_STREAM,
- Irp->UserBuffer,
- IoStack->Parameters.Write.Length,
NULL,
0,
+ Buffer,
+ IoStack->Parameters.Write.Length,
&BytesReturned);
-
/* Release file object */
ObDereferenceObject(FileObject);
@@ -329,9 +341,6 @@
PIO_STATUS_BLOCK IoStatus,
PDEVICE_OBJECT DeviceObject)
{
- DPRINT("Pin_fnFastDeviceIoControl called DeviceObject %p Irp %p\n",
DeviceObject);
-
-
return FALSE;
}
@@ -348,8 +357,6 @@
PIO_STATUS_BLOCK IoStatus,
PDEVICE_OBJECT DeviceObject)
{
- DPRINT("Pin_fnFastRead called DeviceObject %p Irp %p\n", DeviceObject);
-
return FALSE;
}