ReactOS  0.4.15-dev-2993-g14fbe80
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)
 
NTSTATUS 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:1035
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ FreeItem()

VOID FreeItem ( IN PVOID  Item)

Definition at line 43 of file misc.c.

45 {
47 }
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
#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 760 of file fdo.cpp.

763 {
764  ULONG DeviceCount, CodecIndex, AFGIndex;
765  PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
766  PHDA_CODEC_ENTRY Codec;
767  PDEVICE_RELATIONS DeviceRelations;
768 
769  /* get device extension */
770  DeviceExtension = (PHDA_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
771  ASSERT(DeviceExtension->IsFDO == TRUE);
772 
773  DeviceCount = 0;
774  for (CodecIndex = 0; CodecIndex < HDA_MAX_CODECS; CodecIndex++)
775  {
776  if (DeviceExtension->Codecs[CodecIndex] == NULL)
777  continue;
778 
779  Codec = DeviceExtension->Codecs[CodecIndex];
780  DeviceCount += Codec->AudioGroupCount;
781  }
782 
783  if (DeviceCount == 0)
784  return STATUS_UNSUCCESSFUL;
785 
786  DeviceRelations = (PDEVICE_RELATIONS)AllocateItem(NonPagedPool, sizeof(DEVICE_RELATIONS) + (DeviceCount > 1 ? sizeof(PDEVICE_OBJECT) * (DeviceCount - 1) : 0));
787  if (!DeviceRelations)
789 
790  DeviceRelations->Count = 0;
791  for (CodecIndex = 0; CodecIndex < HDA_MAX_CODECS; CodecIndex++)
792  {
793  if (DeviceExtension->Codecs[CodecIndex] == NULL)
794  continue;
795 
796  Codec = DeviceExtension->Codecs[CodecIndex];
798  for (AFGIndex = 0; AFGIndex < Codec->AudioGroupCount; AFGIndex++)
799  {
800  DeviceRelations->Objects[DeviceRelations->Count] = Codec->AudioGroups[AFGIndex]->ChildPDO;
801  ObReferenceObject(Codec->AudioGroups[AFGIndex]->ChildPDO);
802  DeviceRelations->Count++;
803  }
804  }
805 
806  /* FIXME handle existing device relations */
807  ASSERT(Irp->IoStatus.Information == 0);
808 
809  /* store device relations */
810  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
811 
812  /* done */
813  return STATUS_SUCCESS;
814 }
#define HDA_MAX_AUDIO_GROUPS
Definition: driver.h:40
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TRUE
Definition: types.h:120
struct _DEVICE_OBJECT * PDEVICE_OBJECT
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
struct HDA_FDO_DEVICE_EXTENSION * PHDA_FDO_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
PHDA_CODEC_ENTRY Codecs[HDA_MAX_CODECS+1]
Definition: hdaudbus.h:82
_In_ PIRP Irp
Definition: csq.h:116
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
#define ASSERT(a)
Definition: mode.c:44
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Definition: hdaudbus.h:45
#define HDA_MAX_CODECS
Definition: driver.h:41
#define NULL
Definition: types.h:112
#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
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by HDA_FdoPnp().

◆ HDA_FDORemoveDevice()

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

Definition at line 692 of file fdo.cpp.

695 {
697  PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
698  ULONG CodecIndex, AFGIndex;
699  PHDA_CODEC_ENTRY CodecEntry;
700  PDEVICE_OBJECT ChildPDO;
701  PHDA_PDO_DEVICE_EXTENSION ChildDeviceExtension;
702 
703  /* get device extension */
704  DeviceExtension = static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
705  ASSERT(DeviceExtension->IsFDO == TRUE);
706 
707  Irp->IoStatus.Status = STATUS_SUCCESS;
709  Status = IoCallDriver(DeviceExtension->LowerDevice, Irp);
710 
711  IoDetachDevice(DeviceExtension->LowerDevice);
712 
713  if (DeviceExtension->RegBase != NULL)
714  {
715  MmUnmapIoSpace(DeviceExtension->RegBase,
716  DeviceExtension->RegLength);
717  }
718  if (DeviceExtension->Interrupt != NULL)
719  {
720  IoDisconnectInterrupt(DeviceExtension->Interrupt);
721  }
722  if (DeviceExtension->CorbBase != NULL)
723  {
724  MmFreeContiguousMemory(DeviceExtension->CorbBase);
725  }
726 
727  for (CodecIndex = 0; CodecIndex < HDA_MAX_CODECS; CodecIndex++)
728  {
729  CodecEntry = DeviceExtension->Codecs[CodecIndex];
730  if (CodecEntry == NULL)
731  {
732  continue;
733  }
734 
736  for (AFGIndex = 0; AFGIndex < CodecEntry->AudioGroupCount; AFGIndex++)
737  {
738  ChildPDO = CodecEntry->AudioGroups[AFGIndex]->ChildPDO;
739  if (ChildPDO != NULL)
740  {
741  ChildDeviceExtension = static_cast<PHDA_PDO_DEVICE_EXTENSION>(ChildPDO->DeviceExtension);
742  ChildDeviceExtension->Codec = NULL;
743  ChildDeviceExtension->AudioGroup = NULL;
744  ChildDeviceExtension->FDO = NULL;
745  ChildDeviceExtension->ReportedMissing = TRUE;
746  HDA_PDORemoveDevice(ChildPDO);
747  }
748  FreeItem(CodecEntry->AudioGroups[AFGIndex]);
749  }
750  FreeItem(CodecEntry);
751  }
752 
754 
755  return Status;
756 }
#define HDA_MAX_AUDIO_GROUPS
Definition: driver.h:40
PHDA_CODEC_ENTRY Codec
Definition: hdaudbus.h:90
#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
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
PHDA_CODEC_ENTRY Codecs[HDA_MAX_CODECS+1]
Definition: hdaudbus.h:82
_In_ PIRP Irp
Definition: csq.h:116
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
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:140
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
NTSTATUS HDA_PDORemoveDevice(_In_ PDEVICE_OBJECT DeviceObject)
Definition: pdo.cpp:11
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
#define NULL
Definition: types.h:112
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
#define STATUS_SUCCESS
Definition: shellext.h:65
PKINTERRUPT Interrupt
Definition: hdaudbus.h:72

Referenced by HDA_FdoPnp().

◆ HDA_FDOStartDevice()

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

Definition at line 578 of file fdo.cpp.

581 {
582  PIO_STACK_LOCATION IoStack;
584  PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
586  ULONG Index;
587  USHORT Value;
588 
589  /* get device extension */
590  DeviceExtension = (PHDA_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
591  ASSERT(DeviceExtension->IsFDO == TRUE);
592 
593  /* forward irp to lower device */
594  if (!IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
595  {
596  ASSERT(FALSE);
598  }
599  Status = Irp->IoStatus.Status;
600  if (!NT_SUCCESS(Status))
601  {
602  // failed to start
603  DPRINT1("HDA_StartDevice Lower device failed to start %x\n", Status);
604  return Status;
605  }
606 
607  /* get current irp stack location */
609 
610  Resources = IoStack->Parameters.StartDevice.AllocatedResourcesTranslated;
611  for (Index = 0; Index < Resources->List[0].PartialResourceList.Count; Index++)
612  {
613  PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor = &Resources->List[0].PartialResourceList.PartialDescriptors[Index];
614 
615  if (Descriptor->Type == CmResourceTypeMemory)
616  {
617  DeviceExtension->RegLength = Descriptor->u.Memory.Length;
618  DeviceExtension->RegBase = (PUCHAR)MmMapIoSpace(Descriptor->u.Memory.Start, Descriptor->u.Memory.Length, MmNonCached);
619  if (DeviceExtension->RegBase == NULL)
620  {
621  DPRINT1("[HDAB] Failed to map registers\n");
623  break;
624  }
625  }
626  else if (Descriptor->Type == CmResourceTypeInterrupt)
627  {
628  Status = IoConnectInterrupt(&DeviceExtension->Interrupt,
630  DeviceObject,
631  NULL,
632  Descriptor->u.Interrupt.Vector,
633  Descriptor->u.Interrupt.Level,
634  Descriptor->u.Interrupt.Level,
636  (Descriptor->ShareDisposition != CmResourceShareDeviceExclusive),
637  Descriptor->u.Interrupt.Affinity,
638  FALSE);
639  if (!NT_SUCCESS(Status))
640  {
641  DPRINT1("[HDAB] Failed to connect interrupt. Status=%lx\n", Status);
642  break;
643  }
644 
645  }
646  }
647 
648  if (NT_SUCCESS(Status))
649  {
650  // Get controller into valid state
652  if (!NT_SUCCESS(Status)) return Status;
653 
654  // Setup CORB/RIRB/DMA POS
656  if (!NT_SUCCESS(Status)) return Status;
657 
658 
659  // Don't enable codec state change interrupts. We don't handle
660  // them, as we want to use the STATE_STATUS register to identify
661  // available codecs. We'd have to clear that register in the interrupt
662  // handler to 'ack' the codec change.
665 
666  // Enable controller interrupts
668 
670 
672  if (!Value) {
673  DPRINT1("hda: bad codec status\n");
674  return STATUS_UNSUCCESSFUL;
675  }
677 
678  // Create codecs
679  DPRINT1("Codecs %lx\n", Value);
680  for (Index = 0; Index < HDA_MAX_CODECS; Index++) {
681  if ((Value & (1 << Index)) != 0) {
683  }
684  }
685  }
686 
687  return Status;
688 }
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
#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:468
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
NTSTATUS NTAPI HDA_InitCorbRirbPos(IN PDEVICE_OBJECT DeviceObject)
Definition: fdo.cpp:321
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
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
enum _KINTERRUPT_MODE KINTERRUPT_MODE
#define INTR_CONTROL_GLOBAL_ENABLE
#define HDAC_WAKE_ENABLE_MASK
WDF_EXTERN_C_START typedef _In_ WDFCMRESLIST Resources
Definition: wdfpdo.h:63
NTSTATUS HDA_InitCodec(IN PDEVICE_OBJECT DeviceObject, IN ULONG codecAddress)
Definition: fdo.cpp:203
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define INTR_CONTROL_CONTROLLER_ENABLE
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:2793
#define HDA_MAX_CODECS
Definition: driver.h:41
unsigned short USHORT
Definition: pedump.c:61
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
#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)
#define STATUS_SUCCESS
Definition: shellext.h:65
PKINTERRUPT Interrupt
Definition: hdaudbus.h:72
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
unsigned short * PUSHORT
Definition: retypes.h:2
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:96

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 BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
_In_ PIRP Irp
Definition: csq.h:116
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:2793
#define ULONG_PTR
Definition: config.h:101
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128

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
return STATUS_NOT_SUPPORTED
NTSTATUS NTAPI HDA_AllocateCaptureDmaEngine(IN PVOID _context, IN UCHAR CodecAddress, IN PHDAUDIO_STREAM_FORMAT StreamFormat, OUT PHANDLE Handle, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
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
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
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
_In_ PIRP Irp
Definition: csq.h:116
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)
#define ASSERT(a)
Definition: mode.c:44
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
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:2793
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
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 UNIMPLEMENTED
Definition: debug.h:115
struct _HDAUDIO_BUS_INTERFACE_V2 * PHDAUDIO_BUS_INTERFACE_V2
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS NTAPI HDA_GetLinkPositionRegister(IN PVOID _context, IN HANDLE Handle, OUT PULONG *Position)
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128

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 }
#define TRUE
Definition: types.h:120
DEVICE_CAPABILITIES
Definition: iotypes.h:965
_In_ PIRP Irp
Definition: csq.h:116
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128

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 }
#define PNP_DEVICE_DONT_DISPLAY_IN_UI
Definition: iotypes.h:1002
_In_ PIRP Irp
Definition: csq.h:116
#define PNP_DEVICE_NOT_DISABLEABLE
Definition: iotypes.h:1006
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by HDA_PdoPnp().

◆ HDA_PDOQueryBusInformation()

NTSTATUS HDA_PDOQueryBusInformation ( IN PIRP  Irp)

Definition at line 33 of file pdo.cpp.

35 {
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
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_In_ PIRP Irp
Definition: csq.h:116
struct _PNP_BUS_INFORMATION * PPNP_BUS_INFORMATION
#define ULONG_PTR
Definition: config.h:101
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ WDFDEVICE _In_ PPNP_BUS_INFORMATION BusInformation
Definition: wdfdevice.h:3912

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
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
PHDA_CODEC_ENTRY Codec
Definition: hdaudbus.h:90
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
#define swprintf
Definition: precomp.h:40
USHORT ProductId
Definition: hdaudbus.h:48
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
UCHAR Revision
Definition: hdaudbus.h:51
UCHAR Minor
Definition: hdaudbus.h:50
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
__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
_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
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
UCHAR Major
Definition: hdaudbus.h:49
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
USHORT VendorId
Definition: hdaudbus.h:47
UCHAR Addr
Definition: hdaudbus.h:53
PHDA_CODEC_AUDIO_GROUP AudioGroup
Definition: hdaudbus.h:91
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#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
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define NT_ASSERT
Definition: rtlfuncs.h:3310

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 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define NULL
Definition: types.h:112
PHDA_CODEC_AUDIO_GROUP AudioGroup
Definition: hdaudbus.h:91
PDEVICE_OBJECT ChildPDO
Definition: hdaudbus.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by HDA_FDORemoveDevice(), and HDA_PdoPnp().

◆ HDA_SendVerbs()

NTSTATUS 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  {
180  Timeout.QuadPart = -1000LL * 10000; // 1 sec
181 
182  NTSTATUS waitStatus = KeWaitForSingleObject(&Codec->ResponseSemaphore,
183  Executive,
184  KernelMode,
185  FALSE,
186  &Timeout);
187 
188  if (waitStatus == STATUS_TIMEOUT)
189  {
190  DPRINT1("HDA_SendVerbs: timeout! Queued: %u\n", Queued);
192  }
193  }
194 
195  if (Responses != NULL) {
196  memcpy(Responses, Codec->Responses, Codec->ResponseCount * sizeof(ULONG));
197  }
198 
199  return STATUS_SUCCESS;
200 }
#define LL
Definition: tui.h:84
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)
if(dx==0 &&dy==0)
Definition: linetemp.h:174
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 STATUS_TIMEOUT
Definition: ntstatus.h:81
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
int Count
Definition: noreturn.cpp:7
#define ASSERT(a)
Definition: mode.c:44
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define HDAC_CORB_WRITE_POS
static ULONG Timeout
Definition: ping.c:61
#define NULL
Definition: types.h:112
UINT Sent
Definition: arping.c:39
#define DPRINT1
Definition: precomp.h:8
#define HDAC_CORB_READ_POS
unsigned int ULONG
Definition: retypes.h:1
NTKERNELAPI USHORT NTAPI READ_REGISTER_USHORT(IN PUSHORT Register)
#define STATUS_SUCCESS
Definition: shellext.h:65
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.