1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS Kernel Streaming 4 * FILE: drivers/wdm/audio/hdaudbus/hdaudbus.cpp 5 * PURPOSE: HDA Driver Entry 6 * PROGRAMMER: Johannes Anderwald 7 */ 8 #include "hdaudbus.h" 9 10 11 VOID 12 NTAPI 13 HDA_InterfaceReference( 14 PVOID BusContext) 15 { 16 DPRINT1("HDA_InterfaceReference\n"); 17 } 18 19 VOID 20 NTAPI 21 HDA_InterfaceDereference( 22 PVOID BusContext) 23 { 24 DPRINT1("HDA_InterfaceDereference\n"); 25 } 26 27 NTSTATUS 28 NTAPI 29 HDA_TransferCodecVerbs( 30 IN PVOID _context, 31 IN ULONG Count, 32 IN OUT PHDAUDIO_CODEC_TRANSFER CodecTransfer, 33 IN PHDAUDIO_TRANSFER_COMPLETE_CALLBACK Callback, 34 IN PVOID Context) 35 { 36 ULONG Verbs[MAX_CODEC_RESPONSES], Responses[MAX_CODEC_RESPONSES]; 37 ULONG Index; 38 PHDA_PDO_DEVICE_EXTENSION DeviceExtension; 39 40 DPRINT1("HDA_TransferCodecVerbs Count %lu CodecTransfer %p Callback %p Context %p\n", Count, CodecTransfer, Callback, Context); 41 42 /* get device extension */ 43 DeviceExtension = (PHDA_PDO_DEVICE_EXTENSION)_context; 44 ASSERT(DeviceExtension->IsFDO == FALSE); 45 46 /* FIXME handle callback*/ 47 ASSERT(Callback == NULL); 48 49 for (Index = 0; Index < Count; Index++) 50 { 51 Verbs[Index] = CodecTransfer[Index].Output.Command; 52 } 53 54 HDA_SendVerbs(DeviceExtension->FDO, DeviceExtension->Codec, Verbs, Responses, Count); 55 56 for (Index = 0; Index < DeviceExtension->Codec->ResponseCount; Index++) 57 { 58 CodecTransfer[Index].Input.Response = DeviceExtension->Codec->Responses[Index]; 59 } 60 return STATUS_SUCCESS; 61 } 62 63 NTSTATUS 64 NTAPI 65 HDA_AllocateCaptureDmaEngine( 66 IN PVOID _context, 67 IN UCHAR CodecAddress, 68 IN PHDAUDIO_STREAM_FORMAT StreamFormat, 69 OUT PHANDLE Handle, 70 OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat) 71 { 72 UNIMPLEMENTED; 73 ASSERT(FALSE); 74 return STATUS_NOT_IMPLEMENTED; 75 } 76 77 NTSTATUS 78 NTAPI 79 HDA_AllocateRenderDmaEngine( 80 IN PVOID _context, 81 IN PHDAUDIO_STREAM_FORMAT StreamFormat, 82 IN BOOLEAN Stripe, 83 OUT PHANDLE Handle, 84 OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat) 85 { 86 UNIMPLEMENTED; 87 ASSERT(FALSE); 88 return STATUS_NOT_IMPLEMENTED; 89 } 90 91 NTSTATUS 92 NTAPI 93 HDA_ChangeBandwidthAllocation( 94 IN PVOID _context, 95 IN HANDLE Handle, 96 IN PHDAUDIO_STREAM_FORMAT StreamFormat, 97 OUT PHDAUDIO_CONVERTER_FORMAT ConverterFormat) 98 { 99 UNIMPLEMENTED; 100 ASSERT(FALSE); 101 return STATUS_NOT_IMPLEMENTED; 102 } 103 104 NTSTATUS 105 NTAPI 106 HDA_AllocateDmaBuffer( 107 IN PVOID _context, 108 IN HANDLE Handle, 109 IN SIZE_T RequestedBufferSize, 110 OUT PMDL *BufferMdl, 111 OUT PSIZE_T AllocatedBufferSize, 112 OUT PUCHAR StreamId, 113 OUT PULONG FifoSize) 114 { 115 UNIMPLEMENTED; 116 ASSERT(FALSE); 117 return STATUS_NOT_IMPLEMENTED; 118 } 119 120 NTSTATUS 121 NTAPI 122 HDA_FreeDmaBuffer( 123 IN PVOID _context, 124 IN HANDLE Handle) 125 { 126 UNIMPLEMENTED; 127 ASSERT(FALSE); 128 return STATUS_NOT_IMPLEMENTED; 129 } 130 131 NTSTATUS 132 NTAPI 133 HDA_FreeDmaEngine( 134 IN PVOID _context, 135 IN HANDLE Handle) 136 { 137 UNIMPLEMENTED; 138 ASSERT(FALSE); 139 return STATUS_NOT_IMPLEMENTED; 140 } 141 142 NTSTATUS 143 NTAPI 144 HDA_SetDmaEngineState( 145 IN PVOID _context, 146 IN HDAUDIO_STREAM_STATE StreamState, 147 IN ULONG NumberOfHandles, 148 IN PHANDLE Handles) 149 { 150 UNIMPLEMENTED; 151 ASSERT(FALSE); 152 return STATUS_NOT_IMPLEMENTED; 153 } 154 155 VOID 156 NTAPI 157 HDA_GetWallClockRegister( 158 IN PVOID _context, 159 OUT PULONG *Wallclock) 160 { 161 UNIMPLEMENTED; 162 ASSERT(FALSE); 163 } 164 165 NTSTATUS 166 NTAPI 167 HDA_GetLinkPositionRegister( 168 IN PVOID _context, 169 IN HANDLE Handle, 170 OUT PULONG *Position) 171 { 172 UNIMPLEMENTED; 173 ASSERT(FALSE); 174 return STATUS_NOT_IMPLEMENTED; 175 } 176 177 NTSTATUS 178 NTAPI 179 HDA_RegisterEventCallback( 180 IN PVOID _context, 181 IN PHDAUDIO_UNSOLICITED_RESPONSE_CALLBACK Routine, 182 IN PVOID Context, 183 OUT PUCHAR Tag) 184 { 185 UNIMPLEMENTED; 186 *Tag = 1; 187 return STATUS_SUCCESS; 188 } 189 190 191 NTSTATUS 192 NTAPI 193 HDA_UnregisterEventCallback( 194 IN PVOID _context, 195 IN UCHAR Tag) 196 { 197 UNIMPLEMENTED; 198 ASSERT(FALSE); 199 return STATUS_NOT_IMPLEMENTED; 200 } 201 202 NTSTATUS 203 NTAPI 204 HDA_GetDeviceInformation( 205 IN PVOID _context, 206 OUT PHDAUDIO_DEVICE_INFORMATION DeviceInformation) 207 { 208 PHDA_PDO_DEVICE_EXTENSION DeviceExtension; 209 210 DeviceExtension = (PHDA_PDO_DEVICE_EXTENSION)_context; 211 212 DPRINT1("HDA_GetDeviceInformation\n"); 213 214 DeviceInformation->Size = sizeof(HDAUDIO_DEVICE_INFORMATION); 215 DeviceInformation->CodecsDetected = 1; // FIXME 216 DeviceInformation->DeviceVersion = DeviceExtension->Codec->Major << 8 | DeviceExtension->Codec->Minor; 217 DeviceInformation->DriverVersion = DeviceExtension->Codec->Major << 8 | DeviceExtension->Codec->Minor; 218 DeviceInformation->IsStripingSupported = FALSE; 219 220 return STATUS_SUCCESS; 221 } 222 223 VOID 224 NTAPI 225 HDA_GetResourceInformation( 226 IN PVOID _context, 227 OUT PUCHAR CodecAddress, 228 OUT PUCHAR FunctionGroupStartNode) 229 { 230 PHDA_PDO_DEVICE_EXTENSION DeviceExtension; 231 232 DeviceExtension = (PHDA_PDO_DEVICE_EXTENSION)_context; 233 234 DPRINT1("HDA_GetResourceInformation Addr %x NodeId %x\n", DeviceExtension->Codec->Addr, DeviceExtension->AudioGroup->NodeId); 235 236 *CodecAddress = DeviceExtension->Codec->Addr; 237 *FunctionGroupStartNode = DeviceExtension->AudioGroup->NodeId; 238 } 239 240 NTSTATUS 241 NTAPI 242 HDA_AllocateDmaBufferWithNotification( 243 IN PVOID _context, 244 IN HANDLE Handle, 245 IN ULONG NotificationCount, 246 IN SIZE_T RequestedBufferSize, 247 OUT PMDL *BufferMdl, 248 OUT PSIZE_T AllocatedBufferSize, 249 OUT PSIZE_T OffsetFromFirstPage, 250 OUT PUCHAR StreamId, 251 OUT PULONG FifoSize) 252 { 253 UNIMPLEMENTED; 254 ASSERT(FALSE); 255 return STATUS_NOT_IMPLEMENTED; 256 257 } 258 NTSTATUS 259 NTAPI 260 HDA_FreeDmaBufferWithNotification( 261 IN PVOID _context, 262 IN HANDLE Handle, 263 IN PMDL BufferMdl, 264 IN SIZE_T BufferSize) 265 { 266 UNIMPLEMENTED; 267 ASSERT(FALSE); 268 return STATUS_NOT_IMPLEMENTED; 269 270 } 271 272 NTSTATUS 273 NTAPI 274 HDA_RegisterNotificationEvent( 275 PVOID _context, 276 HANDLE Handle, 277 IN PKEVENT NotificationEvent) 278 { 279 UNIMPLEMENTED; 280 ASSERT(FALSE); 281 return STATUS_NOT_IMPLEMENTED; 282 283 } 284 285 NTSTATUS 286 NTAPI 287 HDA_UnregisterNotificationEvent( 288 IN PVOID _context, 289 IN HANDLE Handle, 290 IN PKEVENT NotificationEvent) 291 { 292 UNIMPLEMENTED; 293 ASSERT(FALSE); 294 return STATUS_NOT_IMPLEMENTED; 295 } 296 297 298 NTSTATUS 299 HDA_PDOHandleQueryInterface( 300 IN PDEVICE_OBJECT DeviceObject, 301 IN PIRP Irp) 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 311 IoStack = IoGetCurrentIrpStackLocation(Irp); 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; 319 InterfaceHDA->InterfaceReference = HDA_InterfaceReference; 320 InterfaceHDA->InterfaceDereference = HDA_InterfaceDereference; 321 322 InterfaceHDA->TransferCodecVerbs = HDA_TransferCodecVerbs; 323 InterfaceHDA->AllocateCaptureDmaEngine = HDA_AllocateCaptureDmaEngine; 324 InterfaceHDA->AllocateRenderDmaEngine = HDA_AllocateRenderDmaEngine; 325 InterfaceHDA->ChangeBandwidthAllocation = HDA_ChangeBandwidthAllocation; 326 InterfaceHDA->AllocateDmaBuffer = HDA_AllocateDmaBuffer; 327 InterfaceHDA->FreeDmaBuffer = HDA_FreeDmaBuffer; 328 InterfaceHDA->FreeDmaEngine = HDA_FreeDmaEngine; 329 InterfaceHDA->SetDmaEngineState = HDA_SetDmaEngineState; 330 InterfaceHDA->GetWallClockRegister = HDA_GetWallClockRegister; 331 InterfaceHDA->GetLinkPositionRegister = HDA_GetLinkPositionRegister; 332 InterfaceHDA->RegisterEventCallback = HDA_RegisterEventCallback; 333 InterfaceHDA->UnregisterEventCallback = HDA_UnregisterEventCallback; 334 InterfaceHDA->GetDeviceInformation = HDA_GetDeviceInformation; 335 InterfaceHDA->GetResourceInformation = HDA_GetResourceInformation; 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; 344 InterfaceHDA->InterfaceReference = HDA_InterfaceReference; 345 InterfaceHDA->InterfaceDereference = HDA_InterfaceDereference; 346 347 InterfaceHDA->TransferCodecVerbs = HDA_TransferCodecVerbs; 348 InterfaceHDA->AllocateCaptureDmaEngine = HDA_AllocateCaptureDmaEngine; 349 InterfaceHDA->AllocateRenderDmaEngine = HDA_AllocateRenderDmaEngine; 350 InterfaceHDA->ChangeBandwidthAllocation = HDA_ChangeBandwidthAllocation; 351 InterfaceHDA->AllocateDmaBuffer = HDA_AllocateDmaBuffer; 352 InterfaceHDA->FreeDmaBuffer = HDA_FreeDmaBuffer; 353 InterfaceHDA->FreeDmaEngine = HDA_FreeDmaEngine; 354 InterfaceHDA->SetDmaEngineState = HDA_SetDmaEngineState; 355 InterfaceHDA->GetWallClockRegister = HDA_GetWallClockRegister; 356 InterfaceHDA->GetLinkPositionRegister = HDA_GetLinkPositionRegister; 357 InterfaceHDA->RegisterEventCallback = HDA_RegisterEventCallback; 358 InterfaceHDA->UnregisterEventCallback = HDA_UnregisterEventCallback; 359 InterfaceHDA->GetDeviceInformation = HDA_GetDeviceInformation; 360 InterfaceHDA->GetResourceInformation = HDA_GetResourceInformation; 361 362 InterfaceHDA->AllocateDmaBufferWithNotification = HDA_AllocateDmaBufferWithNotification; 363 InterfaceHDA->FreeDmaBufferWithNotification = HDA_FreeDmaBufferWithNotification; 364 InterfaceHDA->RegisterNotificationEvent = HDA_RegisterNotificationEvent; 365 InterfaceHDA->UnregisterNotificationEvent = HDA_UnregisterNotificationEvent; 366 } 367 368 // FIXME 369 // implement support for GUID_HDAUDIO_BUS_INTERFACE_BDL 370 UNIMPLEMENTED; 371 return STATUS_NOT_SUPPORTED; 372 } 373