I'm a little confused how to add support for multiple bit rates/sample rates in USB Audio Class 2.0. Compared to USB Audio Class 1.0 (which gives you an option on adding multiple rates and such), USB Audio Class 2.0 doesn't give that option. How would I change my descriptors for that? I read somewhere that you use more alternate settings but I don't know how that would help...
Here's my audio format descriptor:
audioformat.bLength = sizeof(usb_audio_format_type_1_desc_t)
audioformat.bDescriptorType = 0x01
audioformat.bDescriptorSubtype = 0x02
audioformat.bFormatType = 0x01
audioformat.bSubSlotSize = 3
audioformat.bBitResolution = 24
Thanks!
Yea so I figured it out and thus bounty doesn't really matter.
To do multiple bit rates: Have alternate settings with its corresponding audio data format descriptors/etc to support different bit rates in order; for example: Alternate Setting 0 (no endpoints), Alternate Setting 1 (with all stream/class descriptors, format descriptor supports 16 bits), Alternate Setting 2 (with all stream/class descriptors, format descriptor supports 24 bits).
To do multiple sample rates: You have to follow the USB Audio Class 2.0 doc with the CUR, MIN, MAX format and give control to the host.
For example:
#define USB_AUDIO_SAMP_RATE_RANGE { CPU16_TO_LE8_ARRAY(2), \
CPU32_TO_LE8_ARRAY(SAMPLE_RATE_44_1), \
CPU32_TO_LE8_ARRAY(SAMPLE_RATE_44_1), \
CPU32_TO_LE8_ARRAY(0), \
CPU32_TO_LE8_ARRAY(SAMPLE_RATE_48_0), \
CPU32_TO_LE8_ARRAY(SAMPLE_RATE_48_0), \
CPU32_TO_LE8_ARRAY(0)}
As reference, LE8 is lower endian 8 bits and the defines are converting a 16 or 32 bit integer into an array of 8 bit integers formatted in lower endian.
There are some Clock Entities in USB Audio 2.0 (UAC2). But USB Audio 1.0 (UAC1) doesn't have it. UAC1 directly provide various Samples rates by which we can request.
But in UAC2, we has to use the Clock Entities. There are some specific descriptor gives the information about clock entities.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With