USB Audio 2.0 - how to provide host with a range or list of supported sample frequencies ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB Audio 2.0 - how to provide host with a range or list of supported sample frequencies ?

Jump to solution
3,863 Views
paulw2
Contributor III

Hello,

In UAC 2, how should the MCU audio device provide the host with a list of supported sample rates ?

Using SDK 2.16 dev_audio_speaker_freertos example on i.MXRT1010 evaluation board.

In this example, is it correct that for UAC2 the supported sample rates are provided to the host via audio_speaker.c:USB_DeviceAudioRequest() returning freqControlRange for the GET_RANGE_SAMPLING_FREQ_CONTROL case ?

Modifying audio_speaker.c:g_UsbDeviceAudioSpeaker.freqControlRange does not produce the expected results :-

 

 

 

/* wNumSubRanges, wMIN, wMAX, wRES */

.freqControlRange = {1U, 48000U, 48000U, 0U} - host lists 48kHz - original values

.freqControlRange = {1U, 44100U, 48000U, 0U} - host lists 44.1kHz + 48kHz

.freqControlRange = {1U, 44100U, 96000U, 0U} - host lists 44,1kHz - expected a range 44.1kHz, 48kHz, 88.2kHz and 96kHz

 

What am I missing ?

Thanks.

Labels (3)
0 Kudos
Reply
1 Solution
3,616 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @paulw2,

While investigating about this issue, I encountered an old project based on SDK 2.8.0 that provides a host with a list of supported sample frequencies. Although older, I believe it can prove to be very useful for your application. I will attach here. Notice how the freqControlRange structure is expanded to include a wide range of frequencies:

    g_deviceAudioComposite->audioUnified.freqControlRange1.wNumSubRanges = 6U;
    g_deviceAudioComposite->audioUnified.freqControlRange1.wMIN          = 44100U;
    g_deviceAudioComposite->audioUnified.freqControlRange1.wMAX          = 44100U;
    g_deviceAudioComposite->audioUnified.freqControlRange1.wRES          = 0U;
    g_deviceAudioComposite->audioUnified.freqControlRange2.wMIN          = 48000U;
    g_deviceAudioComposite->audioUnified.freqControlRange2.wMAX          = 48000U;
    g_deviceAudioComposite->audioUnified.freqControlRange2.wRES          = 0U;
    g_deviceAudioComposite->audioUnified.freqControlRange3.wMIN          = 88200U;
    g_deviceAudioComposite->audioUnified.freqControlRange3.wMAX          = 88200U;
    g_deviceAudioComposite->audioUnified.freqControlRange3.wRES          = 0U;
    g_deviceAudioComposite->audioUnified.freqControlRange4.wMIN          = 96000U;
    g_deviceAudioComposite->audioUnified.freqControlRange4.wMAX          = 96000U;
    g_deviceAudioComposite->audioUnified.freqControlRange4.wRES          = 0U;
    g_deviceAudioComposite->audioUnified.freqControlRange5.wMIN          = 176400U;
    g_deviceAudioComposite->audioUnified.freqControlRange5.wMAX          = 176400U;
    g_deviceAudioComposite->audioUnified.freqControlRange5.wRES          = 0U;
    g_deviceAudioComposite->audioUnified.freqControlRange6.wMIN          = 192000U;
    g_deviceAudioComposite->audioUnified.freqControlRange6.wMAX          = 192000U;
    g_deviceAudioComposite->audioUnified.freqControlRange6.wRES          = 0U;

 

If you wish to quickly test, you could download SDK2.8.0 and build with said SDK for your RT1010. Otherwise, I would recommend you port this implementation to your needs on the latest SDK2.16.0 for the best performance.

BR,
Edwin.

View solution in original post

9 Replies
3,804 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @paulw2,

Please try changing the resolution (wRES) value to 1 or more to achieve higher number of frequencies. As such:

.freqControlRange = {1U, 44100U, 48000U, 1U}

BR,
Edwin. 

0 Kudos
Reply
3,791 Views
paulw2
Contributor III

Hi @EdwinHz

Thanks very much for replying to my question.

Using a resolution of 1 enumerates as 44,100 Hz, 44,101 Hz, 44,102 Hz, ...... 44,160 Hz

Using a resolution of 10 enumerates as 44,100 Hz, 44,110 Hz, 44,120 Hz, ...... 45,440 Hz

