[ros-diffs] [janderwald] 39158: - Implement initializing routines for wdmaud - Register plug&play notification routines for guid KSCATEGORY_SYSAUDIO

janderwald at svn.reactos.org janderwald at svn.reactos.org
Wed Jan 28 01:04:01 CET 2009


Author: janderwald
Date: Tue Jan 27 18:04:00 2009
New Revision: 39158

URL: http://svn.reactos.org/svn/reactos?rev=39158&view=rev
Log:
- Implement initializing routines for wdmaud
- Register plug&play notification routines for guid KSCATEGORY_SYSAUDIO

Modified:
    trunk/reactos/drivers/wdm/audio/legacy/directory.rbuild
    trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c
    trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.rbuild

Modified: trunk/reactos/drivers/wdm/audio/legacy/directory.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/directory.rbuild?rev=39158&r1=39157&r2=39158&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/directory.rbuild [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/directory.rbuild [iso-8859-1] Tue Jan 27 18:04:00 2009
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <!DOCTYPE group SYSTEM "../../../../tools/rbuild/project.dtd">
 <group xmlns:xi="http://www.w3.org/2001/XInclude">
-	<!--directory name="wdmaud">
+	<directory name="wdmaud">
 		<xi:include href="wdmaud/wdmaud.rbuild" />
-	</directory-->
+	</directory>
 </group>

Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c?rev=39158&r1=39157&r2=39158&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c [iso-8859-1] Tue Jan 27 18:04:00 2009
@@ -1,59 +1,228 @@
 /*
-    This doesn't do much yet...
-*/
-
-#include <debug.h>
-
-#define InPassiveIrql() \
-    (KeGetCurrentIrql() == IRQL_PASSIVE_LEVEL)
-
-
-NTSTATUS AudioDeviceControl(
-    IN PDEVICE_OBJECT device,
-    IN PIRP irp
-)
-{
-    return STATUS_SUCCESS;
-}
-
-
-NTSTATUS AudioAddDevice(
-    IN PDRIVER_OBJECT driver,
-    IN PDEVICE_OBJECT device
-)
-{
-    DPRINT("AudioAddDevice called\n");
-
-    if ( ! IsPassiveIrql() )
-    {
-        /* What do we do?! */
-        /* RtlAssert("FAIL", __FILE__, __LINE__, "?" */
-    }
-
-    return STATUS_SUCCESS;
-}
-
-VOID AudioUnload(
-    IN PDRIVER_OBJECT driver
-)
-{
-    DPRINT("AudioUnload called\n");
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS Kernel Streaming
+ * FILE:            drivers/wdm/audio/legacy/wdmaud/main.c
+ * PURPOSE:         System Audio graph builder
+ * PROGRAMMER:      Andrew Greenwood
+ *                  Johannes Anderwald
+ */
+#include "wdmaud.h"
+
+const GUID KSCATEGORY_SYSAUDIO = {0xA7C7A5B1L, 0x5AF3, 0x11D1, {0x9C, 0xED, 0x00, 0xA0, 0x24, 0xBF, 0x04, 0x07}};
+
+NTSTATUS
+NTAPI
+WdmAudAddDevice(
+    IN  PDRIVER_OBJECT  DriverObject,
+    IN  PDEVICE_OBJECT  PhysicalDeviceObject)
+{
+    PDEVICE_OBJECT DeviceObject;
+    PDEVICE_OBJECT NextDeviceObject;
+    NTSTATUS Status;
+    PWDMAUD_DEVICE_EXTENSION DeviceExtension;
+
+    DPRINT("WdmAudAddDevice called\n");
+
+    Status = IoCreateDevice(DriverObject,
+                            sizeof(WDMAUD_DEVICE_EXTENSION),
+                            NULL,
+                            FILE_DEVICE_KS,
+                            0,
+                            FALSE,
+                            &DeviceObject);
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("IoCreateDevice failed with %x\n", Status);
+        return Status;
+    }
+
+    DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+    RtlZeroMemory(DeviceExtension, sizeof(WDMAUD_DEVICE_EXTENSION));
+
+    Status = KsAllocateDeviceHeader(&DeviceExtension->DeviceHeader, 0, NULL);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("KsAllocateDeviceHeader failed with %x\n", Status);
+        IoDeleteDevice(DeviceObject);
+        return Status;
+    }
+
+    NextDeviceObject = IoAttachDeviceToDeviceStack(DeviceObject, PhysicalDeviceObject);
+    if (NextDeviceObject)
+    {
+        /// FIXME
+        /// KsSetDevicePnpAndBaseObject((KSDEVICE_HEADER)DeviceObject->DeviceExtension, NextDeviceObject, DeviceObject);
+    }
+
+
+    DeviceObject->Flags |= DO_DIRECT_IO | DO_POWER_PAGABLE;
+    DeviceObject->Flags &= ~ DO_DEVICE_INITIALIZING;
+
+    return STATUS_SUCCESS;
+}
+
+VOID
+NTAPI
+WdmAudUnload(
+    IN PDRIVER_OBJECT driver)
+{
+    DPRINT("WdmAudUnload called\n");
+}
+
+NTSTATUS
+NTAPI
+WdmAudPnp(
+    IN  PDEVICE_OBJECT DeviceObject,
+    IN  PIRP Irp)
+{
+    PIO_STACK_LOCATION IrpStack;
+
+    DPRINT("WdmAudPnp called\n");
+
+    IrpStack = IoGetCurrentIrpStackLocation(Irp);
+
+    if (IrpStack->MinorFunction == IRP_MN_QUERY_PNP_DEVICE_STATE)
+    {
+        Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
+        return KsDefaultDispatchPnp(DeviceObject, Irp);
+    }
+    return KsDefaultDispatchPnp(DeviceObject, Irp);
+}
+
+NTSTATUS
+NTAPI
+DeviceInterfaceChangeCallback(
+    IN PVOID NotificationStructure,
+    IN PVOID Context)
+{
+    DEVICE_INTERFACE_CHANGE_NOTIFICATION * Event = (DEVICE_INTERFACE_CHANGE_NOTIFICATION*)NotificationStructure;
+
+    DPRINT1("DeviceInterfaceChangeCallback called %p\n", Event);
+    return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+NTAPI
+WdmAudCreate(
+    IN  PDEVICE_OBJECT DeviceObject,
+    IN  PIRP Irp)
+{
+    NTSTATUS Status;
+    PWDMAUD_DEVICE_EXTENSION DeviceExtension;
+
+    DPRINT1("WdmAudCreate\n");
+
+
+    DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+#if 0
+    Status = KsReferenceSoftwareBusObject((KSDEVICE_HEADER)DeviceObject->DeviceExtension);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("KsReferenceSoftwareBusObject failed with %x\n", Status);
+        return Status;
+    }
+#endif
+
+    Status = IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange,
+                                            PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,
+                                            (PVOID)&KSCATEGORY_SYSAUDIO,
+                                            DeviceObject->DriverObject,
+                                            DeviceInterfaceChangeCallback,
+                                            (PVOID)DeviceExtension,
+                                            &DeviceExtension->SysAudioNotification);
+
+
+    Irp->IoStatus.Status = Status;
+    Irp->IoStatus.Information = 0;
+    IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+    return Status;
+}
+
+NTSTATUS
+NTAPI
+WdmAudClose(
+    IN  PDEVICE_OBJECT DeviceObject,
+    IN  PIRP Irp)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+    PWDMAUD_DEVICE_EXTENSION DeviceExtension;
+
+    DPRINT1("WdmAudClose\n");
+
+    DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+#if 0
+    Status = KsDereferenceSoftwareBusObject(DeviceExtension->DeviceHeader);
+#endif
+
+    if (NT_SUCCESS(Status))
+    {
+        Status = IoUnregisterPlugPlayNotification(DeviceExtension->SysAudioNotification);
+    }
+
+    Irp->IoStatus.Status = Status;
+    Irp->IoStatus.Information = 0;
+    IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+    return Status;
+}
+
+NTSTATUS
+NTAPI
+WdmAudDeviceControl(
+    IN  PDEVICE_OBJECT DeviceObject,
+    IN  PIRP Irp)
+{
+    UNIMPLEMENTED
+
+    Irp->IoStatus.Status = STATUS_SUCCESS;
+    Irp->IoStatus.Information = 0;
+    IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+    return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+WdmAudCleanup(
+    IN  PDEVICE_OBJECT DeviceObject,
+    IN  PIRP Irp)
+{
+    UNIMPLEMENTED
+
+    Irp->IoStatus.Status = STATUS_SUCCESS;
+    Irp->IoStatus.Information = 0;
+    IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+    return STATUS_SUCCESS;
 }
 
 
 
 NTSTATUS NTAPI
 DriverEntry(
-    IN PDRIVER_OBJECT driver,
-    IN PUNICODE_STRING registry_path
+    IN PDRIVER_OBJECT Driver,
+    IN PUNICODE_STRING Registry_path
 )
 {
     DPRINT("Wdmaud.sys loaded\n");
 
-    driver->DriverExtension->AddDevice = AudioAddDevice;
-    driver->DriverUnload = AudioUnload;
-
-    driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = AudioDeviceControl;
-
-    return STATUS_SUCCESS;
-}
+    Driver->DriverExtension->AddDevice = WdmAudAddDevice;
+    Driver->DriverUnload = WdmAudUnload;
+
+
+    Driver->MajorFunction[IRP_MJ_CREATE] = WdmAudCreate;
+    Driver->MajorFunction[IRP_MJ_CLOSE] = WdmAudClose;
+    Driver->MajorFunction[IRP_MJ_PNP] = WdmAudPnp;
+    Driver->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = KsDefaultForwardIrp; 
+    Driver->MajorFunction[IRP_MJ_CLEANUP] = WdmAudCleanup;
+    Driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = WdmAudDeviceControl;
+    Driver->MajorFunction[IRP_MJ_POWER] = KsDefaultDispatchPower;
+
+
+    return STATUS_SUCCESS;
+}

Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.rbuild?rev=39158&r1=39157&r2=39158&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.rbuild [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.rbuild [iso-8859-1] Tue Jan 27 18:04:00 2009
@@ -1,8 +1,8 @@
 <?xml version="1.0"?>
 <!DOCTYPE module SYSTEM "../../../../../tools/rbuild/project.dtd">
 <module name="wdmaud_kernel" type="kernelmodedriver" installbase="system32/drivers" installname="wdmaud.sys">
-	<include base="wdmaud">.</include>
-	<include base="wdmaud">..</include>
+	<include base="wdmaud_kernel">.</include>
 	<library>ntoskrnl</library>
+	<library>ks</library>
 	<file>entry.c</file>
 </module>



More information about the Ros-diffs mailing list