182 IN OUT CHAR8 **AsciiBuffer,
183 IN UINTN *AsciiBufferSize,
245 OcAsciiPrintBuffer (AsciiBuffer, AsciiBufferSize,
" bits [0x%X]:", (UINT16)(Rates >> 16));
313 IN OUT CHAR8 **AsciiBuffer,
314 IN UINTN *AsciiBufferSize,
328 "Node 0x%2X (%u) [%a] wcaps 0x%X:",
332 HdaWidget->Capabilities
364 PrintAmpCaps (AsciiBuffer, AsciiBufferSize, HdaWidget->AmpInCapabilities);
367 for (Index = 0; Index < HdaWidget->ConnectionCount; Index++) {
373 HdaWidget->AmpInLeftDefaultGainMute[Index],
374 HdaWidget->AmpInRightDefaultGainMute[Index]
377 OcAsciiPrintBuffer (AsciiBuffer, AsciiBufferSize,
" [0x%2X]", HdaWidget->AmpInLeftDefaultGainMute[Index]);
389 PrintAmpCaps (AsciiBuffer, AsciiBufferSize, HdaWidget->AmpOutCapabilities);
397 HdaWidget->AmpOutLeftDefaultGainMute,
398 HdaWidget->AmpOutRightDefaultGainMute
401 OcAsciiPrintBuffer (AsciiBuffer, AsciiBufferSize,
" [0x%2X]", HdaWidget->AmpOutLeftDefaultGainMute);
416 " Converter: stream=%u, channel=%u\n",
423 PrintRatesFormats (AsciiBuffer, AsciiBufferSize, HdaWidget->SupportedPcmRates, HdaWidget->SupportedFormats);
431 OcAsciiPrintBuffer (AsciiBuffer, AsciiBufferSize,
" Pincap 0x%8X:", HdaWidget->PinCapabilities);
492 OcAsciiPrintBuffer (AsciiBuffer, AsciiBufferSize,
" EAPD 0x%X:", HdaWidget->DefaultEapd);
511 " Pin Default 0x%8X: [%a] %a at %a %a\n",
512 HdaWidget->DefaultConfiguration,
522 " Conn = %a, Color = %a\n",
530 " DefAssociation = 0x%X, Sequence = 0x%X\n",
535 OcAsciiPrintBuffer (AsciiBuffer, AsciiBufferSize,
"Pin-ctls: 0x%2X:", HdaWidget->DefaultPinControl);
568 OcAsciiPrintBuffer (AsciiBuffer, AsciiBufferSize,
" Connection: %u\n ", HdaWidget->ConnectionCount);
569 for (Index = 0; Index < HdaWidget->ConnectionCount; Index++) {
570 OcAsciiPrintBuffer (AsciiBuffer, AsciiBufferSize,
" 0x%2X", HdaWidget->Connections[Index]);
579 IN EFI_FILE_PROTOCOL *Root
584 EFI_HANDLE *HandleBuffer;
589 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
592 UINTN FileBufferSize;
593 CHAR16 TmpFileName[32];
596 CHAR16 *DevicePathStr;
603 UINTN HdaWidgetCount;
604 UINT32 HdaWidgetIndex;
611 Status =
gBS->LocateHandleBuffer (
618 DEBUG ((DEBUG_INFO,
"OCAU: %u HDA controllers installed - %r\n", (UINT32)HandleCount, Status));
620 if (!EFI_ERROR (Status)) {
621 for (Index = 0; Index < HandleCount; Index++) {
623 DEBUG ((DEBUG_INFO,
"OCAU: HDA controller %u info open result - %r\n", Index, Status));
624 if (EFI_ERROR (Status)) {
628 FileBufferSize = SIZE_1KB;
629 FileBuffer = AllocateZeroPool (FileBufferSize);
630 if (FileBuffer == NULL) {
631 return EFI_OUT_OF_RESOURCES;
638 DevicePathStr = NULL;
639 if (DevicePath != NULL) {
640 DevicePathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
643 OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize,
"Device path: %s\n", DevicePathStr != NULL ? DevicePathStr : L
"<NULL>");
644 DEBUG ((DEBUG_INFO,
"OCAU: Dumping controller at %s\n", DevicePathStr != NULL ? DevicePathStr : L
"<NULL>"));
645 if (DevicePathStr != NULL) {
646 FreePool (DevicePathStr);
649 Status = HdaControllerInfo->GetName (HdaControllerInfo, &Name);
650 OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize,
"Controller: %s\n", Status == EFI_SUCCESS ? Name : L
"<NULL>");
652 Status = HdaControllerInfo->GetVendorId (HdaControllerInfo, &Tmp32A);
658 if (FileBuffer != NULL) {
659 UnicodeSPrint (TmpFileName,
sizeof (TmpFileName), L
"Controller%u.txt", Index);
660 Status =
OcSetFileData (Root, TmpFileName, FileBuffer, (UINT32)AsciiStrLen (FileBuffer));
661 DEBUG ((DEBUG_INFO,
"OCAU: Dumped HDA controller %u info result - %r\n", Index, Status));
663 FreePool (FileBuffer);
667 FreePool (HandleBuffer);
675 Status =
gBS->LocateHandleBuffer (
682 DEBUG ((DEBUG_INFO,
"OCAU: %u HDA codecs installed - %r\n", (UINT32)HandleCount, Status));
684 if (!EFI_ERROR (Status)) {
685 for (Index = 0; Index < HandleCount; Index++) {
687 DEBUG ((DEBUG_INFO,
"OCAU: HDA codec %u info open result - %r\n", Index, Status));
688 if (EFI_ERROR (Status)) {
692 Status = HdaCodecInfo->GetWidgets (HdaCodecInfo, &HdaWidgets, &HdaWidgetCount);
693 if (EFI_ERROR (Status)) {
697 if (BaseOverflowMulAddUN (SIZE_4KB, HdaWidgetCount, SIZE_4KB, &FileBufferSize)) {
698 HdaCodecInfo->FreeWidgetsBuffer (HdaWidgets, HdaWidgetCount);
702 FileBuffer = AllocateZeroPool (FileBufferSize);
703 if (FileBuffer == NULL) {
704 HdaCodecInfo->FreeWidgetsBuffer (HdaWidgets, HdaWidgetCount);
705 return EFI_OUT_OF_RESOURCES;
712 DevicePathStr = NULL;
713 if (DevicePath != NULL) {
714 DevicePathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
717 OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize,
"Device path: %s\n", DevicePathStr != NULL ? DevicePathStr : L
"<NULL>");
718 DEBUG ((DEBUG_INFO,
"OCAU: Dumping codec at %s\n", DevicePathStr != NULL ? DevicePathStr : L
"<NULL>"));
719 if (DevicePathStr != NULL) {
720 FreePool (DevicePathStr);
723 Status = HdaCodecInfo->GetAddress (HdaCodecInfo, &Tmp8);
726 Status = HdaCodecInfo->GetName (HdaCodecInfo, &Name);
727 OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize,
"Codec: %s\n", Status == EFI_SUCCESS ? Name : L
"<NULL>");
729 Status = HdaCodecInfo->GetAudioFuncId (HdaCodecInfo, &Tmp8, &TmpBool);
730 OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize,
"AFG Function Id: 0x%X (unsol %u)\n", Tmp8, TmpBool);
732 Status = HdaCodecInfo->GetVendorId (HdaCodecInfo, &Tmp32A);
735 Status = HdaCodecInfo->GetRevisionId (HdaCodecInfo, &Tmp32A);
738 Status = HdaCodecInfo->GetDefaultRatesFormats (HdaCodecInfo, &Tmp32A, &Tmp32B);
739 if (!EFI_ERROR (Status) && ((Tmp32A != 0) || (Tmp32B != 0))) {
746 Status = HdaCodecInfo->GetDefaultAmpCaps (HdaCodecInfo, &Tmp32A, &Tmp32B);
748 PrintAmpCaps (&FileBuffer, &FileBufferSize, Status == EFI_SUCCESS ? Tmp32A : 0);
750 PrintAmpCaps (&FileBuffer, &FileBufferSize, Status == EFI_SUCCESS ? Tmp32B : 0);
755 for (HdaWidgetIndex = 0; HdaWidgetIndex < HdaWidgetCount; HdaWidgetIndex++) {
756 PrintWidget (&FileBuffer, &FileBufferSize, &HdaWidgets[HdaWidgetIndex]);
759 HdaCodecInfo->FreeWidgetsBuffer (HdaWidgets, HdaWidgetCount);
764 if (FileBuffer != NULL) {
765 UnicodeSPrint (TmpFileName,
sizeof (TmpFileName), L
"Codec%u.txt", Index);
766 Status =
OcSetFileData (Root, TmpFileName, FileBuffer, (UINT32)AsciiStrLen (FileBuffer));
767 DEBUG ((DEBUG_INFO,
"OCAU: Dumped HDA codec %u info result - %r\n", Index, Status));
769 FreePool (FileBuffer);
773 FreePool (HandleBuffer);