ReactOS 0.4.15-dev-8100-g1887773
hdaudbus.h File Reference
#include <ntddk.h>
#include <initguid.h>
#include <hdaudio.h>
#include <stdio.h>
#include <ntstrsafe.h>
#include "driver.h"
#include <debug.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 NDEBUG
 
#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.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file hdaudbus.h.

◆ TAG_HDA

#define TAG_HDA   'bADH'

Definition at line 15 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 29 of file misc.c.

32{
33 return ExAllocatePoolZero(PoolType, NumberOfBytes, TAG_KS);
34}
#define TAG_KS
Definition: misc.c:14
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036

◆ FreeItem()

VOID FreeItem ( IN PVOID  Item)

Definition at line 37 of file misc.c.

39{
41}
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_In_ WDFCOLLECTION _In_ WDFOBJECT Item

◆ HDA_FDOQueryBusRelations()

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

Definition at line 761 of file fdo.cpp.

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

Referenced by HDA_FdoPnp().

◆ HDA_FDORemoveDevice()

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

Definition at line 693 of file fdo.cpp.

696{
698 PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
699 ULONG CodecIndex, AFGIndex;
700 PHDA_CODEC_ENTRY CodecEntry;
701 PDEVICE_OBJECT ChildPDO;
702 PHDA_PDO_DEVICE_EXTENSION ChildDeviceExtension;
703
704 /* get device extension */
705 DeviceExtension = static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
706 ASSERT(DeviceExtension->IsFDO == TRUE);
707
708 Irp->IoStatus.Status = STATUS_SUCCESS;
710 Status = IoCallDriver(DeviceExtension->LowerDevice, Irp);
711
712 IoDetachDevice(DeviceExtension->LowerDevice);
713
714 if (DeviceExtension->RegBase != NULL)
715 {
716 MmUnmapIoSpace(DeviceExtension->RegBase,
717 DeviceExtension->RegLength);
718 }
719 if (DeviceExtension->Interrupt != NULL)
720 {
721 IoDisconnectInterrupt(DeviceExtension->Interrupt);
722 }
723 if (DeviceExtension->CorbBase != NULL)
724 {
725 MmFreeContiguousMemory(DeviceExtension->CorbBase);
726 }
727
728 for (CodecIndex = 0; CodecIndex < HDA_MAX_CODECS; CodecIndex++)
729 {
730 CodecEntry = DeviceExtension->Codecs[CodecIndex];
731 if (CodecEntry == NULL)
732 {
733 continue;
734 }
735
737 for (AFGIndex = 0; AFGIndex < CodecEntry->AudioGroupCount; AFGIndex++)
738 {
739 ChildPDO = CodecEntry->AudioGroups[AFGIndex]->ChildPDO;
740 if (ChildPDO != NULL)
741 {
742 ChildDeviceExtension = static_cast<PHDA_PDO_DEVICE_EXTENSION>(ChildPDO->DeviceExtension);
743 ChildDeviceExtension->Codec = NULL;
744 ChildDeviceExtension->AudioGroup = NULL;
745 ChildDeviceExtension->FDO = NULL;
746 ChildDeviceExtension->ReportedMissing = TRUE;
747 HDA_PDORemoveDevice(ChildPDO);
748 }
749 FreeItem(CodecEntry->AudioGroups[AFGIndex]);
750 }
751 FreeItem(CodecEntry);
752 }
753
755
756 return Status;
757}
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI MmFreeContiguousMemory(IN PVOID BaseAddress)
Definition: contmem.c:653
Status
Definition: gdiplustypes.h:25
NTSTATUS HDA_PDORemoveDevice(_In_ PDEVICE_OBJECT DeviceObject)
Definition: pdo.cpp:11
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
VOID FreeItem(IN PVOID Item)
Definition: misc.c:37
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define IoCallDriver
Definition: irp.c:1225
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:142
PDEVICE_OBJECT LowerDevice
Definition: hdaudbus.h:66
PKINTERRUPT Interrupt
Definition: hdaudbus.h:70
PHDA_CODEC_AUDIO_GROUP AudioGroup
Definition: hdaudbus.h:89
PHDA_CODEC_ENTRY Codec
Definition: hdaudbus.h:88
PDEVICE_OBJECT FDO
Definition: hdaudbus.h:90
PVOID DeviceExtension
Definition: env_spec_w32.h:418

Referenced by HDA_FdoPnp().

◆ HDA_FDOStartDevice()

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

Definition at line 579 of file fdo.cpp.

