ReactOS  0.4.15-dev-1054-gd029a62
hdaudbus.h File Reference
#include <ntddk.h>
#include <debug.h>
#include <initguid.h>
#include <hdaudio.h>
#include <stdio.h>
#include <ntstrsafe.h>
#include "driver.h"
Include dependency graph for hdaudbus.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  RIRB_RESPONSE
 
struct  HDA_CODEC_AUDIO_GROUP
 
struct  HDA_CODEC_ENTRY
 
struct  HDA_FDO_DEVICE_EXTENSION
 
struct  HDA_PDO_DEVICE_EXTENSION
 
struct  CODEC_RESPONSE
 

Macros

#define YDEBUG
 
#define TAG_HDA   'bADH'
 
#define MAKE_RATE(base, multiply, divide)
 
#define HDAC_INPUT_STREAM_OFFSET(index)   ((index) * HDAC_STREAM_SIZE)
 
#define HDAC_OUTPUT_STREAM_OFFSET(num_input_streams, index)   ((num_input_streams + (index)) * HDAC_STREAM_SIZE)
 
#define HDAC_BIDIR_STREAM_OFFSET(num_input_streams, num_output_streams, index)
 
#define ALIGN(size, align)   (((size) + align - 1) & ~(align - 1))
 

Typedefs

typedef struct RIRB_RESPONSEPRIRB_RESPONSE
 
typedef struct HDA_CODEC_AUDIO_GROUPPHDA_CODEC_AUDIO_GROUP
 
typedef struct HDA_CODEC_ENTRYPHDA_CODEC_ENTRY
 
typedef struct HDA_FDO_DEVICE_EXTENSIONPHDA_FDO_DEVICE_EXTENSION
 
typedef struct HDA_PDO_DEVICE_EXTENSIONPHDA_PDO_DEVICE_EXTENSION
 
typedef struct CODEC_RESPONSEPCODEC_RESPONSE
 

Functions

