ReactOS 0.4.16-dev-2293-g4d8327b
hdaudio.cpp File Reference
#include "driver.h"
Include dependency graph for hdaudio.cpp:

Go to the source code of this file.

Functions

NTSTATUS HDA_WaitForTransfer (PFDO_CONTEXT fdoCtx, UINT16 codecAddr, _In_ ULONG Count, _Inout_updates_(Count) PHDAUDIO_CODEC_TRANSFER CodecTransfer)
 
void NTAPI HDA_AsyncWait (WDFWORKITEM WorkItem)
 
NTSTATUS NTAPI HDA_TransferCodecVerbs (_In_ PVOID _context, _In_ ULONG Count, _Inout_updates_(Count) PHDAUDIO_CODEC_TRANSFER CodecTransfer, _In_opt_ PHDAUDIO_TRANSFER_COMPLETE_CALLBACK Callback, _In_opt_ PVOID Context)
 
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_AllocateRenderDmaEngine (_In_ PVOID _context, _In_ PHDAUDIO_STREAM_FORMAT StreamFormat, _In_ BOOLEAN Stripe, _Out_ PHANDLE Handle, _Out_ PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
 
NTSTATUS NTAPI HDA_ChangeBandwidthAllocation (_In_ PVOID _context, _In_ HANDLE Handle, _In_ PHDAUDIO_STREAM_FORMAT StreamFormat, _Out_ PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
 
NTSTATUS NTAPI HDA_FreeDmaEngine (_In_ PVOID _context, _In_ HANDLE Handle)
 
NTSTATUS NTAPI HDA_SetDmaEngineState (_In_ PVOID _context, _In_ HDAUDIO_STREAM_STATE StreamState, _In_ ULONG NumberOfHandles, _In_reads_(NumberOfHandles) PHANDLE Handles)
 
VOID NTAPI HDA_GetWallClockRegister (_In_ PVOID _context, _Out_ PULONG *Wallclock)
 
NTSTATUS NTAPI HDA_GetLinkPositionRegister (_In_ PVOID _context, _In_ HANDLE Handle, _Out_ PULONG *Position)
 
NTSTATUS NTAPI HDA_RegisterEventCallback (_In_ PVOID _context, _In_ PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK Routine, _In_opt_ PVOID Context, _Out_ PUCHAR Tag)
 
NTSTATUS NTAPI HDA_UnregisterEventCallback (_In_ PVOID _context, _In_ UCHAR Tag)
 
NTSTATUS NTAPI HDA_GetDeviceInformation (_In_ PVOID _context, _Inout_ PHDAUDIO_DEVICE_INFORMATION DeviceInformation)
 
void NTAPI HDA_GetResourceInformation (_In_ PVOID _context, _Out_ PUCHAR CodecAddress, _Out_ PUCHAR FunctionGroupStartNode)
 
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_FreeDmaBufferWithNotification (_In_ PVOID _context, _In_ HANDLE Handle, _In_ PMDL BufferMdl, _In_ SIZE_T BufferSize)
 
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_FreeDmaBuffer (_In_ PVOID _context, _In_ HANDLE Handle)
 
NTSTATUS NTAPI HDA_RegisterNotificationEvent (_In_ PVOID _context, _In_ HANDLE Handle, _In_ PKEVENT NotificationEvent)
 
NTSTATUS NTAPI HDA_UnregisterNotificationEvent (_In_ PVOID _context, _In_ HANDLE Handle, _In_ PKEVENT NotificationEvent)
 
NTSTATUS NTAPI HDA_RegisterNotificationCallback (_In_ PVOID _context, _In_ HANDLE Handle, PDEVICE_OBJECT Fdo, PHDAUDIO_DMA_NOTIFICATION_CALLBACK NotificationCallback, PVOID CallbackContext)
 
NTSTATUS NTAPI HDA_UnregisterNotificationCallback (_In_ PVOID _context, _In_ HANDLE Handle, PHDAUDIO_DMA_NOTIFICATION_CALLBACK NotificationCallback, PVOID CallbackContext)
 
NTSTATUS NTAPI HDA_SetupDmaEngineWithBdl (_In_ PVOID _context, _In_ HANDLE Handle, _In_ ULONG BufferLength, _In_ ULONG Lvi, _In_ PHDAUDIO_BDL_ISR Isr, _In_ PVOID Context, _Out_ PUCHAR StreamId, _Out_ PULONG FifoSize)
 
NTSTATUS NTAPI HDA_FreeContiguousDmaBuffer (_In_ PVOID _context, _In_ HANDLE Handle)
 
NTSTATUS NTAPI HDA_AllocateContiguousDmaBuffer (_In_ PVOID _context, _In_ HANDLE Handle, _In_ ULONG RequestedBufferSize, _Out_ PVOID *DataBuffer, _Out_ PHDAUDIO_BUFFER_DESCRIPTOR *BdlBuffer)
 
HDAUDIO_BUS_INTERFACE_V2 HDA_BusInterfaceV2 (PVOID Context)
 
HDAUDIO_BUS_INTERFACE_V3 HDA_BusInterfaceV3 (PVOID Context)
 
HDAUDIO_BUS_INTERFACE HDA_BusInterface (PVOID Context)
 
HDAUDIO_BUS_INTERFACE_BDL HDA_BusInterfaceBDL (PVOID Context)
 

Function Documentation

◆ HDA_AllocateCaptureDmaEngine()

NTSTATUS NTAPI HDA_AllocateCaptureDmaEngine ( _In_ PVOID  _context,
_In_ UCHAR  CodecAddress,
_In_ PHDAUDIO_STREAM_FORMAT  StreamFormat,
_Out_ PHANDLE  Handle,
_Out_ PHDAUDIO_CONVERTER_FORMAT  ConverterFormat 
)

Definition at line 150 of file hdaudio.cpp.

156 {
157 UNREFERENCED_PARAMETER(CodecAddress);
158
160 return STATUS_UNSUCCESSFUL;
161 }
162
163 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
164 if (!devData->FdoContext) {
166 }
167
168 PFDO_CONTEXT fdoContext = devData->FdoContext;
169
171 if (!NT_SUCCESS(status)) {
172 return status;
173 }
174
175 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
176 for (UINT32 i = 0; i < fdoContext->captureStreams; i++) {
177 int tag = fdoContext->captureIndexOff + i;
178 PHDAC_STREAM stream = &fdoContext->streams[tag];
179 if (stream->PdoContext != NULL) {
180 continue;
181 }
182
183 stream->PdoContext = devData;
184 stream->running = FALSE;
185 stream->streamFormat = *StreamFormat;
186
187 ConverterFormat->ConverterFormat = hdac_format(stream);
188
189 if (Handle)
190 *Handle = (HANDLE)stream;
191
192 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
193 return STATUS_SUCCESS;
194 }
195
196 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
199}
struct _PDO_DEVICE_DATA * PPDO_DEVICE_DATA
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ULONG Handle
Definition: gdb_input.c:15
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UINT16 hdac_format(PHDAC_STREAM stream)
Definition: hdac_stream.cpp:67
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define STATUS_SUCCESS
Definition: shellext.h:65
WDFDEVICE WdfDevice
Definition: fdo.h:115
UINT32 captureIndexOff
Definition: fdo.h:143
PHDAC_STREAM streams
Definition: fdo.h:149
UINT32 captureStreams
Definition: fdo.h:145
WDFINTERRUPT Interrupt
Definition: fdo.h:124
PFDO_CONTEXT FdoContext
Definition: buspdo.h:49
Definition: ps.c:97
Definition: parse.h:23
Definition: ecma_167.h:138
PVOID HANDLE
Definition: typedefs.h:73
uint32_t UINT32
Definition: typedefs.h:59
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define WdfDeviceStopIdle(Device, WaitForD0)
Definition: wdfdevice.h:1977
#define WdfDeviceResumeIdle(Device)
Definition: wdfdevice.h:1983

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_AllocateContiguousDmaBuffer()

NTSTATUS NTAPI HDA_AllocateContiguousDmaBuffer ( _In_ PVOID  _context,
_In_ HANDLE  Handle,
_In_ ULONG  RequestedBufferSize,
_Out_ PVOID DataBuffer,
_Out_ PHDAUDIO_BUFFER_DESCRIPTOR BdlBuffer 
)

Definition at line 1001 of file hdaudio.cpp.

1007{
1009 return STATUS_UNSUCCESSFUL;
1010 }
1011
1012 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
1013 if (!devData->FdoContext) {
1014 return STATUS_NO_SUCH_DEVICE;
1015 }
1016
1018 if (stream->PdoContext != devData) {
1019 return STATUS_INVALID_HANDLE;
1020 }
1021
1022 if (stream->running) {
1024 }
1025
1026 if (stream->dmaBuf) {
1028 }
1029
1030 if (!stream->bdl) {
1032 }
1033
1034 PHYSICAL_ADDRESS maxAddr;
1035 maxAddr.QuadPart = devData->FdoContext->is64BitOK ? MAXULONG64 : MAXULONG32;
1036
1037 PVOID dmaBuf = MmAllocateContiguousMemory(RequestedBufferSize, maxAddr);
1038 if (!dmaBuf) {
1040 }
1041 RtlZeroMemory(dmaBuf, RequestedBufferSize);
1042
1043 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
1044
1045 stream->dmaBuf = dmaBuf;
1046
1047 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
1048
1049 *DataBuffer = stream->dmaBuf;
1050 *BdlBuffer = (PHDAUDIO_BUFFER_DESCRIPTOR)stream->bdl;
1051
1052 return STATUS_SUCCESS;
1053}
PVOID NTAPI MmAllocateContiguousMemory(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress)
Definition: contmem.c:626
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
struct _HDAC_STREAM * PHDAC_STREAM
struct _HDAUDIO_BUFFER_DESCRIPTOR * PHDAUDIO_BUFFER_DESCRIPTOR
BOOLEAN is64BitOK
Definition: fdo.h:140
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by HDA_BusInterfaceBDL().