The resolution member does not seem to lend itself to providing the host with a list of supported sample rates such as :-

44.100 Hz
48,000 Hz
88,200 Hz
96,000 Hz
176,400 Hz
192,000 Hz
352,000 Hz
384,000 Hz
705,000 Hz
768,000 Hz

Perhaps I should have been clearer on these sample rates.

What would be the correct method of specifying these as the supported sample rates for UAC 2 ?

Thanks and regards,

Paul.

0 Kudos
Reply
3,780 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @paulw2,

Thanks for the clarification. In this case, you would have to add alternate interface setting for each desired supported audio format (i.e. 3 for 44.100 Hz, 48,000 Hz and 88,200 Hz). This can be done by following this application note: AN13447.pdf (nxp.com). Even though it is technically describing the process for an LPC, it is still the same for the RT1010.

BR,
Edwin.

3,732 Views
paulw2
Contributor III

Hi @EdwinHz,

Thanks very much for your reply.

As it happens, it was while working through AN13447 that I encountered this issue.

Following the approach taken in AN13447 I was able to add 32 bit support but when adding additional sample rate frequencies encountered the following results (note failure in UAC 2.0 case)  :-

excerpt from usb_audio_descriptor.c: uint8_t g_UsbDeviceConfbDescriptorSubtypeigurationDescriptor[]

Class 1.0 audio descriptor (USB_DEVICE_CONFIG_AUDIO_CLASS_2_0 == 0U) - single sample rate supported :-

    /* Audio Class Specific type I format INTERFACE Descriptor */
    USB_AUDIO_STREAMING_TYPE_I_DESC_SIZE,               /* bLength (11) */
    USB_DESCRIPTOR_TYPE_AUDIO_CS_INTERFACE,             /* bDescriptorType (CS_INTERFACE) */
    USB_DESCRIPTOR_SUBTYPE_AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype: AUDIO STREAMING FORMAT TYPE */
    USB_AUDIO_FORMAT_TYPE_I,                            /* bFormatType - Format Type: Type I */
    AUDIO_FORMAT_CHANNELS,                              /* bNrChannels - Number of Channels: one channel */
    AUDIO_FORMAT_SIZE,                                  /* bSubFrameSize - SubFrame Size: one byte per audio subframe */
    AUDIO_FORMAT_BITS,                                  /* bBitResolution - Bit Resolution: 8 bits per sample */
    0x01U,                                              /* bSamFreqType - One sample frequency supported */
    TSAMFREQ2BYTES(AUDIO_SAMPLING_RATE_KHZ * 1000),     /* 3 bytes - 48 kHz */
lsusb -v reports :-

      AudioStreaming Interface Descriptor:
        bLength                11
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             2
        bSubframeSize           4
        bBitResolution         32
        bSamFreqType            1 Discrete
        tSamFreq[ 0]        48000

 

Class 1.0 audio descriptor (USB_DEVICE_CONFIG_AUDIO_CLASS_2_0 == 0U) - two sample rates supported :-

    /* Audio Class Specific type I format INTERFACE Descriptor */
    USB_AUDIO_STREAMING_TYPE_I_DESC_SIZE + 3,           /* bLength (14) */
    USB_DESCRIPTOR_TYPE_AUDIO_CS_INTERFACE,             /* bDescriptorType (CS_INTERFACE) */
    USB_DESCRIPTOR_SUBTYPE_AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype: AUDIO STREAMING FORMAT TYPE */
    USB_AUDIO_FORMAT_TYPE_I,                            /* bFormatType - Format Type: Type I */
    AUDIO_FORMAT_CHANNELS,                              /* bNrChannels - Number of Channels: one channel */
    AUDIO_FORMAT_SIZE,                                  /* bSubFrameSize - SubFrame Size: one byte per audio subframe */
    AUDIO_FORMAT_BITS,                                  /* bBitResolution - Bit Resolution: 8 bits per sample */
    0x02U,                                              /* bSamFreqType - Two sample frequencies supported */
    TSAMFREQ2BYTES(AUDIO_SAMPLING_RATE_KHZ * 1000),     /* 3 bytes - 48 kHz */
    TSAMFREQ2BYTES(72 * 1000),                          /* 3 bytes - 72 kHz */

 

