Author: janderwald
Date: Tue Feb 10 16:17:33 2009
New Revision: 39541
URL:
http://svn.reactos.org/svn/reactos?rev=39541&view=rev
Log:
- Increase reference count on ISubdevice interface after successfully allocating the
device header
- Delegate Create Request to Ks
- Implement KSDISPATCH_TABLE for IPortTopology
- KSDEVICE_HEADER must be the first item in the device extension
Modified:
trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/private.h
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c [iso-8859-1] Tue Feb 10
16:17:33 2009
@@ -12,6 +12,7 @@
#include "private.h"
#include <devguid.h>
#include <initguid.h>
+#include <ksmedia.h>
/*
This is called from DriverEntry so that PortCls can take care of some
@@ -199,58 +200,6 @@
return status;
}
-NTSTATUS
-NTAPI
-PciDriverDispatch(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- NTSTATUS Status;
-
- ISubdevice * SubDevice;
- PPCLASS_DEVICE_EXTENSION DeviceExt;
- SUBDEVICE_ENTRY * Entry;
- KSDISPATCH_TABLE DispatchTable;
-
- DPRINT1("PortClsSysControl called\n");
-
- SubDevice = (ISubdevice*)Irp->Tail.Overlay.DriverContext[3];
- DeviceExt = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
- if (!SubDevice || !DeviceExt)
- {
- return STATUS_UNSUCCESSFUL;
- }
-
- Entry = AllocateItem(NonPagedPool, sizeof(SUBDEVICE_ENTRY), TAG_PORTCLASS);
- if (!Entry)
- return STATUS_INSUFFICIENT_RESOURCES;
-
- /* initialize DispatchTable */
- RtlZeroMemory(&DispatchTable, sizeof(KSDISPATCH_TABLE));
- /* FIXME
- * initialize DispatchTable pointer
- * which call in turn ISubDevice
- */
-
-
- Status = KsAllocateObjectHeader(&Entry->ObjectHeader, 1, NULL, Irp,
&DispatchTable);
- if (!NT_SUCCESS(Status))
- {
- FreeItem(Entry, TAG_PORTCLASS);
- return Status;
- }
-
-
- InsertTailList(&DeviceExt->SubDeviceList, &Entry->Entry);
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- return STATUS_SUCCESS;
-}
-
NTSTATUS NTAPI
PcRegisterSubdevice(
IN PDEVICE_OBJECT DeviceObject,
@@ -283,8 +232,7 @@
/* the provided port driver doesnt support ISubdevice */
return STATUS_INVALID_PARAMETER;
}
-#if KS_IMPLEMENTED
- Status = KsAddObjectCreateItemToDeviceHeader(DeviceExt->KsDeviceHeader,
PciDriverDispatch, (PVOID)SubDevice, Name, NULL);
+ Status = KsAddObjectCreateItemToDeviceHeader(DeviceExt->KsDeviceHeader,
PcCreateItemDispatch, (PVOID)SubDevice, Name, NULL);
if (!NT_SUCCESS(Status))
{
/* failed to attach */
@@ -292,8 +240,7 @@
DPRINT1("KsAddObjectCreateItemToDeviceHeader failed with %x\n",
Status);
return Status;
}
-#endif
-
+ SubDevice->lpVtbl->AddRef(SubDevice);
Status = SubDevice->lpVtbl->GetDescriptor(SubDevice,
&SubDeviceDescriptor);
if (!NT_SUCCESS(Status))
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c [iso-8859-1] Tue Feb 10 16:17:33
2009
@@ -49,13 +49,7 @@
{
DPRINT1("PortClsCreate called\n");
- /* TODO */
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- return STATUS_SUCCESS;
+ return KsDispatchIrp(DeviceObject, Irp);
}
@@ -234,19 +228,8 @@
case IRP_MJ_SYSTEM_CONTROL :
return PortClsSysControl(DeviceObject, Irp);
- /* KS - TODO */
-
-#if 0
- KsSetMajorFunctionHandler(DriverObject, IRP_MJ_CLOSE);
- KsSetMajorFunctionHandler(DriverObject, IRP_MJ_DEVICE_CONTROL);
- KsSetMajorFunctionHandler(DriverObject, IRP_MJ_FLUSH_BUFFERS);
- KsSetMajorFunctionHandler(DriverObject, IRP_MJ_QUERY_SECURITY);
- KsSetMajorFunctionHandler(DriverObject, IRP_MJ_READ);
- KsSetMajorFunctionHandler(DriverObject, IRP_MJ_SET_SECURITY);
- KsSetMajorFunctionHandler(DriverObject, IRP_MJ_WRITE);
-#endif
-
- default :
+ default:
+ DPRINT1("Unhandled function %x\n", IoStack->MajorFunction);
break;
};
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c [iso-8859-1]
(original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c [iso-8859-1] Tue Feb
10 16:17:33 2009
@@ -434,6 +434,228 @@
NTSTATUS
+NTAPI
+ITopology_fnDeviceIoControl(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ DPRINT1("ITopology_fnDeviceIoControl called\n");
+
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+ITopology_fnRead(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ DPRINT1("ITopology_fnRead called\n");
+
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+ITopology_fnWrite(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ DPRINT1("ITopology_fnWrite called\n");
+
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+ITopology_fnFlush(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ DPRINT1("ITopology_fnFlush called\n");
+
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+ITopology_fnClose(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ DPRINT1("ITopology_fnClose called\n");
+
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+ITopology_fnQuerySecurity(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ DPRINT1("ITopology_fnQuerySecurity called\n");
+
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+ITopology_fnSetSecurity(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
+{
+ DPRINT1("ITopology_fnSetSecurity called\n");
+
+ return STATUS_SUCCESS;
+}
+
+BOOLEAN
+NTAPI
+ITopology_fnFastDeviceIoControl(
+ PFILE_OBJECT FileObject,
+ BOOLEAN Wait,
+ PVOID InputBuffer,
+ ULONG InputBufferLength,
+ PVOID OutputBuffer,
+ ULONG OutputBufferLength,
+ ULONG IoControlCode,
+ PIO_STATUS_BLOCK IoStatus,
+ PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT1("ITopology_fnFastDeviceIoControl called\n");
+
+ return TRUE;
+}
+
+
+BOOLEAN
+NTAPI
+ITopology_fnFastRead(
+ PFILE_OBJECT FileObject,
+ PLARGE_INTEGER FileOffset,
+ ULONG Length,
+ BOOLEAN Wait,
+ ULONG LockKey,
+ PVOID Buffer,
+ PIO_STATUS_BLOCK IoStatus,
+ PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT1("ITopology_fnFastRead called\n");
+
+ return TRUE;
+
+}
+
+BOOLEAN
+NTAPI
+ITopology_fnFastWrite(
+ PFILE_OBJECT FileObject,
+ PLARGE_INTEGER FileOffset,
+ ULONG Length,
+ BOOLEAN Wait,
+ ULONG LockKey,
+ PVOID Buffer,
+ PIO_STATUS_BLOCK IoStatus,
+ PDEVICE_OBJECT DeviceObject)
+{
+ DPRINT1("ITopology_fnFastWrite called\n");
+
+ return TRUE;
+}
+
+static KSDISPATCH_TABLE DispatchTable =
+{
+ ITopology_fnDeviceIoControl,
+ ITopology_fnRead,
+ ITopology_fnWrite,
+ ITopology_fnFlush,
+ ITopology_fnClose,
+ ITopology_fnQuerySecurity,
+ ITopology_fnSetSecurity,
+ ITopology_fnFastDeviceIoControl,
+ ITopology_fnFastRead,
+ ITopology_fnFastWrite,
+};
+
+NTSTATUS
+NTAPI
+PcCreateItemDispatch(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ ISubdevice * SubDevice;
+ PPCLASS_DEVICE_EXTENSION DeviceExt;
+ SUBDEVICE_ENTRY * Entry;
+ PKSOBJECT_CREATE_ITEM CreateItem;
+
+ DPRINT1("PcCreateItemDispatch called\n");
+
+ /* access the create item */
+ CreateItem = KSCREATE_ITEM_IRP_STORAGE(Irp);
+ if (!CreateItem)
+ {
+ DPRINT1("PcCreateItemDispatch no CreateItem\n");
+ Status = STATUS_UNSUCCESSFUL;
+ goto cleanup;
+ }
+
+ SubDevice = (ISubdevice*)CreateItem->Context;
+ DeviceExt = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ if (!SubDevice || !DeviceExt)
+ {
+ DPRINT1("PcCreateItemDispatch SubDevice %p DeviceExt %p\n", SubDevice,
DeviceExt);
+
+ Status = STATUS_UNSUCCESSFUL;
+ goto cleanup;
+ }
+
+ Entry = AllocateItem(NonPagedPool, sizeof(SUBDEVICE_ENTRY), TAG_PORTCLASS);
+ if (!Entry)
+ {
+ DPRINT1("PcCreateItemDispatch no memory\n");
+
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto cleanup;
+ }
+#if 0
+ Status = KsReferenceSoftwareBusObject(DeviceExt->KsDeviceHeader);
+ if (!NT_SUCCESS(Status) && Status != STATUS_NOT_IMPLEMENTED)
+ {
+ DPRINT1("PciCreateItemDispatch failed to reference device header\n");
+
+ FreeItem(Entry, TAG_PORTCLASS);
+ goto cleanup;
+ }
+#endif
+
+ Status = KsAllocateObjectHeader(&Entry->ObjectHeader, 0, NULL, Irp,
&DispatchTable);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("KsAllocateObjectHeader failed with %x\n", Status);
+ //KsDereferenceSoftwareBusObject(DeviceExt->KsDeviceHeader);
+ FreeItem(Entry, TAG_PORTCLASS);
+ return Status;
+ }
+
+ InsertTailList(&DeviceExt->SubDeviceList, &Entry->Entry);
+
+
+cleanup:
+ // Irp->IoStatus.Status = Status;
+ // Irp->IoStatus.Information = 0;
+ // IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ DPRINT1("PcCreateItemDispatch Status %x\n", Status);
+ return Status;
+}
+
+
+
+NTSTATUS
NewPortTopology(
OUT PPORT* OutPort)
{
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/private.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/private.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/private.h [iso-8859-1] Tue Feb 10
16:17:33 2009
@@ -12,7 +12,6 @@
#define YDEBUG
#include <debug.h>
-#include <portcls.h>
#include <dmusicks.h>
#include "interfaces.h"
@@ -118,10 +117,10 @@
typedef struct
{
+ KSDEVICE_HEADER KsDeviceHeader;
PDEVICE_OBJECT PhysicalDeviceObject;
PDEVICE_OBJECT PrevDeviceObject;
PCPFNSTARTDEVICE StartDevice;
- KSDEVICE_HEADER KsDeviceHeader;
IAdapterPowerManagement * AdapterPowerManagement;
ULONG MaxSubDevices;
KSOBJECT_CREATE_ITEM * CreateItems;
@@ -178,4 +177,11 @@
IN KSEVENT_SET * EventSet,
IN PPCFILTER_DESCRIPTOR FilterDescription);
+NTSTATUS
+NTAPI
+PcCreateItemDispatch(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);
+
+
#endif