1 #ifndef _HDAUDIO_H_ 2 #define _HDAUDIO_H_ 3 4 #ifdef _MSC_VER 5 #pragma warning(disable:4201) 6 #pragma warning(disable:4214) 7 #endif 8 9 DEFINE_GUID(GUID_HDAUDIO_BUS_INTERFACE, 0xd2eaf88b, 0xab18, 0x41a8, 0xb6, 0x64, 0x8d, 0x59, 0x21, 0x67, 0x67, 0x1b); 10 DEFINE_GUID(GUID_HDAUDIO_BUS_INTERFACE_BDL, 0xb4d65397, 0x5634, 0x40b0, 0xb0, 0x68, 0xf5, 0xb9, 0xf8, 0xb9, 0x67, 0xa5); 11 DEFINE_GUID(GUID_HDAUDIO_BUS_INTERFACE_V2, 0xb52af5fb, 0x424b, 0x4bb9, 0xa1, 0x60, 0x5b, 0x38, 0xbe, 0x94, 0xe5, 0x68); 12 DEFINE_GUID(GUID_HDAUDIO_BUS_CLASS, 0xbbd1a745, 0xadd6, 0x4575, 0x9c, 0x2e, 0x9b, 0x42, 0x8d, 0x1c, 0x32, 0x66); 13 14 #ifndef _HDAUDIO_CODEC_TRANSFER_ 15 #define _HDAUDIO_CODEC_TRANSFER_ 16 17 typedef struct _HDAUDIO_CODEC_COMMAND { 18 union { 19 struct { 20 ULONG Data:8; 21 ULONG VerbId:12; 22 ULONG Node:8; 23 ULONG CodecAddress:4; 24 } Verb8; 25 struct { 26 ULONG Data:16; 27 ULONG VerbId:4; 28 ULONG Node:8; 29 ULONG CodecAddress:4; 30 } Verb16; 31 ULONG Command; 32 }; 33 } HDAUDIO_CODEC_COMMAND, *PHDAUDIO_CODEC_COMMAND; 34 35 typedef struct _HDAUDIO_CODEC_RESPONSE { 36 union { 37 struct { 38 union { 39 struct { 40 ULONG Response:26; 41 ULONG Tag:6; 42 } Unsolicited; 43 ULONG Response; 44 }; 45 ULONG SDataIn:4; 46 ULONG IsUnsolicitedResponse:1; 47 ULONG :25; 48 ULONG HasFifoOverrun:1; 49 ULONG IsValid:1; 50 }; 51 ULONGLONG CompleteResponse; 52 }; 53 } HDAUDIO_CODEC_RESPONSE, *PHDAUDIO_CODEC_RESPONSE; 54 55 typedef struct _HDAUDIO_CODEC_TRANSFER { 56 HDAUDIO_CODEC_COMMAND Output; 57 HDAUDIO_CODEC_RESPONSE Input; 58 } HDAUDIO_CODEC_TRANSFER, *PHDAUDIO_CODEC_TRANSFER; 59 60 #endif /* _HDAUDIO_CODEC_TRANSFER_ */ 61 62 typedef struct _HDAUDIO_STREAM_FORMAT { 63 ULONG SampleRate; 64 USHORT ValidBitsPerSample; 65 USHORT ContainerSize; 66 USHORT NumberOfChannels; 67 } HDAUDIO_STREAM_FORMAT, *PHDAUDIO_STREAM_FORMAT; 68 69 typedef struct _HDAUDIO_CONVERTER_FORMAT { 70 union { 71 struct { 72 USHORT NumberOfChannels:4; 73 USHORT BitsPerSample:3; 74 USHORT :1; 75 USHORT SampleRate:7; 76 USHORT StreamType:1; 77 }; 78 USHORT ConverterFormat; 79 }; 80 } HDAUDIO_CONVERTER_FORMAT, *PHDAUDIO_CONVERTER_FORMAT; 81 82 typedef enum _HDAUDIO_STREAM_STATE { 83 ResetState = 0, 84 StopState = 1, 85 PauseState = 1, 86 RunState = 2 87 } HDAUDIO_STREAM_STATE, *PHDAUDIO_STREAM_STATE; 88 89 typedef VOID 90 (NTAPI *PHDAUDIO_TRANSFER_COMPLETE_CALLBACK)( 91 HDAUDIO_CODEC_TRANSFER *, 92 PVOID); 93 94 typedef VOID 95 (NTAPI *PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK)( 96 HDAUDIO_CODEC_RESPONSE, 97 PVOID); 98 99 typedef struct _HDAUDIO_DEVICE_INFORMATION { 100 USHORT Size; /* size of this structure */ 101 USHORT DeviceVersion; /* maj.min (maj is high byte, min is low byte) */ 102 USHORT DriverVersion; /* maj.min (maj is high byte, min is low byte) */ 103 USHORT CodecsDetected; /* mask of codecs present. Bit number == SDI line number */ 104 BOOLEAN IsStripingSupported; /* TRUE if striping (2 SDO lines) is supported */ 105 } HDAUDIO_DEVICE_INFORMATION, *PHDAUDIO_DEVICE_INFORMATION; 106 107 typedef struct _HDAUDIO_BUFFER_DESCRIPTOR { 108 PHYSICAL_ADDRESS Address; 109 ULONG Length; 110 ULONG InterruptOnCompletion; 111 } HDAUDIO_BUFFER_DESCRIPTOR, *PHDAUDIO_BUFFER_DESCRIPTOR; 112 113 typedef 114 _Must_inspect_result_ 115 NTSTATUS 116 (NTAPI *PTRANSFER_CODEC_VERBS)( 117 _In_ PVOID _context, 118 _In_ ULONG Count, 119 _Inout_updates_(Count) PHDAUDIO_CODEC_TRANSFER CodecTransfer, 120 _In_opt_ PHDAUDIO_TRANSFER_COMPLETE_CALLBACK Callback, 121 _In_opt_ PVOID Context); 122 123 typedef 124 _Must_inspect_result_ 125 NTSTATUS 126 (NTAPI *PALLOCATE_CAPTURE_DMA_ENGINE)( 127 _In_ PVOID _context, 128 _In_ UCHAR CodecAddress, 129 _In_ PHDAUDIO_STREAM_FORMAT StreamFormat, 130 _Out_ PHANDLE Handle, 131 _Out_ PHDAUDIO_CONVERTER_FORMAT ConverterFormat); 132 133 typedef 134 _Must_inspect_result_ 135 NTSTATUS 136 (NTAPI *PALLOCATE_RENDER_DMA_ENGINE)( 137 _In_ PVOID _context, 138 _In_ PHDAUDIO_STREAM_FORMAT StreamFormat, 139 _In_ BOOLEAN Stripe, 140 _Out_ PHANDLE Handle, 141 _Out_ PHDAUDIO_CONVERTER_FORMAT ConverterFormat); 142 143 typedef 144 _Must_inspect_result_ 145 NTSTATUS 146 (NTAPI *PCHANGE_BANDWIDTH_ALLOCATION)( 147 _In_ PVOID _context, 148 _In_ HANDLE Handle, 149 _In_ PHDAUDIO_STREAM_FORMAT StreamFormat, 150 _Out_ PHDAUDIO_CONVERTER_FORMAT ConverterFormat); 151 152 typedef 153 _Must_inspect_result_ 154 NTSTATUS 155 (NTAPI *PALLOCATE_DMA_BUFFER)( 156 _In_ PVOID _context, 157 _In_ HANDLE Handle, 158 _In_ SIZE_T RequestedBufferSize, 159 _Out_ PMDL *BufferMdl, 160 _Out_ PSIZE_T AllocatedBufferSize, 161 _Out_ PUCHAR StreamId, 162 _Out_ PULONG FifoSize); 163 164 typedef 165 _Must_inspect_result_ 166 NTSTATUS 167 (NTAPI *PFREE_DMA_BUFFER)( 168 _In_ PVOID _context, 169 _In_ HANDLE Handle); 170 171 typedef 172 _Must_inspect_result_ 173 NTSTATUS 174 (NTAPI *PFREE_DMA_ENGINE)( 175 _In_ PVOID _context, 176 _In_ HANDLE Handle); 177 178 typedef 179 _Must_inspect_result_ 180 NTSTATUS 181 (NTAPI *PSET_DMA_ENGINE_STATE)( 182 _In_ PVOID _context, 183 _In_ HDAUDIO_STREAM_STATE StreamState, 184 _In_ ULONG NumberOfHandles, 185 _In_reads_(NumberOfHandles) PHANDLE Handles); 186 187 typedef VOID 188 (NTAPI *PGET_WALL_CLOCK_REGISTER)( 189 _In_ PVOID _context, 190 _Out_ PULONG *Wallclock); 191 192 typedef 193 _Must_inspect_result_ 194 NTSTATUS 195 (NTAPI *PGET_LINK_POSITION_REGISTER)( 196 _In_ PVOID _context, 197 _In_ HANDLE Handle, 198 _Out_ PULONG *Position); 199 200 typedef 201 _Must_inspect_result_ 202 NTSTATUS 203 (NTAPI *PREGISTER_EVENT_CALLBACK)( 204 _In_ PVOID _context, 205 _In_ PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK Routine, 206 _In_opt_ PVOID Context, 207 _Out_ PUCHAR Tag); 208 209 typedef 210 _Must_inspect_result_ 211 NTSTATUS 212 (NTAPI *PUNREGISTER_EVENT_CALLBACK)( 213 _In_ PVOID _context, 214 _In_ UCHAR Tag); 215 216 typedef 217 _Must_inspect_result_ 218 NTSTATUS 219 (NTAPI *PGET_DEVICE_INFORMATION)( 220 _In_ PVOID _context, 221 _Out_ PHDAUDIO_DEVICE_INFORMATION DeviceInformation); 222 223 typedef VOID 224 (NTAPI *PGET_RESOURCE_INFORMATION)( 225 _In_ PVOID _context, 226 _Out_ PUCHAR CodecAddress, 227 _Out_ PUCHAR FunctionGroupStartNode); 228 229 typedef struct _HDAUDIO_BUS_INTERFACE { 230 USHORT Size; 231 USHORT Version; 232 PVOID Context; 233 PINTERFACE_REFERENCE InterfaceReference; 234 PINTERFACE_DEREFERENCE InterfaceDereference; 235 PTRANSFER_CODEC_VERBS TransferCodecVerbs; 236 PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine; 237 PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine; 238 PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation; 239 PALLOCATE_DMA_BUFFER AllocateDmaBuffer; 240 PFREE_DMA_BUFFER FreeDmaBuffer; 241 PFREE_DMA_ENGINE FreeDmaEngine; 242 PSET_DMA_ENGINE_STATE SetDmaEngineState; 243 PGET_WALL_CLOCK_REGISTER GetWallClockRegister; 244 PGET_LINK_POSITION_REGISTER GetLinkPositionRegister; 245 PREGISTER_EVENT_CALLBACK RegisterEventCallback; 246 PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback; 247 PGET_DEVICE_INFORMATION GetDeviceInformation; 248 PGET_RESOURCE_INFORMATION GetResourceInformation; 249 } HDAUDIO_BUS_INTERFACE, *PHDAUDIO_BUS_INTERFACE; 250 251 typedef void 252 (NTAPI *PHDAUDIO_BDL_ISR)( 253 _In_ VOID *Context, 254 _In_ ULONG InterruptBitMask); 255 256 typedef 257 _Must_inspect_result_ 258 NTSTATUS 259 (NTAPI *PALLOCATE_CONTIGUOUS_DMA_BUFFER)( 260 _In_ PVOID _context, 261 _In_ HANDLE Handle, 262 ULONG RequestedBufferSize, 263 _Out_ PVOID *DataBuffer, 264 _Out_ PHDAUDIO_BUFFER_DESCRIPTOR *BdlBuffer); 265 266 typedef 267 _Must_inspect_result_ 268 NTSTATUS 269 (NTAPI *PFREE_CONTIGUOUS_DMA_BUFFER)( 270 _In_ PVOID _context, 271 _In_ HANDLE Handle); 272 273 typedef 274 _Must_inspect_result_ 275 NTSTATUS 276 (NTAPI *PSETUP_DMA_ENGINE_WITH_BDL)( 277 _In_reads_bytes_(BufferLength) PVOID _context, 278 _In_ HANDLE Handle, 279 _In_ ULONG BufferLength, 280 _In_ ULONG Lvi, 281 _In_ PHDAUDIO_BDL_ISR Isr, 282 _In_ PVOID Context, 283 _Out_ PUCHAR StreamId, 284 _Out_ PULONG FifoSize); 285 286 typedef struct _HDAUDIO_BUS_INTERFACE_BDL { 287 USHORT Size; 288 USHORT Version; 289 PVOID Context; 290 PINTERFACE_REFERENCE InterfaceReference; 291 PINTERFACE_DEREFERENCE InterfaceDereference; 292 PTRANSFER_CODEC_VERBS TransferCodecVerbs; 293 PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine; 294 PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine; 295 PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation; 296 PALLOCATE_CONTIGUOUS_DMA_BUFFER AllocateContiguousDmaBuffer; 297 PSETUP_DMA_ENGINE_WITH_BDL SetupDmaEngineWithBdl; 298 PFREE_CONTIGUOUS_DMA_BUFFER FreeContiguousDmaBuffer; 299 PFREE_DMA_ENGINE FreeDmaEngine; 300 PSET_DMA_ENGINE_STATE SetDmaEngineState; 301 PGET_WALL_CLOCK_REGISTER GetWallClockRegister; 302 PGET_LINK_POSITION_REGISTER GetLinkPositionRegister; 303 PREGISTER_EVENT_CALLBACK RegisterEventCallback; 304 PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback; 305 PGET_DEVICE_INFORMATION GetDeviceInformation; 306 PGET_RESOURCE_INFORMATION GetResourceInformation; 307 } HDAUDIO_BUS_INTERFACE_BDL, *PHDAUDIO_BUS_INTERFACE_BDL; 308 309 typedef 310 _Must_inspect_result_ 311 NTSTATUS 312 (NTAPI *PALLOCATE_DMA_BUFFER_WITH_NOTIFICATION)( 313 _In_ PVOID _context, 314 _In_ HANDLE Handle, 315 _In_ ULONG NotificationCount, 316 _In_ SIZE_T RequestedBufferSize, 317 _Out_ PMDL *BufferMdl, 318 _Out_ PSIZE_T AllocatedBufferSize, 319 _Out_ PSIZE_T OffsetFromFirstPage, 320 _Out_ PUCHAR StreamId, 321 _Out_ PULONG FifoSize); 322 323 typedef 324 _Must_inspect_result_ 325 NTSTATUS 326 (NTAPI *PFREE_DMA_BUFFER_WITH_NOTIFICATION)( 327 _In_ PVOID _context, 328 _In_ HANDLE Handle, 329 _In_ PMDL BufferMdl, 330 _In_ SIZE_T BufferSize); 331 332 typedef 333 _Must_inspect_result_ 334 NTSTATUS 335 (NTAPI *PREGISTER_NOTIFICATION_EVENT)( 336 _In_ PVOID _context, 337 _In_ HANDLE Handle, 338 _In_ PKEVENT NotificationEvent); 339 340 typedef 341 _Must_inspect_result_ 342 NTSTATUS 343 (NTAPI *PUNREGISTER_NOTIFICATION_EVENT)( 344 _In_ PVOID _context, 345 _In_ HANDLE Handle, 346 _In_ PKEVENT NotificationEvent); 347 348 typedef struct _HDAUDIO_BUS_INTERFACE_V2 { 349 USHORT Size; 350 USHORT Version; 351 PVOID Context; 352 PINTERFACE_REFERENCE InterfaceReference; 353 PINTERFACE_DEREFERENCE InterfaceDereference; 354 PTRANSFER_CODEC_VERBS TransferCodecVerbs; 355 PALLOCATE_CAPTURE_DMA_ENGINE AllocateCaptureDmaEngine; 356 PALLOCATE_RENDER_DMA_ENGINE AllocateRenderDmaEngine; 357 PCHANGE_BANDWIDTH_ALLOCATION ChangeBandwidthAllocation; 358 PALLOCATE_DMA_BUFFER AllocateDmaBuffer; 359 PFREE_DMA_BUFFER FreeDmaBuffer; 360 PFREE_DMA_ENGINE FreeDmaEngine; 361 PSET_DMA_ENGINE_STATE SetDmaEngineState; 362 PGET_WALL_CLOCK_REGISTER GetWallClockRegister; 363 PGET_LINK_POSITION_REGISTER GetLinkPositionRegister; 364 PREGISTER_EVENT_CALLBACK RegisterEventCallback; 365 PUNREGISTER_EVENT_CALLBACK UnregisterEventCallback; 366 PGET_DEVICE_INFORMATION GetDeviceInformation; 367 PGET_RESOURCE_INFORMATION GetResourceInformation; 368 PALLOCATE_DMA_BUFFER_WITH_NOTIFICATION AllocateDmaBufferWithNotification; 369 PFREE_DMA_BUFFER_WITH_NOTIFICATION FreeDmaBufferWithNotification; 370 PREGISTER_NOTIFICATION_EVENT RegisterNotificationEvent; 371 PUNREGISTER_NOTIFICATION_EVENT UnregisterNotificationEvent; 372 } HDAUDIO_BUS_INTERFACE_V2, *PHDAUDIO_BUS_INTERFACE_V2; 373 374 #ifdef _MSC_VER 375 #pragma warning(default:4201) 376 #pragma warning(default:4214) 377 #endif 378 379 #endif /* _HDAUDIO_H_ */ 380