Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

USB Audio Class 2.0 - How to support multiple bit rates/sample rates

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!

like image 739
yun Avatar asked Jan 17 '17 17:01

yun


2 Answers

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.

like image 160
yun Avatar answered Sep 17 '22 22:09

yun


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.

like image 22
Ganesh Thiraviam Avatar answered Sep 20 '22 22:09

Ganesh Thiraviam