Objective

This example demonstrates handling of USB Audio Class specific requests by FX3. Important UAC Requests for starting / stopping the audio stream, switching between frequencies, audio control and mute control are handling, thereby providing a reference for handling similar UAC requests and audio controls.

 

USB Audio Class:

The UAC class specification by the USB guides the transfer of audio data in USB Control with the help of audio control and audio streaming interfaces. The attached example is an enhancement to the existing USB Audio Class Example firmware in the FX3 SDK and demonstrates how to handle certain important audio control requests.

UAC Controls demonstrated in this example:

  • Audio Start
  • (ii) Audio Stop
  • (iii) Frequency Selection
  • (iv) Volume Mute
  • (v) Volume Control

 

Changes in the descriptor:

                The number of sampling rates supported should be specified in the Audio Stream Format Descriptor in the corresponding field (Byte [7]). This should be followed by the list of frequencies supported.

           

    /* Class specific AS Format descriptor - Type I Format Descriptor */

    0x0E,                           /* Descriptor size */

    0x24,                           /* Class-specific Interface Descriptor Type */

    0x02,                           /* Format Type Descriptor subtype */

    0x01,                           /* PCM FORMAT_TYPE_I */

    0x02,                           /* Number of channels - 2 */

    0x02,                           /* Subframe size - 2 bytes per audio subframe */

    0x10,                           /* Bit resolution - 16 bits */

    0x02,

    0x44, 0xAC, 0x00,                     /* Sampling frequency - 44100 Hz */                               // <-------(2) Added support for 44.1 KHz

    0x80, 0xBB, 0x00,               /* Sampling frequency - 48000 Hz */

 

The supported audio controls have to be specified in the Bytes[5 + n]  of Feature Unit Descriptor in the form of a bitmap. (bmacontrols filed)

D0

Mute

D1

Volume

D2

Bass

D3

Mid

D4

Treble

D5

Graphic Equalizer

D6

Automatic Gain

D7

Delay

D8

Bass boost

D9

Loudness

               

In our example, mute and volume controls are supported. So, we set the last two bits to 1, making the bmaControls field as 0x03 as follows:

/* Audio Feature Unit descriptor */

             0x09,                           /* Descriptor size in bytes */

             0x24,                           /* CS Interface Descriptor */

             0x06,                           /* Feature Unit Descriptor subtype */

             0x02,                           /* ID Of the feature unit */

             0x01,                           /* Source ID (from Microphone) */

             0x01,                           /* Control size (1 byte) */

                           0x03,                           /* Master Controls: Mute, Volume */

             0x00,                           /* Channel[0] Controls: None */

             0x00,                           /* String index for this descriptor - None */

Refer to the cyfxuacdscr.c file in the attached code. The output terminal descriptor should be linked to the feature unit descriptor by specifying the ID of the feature unit descriptor (0x02 in our example) in bSourceID filed of the output terminal descriptor.

 

UAC Request Handling:

The control requests come through the CyFxUacApplnUSBSetupCB function. Please refer to the CyFxUacApplnUSBSetupCB function in the cyfxuac.c file in the attached code.