◆ HDA_AllocateDmaBuffer()

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 
)

Definition at line 724 of file hdaudio.cpp.

732 {
733 SIZE_T OffsetFromFirstPage;
734 return HDA_AllocateDmaBufferWithNotification(_context, Handle, 1, RequestedBufferSize, BufferMdl, AllocatedBufferSize, &OffsetFromFirstPage, StreamId, FifoSize);
735}
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)
Definition: hdaudio.cpp:529
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by HDA_BusInterface(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_AllocateDmaBufferWithNotification()

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 
)

Definition at line 529 of file hdaudio.cpp.

539 {
541 return STATUS_UNSUCCESSFUL;
542 }
543
544 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
545 if (!devData->FdoContext) {
547 }
548
550 if (stream->PdoContext != devData) {
552 }
553
554 if (stream->running) {
556 }
557
558 if (stream->mdlBuf) {
560 }
561
562 PHYSICAL_ADDRESS zeroAddr;
563 zeroAddr.QuadPart = 0;
564 PHYSICAL_ADDRESS maxAddr;
565 maxAddr.QuadPart = devData->FdoContext->is64BitOK ? MAXULONG64 : MAXULONG32;
566
567 UINT32 allocSize = (UINT32)RequestedBufferSize;
568 UINT32 allocOffset = 0;
569 UINT32 halfSize = 0;
570 if (NotificationCount == 2) {
571 halfSize = (UINT32)RequestedBufferSize / 2;
572 allocOffset = PAGE_SIZE - (halfSize % PAGE_SIZE);
573 allocSize = (UINT32)RequestedBufferSize + allocOffset;
574 }
575
576 PMDL mdl = MmAllocatePagesForMdl(zeroAddr, maxAddr, zeroAddr, allocSize);
577 if (!mdl) {
578 return STATUS_NO_MEMORY;
579 }
580
581 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
582 stream->mdlBuf = mdl;
583 stream->bufSz = (UINT32)RequestedBufferSize;
584
585 *BufferMdl = mdl;
586 *AllocatedBufferSize = RequestedBufferSize;
587 *OffsetFromFirstPage = allocOffset;
588 *StreamId = stream->streamTag;
589
590 {
591 UINT16 numBlocks = 0;
592 UINT16 pageNum = 0;
593
594 //Set up the BDL
595 PHDAC_BDLENTRY bdl = stream->bdl;
596 UINT32 size = (UINT32)RequestedBufferSize;
597
598 PPFN_NUMBER pfnArray = MmGetMdlPfnArray(mdl);
599 UINT32 offset = allocOffset;
600 while (halfSize > 0) {
601 if (numBlocks > HDA_MAX_BDL_ENTRIES) {
602 SklHdAudBusPrint(DEBUG_LEVEL_ERROR, DBG_IOCTL, "%s Too many BDL entries!\n", __func__);
603 numBlocks = HDA_MAX_BDL_ENTRIES;
604 break;
605 }
606
607 UINT32 pageOff = offset % PAGE_SIZE;
608 UINT32 chunk = (pageOff == 0) ? PAGE_SIZE : (PAGE_SIZE - pageOff);
609 if (halfSize < chunk)
610 chunk = halfSize;
611
612 PFN_NUMBER pfn = pfnArray[pageNum];
613 PHYSICAL_ADDRESS addr = { 0 };
614 addr.QuadPart = pfn << PAGE_SHIFT;
615
616 bdl->lowAddr = addr.LowPart + pageOff;
617 bdl->highAddr = addr.HighPart;
618 bdl->len = chunk;
619
620 halfSize -= chunk;
621 size -= chunk;
622
623 //Program interrupt for when buffer is halfway
624 bdl->ioc = (halfSize > 0) ? 0 : 1;
625 bdl++;
626 numBlocks++;
627 offset += chunk;
628 if ((offset % PAGE_SIZE) == 0)
629 pageNum++; //Only increment page num if we go past page boundary
630 }
631
632 while (size > 0) {
633 if (numBlocks > HDA_MAX_BDL_ENTRIES) {
634 SklHdAudBusPrint(DEBUG_LEVEL_ERROR, DBG_IOCTL, "%s Too many BDL entries!\n", __func__);
635 numBlocks = HDA_MAX_BDL_ENTRIES;
636 break;
637 }
638
639 UINT32 pageOff = offset % PAGE_SIZE;
640 UINT32 chunk = (pageOff == 0) ? PAGE_SIZE : (PAGE_SIZE - pageOff);
641 if (size < chunk)
642 chunk = size;
643
644 PFN_NUMBER pfn = pfnArray[pageNum];
645 PHYSICAL_ADDRESS addr = { 0 };
646 addr.QuadPart = pfn << PAGE_SHIFT;
647 bdl->lowAddr = addr.LowPart + pageOff;
648 bdl->highAddr = addr.HighPart;
649 bdl->len = chunk;
650
651 size -= chunk;
652 //Program interrupt for when buffer ends
653 bdl->ioc = (size > 0) ? 0 : 1;
654 bdl++;
655 numBlocks++;
656 offset += chunk;
657 if ((offset % PAGE_SIZE) == 0)
658 pageNum++; //Only increment page num if we go past page boundary
659 }
660 stream->numBlocks = numBlocks;
661 }
662
663 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
664
667
668 *FifoSize = stream->fifoSize;
669 return STATUS_SUCCESS;
670}
ULONG_PTR PFN_NUMBER
unsigned short UINT16
Definition: actypes.h:129
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define SklHdAudBusPrint(dbglevel, fmt,...)
Definition: driver.h:111
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
MDL * mdl
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLenum const GLvoid * addr
Definition: glext.h:9621
#define HDA_MAX_BDL_ENTRIES
void hdac_stream_reset(PHDAC_STREAM stream)
Definition: hdac_stream.cpp:37
void hdac_stream_setup(PHDAC_STREAM stream)
PMDL NTAPI MmAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress, IN PHYSICAL_ADDRESS HighAddress, IN PHYSICAL_ADDRESS SkipBytes, IN SIZE_T TotalBytes)
Definition: mdlsup.c:489
ULONG * PPFN_NUMBER
Definition: ke.h:9
UINT32 len
Definition: fdo.h:39
UINT32 ioc
Definition: fdo.h:40
UINT32 highAddr
Definition: fdo.h:38
UINT32 lowAddr
Definition: fdo.h:37
#define MmGetMdlPfnArray(_Mdl)

