OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Jun 23, 2021 12:16 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Playing audio through USB ADC?
PostPosted: Thu Jun 10, 2021 12:58 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 332
Location: North Dakota, United States
As a part of Google Summer of Code I'm working on an audio output protocol for UEFI. This is in an effort to standardize UEFI accessibility for people with disabilities like myself.
Originally, I was going to use the VirtIO sound device for audio, as a starting point, since its simple and appears easy to work with. However, I found out that QEMU does not yet actually implement the device; there is an RFC for it, but it is just a set of patches that have yet to be upstreamed. As such, I had a few options:
  1. I could implement the device anyway and bank on the (very unlikely) possibility that a QEMU update is released just in time to demonstrate my implementation;
  2. I could implement the Intel HDA specification; or
  3. I could implement either the USB audio device class specification or the basic audio device definition. (One of my mentors says that there's a "generic USB audio device", but I can't seem to find any kind of reference to it other than a few generic descriptors.)
The first option wasn't very tenable. I'm required to demonstrate that my protocol works, since it'll be a driver and not an application, but I (obviously) can't test it if I can't even use the device in QEMU to begin with. The second option might've worked if it weren't for the fact that I'd need to implement separate drivers for each HDA codec I wanted to support, so my mentors and I ruled that out as more of a long-term project than anything else. We'll get there but I don't think I could do that in three months.
The final option was USB audio. I chose this for a few reasons:
  1. Its already in QEMU and it works
  2. The specification is well written (though quite large), and I don't need to implement all of the specification anyway -- you don't need a graphical equalizer, for example.
  3. The specification is relatively easy to implement and UEFI makes USB pretty simple.
The problem is that I'm getting lost within the specification. The main ADC specification is massive and contains tons of descriptors and units, but the basic audio device definition is almost too small for me to actually figure out anything. I'm able to find the device on the USB bus and read its interface, device, and endpoint descriptors, and the USB I/O protocol provides functions like EFI_USB_IO_CONTROL_TRANSFER, EFI_USB_IO_BULK_TRANSFER, etc., so I (think) I can retrieve other descriptors for audio, but the difficulty I'm struggling with is knowing what descriptors I need to look for and then how to actually play something. I'm not looking for anything fancy; I don't need mixing or audio spacialization or anything like that.
Does anyone here know the process for doing this?


Top
 Profile  
 
 Post subject: Re: Playing audio through USB ADC?
PostPosted: Thu Jun 10, 2021 2:14 pm 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 2629
I don't think you need per-codec HDA support. I've tested my generic HDA on many different platforms, and it works without any kind of special code. What is a bit complex is to handle the deivce connections that differs between hardware configurations, but it is doable, and the components are the same (it's just the connections that differ).

I think USB audio is probably a lot more complex than HDA (I haven't done USB audio drivers). You both need to write the USB driver (and there are four different standards + Hubs), and the USB audio driver. I haven't done this yet, and I'm not sure that it is as simple as writing a single driver. USB networks at least are not. The USB CDC only specifies the basics. Same with USB printers.


Top
 Profile  
 
 Post subject: Re: Playing audio through USB ADC?
PostPosted: Thu Jun 10, 2021 2:23 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 332
Location: North Dakota, United States
UEFI already has USB support, so I don't need to worry about that.


Top
 Profile  
 
 Post subject: Re: Playing audio through USB ADC?
PostPosted: Thu Jun 10, 2021 3:31 pm 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 2629
Ethin wrote:
UEFI already has USB support, so I don't need to worry about that.


I suspect USB audio will use isochronous transfers, and are you sure that UEFI supports that? USB keyboards & mice use interrupt transfers, and USB discs use bulk transfers. Thus, UEFI really has no use for isochronous transfers with typical devices.


Top
 Profile  
 
 Post subject: Re: Playing audio through USB ADC?
PostPosted: Thu Jun 10, 2021 4:32 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 332
Location: North Dakota, United States
Yes. The EFI_USB_IO_PROTOCOL supports control, interrupt, bulk, and isochronous transfers, with interrupt and isochronous transfers supporting both a synchronous mode and an asynchronous version via EFI_USB_IO_PROTOCOL.UsbControlTransfer(), EFI_USB_IO_PROTOCOL.UsbBulkTransfer(), EFI_USB_IO_PROTOCOL.UsbAsyncInterruptTransfer(), EFI_USB_IO_PROTOCOL.UsbSyncInterruptTransfer(), EFI_USB_IO_PROTOCOL.UsbIsochronousTransfer(), and EFI_USB_IO_PROTOCOL.UsbAsyncIsochronousTransfer().


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group