582{
583 PIO_STACK_LOCATION IoStack;
585 PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
587 ULONG Index;
589
590 /* get device extension */
591 DeviceExtension = (PHDA_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
592 ASSERT(DeviceExtension->IsFDO == TRUE);
593
594 /* forward irp to lower device */
595 if (!IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
596 {
597 ASSERT(FALSE);
599 }
600 Status = Irp->IoStatus.Status;
601 if (!NT_SUCCESS(Status))
602 {
603 // failed to start
604 DPRINT1("HDA_StartDevice Lower device failed to start %x\n", Status);
605 return Status;
606 }
607
608 /* get current irp stack location */
610
611 Resources = IoStack->Parameters.StartDevice.AllocatedResourcesTranslated;
612 for (Index = 0; Index < Resources->List[0].PartialResourceList.Count; Index++)
613 {
614 PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor = &Resources->List[0].PartialResourceList.PartialDescriptors[Index];
615
616 if (Descriptor->Type == CmResourceTypeMemory)
617 {
618 DeviceExtension->RegLength = Descriptor->u.Memory.Length;
619 DeviceExtension->RegBase = (PUCHAR)MmMapIoSpace(Descriptor->u.Memory.Start, Descriptor->u.Memory.Length, MmNonCached);
620 if (DeviceExtension->RegBase == NULL)
621 {
622 DPRINT1("[HDAB] Failed to map registers\n");
624 break;
625 }
626 }
627 else if (Descriptor->Type == CmResourceTypeInterrupt)
628 {
629 Status = IoConnectInterrupt(&DeviceExtension->Interrupt,
632 NULL,
633 Descriptor->u.Interrupt.Vector,
634 Descriptor->u.Interrupt.Level,
635 Descriptor->u.Interrupt.Level,
637 (Descriptor->ShareDisposition != CmResourceShareDeviceExclusive),
638 Descriptor->u.Interrupt.Affinity,
639 FALSE);
640 if (!NT_SUCCESS(Status))
641 {
642 DPRINT1("[HDAB] Failed to connect interrupt. Status=%lx\n", Status);
643 break;
644 }
645
646 }
647 }
648
649 if (NT_SUCCESS(Status))
650 {
651 // Get controller into valid state
653 if (!NT_SUCCESS(Status)) return Status;
654
655 // Setup CORB/RIRB/DMA POS
657 if (!NT_SUCCESS(Status)) return Status;
658
659
660 // Don't enable codec state change interrupts. We don't handle
661 // them, as we want to use the STATE_STATUS register to identify
662 // available codecs. We'd have to clear that register in the interrupt
663 // handler to 'ack' the codec change.
664 Value = READ_REGISTER_USHORT((PUSHORT)(DeviceExtension->RegBase + HDAC_WAKE_ENABLE)) & ~HDAC_WAKE_ENABLE_MASK;
666
667 // Enable controller interrupts
669
671
673 if (!Value) {
674 DPRINT1("hda: bad codec status\n");
675 return STATUS_UNSUCCESSFUL;
676 }
678
679 // Create codecs
680 DPRINT1("Codecs %lx\n", Value);
681 for (Index = 0; Index < HDA_MAX_CODECS; Index++) {
682 if ((Value & (1 << Index)) != 0) {
684 }
685 }
686 }
687
688 return Status;
689}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define WRITE_REGISTER_USHORT(r, v)
Definition: arm.h:30
#define READ_REGISTER_USHORT(r)
Definition: arm.h:29
#define WRITE_REGISTER_ULONG(r, v)
Definition: arm.h:27
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI HDA_ResetController(IN PDEVICE_OBJECT DeviceObject)
Definition: fdo.cpp:469
NTSTATUS HDA_InitCodec(IN PDEVICE_OBJECT DeviceObject, IN ULONG codecAddress)
Definition: fdo.cpp:204
NTSTATUS NTAPI HDA_InitCorbRirbPos(IN PDEVICE_OBJECT DeviceObject)
Definition: fdo.cpp:322
#define HDAC_INTR_CONTROL
#define INTR_CONTROL_GLOBAL_ENABLE
#define INTR_CONTROL_CONTROLLER_ENABLE
#define HDAC_STATE_STATUS
#define HDAC_WAKE_ENABLE
KSERVICE_ROUTINE HDA_InterruptService
Definition: hdaudbus.h:118
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1625
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:23
unsigned short USHORT
Definition: pedump.c:61
enum _KINTERRUPT_MODE KINTERRUPT_MODE
union _IO_STACK_LOCATION::@1567 Parameters
struct _IO_STACK_LOCATION::@3982::@4019 StartDevice
uint32_t * PULONG
Definition: typedefs.h:59
uint16_t * PUSHORT
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241
@ MmNonCached
Definition: mmtypes.h:129

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;
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}
Definition: bufpool.h:45
#define PagedPool
Definition: env_spec_w32.h:308
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define DPRINT
Definition: sndvol32.h:73
struct _IO_STACK_LOCATION::@3982::@4014 QueryDeviceText
@ DeviceTextDescription
Definition: iotypes.h:2945
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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
372}
#define UNIMPLEMENTED
Definition: debug.h:118
VOID NTAPI HDA_InterfaceDereference(PVOID BusContext)
VOID NTAPI HDA_GetResourceInformation(IN PVOID _context, OUT PUCHAR CodecAddress, OUT PUCHAR FunctionGroupStartNode)
NTSTATUS NTAPI HDA_UnregisterEventCallback(IN PVOID _context, IN UCHAR Tag)
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)
VOID NTAPI HDA_GetWallClockRegister(IN PVOID _context, OUT PULONG *Wallclock)
NTSTATUS NTAPI HDA_ChangeBandwidthAllocation(IN PVOID _context, IN HANDLE Handle, IN PHDAUDIO_STREAM_FORMAT StreamFormat, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
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)
NTSTATUS NTAPI HDA_RegisterEventCallback(IN PVOID _context, IN PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK Routine, IN PVOID Context, OUT PUCHAR Tag)
NTSTATUS NTAPI HDA_GetDeviceInformation(IN PVOID _context, OUT PHDAUDIO_DEVICE_INFORMATION DeviceInformation)
NTSTATUS NTAPI HDA_GetLinkPositionRegister(IN PVOID _context, IN HANDLE Handle, OUT PULONG *Position)
NTSTATUS NTAPI HDA_AllocateCaptureDmaEngine(IN PVOID _context, IN UCHAR CodecAddress, IN PHDAUDIO_STREAM_FORMAT StreamFormat, OUT PHANDLE Handle, OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
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)
NTSTATUS NTAPI HDA_UnregisterNotificationEvent(IN PVOID _context, IN HANDLE Handle, IN PKEVENT NotificationEvent)
NTSTATUS NTAPI HDA_RegisterNotificationEvent(PVOID _context, HANDLE Handle, IN PKEVENT NotificationEvent)
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_FreeDmaBufferWithNotification(IN PVOID _context, IN HANDLE Handle, IN PMDL BufferMdl, IN SIZE_T BufferSize)
NTSTATUS NTAPI HDA_FreeDmaEngine(IN PVOID _context, IN HANDLE Handle)
VOID NTAPI HDA_InterfaceReference(PVOID BusContext)
struct HDA_PDO_DEVICE_EXTENSION * PHDA_PDO_DEVICE_EXTENSION
struct _HDAUDIO_BUS_INTERFACE_V2 * PHDAUDIO_BUS_INTERFACE_V2
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine
Definition: hdaudio.h:355
PALLOCATE_DMA_BUFFER_WITH_NOTIFICATION AllocateDmaBufferWithNotification
Definition: hdaudio.h:368
PFREE_DMA_ENGINE FreeDmaEngine
Definition: hdaudio.h:360
PINTERFACE_REFERENCE InterfaceReference
Definition: hdaudio.h:352
PGET_DEVICE_INFORMATION GetDeviceInformation
Definition: hdaudio.h:366
PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation
Definition: hdaudio.h:357
PFREE_DMA_BUFFER FreeDmaBuffer
Definition: hdaudio.h:359
PUNREGISTER_NOTIFICATION_EVENT UnregisterNotificationEvent
Definition: hdaudio.h:371
PSET_DMA_ENGINE_STATE SetDmaEngineState
Definition: hdaudio.h:361
PREGISTER_EVENT_CALLBACK RegisterEventCallback
Definition: hdaudio.h:364
PREGISTER_NOTIFICATION_EVENT RegisterNotificationEvent
Definition: hdaudio.h:370
PGET_LINK_POSITION_REGISTER GetLinkPositionRegister
Definition: hdaudio.h:363
PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback
Definition: hdaudio.h:365
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: hdaudio.h:353
PTRANSFER_CODEC_VERBS TransferCodecVerbs
Definition: hdaudio.h:354
PGET_WALL_CLOCK_REGISTER GetWallClockRegister
Definition: hdaudio.h:362
PFREE_DMA_BUFFER_WITH_NOTIFICATION FreeDmaBufferWithNotification
Definition: hdaudio.h:369
PALLOCATE_DMA_BUFFER AllocateDmaBuffer
Definition: hdaudio.h:358
PGET_RESOURCE_INFORMATION GetResourceInformation
Definition: hdaudio.h:367
PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine
Definition: hdaudio.h:356
struct _IO_STACK_LOCATION::@3982::@4008 QueryInterface
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

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}
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
@ PowerSystemWorking
Definition: ntpoapi.h:36
@ PowerDeviceD0
Definition: ntpoapi.h:49
struct _IO_STACK_LOCATION::@3982::@4009 DeviceCapabilities
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
DEVICE_CAPABILITIES
Definition: iotypes.h:965
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965

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_NOT_DISABLEABLE
Definition: iotypes.h:1006
#define PNP_DEVICE_DONT_DISPLAY_IN_UI
Definition: iotypes.h:1002

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}
@ PCIBus
Definition: hwresource.cpp:142
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_In_ WDFDEVICE _In_ PPNP_BUS_INFORMATION BusInformation
Definition: wdfdevice.h:3915
struct _PNP_BUS_INFORMATION * PPNP_BUS_INFORMATION

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;
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);
89
90 /* allocate result buffer*/
92 if (!Device)
94
96 Length * sizeof(WCHAR),
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 }
151}
#define swprintf
Definition: precomp.h:40
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
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
UCHAR Revision
Definition: hdaudbus.h:50
USHORT ProductId
Definition: hdaudbus.h:47
UCHAR Major
Definition: hdaudbus.h:48
USHORT VendorId
Definition: hdaudbus.h:46
UCHAR Minor
Definition: hdaudbus.h:49
UCHAR Addr
Definition: hdaudbus.h:52
struct _IO_STACK_LOCATION::@3982::@4013 QueryId
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
@ BusQueryCompatibleIDs
Definition: iotypes.h:2938
@ BusQueryInstanceID
Definition: iotypes.h:2939
@ BusQueryDeviceID
Definition: iotypes.h:2936
@ BusQueryHardwareIDs
Definition: iotypes.h:2937
#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}

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 139 of file fdo.cpp.