Referenced by HDA_AllocateDmaBuffer(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_AllocateRenderDmaEngine()

NTSTATUS NTAPI HDA_AllocateRenderDmaEngine ( _In_ PVOID  _context,
_In_ PHDAUDIO_STREAM_FORMAT  StreamFormat,
_In_ BOOLEAN  Stripe,
_Out_ PHANDLE  Handle,
_Out_ PHDAUDIO_CONVERTER_FORMAT  ConverterFormat 
)

Definition at line 203 of file hdaudio.cpp.

209 {
211 return STATUS_UNSUCCESSFUL;
212 }
213
214 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
215 if (!devData->FdoContext) {
217 }
218
219 PFDO_CONTEXT fdoContext = devData->FdoContext;
220
222 if (!NT_SUCCESS(status)) {
223 return status;
224 }
225
226 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
227 for (UINT32 i = 0; i < fdoContext->playbackStreams; i++) {
228 int tag = fdoContext->playbackIndexOff + i;
229 PHDAC_STREAM stream = &fdoContext->streams[tag];
230 if (stream->PdoContext != NULL) {
231 continue;
232 }
233
234 stream->stripe = Stripe;
235 stream->PdoContext = devData;
236 stream->running = FALSE;
237 stream->streamFormat = *StreamFormat;
238
239 ConverterFormat->ConverterFormat = hdac_format(stream);
240
241 if (Handle)
242 *Handle = (HANDLE)stream;
243
244 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
245 return STATUS_SUCCESS;
246 }
247
248 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
251}
UINT32 playbackStreams
Definition: fdo.h:146
UINT32 playbackIndexOff
Definition: fdo.h:144

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_AsyncWait()

void NTAPI HDA_AsyncWait ( WDFWORKITEM  WorkItem)

Definition at line 43 of file hdaudio.cpp.

43 {
44 PHDA_ASYNC_CONTEXT workItemContext = HDAAsyncWorkItem_GetContext(WorkItem);
45
46 SklHdAudBusPrint(DEBUG_LEVEL_VERBOSE, DBG_IOCTL, "%s called (Count: %d)!\n", __func__, workItemContext->Count);
47
49 workItemContext->devData->FdoContext,
50 (UINT16)workItemContext->devData->CodecIds.CodecAddress,
51 workItemContext->Count,
52 workItemContext->CodecTransfer
53 );
55
56 workItemContext->Callback(
57 workItemContext->CodecTransfer,
58 workItemContext->CallbackContext
59 );
60
61 PFDO_CONTEXT fdoCtx = workItemContext->devData->FdoContext;
63 WdfObjectDelete(WorkItem);
64
65 SklHdAudBusPrint(DEBUG_LEVEL_VERBOSE, DBG_IOCTL, "%s exit (Count: %d)!\n", __func__);
66}
NTSTATUS HDA_WaitForTransfer(PFDO_CONTEXT fdoCtx, UINT16 codecAddr, _In_ ULONG Count, _Inout_updates_(Count) PHDAUDIO_CODEC_TRANSFER CodecTransfer)
Definition: hdaudio.cpp:3
UINT32 CodecAddress
Definition: buspdo.h:13
PHDAUDIO_TRANSFER_COMPLETE_CALLBACK Callback
PHDAUDIO_CODEC_TRANSFER CodecTransfer
PPDO_DEVICE_DATA devData
CODEC_IDS CodecIds
Definition: buspdo.h:51
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
Definition: wdfworkitem.h:115

Referenced by HDA_TransferCodecVerbs().

◆ HDA_BusInterface()

HDAUDIO_BUS_INTERFACE HDA_BusInterface ( PVOID  Context)

Definition at line 1119 of file hdaudio.cpp.

