mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-23 09:41:19 +00:00
Fix mic audio descriptor, fix too strict check on IAD desc. in usbd.c
This commit is contained in:
parent
d2f1bb58b3
commit
4362665fb3
@ -57,6 +57,12 @@ typedef enum
|
|||||||
AUDIO_SUBCLASS_MIDI_STREAMING , ///< MIDI Streaming
|
AUDIO_SUBCLASS_MIDI_STREAMING , ///< MIDI Streaming
|
||||||
} audio_subclass_type_t;
|
} audio_subclass_type_t;
|
||||||
|
|
||||||
|
/// Audio Function Subclass Codes
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
AUDIO_FUNCTION_SUBCLASS_UNDEFINED = 0x00,
|
||||||
|
} audio_function_subclass_type_t;
|
||||||
|
|
||||||
/// Audio Protocol Codes
|
/// Audio Protocol Codes
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -632,7 +632,7 @@ void audiod_reset(uint8_t rhport)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool audiod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length)
|
uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len)
|
||||||
{
|
{
|
||||||
TU_VERIFY ( TUSB_CLASS_AUDIO == itf_desc->bInterfaceClass &&
|
TU_VERIFY ( TUSB_CLASS_AUDIO == itf_desc->bInterfaceClass &&
|
||||||
AUDIO_SUBCLASS_CONTROL == itf_desc->bInterfaceSubClass);
|
AUDIO_SUBCLASS_CONTROL == itf_desc->bInterfaceSubClass);
|
||||||
@ -666,9 +666,11 @@ bool audiod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_
|
|||||||
// This is all we need so far - the EPs are setup by a later set_interface request (as per UAC2 specification)
|
// This is all we need so far - the EPs are setup by a later set_interface request (as per UAC2 specification)
|
||||||
|
|
||||||
// Notify caller we read complete descriptor
|
// Notify caller we read complete descriptor
|
||||||
(*p_length) += tud_audio_desc_lengths[i];
|
// (*p_length) += tud_audio_desc_lengths[i];
|
||||||
|
// TODO: Find a way to find end of current audio function and avoid necessity of tud_audio_desc_lengths - since now max_length is available we could do this surely somehow
|
||||||
|
uint16_t drv_len = tud_audio_desc_lengths[i] - TUD_AUDIO_DESC_IAD_LEN; // - TUD_AUDIO_DESC_IAD_LEN since tinyUSB already handles the IAD descriptor
|
||||||
|
|
||||||
return true;
|
return drv_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool audiod_get_interface(uint8_t rhport, tusb_control_request_t const * p_request)
|
static bool audiod_get_interface(uint8_t rhport, tusb_control_request_t const * p_request)
|
||||||
|
@ -289,7 +289,7 @@ inline uint16_t tud_audio_int_ctr_write(uint8_t const* buffer, uint16_t bufsize)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void audiod_init (void);
|
void audiod_init (void);
|
||||||
void audiod_reset (uint8_t rhport);
|
void audiod_reset (uint8_t rhport);
|
||||||
bool audiod_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length);
|
uint16_t audiod_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||||
bool audiod_control_request (uint8_t rhport, tusb_control_request_t const * request);
|
bool audiod_control_request (uint8_t rhport, tusb_control_request_t const * request);
|
||||||
bool audiod_control_complete (uint8_t rhport, tusb_control_request_t const * request);
|
bool audiod_control_complete (uint8_t rhport, tusb_control_request_t const * request);
|
||||||
bool audiod_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes);
|
bool audiod_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||||
|
@ -779,7 +779,7 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num)
|
|||||||
// IAD's first interface number and class/subclass/protocol should match with opened interface
|
// IAD's first interface number and class/subclass/protocol should match with opened interface
|
||||||
TU_ASSERT(desc_itf_assoc->bFirstInterface == desc_itf->bInterfaceNumber &&
|
TU_ASSERT(desc_itf_assoc->bFirstInterface == desc_itf->bInterfaceNumber &&
|
||||||
desc_itf_assoc->bFunctionClass == desc_itf->bInterfaceClass &&
|
desc_itf_assoc->bFunctionClass == desc_itf->bInterfaceClass &&
|
||||||
desc_itf_assoc->bFunctionSubClass == desc_itf->bInterfaceSubClass &&
|
// desc_itf_assoc->bFunctionSubClass == desc_itf->bInterfaceSubClass &&
|
||||||
desc_itf_assoc->bFunctionProtocol == desc_itf->bInterfaceProtocol);
|
desc_itf_assoc->bFunctionProtocol == desc_itf->bInterfaceProtocol);
|
||||||
|
|
||||||
for(uint8_t i=1; i<desc_itf_assoc->bInterfaceCount; i++)
|
for(uint8_t i=1; i<desc_itf_assoc->bInterfaceCount; i++)
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#define _TUSB_USBD_H_
|
#define _TUSB_USBD_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "common/tusb_common.h"
|
#include "common/tusb_common.h"
|
||||||
@ -319,41 +319,154 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re
|
|||||||
|
|
||||||
//------------- AUDIO -------------//
|
//------------- AUDIO -------------//
|
||||||
|
|
||||||
// Length of template descriptor (132 bytes)
|
/* Standard Interface Association Descriptor (IAD) */
|
||||||
#define TUD_AUDIO_MIC_DESC_LEN (8 + 9 + 9 + 8 + 17 + 12 + 14 + 9 + 9 + 16 + 6 + 7 + 8)
|
#define TUD_AUDIO_DESC_IAD_LEN 8
|
||||||
#define TUD_AUDIO_MIC_DESC_N_AS_INT 1
|
#define TUD_AUDIO_DESC_IAD(_firstitfs, _nitfs, _stridx) \
|
||||||
|
TUD_AUDIO_DESC_IAD_LEN, TUSB_DESC_INTERFACE_ASSOCIATION, _firstitfs, _nitfs, TUSB_CLASS_AUDIO, AUDIO_FUNCTION_SUBCLASS_UNDEFINED, AUDIO_PROTOCOL_V2, _stridx
|
||||||
|
|
||||||
|
/* Standard AC Interface Descriptor(4.7.1) */
|
||||||
|
#define TUD_AUDIO_DESC_STD_AC_LEN 9
|
||||||
|
#define TUD_AUDIO_DESC_STD_AC(_itfnum, _nEPs, _stridx) /* _nEPs is 0 or 1 */\
|
||||||
|
TUD_AUDIO_DESC_STD_AC_LEN, TUSB_DESC_INTERFACE, _itfnum, /* fixed to zero */ 0x00, _nEPs, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_CONTROL, AUDIO_PROTOCOL_V2, _stridx
|
||||||
|
|
||||||
|
/* Class-Specific AC Interface Header Descriptor(4.7.2) */
|
||||||
|
#define TUD_AUDIO_DESC_CS_AC_LEN 9
|
||||||
|
#define TUD_AUDIO_DESC_CS_AC(_bcdADC, _category, _totallen, _ctrl) /* _bcdADC : Audio Device Class Specification Release Number in Binary-Coded Decimal, _category : see audio_function_t, _totallen : Total number of bytes returned for the class-specific AudioControl interface i.e. Clock Source, Unit and Terminal descriptors - Do not include TUD_AUDIO_DESC_CS_AC_LEN, we already do this here*/ \
|
||||||
|
TUD_AUDIO_DESC_CS_AC_LEN, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_HEADER, U16_TO_U8S_LE(_bcdADC), _category, U16_TO_U8S_LE(_totallen + TUD_AUDIO_DESC_CS_AC_LEN), _ctrl
|
||||||
|
|
||||||
|
/* Clock Source Descriptor(4.7.2.1) */
|
||||||
|
#define TUD_AUDIO_DESC_CLK_SRC_LEN 8
|
||||||
|
#define TUD_AUDIO_DESC_CLK_SRC(_clkid, _attr, _ctrl, _assocTerm, _stridx) \
|
||||||
|
TUD_AUDIO_DESC_CLK_SRC_LEN, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_CLOCK_SOURCE, _clkid, _attr, _ctrl, _assocTerm, _stridx
|
||||||
|
|
||||||
|
/* Input Terminal Descriptor(4.7.2.4) */
|
||||||
|
#define TUD_AUDIO_DESC_INPUT_TERM_LEN 17
|
||||||
|
#define TUD_AUDIO_DESC_INPUT_TERM(_termid, _termtype, _assocTerm, _clkid, _nchannelslogical, _channelcfg, _idxchannelnames, _ctrl, _stridx) \
|
||||||
|
TUD_AUDIO_DESC_INPUT_TERM_LEN, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_INPUT_TERMINAL, _termid, U16_TO_U8S_LE(_termtype), _assocTerm, _clkid, _nchannelslogical, U32_TO_U8S_LE(_channelcfg), _idxchannelnames, U16_TO_U8S_LE(_ctrl), _stridx
|
||||||
|
|
||||||
|
/* Output Terminal Descriptor(4.7.2.5) */
|
||||||
|
#define TUD_AUDIO_DESC_OUTPUT_TERM_LEN 12
|
||||||
|
#define TUD_AUDIO_DESC_OUTPUT_TERM(_termid, _termtype, _assocTerm, _srcid, _clkid, _ctrl, _stridx) \
|
||||||
|
TUD_AUDIO_DESC_OUTPUT_TERM_LEN, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_OUTPUT_TERMINAL, _termid, U16_TO_U8S_LE(_termtype), _assocTerm, _srcid, _clkid, U16_TO_U8S_LE(_ctrl), _stridx
|
||||||
|
|
||||||
|
/* Feature Unit Descriptor(4.7.2.8) */
|
||||||
|
// 1 - Channel
|
||||||
|
#define TUD_AUDIO_DESC_FEATURE_UNIT_ONE_CHANNEL_LEN 6+(1+1)*4
|
||||||
|
#define TUD_AUDIO_DESC_FEATURE_UNIT_ONE_CHANNEL(_unitid, _srcid, _ctrlch0master, _ctrlch1, _stridx) \
|
||||||
|
TUD_AUDIO_DESC_FEATURE_UNIT_ONE_CHANNEL_LEN, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_FEATURE_UNIT, _unitid, _srcid, U32_TO_U8S_LE(_ctrlch0master), U32_TO_U8S_LE(_ctrlch1), _stridx
|
||||||
|
|
||||||
|
// For more channels, add definitions here
|
||||||
|
|
||||||
|
/* Standard AS Interface Descriptor(4.9.1) */
|
||||||
|
#define TUD_AUDIO_DESC_STD_AS_INT_LEN 9
|
||||||
|
#define TUD_AUDIO_DESC_STD_AS_INT(_itfnum, _altset, _nEPs, _stridx) \
|
||||||
|
TUD_AUDIO_DESC_STD_AS_INT_LEN, TUSB_DESC_INTERFACE, _itfnum, _altset, _nEPs, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_STREAMING, AUDIO_PROTOCOL_V2, _stridx
|
||||||
|
|
||||||
|
/* Class-Specific AS Interface Descriptor(4.9.2) */
|
||||||
|
#define TUD_AUDIO_DESC_CS_AS_INT_LEN 16
|
||||||
|
#define TUD_AUDIO_DESC_CS_AS_INT(_termid, _ctrl, _formattype, _formats, _nchannelsphysical, _channelcfg, _stridx) \
|
||||||
|
TUD_AUDIO_DESC_CS_AS_INT_LEN, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AS_INTERFACE_AS_GENERAL, _termid, _ctrl, _formattype, U32_TO_U8S_LE(_formats), _nchannelsphysical, U32_TO_U8S_LE(_channelcfg), _stridx
|
||||||
|
|
||||||
|
/* Type I Format Type Descriptor(2.3.1.6 - Audio Formats) */
|
||||||
|
#define TUD_AUDIO_DESC_TYPE_I_FORMAT_LEN 6
|
||||||
|
#define TUD_AUDIO_DESC_TYPE_I_FORMAT(_subslotsize, _bitresolution) /* _subslotsize is number of bytes per sample (i.e. subslot) and can be 1,2,3, or 4 */\
|
||||||
|
TUD_AUDIO_DESC_TYPE_I_FORMAT_LEN, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AS_INTERFACE_FORMAT_TYPE, AUDIO_FORMAT_TYPE_I, _subslotsize, _bitresolution
|
||||||
|
|
||||||
|
/* Standard AS Isochronous Audio Data Endpoint Descriptor(4.10.1.1) */
|
||||||
|
#define TUD_AUDIO_DESC_STD_AS_ISO_EP_LEN 7
|
||||||
|
#define TUD_AUDIO_DESC_STD_AS_ISO_EP(_ep, _attr, _maxEPsize, _interval) \
|
||||||
|
TUD_AUDIO_DESC_STD_AS_ISO_EP_LEN, TUSB_DESC_ENDPOINT, _ep, _attr, U16_TO_U8S_LE(_maxEPsize), _interval
|
||||||
|
|
||||||
|
/* Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.10.1.2) */
|
||||||
|
#define TUD_AUDIO_DESC_CS_AS_ISO_EP_LEN 8
|
||||||
|
#define TUD_AUDIO_DESC_CS_AS_ISO_EP(_attr, _ctrl, _lockdelayunit, _lockdelay) \
|
||||||
|
TUD_AUDIO_DESC_CS_AS_ISO_EP_LEN, TUSB_DESC_CS_ENDPOINT, AUDIO_CS_EP_SUBTYPE_GENERAL, _attr, _ctrl, _lockdelayunit, U16_TO_U8S_LE(_lockdelay)
|
||||||
|
|
||||||
// AUDIO simple descriptor (UAC2) for 1 microphone input
|
// AUDIO simple descriptor (UAC2) for 1 microphone input
|
||||||
// - 1 Input Terminal, 1 Feature Unit (Mute and Volume Control), 1 Output Terminal, 1 Clock Source
|
// - 1 Input Terminal, 1 Feature Unit (Mute and Volume Control), 1 Output Terminal, 1 Clock Source
|
||||||
|
|
||||||
|
#define TUD_AUDIO_MIC_DESC_LEN (TUD_AUDIO_DESC_IAD_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_STD_AC_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_CS_AC_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_CLK_SRC_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_INPUT_TERM_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_OUTPUT_TERM_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_FEATURE_UNIT_ONE_CHANNEL_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_STD_AS_INT_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_STD_AS_INT_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_CS_AS_INT_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_TYPE_I_FORMAT_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_STD_AS_ISO_EP_LEN\
|
||||||
|
+ TUD_AUDIO_DESC_CS_AS_ISO_EP_LEN)
|
||||||
|
|
||||||
|
#define TUD_AUDIO_MIC_DESC_N_AS_INT 1 // Number of AS interfaces
|
||||||
|
|
||||||
#define TUD_AUDIO_MIC_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epin, _epsize) \
|
#define TUD_AUDIO_MIC_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epin, _epsize) \
|
||||||
/* Standard Interface Association Descriptor (IAD) */\
|
/* Standard Interface Association Descriptor (IAD) */\
|
||||||
8, TUSB_DESC_INTERFACE_ASSOCIATION, _itfnum, 0x02, TUSB_CLASS_AUDIO, 0x00, AUDIO_PROTOCOL_V2, 0x00,\
|
TUD_AUDIO_DESC_IAD(/*_firstitfs*/ _itfnum, /*_nitfs*/ 0x02, /*_stridx*/ 0x00),\
|
||||||
/* Standard AC Interface Descriptor(4.7.1) */\
|
/* Standard AC Interface Descriptor(4.7.1) */\
|
||||||
9, TUSB_DESC_INTERFACE, _itfnum, 0x00, 0x00, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_CONTROL, AUDIO_PROTOCOL_V2, _stridx,\
|
TUD_AUDIO_DESC_STD_AC(/*_itfnum*/ _itfnum, /*_nEPs*/ 0x00, /*_stridx*/ _stridx),\
|
||||||
/* Class-Specific AC Interface Header Descriptor(4.7.2) */\
|
/* Class-Specific AC Interface Header Descriptor(4.7.2) */\
|
||||||
9, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_HEADER, U16_TO_U8S_LE(0x0200), AUDIO_FUNC_MICROPHONE, U16_TO_U8S_LE(9+8+17+12+6+(1+1)*4), AUDIO_CS_AS_INTERFACE_CTRL_LATENCY_POS,\
|
TUD_AUDIO_DESC_CS_AC(/*_bcdADC*/ 0x0200, /*_category*/ AUDIO_FUNC_MICROPHONE, /*_totallen*/ TUD_AUDIO_DESC_CLK_SRC_LEN+TUD_AUDIO_DESC_INPUT_TERM_LEN+TUD_AUDIO_DESC_OUTPUT_TERM_LEN+TUD_AUDIO_DESC_FEATURE_UNIT_ONE_CHANNEL_LEN, /*_ctrl*/ AUDIO_CS_AS_INTERFACE_CTRL_LATENCY_POS),\
|
||||||
/* Clock Source Descriptor(4.7.2.1) */\
|
/* Clock Source Descriptor(4.7.2.1) */\
|
||||||
8, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_CLOCK_SOURCE, 0x04, AUDIO_CLOCK_SOURCE_ATT_INT_FIX_CLK, (AUDIO_CTRL_R << AUDIO_CLOCK_SOURCE_CTRL_CLK_FRQ_POS), 0x00, \
|
TUD_AUDIO_DESC_CLK_SRC(/*_clkid*/ 0x04, /*_attr*/ AUDIO_CLOCK_SOURCE_ATT_INT_FIX_CLK, /*_ctrl*/ (AUDIO_CTRL_R << AUDIO_CLOCK_SOURCE_CTRL_CLK_FRQ_POS), /*_assocTerm*/ 0x01, /*_stridx*/ 0x00),\
|
||||||
/* Input Terminal Descriptor(4.7.2.4) */\
|
/* Input Terminal Descriptor(4.7.2.4) */\
|
||||||
17, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_INPUT_TERMINAL, 0x01, U16_TO_U8S_LE(AUDIO_TERM_TYPE_IN_GENERIC_MIC), 0x00, 0x04, 0x01, U32_TO_U8S_LE(AUDIO_CHANNEL_CONFIG_NON_PREDEFINED), 0x00, U16_TO_U8S_LE(AUDIO_CTRL_R << AUDIO_IN_TERM_CTRL_CONNECTOR_POS), 0x00, \
|
TUD_AUDIO_DESC_INPUT_TERM(/*_termid*/ 0x01, /*_termtype*/ AUDIO_TERM_TYPE_IN_GENERIC_MIC, /*_assocTerm*/ 0x03, /*_clkid*/ 0x04, /*_nchannelslogical*/ 0x01, /*_channelcfg*/ AUDIO_CHANNEL_CONFIG_NON_PREDEFINED, /*_idxchannelnames*/ 0x00, /*_ctrl*/ AUDIO_CTRL_R << AUDIO_IN_TERM_CTRL_CONNECTOR_POS, /*_stridx*/ 0x00),\
|
||||||
/* Output Terminal Descriptor(4.7.2.5) */\
|
/* Output Terminal Descriptor(4.7.2.5) */\
|
||||||
12, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_OUTPUT_TERMINAL, 0x03, U16_TO_U8S_LE(AUDIO_TERM_TYPE_USB_STREAMING), 0x00, 0x02, 0x04, U16_TO_U8S_LE(0x0000), 0x00, \
|
TUD_AUDIO_DESC_OUTPUT_TERM(/*_termid*/ 0x03, /*_termtype*/ AUDIO_TERM_TYPE_USB_STREAMING, /*_assocTerm*/ 0x01, /*_srcid*/ 0x02, /*_clkid*/ 0x04, /*_ctrl*/ 0x0000, /*_stridx*/ 0x00),\
|
||||||
/* Feature Unit Descriptor(4.7.2.8) */\
|
/* Feature Unit Descriptor(4.7.2.8) */\
|
||||||
6+(1+1)*4, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_FEATURE_UNIT, 0x02, 0x01, U32_TO_U8S_LE(AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS), U32_TO_U8S_LE(AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS), 0x00, \
|
TUD_AUDIO_DESC_FEATURE_UNIT_ONE_CHANNEL(/*_unitid*/ 0x02, /*_srcid*/ 0x01, /*_ctrlch0master*/ AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch1*/ AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS, /*_stridx*/ 0x00),\
|
||||||
/* Standard AS Interface Descriptor(4.9.1) */\
|
/* Standard AS Interface Descriptor(4.9.1) */\
|
||||||
/* Interface 1, Alternate 0 - default alternate setting with 0 bandwidth */\
|
/* Interface 1, Alternate 0 - default alternate setting with 0 bandwidth */\
|
||||||
9, TUSB_DESC_INTERFACE, (uint8_t)((_itfnum)+1), /* alternate setting */ 0x00, /* number of EPs */ 0x00, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_STREAMING, AUDIO_PROTOCOL_V2, 0x00,\
|
TUD_AUDIO_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x00, /*_nEPs*/ 0x00, /*_stridx*/ 0x00),\
|
||||||
/* Standard AS Interface Descriptor(4.9.1) */\
|
/* Standard AS Interface Descriptor(4.9.1) */\
|
||||||
/* Interface 1, Alternate 1 - alternate interface for data streaming */\
|
/* Interface 1, Alternate 1 - alternate interface for data streaming */\
|
||||||
9, TUSB_DESC_INTERFACE, (uint8_t)((_itfnum)+1), /* alternate setting */ 0x01, /* number of EPs */ 0x01, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_STREAMING, AUDIO_PROTOCOL_V2, 0x00,\
|
TUD_AUDIO_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x01, /*_nEPs*/ 0x01, /*_stridx*/ 0x00),\
|
||||||
/* Class-Specific AS Interface Descriptor(4.9.2) */\
|
/* Class-Specific AS Interface Descriptor(4.9.2) */\
|
||||||
16, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AS_INTERFACE_AS_GENERAL, 0x03, AUDIO_CTRL_NONE, AUDIO_FORMAT_TYPE_I, U32_TO_U8S_LE(AUDIO_DATA_FORMAT_TYPE_I_PCM), 0x01, U32_TO_U8S_LE(AUDIO_CHANNEL_CONFIG_NON_PREDEFINED), 0x00, \
|
TUD_AUDIO_DESC_CS_AS_INT(/*_termid*/ 0x03, /*_ctrl*/ AUDIO_CTRL_NONE, /*_formattype*/ AUDIO_FORMAT_TYPE_I, /*_formats*/ AUDIO_DATA_FORMAT_TYPE_I_PCM, /*_nchannelsphysical*/ 0x01, /*_channelcfg*/ AUDIO_CHANNEL_CONFIG_NON_PREDEFINED, /*_stridx*/ 0x00),\
|
||||||
/* Type I Format Type Descriptor(2.3.1.6 - Audio Formats) */\
|
/* Type I Format Type Descriptor(2.3.1.6 - Audio Formats) */\
|
||||||
6, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AS_INTERFACE_FORMAT_TYPE, AUDIO_FORMAT_TYPE_I, _nBytesPerSample, _nBitsUsedPerSample,\
|
TUD_AUDIO_DESC_TYPE_I_FORMAT(_nBytesPerSample, _nBitsUsedPerSample),\
|
||||||
/* Standard AS Isochronous Audio Data Endpoint Descriptor(4.10.1.1) */\
|
/* Standard AS Isochronous Audio Data Endpoint Descriptor(4.10.1.1) */\
|
||||||
7, TUSB_DESC_ENDPOINT, _epin, (TUSB_XFER_ISOCHRONOUS | TUSB_ISO_EP_ATT_ASYNCHRONOUS | TUSB_ISO_EP_ATT_DATA), U16_TO_U8S_LE(_epsize), (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HIGH_SPEED) ? 0x04 : 0x01,\
|
TUD_AUDIO_DESC_STD_AS_ISO_EP(/*_ep*/ _epin, /*_attr*/ (TUSB_XFER_ISOCHRONOUS | TUSB_ISO_EP_ATT_ASYNCHRONOUS | TUSB_ISO_EP_ATT_DATA), /*_maxEPsize*/ _epsize, /*_interval*/ (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HIGH_SPEED) ? 0x04 : 0x01),\
|
||||||
/* Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.10.1.2) */\
|
/* Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.10.1.2) */\
|
||||||
8, TUSB_DESC_CS_ENDPOINT, AUDIO_CS_EP_SUBTYPE_GENERAL, AUDIO_CS_AS_ISO_DATA_EP_ATT_NON_MAX_PACKETS_OK, AUDIO_CTRL_NONE, AUDIO_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_UNDEFINED, U16_TO_U8S_LE(0x0000)\
|
TUD_AUDIO_DESC_CS_AS_ISO_EP(/*_attr*/ AUDIO_CS_AS_ISO_DATA_EP_ATT_NON_MAX_PACKETS_OK, /*_ctrl*/ AUDIO_CTRL_NONE, /*_lockdelayunit*/ AUDIO_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_UNDEFINED, /*_lockdelay*/ 0x0000)
|
||||||
|
|
||||||
|
// Length of template descriptor (132 bytes)
|
||||||
|
//#define TUD_AUDIO_MIC_DESC_LEN (8 + 9 + 9 + 8 + 17 + 12 + 14 + 9 + 9 + 16 + 6 + 7 + 8)
|
||||||
|
//#define TUD_AUDIO_MIC_DESC_N_AS_INT 1
|
||||||
|
//
|
||||||
|
// // AUDIO simple descriptor (UAC2) for 1 microphone input
|
||||||
|
// // - 1 Input Terminal, 1 Feature Unit (Mute and Volume Control), 1 Output Terminal, 1 Clock Source
|
||||||
|
// #define TUD_AUDIO_MIC_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epin, _epsize) \
|
||||||
|
// /* Standard Interface Association Descriptor (IAD) */\
|
||||||
|
// 8, TUSB_DESC_INTERFACE_ASSOCIATION, _itfnum, 0x02, TUSB_CLASS_AUDIO, 0x00, AUDIO_PROTOCOL_V2, 0x00,\
|
||||||
|
// /* Standard AC Interface Descriptor(4.7.1) */\
|
||||||
|
// 9, TUSB_DESC_INTERFACE, _itfnum, 0x00, 0x00, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_CONTROL, AUDIO_PROTOCOL_V2, _stridx,\
|
||||||
|
// /* Class-Specific AC Interface Header Descriptor(4.7.2) */\
|
||||||
|
// 9, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_HEADER, U16_TO_U8S_LE(0x0200), AUDIO_FUNC_MICROPHONE, U16_TO_U8S_LE(9+8+17+12+6+(1+1)*4), AUDIO_CS_AS_INTERFACE_CTRL_LATENCY_POS,\
|
||||||
|
// /* Clock Source Descriptor(4.7.2.1) */\
|
||||||
|
// 8, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_CLOCK_SOURCE, 0x04, AUDIO_CLOCK_SOURCE_ATT_INT_FIX_CLK, (AUDIO_CTRL_R << AUDIO_CLOCK_SOURCE_CTRL_CLK_FRQ_POS), 0x00, \
|
||||||
|
// /* Input Terminal Descriptor(4.7.2.4) */\
|
||||||
|
// 17, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_INPUT_TERMINAL, 0x01, U16_TO_U8S_LE(AUDIO_TERM_TYPE_IN_GENERIC_MIC), 0x00, 0x04, 0x01, U32_TO_U8S_LE(AUDIO_CHANNEL_CONFIG_NON_PREDEFINED), 0x00, U16_TO_U8S_LE(AUDIO_CTRL_R << AUDIO_IN_TERM_CTRL_CONNECTOR_POS), 0x00, \
|
||||||
|
// /* Output Terminal Descriptor(4.7.2.5) */\
|
||||||
|
// 12, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_OUTPUT_TERMINAL, 0x03, U16_TO_U8S_LE(AUDIO_TERM_TYPE_USB_STREAMING), 0x00, 0x02, 0x04, U16_TO_U8S_LE(0x0000), 0x00, \
|
||||||
|
// /* Feature Unit Descriptor(4.7.2.8) */\
|
||||||
|
// 6+(1+1)*4, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_FEATURE_UNIT, 0x02, 0x01, U32_TO_U8S_LE(AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS), U32_TO_U8S_LE(AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS), 0x00, \
|
||||||
|
// /* Standard AS Interface Descriptor(4.9.1) */\
|
||||||
|
// /* Interface 1, Alternate 0 - default alternate setting with 0 bandwidth */\
|
||||||
|
// 9, TUSB_DESC_INTERFACE, (uint8_t)((_itfnum)+1), /* alternate setting */ 0x00, /* number of EPs */ 0x00, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_STREAMING, AUDIO_PROTOCOL_V2, 0x00,\
|
||||||
|
// /* Standard AS Interface Descriptor(4.9.1) */\
|
||||||
|
// /* Interface 1, Alternate 1 - alternate interface for data streaming */\
|
||||||
|
// 9, TUSB_DESC_INTERFACE, (uint8_t)((_itfnum)+1), /* alternate setting */ 0x01, /* number of EPs */ 0x01, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_STREAMING, AUDIO_PROTOCOL_V2, 0x00,\
|
||||||
|
// /* Class-Specific AS Interface Descriptor(4.9.2) */\
|
||||||
|
// 16, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AS_INTERFACE_AS_GENERAL, 0x03, AUDIO_CTRL_NONE, AUDIO_FORMAT_TYPE_I, U32_TO_U8S_LE(AUDIO_DATA_FORMAT_TYPE_I_PCM), 0x01, U32_TO_U8S_LE(AUDIO_CHANNEL_CONFIG_NON_PREDEFINED), 0x00,\
|
||||||
|
// /* Type I Format Type Descriptor(2.3.1.6 - Audio Formats) */\
|
||||||
|
// 6, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AS_INTERFACE_FORMAT_TYPE, AUDIO_FORMAT_TYPE_I, _nBytesPerSample, _nBitsUsedPerSample,\
|
||||||
|
// /* Standard AS Isochronous Audio Data Endpoint Descriptor(4.10.1.1) */\
|
||||||
|
// 7, TUSB_DESC_ENDPOINT, _epin, (TUSB_XFER_ISOCHRONOUS | TUSB_ISO_EP_ATT_ASYNCHRONOUS | TUSB_ISO_EP_ATT_DATA), U16_TO_U8S_LE(_epsize), (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HIGH_SPEED) ? 0x04 : 0x01,\
|
||||||
|
// /* Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.10.1.2) */\
|
||||||
|
// 8, TUSB_DESC_CS_ENDPOINT, AUDIO_CS_EP_SUBTYPE_GENERAL, AUDIO_CS_AS_ISO_DATA_EP_ATT_NON_MAX_PACKETS_OK, AUDIO_CTRL_NONE, AUDIO_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_UNDEFINED, U16_TO_U8S_LE(0x0000)
|
||||||
|
|
||||||
|
|
||||||
//------------- TUD_USBTMC/USB488 -------------//
|
//------------- TUD_USBTMC/USB488 -------------//
|
||||||
#define TUD_USBTMC_APP_CLASS (TUSB_CLASS_APPLICATION_SPECIFIC)
|
#define TUD_USBTMC_APP_CLASS (TUSB_CLASS_APPLICATION_SPECIFIC)
|
||||||
@ -447,15 +560,15 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re
|
|||||||
//------------- RNDIS -------------//
|
//------------- RNDIS -------------//
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Windows XP */
|
/* Windows XP */
|
||||||
#define TUD_RNDIS_ITF_CLASS TUSB_CLASS_CDC
|
#define TUD_RNDIS_ITF_CLASS TUSB_CLASS_CDC
|
||||||
#define TUD_RNDIS_ITF_SUBCLASS CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL
|
#define TUD_RNDIS_ITF_SUBCLASS CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL
|
||||||
#define TUD_RNDIS_ITF_PROTOCOL 0xFF /* CDC_COMM_PROTOCOL_MICROSOFT_RNDIS */
|
#define TUD_RNDIS_ITF_PROTOCOL 0xFF /* CDC_COMM_PROTOCOL_MICROSOFT_RNDIS */
|
||||||
#else
|
#else
|
||||||
/* Windows 7+ */
|
/* Windows 7+ */
|
||||||
#define TUD_RNDIS_ITF_CLASS TUSB_CLASS_WIRELESS_CONTROLLER
|
#define TUD_RNDIS_ITF_CLASS TUSB_CLASS_WIRELESS_CONTROLLER
|
||||||
#define TUD_RNDIS_ITF_SUBCLASS 0x01
|
#define TUD_RNDIS_ITF_SUBCLASS 0x01
|
||||||
#define TUD_RNDIS_ITF_PROTOCOL 0x03
|
#define TUD_RNDIS_ITF_PROTOCOL 0x03
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Length of template descriptor: 66 bytes
|
// Length of template descriptor: 66 bytes
|
||||||
@ -541,7 +654,7 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re
|
|||||||
TUD_BTH_ISO_ITFS(_itfnum + 1, _ep_in + 1, _ep_out + 1, __VA_ARGS__)
|
TUD_BTH_ISO_ITFS(_itfnum + 1, _ep_in + 1, _ep_out + 1, __VA_ARGS__)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _TUSB_USBD_H_ */
|
#endif /* _TUSB_USBD_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user