lsbusb -v reports :-

      AudioStreaming Interface Descriptor:
        bLength                14
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             2
        bSubframeSize           4
        bBitResolution         32
        bSamFreqType            2 Discrete
        tSamFreq[ 0]        48000
        tSamFreq[ 1]        72000

 

Class 2.0 audio descriptor (USB_DEVICE_CONFIG_AUDIO_CLASS_2_0 == 1U) - two sample rates supported :-

    /* Audio Class Specific type I format INTERFACE Descriptor */
    USB_AUDIO_STREAMING_TYPE_I_DESC_SIZE + 3,           /* bLength (14) */
    USB_DESCRIPTOR_TYPE_AUDIO_CS_INTERFACE,             /* bDescriptorType (CS_INTERFACE) */
    USB_DESCRIPTOR_SUBTYPE_AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype: AUDIO STREAMING FORMAT TYPE */
    USB_AUDIO_FORMAT_TYPE_I,                            /* bFormatType - Format Type: Type I */
    AUDIO_FORMAT_CHANNELS,                              /* bNrChannels - Number of Channels: one channel */
    AUDIO_FORMAT_SIZE,                                  /* bSubFrameSize - SubFrame Size: one byte per audio subframe */
    AUDIO_FORMAT_BITS,                                  /* bBitResolution - Bit Resolution: 8 bits per sample */
    0x02U,                                              /* bSamFreqType - Two sample frequencies supported */
    TSAMFREQ2BYTES(AUDIO_SAMPLING_RATE_KHZ * 1000),     /* 3 bytes - 48 kHz */
    TSAMFREQ2BYTES(72 * 1000),                          /* 3 bytes - 72 kHz */
lsbusb -v reports :-

      AudioStreaming Interface Descriptor:
        bLength                13
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         32
        junk at descriptor end: 02 80 bb 00 40 19 01

 

Various documentation including, USB Device Class Definition for Audio Devices - Release 2.0, state that in UAC2 the supported sample rates are requested by the host and provided by the device in the  Minimum (MIN), Maximum (MAX), and Resolution (RES) format listed in my original question.

As stated initially, the following changes to audio_speaker.c did enable the host to determine the device supported 2 sample rates.

g_UsbDeviceAudioSpeaker.freqControlRange = {1U, 44100U, 48000U, 0U}, // gives 44.1 + 48

 

This looks to be on the right track for UAC 2 but more info is needed on how to properly utilise this interface.

Thanks and regards,

Paul.

 

 

0 Kudos
Reply
3,617 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @paulw2,

While investigating about this issue, I encountered an old project based on SDK 2.8.0 that provides a host with a list of supported sample frequencies. Although older, I believe it can prove to be very useful for your application. I will attach here. Notice how the freqControlRange structure is expanded to include a wide range of frequencies:

    g_deviceAudioComposite->audioUnified.freqControlRange1.wNumSubRanges = 6U;
    g_deviceAudioComposite->audioUnified.freqControlRange1.wMIN          = 44100U;
    g_deviceAudioComposite->audioUnified.freqControlRange1.wMAX          = 44100U;
    g_deviceAudioComposite->audioUnified.freqControlRange1.wRES          = 0U;
    g_deviceAudioComposite->audioUnified.freqControlRange2.wMIN          = 48000U;
    g_deviceAudioComposite->audioUnified.freqControlRange2.wMAX          = 48000U;
    g_deviceAudioComposite->audioUnified.freqControlRange2.wRES          = 0U;
    g_deviceAudioComposite->audioUnified.freqControlRange3.wMIN          = 88200U;
    g_deviceAudioComposite->audioUnified.freqControlRange3.wMAX          = 88200U;
    g_deviceAudioComposite->audioUnified.freqControlRange3.wRES          = 0U;
    g_deviceAudioComposite->audioUnified.freqControlRange4.wMIN          = 96000U;
    g_deviceAudioComposite->audioUnified.freqControlRange4.wMAX          = 96000U;
    g_deviceAudioComposite->audioUnified.freqControlRange4.wRES          = 0U;
    g_deviceAudioComposite->audioUnified.freqControlRange5.wMIN          = 176400U;
    g_deviceAudioComposite->audioUnified.freqControlRange5.wMAX          = 176400U;
    g_deviceAudioComposite->audioUnified.freqControlRange5.wRES          = 0U;
    g_deviceAudioComposite->audioUnified.freqControlRange6.wMIN          = 192000U;
    g_deviceAudioComposite->audioUnified.freqControlRange6.wMAX          = 192000U;
    g_deviceAudioComposite->audioUnified.freqControlRange6.wRES          = 0U;

 