1119 {
1120 HDAUDIO_BUS_INTERFACE busInterface;
1121 RtlZeroMemory(&busInterface, sizeof(HDAUDIO_BUS_INTERFACE));
1122
1123 busInterface.Size = sizeof(HDAUDIO_BUS_INTERFACE);
1124 busInterface.Version = 0x0100;
1125 busInterface.Context = Context;
1133 busInterface.FreeDmaBuffer = HDA_FreeDmaBuffer;
1134 busInterface.FreeDmaEngine = HDA_FreeDmaEngine;
1142
1143 return busInterface;
1144}
NTSTATUS NTAPI HDA_AllocateCaptureDmaEngine(_In_ PVOID _context, _In_ UCHAR CodecAddress, _In_ PHDAUDIO_STREAM_FORMAT StreamFormat, _Out_ PHANDLE Handle, _Out_ PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
Definition: hdaudio.cpp:150
NTSTATUS NTAPI HDA_UnregisterEventCallback(_In_ PVOID _context, _In_ UCHAR Tag)
Definition: hdaudio.cpp:453
NTSTATUS NTAPI HDA_AllocateRenderDmaEngine(_In_ PVOID _context, _In_ PHDAUDIO_STREAM_FORMAT StreamFormat, _In_ BOOLEAN Stripe, _Out_ PHANDLE Handle, _Out_ PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
Definition: hdaudio.cpp:203
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)
Definition: hdaudio.cpp:724
void NTAPI HDA_GetResourceInformation(_In_ PVOID _context, _Out_ PUCHAR CodecAddress, _Out_ PUCHAR FunctionGroupStartNode)
Definition: hdaudio.cpp:512
NTSTATUS NTAPI HDA_SetDmaEngineState(_In_ PVOID _context, _In_ HDAUDIO_STREAM_STATE StreamState, _In_ ULONG NumberOfHandles, _In_reads_(NumberOfHandles) PHANDLE Handles)
Definition: hdaudio.cpp:331
NTSTATUS NTAPI HDA_ChangeBandwidthAllocation(_In_ PVOID _context, _In_ HANDLE Handle, _In_ PHDAUDIO_STREAM_FORMAT StreamFormat, _Out_ PHDAUDIO_CONVERTER_FORMAT ConverterFormat)
Definition: hdaudio.cpp:255
NTSTATUS NTAPI HDA_FreeDmaEngine(_In_ PVOID _context, _In_ HANDLE Handle)
Definition: hdaudio.cpp:296
NTSTATUS NTAPI HDA_GetDeviceInformation(_In_ PVOID _context, _Inout_ PHDAUDIO_DEVICE_INFORMATION DeviceInformation)
Definition: hdaudio.cpp:482
NTSTATUS NTAPI HDA_FreeDmaBuffer(_In_ PVOID _context, _In_ HANDLE Handle)
Definition: hdaudio.cpp:739
NTSTATUS NTAPI HDA_TransferCodecVerbs(_In_ PVOID _context, _In_ ULONG Count, _Inout_updates_(Count) PHDAUDIO_CODEC_TRANSFER CodecTransfer, _In_opt_ PHDAUDIO_TRANSFER_COMPLETE_CALLBACK Callback, _In_opt_ PVOID Context)
Definition: hdaudio.cpp:70
NTSTATUS NTAPI HDA_GetLinkPositionRegister(_In_ PVOID _context, _In_ HANDLE Handle, _Out_ PULONG *Position)
Definition: hdaudio.cpp:388
VOID NTAPI HDA_GetWallClockRegister(_In_ PVOID _context, _Out_ PULONG *Wallclock)
Definition: hdaudio.cpp:374
NTSTATUS NTAPI HDA_RegisterEventCallback(_In_ PVOID _context, _In_ PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK Routine, _In_opt_ PVOID Context, _Out_ PUCHAR Tag)
Definition: hdaudio.cpp:413
struct _HDAUDIO_BUS_INTERFACE HDAUDIO_BUS_INTERFACE
PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine
Definition: hdaudio.h:270
PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback
Definition: hdaudio.h:279
PSET_DMA_ENGINE_STATE SetDmaEngineState
Definition: hdaudio.h:275
PTRANSFER_CODEC_VERBS TransferCodecVerbs
Definition: hdaudio.h:268
PGET_DEVICE_INFORMATION GetDeviceInformation
Definition: hdaudio.h:280
PREGISTER_EVENT_CALLBACK RegisterEventCallback
Definition: hdaudio.h:278
PINTERFACE_REFERENCE InterfaceReference
Definition: hdaudio.h:266
PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine
Definition: hdaudio.h:269
PGET_WALL_CLOCK_REGISTER GetWallClockRegister
Definition: hdaudio.h:276
PFREE_DMA_ENGINE FreeDmaEngine
Definition: hdaudio.h:274
PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation
Definition: hdaudio.h:271
PFREE_DMA_BUFFER FreeDmaBuffer
Definition: hdaudio.h:273
PGET_RESOURCE_INFORMATION GetResourceInformation
Definition: hdaudio.h:281
PALLOCATE_DMA_BUFFER AllocateDmaBuffer
Definition: hdaudio.h:272
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: hdaudio.h:267
PGET_LINK_POSITION_REGISTER GetLinkPositionRegister
Definition: hdaudio.h:277
FORCEINLINE VOID NTAPI WdfDeviceInterfaceReferenceNoOp(_In_ PVOID Context)
FORCEINLINE VOID NTAPI WdfDeviceInterfaceDereferenceNoOp(_In_ PVOID Context)

Referenced by Bus_CreatePdo().

◆ HDA_BusInterfaceBDL()

HDAUDIO_BUS_INTERFACE_BDL HDA_BusInterfaceBDL ( PVOID  Context)

Definition at line 1146 of file hdaudio.cpp.

1147{
1148 HDAUDIO_BUS_INTERFACE_BDL busInterface;
1149 RtlZeroMemory(&busInterface, sizeof(HDAUDIO_BUS_INTERFACE_BDL));
1150
1151 busInterface.Size = sizeof(HDAUDIO_BUS_INTERFACE_BDL);
1152 busInterface.Version = 0x0100;
1153 busInterface.Context = Context;
1163 busInterface.FreeDmaEngine = HDA_FreeDmaEngine;
1171
1172 return busInterface;
1173}
NTSTATUS NTAPI HDA_AllocateContiguousDmaBuffer(_In_ PVOID _context, _In_ HANDLE Handle, _In_ ULONG RequestedBufferSize, _Out_ PVOID *DataBuffer, _Out_ PHDAUDIO_BUFFER_DESCRIPTOR *BdlBuffer)
Definition: hdaudio.cpp:1001
NTSTATUS NTAPI HDA_SetupDmaEngineWithBdl(_In_ PVOID _context, _In_ HANDLE Handle, _In_ ULONG BufferLength, _In_ ULONG Lvi, _In_ PHDAUDIO_BDL_ISR Isr, _In_ PVOID Context, _Out_ PUCHAR StreamId, _Out_ PULONG FifoSize)
Definition: hdaudio.cpp:892
NTSTATUS NTAPI HDA_FreeContiguousDmaBuffer(_In_ PVOID _context, _In_ HANDLE Handle)
Definition: hdaudio.cpp:951
struct _HDAUDIO_BUS_INTERFACE_BDL HDAUDIO_BUS_INTERFACE_BDL
PINTERFACE_REFERENCE InterfaceReference
Definition: hdaudio.h:323
PTRANSFER_CODEC_VERBS TransferCodecVerbs
Definition: hdaudio.h:325
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: hdaudio.h:324
PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback
Definition: hdaudio.h:337
PGET_RESOURCE_INFORMATION GetResourceInformation
Definition: hdaudio.h:339
PALLOCATE_CONTIGUOUS_DMA_BUFFER AllocateContiguousDmaBuffer
Definition: hdaudio.h:329
PGET_WALL_CLOCK_REGISTER GetWallClockRegister
Definition: hdaudio.h:334
PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation
Definition: hdaudio.h:328
PGET_DEVICE_INFORMATION GetDeviceInformation
Definition: hdaudio.h:338
PSETUP_DMA_ENGINE_WITH_BDL SetupDmaEngineWithBdl
Definition: hdaudio.h:330
PFREE_DMA_ENGINE FreeDmaEngine
Definition: hdaudio.h:332
PSET_DMA_ENGINE_STATE SetDmaEngineState
Definition: hdaudio.h:333
PGET_LINK_POSITION_REGISTER GetLinkPositionRegister
Definition: hdaudio.h:335
PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine
Definition: hdaudio.h:327
PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine
Definition: hdaudio.h:326
PFREE_CONTIGUOUS_DMA_BUFFER FreeContiguousDmaBuffer
Definition: hdaudio.h:331
PREGISTER_EVENT_CALLBACK RegisterEventCallback
Definition: hdaudio.h:336

Referenced by Bus_CreatePdo().

◆ HDA_BusInterfaceV2()

HDAUDIO_BUS_INTERFACE_V2 HDA_BusInterfaceV2 ( PVOID  Context)

Definition at line 1055 of file hdaudio.cpp.

1055 {
1056 HDAUDIO_BUS_INTERFACE_V2 busInterface;
1057 RtlZeroMemory(&busInterface, sizeof(HDAUDIO_BUS_INTERFACE_V2));
1058
1059 busInterface.Size = sizeof(HDAUDIO_BUS_INTERFACE_V2);
1060 busInterface.Version = 0x0100;
1061 busInterface.Context = Context;
1069 busInterface.FreeDmaBuffer = HDA_FreeDmaBuffer;
1070 busInterface.FreeDmaEngine = HDA_FreeDmaEngine;
1082
1083 return busInterface;
1084}
NTSTATUS NTAPI HDA_UnregisterNotificationEvent(_In_ PVOID _context, _In_ HANDLE Handle, _In_ PKEVENT NotificationEvent)
Definition: hdaudio.cpp:788
NTSTATUS NTAPI HDA_FreeDmaBufferWithNotification(_In_ PVOID _context, _In_ HANDLE Handle, _In_ PMDL BufferMdl, _In_ SIZE_T BufferSize)
Definition: hdaudio.cpp:674
NTSTATUS NTAPI HDA_RegisterNotificationEvent(_In_ PVOID _context, _In_ HANDLE Handle, _In_ PKEVENT NotificationEvent)
Definition: hdaudio.cpp:758
struct _HDAUDIO_BUS_INTERFACE_V2 HDAUDIO_BUS_INTERFACE_V2
PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine
Definition: hdaudio.h:388
PALLOCATE_DMA_BUFFER_WITH_NOTIFICATION AllocateDmaBufferWithNotification
Definition: hdaudio.h:401
PFREE_DMA_ENGINE FreeDmaEngine
Definition: hdaudio.h:393
PINTERFACE_REFERENCE InterfaceReference
Definition: hdaudio.h:385
PGET_DEVICE_INFORMATION GetDeviceInformation
Definition: hdaudio.h:399
PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation
Definition: hdaudio.h:390
PFREE_DMA_BUFFER FreeDmaBuffer
Definition: hdaudio.h:392
PUNREGISTER_NOTIFICATION_EVENT UnregisterNotificationEvent
Definition: hdaudio.h:404
PSET_DMA_ENGINE_STATE SetDmaEngineState
Definition: hdaudio.h:394
PREGISTER_EVENT_CALLBACK RegisterEventCallback
Definition: hdaudio.h:397
PREGISTER_NOTIFICATION_EVENT RegisterNotificationEvent
Definition: hdaudio.h:403
PGET_LINK_POSITION_REGISTER GetLinkPositionRegister
Definition: hdaudio.h:396
PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback
Definition: hdaudio.h:398
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: hdaudio.h:386
PTRANSFER_CODEC_VERBS TransferCodecVerbs
Definition: hdaudio.h:387
PGET_WALL_CLOCK_REGISTER GetWallClockRegister
Definition: hdaudio.h:395
PFREE_DMA_BUFFER_WITH_NOTIFICATION FreeDmaBufferWithNotification
Definition: hdaudio.h:402
PALLOCATE_DMA_BUFFER AllocateDmaBuffer
Definition: hdaudio.h:391
PGET_RESOURCE_INFORMATION GetResourceInformation
Definition: hdaudio.h:400
PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine
Definition: hdaudio.h:389

Referenced by Bus_CreatePdo().

◆ HDA_BusInterfaceV3()

HDAUDIO_BUS_INTERFACE_V3 HDA_BusInterfaceV3 ( PVOID  Context)

Definition at line 1086 of file hdaudio.cpp.

1086 {
1087 HDAUDIO_BUS_INTERFACE_V3 busInterface;
1088 RtlZeroMemory(&busInterface, sizeof(HDAUDIO_BUS_INTERFACE_V3));
1089
1090 busInterface.Size = sizeof(HDAUDIO_BUS_INTERFACE_V3);
1091 busInterface.Version = 0x0100;
1092 busInterface.Context = Context;
1100 busInterface.FreeDmaBuffer = HDA_FreeDmaBuffer;
1101 busInterface.FreeDmaEngine = HDA_FreeDmaEngine;
1115
1116 return busInterface;
1117}
NTSTATUS NTAPI HDA_RegisterNotificationCallback(_In_ PVOID _context, _In_ HANDLE Handle, PDEVICE_OBJECT Fdo, PHDAUDIO_DMA_NOTIFICATION_CALLBACK NotificationCallback, PVOID CallbackContext)
Definition: hdaudio.cpp:818
NTSTATUS NTAPI HDA_UnregisterNotificationCallback(_In_ PVOID _context, _In_ HANDLE Handle, PHDAUDIO_DMA_NOTIFICATION_CALLBACK NotificationCallback, PVOID CallbackContext)
Definition: hdaudio.cpp:856
struct _HDAUDIO_BUS_INTERFACE_V3 HDAUDIO_BUS_INTERFACE_V3
PUNREGISTER_NOTIFICATION_CALLBACK UnregisterNotificationCallback
Definition: hdaudio.h:432
PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine
Definition: hdaudio.h:415
PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation
Definition: hdaudio.h:416
PGET_RESOURCE_INFORMATION GetResourceInformation
Definition: hdaudio.h:426
PFREE_DMA_BUFFER FreeDmaBuffer
Definition: hdaudio.h:418
PGET_DEVICE_INFORMATION GetDeviceInformation
Definition: hdaudio.h:425
PINTERFACE_REFERENCE InterfaceReference
Definition: hdaudio.h:411
PUNREGISTER_NOTIFICATION_EVENT UnregisterNotificationEvent
Definition: hdaudio.h:430
PFREE_DMA_ENGINE FreeDmaEngine
Definition: hdaudio.h:419
PGET_WALL_CLOCK_REGISTER GetWallClockRegister
Definition: hdaudio.h:421
PREGISTER_NOTIFICATION_CALLBACK RegisterNotificationCallback
Definition: hdaudio.h:431
PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback
Definition: hdaudio.h:424
PTRANSFER_CODEC_VERBS TransferCodecVerbs
Definition: hdaudio.h:413
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: hdaudio.h:412
PGET_LINK_POSITION_REGISTER GetLinkPositionRegister
Definition: hdaudio.h:422
PALLOCATE_DMA_BUFFER AllocateDmaBuffer
Definition: hdaudio.h:417
PFREE_DMA_BUFFER_WITH_NOTIFICATION FreeDmaBufferWithNotification
Definition: hdaudio.h:428
PSET_DMA_ENGINE_STATE SetDmaEngineState
Definition: hdaudio.h:420
PREGISTER_EVENT_CALLBACK RegisterEventCallback
Definition: hdaudio.h:423
PALLOCATE_DMA_BUFFER_WITH_NOTIFICATION AllocateDmaBufferWithNotification
Definition: hdaudio.h:427
PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine
Definition: hdaudio.h:414
PREGISTER_NOTIFICATION_EVENT RegisterNotificationEvent
Definition: hdaudio.h:429

Referenced by Bus_CreatePdo().

◆ HDA_ChangeBandwidthAllocation()

NTSTATUS NTAPI HDA_ChangeBandwidthAllocation ( _In_ PVOID  _context,
_In_ HANDLE  Handle,
_In_ PHDAUDIO_STREAM_FORMAT  StreamFormat,
_Out_ PHDAUDIO_CONVERTER_FORMAT  ConverterFormat 
)

Definition at line 255 of file hdaudio.cpp.

260 {
262 return STATUS_UNSUCCESSFUL;
263 }
264
265 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
266 if (!devData->FdoContext) {
268 }
269
271 if (stream->PdoContext != devData) {
273 }
274
275 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
276
277 if (stream->running) {
278 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
280 }
281
282 stream->streamFormat = *StreamFormat;
283 ConverterFormat->ConverterFormat = hdac_format(stream);
284
286
287 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
288
289 SklHdAudBusPrint(DEBUG_LEVEL_VERBOSE, DBG_IOCTL, "%s called!\n", __func__);
290
291 return STATUS_SUCCESS;
292}

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_FreeContiguousDmaBuffer()

