Make USB MIDI device code allow a device with no Audio Control interface
This commit is contained in:
@@ -406,20 +406,26 @@ void midid_reset(uint8_t rhport)
|
||||
|
||||
uint16_t midid_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint16_t max_len)
|
||||
{
|
||||
uint16_t drv_len = 0;
|
||||
uint8_t const * p_desc = (uint8_t const *)desc_itf;
|
||||
// 1st Interface is Audio Control v1
|
||||
TU_VERIFY(TUSB_CLASS_AUDIO == desc_itf->bInterfaceClass &&
|
||||
if (TUSB_CLASS_AUDIO == desc_itf->bInterfaceClass &&
|
||||
AUDIO_SUBCLASS_CONTROL == desc_itf->bInterfaceSubClass &&
|
||||
AUDIO_FUNC_PROTOCOL_CODE_UNDEF == desc_itf->bInterfaceProtocol, 0);
|
||||
|
||||
uint16_t drv_len = tu_desc_len(desc_itf);
|
||||
uint8_t const * p_desc = tu_desc_next(desc_itf);
|
||||
|
||||
AUDIO_FUNC_PROTOCOL_CODE_UNDEF == desc_itf->bInterfaceProtocol)
|
||||
{
|
||||
drv_len = tu_desc_len(desc_itf);
|
||||
p_desc = tu_desc_next(desc_itf);
|
||||
// Skip Class Specific descriptors
|
||||
while ( TUSB_DESC_CS_INTERFACE == tu_desc_type(p_desc) && drv_len <= max_len )
|
||||
{
|
||||
drv_len += tu_desc_len(p_desc);
|
||||
p_desc = tu_desc_next(p_desc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TU_LOG1("Warning: MIDI Device has no Audio Control Interface");
|
||||
}
|
||||
|
||||
// 2nd Interface is MIDI Streaming
|
||||
TU_VERIFY(TUSB_DESC_INTERFACE == tu_desc_type(p_desc), 0);
|
||||
|
@@ -920,7 +920,15 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num)
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_MIDI
|
||||
if ( driver->open == midid_open ) assoc_itf_count = 2;
|
||||
if ( driver->open == midid_open )
|
||||
{
|
||||
// If there is a class-compliant Audio Control Class, then 2 interfaces
|
||||
// Otherwise, only one
|
||||
if (TUSB_CLASS_AUDIO == desc_itf->bInterfaceClass &&
|
||||
AUDIO_SUBCLASS_CONTROL == desc_itf->bInterfaceSubClass &&
|
||||
AUDIO_FUNC_PROTOCOL_CODE_UNDEF == desc_itf->bInterfaceProtocol)
|
||||
assoc_itf_count = 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_BTH && CFG_TUD_BTH_ISO_ALT_COUNT
|
||||
|
Reference in New Issue
Block a user