From 04a9e81b9eb67213be1af5896328f9c7e7072413 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Wed, 28 Jan 2009 00:04:00 +0000 Subject: [PATCH] - Implement initializing routines for wdmaud - Register plug&play notification routines for guid KSCATEGORY_SYSAUDIO svn path=/trunk/; revision=39158 --- .../drivers/wdm/audio/legacy/directory.rbuild | 4 +- .../drivers/wdm/audio/legacy/wdmaud/entry.c | 231 +++++++++++++++--- .../wdm/audio/legacy/wdmaud/wdmaud.rbuild | 4 +- 3 files changed, 204 insertions(+), 35 deletions(-) diff --git a/reactos/drivers/wdm/audio/legacy/directory.rbuild b/reactos/drivers/wdm/audio/legacy/directory.rbuild index a95c2900481..9f313d10d87 100644 --- a/reactos/drivers/wdm/audio/legacy/directory.rbuild +++ b/reactos/drivers/wdm/audio/legacy/directory.rbuild @@ -1,7 +1,7 @@ - + diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c b/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c index 099c721cadd..9e056a4e28d 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c @@ -1,59 +1,228 @@ /* - This doesn't do much yet... -*/ + * 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" -#include +const GUID KSCATEGORY_SYSAUDIO = {0xA7C7A5B1L, 0x5AF3, 0x11D1, {0x9C, 0xED, 0x00, 0xA0, 0x24, 0xBF, 0x04, 0x07}}; -#define InPassiveIrql() \ - (KeGetCurrentIrql() == IRQL_PASSIVE_LEVEL) - - -NTSTATUS AudioDeviceControl( - IN PDEVICE_OBJECT device, - IN PIRP irp -) +NTSTATUS +NTAPI +WdmAudAddDevice( + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT PhysicalDeviceObject) { - return STATUS_SUCCESS; -} + PDEVICE_OBJECT DeviceObject; + PDEVICE_OBJECT NextDeviceObject; + NTSTATUS Status; + PWDMAUD_DEVICE_EXTENSION DeviceExtension; + DPRINT("WdmAudAddDevice called\n"); -NTSTATUS AudioAddDevice( - IN PDRIVER_OBJECT driver, - IN PDEVICE_OBJECT device -) -{ - DPRINT("AudioAddDevice called\n"); + Status = IoCreateDevice(DriverObject, + sizeof(WDMAUD_DEVICE_EXTENSION), + NULL, + FILE_DEVICE_KS, + 0, + FALSE, + &DeviceObject); - if ( ! IsPassiveIrql() ) + if (!NT_SUCCESS(Status)) { - /* What do we do?! */ - /* RtlAssert("FAIL", __FILE__, __LINE__, "?" */ + 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 AudioUnload( - IN PDRIVER_OBJECT driver -) +VOID +NTAPI +WdmAudUnload( + IN PDRIVER_OBJECT driver) { - DPRINT("AudioUnload called\n"); + 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->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; - driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = AudioDeviceControl; return STATUS_SUCCESS; } diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.rbuild b/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.rbuild index 14c701e38a9..dd3b89db132 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.rbuild +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/wdmaud.rbuild @@ -1,8 +1,8 @@ - . - .. + . ntoskrnl + ks entry.c