NTSTATUS NTAPI HDA_FreeContiguousDmaBuffer ( _In_ PVOID  _context,
_In_ HANDLE  Handle 
)

Definition at line 951 of file hdaudio.cpp.

954{
956 return STATUS_UNSUCCESSFUL;
957 }
958
959 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
960 if (!devData->FdoContext) {
962 }
963
965 if (stream->PdoContext != devData) {
967 }
968
969 if (stream->running) {
971 }
972
973 if (!stream->bdl) {
975 }
976
977 if (!stream->dmaBuf) {
979 }
980
981 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
982
983 stream_write32(stream, SD_BDLPL, 0);
984 stream_write32(stream, SD_BDLPU, 0);
985 stream_write32(stream, SD_CTL, 0);
986
987 RtlZeroMemory(&stream->isr, sizeof(HDAC_ISR_CALLBACK));
988
989 PVOID dmaBuf = stream->dmaBuf;
990 stream->dmaBuf = NULL;
991
992 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
993
995
996 return STATUS_SUCCESS;
997}
VOID NTAPI MmFreeContiguousMemory(IN PVOID BaseAddress)
Definition: contmem.c:653
#define stream_write32(ctx, reg, data)
Definition: regfuncs.h:70

Referenced by HDA_BusInterfaceBDL().

◆ HDA_FreeDmaBuffer()

