[edk2-devel] EFI_AUDIO_OUTPUT_PROTOCOL: assistance with VirtIO initialization

Michael Brown mcb30 at ipxe.org
Fri Jul 2 09:41:36 UTC 2021


On 01/07/2021 19:10, Ethin Probst wrote:
> The first: I don't know how to retrieve the descriptors on the UEFI
> API. I've looked at the Chaos Key DXE, if memory serves, or the
> display port one -- one of the two. One of them contained a
> ReadDescriptor() function, and so I've borrowed that, but that doesn't
> really help much.

I have no idea what higher-level utility library functions exist within 
EDK2 that you might be able to use.  Based on skimming through the USB 
audio spec, at the raw protocol level you would need to use 
EFI_USB_IO_PROTOCOL.UsbControlTransfer() something like:

#define AUDIO_CS_INTERFACE 0x24

#pragma pack(1)
typedef struct {
   UINT8 Length;
   UINT8 DescriptorType;
   UINT8 DescriptorSubType;
   UINT16 BcdADC;
   UINT16 TotalLength;
   UINT8 InCollection;
} AUDIO_HEADER_DESCRIPTOR;
#pragma pack()

EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
EFI_USB_DEVICE_REQUEST Req;
AUDIO_CS_HEADER Header;
UINT32 Status;

UsbIo->UsbGetInterfaceDescriptor(UsbIo, &InterfaceDescriptor);

Req.RequestType = (USB_DEV_GET_DESCRIPTOR_REQ_TYPE |
                    USB_REQ_TYPE_CLASS);
Req.Request = USB_REQ_GET_DESCRIPTOR;
Req.Value = (AUDIO_CS_INTERFACE << 8);
Req.Index = InterfaceDescriptor.InterfaceNumber;
Req.Length = sizeof(Header);

UsbIo->UsbControlTransfer(UsbIo, &Req, EfiUsbDataIn,
                           PcdGet32 (PcdUsbTransferTimeoutValue),
                           &Header, sizeof(Header), &Status);

(Error handling etc omitted for brevity)

That would get you the first 8 bytes of the class-specific AC interface 
header descriptor.  You would then need to extract the TotalLength 
field, allocate that length of memory, and repeat the 
UsbControlTransfer() call to fetch the full-length descriptor into the 
newly allocated block.

Hope that helps,

Michael


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#77445): https://edk2.groups.io/g/devel/message/77445
Mute This Topic: https://groups.io/mt/83904983/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list