Marc.O
Marc.O

Reputation: 125

USB 24bits audiostream descriptors

I am working on a demo for an USB headset and I have a question about the audio endpoint descriptors of the USB. I have a working 8-48kHz 16bit audio stream and I can select any sample frequency in the windows properties of an audio device. I use the following descriptors:

Code:

// Interface 2: Speaker, alternate setting 1. Type 1 format descriptor. 
static const UsbAudioStreamingType1DescriptorType UsbIfd2Format = 
{ 
  sizeof(UsbAudioStreamingType1DescriptorType),                                       // uint8 bLength; 
  UDESC_CS_INTERFACE,                                                                 // uint8 bDescriptorType; 
  UA_FORMAT_TYPE,                                                                     // uint8 bDescriptorSubtype; 
  UA_FORMAT_TYPE_I,                                                                   // uint8 bFormatType; 
  AUDIO_LSR_NOC,                                                                      // uint8 bNrChannels; 
  AUDIO_LSR_SAMPLE_SIZE,                                                              // uint8 bSubFrameSize; 
  AUDIO_LSR_SAMPLE_SIZE << 3,                                                         // uint8 bBitResolution; 
  0x00,                                                                               // uint8 bSamFreqType; 
  (uint8)((AUDIO_LSR_MIN_SAMPLE_FREQUENCY) & 0xFF),                                   // uint8 first byte minumum sample frequency  
  (uint8)((AUDIO_LSR_MIN_SAMPLE_FREQUENCY >> 8) & 0xFF),                              // uint8 second byte minumum sample frequency                            
  (uint8)(((0x10000000 | AUDIO_LSR_MIN_SAMPLE_FREQUENCY) >> 16) & 0xFF),              // uint8 third byte minumum sample frequency  
  (uint8)((AUDIO_LSR_MAX_SAMPLE_FREQUENCY) & 0xFF),                                   // uint8 first byte maximum sample frequency  
  (uint8)((AUDIO_LSR_MAX_SAMPLE_FREQUENCY >> 8) & 0xFF),                              // uint8 second byte maximum sample frequency  
  (uint8)(((0x10000000 | AUDIO_LSR_MAX_SAMPLE_FREQUENCY) >> 16) & 0xFF),              // uint8 third byte maximum sample frequency  
}; 

// Interface 2: Speaker, alternate setting 1. Audio endpoint descriptor. 
static const UsbAudioEndpointDescriptorType UsbIfd2StdEndpoint = 
{ 
  sizeof(UsbAudioEndpointDescriptorType),                                             // uint8 bLength; 
  USB_DT_ENDPOINT,                                                                    // uint8 bDescriptorType; 
  USB_DIR_OUT | USB_EP_AUDIO_RX,                                                      // uint8 bEndpointAddress; 
  0x01,                                                                               // uint8 bmAttributes; 
  ((AUDIO_LSR_MAX_SAMPLE_FREQUENCY / 1000) * AUDIO_LSR_SAMPLE_SIZE) * AUDIO_LSR_NOC,  // uint16 wMaxPacketSize; 
  0x01,                                                                               // uint8 bInterval; 
  0x00,                                                                               // uint8 bRefresh; 
  0x00,                                                                               // uint8 bSynchAddress; 
};

With these settings:

// Sample frequencies 
#define AUDIO_LSR_MIN_SAMPLE_FREQUENCY 0x01F40  // 8kHz 
#define AUDIO_LSR_MAX_SAMPLE_FREQUENCY 0x0BB80  // 48kHz 

// Sample size 
#define AUDIO_LSR_SAMPLE_SIZE 0x02 // in bytes 

// Defines for mono/stereo. 
#define AUDIO_LSR_NOC 0x02 // Number Of Channels (stereo)

Now I want to change it to a 8-48kHz 24bit stream. By changing the AUDIO_LSR_SAMPLE_SIZE to 0x03. When I do this the sample frequency selection box in the windows properties window is grayed out at 48kHz so I cannot select any other frequency. When I play something to the device the stream is 24bit though. I already tried uninstalling the drivers but this does not change anything.

Does anyone encounter this problem as well or does anyone have an idea what might cause this problem?

Upvotes: 3

Views: 1163

Answers (1)

Marc.O
Marc.O

Reputation: 125

It turned out that the problem was not in these descriptors but in the Input Terminal Descriptor where the channel configuration was wrong.

Upvotes: 1

Related Questions