mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-21 21:41:09 +00:00
Fix structure definition audio_control_range_X_n_t
This commit is contained in:
parent
e047fbe8fb
commit
1269bb440a
@ -874,7 +874,7 @@ typedef struct TU_ATTR_PACKED {
|
|||||||
// 5.2.3.1 1-byte Control RANGE Parameter Block
|
// 5.2.3.1 1-byte Control RANGE Parameter Block
|
||||||
#define audio_control_range_1_n_t(numSubRanges) \
|
#define audio_control_range_1_n_t(numSubRanges) \
|
||||||
struct TU_ATTR_PACKED { \
|
struct TU_ATTR_PACKED { \
|
||||||
uint16_t wNumSubRanges = numSubRanges; \
|
uint16_t wNumSubRanges; \
|
||||||
struct TU_ATTR_PACKED { \
|
struct TU_ATTR_PACKED { \
|
||||||
int8_t bMin ; /*The setting for the MIN attribute of the nth subrange of the addressed Control*/\
|
int8_t bMin ; /*The setting for the MIN attribute of the nth subrange of the addressed Control*/\
|
||||||
int8_t bMax ; /*The setting for the MAX attribute of the nth subrange of the addressed Control*/\
|
int8_t bMax ; /*The setting for the MAX attribute of the nth subrange of the addressed Control*/\
|
||||||
@ -884,8 +884,8 @@ typedef struct TU_ATTR_PACKED {
|
|||||||
|
|
||||||
// 5.2.3.2 2-byte Control RANGE Parameter Block
|
// 5.2.3.2 2-byte Control RANGE Parameter Block
|
||||||
#define audio_control_range_2_n_t(numSubRanges) \
|
#define audio_control_range_2_n_t(numSubRanges) \
|
||||||
struct TU_ATTR_PACKED { \
|
struct TU_ATTR_PACKED { \
|
||||||
uint16_t wNumSubRanges = numSubRanges; \
|
uint16_t wNumSubRanges; \
|
||||||
struct TU_ATTR_PACKED { \
|
struct TU_ATTR_PACKED { \
|
||||||
int16_t bMin ; /*The setting for the MIN attribute of the nth subrange of the addressed Control*/\
|
int16_t bMin ; /*The setting for the MIN attribute of the nth subrange of the addressed Control*/\
|
||||||
int16_t bMax ; /*The setting for the MAX attribute of the nth subrange of the addressed Control*/\
|
int16_t bMax ; /*The setting for the MAX attribute of the nth subrange of the addressed Control*/\
|
||||||
@ -895,8 +895,8 @@ typedef struct TU_ATTR_PACKED {
|
|||||||
|
|
||||||
// 5.2.3.3 4-byte Control RANGE Parameter Block
|
// 5.2.3.3 4-byte Control RANGE Parameter Block
|
||||||
#define audio_control_range_4_n_t(numSubRanges) \
|
#define audio_control_range_4_n_t(numSubRanges) \
|
||||||
struct TU_ATTR_PACKED { \
|
struct TU_ATTR_PACKED { \
|
||||||
uint16_t wNumSubRanges = numSubRanges; \
|
uint16_t wNumSubRanges; \
|
||||||
struct TU_ATTR_PACKED { \
|
struct TU_ATTR_PACKED { \
|
||||||
int32_t bMin ; /*The setting for the MIN attribute of the nth subrange of the addressed Control*/\
|
int32_t bMin ; /*The setting for the MIN attribute of the nth subrange of the addressed Control*/\
|
||||||
int32_t bMax ; /*The setting for the MAX attribute of the nth subrange of the addressed Control*/\
|
int32_t bMax ; /*The setting for the MAX attribute of the nth subrange of the addressed Control*/\
|
||||||
|
@ -694,6 +694,8 @@ static bool audiod_get_interface(uint8_t rhport, tusb_control_request_t const *
|
|||||||
TU_VERIFY(audiod_get_AS_interface_index(itf, &idxDriver, &idxItf, &dummy));
|
TU_VERIFY(audiod_get_AS_interface_index(itf, &idxDriver, &idxItf, &dummy));
|
||||||
TU_VERIFY(tud_control_xfer(rhport, p_request, &_audiod_itf[idxDriver].altSetting[idxItf], 1));
|
TU_VERIFY(tud_control_xfer(rhport, p_request, &_audiod_itf[idxDriver].altSetting[idxItf], 1));
|
||||||
|
|
||||||
|
TU_LOG2(" Get itf: %u - current alt: %u\r\n", itf, _audiod_itf[idxDriver].altSetting[idxItf]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -709,9 +711,9 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
|
|||||||
|
|
||||||
// Here we need to do the following:
|
// Here we need to do the following:
|
||||||
|
|
||||||
// 1. Find the audio driver interface which was assigned to the given interface which is to be set
|
// 1. Find the audio driver assigned to the given interface to be set
|
||||||
// Since one audio driver interface has to be able to cover an unknown number of interfaces (AC, AS + its alternate settings), the best memory efficient way to solve this is to always search through the descriptors.
|
// Since one audio driver interface has to be able to cover an unknown number of interfaces (AC, AS + its alternate settings), the best memory efficient way to solve this is to always search through the descriptors.
|
||||||
// The audio driver interface is mapped to an audio function by a reference pointer to the corresponding AC interface of this audio function which serves as a starting point for searching
|
// The audio driver is mapped to an audio function by a reference pointer to the corresponding AC interface of this audio function which serves as a starting point for searching
|
||||||
|
|
||||||
// 2. Close EPs which are currently open
|
// 2. Close EPs which are currently open
|
||||||
// To do so it is not necessary to know the current active alternate interface since we already save the current EP addresses - we simply close them
|
// To do so it is not necessary to know the current active alternate interface since we already save the current EP addresses - we simply close them
|
||||||
@ -721,6 +723,8 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
|
|||||||
uint8_t const itf = tu_u16_low(p_request->wIndex);
|
uint8_t const itf = tu_u16_low(p_request->wIndex);
|
||||||
uint8_t const alt = tu_u16_low(p_request->wValue);
|
uint8_t const alt = tu_u16_low(p_request->wValue);
|
||||||
|
|
||||||
|
TU_LOG2(" Set itf: %u - alt: %u\r\n", itf, alt);
|
||||||
|
|
||||||
// Find index of audio streaming interface and index of interface
|
// Find index of audio streaming interface and index of interface
|
||||||
uint8_t idxDriver, idxItf;
|
uint8_t idxDriver, idxItf;
|
||||||
uint8_t const *p_desc;
|
uint8_t const *p_desc;
|
||||||
@ -768,7 +772,8 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
|
|||||||
{
|
{
|
||||||
if (tu_desc_type(p_desc) == TUSB_DESC_ENDPOINT)
|
if (tu_desc_type(p_desc) == TUSB_DESC_ENDPOINT)
|
||||||
{
|
{
|
||||||
TU_ASSERT(dcd_edpt_open(rhport, (tusb_desc_endpoint_t const *) p_desc), false);
|
// TU_ASSERT(dcd_edpt_open(rhport, (tusb_desc_endpoint_t const *) p_desc), false);
|
||||||
|
TU_ASSERT(usbd_edpt_open(rhport, (tusb_desc_endpoint_t const *)p_desc));
|
||||||
uint8_t ep_addr = ((tusb_desc_endpoint_t const *) p_desc)->bEndpointAddress;
|
uint8_t ep_addr = ((tusb_desc_endpoint_t const *) p_desc)->bEndpointAddress;
|
||||||
|
|
||||||
#if CFG_TUD_AUDIO_EPSIZE_IN > 0
|
#if CFG_TUD_AUDIO_EPSIZE_IN > 0
|
||||||
@ -813,18 +818,15 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
|
|||||||
// Check for nothing found - we can rely on this since EP descriptors are never the last descriptors, there are always also class specific EP descriptors following!
|
// Check for nothing found - we can rely on this since EP descriptors are never the last descriptors, there are always also class specific EP descriptors following!
|
||||||
TU_VERIFY(p_desc < p_desc_end);
|
TU_VERIFY(p_desc < p_desc_end);
|
||||||
|
|
||||||
|
// Save current alternative interface setting
|
||||||
|
_audiod_itf[idxDriver].altSetting[idxItf] = alt;
|
||||||
|
|
||||||
// Invoke callback
|
// Invoke callback
|
||||||
if (tud_audio_set_itf_cb)
|
if (tud_audio_set_itf_cb)
|
||||||
{
|
{
|
||||||
if (!tud_audio_set_itf_cb(rhport, p_request))
|
if (!tud_audio_set_itf_cb(rhport, p_request)) return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save current alternative interface setting
|
|
||||||
_audiod_itf[idxDriver].altSetting[idxItf] = alt;
|
|
||||||
|
|
||||||
tud_control_status(rhport, p_request);
|
tud_control_status(rhport, p_request);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user