If you wish to quickly test, you could download SDK2.8.0 and build with said SDK for your RT1010. Otherwise, I would recommend you port this implementation to your needs on the latest SDK2.16.0 for the best performance.

BR,
Edwin.

3,477 Views
paulw2
Contributor III

Hi @EdwinHz

Apologies for this delayed reply, I've been away from NXP SDK for a while.

I tested this example app as is, with SDK 2.8.

Once I figure out which of the changes it introduces I require, I'll port them to the current SDK.

It enumerates as follows :-

USB-AUDIO-HID-DEMO-1.jpeg

 

USB-AUDIO-HID-DEMO-2.jpeg

$ lsusb -vd 1fc9:0032

Bus 001 Device 009: ID 1fc9:0032 NXP Semiconductors USB AUDIO+HID DEMO
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 [unknown]
  bDeviceSubClass         0 [unknown]
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x1fc9 NXP Semiconductors
  idProduct          0x0032 USB AUDIO+HID DEMO
  bcdDevice            1.01
  iManufacturer           1 NXP SEMICONDUCTORS
  iProduct                2 USB AUDIO+HID DEMO
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0146
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower              500mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         3
      bFunctionClass          1 Audio
      bFunctionSubClass       0 [unknown]
      bFunctionProtocol      32 
      iFunction               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol     32 
      iInterface              0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               2.00
        bCategory               4
        wTotalLength       0x006f
        bmControls           0x00
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     10 (CLOCK_SOURCE)
        bClockID               16
        bmAttributes            3 Internal programmable clock 
        bmControls           0x07
          Clock Frequency Control (read/write)
          Clock Validity Control (read-only)
        bAssocTerminal          0
        iClockSource            0 
      AudioControl Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0201 Microphone
        bAssocTerminal          0
        bCSourceID             16
        bNrChannels             2
        bmChannelConfig    0x00000003
          Front Left (FL)
          Front Right (FR)
        iChannelNames           0 
        bmControls         0x0000
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                18
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                 2
        bSourceID               1
        bmaControls(0)     0x0000000f
          Mute Control (read/write)
          Volume Control (read/write)
        bmaControls(1)     0x00000000
        bmaControls(2)     0x00000000
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             3
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          1
        bSourceID               2
        bCSourceID             16
        bmControls         0x0000
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     10 (CLOCK_SOURCE)
        bClockID               18
        bmAttributes            3 Internal programmable clock 
        bmControls           0x07
          Clock Frequency Control (read/write)
          Clock Validity Control (read-only)
        bAssocTerminal          0
        iClockSource            0 
      AudioControl Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             4
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bCSourceID             18
        bNrChannels             2
        bmChannelConfig    0x00000003
          Front Left (FL)
          Front Right (FR)
        iChannelNames           0 
        bmControls         0x0000
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                18
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                 5
        bSourceID               4
        bmaControls(0)     0x0000000f
          Mute Control (read/write)
          Volume Control (read/write)
        bmaControls(1)     0x00000000
        bmaControls(2)     0x00000000
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             6
        wTerminalType      0x0301 Speaker
        bAssocTerminal          4
        bSourceID               5
        bCSourceID             18
        bmControls         0x0000
        iTerminal               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           3
        bmControls           0x00
        bFormatType             1
        bmFormats          0x00000001
          PCM
        bNrChannels             2
        bmChannelConfig    0x00000003
          Front Left (FL)
          Front Right (FR)
        iChannelNames           0 
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            3
        bBitResolution         24
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x00c0  1x 192 bytes
        bInterval               1
        AudioStreaming Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           4
        bmControls           0x00
        bFormatType             1
        bmFormats          0x00000001
          PCM
        bNrChannels             2
        bmChannelConfig    0x00000003
          Front Left (FL)
          Front Right (FR)
        iChannelNames           0 
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            2
        bBitResolution         16
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            9
          Transfer Type            Isochronous
          Synch Type               Adaptive
          Usage Type               Data
        wMaxPacketSize     0x00c0  1x 192 bytes
        bInterval               1
        AudioStreaming Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       2
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           4
        bmControls           0x00
        bFormatType             1
        bmFormats          0x00000001
          PCM
        bNrChannels             2
        bmChannelConfig    0x00000003
          Front Left (FL)
          Front Right (FR)
        iChannelNames           0 
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            3
        bBitResolution         24
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            9
          Transfer Type            Isochronous
          Synch Type               Adaptive
          Usage Type               Data
        wMaxPacketSize     0x00c0  1x 192 bytes
        bInterval               1
        AudioStreaming Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 [unknown]
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.00
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      35
          Report Descriptors: 
            ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              16

 