145{
146 PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
147 ULONG Sent = 0, ReadPosition, WritePosition, Queued;
148
149 /* get device extension */
150 DeviceExtension = (PHDA_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
151 ASSERT(DeviceExtension->IsFDO);
152
153 /* reset response count */
154 Codec->ResponseCount = 0;
155
156 while (Sent < Count) {
157 ReadPosition = READ_REGISTER_USHORT((PUSHORT)(DeviceExtension->RegBase + HDAC_CORB_READ_POS));
158
159 Queued = 0;
160
161 while (Sent < Count) {
162 WritePosition = (DeviceExtension->CorbWritePos + 1) % DeviceExtension->CorbLength;
163
164 if (WritePosition == ReadPosition) {
165 // There is no space left in the ring buffer; execute the
166 // queued commands and wait until
167 break;
168 }
169
170 DeviceExtension->CorbBase[WritePosition] = Verbs[Sent++];
171 DeviceExtension->CorbWritePos = WritePosition;
172 Queued++;
173 }
174
175 WRITE_REGISTER_USHORT((PUSHORT)(DeviceExtension->RegBase + HDAC_CORB_WRITE_POS), DeviceExtension->CorbWritePos);
176 }
177
178 while (Queued--)
179 {
181 Timeout.QuadPart = -1000LL * 10000; // 1 sec
182
183 NTSTATUS waitStatus = KeWaitForSingleObject(&Codec->ResponseSemaphore,
184 Executive,
186 FALSE,
187 &Timeout);
188
189 if (waitStatus == STATUS_TIMEOUT)
190 {
191 DPRINT1("HDA_SendVerbs: timeout! Queued: %u\n", Queued);
193 }
194 }
195
196 if (Responses != NULL) {
197 memcpy(Responses, Codec->Responses, Codec->ResponseCount * sizeof(ULONG));
198 }
199
200 return STATUS_SUCCESS;
201}
UINT Sent
Definition: arping.c:39
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define HDAC_CORB_READ_POS
#define HDAC_CORB_WRITE_POS
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define KernelMode
Definition: asm.h:34
int Count
Definition: noreturn.cpp:7
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
static ULONG Timeout
Definition: ping.c:61
@ Executive
Definition: ketypes.h:415

Referenced by HDA_InitCodec(), and HDA_TransferCodecVerbs().

Variable Documentation

◆ HDA_DpcForIsr

IO_DPC_ROUTINE HDA_DpcForIsr

Definition at line 119 of file hdaudbus.h.

Referenced by HDA_AddDevice().

◆ HDA_InterruptService

KSERVICE_ROUTINE HDA_InterruptService

Definition at line 118 of file hdaudbus.h.

Referenced by HDA_FDOStartDevice().