19 ULONG InterruptStatus;
20 UCHAR RirbStatus, CorbStatus;
30 DPRINT(
"HDA_InterruptService %lx\n", InterruptStatus);
54 DPRINT1(
"hda: RIRB Overflow\n");
62 DPRINT1(
"hda: CORB Memory Error!\n");
68 if ((intrStatus & (1 <<
index)) != 0) {
69 if (controller->streams[
index]) {
70 if (stream_handle_interrupt(controller,
72 handled = B_INVOKE_SCHEDULER;
76 dprintf(
"hda: Stream interrupt for unconfigured stream "
110 DPRINT1(
"Response %lx ResponseFlags %lx Cad %lx\n",
Response, ResponseFlags, Cad);
113 Codec = DeviceExtension->
Codecs[Cad];
116 DPRINT1(
"hda: response for unknown codec %x Response %x ResponseFlags %x\n", Cad,
Response, ResponseFlags);
123 DPRINT1(
"too many responses for codec %x Response %x ResponseFlags %x\n", Cad,
Response, ResponseFlags);
147 ULONG Sent = 0, ReadPosition, WritePosition, Queued;
154 Codec->ResponseCount = 0;
164 if (WritePosition == ReadPosition) {
170 DeviceExtension->
CorbBase[WritePosition] = Verbs[
Sent++];
181 Timeout.QuadPart = -1000LL * 10000;
191 DPRINT1(
"HDA_SendVerbs: timeout! Queued: %u\n", Queued);
196 if (Responses !=
NULL) {
197 memcpy(Responses, Codec->Responses, Codec->ResponseCount *
sizeof(
ULONG));
212 ULONG NodeId, GroupType;
221 DPRINT1(
"hda: failed to allocate memory\n");
226 Entry->Addr = codecAddress;
256 DPRINT1(
"hda Codec %ld Vendor: %04lx Product: %04lx, Revision: %lu.%lu.%lu.%lu NodeStart %u NodeCount %u \n", codecAddress,
Response.vendor,
265 DPRINT1(
"Status %x NodeId %u GroupType %x\n",
Status, NodeId, GroupType);
273 DPRINT1(
"Too many audio groups in node %u. Skipping.\n", NodeId);
280 DPRINT1(
"hda: insufficient memory\n");
285 AudioGroup->
NodeId = NodeId;
289 DPRINT1(
"NodeId %x found an audio function group!\n", NodeId);
304 ChildDeviceExtension->
AudioGroup = AudioGroup;
312 Entry->AudioGroups[
Entry->AudioGroupCount] = AudioGroup;
313 Entry->AudioGroupCount++;
329 USHORT corbReadPointer, rirbWritePointer, interruptValue, corbControl, rirbControl;
377 HighestPhysicalAddress.
QuadPart = 0x00000000FFFFFFFF;
422 DPRINT1(
"hda: CORB read pointer reset not acknowledged\n");
432 corbReadPointer &= ~CORB_READ_POS_RESET;
441 DPRINT1(
"hda: CORB read pointer reset failed\n");
475 ULONG InputStreams, OutputStreams, BiDirStreams,
Control;
476 UCHAR corbControl, rirbControl;
488 DPRINT1(
"NumInputStreams %u\n", InputStreams);
489 DPRINT1(
"NumOutputStreams %u\n", OutputStreams);
490 DPRINT1(
"NumBiDirStreams %u\n", BiDirStreams);
521 if (corbControl == 0 && rirbControl == 0)
524 if (corbControl != 0 || rirbControl != 0) {
525 DPRINT1(
"hda: unable to stop dma\n");
546 DPRINT1(
"hda: unable to reset controller\n");
562 DPRINT1(
"hda: unable to exit reset\n");
604 DPRINT1(
"HDA_StartDevice Lower device failed to start %x\n",
Status);
622 DPRINT1(
"[HDAB] Failed to map registers\n");
642 DPRINT1(
"[HDAB] Failed to connect interrupt. Status=%lx\n",
Status);
674 DPRINT1(
"hda: bad codec status\n");
699 ULONG CodecIndex, AFGIndex;
730 CodecEntry = DeviceExtension->
Codecs[CodecIndex];
731 if (CodecEntry ==
NULL)
740 if (ChildPDO !=
NULL)
745 ChildDeviceExtension->
FDO =
NULL;
777 if (DeviceExtension->
Codecs[CodecIndex] ==
NULL)
780 Codec = DeviceExtension->
Codecs[CodecIndex];
788 if (!DeviceRelations)
791 DeviceRelations->
Count = 0;
794 if (DeviceExtension->
Codecs[CodecIndex] ==
NULL)
797 Codec = DeviceExtension->
Codecs[CodecIndex];
803 DeviceRelations->
Count++;
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define WRITE_REGISTER_USHORT(r, v)
#define READ_REGISTER_USHORT(r)
#define WRITE_REGISTER_ULONG(r, v)
#define READ_REGISTER_ULONG(r)
PVOID NTAPI MmAllocateContiguousMemory(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress)
VOID NTAPI MmFreeContiguousMemory(IN PVOID BaseAddress)
#define NT_SUCCESS(StatCode)
#define HDA_MAX_AUDIO_GROUPS
#define MAX_CODEC_RESPONSES
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
struct _DEVICE_OBJECT * PDEVICE_OBJECT
#define DO_DEVICE_INITIALIZING
NTSTATUS NTAPI HDA_FDOStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS NTAPI HDA_ResetController(IN PDEVICE_OBJECT DeviceObject)
NTSTATUS HDA_InitCodec(IN PDEVICE_OBJECT DeviceObject, IN ULONG codecAddress)
NTSTATUS NTAPI HDA_FDORemoveDevice(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
NTSTATUS NTAPI HDA_InitCorbRirbPos(IN PDEVICE_OBJECT DeviceObject)
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)
#define MAKE_VERB(cad, nid, vid, payload)
#define FUNCTION_GROUP_NODETYPE_AUDIO
#define VID_GET_PARAMETER
#define FUNCTION_GROUP_NODETYPE_MASK
#define PID_SUB_NODE_COUNT
#define PID_FUNCTION_GROUP_TYPE
#define RIRB_WRITE_POS_RESET
#define HDAC_STREAM_STATUS
#define GLOBAL_CAP_INPUT_STREAMS(cap)
#define INTR_STATUS_STREAM_MASK
#define CORB_SIZE_16_ENTRIES
#define CORB_SIZE_CAP_2_ENTRIES
#define CORB_SIZE_CAP_16_ENTRIES
#define HDAC_INTR_CONTROL
#define RIRB_SIZE_2_ENTRIES
#define RIRB_STATUS_RESPONSE
#define INTR_CONTROL_GLOBAL_ENABLE
#define CORB_CONTROL_MEMORY_ERROR_INTR
#define INTR_CONTROL_CONTROLLER_ENABLE
#define INTR_STATUS_CONTROLLER
#define GLOBAL_CAP_OUTPUT_STREAMS(cap)
#define HDAC_RESPONSE_INTR_COUNT
#define RIRB_SIZE_CAP_2_ENTRIES
#define GLOBAL_CONTROL_UNSOLICITED
#define CORB_READ_POS_RESET
#define HDAC_RIRB_BASE_LOWER
#define RIRB_SIZE_256_ENTRIES
#define RIRB_SIZE_16_ENTRIES
#define HDAC_RIRB_WRITE_POS
#define HDAC_CORB_CONTROL
#define CORB_SIZE_256_ENTRIES
#define GLOBAL_CONTROL_RESET
#define RIRB_SIZE_CAP_16_ENTRIES
#define RIRB_CONTROL_DMA_ENABLE
#define HDAC_CORB_READ_POS
#define RIRB_SIZE_CAP_256_ENTRIES
#define HDAC_GLOBAL_CONTROL
#define RIRB_CONTROL_OVERRUN_INTR
#define HDAC_RIRB_CONTROL
#define CORB_SIZE_CAP_256_ENTRIES
#define CORB_SIZE_2_ENTRIES
#define HDAC_STREAM_CONTROL0
#define HDAC_DMA_POSITION_BASE_UPPER
#define HDAC_RIRB_BASE_UPPER
#define HDAC_DMA_POSITION_BASE_LOWER
#define HDAC_CORB_BASE_LOWER
#define GLOBAL_CAP_BIDIR_STREAMS(cap)
#define HDAC_CORB_WRITE_POS
#define HDAC_STATE_STATUS
#define RESPONSE_FLAGS_UNSOLICITED
#define INTR_STATUS_GLOBAL
#define RIRB_CONTROL_RESPONSE_INTR
#define HDAC_CORB_BASE_UPPER
#define RIRB_STATUS_OVERRUN
#define CORB_STATUS_MEMORY_ERROR
#define RESPONSE_FLAGS_CODEC_MASK
IO_DPC_ROUTINE HDA_DpcForIsr
struct HDA_CODEC_AUDIO_GROUP * PHDA_CODEC_AUDIO_GROUP
struct HDA_CODEC_ENTRY * PHDA_CODEC_ENTRY
struct RIRB_RESPONSE * PRIRB_RESPONSE
NTSTATUS HDA_PDORemoveDevice(_In_ PDEVICE_OBJECT DeviceObject)
struct HDA_PDO_DEVICE_EXTENSION * PHDA_PDO_DEVICE_EXTENSION
struct HDA_FDO_DEVICE_EXTENSION * PHDA_FDO_DEVICE_EXTENSION
#define HDAC_INPUT_STREAM_OFFSET(index)
#define HDAC_OUTPUT_STREAM_OFFSET(num_input_streams, index)
#define HDAC_BIDIR_STREAM_OFFSET(num_input_streams, num_output_streams, index)
KSERVICE_ROUTINE HDA_InterruptService
#define CmResourceTypeMemory
#define CmResourceTypeInterrupt
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
VOID FreeItem(IN PVOID Item)
#define memcpy(s1, s2, n)
#define KeStallExecutionProcessor(MicroSeconds)
#define CM_RESOURCE_INTERRUPT_LATCHED
#define FILE_AUTOGENERATED_DEVICE_NAME
#define IoSkipCurrentIrpStackLocation(Irp)
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
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)
PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress(IN PVOID Address)
#define FILE_DEVICE_SOUND
enum _KINTERRUPT_MODE KINTERRUPT_MODE
VOID NTAPI KeInitializeSemaphore(IN PKSEMAPHORE Semaphore, IN LONG Count, IN LONG Limit)
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
base of all file and directory entries
PHDA_CODEC_AUDIO_GROUP AudioGroups[HDA_MAX_AUDIO_GROUPS]
ULONG Responses[MAX_CODEC_RESPONSES]
KSEMAPHORE ResponseSemaphore
PDEVICE_OBJECT LowerDevice
PHDA_CODEC_ENTRY Codecs[HDA_MAX_CODECS+1]
PHDA_CODEC_AUDIO_GROUP AudioGroup
PDEVICE_OBJECT Objects[1]
union _IO_STACK_LOCATION::@1580 Parameters
struct _IO_STACK_LOCATION::@3979::@4016 StartDevice
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
_In_ WDF_WMI_PROVIDER_CONTROL Control
@ CmResourceShareDeviceExclusive
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)
FORCEINLINE VOID IoRequestDpc(_Inout_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Irp, _In_opt_ __drv_aliasesMem PVOID Context)
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID ServiceContext
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
#define ObReferenceObject