NTSTATUS NTAPI HDA_FreeDmaBuffer ( _In_ PVOID  _context,
_In_ HANDLE  Handle 
)

Definition at line 739 of file hdaudio.cpp.

742 {
743 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
744 if (!devData->FdoContext) {
746 }
747
749 if (stream->PdoContext != devData) {
751 }
752
753 return HDA_FreeDmaBufferWithNotification(_context, Handle, stream->mdlBuf, stream->bufSz);
754}

Referenced by HDA_BusInterface(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_FreeDmaBufferWithNotification()

NTSTATUS NTAPI HDA_FreeDmaBufferWithNotification ( _In_ PVOID  _context,
_In_ HANDLE  Handle,
_In_ PMDL  BufferMdl,
_In_ SIZE_T  BufferSize 
)

Definition at line 674 of file hdaudio.cpp.

679 {
680 UNREFERENCED_PARAMETER(BufferMdl);
682
684 return STATUS_UNSUCCESSFUL;
685 }
686
687 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
688 if (!devData->FdoContext) {
690 }
691
693 if (stream->PdoContext != devData) {
695 }
696
697 if (stream->running) {
699 }
700
701 if (!stream->mdlBuf) {
703 }
704
705 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
706
707 stream_write32(stream, SD_BDLPL, 0);
708 stream_write32(stream, SD_BDLPU, 0);
709 stream_write32(stream, SD_CTL, 0);
710
711 PMDL mdl = stream->mdlBuf;
712 stream->mdlBuf = NULL;
713
714 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
715
718
719 return STATUS_SUCCESS;
720}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
VOID NTAPI MmFreePagesFromMdl(IN PMDL Mdl)
Definition: mdlsup.c:564
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by HDA_BusInterfaceV2(), HDA_BusInterfaceV3(), and HDA_FreeDmaBuffer().

◆ HDA_FreeDmaEngine()

NTSTATUS NTAPI HDA_FreeDmaEngine ( _In_ PVOID  _context,
_In_ HANDLE  Handle 
)

Definition at line 296 of file hdaudio.cpp.

299 {
301 return STATUS_UNSUCCESSFUL;
302 }
303
304 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
305 if (!devData->FdoContext) {
307 }
308
310 if (stream->PdoContext != devData) {
312 }
313
314 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
315
316 if (stream->running) {
317 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
319 }
320
321 stream->PdoContext = NULL;
322 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
323
325
326 return STATUS_SUCCESS;
327}

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_GetDeviceInformation()

NTSTATUS NTAPI HDA_GetDeviceInformation ( _In_ PVOID  _context,
_Inout_ PHDAUDIO_DEVICE_INFORMATION  DeviceInformation 
)

Definition at line 482 of file hdaudio.cpp.

485 {
486 if (!_context)
488
489 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
490 if (!devData->FdoContext) {
492 }
493
494 if (DeviceInformation->Size >= sizeof(HDAUDIO_DEVICE_INFORMATION)) {
495 DeviceInformation->CodecsDetected = devData->FdoContext->numCodecs;
496 DeviceInformation->DeviceVersion = devData->FdoContext->hwVersion;
497 DeviceInformation->DriverVersion = 0x100;
498 DeviceInformation->IsStripingSupported = TRUE;
499 }
500 if (DeviceInformation->Size >= sizeof(HDAUDIO_DEVICE_INFORMATION_V2)) {
501 PHDAUDIO_DEVICE_INFORMATION_V2 DeviceInformationV2 = (PHDAUDIO_DEVICE_INFORMATION_V2)DeviceInformation;
502 DeviceInformationV2->CtrlRevision = devData->FdoContext->revId;
503 DeviceInformationV2->CtrlVendorId = devData->FdoContext->venId;
504 DeviceInformationV2->CtrlDeviceId = devData->FdoContext->devId;
505 }
506
507 return STATUS_SUCCESS;
508}
struct _HDAUDIO_DEVICE_INFORMATION_V2 * PHDAUDIO_DEVICE_INFORMATION_V2
UINT8 revId
Definition: fdo.h:119
USHORT numCodecs
Definition: fdo.h:161
UINT16 hwVersion
Definition: fdo.h:141
UINT16 venId
Definition: fdo.h:117
UINT16 devId
Definition: fdo.h:118

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_GetLinkPositionRegister()

NTSTATUS NTAPI HDA_GetLinkPositionRegister ( _In_ PVOID  _context,
_In_ HANDLE  Handle,
_Out_ PULONG Position 
)

Definition at line 388 of file hdaudio.cpp.

392 {
393 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
394 if (!devData->FdoContext) {
396 }
397
399 if (stream->PdoContext != devData) {
401 }
402
403 if (devData->CodecIds.CtlrVenId != VEN_INTEL) //Experimental Non-Intel support
404 *Position = (ULONG*)(stream->sdAddr + HDA_REG_SD_LPIBA);
405 else
406 *Position = (ULONG *)stream->posbuf; //Use Posbuf for all Intel
407
408 return STATUS_SUCCESS;
409}
#define VEN_INTEL
Definition: driver.h:46
#define HDA_REG_SD_LPIBA
Definition: hda_registers.h:81
UINT16 CtlrVenId
Definition: buspdo.h:19
static COORD Position
Definition: mouse.c:34
uint32_t ULONG
Definition: typedefs.h:59

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_GetResourceInformation()

void NTAPI HDA_GetResourceInformation ( _In_ PVOID  _context,
_Out_ PUCHAR  CodecAddress,
_Out_ PUCHAR  FunctionGroupStartNode 
)

Definition at line 512 of file hdaudio.cpp.

516 {
517 if (!_context)
518 return;
519
520 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
521 if (CodecAddress)
522 *CodecAddress = (UINT8)devData->CodecIds.CodecAddress;
523 if (FunctionGroupStartNode)
524 *FunctionGroupStartNode = devData->CodecIds.FunctionGroupStartNode;
525}
unsigned char UINT8
Definition: actypes.h:128
if(dx< 0)
Definition: linetemp.h:194
UINT8 FunctionGroupStartNode
Definition: buspdo.h:16

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_GetWallClockRegister()

VOID NTAPI HDA_GetWallClockRegister ( _In_ PVOID  _context,
_Out_ PULONG Wallclock 
)

Definition at line 374 of file hdaudio.cpp.

377 {
378 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
379 if (!devData->FdoContext) {
380 *Wallclock = NULL;
381 return;
382 }
383 *Wallclock = (ULONG *)((devData->FdoContext)->m_BAR0.Base.baseptr + HDA_REG_WALLCLKA);
384}
#define HDA_REG_WALLCLKA
Definition: hda_registers.h:26

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_RegisterEventCallback()

NTSTATUS NTAPI HDA_RegisterEventCallback ( _In_ PVOID  _context,
_In_ PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK  Routine,
_In_opt_ PVOID  Context,
_Out_ PUCHAR  Tag 
)

Definition at line 413 of file hdaudio.cpp.

418 {
419 if (!_context)
421
422
423 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
424 if (devData->FdoContext) {
425 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
426 }
427
428 for (UINT8 i = 0; i < MAX_UNSOLICIT_CALLBACKS; i++) {
429 if (devData->unsolitCallbacks[i].inUse)
430 continue;
431
432 if (Tag)
433 *Tag = i;
434
435 devData->unsolitCallbacks[i].inUse = TRUE;
436 devData->unsolitCallbacks[i].Context = Context;
437 devData->unsolitCallbacks[i].Routine = Routine;
438
439 if (devData->FdoContext) {
440 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
441 }
442 return STATUS_SUCCESS;
443 }
444
445 if (devData->FdoContext) {
446 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
447 }
449}
#define MAX_UNSOLICIT_CALLBACKS
Definition: buspdo.h:40
PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK Routine
Definition: buspdo.h:9
CODEC_UNSOLICITED_CALLBACK unsolitCallbacks[MAX_UNSOLICIT_CALLBACKS]
Definition: buspdo.h:53
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4071

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_RegisterNotificationCallback()

