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

2

9

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!

Tint answered 17/1, 2017 at 17:3 Comment(0)
T
6

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.

Tint answered 10/2, 2017 at 18:11 Comment(0)
C
2

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.

Cletus answered 18/9, 2017 at 7:34 Comment(1)
Thanks Ganesh, I eventually came to learn/understand this part about UAC2 months after I asked this question.Tint

© 2022 - 2024 — McMap. All rights reserved.