Thanks very much for finding and sharing this example.

Best regards,

Paul.

0 Kudos
Reply
3,613 Views
paulw2
Contributor III

Hi @EdwinHz.,

Thank you so much for continuing to research this issue and for providing this example project which seems to tie in with some further research I have done.

I will give it a try with SDK 2.8.0 and if successful, will then port to 2.16 as you suggest.

I used Wireshark to capture the USB traffic for a known good UAC 2 device which enumerates as supporting the following sample rates.

cxn100-sample-rate-range.jpeg

host requests sample rate rangehost requests sample rate range

audio device responds with sample rate rangeaudio device responds with sample rate range

That CONTROL response date decodes as follows :-

 

numSubRanges
0x0a 00

min max res
0x44 ac 00 00, 44 ac 00 00, 00 00 00 00 - 44100 kHz
0x80 bb 00 00, 80 bb 00 00, 00 00 00 00 - 48000 kHz
0x88 58 01 00, 88 58 01 00, 00 00 00 00 - 88200 kHz
0x00 77 01 00, 00 77 01 00, 00 00 00 00 - 96000 kHz
0x10 b1 02 00, 10 b1 02 00, 00 00 00 00 - 176400 kHz
0x00 ee 02 00, 00 ee 02 00, 00 00 00 00 - 192000 kHz
0x20 62 05 00, 20 62 05 00, 00 00 00 00 - 352800 kHz
0x00 dc 05 00, 00 dc 05 00, 00 00 00 00 - 384000 kHz
0x40 c4 0a 00, 40 c4 0a 00, 00 00 00 00 - 705600 kHz
0x00 b8 0b 00, 00 b8 0b 00, 00 00 00 00 - 768000 kHz

 

This seems to align with the structure of the sample rate data of the example you have provided.

Thanks and regards,

Paul.

0 Kudos
Reply
3,694 Views
paulw2
Contributor III

Hi @EdwinHz,

Further reading of, "USB Device Class Definition for Audio Devices", Release 2.0 May 31, 2006 89 :-

Chapter 5

5.2 Class-Specific Requests

5.2.1 Control Attributes - concludes with the hypothetical Volume Control example :-

• -∞ dB
• -70 dB to -40 dB in steps of 3 dB
• -40 dB to -20 dB in steps of 2 dB
• -20 dB to 0 dB in steps of 1 dB
One possible layout of the RANGE attribute is then:
RANGE(0) = 3
RANGE(1) = [-70, -40, 3]
RANGE(2) = [-38, -20, 2]
RANGE(3) = [-19, 0, 1]
Another way of representing the same Control is as follows:
RANGE(0) = 3
RANGE(1) = [-70, -43, 3]
RANGE(2) = [-40, -22, 2]
RANGE(3) = [-20, 0, 1]

Which suggests that supported sample rates could be represented as :-

 

#if (USB_DEVICE_CONFIG_AUDIO_CLASS_2_0)
struct _usb_device_control_range_layout3_struct
{
    uint32_t wMIN;
    uint32_t wMAX;
    uint32_t wRES;
} STRUCT_UNPACKED;

struct _usb_device_control_ranges_layout3_struct
{
    uint16_t wNumSubRanges;
    struct _usb_device_control_range_layout3_struct range[MAX_SAMPLE_RATES];
} STRUCT_UNPACKED;

typedef struct _usb_device_control_ranges_layout3_struct usb_device_control_ranges_layout3_struct_t;
#endif /* USB_DEVICE_CONFIG_AUDIO_CLASS_2_0 */

 

 

Or am I misunderstanding the documentation and/or the interface provided by the MCUXpresso SDK ?

Thanks and regards,

Paul.

0 Kudos
Reply
3,691 Views
paulw2
Contributor III
Apologies, not sure where those bogus 'STRUCT_UNPACKED' came from.
0 Kudos
Reply