NTSTATUS NTAPI HDA_RegisterNotificationCallback ( _In_ PVOID  _context,
_In_ HANDLE  Handle,
PDEVICE_OBJECT  Fdo,
PHDAUDIO_DMA_NOTIFICATION_CALLBACK  NotificationCallback,
PVOID  CallbackContext 
)

Definition at line 818 of file hdaudio.cpp.

824 {
825 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
826 if (!devData->FdoContext) {
828 }
829
831 if (stream->PdoContext != devData) {
833 }
834
835 BOOL registered = FALSE;
836
837 for (int i = 0; i < MAX_NOTIF_EVENTS; i++) {
838 if (stream->registeredCallbacks[i].InUse)
839 continue;
840 stream->registeredCallbacks[i].InUse = TRUE;
841 stream->registeredCallbacks[i].Fdo = Fdo;
842 stream->registeredCallbacks[i].NotificationCallback = NotificationCallback;
843 stream->registeredCallbacks[i].CallbackContext = CallbackContext;
844
845 InterlockedIncrement(&Fdo->ReferenceCount);
846
847 registered = true;
848 break;
849 }
850
851 return registered ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
852}
static DRIVER_NOTIFICATION_CALLBACK_ROUTINE NotificationCallback
#define InterlockedIncrement
Definition: armddk.h:53
#define MAX_NOTIF_EVENTS
Definition: fdo.h:17
unsigned int BOOL
Definition: ntddk_ex.h:94
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR _In_ ULONGLONG _In_ ULONGLONG _In_opt_ PEVENT_FILTER_DESCRIPTOR _Inout_opt_ PVOID CallbackContext
Definition: wmitypes.h:60

Referenced by HDA_BusInterfaceV3().

◆ HDA_RegisterNotificationEvent()

NTSTATUS NTAPI HDA_RegisterNotificationEvent ( _In_ PVOID  _context,
_In_ HANDLE  Handle,
_In_ PKEVENT  NotificationEvent 
)

Definition at line 758 of file hdaudio.cpp.

762 {
763 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
764 if (!devData->FdoContext) {
766 }
767
769 if (stream->PdoContext != devData) {
771 }
772
773 BOOL registered = FALSE;
774
775 for (int i = 0; i < MAX_NOTIF_EVENTS; i++) {
776 if (stream->registeredEvents[i])
777 continue;
778 stream->registeredEvents[i] = NotificationEvent;
779 registered = true;
780 break;
781 }
782
783 return registered ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
784}
@ NotificationEvent

Referenced by HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_SetDmaEngineState()

NTSTATUS NTAPI HDA_SetDmaEngineState ( _In_ PVOID  _context,
_In_ HDAUDIO_STREAM_STATE  StreamState,
_In_ ULONG  NumberOfHandles,
_In_reads_(NumberOfHandles) PHANDLE  Handles 
)

Definition at line 331 of file hdaudio.cpp.

336 {
337 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
338 if (!devData->FdoContext) {
340 }
341
342 for (ULONG i = 0; i < NumberOfHandles; i++) {
343 PHDAC_STREAM stream = (PHDAC_STREAM)Handles[i];
344 if (stream->PdoContext != devData) {
346 }
347
348 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
349
350 if (StreamState == RunState && !stream->running) {
353 stream->running = TRUE;
354 }
355 else if ((StreamState == PauseState || StreamState == StopState) && stream->running) {
357 stream->running = FALSE;
358 }
359 else if (StreamState == ResetState) {
360 if (!stream->running) {
363 }
364 }
365
366 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
367 }
368
369 return STATUS_SUCCESS;
370}
void hdac_stream_stop(PHDAC_STREAM stream)
Definition: hdac_stream.cpp:30
void hdac_stream_start(PHDAC_STREAM stream)
Definition: hdac_stream.cpp:3
@ PauseState
Definition: hdaudio.h:86
@ RunState
Definition: hdaudio.h:87
@ StopState
Definition: hdaudio.h:85
@ ResetState
Definition: hdaudio.h:84

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_SetupDmaEngineWithBdl()

NTSTATUS NTAPI HDA_SetupDmaEngineWithBdl ( _In_ PVOID  _context,
_In_ HANDLE  Handle,
_In_ ULONG  BufferLength,
_In_ ULONG  Lvi,
_In_ PHDAUDIO_BDL_ISR  Isr,
_In_ PVOID  Context,
_Out_ PUCHAR  StreamId,
_Out_ PULONG  FifoSize 
)

Definition at line 892 of file hdaudio.cpp.

901{
903 return STATUS_UNSUCCESSFUL;
904 }
905
906 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
907 if (!devData->FdoContext) {
909 }
910
912 if (stream->PdoContext != devData) {
914 }
915
916 if (stream->running) {
918 }
919
920 if (!stream->bdl) {
922 }
923
924 if (!stream->dmaBuf) {
926 }
927
928 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
929
930 stream->bufSz = BufferLength;
931 stream->numBlocks = (UINT16)Lvi;
932
933 RtlZeroMemory(&stream->isr, sizeof(HDAC_ISR_CALLBACK));
934 stream->isr.IOC = TRUE;
935 stream->isr.IsrCallback = Isr;
936 stream->isr.CallbackContext = Context;
937
940
941 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
942
943 *StreamId = stream->streamTag;
944 *FifoSize = stream->fifoSize;
945
946 return STATUS_SUCCESS;
947}
static BOOLEAN NTAPI Isr(PKINTERRUPT Interrupt, PVOID ServiceContext)
Definition: floppy.c:581
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777

Referenced by HDA_BusInterfaceBDL().

◆ HDA_TransferCodecVerbs()

NTSTATUS NTAPI HDA_TransferCodecVerbs ( _In_ PVOID  _context,
_In_ ULONG  Count,
_Inout_updates_(Count) PHDAUDIO_CODEC_TRANSFER  CodecTransfer,
_In_opt_ PHDAUDIO_TRANSFER_COMPLETE_CALLBACK  Callback,
_In_opt_ PVOID  Context 
)

Definition at line 70 of file hdaudio.cpp.