PVOID AllocateItem (IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
 
VOID FreeItem (IN PVOID Item)
 
NTSTATUS NTAPI HDA_FDOStartDevice (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI HDA_FDORemoveDevice (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 
NTSTATUS NTAPI HDA_FDOQueryBusRelations (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID HDA_SendVerbs (IN PDEVICE_OBJECT DeviceObject, IN PHDA_CODEC_ENTRY Codec, IN PULONG Verbs, OUT PULONG Responses, IN ULONG Count)
 
NTSTATUS HDA_PDORemoveDevice (_In_ PDEVICE_OBJECT DeviceObject)
 
NTSTATUS HDA_PDOQueryBusInformation (IN PIRP Irp)
 
NTSTATUS NTAPI HDA_PDOQueryId (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS HDA_PDOHandleQueryDeviceText (IN PIRP Irp)
 
NTSTATUS HDA_PDOQueryBusDeviceCapabilities (IN PIRP Irp)
 
NTSTATUS HDA_PDOQueryBusDevicePnpState (IN PIRP Irp)
 
NTSTATUS HDA_PDOHandleQueryInterface (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Variables

KSERVICE_ROUTINE HDA_InterruptService
 
IO_DPC_ROUTINE HDA_DpcForIsr
 

Macro Definition Documentation

◆ ALIGN

#define ALIGN (   size,
  align 
)    (((size) + align - 1) & ~(align - 1))

Definition at line 30 of file hdaudbus.h.

◆ HDAC_BIDIR_STREAM_OFFSET

#define HDAC_BIDIR_STREAM_OFFSET (   num_input_streams,
  num_output_streams,
  index 
)
Value:
((num_input_streams + num_output_streams \
#define index(s, c)
Definition: various.h:29
#define HDAC_STREAM_SIZE

Definition at line 26 of file hdaudbus.h.

◆ HDAC_INPUT_STREAM_OFFSET

#define HDAC_INPUT_STREAM_OFFSET (   index)    ((index) * HDAC_STREAM_SIZE)

Definition at line 22 of file hdaudbus.h.

◆ HDAC_OUTPUT_STREAM_OFFSET

#define HDAC_OUTPUT_STREAM_OFFSET (   num_input_streams,
  index 
)    ((num_input_streams + (index)) * HDAC_STREAM_SIZE)

Definition at line 24 of file hdaudbus.h.

◆ MAKE_RATE

#define MAKE_RATE (   base,
  multiply,
  divide 
)
Value:
((base == 44100 ? FORMAT_44_1_BASE_RATE : 0) \
| ((multiply - 1) << FORMAT_MULTIPLY_RATE_SHIFT) \
| ((divide - 1) << FORMAT_DIVIDE_RATE_SHIFT))
#define FORMAT_44_1_BASE_RATE
#define FORMAT_DIVIDE_RATE_SHIFT
#define FORMAT_MULTIPLY_RATE_SHIFT

Definition at line 17 of file hdaudbus.h.

◆ TAG_HDA

#define TAG_HDA   'bADH'

Definition at line 11 of file hdaudbus.h.

◆ YDEBUG

#define YDEBUG

Definition at line 3 of file hdaudbus.h.

Typedef Documentation

◆ PCODEC_RESPONSE

◆ PHDA_CODEC_AUDIO_GROUP

◆ PHDA_CODEC_ENTRY

◆ PHDA_FDO_DEVICE_EXTENSION

◆ PHDA_PDO_DEVICE_EXTENSION

◆ PRIRB_RESPONSE

Function Documentation

◆ AllocateItem()

PVOID AllocateItem ( IN POOL_TYPE  PoolType,
IN SIZE_T  NumberOfBytes 
)

Definition at line 30 of file misc.c.

33 {
35  if (!Item)
36  return Item;
37 
39  return Item;
40 }
#define TAG_KS
Definition: misc.c:14
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1018
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444

◆ FreeItem()

VOID FreeItem ( IN PVOID  Item)

Definition at line 43 of file misc.c.

45 {
46  ExFreePool(Item);
47 }
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ HDA_FDOQueryBusRelations()

NTSTATUS NTAPI HDA_FDOQueryBusRelations ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 740 of file fdo.cpp.

743 {
744  ULONG DeviceCount, CodecIndex, AFGIndex;
745  PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
746  PHDA_CODEC_ENTRY Codec;
747  PDEVICE_RELATIONS DeviceRelations;
748 
749  /* get device extension */
750  DeviceExtension = (PHDA_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
751  ASSERT(DeviceExtension->IsFDO == TRUE);
752 
753  DeviceCount = 0;
754  for (CodecIndex = 0; CodecIndex < HDA_MAX_CODECS; CodecIndex++)
755  {
756  if (DeviceExtension->Codecs[CodecIndex] == NULL)
757  continue;
758 
759  Codec = DeviceExtension->Codecs[CodecIndex];
760  DeviceCount += Codec->AudioGroupCount;
761  }
762 
763  if (DeviceCount == 0)
764  return STATUS_UNSUCCESSFUL;
765 
766  DeviceRelations = (PDEVICE_RELATIONS)AllocateItem(NonPagedPool, sizeof(DEVICE_RELATIONS) + (DeviceCount > 1 ? sizeof(PDEVICE_OBJECT) * (DeviceCount - 1) : 0));
767  if (!DeviceRelations)
769 
770  DeviceRelations->Count = 0;
771  for (CodecIndex = 0; CodecIndex < HDA_MAX_CODECS; CodecIndex++)
772  {
773  if (DeviceExtension->Codecs[CodecIndex] == NULL)
774  continue;
775 
776  Codec = DeviceExtension->Codecs[CodecIndex];
778  for (AFGIndex = 0; AFGIndex < Codec->AudioGroupCount; AFGIndex++)
779  {
780  DeviceRelations->Objects[DeviceRelations->Count] = Codec->AudioGroups[AFGIndex]->ChildPDO;
781  ObReferenceObject(Codec->AudioGroups[AFGIndex]->ChildPDO);
782  DeviceRelations->Count++;
783  }
784  }
785 
786  /* FIXME handle existing device relations */
787  ASSERT(Irp->IoStatus.Information == 0);
788 
789  /* store device relations */
790  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
791 
792  /* done */
793  return STATUS_SUCCESS;
794 }
#define HDA_MAX_AUDIO_GROUPS
Definition: driver.h:40
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
struct _DEVICE_OBJECT * PDEVICE_OBJECT
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2143
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
struct HDA_FDO_DEVICE_EXTENSION * PHDA_FDO_DEVICE_EXTENSION
PHDA_CODEC_ENTRY Codecs[HDA_MAX_CODECS+1]
Definition: hdaudbus.h:82
ULONG AudioGroupCount
Definition: hdaudbus.h:60
ULONG DeviceCount
Definition: mpu401.c:26
PHDA_CODEC_AUDIO_GROUP AudioGroups[HDA_MAX_AUDIO_GROUPS]
Definition: hdaudbus.h:59
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Definition: hdaudbus.h:45
#define HDA_MAX_CODECS
Definition: driver.h:41
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define ObReferenceObject
Definition: obfuncs.h:204
PDEVICE_OBJECT ChildPDO
Definition: hdaudbus.h:40
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by HDA_FdoPnp().

◆ HDA_FDORemoveDevice()

NTSTATUS NTAPI HDA_FDORemoveDevice ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 672 of file fdo.cpp.

675 {
677  PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
678  ULONG CodecIndex, AFGIndex;
679  PHDA_CODEC_ENTRY CodecEntry;
680  PDEVICE_OBJECT ChildPDO;
681  PHDA_PDO_DEVICE_EXTENSION ChildDeviceExtension;
682 
683  /* get device extension */
684  DeviceExtension = static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
685  ASSERT(DeviceExtension->IsFDO == TRUE);
686 
687  Irp->IoStatus.Status = STATUS_SUCCESS;
689  Status = IoCallDriver(DeviceExtension->LowerDevice, Irp);
690 
691  IoDetachDevice(DeviceExtension->LowerDevice);
692 
693  if (DeviceExtension->RegBase != NULL)
694  {
695  MmUnmapIoSpace(DeviceExtension->RegBase,
696  DeviceExtension->RegLength);
697  }
698  if (DeviceExtension->Interrupt != NULL)
699  {
700  IoDisconnectInterrupt(DeviceExtension->Interrupt);
701  }
702  if (DeviceExtension->CorbBase != NULL)
703  {
704  MmFreeContiguousMemory(DeviceExtension->CorbBase);
705  }
706 
707  for (CodecIndex = 0; CodecIndex < HDA_MAX_CODECS; CodecIndex++)
708  {
709  CodecEntry = DeviceExtension->Codecs[CodecIndex];
710  if (CodecEntry == NULL)
711  {
712  continue;
713  }
714 
716  for (AFGIndex = 0; AFGIndex < CodecEntry->AudioGroupCount; AFGIndex++)
717  {
718  ChildPDO = CodecEntry->AudioGroups[AFGIndex]->ChildPDO;
719  if (ChildPDO != NULL)
720  {
721  ChildDeviceExtension = static_cast<PHDA_PDO_DEVICE_EXTENSION>(ChildPDO->DeviceExtension);
722  ChildDeviceExtension->Codec = NULL;
723  ChildDeviceExtension->AudioGroup = NULL;
724  ChildDeviceExtension->FDO = NULL;
725  ChildDeviceExtension->ReportedMissing = TRUE;
726  HDA_PDORemoveDevice(ChildPDO);
727  }
728  FreeItem(CodecEntry->AudioGroups[AFGIndex]);
729  }
730  FreeItem(CodecEntry);
731  }
732 
734 
735  return Status;
736 }
#define HDA_MAX_AUDIO_GROUPS
Definition: driver.h:40
PHDA_CODEC_ENTRY Codec
Definition: hdaudbus.h:90
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT FDO
Definition: hdaudbus.h:92
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
VOID NTAPI MmFreeContiguousMemory(IN PVOID BaseAddress)
Definition: contmem.c:653
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
PHDA_CODEC_ENTRY Codecs[HDA_MAX_CODECS+1]
Definition: hdaudbus.h:82
ULONG AudioGroupCount
Definition: hdaudbus.h:60
PHDA_CODEC_AUDIO_GROUP AudioGroups[HDA_MAX_AUDIO_GROUPS]
Definition: hdaudbus.h:59
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:140
NTSTATUS HDA_PDORemoveDevice(_In_ PDEVICE_OBJECT DeviceObject)
Definition: pdo.cpp:11
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT LowerDevice
Definition: hdaudbus.h:68
Definition: hdaudbus.h:45
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define HDA_MAX_CODECS
Definition: driver.h:41
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
PHDA_CODEC_AUDIO_GROUP AudioGroup
Definition: hdaudbus.h:91
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
PDEVICE_OBJECT ChildPDO
Definition: hdaudbus.h:40
unsigned int ULONG
Definition: retypes.h:1
PKINTERRUPT Interrupt
Definition: hdaudbus.h:72
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by HDA_FdoPnp().

◆ HDA_FDOStartDevice()

NTSTATUS NTAPI HDA_FDOStartDevice ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 558 of file fdo.cpp.

561 {
562  PIO_STACK_LOCATION IoStack;
564  PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
566  ULONG Index;
567  USHORT Value;
568 
569  /* get device extension */
570  DeviceExtension = (PHDA_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
571  ASSERT(DeviceExtension->IsFDO == TRUE);
572 
573  /* forward irp to lower device */
574  if (!IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
575  {
576  ASSERT(FALSE);
578  }
579  Status = Irp->IoStatus.Status;
580  if (!NT_SUCCESS(Status))
581  {
582  // failed to start
583  DPRINT1("HDA_StartDevice Lower device failed to start %x\n", Status);
584  return Status;
585  }
586 
587  /* get current irp stack location */
589 
590  Resources = IoStack->Parameters.StartDevice.AllocatedResourcesTranslated;
591  for (Index = 0; Index < Resources->List[0].PartialResourceList.Count; Index++)
592  {
593  PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor = &Resources->List[0].PartialResourceList.PartialDescriptors[Index];
594 
595  if (Descriptor->Type == CmResourceTypeMemory)
596  {
597  DeviceExtension->RegLength = Descriptor->u.Memory.Length;
598  DeviceExtension->RegBase = (PUCHAR)MmMapIoSpace(Descriptor->u.Memory.Start, Descriptor->u.Memory.Length, MmNonCached);
599  if (DeviceExtension->RegBase == NULL)
600  {
601  DPRINT1("[HDAB] Failed to map registers\n");
603  break;
604  }
605  }
606  else if (Descriptor->Type == CmResourceTypeInterrupt)
607  {
608  Status = IoConnectInterrupt(&DeviceExtension->Interrupt,
610  DeviceObject,
611  NULL,
612  Descriptor->u.Interrupt.Vector,
613  Descriptor->u.Interrupt.Level,
614  Descriptor->u.Interrupt.Level,
616  (Descriptor->ShareDisposition != CmResourceShareDeviceExclusive),
617  Descriptor->u.Interrupt.Affinity,
618  FALSE);
619  if (!NT_SUCCESS(Status))
620  {
621  DPRINT1("[HDAB] Failed to connect interrupt. Status=%lx\n", Status);
622  break;
623  }
624 
625  }
626  }
627 
628  if (NT_SUCCESS(Status))
629  {
630  // Get controller into valid state
632  if (!NT_SUCCESS(Status)) return Status;
633 
634  // Setup CORB/RIRB/DMA POS
636  if (!NT_SUCCESS(Status)) return Status;
637 
638 
639  // Don't enable codec state change interrupts. We don't handle
640  // them, as we want to use the STATE_STATUS register to identify
641  // available codecs. We'd have to clear that register in the interrupt
642  // handler to 'ack' the codec change.
645 
646  // Enable controller interrupts
648 
650 
652  if (!Value) {
653  DPRINT1("hda: bad codec status\n");
654  return STATUS_UNSUCCESSFUL;
655  }
657 
658  // Create codecs
659  DPRINT1("Codecs %lx\n", Value);
660  for (Index = 0; Index < HDA_MAX_CODECS; Index++) {
661  if ((Value & (1 << Index)) != 0) {
663  }
664  }
665  }
666 
667  return Status;
668 }
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define HDAC_INTR_CONTROL
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1625
unsigned char * PUCHAR
Definition: retypes.h:3
struct HDA_FDO_DEVICE_EXTENSION * PHDA_FDO_DEVICE_EXTENSION
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
NTKERNELAPI VOID NTAPI WRITE_REGISTER_USHORT(IN PUSHORT Register, IN USHORT Value)
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
NTSTATUS NTAPI HDA_ResetController(IN PDEVICE_OBJECT DeviceObject)
Definition: fdo.cpp:448
IN UCHAR Value
Definition: halp.h:394
NTSTATUS NTAPI HDA_InitCorbRirbPos(IN PDEVICE_OBJECT DeviceObject)
Definition: fdo.cpp:301
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
Definition: irq.c:22
#define HDAC_WAKE_ENABLE
smooth NULL
Definition: ftsmooth.c:416
enum _KINTERRUPT_MODE KINTERRUPT_MODE
#define INTR_CONTROL_GLOBAL_ENABLE
#define HDAC_WAKE_ENABLE_MASK
NTSTATUS HDA_InitCodec(IN PDEVICE_OBJECT DeviceObject, IN ULONG codecAddress)
Definition: fdo.cpp:192
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define INTR_CONTROL_CONTROLLER_ENABLE
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT LowerDevice
Definition: hdaudbus.h:68
#define HDAC_STATE_STATUS
BOOLEAN NTAPI HDA_InterruptService(IN PKINTERRUPT Interrupt, IN PVOID ServiceContext)
Definition: fdo.cpp:12
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define HDA_MAX_CODECS
Definition: driver.h:41
unsigned short USHORT
Definition: pedump.c:61
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
unsigned int * PULONG
Definition: retypes.h:1
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define DPRINT1
Definition: precomp.h:8
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
unsigned int ULONG
Definition: retypes.h:1
NTKERNELAPI USHORT NTAPI READ_REGISTER_USHORT(IN PUSHORT Register)
PKINTERRUPT Interrupt
Definition: hdaudbus.h:72
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
return STATUS_SUCCESS
Definition: btrfs.c:3014
unsigned short * PUSHORT
Definition: retypes.h:2
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:95
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PVOID * Descriptor
Definition: classpnp.h:1159

Referenced by HDA_FdoPnp().

◆ HDA_PDOHandleQueryDeviceText()

NTSTATUS HDA_PDOHandleQueryDeviceText ( IN PIRP  Irp)

Definition at line 154 of file pdo.cpp.

156 {
157  PIO_STACK_LOCATION IoStack;
158  LPWSTR Buffer;
159  static WCHAR DeviceText[] = L"Audio Device on High Definition Audio Bus";
160 
162  if (IoStack->Parameters.QueryDeviceText.DeviceTextType == DeviceTextDescription)
163  {
164  DPRINT("HDA_PdoHandleQueryDeviceText DeviceTextDescription\n");
165 
166  Buffer = (LPWSTR)AllocateItem(PagedPool, sizeof(DeviceText));
167  if (!Buffer)
168  {
169  Irp->IoStatus.Information = 0;
171  }
172 
173  wcscpy(Buffer, DeviceText);
174 
175  Irp->IoStatus.Information = (ULONG_PTR)Buffer;
176  return STATUS_SUCCESS;
177  }
178  else
179  {
180  DPRINT("HDA_PdoHandleQueryDeviceText DeviceTextLocationInformation\n");
181 
182  Buffer = (LPWSTR)AllocateItem(PagedPool, sizeof(DeviceText));
183  if (!Buffer)
184  {
185  Irp->IoStatus.Information = 0;
187  }
188 
189  wcscpy(Buffer, DeviceText);
190 
191  /* save result */
192  Irp->IoStatus.Information = (ULONG_PTR)Buffer;
193  return STATUS_SUCCESS;
194  }
195 
196 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define ULONG_PTR
Definition: config.h:101
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by HDA_PdoPnp().

◆ HDA_PDOHandleQueryInterface()

NTSTATUS HDA_PDOHandleQueryInterface ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 299 of file businterface.cpp.

302 {
303  PIO_STACK_LOCATION IoStack;
304  PHDAUDIO_BUS_INTERFACE_V2 InterfaceHDA;
305  PHDA_PDO_DEVICE_EXTENSION DeviceExtension;
306 
307  /* get device extension */
308  DeviceExtension = (PHDA_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
309  ASSERT(DeviceExtension->IsFDO == FALSE);
310 
312 
313  if (IsEqualGUIDAligned(*IoStack->Parameters.QueryInterface.InterfaceType, GUID_HDAUDIO_BUS_INTERFACE))
314  {
315  InterfaceHDA = (PHDAUDIO_BUS_INTERFACE_V2)IoStack->Parameters.QueryInterface.Interface;
316  InterfaceHDA->Version = IoStack->Parameters.QueryInterface.Version;
317  InterfaceHDA->Size = sizeof(HDAUDIO_BUS_INTERFACE);
318  InterfaceHDA->Context = DeviceExtension;
321 
327  InterfaceHDA->FreeDmaBuffer = HDA_FreeDmaBuffer;
328  InterfaceHDA->FreeDmaEngine = HDA_FreeDmaEngine;
336  return STATUS_SUCCESS;
337  }
338  else if (IsEqualGUIDAligned(*IoStack->Parameters.QueryInterface.InterfaceType, GUID_HDAUDIO_BUS_INTERFACE_V2))
339  {
340  InterfaceHDA = (PHDAUDIO_BUS_INTERFACE_V2)IoStack->Parameters.QueryInterface.Interface;
341  InterfaceHDA->Version = IoStack->Parameters.QueryInterface.Version;
342  InterfaceHDA->Size = sizeof(HDAUDIO_BUS_INTERFACE_V2);
343  InterfaceHDA->Context = DeviceExtension;
346 
352  InterfaceHDA->FreeDmaBuffer = HDA_FreeDmaBuffer;
353  InterfaceHDA->FreeDmaEngine = HDA_FreeDmaEngine;
361 
366  }
367 
368  // FIXME
369  // implement support for GUID_HDAUDIO_BUS_INTERFACE_BDL
371  return STATUS_NOT_SUPPORTED;
372 }
PFREE_DMA_BUFFER FreeDmaBuffer
Definition: hdaudio.h:359
NTSTATUS NTAPI HDA_AllocateCaptureDmaEngine(IN PVOID _context, IN UCHAR CodecAddress, IN PHDAUDIO_STREAM_FORMAT StreamFormat, OUT PHANDLE Handle, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
_In_ PIRP Irp
Definition: csq.h:116
VOID NTAPI HDA_InterfaceReference(PVOID BusContext)
PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine
Definition: hdaudio.h:356
struct HDA_PDO_DEVICE_EXTENSION * PHDA_PDO_DEVICE_EXTENSION
NTSTATUS NTAPI HDA_AllocateDmaBufferWithNotification(IN PVOID _context, IN HANDLE Handle, IN ULONG NotificationCount, IN SIZE_T RequestedBufferSize, OUT PMDL *BufferMdl, OUT PSIZE_T AllocatedBufferSize, OUT PSIZE_T OffsetFromFirstPage, OUT PUCHAR StreamId, OUT PULONG FifoSize)
PSET_DMA_ENGINE_STATE SetDmaEngineState
Definition: hdaudio.h:361
PGET_LINK_POSITION_REGISTER GetLinkPositionRegister
Definition: hdaudio.h:363
PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation
Definition: hdaudio.h:357
NTSTATUS NTAPI HDA_TransferCodecVerbs(IN PVOID _context, IN ULONG Count, IN OUT PHDAUDIO_CODEC_TRANSFER CodecTransfer, IN PHDAUDIO_TRANSFER_COMPLETE_CALLBACK Callback, IN PVOID Context)
NTSTATUS NTAPI HDA_SetDmaEngineState(IN PVOID _context, IN HDAUDIO_STREAM_STATE StreamState, IN ULONG NumberOfHandles, IN PHANDLE Handles)
PUNREGISTER_NOTIFICATION_EVENT UnregisterNotificationEvent
Definition: hdaudio.h:371
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:240
PINTERFACE_REFERENCE InterfaceReference
Definition: hdaudio.h:352
NTSTATUS NTAPI HDA_FreeDmaBufferWithNotification(IN PVOID _context, IN HANDLE Handle, IN PMDL BufferMdl, IN SIZE_T BufferSize)
VOID NTAPI HDA_GetWallClockRegister(IN PVOID _context, OUT PULONG *Wallclock)
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI HDA_UnregisterNotificationEvent(IN PVOID _context, IN HANDLE Handle, IN PKEVENT NotificationEvent)
PALLOCATE_DMA_BUFFER AllocateDmaBuffer
Definition: hdaudio.h:358
PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback
Definition: hdaudio.h:365
NTSTATUS NTAPI HDA_UnregisterEventCallback(IN PVOID _context, IN UCHAR Tag)
NTSTATUS NTAPI HDA_AllocateRenderDmaEngine(IN PVOID _context, IN PHDAUDIO_STREAM_FORMAT StreamFormat, IN BOOLEAN Stripe, OUT PHANDLE Handle, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
NTSTATUS NTAPI HDA_FreeDmaBuffer(IN PVOID _context, IN HANDLE Handle)
PGET_DEVICE_INFORMATION GetDeviceInformation
Definition: hdaudio.h:366
VOID NTAPI HDA_InterfaceDereference(PVOID BusContext)
PFREE_DMA_ENGINE FreeDmaEngine
Definition: hdaudio.h:360
PREGISTER_NOTIFICATION_EVENT RegisterNotificationEvent
Definition: hdaudio.h:370
NTSTATUS NTAPI HDA_ChangeBandwidthAllocation(IN PVOID _context, IN HANDLE Handle, IN PHDAUDIO_STREAM_FORMAT StreamFormat, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
VOID NTAPI HDA_GetResourceInformation(IN PVOID _context, OUT PUCHAR CodecAddress, OUT PUCHAR FunctionGroupStartNode)
NTSTATUS NTAPI HDA_FreeDmaEngine(IN PVOID _context, IN HANDLE Handle)
PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine
Definition: hdaudio.h:355
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PTRANSFER_CODEC_VERBS TransferCodecVerbs
Definition: hdaudio.h:354
PGET_RESOURCE_INFORMATION GetResourceInformation
Definition: hdaudio.h:367
NTSTATUS NTAPI HDA_AllocateDmaBuffer(IN PVOID _context, IN HANDLE Handle, IN SIZE_T RequestedBufferSize, OUT PMDL *BufferMdl, OUT PSIZE_T AllocatedBufferSize, OUT PUCHAR StreamId, OUT PULONG FifoSize)
NTSTATUS NTAPI HDA_RegisterNotificationEvent(PVOID _context, HANDLE Handle, IN PKEVENT NotificationEvent)
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: hdaudio.h:353
NTSTATUS NTAPI HDA_GetDeviceInformation(IN PVOID _context, OUT PHDAUDIO_DEVICE_INFORMATION DeviceInformation)
PREGISTER_EVENT_CALLBACK RegisterEventCallback
Definition: hdaudio.h:364
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PALLOCATE_DMA_BUFFER_WITH_NOTIFICATION AllocateDmaBufferWithNotification
Definition: hdaudio.h:368
PFREE_DMA_BUFFER_WITH_NOTIFICATION FreeDmaBufferWithNotification
Definition: hdaudio.h:369
PGET_WALL_CLOCK_REGISTER GetWallClockRegister
Definition: hdaudio.h:362
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
NTSTATUS NTAPI HDA_RegisterEventCallback(IN PVOID _context, IN PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK Routine, IN PVOID Context, OUT PUCHAR Tag)
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define UNIMPLEMENTED
Definition: debug.h:115
struct _HDAUDIO_BUS_INTERFACE_V2 * PHDAUDIO_BUS_INTERFACE_V2
NTSTATUS NTAPI HDA_GetLinkPositionRegister(IN PVOID _context, IN HANDLE Handle, OUT PULONG *Position)
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by HDA_PdoPnp().

◆ HDA_PDOQueryBusDeviceCapabilities()

NTSTATUS HDA_PDOQueryBusDeviceCapabilities ( IN PIRP  Irp)

Definition at line 199 of file pdo.cpp.

201 {
203  PIO_STACK_LOCATION IoStack;
204 
205  /* get stack location */
207 
208  /* get capabilities */
209  Capabilities = IoStack->Parameters.DeviceCapabilities.Capabilities;
210 
212 
213  /* setup capabilities */
214  Capabilities->UniqueID = TRUE;
215  Capabilities->SilentInstall = TRUE;
216  Capabilities->SurpriseRemovalOK = TRUE;
217  Capabilities->Address = 0;
218  Capabilities->UINumber = 0;
219  Capabilities->SystemWake = PowerSystemWorking; /* FIXME common device extension */
220  Capabilities->DeviceWake = PowerDeviceD0;
221 
222  /* done */
223  return STATUS_SUCCESS;
224 }
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
DEVICE_CAPABILITIES
Definition: iotypes.h:948
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
* PDEVICE_CAPABILITIES
Definition: iotypes.h:948
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by HDA_PdoPnp().

◆ HDA_PDOQueryBusDevicePnpState()

NTSTATUS HDA_PDOQueryBusDevicePnpState ( IN PIRP  Irp)

Definition at line 227 of file pdo.cpp.

229 {
230  /* set device flags */
232 
233  /* done */
234  return STATUS_SUCCESS;
235 }
_In_ PIRP Irp
Definition: csq.h:116
#define PNP_DEVICE_DONT_DISPLAY_IN_UI
Definition: iotypes.h:985
#define PNP_DEVICE_NOT_DISABLEABLE
Definition: iotypes.h:989
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by HDA_PdoPnp().

◆ HDA_PDOQueryBusInformation()

NTSTATUS HDA_PDOQueryBusInformation ( IN PIRP  Irp)

Definition at line 33 of file pdo.cpp.

35 {
36  PPNP_BUS_INFORMATION BusInformation;
37 
38  /* allocate bus information */
40 
41  if (!BusInformation)
42  {
43  /* no memory */
45  }
46 
47  /* return info */
48  BusInformation->BusNumber = 0;
49  BusInformation->LegacyBusType = PCIBus;
50  RtlMoveMemory(&BusInformation->BusTypeGuid, &GUID_HDAUDIO_BUS_INTERFACE, sizeof(GUID));
51 
52  /* store result */
53  Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
54 
55  /* done */
56  return STATUS_SUCCESS;
57 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
struct _PNP_BUS_INFORMATION * PPNP_BUS_INFORMATION
#define ULONG_PTR
Definition: config.h:101
return STATUS_SUCCESS
Definition: btrfs.c:3014
INTERFACE_TYPE LegacyBusType
Definition: cmtypes.h:365

Referenced by HDA_PdoPnp().

◆ HDA_PDOQueryId()

NTSTATUS NTAPI HDA_PDOQueryId ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 62 of file pdo.cpp.

65 {
66  PIO_STACK_LOCATION IoStack;
67  WCHAR DeviceName[200];
68  PHDA_PDO_DEVICE_EXTENSION DeviceExtension;
69  ULONG Length;
70  LPWSTR Device;
72 
73  /* get device extension */
74  DeviceExtension = (PHDA_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
75  ASSERT(DeviceExtension->IsFDO == FALSE);
76 
77  /* get current irp stack location */
79 
80  if (IoStack->Parameters.QueryId.IdType == BusQueryInstanceID)
81  {
83  sizeof(DeviceName),
84  L"%02x%02x",
85  DeviceExtension->Codec->Addr,
86  DeviceExtension->AudioGroup->NodeId);
88  Length = wcslen(DeviceName) + 1;
89 
90  /* allocate result buffer*/
92  if (!Device)
94 
96  Length * sizeof(WCHAR),
97  DeviceName);
99 
100  DPRINT1("ID: %S\n", Device);
101  /* store result */
102  Irp->IoStatus.Information = (ULONG_PTR)Device;
103  return STATUS_SUCCESS;
104  }
105  else if (IoStack->Parameters.QueryId.IdType == BusQueryDeviceID ||
106  IoStack->Parameters.QueryId.IdType == BusQueryHardwareIDs)
107  {
108 
109  /* calculate size */
110  swprintf(DeviceName, L"HDAUDIO\\FUNC_%02X&VEN_%04X&DEV_%04X&SUBSYS_%08X", DeviceExtension->AudioGroup->FunctionGroup, DeviceExtension->Codec->VendorId, DeviceExtension->Codec->ProductId, DeviceExtension->Codec->VendorId << 16 | DeviceExtension->Codec->ProductId);
111  Length = wcslen(DeviceName) + 20;
112 
113  /* allocate result buffer*/
115  if (!Device)
117 
119 
120  DPRINT1("ID: %S\n", Device);
121  /* store result */
122  Irp->IoStatus.Information = (ULONG_PTR)Device;
123  return STATUS_SUCCESS;
124  }
125  else if (IoStack->Parameters.QueryId.IdType == BusQueryCompatibleIDs)
126  {
128  Length = swprintf(DeviceName, L"HDAUDIO\\FUNC_%02X&VEN_%04X&DEV_%04X&REV_%04X", DeviceExtension->AudioGroup->FunctionGroup, DeviceExtension->Codec->VendorId, DeviceExtension->Codec->ProductId, DeviceExtension->Codec->Major << 12 | DeviceExtension->Codec->Minor << 8 | DeviceExtension->Codec->Revision) + 1;
129  Length += swprintf(&DeviceName[Length], L"HDAUDIO\\FUNC_%02X&VEN_%04X&DEV_%04X", DeviceExtension->AudioGroup->FunctionGroup, DeviceExtension->Codec->VendorId, DeviceExtension->Codec->ProductId) + 1;
130  Length += swprintf(&DeviceName[Length], L"HDAUDIO\\FUNC_%02X&VEN_%04X", DeviceExtension->AudioGroup->FunctionGroup, DeviceExtension->Codec->VendorId) + 1;
131  Length += swprintf(&DeviceName[Length], L"HDAUDIO\\FUNC_%02X", DeviceExtension->AudioGroup->FunctionGroup) + 2;
132 
133  /* allocate result buffer*/
135  if (!Device)
137 
139 
140  DPRINT1("ID: %S\n", Device);
141  /* store result */
142  Irp->IoStatus.Information = (ULONG_PTR)Device;
143  return STATUS_SUCCESS;
144  }
145  else
146  {
147  DPRINT1("QueryID Type %x not implemented\n", IoStack->Parameters.QueryId.IdType);
148  return Irp->IoStatus.Status;
149  }
150  return STATUS_NOT_IMPLEMENTED;
151 }
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PHDA_CODEC_ENTRY Codec
Definition: hdaudbus.h:90
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2029
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
_In_ PIRP Irp
Definition: csq.h:116
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
struct HDA_PDO_DEVICE_EXTENSION * PHDA_PDO_DEVICE_EXTENSION
LONG NTSTATUS
Definition: precomp.h:26
WCHAR DeviceName[]
Definition: adapter.cpp:21
USHORT ProductId
Definition: hdaudbus.h:48
#define FALSE
Definition: types.h:117
UCHAR Revision
Definition: hdaudbus.h:51
UCHAR Minor
Definition: hdaudbus.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
#define swprintf(buf, format,...)
Definition: sprintf.c:56
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
UCHAR Major
Definition: hdaudbus.h:49
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
USHORT VendorId
Definition: hdaudbus.h:47
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
UCHAR Addr
Definition: hdaudbus.h:53
PHDA_CODEC_AUDIO_GROUP AudioGroup
Definition: hdaudbus.h:91
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by HDA_PdoPnp().

◆ HDA_PDORemoveDevice()

NTSTATUS HDA_PDORemoveDevice ( _In_ PDEVICE_OBJECT  DeviceObject)

Definition at line 11 of file pdo.cpp.

13 {
14  PHDA_PDO_DEVICE_EXTENSION DeviceExtension;
15 
16  /* get device extension */
17  DeviceExtension = static_cast<PHDA_PDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
18  ASSERT(DeviceExtension->IsFDO == FALSE);
19 
20  if (DeviceExtension->ReportedMissing)
21  {
22  if (DeviceExtension->AudioGroup != NULL)
23  {
24  DeviceExtension->AudioGroup->ChildPDO = NULL;
25  }
27  }
28 
29  return STATUS_SUCCESS;
30 }
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
PHDA_CODEC_AUDIO_GROUP AudioGroup
Definition: hdaudbus.h:91
PDEVICE_OBJECT ChildPDO
Definition: hdaudbus.h:40
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by HDA_FDORemoveDevice(), and HDA_PdoPnp().

◆ HDA_SendVerbs()

VOID HDA_SendVerbs ( IN PDEVICE_OBJECT  DeviceObject,
IN PHDA_CODEC_ENTRY  Codec,
IN PULONG  Verbs,
OUT PULONG  Responses,
IN ULONG  Count 
)

Definition at line 138 of file fdo.cpp.

144 {
145  PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
146  ULONG Sent = 0, ReadPosition, WritePosition, Queued;
147 
148  /* get device extension */
149  DeviceExtension = (PHDA_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
150  ASSERT(DeviceExtension->IsFDO);
151 
152  /* reset response count */
153  Codec->ResponseCount = 0;
154 
155  while (Sent < Count) {
156  ReadPosition = READ_REGISTER_USHORT((PUSHORT)(DeviceExtension->RegBase + HDAC_CORB_READ_POS));
157 
158  Queued = 0;
159 
160  while (Sent < Count) {
161  WritePosition = (DeviceExtension->CorbWritePos + 1) % DeviceExtension->CorbLength;
162 
163  if (WritePosition == ReadPosition) {
164  // There is no space left in the ring buffer; execute the
165  // queued commands and wait until
166  break;
167  }
168 
169  DeviceExtension->CorbBase[WritePosition] = Verbs[Sent++];
170  DeviceExtension->CorbWritePos = WritePosition;
171  Queued++;
172  }
173 
174  WRITE_REGISTER_USHORT((PUSHORT)(DeviceExtension->RegBase + HDAC_CORB_WRITE_POS), DeviceExtension->CorbWritePos);
175  }
176 
177  while (Queued--)
178  {
179  KeWaitForSingleObject(&Codec->ResponseSemaphore,
180  Executive,
181  KernelMode,
182  FALSE,
183  NULL);
184  }
185 
186  if (Responses != NULL) {
187  memcpy(Responses, Codec->Responses, Codec->ResponseCount * sizeof(ULONG));
188  }
189 }
struct HDA_FDO_DEVICE_EXTENSION * PHDA_FDO_DEVICE_EXTENSION
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1223
NTKERNELAPI VOID NTAPI WRITE_REGISTER_USHORT(IN PUSHORT Register, IN USHORT Value)
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define HDAC_CORB_WRITE_POS
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
UINT Sent
Definition: arping.c:39
#define HDAC_CORB_READ_POS
unsigned int ULONG
Definition: retypes.h:1
NTKERNELAPI USHORT NTAPI READ_REGISTER_USHORT(IN PUSHORT Register)
unsigned short * PUSHORT
Definition: retypes.h:2

Referenced by HDA_InitCodec(), and HDA_TransferCodecVerbs().

Variable Documentation

◆ HDA_DpcForIsr

IO_DPC_ROUTINE HDA_DpcForIsr

Definition at line 122 of file hdaudbus.h.

Referenced by HDA_AddDevice().

◆ HDA_InterruptService

KSERVICE_ROUTINE HDA_InterruptService

Definition at line 121 of file hdaudbus.h.