Author: janderwald
Date: Thu Dec 16 11:10:45 2010
New Revision: 50035
URL:
http://svn.reactos.org/svn/reactos?rev=50035&view=rev
Log:
[AUDIO-BRINGUP]
- Fix several bugs in SwDispatchPnp routine
- Routine did not complete requests, when KsServiceBusEnumPnpRequest successfully handled
the request
- Software bus driver did not handle resource lists irps
- Software bus driver did not support querying pnp device state
- Software bus driver leaked the irp for IOCTL_SWENUM_GET_BUS_ID requests in
SwDispatchDeviceControl
- Software bus driver is now successfully initializes in XP and audio devices are present
Modified:
branches/audio-bringup/drivers/ksfilter/swenum/swenum.c
Modified: branches/audio-bringup/drivers/ksfilter/swenum/swenum.c
URL:
http://svn.reactos.org/svn/reactos/branches/audio-bringup/drivers/ksfilter/…
==============================================================================
--- branches/audio-bringup/drivers/ksfilter/swenum/swenum.c [iso-8859-1] (original)
+++ branches/audio-bringup/drivers/ksfilter/swenum/swenum.c [iso-8859-1] Thu Dec 16
11:10:45 2010
@@ -43,6 +43,9 @@
PIO_STACK_LOCATION IoStack;
PDEVICE_OBJECT PnpDeviceObject = NULL;
+ /* get current stack location */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
/* check if the device object is a child device */
Status = KsIsBusEnumChildDevice(DeviceObject, &ChildDevice);
@@ -55,10 +58,30 @@
return Status;
}
+ DPRINT1("SwDispatchPnp ChildDevice %u Request %x\n", ChildDevice,
IoStack->MinorFunction);
+
/* let ks handle it */
Status = KsServiceBusEnumPnpRequest(DeviceObject, Irp);
- if (!NT_SUCCESS(Status))
+ /* check if the request was for a pdo */
+ if (!ChildDevice)
+ {
+ if (Status != STATUS_NOT_SUPPORTED)
+ {
+ /* store result */
+ Irp->IoStatus.Status = Status;
+ }
+
+ /* complete request */
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ /* done */
+ return Status;
+ }
+
+ DPRINT1("SwDispatchPnp KsServiceBusEnumPnpRequest Status %x\n", Status);
+
+ if (NT_SUCCESS(Status))
{
/* invalid request or not supported */
Irp->IoStatus.Status = Status;
@@ -69,6 +92,8 @@
/* get bus enum pnp object */
Status = KsGetBusEnumPnpDeviceObject(DeviceObject, &PnpDeviceObject);
+ DPRINT1("SwDispatchPnp KsGetBusEnumPnpDeviceObject Status %x\n", Status);
+
/* check for success */
if (!NT_SUCCESS(Status))
{
@@ -89,11 +114,49 @@
/* delete the device */
IoDeleteDevice(DeviceObject);
}
-
- /* skip current location */
- IoSkipCurrentIrpStackLocation(Irp);
- /* call the pnp device object */
- return IoCallDriver(PnpDeviceObject, Irp);
+ else
+ {
+ if (IoStack->MinorFunction == IRP_MN_QUERY_RESOURCES ||
IoStack->MinorFunction == IRP_MN_QUERY_RESOURCE_REQUIREMENTS)
+ {
+ /* no resources required */
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+
+ /* skip current location */
+ IoSkipCurrentIrpStackLocation(Irp);
+
+ /* call the pnp device object */
+ return IoCallDriver(PnpDeviceObject, Irp);
+ }
+
+ if (IoStack->MajorFunction == IRP_MN_QUERY_PNP_DEVICE_STATE)
+ {
+ /* device cannot be disabled */
+ Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+
+ /* skip current location */
+ IoSkipCurrentIrpStackLocation(Irp);
+
+ /* call the pnp device object */
+ return IoCallDriver(PnpDeviceObject, Irp);
+ }
+
+ if (Status == STATUS_NOT_SUPPORTED)
+ {
+ /* skip current location */
+ IoSkipCurrentIrpStackLocation(Irp);
+
+ /* call the pnp device object */
+ return IoCallDriver(PnpDeviceObject, Irp);
+ }
+ }
+
+ /* complete the request */
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ return Status;
}
NTSTATUS
@@ -149,7 +212,7 @@
IN PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
- NTSTATUS Status = STATUS_SUCCESS;
+ NTSTATUS Status;
/* get current stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
@@ -158,16 +221,25 @@
{
/* install interface */
Status = KsInstallBusEnumInterface(Irp);
+ DPRINT1("SwDispatchDeviceControl IOCTL_SWENUM_INSTALL_INTERFACE %x\n",
Status);
}
else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_SWENUM_REMOVE_INTERFACE)
{
/* remove interface */
Status = KsRemoveBusEnumInterface(Irp);
+ DPRINT1("SwDispatchDeviceControl IOCTL_SWENUM_REMOVE_INTERFACE %x\n",
Status);
+
}
else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_SWENUM_GET_BUS_ID)
{
/* get bus id */
- return KsGetBusEnumIdentifier(Irp);
+ Status = KsGetBusEnumIdentifier(Irp);
+ DPRINT1("SwDispatchDeviceControl IOCTL_SWENUM_GET_BUS_ID %x\n",
Status);
+ }
+ else
+ {
+ DPRINT1("SwDispatchDeviceControl Unknown IOCTL %x\n",
IoStack->Parameters.DeviceIoControl.IoControlCode);
+ Status = STATUS_INVALID_PARAMETER;
}
/* store result */
@@ -192,6 +264,8 @@
/* check if the device object is a child device */
Status = KsIsBusEnumChildDevice(DeviceObject, &ChildDevice);
+
+ DPRINT1("SwDispatchCreate %x\n", Status);
/* check for success */
if (NT_SUCCESS(Status))
@@ -205,6 +279,7 @@
}
/* perform the create request */
Status = KsServiceBusEnumCreateRequest(DeviceObject, Irp);
+ DPRINT1("SwDispatchCreate %x\n", Status);
}
/* check the irp is pending */
@@ -246,7 +321,6 @@
PDEVICE_OBJECT FunctionalDeviceObject;
DPRINT1("SWENUM AddDevice\n");
- DbgBreakPoint();
/* create the device */
Status = IoCreateDevice(DriverObject, sizeof(KSDEVICE_HEADER), NULL,
FILE_DEVICE_BUS_EXTENDER, 0, FALSE, &FunctionalDeviceObject);
@@ -307,7 +381,6 @@
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = SwDispatchSystemControl;
DPRINT1("SWENUM loaded\n");
- DbgBreakPoint();
return STATUS_SUCCESS;
}