77 {
78 SklHdAudBusPrint(DEBUG_LEVEL_VERBOSE, DBG_IOCTL, "%s called (Count: %d, Callback? %d)!\n", __func__, Count, Callback != NULL);
79
80 if (!_context)
82
84
85 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
86 if (!devData->FdoContext) {
88 }
89
90 PFDO_CONTEXT fdoCtx = devData->FdoContext;
91 if (devData->CodecIds.IsGraphicsCodec) {
92 if (!fdoCtx->GraphicsCodecConnected) {
93 SklHdAudBusPrint(DEBUG_LEVEL_VERBOSE, DBG_IOCTL, "Gfx codec 0x%x disconnected! Not transferring.\n", devData->CodecIds.CodecAddress);
95 }
96 }
97
99 if (!NT_SUCCESS(status)) {
100 return status;
101 }
102
103 status = SendHDACmds(fdoCtx, Count, CodecTransfer);
104 if (!NT_SUCCESS(status)) {
105 goto out;
106 }
107
108 if (Callback) { //TODO: Do this async
109 WDF_WORKITEM_CONFIG workItemConfig;
110 WDF_WORKITEM_CONFIG_INIT(&workItemConfig, HDA_AsyncWait);
111
112 WDF_OBJECT_ATTRIBUTES attributes;
113 WDFWORKITEM workItem;
114
115 WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
117 &attributes,
119 );
120 attributes.ParentObject = fdoCtx->WdfDevice;
121
122 WdfWorkItemCreate(&workItemConfig, &attributes, &workItem);
123
124 PHDA_ASYNC_CONTEXT workItemContext = HDAAsyncWorkItem_GetContext(workItem);
125 workItemContext->devData = devData;
126 workItemContext->Count = Count;
127 workItemContext->CodecTransfer = CodecTransfer;
128 workItemContext->Callback = Callback;
129 workItemContext->CallbackContext = Context;
130 WdfWorkItemEnqueue(workItem);
131 }
132 else {
133 status = HDA_WaitForTransfer(fdoCtx, (UINT16)devData->CodecIds.CodecAddress, Count, CodecTransfer);
134 if (!NT_SUCCESS(status)) {
135 goto out;
136 }
137 }
138
140
141out:
142 if (!Callback)
144 SklHdAudBusPrint(DEBUG_LEVEL_VERBOSE, DBG_IOCTL, "%s exit (Count: %d)!\n", __func__, Count);
145 return status;
146}
NTSTATUS SendHDACmds(PFDO_CONTEXT fdoCtx, ULONG count, PHDAUDIO_CODEC_TRANSFER CodecTransfer)
void NTAPI HDA_AsyncWait(WDFWORKITEM WorkItem)
Definition: hdaudio.cpp:43
int Count
Definition: noreturn.cpp:7
BOOL IsGraphicsCodec
Definition: buspdo.h:14
BOOLEAN GraphicsCodecConnected
Definition: fdo.h:132
WDFOBJECT ParentObject
Definition: wdfobject.h:130
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: wdfobject.h:147
#define WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(_attributes, _contexttype)
Definition: wdfobject.h:157
FORCEINLINE VOID WDF_WORKITEM_CONFIG_INIT(_Out_ PWDF_WORKITEM_CONFIG Config, _In_ PFN_WDF_WORKITEM EvtWorkItemFunc)
Definition: wdfworkitem.h:85

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_UnregisterEventCallback()

NTSTATUS NTAPI HDA_UnregisterEventCallback ( _In_ PVOID  _context,
_In_ UCHAR  Tag 
)

Definition at line 453 of file hdaudio.cpp.

456 {
457 if (!_context)
459
460 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
461 if (!devData->unsolitCallbacks[Tag].inUse) {
462 return STATUS_NOT_FOUND;
463 }
464
465 if (devData->FdoContext) {
466 WdfInterruptAcquireLock(devData->FdoContext->Interrupt);
467 }
468
469 devData->unsolitCallbacks[Tag].Routine = NULL;
470 devData->unsolitCallbacks[Tag].Context = NULL;
471 devData->unsolitCallbacks[Tag].inUse = FALSE;
472
473 if (devData->FdoContext) {
474 WdfInterruptReleaseLock(devData->FdoContext->Interrupt);
475 }
476
477 return STATUS_SUCCESS;
478}
#define STATUS_NOT_FOUND
Definition: shellext.h:72

Referenced by HDA_BusInterface(), HDA_BusInterfaceBDL(), HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_UnregisterNotificationCallback()

NTSTATUS NTAPI HDA_UnregisterNotificationCallback ( _In_ PVOID  _context,
_In_ HANDLE  Handle,
PHDAUDIO_DMA_NOTIFICATION_CALLBACK  NotificationCallback,
PVOID  CallbackContext 
)

Definition at line 856 of file hdaudio.cpp.

861 {
862 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
863 if (!devData->FdoContext) {
865 }
866
868 if (stream->PdoContext != devData) {
870 }
871
872 BOOL registered = FALSE;
873
874 for (int i = 0; i < MAX_NOTIF_EVENTS; i++) {
875 if (stream->registeredCallbacks[i].InUse &&
876 stream->registeredCallbacks[i].NotificationCallback != NotificationCallback &&
877 stream->registeredCallbacks[i].CallbackContext != CallbackContext)
878 continue;
879
880 InterlockedDecrement(&stream->registeredCallbacks[i].Fdo->ReferenceCount);
881
882 RtlZeroMemory(&stream->registeredCallbacks[i], sizeof(stream->registeredCallbacks[i]));
883 registered = true;
884 break;
885 }
886
887 return registered ? STATUS_SUCCESS : STATUS_INVALID_PARAMETER;
888}
#define InterlockedDecrement
Definition: armddk.h:52
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by HDA_BusInterfaceV3().

◆ HDA_UnregisterNotificationEvent()

NTSTATUS NTAPI HDA_UnregisterNotificationEvent ( _In_ PVOID  _context,
_In_ HANDLE  Handle,
_In_ PKEVENT  NotificationEvent 
)

Definition at line 788 of file hdaudio.cpp.

792 {
793 PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context;
794 if (!devData->FdoContext) {
796 }
797
799 if (stream->PdoContext != devData) {
801 }
802
803 BOOL registered = FALSE;
804
805 for (int i = 0; i < MAX_NOTIF_EVENTS; i++) {
806 if (stream->registeredEvents[i] != NotificationEvent)
807 continue;
808 stream->registeredEvents[i] = NULL;
809 registered = true;
810 break;
811 }
812
813 return registered ? STATUS_SUCCESS : STATUS_INVALID_PARAMETER;
814}

Referenced by HDA_BusInterfaceV2(), and HDA_BusInterfaceV3().

◆ HDA_WaitForTransfer()

NTSTATUS HDA_WaitForTransfer ( PFDO_CONTEXT  fdoCtx,
UINT16  codecAddr,
_In_ ULONG  Count,
_Inout_updates_(Count) PHDAUDIO_CODEC_TRANSFER  CodecTransfer 
)

Definition at line 3 of file hdaudio.cpp.

9 {
11
12 SklHdAudBusPrint(DEBUG_LEVEL_VERBOSE, DBG_IOCTL, "%s called (Count: %d)!\n", __func__, Count);
13
15 Timeout.QuadPart = -10LL * 1000LL * 1000LL * (LONGLONG)Count;
17 KeClearEvent(&fdoCtx->rirb.xferEvent[codecAddr]);
18
19 SklHdAudBusPrint(DEBUG_LEVEL_VERBOSE, DBG_IOCTL, "%s wait status: 0x%x!\n", __func__, status);
20
21 ULONG TransferredCount = 0;
22 for (ULONG i = 0; i < Count; i++) {
23 if (CodecTransfer[i].Input.IsValid) {
24 TransferredCount++;
25 }
26 }
27
28 if (TransferredCount < Count) {
29 InterlockedAdd(&fdoCtx->rirb.cmds[codecAddr], TransferredCount - Count);
30
31 SklHdAudBusPrint(DEBUG_LEVEL_VERBOSE, DBG_IOCTL, "%s timeout (Count: %d, transferred %d)!\n", __func__, Count, TransferredCount);
33 goto out;
34 }
35
36out:
37 SklHdAudBusPrint(DEBUG_LEVEL_VERBOSE, DBG_IOCTL, "%s exit (Count: %d)!\n", __func__, Count);
38 return status;
39}
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
#define InterlockedAdd
Definition: interlocked.h:66
#define KernelMode
Definition: asm.h:38
static ULONG Timeout
Definition: ping.c:61
@ Input
Definition: arc.h:93
HDAC_RB rirb
Definition: fdo.h:164
LONG cmds[HDA_MAX_CODECS]
Definition: fdo.h:95
KEVENT xferEvent[HDA_MAX_CODECS]
Definition: fdo.h:96
int64_t LONGLONG
Definition: typedefs.h:68
#define STATUS_IO_TIMEOUT
Definition: udferr_usr.h:163
@ Executive
Definition: ketypes.h:467

Referenced by HDA_AsyncWait(), HDA_TransferCodecVerbs(), and RunSingleHDACmd().