summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/class/audio/audio.h1828
-rw-r--r--src/class/audio/audio_device.c572
-rw-r--r--src/class/audio/audio_device.h140
-rwxr-xr-xsrc/class/bth/bth_device.h6
-rw-r--r--src/class/cdc/cdc.h4
-rw-r--r--src/class/cdc/cdc_device.c2
-rw-r--r--src/class/cdc/cdc_device.h2
-rw-r--r--src/class/cdc/cdc_host.c5
-rw-r--r--src/class/cdc/cdc_host.h6
-rw-r--r--src/class/cdc/cdc_rndis.h6
-rw-r--r--src/class/cdc/cdc_rndis_host.h6
-rw-r--r--src/class/cdc/serial/ftdi_sio.h13
-rw-r--r--src/class/dfu/dfu.h6
-rw-r--r--src/class/dfu/dfu_device.h6
-rw-r--r--src/class/dfu/dfu_rt_device.h6
-rw-r--r--src/class/hid/hid.h6
-rw-r--r--src/class/hid/hid_host.h6
-rw-r--r--src/class/midi/midi_device.h6
-rw-r--r--src/class/midi/midi_host.c4
-rw-r--r--src/class/msc/msc.h6
-rw-r--r--src/class/msc/msc_device.h6
-rw-r--r--src/class/net/ncm.h4
-rw-r--r--src/class/net/net_device.h6
-rw-r--r--src/class/usbtmc/usbtmc.h4
-rw-r--r--src/class/vendor/vendor_device.h6
-rw-r--r--src/class/vendor/vendor_host.h6
-rw-r--r--src/common/tusb_common.h52
-rw-r--r--src/common/tusb_compiler.h30
-rw-r--r--src/common/tusb_debug.h18
-rw-r--r--src/common/tusb_fifo.h6
-rw-r--r--src/common/tusb_mcu.h5
-rw-r--r--src/common/tusb_types.h20
-rw-r--r--src/device/dcd.h2
-rw-r--r--src/device/usbd.c22
-rw-r--r--src/device/usbd.h406
-rw-r--r--src/host/hcd.h4
-rw-r--r--src/host/usbh.h6
-rw-r--r--src/host/usbh_pvt.h4
-rw-r--r--src/osal/osal.h21
-rw-r--r--src/osal/osal_none.h6
-rw-r--r--src/portable/ehci/ehci.h6
-rw-r--r--src/portable/ehci/ehci_api.h4
-rw-r--r--src/portable/nuvoton/nuc121/dcd_nuc121.c10
-rw-r--r--src/portable/nuvoton/nuc505/dcd_nuc505.c10
-rw-r--r--src/portable/nxp/lpc17_40/dcd_lpc17_40.h4
-rw-r--r--src/portable/ohci/ohci.c11
-rw-r--r--src/portable/ohci/ohci.h55
-rw-r--r--src/portable/ohci/ohci_nxp.h (renamed from src/portable/nxp/lpc17_40/hcd_lpc17_40.c)48
-rw-r--r--src/portable/raspberrypi/pio_usb/hcd_pio_usb.c11
-rw-r--r--src/portable/renesas/rusb2/rusb2_type.h6
-rw-r--r--src/portable/sunxi/musb_def.h4
-rw-r--r--src/portable/synopsys/dwc2/dcd_dwc2.c8
-rw-r--r--src/portable/synopsys/dwc2/dwc2_at32.h79
-rw-r--r--src/portable/synopsys/dwc2/dwc2_bcm.h4
-rw-r--r--src/portable/valentyusb/eptri/dcd_eptri.h6
-rw-r--r--src/tusb.c8
-rw-r--r--src/tusb.h6
-rw-r--r--src/tusb_option.h16
-rw-r--r--src/typec/pd_types.h4
-rw-r--r--src/typec/tcd.h4
-rw-r--r--src/typec/usbc.h6
61 files changed, 2096 insertions, 1484 deletions
diff --git a/src/class/audio/audio.h b/src/class/audio/audio.h
index 0d1acadcc..47d25dd81 100644
--- a/src/class/audio/audio.h
+++ b/src/class/audio/audio.h
@@ -30,8 +30,8 @@
* Currently only MIDI subclass is supported
* @{ */
-#ifndef _TUSB_AUDIO_H__
-#define _TUSB_AUDIO_H__
+#ifndef TUSB_AUDIO_H__
+#define TUSB_AUDIO_H__
#include "common/tusb_common.h"
@@ -39,917 +39,1255 @@
extern "C" {
#endif
-/// Audio Device Class Codes
+//--------------------------------------------------------------------+
+// GENERIC AUDIO CLASS CODES (COMMON TO UAC1 AND UAC2)
+//--------------------------------------------------------------------+
/// A.2 - Audio Function Subclass Codes
-typedef enum
-{
+typedef enum {
AUDIO_FUNCTION_SUBCLASS_UNDEFINED = 0x00,
} audio_function_subclass_type_t;
/// A.3 - Audio Function Protocol Codes
-typedef enum
-{
- AUDIO_FUNC_PROTOCOL_CODE_UNDEF = 0x00,
- AUDIO_FUNC_PROTOCOL_CODE_V2 = 0x20, ///< Version 2.0
+typedef enum {
+ AUDIO_FUNC_PROTOCOL_CODE_UNDEF = 0x00,
+ AUDIO_FUNC_PROTOCOL_CODE_V1 = 0x00,///< Version 1.0 - same as undefined for backward compatibility
+ AUDIO_FUNC_PROTOCOL_CODE_V2 = 0x20,///< Version 2.0
} audio_function_protocol_code_t;
/// A.5 - Audio Interface Subclass Codes
-typedef enum
-{
+typedef enum {
AUDIO_SUBCLASS_UNDEFINED = 0x00,
- AUDIO_SUBCLASS_CONTROL , ///< Audio Control
- AUDIO_SUBCLASS_STREAMING , ///< Audio Streaming
- AUDIO_SUBCLASS_MIDI_STREAMING , ///< MIDI Streaming
+ AUDIO_SUBCLASS_CONTROL, ///< Audio Control
+ AUDIO_SUBCLASS_STREAMING, ///< Audio Streaming
+ AUDIO_SUBCLASS_MIDI_STREAMING,///< MIDI Streaming
} audio_subclass_type_t;
/// A.6 - Audio Interface Protocol Codes
-typedef enum
-{
- AUDIO_INT_PROTOCOL_CODE_UNDEF = 0x00,
- AUDIO_INT_PROTOCOL_CODE_V2 = 0x20, ///< Version 2.0
+typedef enum {
+ AUDIO_INT_PROTOCOL_CODE_UNDEF = 0x00,
+ AUDIO_INT_PROTOCOL_CODE_V1 = 0x00,///< Version 1.0 - same as undefined for backward compatibility
+ AUDIO_INT_PROTOCOL_CODE_V2 = 0x20,///< Version 2.0
} audio_interface_protocol_code_t;
+/// Terminal Types
+
+/// 2.1 - Audio Class-Terminal Types
+typedef enum {
+ AUDIO_TERM_TYPE_USB_UNDEFINED = 0x0100,
+ AUDIO_TERM_TYPE_USB_STREAMING = 0x0101,
+ AUDIO_TERM_TYPE_USB_VENDOR_SPEC = 0x01FF,
+} audio_terminal_type_t;
+
+/// 2.2 - Audio Class-Input Terminal Types
+typedef enum {
+ AUDIO_TERM_TYPE_IN_UNDEFINED = 0x0200,
+ AUDIO_TERM_TYPE_IN_GENERIC_MIC = 0x0201,
+ AUDIO_TERM_TYPE_IN_DESKTOP_MIC = 0x0202,
+ AUDIO_TERM_TYPE_IN_PERSONAL_MIC = 0x0203,
+ AUDIO_TERM_TYPE_IN_OMNI_MIC = 0x0204,
+ AUDIO_TERM_TYPE_IN_ARRAY_MIC = 0x0205,
+ AUDIO_TERM_TYPE_IN_PROC_ARRAY_MIC = 0x0206,
+} audio_terminal_input_type_t;
+
+/// 2.3 - Audio Class-Output Terminal Types
+typedef enum {
+ AUDIO_TERM_TYPE_OUT_UNDEFINED = 0x0300,
+ AUDIO_TERM_TYPE_OUT_GENERIC_SPEAKER = 0x0301,
+ AUDIO_TERM_TYPE_OUT_HEADPHONES = 0x0302,
+ AUDIO_TERM_TYPE_OUT_HEAD_MNT_DISP_AUIDO = 0x0303,
+ AUDIO_TERM_TYPE_OUT_DESKTOP_SPEAKER = 0x0304,
+ AUDIO_TERM_TYPE_OUT_ROOM_SPEAKER = 0x0305,
+ AUDIO_TERM_TYPE_OUT_COMMUNICATION_SPEAKER = 0x0306,
+ AUDIO_TERM_TYPE_OUT_LOW_FRQ_EFFECTS_SPEAKER = 0x0307,
+} audio_terminal_output_type_t;
+
+/// Rest is yet to be implemented
+
+//--------------------------------------------------------------------+
+// USB AUDIO CLASS 1.0 (UAC1) DEFINITIONS
+//--------------------------------------------------------------------+
+
+/// A.5 - Audio Class-Specific AC Interface Descriptor Subtypes UAC1
+typedef enum {
+ AUDIO10_CS_AC_INTERFACE_AC_DESCRIPTOR_UNDEF = 0x00,
+ AUDIO10_CS_AC_INTERFACE_HEADER = 0x01,
+ AUDIO10_CS_AC_INTERFACE_INPUT_TERMINAL = 0x02,
+ AUDIO10_CS_AC_INTERFACE_OUTPUT_TERMINAL = 0x03,
+ AUDIO10_CS_AC_INTERFACE_MIXER_UNIT = 0x04,
+ AUDIO10_CS_AC_INTERFACE_SELECTOR_UNIT = 0x05,
+ AUDIO10_CS_AC_INTERFACE_FEATURE_UNIT = 0x06,
+ AUDIO10_CS_AC_INTERFACE_PROCESSING_UNIT = 0x07,
+ AUDIO10_CS_AC_INTERFACE_EXTENSION_UNIT = 0x08,
+} audio10_cs_ac_interface_subtype_t;
+
+/// A.6 - Audio Class-Specific AS Interface Descriptor Subtypes UAC1
+typedef enum {
+ AUDIO10_CS_AS_INTERFACE_AS_DESCRIPTOR_UNDEF = 0x00,
+ AUDIO10_CS_AS_INTERFACE_AS_GENERAL = 0x01,
+ AUDIO10_CS_AS_INTERFACE_FORMAT_TYPE = 0x02,
+} audio10_cs_as_interface_subtype_t;
+
+/// A.8 - Audio Class-Specific EP Descriptor Subtypes UAC1
+typedef enum {
+ AUDIO10_CS_EP_SUBTYPE_UNDEF = 0x00,
+ AUDIO10_CS_EP_SUBTYPE_GENERAL = 0x01,
+} audio10_cs_ep_subtype_t;
+
+/// A.9 - Audio Class-Specific Request Codes UAC1
+typedef enum {
+ AUDIO10_CS_REQ_UNDEF = 0x00,
+ AUDIO10_CS_REQ_SET_CUR = 0x01,
+ AUDIO10_CS_REQ_GET_CUR = 0x81,
+ AUDIO10_CS_REQ_SET_MIN = 0x02,
+ AUDIO10_CS_REQ_GET_MIN = 0x82,
+ AUDIO10_CS_REQ_SET_MAX = 0x03,
+ AUDIO10_CS_REQ_GET_MAX = 0x83,
+ AUDIO10_CS_REQ_SET_RES = 0x04,
+ AUDIO10_CS_REQ_GET_RES = 0x84,
+ AUDIO10_CS_REQ_SET_MEM = 0x05,
+ AUDIO10_CS_REQ_GET_MEM = 0x85,
+ AUDIO10_CS_REQ_GET_STAT = 0xFF,
+} audio10_cs_req_t;
+
+/// A.10.1 - Terminal Control Selectors UAC1
+typedef enum {
+ AUDIO10_TE_CTRL_UNDEF = 0x00,
+ AUDIO10_TE_CTRL_COPY_PROTECT = 0x01,
+} audio10_terminal_control_selector_t;
+
+/// A.10.2 - Feature Unit Control Selectors UAC1
+typedef enum {
+ AUDIO10_FU_CTRL_UNDEF = 0x00,
+ AUDIO10_FU_CTRL_MUTE = 0x01,
+ AUDIO10_FU_CTRL_VOLUME = 0x02,
+ AUDIO10_FU_CTRL_BASS = 0x03,
+ AUDIO10_FU_CTRL_MID = 0x04,
+ AUDIO10_FU_CTRL_TREBLE = 0x05,
+ AUDIO10_FU_CTRL_GRAPHIC_EQUALIZER = 0x06,
+ AUDIO10_FU_CTRL_AGC = 0x07,
+ AUDIO10_FU_CTRL_DELAY = 0x08,
+ AUDIO10_FU_CTRL_BASS_BOOST = 0x09,
+ AUDIO10_FU_CTRL_LOUDNESS = 0x0A,
+} audio10_feature_unit_control_selector_t;
+
+/// A.10.3.1 - Up/Down-mix Processing Unit Control Selectors UAC1
+typedef enum {
+ AUDIO10_UD_CTRL_UNDEF = 0x00,
+ AUDIO10_UD_CTRL_ENABLE = 0x01,
+ AUDIO10_UD_CTRL_MODE_SELECT = 0x02,
+} audio10_up_down_mix_control_selector_t;
+
+/// A.10.3.2 - Dolby Prologic Processing Unit Control Selectors UAC1
+typedef enum {
+ AUDIO10_DP_CTRL_UNDEF = 0x00,
+ AUDIO10_DP_CTRL_ENABLE = 0x01,
+ AUDIO10_DP_CTRL_MODE_SELECT = 0x02,
+} audio10_dolby_prologic_control_selector_t;
+
+/// A.10.3.3 - 3D Stereo Extender Processing Unit Control Selectors UAC1
+typedef enum {
+ AUDIO10_3D_CTRL_UNDEF = 0x00,
+ AUDIO10_3D_CTRL_ENABLE = 0x01,
+ AUDIO10_3D_CTRL_SPACIOUSNESS = 0x02,
+} audio10_3d_stereo_extender_control_selector_t;
+
+/// A.10.3.4 - Reverberation Processing Unit Control Selectors UAC1
+typedef enum {
+ AUDIO10_RV_CTRL_UNDEF = 0x00,
+ AUDIO10_RV_CTRL_ENABLE = 0x01,
+ AUDIO10_RV_CTRL_REVERB_LEVEL = 0x02,
+ AUDIO10_RV_CTRL_REVERB_TIME = 0x03,
+ AUDIO10_RV_CTRL_REVERB_FEEDBACK = 0x04,
+} audio10_reverberation_control_selector_t;
+
+/// A.10.3.5 - Chorus Processing Unit Control Selectors UAC1
+typedef enum {
+ AUDIO10_CH_CTRL_UNDEF = 0x00,
+ AUDIO10_CH_CTRL_ENABLE = 0x01,
+ AUDIO10_CH_CTRL_CHORUS_LEVEL = 0x02,
+ AUDIO10_CH_CTRL_CHORUS_RATE = 0x03,
+ AUDIO10_CH_CTRL_CHORUS_DEPTH = 0x04,
+} audio10_chorus_control_selector_t;
+
+/// A.10.3.6 - Dynamic Range Compressor Processing Unit Control Selectors UAC1
+typedef enum {
+ AUDIO10_DR_CTRL_UNDEF = 0x00,
+ AUDIO10_DR_CTRL_ENABLE = 0x01,
+ AUDIO10_DR_CTRL_COMPRESSION_RATE = 0x02,
+ AUDIO10_DR_CTRL_MAXAMPL = 0x03,
+ AUDIO10_DR_CTRL_THRESHOLD = 0x04,
+ AUDIO10_DR_CTRL_ATTACK_TIME = 0x05,
+ AUDIO10_DR_CTRL_RELEASE_TIME = 0x06,
+} audio10_dynamic_range_compression_control_selector_t;
+
+/// A.10.4 - Extension Unit Control Selectors UAC1
+typedef enum {
+ AUDIO10_XU_CTRL_UNDEF = 0x00,
+ AUDIO10_XU_CTRL_ENABLE = 0x01,
+} audio10_extension_unit_control_selector_t;
+
+/// A.10.5 - Endpoint Control Selectors UAC1
+typedef enum {
+ AUDIO10_EP_CTRL_UNDEF = 0x00,
+ AUDIO10_EP_CTRL_SAMPLING_FREQ = 0x01,
+ AUDIO10_EP_CTRL_PITCH = 0x02,
+} audio10_ep_control_selector_t;
+
+/// Audio Class-Specific AS Isochronous Data EP Attributes UAC1
+typedef enum {
+ AUDIO10_CS_AS_ISO_DATA_EP_ATT_MAX_PACKETS_ONLY = 0x80,
+ AUDIO10_CS_AS_ISO_DATA_EP_ATT_NON_MAX_PACKETS_OK = 0x00,
+ AUDIO10_CS_AS_ISO_DATA_EP_ATT_SAMPLING_FRQ = 0x01,
+ AUDIO10_CS_AS_ISO_DATA_EP_ATT_PITCH = 0x02,
+} audio10_cs_as_iso_data_ep_attribute_t;
+
+/// Audio Class-Specific AS Isochronous Data EP Lock Delay Units UAC1
+typedef enum {
+ AUDIO10_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_UNDEFINED = 0x00,
+ AUDIO10_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_MILLISEC = 0x01,
+ AUDIO10_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_PCM_SAMPLES = 0x02,
+} audio10_cs_as_iso_data_ep_lock_delay_unit_t;
+
+/// Audio Class-Feature Unit Controls UAC1
+typedef enum {
+ AUDIO10_FU_CONTROL_BM_MUTE = 1 << 0,
+ AUDIO10_FU_CONTROL_BM_VOLUME = 1 << 1,
+ AUDIO10_FU_CONTROL_BM_BASS = 1 << 2,
+ AUDIO10_FU_CONTROL_BM_MID = 1 << 3,
+ AUDIO10_FU_CONTROL_BM_TREBLE = 1 << 4,
+ AUDIO10_FU_CONTROL_BM_GRAPHIC_EQUALIZER = 1 << 5,
+ AUDIO10_FU_CONTROL_BM_AGC = 1 << 6,
+ AUDIO10_FU_CONTROL_BM_DELAY = 1 << 7,
+ AUDIO10_FU_CONTROL_BM_BASS_BOOST = 1 << 8,
+ AUDIO10_FU_CONTROL_BM_LOUDNESS = 1 << 9,
+} audio10_feature_unit_control_bitmap_t;
+
+/// A.1 - Audio Class-Format Type Codes UAC1
+typedef enum {
+ AUDIO10_FORMAT_TYPE_UNDEFINED = 0x00,
+ AUDIO10_FORMAT_TYPE_I = 0x01,
+ AUDIO10_FORMAT_TYPE_II = 0x02,
+ AUDIO10_FORMAT_TYPE_III = 0x03,
+} audio10_format_type_t;
+
+// A.1.1 - Audio Class-Audio Data Format Type I UAC1
+typedef enum {
+ AUDIO10_DATA_FORMAT_TYPE_I_PCM = 0x0001,
+ AUDIO10_DATA_FORMAT_TYPE_I_PCM8 = 0x0002,
+ AUDIO10_DATA_FORMAT_TYPE_I_IEEE_FLOAT = 0x0003,
+ AUDIO10_DATA_FORMAT_TYPE_I_ALAW = 0x0004,
+ AUDIO10_DATA_FORMAT_TYPE_I_MULAW = 0x0005,
+} audio10_data_format_type_I_t;
+
+// A.1.2 - Audio Class-Audio Data Format Type II UAC1
+typedef enum {
+ AUDIO10_DATA_FORMAT_TYPE_II_MPEG = 0x1001,
+ AUDIO10_DATA_FORMAT_TYPE_II_AC3 = 0x1002,
+} audio10_data_format_type_II_t;
+
+// A.1.3 - Audio Class-Audio Data Format Type III UAC1
+typedef enum {
+ AUDIO10_DATA_FORMAT_TYPE_III_IEC1937_AC3_1 = 0x2001,
+ AUDIO10_DATA_FORMAT_TYPE_III_IEC1937_MPEG1_L1_1 = 0x2002,
+ AUDIO10_DATA_FORMAT_TYPE_III_IEC1937_MPEG1_L23_1 = 0x2003,
+ AUDIO10_DATA_FORMAT_TYPE_III_IEC1937_MPEG2_EXT_1 = 0x2004,
+ AUDIO10_DATA_FORMAT_TYPE_III_IEC1937_MPEG2_L1_LS_1 = 0x2005,
+ AUDIO10_DATA_FORMAT_TYPE_III_IEC1937_MPEG2_L23_LS_1 = 0x2006,
+} audio10_data_format_type_III_t;
+
+/// Audio Class-Audio Channel Configuration UAC1 (Table A-7)
+typedef enum {
+ AUDIO10_CHANNEL_CONFIG_NON_PREDEFINED = 0x0000,
+ AUDIO10_CHANNEL_CONFIG_LEFT_FRONT = 0x0001,
+ AUDIO10_CHANNEL_CONFIG_RIGHT_FRONT = 0x0002,
+ AUDIO10_CHANNEL_CONFIG_CENTER_FRONT = 0x0004,
+ AUDIO10_CHANNEL_CONFIG_LOW_FRQ_EFFECTS = 0x0008,
+ AUDIO10_CHANNEL_CONFIG_LEFT_SURROUND = 0x0010,
+ AUDIO10_CHANNEL_CONFIG_RIGHT_SURROUND = 0x0020,
+ AUDIO10_CHANNEL_CONFIG_LEFT_OF_CENTER = 0x0040,
+ AUDIO10_CHANNEL_CONFIG_RIGHT_OF_CENTER = 0x0080,
+ AUDIO10_CHANNEL_CONFIG_SURROUND = 0x0100,
+ AUDIO10_CHANNEL_CONFIG_SIDE_LEFT = 0x0200,
+ AUDIO10_CHANNEL_CONFIG_SIDE_RIGHT = 0x0400,
+ AUDIO10_CHANNEL_CONFIG_TOP = 0x0800,
+} audio10_channel_config_t;
+
+
+//--------------------------------------------------------------------+
+// USB AUDIO CLASS 1.0 (UAC1) DESCRIPTORS
+//--------------------------------------------------------------------+
+
+/// AUDIO Class-Specific AC Interface Header Descriptor UAC1 (4.3.2)
+#define audio10_desc_cs_ac_interface_n_t(numInterfaces) \
+ struct TU_ATTR_PACKED { \
+ uint8_t bLength; /* Size of this descriptor in bytes: 8+n. */ \
+ uint8_t bDescriptorType; /* Descriptor Type. Value: TUSB_DESC_CS_INTERFACE. */ \
+ uint8_t bDescriptorSubType; /* Descriptor SubType. Value: AUDIO10_CS_AC_INTERFACE_HEADER. */ \
+ uint16_t bcdADC; /* Audio Device Class Specification Release Number in Binary-Coded Decimal. Value: 0x0100 for UAC1. */ \
+ uint16_t wTotalLength; /* Total number of bytes returned for the class-specific AudioControl interface descriptor. */ \
+ uint8_t bInCollection; /* The number of AudioStreaming and MIDIStreaming interfaces in the Audio Interface Collection. */ \
+ uint8_t baInterfaceNr[numInterfaces]; /* Interface number of the AudioStreaming or MIDIStreaming interface in the Collection. */ \
+ }
+
+/// AUDIO Input Terminal Descriptor UAC1 (4.3.2.1)
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor in bytes: 12.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO10_CS_AC_INTERFACE_INPUT_TERMINAL.
+ uint8_t bTerminalID; ///< Constant uniquely identifying the Terminal within the audio function.
+ uint16_t wTerminalType; ///< Constant characterizing the type of Terminal.
+ uint8_t bAssocTerminal; ///< ID of the Output Terminal to which this Input Terminal is associated.
+ uint8_t bNrChannels; ///< Number of logical output channels in the Terminal's output audio channel cluster.
+ uint16_t wChannelConfig; ///< Describes the spatial location of the logical channels.
+ uint8_t iChannelNames; ///< Index of a string descriptor, describing the name of the first logical channel.
+ uint8_t iTerminal; ///< Index of a string descriptor, describing the Input Terminal.
+} audio10_desc_input_terminal_t;
+
+/// AUDIO Output Terminal Descriptor UAC1 (4.3.2.2)
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor in bytes: 9.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO10_CS_AC_INTERFACE_OUTPUT_TERMINAL.
+ uint8_t bTerminalID; ///< Constant uniquely identifying the Terminal within the audio function.
+ uint16_t wTerminalType; ///< Constant characterizing the type of Terminal.
+ uint8_t bAssocTerminal; ///< Constant, identifying the Input Terminal to which this Output Terminal is associated.
+ uint8_t bSourceID; ///< ID of the Unit or Terminal to which this Terminal is connected.
+ uint8_t iTerminal; ///< Index of a string descriptor, describing the Output Terminal.
+} audio10_desc_output_terminal_t;
+
+/// AUDIO Mixer Unit Descriptor UAC1 (4.3.2.3)
+#define audio10_desc_mixer_unit_n_t(numInputPins, numControlBytes) \
+ struct TU_ATTR_PACKED { \
+ uint8_t bLength; /* Size of this descriptor in bytes: 10+p+n. */ \
+ uint8_t bDescriptorType; /* Descriptor Type. Value: TUSB_DESC_CS_INTERFACE. */ \
+ uint8_t bDescriptorSubType; /* Descriptor SubType. Value: AUDIO10_CS_AC_INTERFACE_MIXER_UNIT. */ \
+ uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */ \
+ uint8_t bNrInPins; /* Number of Input Pins of this Unit: p. */ \
+ uint8_t baSourceID[numInputPins]; /* ID of the Unit or Terminal to which Input Pins of this Mixer Unit are connected. */ \
+ uint8_t bNrChannels; /* Number of logical output channels in the Mixer Unit's output audio channel cluster. */ \
+ uint16_t wChannelConfig; /* Describes the spatial location of the logical channels. */ \
+ uint8_t iChannelNames; /* Index of a string descriptor, describing the name of the first logical channel. */ \
+ uint8_t bmControls[numControlBytes]; /* Mixer Unit Controls bitmap. */ \
+ uint8_t iMixer; /* Index of a string descriptor, describing the Mixer Unit. */ \
+ }
+
+/// AUDIO Selector Unit Descriptor UAC1 (4.3.2.4)
+#define audio10_desc_selector_unit_n_t(numInputPins) \
+ struct TU_ATTR_PACKED { \
+ uint8_t bLength; /* Size of this descriptor in bytes: 6+p. */ \
+ uint8_t bDescriptorType; /* Descriptor Type. Value: TUSB_DESC_CS_INTERFACE. */ \
+ uint8_t bDescriptorSubType; /* Descriptor SubType. Value: AUDIO10_CS_AC_INTERFACE_SELECTOR_UNIT. */ \
+ uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */ \
+ uint8_t bNrInPins; /* Number of Input Pins of this Unit: p. */ \
+ uint8_t baSourceID[numInputPins]; /* ID of the Unit or Terminal to which Input Pins of this Selector Unit are connected. */ \
+ uint8_t iSelector; /* Index of a string descriptor, describing the Selector Unit. */ \
+ }
+
+/// AUDIO Feature Unit Descriptor UAC1 (4.3.2.5)
+#define audio10_desc_feature_unit_n_t(numChannels, controlSize) \
+ struct TU_ATTR_PACKED { \
+ uint8_t bLength; /* Size of this descriptor in bytes: 7+(ch+1)*n. */ \
+ uint8_t bDescriptorType; /* Descriptor Type. Value: TUSB_DESC_CS_INTERFACE. */ \
+ uint8_t bDescriptorSubType; /* Descriptor SubType. Value: AUDIO10_CS_AC_INTERFACE_FEATURE_UNIT. */ \
+ uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */ \
+ uint8_t bSourceID; /* ID of the Unit or Terminal to which this Feature Unit is connected. */ \
+ uint8_t bControlSize; /* Size in bytes of an element of the bmaControls() array. */ \
+ uint8_t bmaControls[(numChannels + 1) * controlSize]; /* Control bitmaps for master + logical channels. */ \
+ uint8_t iFeature; /* Index of a string descriptor, describing this Feature Unit. */ \
+ }
+
+/// AUDIO Processing Unit Descriptor UAC1 (4.3.2.6)
+#define audio10_desc_processing_unit_n_t(numInputPins, numControlBytes) \
+ struct TU_ATTR_PACKED { \
+ uint8_t bLength; /* Size of this descriptor in bytes: 13+p+n. */ \
+ uint8_t bDescriptorType; /* Descriptor Type. Value: TUSB_DESC_CS_INTERFACE. */ \
+ uint8_t bDescriptorSubType; /* Descriptor SubType. Value: AUDIO10_CS_AC_INTERFACE_PROCESSING_UNIT. */ \
+ uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */ \
+ uint16_t wProcessType; /* Constant identifying the type of processing this Unit is performing. */ \
+ uint8_t bNrInPins; /* Number of Input Pins of this Unit: p. */ \
+ uint8_t baSourceID[numInputPins]; /* ID of the Unit or Terminal to which Input Pins of this Processing Unit are connected. */ \
+ uint8_t bNrChannels; /* Number of logical output channels in the Processing Unit's output audio channel cluster. */ \
+ uint16_t wChannelConfig; /* Describes the spatial location of the logical channels. */ \
+ uint8_t iChannelNames; /* Index of a string descriptor, describing the name of the first logical channel. */ \
+ uint8_t bControlSize; /* Size in bytes of the bmControls field. */ \
+ uint8_t bmControls[numControlBytes]; /* Processing Unit Controls bitmap. */ \
+ uint8_t iProcessing; /* Index of a string descriptor, describing the Processing Unit. */ \
+ }
+
+/// AUDIO Extension Unit Descriptor UAC1 (4.3.2.7)
+#define audio10_desc_extension_unit_n_t(numInputPins, numControlBytes) \
+ struct TU_ATTR_PACKED { \
+ uint8_t bLength; /* Size of this descriptor in bytes: 13+p+n. */ \
+ uint8_t bDescriptorType; /* Descriptor Type. Value: TUSB_DESC_CS_INTERFACE. */ \
+ uint8_t bDescriptorSubType; /* Descriptor SubType. Value: AUDIO10_CS_AC_INTERFACE_EXTENSION_UNIT. */ \
+ uint8_t bUnitID; /* Constant uniquely identifying the Unit within the audio function. */ \
+ uint16_t wExtensionCode; /* Vendor-specific code identifying the Extension Unit. */ \
+ uint8_t bNrInPins; /* Number of Input Pins of this Unit: p. */ \
+ uint8_t baSourceID[numInputPins]; /* ID of the Unit or Terminal to which Input Pins of this Extension Unit are connected. */ \
+ uint8_t bNrChannels; /* Number of logical output channels in the Extension Unit's output audio channel cluster. */ \
+ uint16_t wChannelConfig; /* Describes the spatial location of the logical channels. */ \
+ uint8_t iChannelNames; /* Index of a string descriptor, describing the name of the first logical channel. */ \
+ uint8_t bControlSize; /* Size in bytes of the bmControls field. */ \
+ uint8_t bmControls[numControlBytes]; /* Extension Unit Controls bitmap. */ \
+ uint8_t iExtension; /* Index of a string descriptor, describing the Extension Unit. */ \
+ }
+
+/// AUDIO Class-Specific AS Interface Descriptor UAC1 (4.5.2)
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor in bytes: 7.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO10_CS_AS_INTERFACE_AS_GENERAL.
+ uint8_t bTerminalLink; ///< The Terminal ID of the Terminal to which the endpoint of this interface is connected.
+ uint8_t bDelay; ///< Expressed in number of frames.
+ uint16_t wFormatTag; ///< The Audio Data Format that has to be used to communicate with this interface.
+} audio10_desc_cs_as_interface_t;
+
+/// AUDIO Type I Format Type Descriptor UAC1 (2.2.5)
+#define audio10_desc_type_I_format_n_t(numSamFreq) \
+ struct TU_ATTR_PACKED { \
+ uint8_t bLength; /* Size of this descriptor in bytes: 8+(ns*3). */ \
+ uint8_t bDescriptorType; /* Descriptor Type. Value: TUSB_DESC_CS_INTERFACE. */ \
+ uint8_t bDescriptorSubType; /* Descriptor SubType. Value: AUDIO10_CS_AS_INTERFACE_FORMAT_TYPE. */ \
+ uint8_t bFormatType; /* Constant identifying the Format Type the AudioStreaming interface is using. */ \
+ uint8_t bNrChannels; /* Indicates the number of physical channels in the audio data stream. */ \
+ uint8_t bSubFrameSize; /* The number of bytes occupied by one audio subframe. */ \
+ uint8_t bBitResolution; /* The number of effectively used bits from the available bits in an audio subframe. */ \
+ uint8_t bSamFreqType; /* Indicates how the sampling frequency can be programmed. */ \
+ uint8_t tSamFreq[numSamFreq * 3]; /* Sampling frequency or lower/upper bounds in Hz for the sampling frequency range. */ \
+ }
+
+/// AUDIO Type II Format Type Descriptor UAC1 (2.3.5)
+#define audio10_desc_type_II_format_n_t(numSamFreq) \
+ struct TU_ATTR_PACKED { \
+ uint8_t bLength; /* Size of this descriptor in bytes: 9+(ns*3). */ \
+ uint8_t bDescriptorType; /* Descriptor Type. Value: TUSB_DESC_CS_INTERFACE. */ \
+ uint8_t bDescriptorSubType; /* Descriptor SubType. Value: AUDIO10_CS_AS_INTERFACE_FORMAT_TYPE. */ \
+ uint8_t bFormatType; /* Constant identifying the Format Type the AudioStreaming interface is using. */ \
+ uint16_t wMaxBitRate; /* Indicates the maximum number of bits per second this interface can handle. */ \
+ uint16_t wSamplesPerFrame; /* Indicates the number of PCM audio samples contained in one encoded audio frame. */ \
+ uint8_t bSamFreqType; /* Indicates how the sampling frequency can be programmed. */ \
+ uint8_t tSamFreq[numSamFreq * 3]; /* Sampling frequency or lower/upper bounds in Hz for the sampling frequency range. */ \
+ }
+
+/// AUDIO Type III Format Type Descriptor UAC1 (2.4.5)
+#define audio10_desc_type_III_format_n_t(numSamFreq) \
+ struct TU_ATTR_PACKED { \
+ uint8_t bLength; /* Size of this descriptor in bytes: 8+(ns*3). */ \
+ uint8_t bDescriptorType; /* Descriptor Type. Value: TUSB_DESC_CS_INTERFACE. */ \
+ uint8_t bDescriptorSubType; /* Descriptor SubType. Value: AUDIO10_CS_AS_INTERFACE_FORMAT_TYPE. */ \
+ uint8_t bFormatType; /* Constant identifying the Format Type the AudioStreaming interface is using. */ \
+ uint8_t bNrChannels; /* Indicates the number of physical channels in the audio data stream. */ \
+ uint8_t bSubFrameSize; /* The number of bytes occupied by one audio subframe. */ \
+ uint8_t bBitResolution; /* The number of effectively used bits from the available bits in an audio subframe. */ \
+ uint8_t bSamFreqType; /* Indicates how the sampling frequency can be programmed. */ \
+ uint8_t tSamFreq[numSamFreq * 3]; /* Sampling frequency or lower/upper bounds in Hz for the sampling frequency range. */ \
+ }
+
+/// Standard AS Isochronous Audio Data Endpoint Descriptor UAC1 (4.6.1.1)
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor in bytes: 9.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_ENDPOINT.
+ uint8_t bEndpointAddress;///< The address of the endpoint on the USB device described by this descriptor.
+ struct TU_ATTR_PACKED {
+ uint8_t xfer : 2; // Control, ISO, Bulk, Interrupt
+ uint8_t sync : 2; // None, Asynchronous, Adaptive, Synchronous
+ uint8_t usage : 2; // Data, Feedback, Implicit feedback
+ uint8_t : 2;
+ } bmAttributes;
+ uint16_t wMaxPacketSize; ///< Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected.
+ uint8_t bInterval; ///< Interval for polling endpoint for data transfers.
+ uint8_t bRefresh; ///< The rate at which the endpoint is refreshed.
+ uint8_t bSynchAddress; ///< The address of the endpoint used to send synchronization information for the data endpoint.
+} audio10_desc_as_iso_data_ep_t;
+
+/// AUDIO Class-Specific AS Isochronous Audio Data Endpoint Descriptor UAC1 (4.6.1.2)
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor in bytes: 7.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_ENDPOINT.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO10_CS_EP_SUBTYPE_GENERAL.
+ uint8_t bmAttributes; ///< Bit 0: Sampling Frequency, Bit 1: Pitch, Bit 7: MaxPacketsOnly.
+ uint8_t bLockDelayUnits; ///< Indicates the units used for the wLockDelay field.
+ uint16_t wLockDelay; ///< Indicates the time it takes this endpoint to reliably lock its internal clock recovery circuitry.
+} audio10_desc_cs_as_iso_data_ep_t;
+
+/// AUDIO Interrupt Data Message Format UAC1 (3.7.1.2)
+typedef struct TU_ATTR_PACKED {
+ uint8_t bStatusType;///< Indicates the type of status information being reported.
+ uint8_t bOriginator;///< Indicates the entity that originated this status information.
+} audio10_interrupt_data_t;
+
+//--------------------------------------------------------------------+
+// USB AUDIO CLASS 2.0 (UAC2) DEFINITIONS
+//--------------------------------------------------------------------+
+
/// A.7 - Audio Function Category Codes
-typedef enum
-{
- AUDIO_FUNC_UNDEF = 0x00,
- AUDIO_FUNC_DESKTOP_SPEAKER = 0x01,
- AUDIO_FUNC_HOME_THEATER = 0x02,
- AUDIO_FUNC_MICROPHONE = 0x03,
- AUDIO_FUNC_HEADSET = 0x04,
- AUDIO_FUNC_TELEPHONE = 0x05,
- AUDIO_FUNC_CONVERTER = 0x06,
- AUDIO_FUNC_SOUND_RECODER = 0x07,
- AUDIO_FUNC_IO_BOX = 0x08,
- AUDIO_FUNC_MUSICAL_INSTRUMENT = 0x09,
- AUDIO_FUNC_PRO_AUDIO = 0x0A,
- AUDIO_FUNC_AUDIO_VIDEO = 0x0B,
- AUDIO_FUNC_CONTROL_PANEL = 0x0C,
- AUDIO_FUNC_OTHER = 0xFF,
-} audio_function_code_t;
+typedef enum {
+ AUDIO20_FUNC_UNDEF = 0x00,
+ AUDIO20_FUNC_DESKTOP_SPEAKER = 0x01,
+ AUDIO20_FUNC_HOME_THEATER = 0x02,
+ AUDIO20_FUNC_MICROPHONE = 0x03,
+ AUDIO20_FUNC_HEADSET = 0x04,
+ AUDIO20_FUNC_TELEPHONE = 0x05,
+ AUDIO20_FUNC_CONVERTER = 0x06,
+ AUDIO20_FUNC_SOUND_RECODER = 0x07,
+ AUDIO20_FUNC_IO_BOX = 0x08,
+ AUDIO20_FUNC_MUSICAL_INSTRUMENT = 0x09,
+ AUDIO20_FUNC_PRO_AUDIO = 0x0A,
+ AUDIO20_FUNC_AUDIO_VIDEO = 0x0B,
+ AUDIO20_FUNC_CONTROL_PANEL = 0x0C,
+ AUDIO20_FUNC_OTHER = 0xFF,
+} audio20_function_code_t;
/// A.9 - Audio Class-Specific AC Interface Descriptor Subtypes UAC2
-typedef enum
-{
- AUDIO_CS_AC_INTERFACE_AC_DESCRIPTOR_UNDEF = 0x00,
- AUDIO_CS_AC_INTERFACE_HEADER = 0x01,
- AUDIO_CS_AC_INTERFACE_INPUT_TERMINAL = 0x02,
- AUDIO_CS_AC_INTERFACE_OUTPUT_TERMINAL = 0x03,
- AUDIO_CS_AC_INTERFACE_MIXER_UNIT = 0x04,
- AUDIO_CS_AC_INTERFACE_SELECTOR_UNIT = 0x05,
- AUDIO_CS_AC_INTERFACE_FEATURE_UNIT = 0x06,
- AUDIO_CS_AC_INTERFACE_EFFECT_UNIT = 0x07,
- AUDIO_CS_AC_INTERFACE_PROCESSING_UNIT = 0x08,
- AUDIO_CS_AC_INTERFACE_EXTENSION_UNIT = 0x09,
- AUDIO_CS_AC_INTERFACE_CLOCK_SOURCE = 0x0A,
- AUDIO_CS_AC_INTERFACE_CLOCK_SELECTOR = 0x0B,
- AUDIO_CS_AC_INTERFACE_CLOCK_MULTIPLIER = 0x0C,
- AUDIO_CS_AC_INTERFACE_SAMPLE_RATE_CONVERTER = 0x0D,
-} audio_cs_ac_interface_subtype_t;
+typedef enum {
+ AUDIO20_CS_AC_INTERFACE_AC_DESCRIPTOR_UNDEF = 0x00,
+ AUDIO20_CS_AC_INTERFACE_HEADER = 0x01,
+ AUDIO20_CS_AC_INTERFACE_INPUT_TERMINAL = 0x02,
+ AUDIO20_CS_AC_INTERFACE_OUTPUT_TERMINAL = 0x03,
+ AUDIO20_CS_AC_INTERFACE_MIXER_UNIT = 0x04,
+ AUDIO20_CS_AC_INTERFACE_SELECTOR_UNIT = 0x05,
+ AUDIO20_CS_AC_INTERFACE_FEATURE_UNIT = 0x06,
+ AUDIO20_CS_AC_INTERFACE_EFFECT_UNIT = 0x07,
+ AUDIO20_CS_AC_INTERFACE_PROCESSING_UNIT = 0x08,
+ AUDIO20_CS_AC_INTERFACE_EXTENSION_UNIT = 0x09,
+ AUDIO20_CS_AC_INTERFACE_CLOCK_SOURCE = 0x0A,
+ AUDIO20_CS_AC_INTERFACE_CLOCK_SELECTOR = 0x0B,
+ AUDIO20_CS_AC_INTERFACE_CLOCK_MULTIPLIER = 0x0C,
+ AUDIO20_CS_AC_INTERFACE_SAMPLE_RATE_CONVERTER = 0x0D,
+} audio20_cs_ac_interface_subtype_t;
/// A.10 - Audio Class-Specific AS Interface Descriptor Subtypes UAC2
-typedef enum
-{
- AUDIO_CS_AS_INTERFACE_AS_DESCRIPTOR_UNDEF = 0x00,
- AUDIO_CS_AS_INTERFACE_AS_GENERAL = 0x01,
- AUDIO_CS_AS_INTERFACE_FORMAT_TYPE = 0x02,
- AUDIO_CS_AS_INTERFACE_ENCODER = 0x03,
- AUDIO_CS_AS_INTERFACE_DECODER = 0x04,
-} audio_cs_as_interface_subtype_t;
+typedef enum {
+ AUDIO20_CS_AS_INTERFACE_AS_DESCRIPTOR_UNDEF = 0x00,
+ AUDIO20_CS_AS_INTERFACE_AS_GENERAL = 0x01,
+ AUDIO20_CS_AS_INTERFACE_FORMAT_TYPE = 0x02,
+ AUDIO20_CS_AS_INTERFACE_ENCODER = 0x03,
+ AUDIO20_CS_AS_INTERFACE_DECODER = 0x04,
+} audio20_cs_as_interface_subtype_t;
/// A.11 - Effect Unit Effect Types
-typedef enum
-{
- AUDIO_EFFECT_TYPE_UNDEF = 0x00,
- AUDIO_EFFECT_TYPE_PARAM_EQ_SECTION = 0x01,
- AUDIO_EFFECT_TYPE_REVERBERATION = 0x02,
- AUDIO_EFFECT_TYPE_MOD_DELAY = 0x03,
- AUDIO_EFFECT_TYPE_DYN_RANGE_COMP = 0x04,
-} audio_effect_unit_effect_type_t;
+typedef enum {
+ AUDIO20_EFFECT_TYPE_UNDEF = 0x00,
+ AUDIO20_EFFECT_TYPE_PARAM_EQ_SECTION = 0x01,
+ AUDIO20_EFFECT_TYPE_REVERBERATION = 0x02,
+ AUDIO20_EFFECT_TYPE_MOD_DELAY = 0x03,
+ AUDIO20_EFFECT_TYPE_DYN_RANGE_COMP = 0x04,
+} audio20_effect_unit_effect_type_t;
/// A.12 - Processing Unit Process Types
-typedef enum
-{
- AUDIO_PROCESS_TYPE_UNDEF = 0x00,
- AUDIO_PROCESS_TYPE_UP_DOWN_MIX = 0x01,
- AUDIO_PROCESS_TYPE_DOLBY_PROLOGIC = 0x02,
- AUDIO_PROCESS_TYPE_STEREO_EXTENDER = 0x03,
-} audio_processing_unit_process_type_t;
+typedef enum {
+ AUDIO20_PROCESS_TYPE_UNDEF = 0x00,
+ AUDIO20_PROCESS_TYPE_UP_DOWN_MIX = 0x01,
+ AUDIO20_PROCESS_TYPE_DOLBY_PROLOGIC = 0x02,
+ AUDIO20_PROCESS_TYPE_STEREO_EXTENDER = 0x03,
+} audio20_processing_unit_process_type_t;
/// A.13 - Audio Class-Specific EP Descriptor Subtypes UAC2
-typedef enum
-{
- AUDIO_CS_EP_SUBTYPE_UNDEF = 0x00,
- AUDIO_CS_EP_SUBTYPE_GENERAL = 0x01,
-} audio_cs_ep_subtype_t;
+typedef enum {
+ AUDIO20_CS_EP_SUBTYPE_UNDEF = 0x00,
+ AUDIO20_CS_EP_SUBTYPE_GENERAL = 0x01,
+} audio20_cs_ep_subtype_t;
-/// A.14 - Audio Class-Specific Request Codes
-typedef enum
-{
- AUDIO_CS_REQ_UNDEF = 0x00,
- AUDIO_CS_REQ_CUR = 0x01,
- AUDIO_CS_REQ_RANGE = 0x02,
- AUDIO_CS_REQ_MEM = 0x03,
-} audio_cs_req_t;
+/// A.14 - Audio Class-Specific Request Codes UAC2
+typedef enum {
+ AUDIO20_CS_REQ_UNDEF = 0x00,
+ AUDIO20_CS_REQ_CUR = 0x01,
+ AUDIO20_CS_REQ_RANGE = 0x02,
+ AUDIO20_CS_REQ_MEM = 0x03,
+} audio20_cs_req_t;
-/// A.17 - Control Selector Codes
+/// A.17 - Control Selector Codes UAC2
/// A.17.1 - Clock Source Control Selectors
-typedef enum
-{
- AUDIO_CS_CTRL_UNDEF = 0x00,
- AUDIO_CS_CTRL_SAM_FREQ = 0x01,
- AUDIO_CS_CTRL_CLK_VALID = 0x02,
-} audio_clock_src_control_selector_t;
+typedef enum {
+ AUDIO20_CS_CTRL_UNDEF = 0x00,
+ AUDIO20_CS_CTRL_SAM_FREQ = 0x01,
+ AUDIO20_CS_CTRL_CLK_VALID = 0x02,
+} audio20_clock_src_control_selector_t;
/// A.17.2 - Clock Selector Control Selectors
-typedef enum
-{
- AUDIO_CX_CTRL_UNDEF = 0x00,
- AUDIO_CX_CTRL_CONTROL = 0x01,
-} audio_clock_sel_control_selector_t;
+typedef enum {
+ AUDIO20_CX_CTRL_UNDEF = 0x00,
+ AUDIO20_CX_CTRL_CONTROL = 0x01,
+} audio20_clock_sel_control_selector_t;
/// A.17.3 - Clock Multiplier Control Selectors
-typedef enum
-{
- AUDIO_CM_CTRL_UNDEF = 0x00,
- AUDIO_CM_CTRL_NUMERATOR_CONTROL = 0x01,
- AUDIO_CM_CTRL_DENOMINATOR_CONTROL = 0x02,
-} audio_clock_mul_control_selector_t;
+typedef enum {
+ AUDIO20_CM_CTRL_UNDEF = 0x00,
+ AUDIO20_CM_CTRL_NUMERATOR_CONTROL = 0x01,
+ AUDIO20_CM_CTRL_DENOMINATOR_CONTROL = 0x02,
+} audio20_clock_mul_control_selector_t;
-/// A.17.4 - Terminal Control Selectors
-typedef enum
-{
- AUDIO_TE_CTRL_UNDEF = 0x00,
- AUDIO_TE_CTRL_COPY_PROTECT = 0x01,
- AUDIO_TE_CTRL_CONNECTOR = 0x02,
- AUDIO_TE_CTRL_OVERLOAD = 0x03,
- AUDIO_TE_CTRL_CLUSTER = 0x04,
- AUDIO_TE_CTRL_UNDERFLOW = 0x05,
- AUDIO_TE_CTRL_OVERFLOW = 0x06,
- AUDIO_TE_CTRL_LATENCY = 0x07,
-} audio_terminal_control_selector_t;
+/// A.17.4 - Terminal Control Selectors UAC2
+typedef enum {
+ AUDIO20_TE_CTRL_UNDEF = 0x00,
+ AUDIO20_TE_CTRL_COPY_PROTECT = 0x01,
+ AUDIO20_TE_CTRL_CONNECTOR = 0x02,
+ AUDIO20_TE_CTRL_OVERLOAD = 0x03,
+ AUDIO20_TE_CTRL_CLUSTER = 0x04,
+ AUDIO20_TE_CTRL_UNDERFLOW = 0x05,
+ AUDIO20_TE_CTRL_OVERFLOW = 0x06,
+ AUDIO20_TE_CTRL_LATENCY = 0x07,
+} audio20_terminal_control_selector_t;
/// A.17.5 - Mixer Control Selectors
-typedef enum
-{
- AUDIO_MU_CTRL_UNDEF = 0x00,
- AUDIO_MU_CTRL_MIXER = 0x01,
- AUDIO_MU_CTRL_CLUSTER = 0x02,
- AUDIO_MU_CTRL_UNDERFLOW = 0x03,
- AUDIO_MU_CTRL_OVERFLOW = 0x04,
- AUDIO_MU_CTRL_LATENCY = 0x05,
-} audio_mixer_control_selector_t;
+typedef enum {
+ AUDIO20_MU_CTRL_UNDEF = 0x00,
+ AUDIO20_MU_CTRL_MIXER = 0x01,
+ AUDIO20_MU_CTRL_CLUSTER = 0x02,
+ AUDIO20_MU_CTRL_UNDERFLOW = 0x03,
+ AUDIO20_MU_CTRL_OVERFLOW = 0x04,
+ AUDIO20_MU_CTRL_LATENCY = 0x05,
+} audio20_mixer_control_selector_t;
/// A.17.6 - Selector Control Selectors
-typedef enum
-{
- AUDIO_SU_CTRL_UNDEF = 0x00,
- AUDIO_SU_CTRL_SELECTOR = 0x01,
- AUDIO_SU_CTRL_LATENCY = 0x02,
-} audio_sel_control_selector_t;
+typedef enum {
+ AUDIO20_SU_CTRL_UNDEF = 0x00,
+ AUDIO20_SU_CTRL_SELECTOR = 0x01,
+ AUDIO20_SU_CTRL_LATENCY = 0x02,
+} audio20_sel_control_selector_t;
-/// A.17.7 - Feature Unit Control Selectors
-typedef enum
-{
- AUDIO_FU_CTRL_UNDEF = 0x00,
- AUDIO_FU_CTRL_MUTE = 0x01,
- AUDIO_FU_CTRL_VOLUME = 0x02,
- AUDIO_FU_CTRL_BASS = 0x03,
- AUDIO_FU_CTRL_MID = 0x04,
- AUDIO_FU_CTRL_TREBLE = 0x05,
- AUDIO_FU_CTRL_GRAPHIC_EQUALIZER = 0x06,
- AUDIO_FU_CTRL_AGC = 0x07,
- AUDIO_FU_CTRL_DELAY = 0x08,
- AUDIO_FU_CTRL_BASS_BOOST = 0x09,
- AUDIO_FU_CTRL_LOUDNESS = 0x0A,
- AUDIO_FU_CTRL_INPUT_GAIN = 0x0B,
- AUDIO_FU_CTRL_GAIN_PAD = 0x0C,
- AUDIO_FU_CTRL_INVERTER = 0x0D,
- AUDIO_FU_CTRL_UNDERFLOW = 0x0E,
- AUDIO_FU_CTRL_OVERVLOW = 0x0F,
- AUDIO_FU_CTRL_LATENCY = 0x10,
-} audio_feature_unit_control_selector_t;
+/// A.17.7 - Feature Unit Control Selectors UAC2
+typedef enum {
+ AUDIO20_FU_CTRL_UNDEF = 0x00,
+ AUDIO20_FU_CTRL_MUTE = 0x01,
+ AUDIO20_FU_CTRL_VOLUME = 0x02,
+ AUDIO20_FU_CTRL_BASS = 0x03,
+ AUDIO20_FU_CTRL_MID = 0x04,
+ AUDIO20_FU_CTRL_TREBLE = 0x05,
+ AUDIO20_FU_CTRL_GRAPHIC_EQUALIZER = 0x06,
+ AUDIO20_FU_CTRL_AGC = 0x07,
+ AUDIO20_FU_CTRL_DELAY = 0x08,
+ AUDIO20_FU_CTRL_BASS_BOOST = 0x09,
+ AUDIO20_FU_CTRL_LOUDNESS = 0x0A,
+ AUDIO20_FU_CTRL_INPUT_GAIN = 0x0B,
+ AUDIO20_FU_CTRL_GAIN_PAD = 0x0C,
+ AUDIO20_FU_CTRL_INVERTER = 0x0D,
+ AUDIO20_FU_CTRL_UNDERFLOW = 0x0E,
+ AUDIO20_FU_CTRL_OVERVLOW = 0x0F,
+ AUDIO20_FU_CTRL_LATENCY = 0x10,
+} audio20_feature_unit_control_selector_t;
/// A.17.8 Effect Unit Control Selectors
/// A.17.8.1 Parametric Equalizer Section Effect Unit Control Selectors
-typedef enum
-{
- AUDIO_PE_CTRL_UNDEF = 0x00,
- AUDIO_PE_CTRL_ENABLE = 0x01,
- AUDIO_PE_CTRL_CENTERFREQ = 0x02,
- AUDIO_PE_CTRL_QFACTOR = 0x03,
- AUDIO_PE_CTRL_GAIN = 0x04,
- AUDIO_PE_CTRL_UNDERFLOW = 0x05,
- AUDIO_PE_CTRL_OVERFLOW = 0x06,
- AUDIO_PE_CTRL_LATENCY = 0x07,
-} audio_parametric_equalizer_control_selector_t;
+typedef enum {
+ AUDIO20_PE_CTRL_UNDEF = 0x00,
+ AUDIO20_PE_CTRL_ENABLE = 0x01,
+ AUDIO20_PE_CTRL_CENTERFREQ = 0x02,
+ AUDIO20_PE_CTRL_QFACTOR = 0x03,
+ AUDIO20_PE_CTRL_GAIN = 0x04,
+ AUDIO20_PE_CTRL_UNDERFLOW = 0x05,
+ AUDIO20_PE_CTRL_OVERFLOW = 0x06,
+ AUDIO20_PE_CTRL_LATENCY = 0x07,
+} audio20_parametric_equalizer_control_selector_t;
/// A.17.8.2 Reverberation Effect Unit Control Selectors
-typedef enum
-{
- AUDIO_RV_CTRL_UNDEF = 0x00,
- AUDIO_RV_CTRL_ENABLE = 0x01,
- AUDIO_RV_CTRL_TYPE = 0x02,
- AUDIO_RV_CTRL_LEVEL = 0x03,
- AUDIO_RV_CTRL_TIME = 0x04,
- AUDIO_RV_CTRL_FEEDBACK = 0x05,
- AUDIO_RV_CTRL_PREDELAY = 0x06,
- AUDIO_RV_CTRL_DENSITY = 0x07,
- AUDIO_RV_CTRL_HIFREQ_ROLLOFF = 0x08,
- AUDIO_RV_CTRL_UNDERFLOW = 0x09,
- AUDIO_RV_CTRL_OVERFLOW = 0x0A,
- AUDIO_RV_CTRL_LATENCY = 0x0B,
-} audio_reverberation_effect_control_selector_t;
+typedef enum {
+ AUDIO20_RV_CTRL_UNDEF = 0x00,
+ AUDIO20_RV_CTRL_ENABLE = 0x01,
+ AUDIO20_RV_CTRL_TYPE = 0x02,
+ AUDIO20_RV_CTRL_LEVEL = 0x03,
+ AUDIO20_RV_CTRL_TIME = 0x04,
+ AUDIO20_RV_CTRL_FEEDBACK = 0x05,
+ AUDIO20_RV_CTRL_PREDELAY = 0x06,
+ AUDIO20_RV_CTRL_DENSITY = 0x07,
+ AUDIO20_RV_CTRL_HIFREQ_ROLLOFF = 0x08,
+ AUDIO20_RV_CTRL_UNDERFLOW = 0x09,
+ AUDIO20_RV_CTRL_OVERFLOW = 0x0A,
+ AUDIO20_RV_CTRL_LATENCY = 0x0B,
+} audio20_reverberation_effect_control_selector_t;
/// A.17.8.3 Modulation Delay Effect Unit Control Selectors
-typedef enum
-{
- AUDIO_MD_CTRL_UNDEF = 0x00,
- AUDIO_MD_CTRL_ENABLE = 0x01,
- AUDIO_MD_CTRL_BALANCE = 0x02,
- AUDIO_MD_CTRL_RATE = 0x03,
- AUDIO_MD_CTRL_DEPTH = 0x04,
- AUDIO_MD_CTRL_TIME = 0x05,
- AUDIO_MD_CTRL_FEEDBACK = 0x06,
- AUDIO_MD_CTRL_UNDERFLOW = 0x07,
- AUDIO_MD_CTRL_OVERFLOW = 0x08,
- AUDIO_MD_CTRL_LATENCY = 0x09,
-} audio_modulation_delay_control_selector_t;
+typedef enum {
+ AUDIO20_MD_CTRL_UNDEF = 0x00,
+ AUDIO20_MD_CTRL_ENABLE = 0x01,
+ AUDIO20_MD_CTRL_BALANCE = 0x02,
+ AUDIO20_MD_CTRL_RATE = 0x03,
+ AUDIO20_MD_CTRL_DEPTH = 0x04,
+ AUDIO20_MD_CTRL_TIME = 0x05,
+ AUDIO20_MD_CTRL_FEEDBACK = 0x06,
+ AUDIO20_MD_CTRL_UNDERFLOW = 0x07,
+ AUDIO20_MD_CTRL_OVERFLOW = 0x08,
+ AUDIO20_MD_CTRL_LATENCY = 0x09,
+} audio20_modulation_delay_control_selector_t;
/// A.17.8.4 Dynamic Range Compressor Effect Unit Control Selectors
-typedef enum
-{
- AUDIO_DR_CTRL_UNDEF = 0x00,
- AUDIO_DR_CTRL_ENABLE = 0x01,
- AUDIO_DR_CTRL_COMPRESSION_RATE = 0x02,
- AUDIO_DR_CTRL_MAXAMPL = 0x03,
- AUDIO_DR_CTRL_THRESHOLD = 0x04,
- AUDIO_DR_CTRL_ATTACK_TIME = 0x05,
- AUDIO_DR_CTRL_RELEASE_TIME = 0x06,
- AUDIO_DR_CTRL_UNDERFLOW = 0x07,
- AUDIO_DR_CTRL_OVERFLOW = 0x08,
- AUDIO_DR_CTRL_LATENCY = 0x09,
-} audio_dynamic_range_compression_control_selector_t;
+typedef enum {
+ AUDIO20_DR_CTRL_UNDEF = 0x00,
+ AUDIO20_DR_CTRL_ENABLE = 0x01,
+ AUDIO20_DR_CTRL_COMPRESSION_RATE = 0x02,
+ AUDIO20_DR_CTRL_MAXAMPL = 0x03,
+ AUDIO20_DR_CTRL_THRESHOLD = 0x04,
+ AUDIO20_DR_CTRL_ATTACK_TIME = 0x05,
+ AUDIO20_DR_CTRL_RELEASE_TIME = 0x06,
+ AUDIO20_DR_CTRL_UNDERFLOW = 0x07,
+ AUDIO20_DR_CTRL_OVERFLOW = 0x08,
+ AUDIO20_DR_CTRL_LATENCY = 0x09,
+} audio20_dynamic_range_compression_control_selector_t;
/// A.17.9 Processing Unit Control Selectors
/// A.17.9.1 Up/Down-mix Processing Unit Control Selectors
-typedef enum
-{
- AUDIO_UD_CTRL_UNDEF = 0x00,
- AUDIO_UD_CTRL_ENABLE = 0x01,
- AUDIO_UD_CTRL_MODE_SELECT = 0x02,
- AUDIO_UD_CTRL_CLUSTER = 0x03,
- AUDIO_UD_CTRL_UNDERFLOW = 0x04,
- AUDIO_UD_CTRL_OVERFLOW = 0x05,
- AUDIO_UD_CTRL_LATENCY = 0x06,
-} audio_up_down_mix_control_selector_t;
+typedef enum {
+ AUDIO20_UD_CTRL_UNDEF = 0x00,
+ AUDIO20_UD_CTRL_ENABLE = 0x01,
+ AUDIO20_UD_CTRL_MODE_SELECT = 0x02,
+ AUDIO20_UD_CTRL_CLUSTER = 0x03,
+ AUDIO20_UD_CTRL_UNDERFLOW = 0x04,
+ AUDIO20_UD_CTRL_OVERFLOW = 0x05,
+ AUDIO20_UD_CTRL_LATENCY = 0x06,
+} audio20_up_down_mix_control_selector_t;
/// A.17.9.2 Dolby Prologic â„¢ Processing Unit Control Selectors
-typedef enum
-{
- AUDIO_DP_CTRL_UNDEF = 0x00,
- AUDIO_DP_CTRL_ENABLE = 0x01,
- AUDIO_DP_CTRL_MODE_SELECT = 0x02,
- AUDIO_DP_CTRL_CLUSTER = 0x03,
- AUDIO_DP_CTRL_UNDERFLOW = 0x04,
- AUDIO_DP_CTRL_OVERFLOW = 0x05,
- AUDIO_DP_CTRL_LATENCY = 0x06,
-} audio_dolby_prologic_control_selector_t;
+typedef enum {
+ AUDIO20_DP_CTRL_UNDEF = 0x00,
+ AUDIO20_DP_CTRL_ENABLE = 0x01,
+ AUDIO20_DP_CTRL_MODE_SELECT = 0x02,
+ AUDIO20_DP_CTRL_CLUSTER = 0x03,
+ AUDIO20_DP_CTRL_UNDERFLOW = 0x04,
+ AUDIO20_DP_CTRL_OVERFLOW = 0x05,
+ AUDIO20_DP_CTRL_LATENCY = 0x06,
+} audio20_dolby_prologic_control_selector_t;
/// A.17.9.3 Stereo Extender Processing Unit Control Selectors
-typedef enum
-{
- AUDIO_ST_EXT_CTRL_UNDEF = 0x00,
- AUDIO_ST_EXT_CTRL_ENABLE = 0x01,
- AUDIO_ST_EXT_CTRL_WIDTH = 0x02,
- AUDIO_ST_EXT_CTRL_UNDERFLOW = 0x03,
- AUDIO_ST_EXT_CTRL_OVERFLOW = 0x04,
- AUDIO_ST_EXT_CTRL_LATENCY = 0x05,
-} audio_stereo_extender_control_selector_t;
+typedef enum {
+ AUDIO20_ST_EXT_CTRL_UNDEF = 0x00,
+ AUDIO20_ST_EXT_CTRL_ENABLE = 0x01,
+ AUDIO20_ST_EXT_CTRL_WIDTH = 0x02,
+ AUDIO20_ST_EXT_CTRL_UNDERFLOW = 0x03,
+ AUDIO20_ST_EXT_CTRL_OVERFLOW = 0x04,
+ AUDIO20_ST_EXT_CTRL_LATENCY = 0x05,
+} audio20_stereo_extender_control_selector_t;
/// A.17.10 Extension Unit Control Selectors
-typedef enum
-{
- AUDIO_XU_CTRL_UNDEF = 0x00,
- AUDIO_XU_CTRL_ENABLE = 0x01,
- AUDIO_XU_CTRL_CLUSTER = 0x02,
- AUDIO_XU_CTRL_UNDERFLOW = 0x03,
- AUDIO_XU_CTRL_OVERFLOW = 0x04,
- AUDIO_XU_CTRL_LATENCY = 0x05,
-} audio_extension_unit_control_selector_t;
+typedef enum {
+ AUDIO20_XU_CTRL_UNDEF = 0x00,
+ AUDIO20_XU_CTRL_ENABLE = 0x01,
+ AUDIO20_XU_CTRL_CLUSTER = 0x02,
+ AUDIO20_XU_CTRL_UNDERFLOW = 0x03,
+ AUDIO20_XU_CTRL_OVERFLOW = 0x04,
+ AUDIO20_XU_CTRL_LATENCY = 0x05,
+} audio20_extension_unit_control_selector_t;
/// A.17.11 AudioStreaming Interface Control Selectors
-typedef enum
-{
- AUDIO_AS_CTRL_UNDEF = 0x00,
- AUDIO_AS_CTRL_ACT_ALT_SETTING = 0x01,
- AUDIO_AS_CTRL_VAL_ALT_SETTINGS = 0x02,
- AUDIO_AS_CTRL_AUDIO_DATA_FORMAT = 0x03,
-} audio_audiostreaming_interface_control_selector_t;
+typedef enum {
+ AUDIO20_AS_CTRL_UNDEF = 0x00,
+ AUDIO20_AS_CTRL_ACT_ALT_SETTING = 0x01,
+ AUDIO20_AS_CTRL_VAL_ALT_SETTINGS = 0x02,
+ AUDIO20_AS_CTRL_AUDIO_DATA_FORMAT = 0x03,
+} audio20_audiostreaming_interface_control_selector_t;
/// A.17.12 Encoder Control Selectors
-typedef enum
-{
- AUDIO_EN_CTRL_UNDEF = 0x00,
- AUDIO_EN_CTRL_BIT_RATE = 0x01,
- AUDIO_EN_CTRL_QUALITY = 0x02,
- AUDIO_EN_CTRL_VBR = 0x03,
- AUDIO_EN_CTRL_TYPE = 0x04,
- AUDIO_EN_CTRL_UNDERFLOW = 0x05,
- AUDIO_EN_CTRL_OVERFLOW = 0x06,
- AUDIO_EN_CTRL_ENCODER_ERROR = 0x07,
- AUDIO_EN_CTRL_PARAM1 = 0x08,
- AUDIO_EN_CTRL_PARAM2 = 0x09,
- AUDIO_EN_CTRL_PARAM3 = 0x0A,
- AUDIO_EN_CTRL_PARAM4 = 0x0B,
- AUDIO_EN_CTRL_PARAM5 = 0x0C,
- AUDIO_EN_CTRL_PARAM6 = 0x0D,
- AUDIO_EN_CTRL_PARAM7 = 0x0E,
- AUDIO_EN_CTRL_PARAM8 = 0x0F,
-} audio_encoder_control_selector_t;
+typedef enum {
+ AUDIO20_EN_CTRL_UNDEF = 0x00,
+ AUDIO20_EN_CTRL_BIT_RATE = 0x01,
+ AUDIO20_EN_CTRL_QUALITY = 0x02,
+ AUDIO20_EN_CTRL_VBR = 0x03,
+ AUDIO20_EN_CTRL_TYPE = 0x04,
+ AUDIO20_EN_CTRL_UNDERFLOW = 0x05,
+ AUDIO20_EN_CTRL_OVERFLOW = 0x06,
+ AUDIO20_EN_CTRL_ENCODER_ERROR = 0x07,
+ AUDIO20_EN_CTRL_PARAM1 = 0x08,
+ AUDIO20_EN_CTRL_PARAM2 = 0x09,
+ AUDIO20_EN_CTRL_PARAM3 = 0x0A,
+ AUDIO20_EN_CTRL_PARAM4 = 0x0B,
+ AUDIO20_EN_CTRL_PARAM5 = 0x0C,
+ AUDIO20_EN_CTRL_PARAM6 = 0x0D,
+ AUDIO20_EN_CTRL_PARAM7 = 0x0E,
+ AUDIO20_EN_CTRL_PARAM8 = 0x0F,
+} audio20_encoder_control_selector_t;
/// A.17.13 Decoder Control Selectors
/// A.17.13.1 MPEG Decoder Control Selectors
-typedef enum
-{
- AUDIO_MPD_CTRL_UNDEF = 0x00,
- AUDIO_MPD_CTRL_DUAL_CHANNEL = 0x01,
- AUDIO_MPD_CTRL_SECOND_STEREO = 0x02,
- AUDIO_MPD_CTRL_MULTILINGUAL = 0x03,
- AUDIO_MPD_CTRL_DYN_RANGE = 0x04,
- AUDIO_MPD_CTRL_SCALING = 0x05,
- AUDIO_MPD_CTRL_HILO_SCALING = 0x06,
- AUDIO_MPD_CTRL_UNDERFLOW = 0x07,
- AUDIO_MPD_CTRL_OVERFLOW = 0x08,
- AUDIO_MPD_CTRL_DECODER_ERROR = 0x09,
-} audio_MPEG_decoder_control_selector_t;
+typedef enum {
+ AUDIO20_MPD_CTRL_UNDEF = 0x00,
+ AUDIO20_MPD_CTRL_DUAL_CHANNEL = 0x01,
+ AUDIO20_MPD_CTRL_SECOND_STEREO = 0x02,
+ AUDIO20_MPD_CTRL_MULTILINGUAL = 0x03,
+ AUDIO20_MPD_CTRL_DYN_RANGE = 0x04,
+ AUDIO20_MPD_CTRL_SCALING = 0x05,
+ AUDIO20_MPD_CTRL_HILO_SCALING = 0x06,
+ AUDIO20_MPD_CTRL_UNDERFLOW = 0x07,
+ AUDIO20_MPD_CTRL_OVERFLOW = 0x08,
+ AUDIO20_MPD_CTRL_DECODER_ERROR = 0x09,
+} audio20_MPEG_decoder_control_selector_t;
/// A.17.13.2 AC-3 Decoder Control Selectors
-typedef enum
-{
- AUDIO_AD_CTRL_UNDEF = 0x00,
- AUDIO_AD_CTRL_MODE = 0x01,
- AUDIO_AD_CTRL_DYN_RANGE = 0x02,
- AUDIO_AD_CTRL_SCALING = 0x03,
- AUDIO_AD_CTRL_HILO_SCALING = 0x04,
- AUDIO_AD_CTRL_UNDERFLOW = 0x05,
- AUDIO_AD_CTRL_OVERFLOW = 0x06,
- AUDIO_AD_CTRL_DECODER_ERROR = 0x07,
-} audio_AC3_decoder_control_selector_t;
+typedef enum {
+ AUDIO20_AD_CTRL_UNDEF = 0x00,
+ AUDIO20_AD_CTRL_MODE = 0x01,
+ AUDIO20_AD_CTRL_DYN_RANGE = 0x02,
+ AUDIO20_AD_CTRL_SCALING = 0x03,
+ AUDIO20_AD_CTRL_HILO_SCALING = 0x04,
+ AUDIO20_AD_CTRL_UNDERFLOW = 0x05,
+ AUDIO20_AD_CTRL_OVERFLOW = 0x06,
+ AUDIO20_AD_CTRL_DECODER_ERROR = 0x07,
+} audio20_AC3_decoder_control_selector_t;
/// A.17.13.3 WMA Decoder Control Selectors
-typedef enum
-{
- AUDIO_WD_CTRL_UNDEF = 0x00,
- AUDIO_WD_CTRL_UNDERFLOW = 0x01,
- AUDIO_WD_CTRL_OVERFLOW = 0x02,
- AUDIO_WD_CTRL_DECODER_ERROR = 0x03,
-} audio_WMA_decoder_control_selector_t;
+typedef enum {
+ AUDIO20_WD_CTRL_UNDEF = 0x00,
+ AUDIO20_WD_CTRL_UNDERFLOW = 0x01,
+ AUDIO20_WD_CTRL_OVERFLOW = 0x02,
+ AUDIO20_WD_CTRL_DECODER_ERROR = 0x03,
+} audio20_WMA_decoder_control_selector_t;
/// A.17.13.4 DTS Decoder Control Selectors
-typedef enum
-{
- AUDIO_DD_CTRL_UNDEF = 0x00,
- AUDIO_DD_CTRL_UNDERFLOW = 0x01,
- AUDIO_DD_CTRL_OVERFLOW = 0x02,
- AUDIO_DD_CTRL_DECODER_ERROR = 0x03,
-} audio_DTS_decoder_control_selector_t;
+typedef enum {
+ AUDIO20_DD_CTRL_UNDEF = 0x00,
+ AUDIO20_DD_CTRL_UNDERFLOW = 0x01,
+ AUDIO20_DD_CTRL_OVERFLOW = 0x02,
+ AUDIO20_DD_CTRL_DECODER_ERROR = 0x03,
+} audio20_DTS_decoder_control_selector_t;
/// A.17.14 Endpoint Control Selectors
-typedef enum
-{
- AUDIO_EP_CTRL_UNDEF = 0x00,
- AUDIO_EP_CTRL_PITCH = 0x01,
- AUDIO_EP_CTRL_DATA_OVERRUN = 0x02,
- AUDIO_EP_CTRL_DATA_UNDERRUN = 0x03,
-} audio_EP_control_selector_t;
-
-/// Terminal Types
-
-/// 2.1 - Audio Class-Terminal Types UAC2
-typedef enum
-{
- AUDIO_TERM_TYPE_USB_UNDEFINED = 0x0100,
- AUDIO_TERM_TYPE_USB_STREAMING = 0x0101,
- AUDIO_TERM_TYPE_USB_VENDOR_SPEC = 0x01FF,
-} audio_terminal_type_t;
-
-/// 2.2 - Audio Class-Input Terminal Types UAC2
-typedef enum
-{
- AUDIO_TERM_TYPE_IN_UNDEFINED = 0x0200,
- AUDIO_TERM_TYPE_IN_GENERIC_MIC = 0x0201,
- AUDIO_TERM_TYPE_IN_DESKTOP_MIC = 0x0202,
- AUDIO_TERM_TYPE_IN_PERSONAL_MIC = 0x0203,
- AUDIO_TERM_TYPE_IN_OMNI_MIC = 0x0204,
- AUDIO_TERM_TYPE_IN_ARRAY_MIC = 0x0205,
- AUDIO_TERM_TYPE_IN_PROC_ARRAY_MIC = 0x0206,
-} audio_terminal_input_type_t;
-
-/// 2.3 - Audio Class-Output Terminal Types UAC2
-typedef enum
-{
- AUDIO_TERM_TYPE_OUT_UNDEFINED = 0x0300,
- AUDIO_TERM_TYPE_OUT_GENERIC_SPEAKER = 0x0301,
- AUDIO_TERM_TYPE_OUT_HEADPHONES = 0x0302,
- AUDIO_TERM_TYPE_OUT_HEAD_MNT_DISP_AUIDO = 0x0303,
- AUDIO_TERM_TYPE_OUT_DESKTOP_SPEAKER = 0x0304,
- AUDIO_TERM_TYPE_OUT_ROOM_SPEAKER = 0x0305,
- AUDIO_TERM_TYPE_OUT_COMMUNICATION_SPEAKER = 0x0306,
- AUDIO_TERM_TYPE_OUT_LOW_FRQ_EFFECTS_SPEAKER = 0x0307,
-} audio_terminal_output_type_t;
-
-/// Rest is yet to be implemented
+typedef enum {
+ AUDIO20_EP_CTRL_UNDEF = 0x00,
+ AUDIO20_EP_CTRL_PITCH = 0x01,
+ AUDIO20_EP_CTRL_DATA_OVERRUN = 0x02,
+ AUDIO20_EP_CTRL_DATA_UNDERRUN = 0x03,
+} audio20_EP_control_selector_t;
/// Additional Audio Device Class Codes - Source: Audio Data Formats
/// A.1 - Audio Class-Format Type Codes UAC2
-typedef enum
-{
- AUDIO_FORMAT_TYPE_UNDEFINED = 0x00,
- AUDIO_FORMAT_TYPE_I = 0x01,
- AUDIO_FORMAT_TYPE_II = 0x02,
- AUDIO_FORMAT_TYPE_III = 0x03,
- AUDIO_FORMAT_TYPE_IV = 0x04,
- AUDIO_EXT_FORMAT_TYPE_I = 0x81,
- AUDIO_EXT_FORMAT_TYPE_II = 0x82,
- AUDIO_EXT_FORMAT_TYPE_III = 0x83,
-} audio_format_type_t;
+typedef enum {
+ AUDIO20_FORMAT_TYPE_UNDEFINED = 0x00,
+ AUDIO20_FORMAT_TYPE_I = 0x01,
+ AUDIO20_FORMAT_TYPE_II = 0x02,
+ AUDIO20_FORMAT_TYPE_III = 0x03,
+ AUDIO20_FORMAT_TYPE_IV = 0x04,
+ AUDIO20_EXT_FORMAT_TYPE_I = 0x81,
+ AUDIO20_EXT_FORMAT_TYPE_II = 0x82,
+ AUDIO20_EXT_FORMAT_TYPE_III = 0x83,
+} audio20_format_type_t;
// A.2.1 - Audio Class-Audio Data Format Type I UAC2
-typedef enum
-{
- AUDIO_DATA_FORMAT_TYPE_I_PCM = (uint32_t) (1 << 0),
- AUDIO_DATA_FORMAT_TYPE_I_PCM8 = (uint32_t) (1 << 1),
- AUDIO_DATA_FORMAT_TYPE_I_IEEE_FLOAT = (uint32_t) (1 << 2),
- AUDIO_DATA_FORMAT_TYPE_I_ALAW = (uint32_t) (1 << 3),
- AUDIO_DATA_FORMAT_TYPE_I_MULAW = (uint32_t) (1 << 4),
- AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA = 0x80000000u,
-} audio_data_format_type_I_t;
+typedef enum {
+ AUDIO20_DATA_FORMAT_TYPE_I_PCM = (uint32_t) (1 << 0),
+ AUDIO20_DATA_FORMAT_TYPE_I_PCM8 = (uint32_t) (1 << 1),
+ AUDIO20_DATA_FORMAT_TYPE_I_IEEE_FLOAT = (uint32_t) (1 << 2),
+ AUDIO20_DATA_FORMAT_TYPE_I_ALAW = (uint32_t) (1 << 3),
+ AUDIO20_DATA_FORMAT_TYPE_I_MULAW = (uint32_t) (1 << 4),
+ AUDIO20_DATA_FORMAT_TYPE_I_RAW_DATA = 0x80000000u,
+} audio20_data_format_type_I_t;
+
+/// Audio Class-Audio Channel Configuration UAC2 (Table A-11)
+typedef enum {
+ AUDIO20_CHANNEL_CONFIG_NON_PREDEFINED = 0x00000000,
+ AUDIO20_CHANNEL_CONFIG_FRONT_LEFT = 0x00000001,
+ AUDIO20_CHANNEL_CONFIG_FRONT_RIGHT = 0x00000002,
+ AUDIO20_CHANNEL_CONFIG_FRONT_CENTER = 0x00000004,
+ AUDIO20_CHANNEL_CONFIG_LOW_FRQ_EFFECTS = 0x00000008,
+ AUDIO20_CHANNEL_CONFIG_BACK_LEFT = 0x00000010,
+ AUDIO20_CHANNEL_CONFIG_BACK_RIGHT = 0x00000020,
+ AUDIO20_CHANNEL_CONFIG_FRONT_LEFT_OF_CENTER = 0x00000040,
+ AUDIO20_CHANNEL_CONFIG_FRONT_RIGHT_OF_CENTER = 0x00000080,
+ AUDIO20_CHANNEL_CONFIG_BACK_CENTER = 0x00000100,
+ AUDIO20_CHANNEL_CONFIG_SIDE_LEFT = 0x00000200,
+ AUDIO20_CHANNEL_CONFIG_SIDE_RIGHT = 0x00000400,
+ AUDIO20_CHANNEL_CONFIG_TOP_CENTER = 0x00000800,
+ AUDIO20_CHANNEL_CONFIG_TOP_FRONT_LEFT = 0x00001000,
+ AUDIO20_CHANNEL_CONFIG_TOP_FRONT_CENTER = 0x00002000,
+ AUDIO20_CHANNEL_CONFIG_TOP_FRONT_RIGHT = 0x00004000,
+ AUDIO20_CHANNEL_CONFIG_TOP_BACK_LEFT = 0x00008000,
+ AUDIO20_CHANNEL_CONFIG_TOP_BACK_CENTER = 0x00010000,
+ AUDIO20_CHANNEL_CONFIG_TOP_BACK_RIGHT = 0x00020000,
+ AUDIO20_CHANNEL_CONFIG_TOP_FRONT_LEFT_OF_CENTER = 0x00040000,
+ AUDIO20_CHANNEL_CONFIG_TOP_FRONT_RIGHT_OF_CENTER = 0x00080000,
+ AUDIO20_CHANNEL_CONFIG_LEFT_LOW_FRQ_EFFECTS = 0x00100000,
+ AUDIO20_CHANNEL_CONFIG_RIGHT_LOW_FRQ_EFFECTS = 0x00200000,
+ AUDIO20_CHANNEL_CONFIG_TOP_SIDE_LEFT = 0x00400000,
+ AUDIO20_CHANNEL_CONFIG_TOP_SIDE_RIGHT = 0x00800000,
+ AUDIO20_CHANNEL_CONFIG_BOTTOM_CENTER = 0x01000000,
+ AUDIO20_CHANNEL_CONFIG_BACK_LEFT_OF_CENTER = 0x02000000,
+ AUDIO20_CHANNEL_CONFIG_BACK_RIGHT_OF_CENTER = 0x04000000,
+ AUDIO20_CHANNEL_CONFIG_RAW_DATA = 0x80000000,
+} audio20_channel_config_t;
/// All remaining definitions are taken from the descriptor descriptions in the UAC2 main specification
/// Audio Class-Control Values UAC2
-typedef enum
-{
- AUDIO_CTRL_NONE = 0x00, ///< No Host access
- AUDIO_CTRL_R = 0x01, ///< Host read access only
- AUDIO_CTRL_RW = 0x03, ///< Host read write access
-} audio_control_t;
+typedef enum {
+ AUDIO20_CTRL_NONE = 0x00,///< No Host access
+ AUDIO20_CTRL_R = 0x01, ///< Host read access only
+ AUDIO20_CTRL_RW = 0x03, ///< Host read write access
+} audio20_control_t;
/// Audio Class-Specific AC Interface Descriptor Controls UAC2
-typedef enum
-{
- AUDIO_CS_AS_INTERFACE_CTRL_LATENCY_POS = 0,
-} audio_cs_ac_interface_control_pos_t;
+typedef enum {
+ AUDIO20_CS_AS_INTERFACE_CTRL_LATENCY_POS = 0,
+} audio20_cs_ac_interface_control_pos_t;
/// Audio Class-Specific AS Interface Descriptor Controls UAC2
-typedef enum
-{
- AUDIO_CS_AS_INTERFACE_CTRL_ACTIVE_ALT_SET_POS = 0,
- AUDIO_CS_AS_INTERFACE_CTRL_VALID_ALT_SET_POS = 2,
-} audio_cs_as_interface_control_pos_t;
+typedef enum {
+ AUDIO20_CS_AS_INTERFACE_CTRL_ACTIVE_ALT_SET_POS = 0,
+ AUDIO20_CS_AS_INTERFACE_CTRL_VALID_ALT_SET_POS = 2,
+} audio20_cs_as_interface_control_pos_t;
/// Audio Class-Specific AS Isochronous Data EP Attributes UAC2
-typedef enum
-{
- AUDIO_CS_AS_ISO_DATA_EP_ATT_MAX_PACKETS_ONLY = 0x80,
- AUDIO_CS_AS_ISO_DATA_EP_ATT_NON_MAX_PACKETS_OK = 0x00,
-} audio_cs_as_iso_data_ep_attribute_t;
+typedef enum {
+ AUDIO20_CS_AS_ISO_DATA_EP_ATT_MAX_PACKETS_ONLY = 0x80,
+ AUDIO20_CS_AS_ISO_DATA_EP_ATT_NON_MAX_PACKETS_OK = 0x00,
+} audio20_cs_as_iso_data_ep_attribute_t;
/// Audio Class-Specific AS Isochronous Data EP Controls UAC2
-typedef enum
-{
- AUDIO_CS_AS_ISO_DATA_EP_CTRL_PITCH_POS = 0,
- AUDIO_CS_AS_ISO_DATA_EP_CTRL_DATA_OVERRUN_POS = 2,
- AUDIO_CS_AS_ISO_DATA_EP_CTRL_DATA_UNDERRUN_POS = 4,
-} audio_cs_as_iso_data_ep_control_pos_t;
+typedef enum {
+ AUDIO20_CS_AS_ISO_DATA_EP_CTRL_PITCH_POS = 0,
+ AUDIO20_CS_AS_ISO_DATA_EP_CTRL_DATA_OVERRUN_POS = 2,
+ AUDIO20_CS_AS_ISO_DATA_EP_CTRL_DATA_UNDERRUN_POS = 4,
+} audio20_cs_as_iso_data_ep_control_pos_t;
/// Audio Class-Specific AS Isochronous Data EP Lock Delay Units UAC2
-typedef enum
-{
- AUDIO_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_UNDEFINED = 0x00,
- AUDIO_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_MILLISEC = 0x01,
- AUDIO_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_PCM_SAMPLES = 0x02,
-} audio_cs_as_iso_data_ep_lock_delay_unit_t;
+typedef enum {
+ AUDIO20_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_UNDEFINED = 0x00,
+ AUDIO20_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_MILLISEC = 0x01,
+ AUDIO20_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_PCM_SAMPLES = 0x02,
+} audio20_cs_as_iso_data_ep_lock_delay_unit_t;
/// Audio Class-Clock Source Attributes UAC2
-typedef enum
-{
- AUDIO_CLOCK_SOURCE_ATT_EXT_CLK = 0x00,
- AUDIO_CLOCK_SOURCE_ATT_INT_FIX_CLK = 0x01,
- AUDIO_CLOCK_SOURCE_ATT_INT_VAR_CLK = 0x02,
- AUDIO_CLOCK_SOURCE_ATT_INT_PRO_CLK = 0x03,
- AUDIO_CLOCK_SOURCE_ATT_CLK_SYC_SOF = 0x04,
-} audio_clock_source_attribute_t;
+typedef enum {
+ AUDIO20_CLOCK_SOURCE_ATT_EXT_CLK = 0x00,
+ AUDIO20_CLOCK_SOURCE_ATT_INT_FIX_CLK = 0x01,
+ AUDIO20_CLOCK_SOURCE_ATT_INT_VAR_CLK = 0x02,
+ AUDIO20_CLOCK_SOURCE_ATT_INT_PRO_CLK = 0x03,
+ AUDIO20_CLOCK_SOURCE_ATT_CLK_SYC_SOF = 0x04,
+} audio20_clock_source_attribute_t;
/// Audio Class-Clock Source Controls UAC2
-typedef enum
-{
- AUDIO_CLOCK_SOURCE_CTRL_CLK_FRQ_POS = 0,
- AUDIO_CLOCK_SOURCE_CTRL_CLK_VAL_POS = 2,
-} audio_clock_source_control_pos_t;
+typedef enum {
+ AUDIO20_CLOCK_SOURCE_CTRL_CLK_FRQ_POS = 0,
+ AUDIO20_CLOCK_SOURCE_CTRL_CLK_VAL_POS = 2,
+} audio20_clock_source_control_pos_t;
/// Audio Class-Clock Selector Controls UAC2
-typedef enum
-{
- AUDIO_CLOCK_SELECTOR_CTRL_POS = 0,
-} audio_clock_selector_control_pos_t;
+typedef enum {
+ AUDIO20_CLOCK_SELECTOR_CTRL_POS = 0,
+} audio20_clock_selector_control_pos_t;
/// Audio Class-Clock Multiplier Controls UAC2
-typedef enum
-{
- AUDIO_CLOCK_MULTIPLIER_CTRL_NUMERATOR_POS = 0,
- AUDIO_CLOCK_MULTIPLIER_CTRL_DENOMINATOR_POS = 2,
-} audio_clock_multiplier_control_pos_t;
+typedef enum {
+ AUDIO20_CLOCK_MULTIPLIER_CTRL_NUMERATOR_POS = 0,
+ AUDIO20_CLOCK_MULTIPLIER_CTRL_DENOMINATOR_POS = 2,
+} audio20_clock_multiplier_control_pos_t;
/// Audio Class-Input Terminal Controls UAC2
-typedef enum
-{
- AUDIO_IN_TERM_CTRL_CPY_PROT_POS = 0,
- AUDIO_IN_TERM_CTRL_CONNECTOR_POS = 2,
- AUDIO_IN_TERM_CTRL_OVERLOAD_POS = 4,
- AUDIO_IN_TERM_CTRL_CLUSTER_POS = 6,
- AUDIO_IN_TERM_CTRL_UNDERFLOW_POS = 8,
- AUDIO_IN_TERM_CTRL_OVERFLOW_POS = 10,
-} audio_terminal_input_control_pos_t;
+typedef enum {
+ AUDIO20_IN_TERM_CTRL_CPY_PROT_POS = 0,
+ AUDIO20_IN_TERM_CTRL_CONNECTOR_POS = 2,
+ AUDIO20_IN_TERM_CTRL_OVERLOAD_POS = 4,
+ AUDIO20_IN_TERM_CTRL_CLUSTER_POS = 6,
+ AUDIO20_IN_TERM_CTRL_UNDERFLOW_POS = 8,
+ AUDIO20_IN_TERM_CTRL_OVERFLOW_POS = 10,
+} audio20_terminal_input_control_pos_t;
/// Audio Class-Output Terminal Controls UAC2
-typedef enum
-{
- AUDIO_OUT_TERM_CTRL_CPY_PROT_POS = 0,
- AUDIO_OUT_TERM_CTRL_CONNECTOR_POS = 2,
- AUDIO_OUT_TERM_CTRL_OVERLOAD_POS = 4,
- AUDIO_OUT_TERM_CTRL_UNDERFLOW_POS = 6,
- AUDIO_OUT_TERM_CTRL_OVERFLOW_POS = 8,
-} audio_terminal_output_control_pos_t;
+typedef enum {
+ AUDIO20_OUT_TERM_CTRL_CPY_PROT_POS = 0,
+ AUDIO20_OUT_TERM_CTRL_CONNECTOR_POS = 2,
+ AUDIO20_OUT_TERM_CTRL_OVERLOAD_POS = 4,
+ AUDIO20_OUT_TERM_CTRL_UNDERFLOW_POS = 6,
+ AUDIO20_OUT_TERM_CTRL_OVERFLOW_POS = 8,
+} audio20_terminal_output_control_pos_t;
/// Audio Class-Feature Unit Controls UAC2
-typedef enum
-{
- AUDIO_FEATURE_UNIT_CTRL_MUTE_POS = 0,
- AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS = 2,
- AUDIO_FEATURE_UNIT_CTRL_BASS_POS = 4,
- AUDIO_FEATURE_UNIT_CTRL_MID_POS = 6,
- AUDIO_FEATURE_UNIT_CTRL_TREBLE_POS = 8,
- AUDIO_FEATURE_UNIT_CTRL_GRAPHIC_EQU_POS = 10,
- AUDIO_FEATURE_UNIT_CTRL_AGC_POS = 12,
- AUDIO_FEATURE_UNIT_CTRL_DELAY_POS = 14,
- AUDIO_FEATURE_UNIT_CTRL_BASS_BOOST_POS = 16,
- AUDIO_FEATURE_UNIT_CTRL_LOUDNESS_POS = 18,
- AUDIO_FEATURE_UNIT_CTRL_INPUT_GAIN_POS = 20,
- AUDIO_FEATURE_UNIT_CTRL_INPUT_GAIN_PAD_POS = 22,
- AUDIO_FEATURE_UNIT_CTRL_PHASE_INV_POS = 24,
- AUDIO_FEATURE_UNIT_CTRL_UNDERFLOW_POS = 26,
- AUDIO_FEATURE_UNIT_CTRL_OVERFLOW_POS = 28,
-} audio_feature_unit_control_pos_t;
+typedef enum {
+ AUDIO20_FEATURE_UNIT_CTRL_MUTE_POS = 0,
+ AUDIO20_FEATURE_UNIT_CTRL_VOLUME_POS = 2,
+ AUDIO20_FEATURE_UNIT_CTRL_BASS_POS = 4,
+ AUDIO20_FEATURE_UNIT_CTRL_MID_POS = 6,
+ AUDIO20_FEATURE_UNIT_CTRL_TREBLE_POS = 8,
+ AUDIO20_FEATURE_UNIT_CTRL_GRAPHIC_EQU_POS = 10,
+ AUDIO20_FEATURE_UNIT_CTRL_AGC_POS = 12,
+ AUDIO20_FEATURE_UNIT_CTRL_DELAY_POS = 14,
+ AUDIO20_FEATURE_UNIT_CTRL_BASS_BOOST_POS = 16,
+ AUDIO20_FEATURE_UNIT_CTRL_LOUDNESS_POS = 18,
+ AUDIO20_FEATURE_UNIT_CTRL_INPUT_GAIN_POS = 20,
+ AUDIO20_FEATURE_UNIT_CTRL_INPUT_GAIN_PAD_POS = 22,
+ AUDIO20_FEATURE_UNIT_CTRL_PHASE_INV_POS = 24,
+ AUDIO20_FEATURE_UNIT_CTRL_UNDERFLOW_POS = 26,
+ AUDIO20_FEATURE_UNIT_CTRL_OVERFLOW_POS = 28,
+} audio20_feature_unit_control_pos_t;
-/// Audio Class-Audio Channel Configuration UAC2
-typedef enum
-{
- AUDIO_CHANNEL_CONFIG_NON_PREDEFINED = 0x00000000,
- AUDIO_CHANNEL_CONFIG_FRONT_LEFT = 0x00000001,
- AUDIO_CHANNEL_CONFIG_FRONT_RIGHT = 0x00000002,
- AUDIO_CHANNEL_CONFIG_FRONT_CENTER = 0x00000004,
- AUDIO_CHANNEL_CONFIG_LOW_FRQ_EFFECTS = 0x00000008,
- AUDIO_CHANNEL_CONFIG_BACK_LEFT = 0x00000010,
- AUDIO_CHANNEL_CONFIG_BACK_RIGHT = 0x00000020,
- AUDIO_CHANNEL_CONFIG_FRONT_LEFT_OF_CENTER = 0x00000040,
- AUDIO_CHANNEL_CONFIG_FRONT_RIGHT_OF_CENTER = 0x00000080,
- AUDIO_CHANNEL_CONFIG_BACK_CENTER = 0x00000100,
- AUDIO_CHANNEL_CONFIG_SIDE_LEFT = 0x00000200,
- AUDIO_CHANNEL_CONFIG_SIDE_RIGHT = 0x00000400,
- AUDIO_CHANNEL_CONFIG_TOP_CENTER = 0x00000800,
- AUDIO_CHANNEL_CONFIG_TOP_FRONT_LEFT = 0x00001000,
- AUDIO_CHANNEL_CONFIG_TOP_FRONT_CENTER = 0x00002000,
- AUDIO_CHANNEL_CONFIG_TOP_FRONT_RIGHT = 0x00004000,
- AUDIO_CHANNEL_CONFIG_TOP_BACK_LEFT = 0x00008000,
- AUDIO_CHANNEL_CONFIG_TOP_BACK_CENTER = 0x00010000,
- AUDIO_CHANNEL_CONFIG_TOP_BACK_RIGHT = 0x00020000,
- AUDIO_CHANNEL_CONFIG_TOP_FRONT_LEFT_OF_CENTER = 0x00040000,
- AUDIO_CHANNEL_CONFIG_TOP_FRONT_RIGHT_OF_CENTER = 0x00080000,
- AUDIO_CHANNEL_CONFIG_LEFT_LOW_FRQ_EFFECTS = 0x00100000,
- AUDIO_CHANNEL_CONFIG_RIGHT_LOW_FRQ_EFFECTS = 0x00200000,
- AUDIO_CHANNEL_CONFIG_TOP_SIDE_LEFT = 0x00400000,
- AUDIO_CHANNEL_CONFIG_TOP_SIDE_RIGHT = 0x00800000,
- AUDIO_CHANNEL_CONFIG_BOTTOM_CENTER = 0x01000000,
- AUDIO_CHANNEL_CONFIG_BACK_LEFT_OF_CENTER = 0x02000000,
- AUDIO_CHANNEL_CONFIG_BACK_RIGHT_OF_CENTER = 0x04000000,
- AUDIO_CHANNEL_CONFIG_RAW_DATA = 0x80000000u,
-} audio_channel_config_t;
+//--------------------------------------------------------------------+
+// USB AUDIO CLASS 2.0 (UAC2) DESCRIPTORS
+//--------------------------------------------------------------------+
-/// AUDIO Channel Cluster Descriptor (4.1)
+/// AUDIO Channel Cluster Descriptor UAC2 (4.1)
typedef struct TU_ATTR_PACKED {
- uint8_t bNrChannels; ///< Number of channels currently connected.
- audio_channel_config_t bmChannelConfig; ///< Bitmap according to 'audio_channel_config_t' with a 1 set if channel is connected and 0 else. In case channels are non-predefined ignore them here (see UAC2 specification 4.1 Audio Channel Cluster Descriptor.
- uint8_t iChannelNames; ///< Index of a string descriptor, describing the name of the first inserted channel with a non-predefined spatial location.
-} audio_desc_channel_cluster_t;
+ uint8_t bNrChannels; ///< Number of channels currently connected.
+ uint32_t bmChannelConfig;///< Bitmap according to 'audio20_channel_config_t' with a 1 set if channel is connected and 0 else. In case channels are non-predefined ignore them here (see UAC2 specification 4.1 Audio Channel Cluster Descriptor.
+ uint8_t iChannelNames; ///< Index of a string descriptor, describing the name of the first inserted channel with a non-predefined spatial location.
+} audio20_desc_channel_cluster_t;
-/// AUDIO Class-Specific AC Interface Header Descriptor (4.7.2)
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor in bytes: 9.
- uint8_t bDescriptorType ; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
- uint8_t bDescriptorSubType ; ///< Descriptor SubType. Value: AUDIO_CS_AC_INTERFACE_HEADER.
- uint16_t bcdADC ; ///< Audio Device Class Specification Release Number in Binary-Coded Decimal. Value: U16_TO_U8S_LE(0x0200).
- uint8_t bCategory ; ///< Constant, indicating the primary use of this audio function, as intended by the manufacturer. See: audio_function_t.
- uint16_t wTotalLength ; ///< Total number of bytes returned for the class-specific AudioControl interface descriptor. Includes the combined length of this descriptor header and all Clock Source, Unit and Terminal descriptors.
- uint8_t bmControls ; ///< See: audio_cs_ac_interface_control_pos_t.
-} audio_desc_cs_ac_interface_t;
-TU_VERIFY_STATIC(sizeof(audio_desc_cs_ac_interface_t) == 9, "size is not correct");
+/// AUDIO Class-Specific AC Interface Header Descriptor UAC2 (4.7.2)
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor in bytes: 9.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO20_CS_AC_INTERFACE_HEADER.
+ uint16_t bcdADC; ///< Audio Device Class Specification Release Number in Binary-Coded Decimal. Value: U16_TO_U8S_LE(0x0200).
+ uint8_t bCategory; ///< Constant, indicating the primary use of this audio function, as intended by the manufacturer. See: audio20_function_code_t.
+ uint16_t wTotalLength; ///< Total number of bytes returned for the class-specific AudioControl interface descriptor. Includes the combined length of this descriptor header and all Clock Source, Unit and Terminal descriptors.
+ uint8_t bmControls; ///< See: audio20_cs_ac_interface_control_pos_t.
+} audio20_desc_cs_ac_interface_t;
+TU_VERIFY_STATIC(sizeof(audio20_desc_cs_ac_interface_t) == 9, "size is not correct");
-/// AUDIO Clock Source Descriptor (4.7.2.1)
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor in bytes: 8.
- uint8_t bDescriptorType ; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
- uint8_t bDescriptorSubType ; ///< Descriptor SubType. Value: AUDIO_CS_AC_INTERFACE_CLOCK_SOURCE.
- uint8_t bClockID ; ///< Constant uniquely identifying the Clock Source Entity within the audio function. This value is used in all requests to address this Entity.
- uint8_t bmAttributes ; ///< See: audio_clock_source_attribute_t.
- uint8_t bmControls ; ///< See: audio_clock_source_control_pos_t.
- uint8_t bAssocTerminal ; ///< Terminal ID of the Terminal that is associated with this Clock Source.
- uint8_t iClockSource ; ///< Index of a string descriptor, describing the Clock Source Entity.
-} audio_desc_clock_source_t;
+/// AUDIO Clock Source Descriptor UAC2 (4.7.2.1)
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor in bytes: 8.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO20_CS_AC_INTERFACE_CLOCK_SOURCE.
+ uint8_t bClockID; ///< Constant uniquely identifying the Clock Source Entity within the audio function. This value is used in all requests to address this Entity.
+ uint8_t bmAttributes; ///< See: audio20_clock_source_attribute_t.
+ uint8_t bmControls; ///< See: audio20_clock_source_control_pos_t.
+ uint8_t bAssocTerminal; ///< Terminal ID of the Terminal that is associated with this Clock Source.
+ uint8_t iClockSource; ///< Index of a string descriptor, describing the Clock Source Entity.
+} audio20_desc_clock_source_t;
-/// AUDIO Clock Selector Descriptor (4.7.2.2) for ONE pin
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor, in bytes: 7+p.
- uint8_t bDescriptorType ; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
- uint8_t bDescriptorSubType ; ///< Descriptor SubType. Value: AUDIO_CS_AC_INTERFACE_CLOCK_SELECTOR.
- uint8_t bClockID ; ///< Constant uniquely identifying the Clock Selector Entity within the audio function. This value is used in all requests to address this Entity.
- uint8_t bNrInPins ; ///< Number of Input Pins of this Unit: p = 1 thus bNrInPins = 1.
- uint8_t baCSourceID ; ///< ID of the Clock Entity to which the first Clock Input Pin of this Clock Selector Entity is connected..
- uint8_t bmControls ; ///< See: audio_clock_selector_control_pos_t.
- uint8_t iClockSource ; ///< Index of a string descriptor, describing the Clock Selector Entity.
-} audio_desc_clock_selector_t;
+/// AUDIO Clock Selector Descriptor UAC2 (4.7.2.2) for ONE pin
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor, in bytes: 7+p.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO20_CS_AC_INTERFACE_CLOCK_SELECTOR.
+ uint8_t bClockID; ///< Constant uniquely identifying the Clock Selector Entity within the audio function. This value is used in all requests to address this Entity.
+ uint8_t bNrInPins; ///< Number of Input Pins of this Unit: p = 1 thus bNrInPins = 1.
+ uint8_t baCSourceID; ///< ID of the Clock Entity to which the first Clock Input Pin of this Clock Selector Entity is connected..
+ uint8_t bmControls; ///< See: audio20_clock_selector_control_pos_t.
+ uint8_t iClockSource; ///< Index of a string descriptor, describing the Clock Selector Entity.
+} audio20_desc_clock_selector_t;
/// AUDIO Clock Selector Descriptor (4.7.2.2) for multiple pins
-#define audio_desc_clock_selector_n_t(source_num) \
- struct TU_ATTR_PACKED { \
- uint8_t bLength ; \
- uint8_t bDescriptorType ; \
- uint8_t bDescriptorSubType ; \
- uint8_t bClockID ; \
- uint8_t bNrInPins ; \
- struct TU_ATTR_PACKED { \
- uint8_t baSourceID ; \
- } sourceID[source_num] ; \
- uint8_t bmControls ; \
- uint8_t iClockSource ; \
-}
+#define audio20_desc_clock_selector_n_t(source_num) \
+ struct TU_ATTR_PACKED { \
+ uint8_t bLength; \
+ uint8_t bDescriptorType; \
+ uint8_t bDescriptorSubType; \
+ uint8_t bClockID; \
+ uint8_t bNrInPins; \
+ struct TU_ATTR_PACKED { \
+ uint8_t baSourceID; \
+ } sourceID[source_num]; \
+ uint8_t bmControls; \
+ uint8_t iClockSource; \
+ }
-/// AUDIO Clock Multiplier Descriptor (4.7.2.3)
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor, in bytes: 7.
- uint8_t bDescriptorType ; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
- uint8_t bDescriptorSubType ; ///< Descriptor SubType. Value: AUDIO_CS_AC_INTERFACE_CLOCK_MULTIPLIER.
- uint8_t bClockID ; ///< Constant uniquely identifying the Clock Multiplier Entity within the audio function. This value is used in all requests to address this Entity.
- uint8_t bCSourceID ; ///< ID of the Clock Entity to which the last Clock Input Pin of this Clock Selector Entity is connected.
- uint8_t bmControls ; ///< See: audio_clock_multiplier_control_pos_t.
- uint8_t iClockSource ; ///< Index of a string descriptor, describing the Clock Multiplier Entity.
-} audio_desc_clock_multiplier_t;
+/// AUDIO Clock Multiplier Descriptor UAC2 (4.7.2.3)
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor, in bytes: 7.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO20_CS_AC_INTERFACE_CLOCK_MULTIPLIER.
+ uint8_t bClockID; ///< Constant uniquely identifying the Clock Multiplier Entity within the audio function. This value is used in all requests to address this Entity.
+ uint8_t bCSourceID; ///< ID of the Clock Entity to which the last Clock Input Pin of this Clock Selector Entity is connected.
+ uint8_t bmControls; ///< See: audio20_clock_multiplier_control_pos_t.
+ uint8_t iClockSource; ///< Index of a string descriptor, describing the Clock Multiplier Entity.
+} audio20_desc_clock_multiplier_t;
/// AUDIO Input Terminal Descriptor(4.7.2.4)
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor, in bytes: 17.
- uint8_t bDescriptorType ; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
- uint8_t bDescriptorSubType ; ///< Descriptor SubType. Value: AUDIO_CS_AC_INTERFACE_INPUT_TERMINAL.
- uint8_t bTerminalID ; ///< Constant uniquely identifying the Terminal within the audio function. This value is used in all requests to address this terminal.
- uint16_t wTerminalType ; ///< Constant characterizing the type of Terminal. See: audio_terminal_type_t for USB streaming and audio_terminal_input_type_t for other input types.
- uint8_t bAssocTerminal ; ///< ID of the Output Terminal to which this Input Terminal is associated.
- uint8_t bCSourceID ; ///< ID of the Clock Entity to which this Input Terminal is connected.
- uint8_t bNrChannels ; ///< Number of logical output channels in the Terminal’s output audio channel cluster.
- uint32_t bmChannelConfig ; ///< Describes the spatial location of the logical channels. See:audio_channel_config_t.
- uint8_t iChannelNames ; ///< Index of a string descriptor, describing the name of the first logical channel.
- uint16_t bmControls ; ///< See: audio_terminal_input_control_pos_t.
- uint8_t iTerminal ; ///< Index of a string descriptor, describing the Input Terminal.
-} audio_desc_input_terminal_t;
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor, in bytes: 17.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO_CS_AC_INTERFACE_INPUT_TERMINAL.
+ uint8_t bTerminalID; ///< Constant uniquely identifying the Terminal within the audio function. This value is used in all requests to address this terminal.
+ uint16_t wTerminalType; ///< Constant characterizing the type of Terminal. See: audio_terminal_type_t for USB streaming and audio_terminal_input_type_t for other input types.
+ uint8_t bAssocTerminal; ///< ID of the Output Terminal to which this Input Terminal is associated.
+ uint8_t bCSourceID; ///< ID of the Clock Entity to which this Input Terminal is connected.
+ uint8_t bNrChannels; ///< Number of logical output channels in the Terminal’s output audio channel cluster.
+ uint32_t bmChannelConfig; ///< Describes the spatial location of the logical channels. See:audio20_channel_config_t.
+ uint8_t iChannelNames; ///< Index of a string descriptor, describing the name of the first logical channel.
+ uint16_t bmControls; ///< See: audio_terminal_input_control_pos_t.
+ uint8_t iTerminal; ///< Index of a string descriptor, describing the Input Terminal.
+} audio20_desc_input_terminal_t;
-/// AUDIO Output Terminal Descriptor(4.7.2.5)
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor, in bytes: 12.
- uint8_t bDescriptorType ; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
- uint8_t bDescriptorSubType ; ///< Descriptor SubType. Value: AUDIO_CS_AC_INTERFACE_OUTPUT_TERMINAL.
- uint8_t bTerminalID ; ///< Constant uniquely identifying the Terminal within the audio function. This value is used in all requests to address this Terminal.
- uint16_t wTerminalType ; ///< Constant characterizing the type of Terminal. See: audio_terminal_type_t for USB streaming and audio_terminal_output_type_t for other output types.
- uint8_t bAssocTerminal ; ///< Constant, identifying the Input Terminal to which this Output Terminal is associated.
- uint8_t bSourceID ; ///< ID of the Unit or Terminal to which this Terminal is connected.
- uint8_t bCSourceID ; ///< ID of the Clock Entity to which this Output Terminal is connected.
- uint16_t bmControls ; ///< See: audio_terminal_output_type_t.
- uint8_t iTerminal ; ///< Index of a string descriptor, describing the Output Terminal.
-} audio_desc_output_terminal_t;
+/// AUDIO Output Terminal Descriptor UAC2 (4.7.2.5)
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor, in bytes: 12.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO20_CS_AC_INTERFACE_OUTPUT_TERMINAL.
+ uint8_t bTerminalID; ///< Constant uniquely identifying the Terminal within the audio function. This value is used in all requests to address this Terminal.
+ uint16_t wTerminalType; ///< Constant characterizing the type of Terminal. See: audio20_terminal_type_t for USB streaming and audio20_terminal_output_type_t for other output types.
+ uint8_t bAssocTerminal; ///< Constant, identifying the Input Terminal to which this Output Terminal is associated.
+ uint8_t bSourceID; ///< ID of the Unit or Terminal to which this Terminal is connected.
+ uint8_t bCSourceID; ///< ID of the Clock Entity to which this Output Terminal is connected.
+ uint16_t bmControls; ///< See: audio20_terminal_output_control_pos_t.
+ uint8_t iTerminal; ///< Index of a string descriptor, describing the Output Terminal.
+} audio20_desc_output_terminal_t;
-/// AUDIO Feature Unit Descriptor(4.7.2.8) for ONE channel
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor, in bytes: 14.
- uint8_t bDescriptorType ; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
- uint8_t bDescriptorSubType ; ///< Descriptor SubType. Value: AUDIO_CS_AC_INTERFACE_FEATURE_UNIT.
- uint8_t bUnitID ; ///< Constant uniquely identifying the Unit within the audio function. This value is used in all requests to address this Unit.
- uint8_t bSourceID ; ///< ID of the Unit or Terminal to which this Feature Unit is connected.
+/// AUDIO Feature Unit Descriptor UAC2 (4.7.2.8) for ONE channel
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor, in bytes: 14.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO20_CS_AC_INTERFACE_FEATURE_UNIT.
+ uint8_t bUnitID; ///< Constant uniquely identifying the Unit within the audio function. This value is used in all requests to address this Unit.
+ uint8_t bSourceID; ///< ID of the Unit or Terminal to which this Feature Unit is connected.
struct TU_ATTR_PACKED {
- uint32_t bmaControls ; ///< See: audio_feature_unit_control_pos_t. Controls0 is master channel 0 (always present) and Controls1 is logical channel 1.
- } controls[2] ;
- uint8_t iTerminal ; ///< Index of a string descriptor, describing this Feature Unit.
-} audio_desc_feature_unit_t;
+ uint32_t bmaControls;///< See: audio20_feature_unit_control_pos_t. Controls0 is master channel 0 (always present) and Controls1 is logical channel 1.
+ } controls[2];
+ uint8_t iTerminal;///< Index of a string descriptor, describing this Feature Unit.
+} audio20_desc_feature_unit_t;
/// AUDIO Feature Unit Descriptor(4.7.2.8) for multiple channels
-#define audio_desc_feature_unit_n_t(ch_num)\
- struct TU_ATTR_PACKED { \
- uint8_t bLength ; /* 6+(ch_num+1)*4 */\
- uint8_t bDescriptorType ; \
- uint8_t bDescriptorSubType ; \
- uint8_t bUnitID ; \
- uint8_t bSourceID ; \
- struct TU_ATTR_PACKED { \
- uint32_t bmaControls ; \
- } controls[ch_num+1] ; \
- uint8_t iTerminal ; \
-}
+#define audio20_desc_feature_unit_n_t(ch_num) \
+ struct TU_ATTR_PACKED { \
+ uint8_t bLength; /* 6+(ch_num+1)*4 */ \
+ uint8_t bDescriptorType; \
+ uint8_t bDescriptorSubType; \
+ uint8_t bUnitID; \
+ uint8_t bSourceID; \
+ struct TU_ATTR_PACKED { \
+ uint32_t bmaControls; \
+ } controls[ch_num + 1]; \
+ uint8_t iTerminal; \
+ }
/// AUDIO Class-Specific AS Interface Descriptor(4.9.2)
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor, in bytes: 16.
- uint8_t bDescriptorType ; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
- uint8_t bDescriptorSubType ; ///< Descriptor SubType. Value: AUDIO_CS_AS_INTERFACE_AS_GENERAL.
- uint8_t bTerminalLink ; ///< The Terminal ID of the Terminal to which this interface is connected.
- uint8_t bmControls ; ///< See: audio_cs_as_interface_control_pos_t.
- uint8_t bFormatType ; ///< Constant identifying the Format Type the AudioStreaming interface is using. See: audio_format_type_t.
- uint32_t bmFormats ; ///< The Audio Data Format(s) that can be used to communicate with this interface.See: audio_data_format_type_I_t.
- uint8_t bNrChannels ; ///< Number of physical channels in the AS Interface audio channel cluster.
- uint32_t bmChannelConfig ; ///< Describes the spatial location of the physical channels. See: audio_channel_config_t.
- uint8_t iChannelNames ; ///< Index of a string descriptor, describing the name of the first physical channel.
-} audio_desc_cs_as_interface_t;
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor, in bytes: 16.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO20_CS_AS_INTERFACE_AS_GENERAL.
+ uint8_t bTerminalLink; ///< The Terminal ID of the Terminal to which this interface is connected.
+ uint8_t bmControls; ///< See: audio20_cs_as_interface_control_pos_t.
+ uint8_t bFormatType; ///< Constant identifying the Format Type the AudioStreaming interface is using. See: audio20_format_type_t.
+ uint32_t bmFormats; ///< The Audio Data Format(s) that can be used to communicate with this interface.See: audio20_data_format_type_I_t.
+ uint8_t bNrChannels; ///< Number of physical channels in the AS Interface audio channel cluster.
+ uint32_t bmChannelConfig; ///< Describes the spatial location of the physical channels. See: audio20_channel_config_t.
+ uint8_t iChannelNames; ///< Index of a string descriptor, describing the name of the first physical channel.
+} audio20_desc_cs_as_interface_t;
/// AUDIO Type I Format Type Descriptor(2.3.1.6 - Audio Formats)
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor, in bytes: 6.
- uint8_t bDescriptorType ; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
- uint8_t bDescriptorSubType ; ///< Descriptor SubType. Value: AUDIO_CS_AS_INTERFACE_FORMAT_TYPE.
- uint8_t bFormatType ; ///< Constant identifying the Format Type the AudioStreaming interface is using. Value: AUDIO_FORMAT_TYPE_I.
- uint8_t bSubslotSize ; ///< The number of bytes occupied by one audio subslot. Can be 1, 2, 3 or 4.
- uint8_t bBitResolution ; ///< The number of effectively used bits from the available bits in an audio subslot.
-} audio_desc_type_I_format_t;
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor, in bytes: 6.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO20_CS_AS_INTERFACE_FORMAT_TYPE.
+ uint8_t bFormatType; ///< Constant identifying the Format Type the AudioStreaming interface is using. Value: AUDIO20_FORMAT_TYPE_I.
+ uint8_t bSubslotSize; ///< The number of bytes occupied by one audio subslot. Can be 1, 2, 3 or 4.
+ uint8_t bBitResolution; ///< The number of effectively used bits from the available bits in an audio subslot.
+} audio20_desc_type_I_format_t;
/// AUDIO Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.10.1.2)
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor, in bytes: 8.
- uint8_t bDescriptorType ; ///< Descriptor Type. Value: TUSB_DESC_CS_ENDPOINT.
- uint8_t bDescriptorSubType ; ///< Descriptor SubType. Value: AUDIO_CS_EP_SUBTYPE_GENERAL.
- uint8_t bmAttributes ; ///< See: audio_cs_as_iso_data_ep_attribute_t.
- uint8_t bmControls ; ///< See: audio_cs_as_iso_data_ep_control_pos_t.
- uint8_t bLockDelayUnits ; ///< Indicates the units used for the wLockDelay field. See: audio_cs_as_iso_data_ep_lock_delay_unit_t.
- uint16_t wLockDelay ; ///< Indicates the time it takes this endpoint to reliably lock its internal clock recovery circuitry. Units used depend on the value of the bLockDelayUnits field.
-} audio_desc_cs_as_iso_data_ep_t;
+typedef struct TU_ATTR_PACKED {
+ uint8_t bLength; ///< Size of this descriptor, in bytes: 8.
+ uint8_t bDescriptorType; ///< Descriptor Type. Value: TUSB_DESC_CS_ENDPOINT.
+ uint8_t bDescriptorSubType;///< Descriptor SubType. Value: AUDIO20_CS_EP_SUBTYPE_GENERAL.
+ uint8_t bmAttributes; ///< See: audio20_cs_as_iso_data_ep_attribute_t.
+ uint8_t bmControls; ///< See: audio20_cs_as_iso_data_ep_control_pos_t.
+ uint8_t bLockDelayUnits; ///< Indicates the units used for the wLockDelay field. See: audio20_cs_as_iso_data_ep_lock_delay_unit_t.
+ uint16_t wLockDelay; ///< Indicates the time it takes this endpoint to reliably lock its internal clock recovery circuitry. Units used depend on the value of the bLockDelayUnits field.
+} audio20_desc_cs_as_iso_data_ep_t;
// 5.2.2 Control Request Layout
-typedef struct TU_ATTR_PACKED
-{
- union
- {
- struct TU_ATTR_PACKED
- {
- uint8_t recipient : 5; ///< Recipient type tusb_request_recipient_t.
- uint8_t type : 2; ///< Request type tusb_request_type_t.
- uint8_t direction : 1; ///< Direction type. tusb_dir_t
- } bmRequestType_bit;
+typedef struct TU_ATTR_PACKED {
+ union {
+ struct TU_ATTR_PACKED {
+ uint8_t recipient : 5;///< Recipient type tusb_request_recipient_t.
+ uint8_t type : 2; ///< Request type tusb_request_type_t.
+ uint8_t direction : 1;///< Direction type. tusb_dir_t
+ } bmRequestType_bit;
- uint8_t bmRequestType;
- };
+ uint8_t bmRequestType;
+ };
- uint8_t bRequest; ///< Request type audio_cs_req_t
- uint8_t bChannelNumber;
- uint8_t bControlSelector;
- union
- {
- uint8_t bInterface;
- uint8_t bEndpoint;
- };
- uint8_t bEntityID;
- uint16_t wLength;
-} audio_control_request_t;
+ uint8_t bRequest;///< Request type audio_cs_req_t
+ uint8_t bChannelNumber;
+ uint8_t bControlSelector;
+ union {
+ uint8_t bInterface;
+ uint8_t bEndpoint;
+ };
+ uint8_t bEntityID;
+ uint16_t wLength;
+} audio20_control_request_t;
//// 5.2.3 Control Request Parameter Block Layout
// 5.2.3.1 1-byte Control CUR Parameter Block
-typedef struct TU_ATTR_PACKED
-{
- int8_t bCur ; ///< The setting for the CUR attribute of the addressed Control
-} audio_control_cur_1_t;
+typedef struct TU_ATTR_PACKED {
+ int8_t bCur;///< The setting for the CUR attribute of the addressed Control
+} audio20_control_cur_1_t;
// 5.2.3.2 2-byte Control CUR Parameter Block
-typedef struct TU_ATTR_PACKED
-{
- int16_t bCur ; ///< The setting for the CUR attribute of the addressed Control
-} audio_control_cur_2_t;
-
-// 5.2.3.3 4-byte Control CUR Parameter Block
-typedef struct TU_ATTR_PACKED
-{
- int32_t bCur ; ///< The setting for the CUR attribute of the addressed Control
-} audio_control_cur_4_t;
-
-// Use the following ONLY for RECEIVED data - compiler does not know how many subranges are defined! Use the one below for predefined lengths - or if you know what you are doing do what you like
-// 5.2.3.1 1-byte Control RANGE Parameter Block
typedef struct TU_ATTR_PACKED {
- uint16_t wNumSubRanges;
- struct TU_ATTR_PACKED {
- 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*/
- uint8_t bRes ; /*The setting for the RES attribute of the nth subrange of the addressed Control*/
- } subrange[] ;
-} audio_control_range_1_t;
+ int16_t bCur;///< The setting for the CUR attribute of the addressed Control
+} audio20_control_cur_2_t;
-// 5.2.3.2 2-byte Control RANGE Parameter Block
+// 5.2.3.3 4-byte Control CUR Parameter Block
typedef struct TU_ATTR_PACKED {
- uint16_t wNumSubRanges;
- struct TU_ATTR_PACKED {
- 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*/
- uint16_t bRes ; /*The setting for the RES attribute of the nth subrange of the addressed Control*/
- } subrange[] ;
-} audio_control_range_2_t;
+ int32_t bCur;///< The setting for the CUR attribute of the addressed Control
+} audio20_control_cur_4_t;
-// 5.2.3.3 4-byte Control RANGE Parameter Block
-typedef struct TU_ATTR_PACKED {
- uint16_t wNumSubRanges;
- struct TU_ATTR_PACKED {
- 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*/
- uint32_t bRes ; /*The setting for the RES attribute of the nth subrange of the addressed Control*/
- } subrange[] ;
-} audio_control_range_4_t;
+// Use the following ONLY for RECEIVED data - compiler does not know how many subranges are defined! Use the #define macros below for predefined lengths.
// 5.2.3.1 1-byte Control RANGE Parameter Block
-#define audio_control_range_1_n_t(numSubRanges) \
- struct TU_ATTR_PACKED { \
- uint16_t wNumSubRanges; \
- struct TU_ATTR_PACKED { \
- 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*/\
- uint8_t bRes ; /*The setting for the RES attribute of the nth subrange of the addressed Control*/\
- } subrange[numSubRanges] ; \
-}
+#define audio20_control_range_1_n_t(numSubRanges) \
+ struct TU_ATTR_PACKED { \
+ uint16_t wNumSubRanges; \
+ struct TU_ATTR_PACKED { \
+ 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*/ \
+ uint8_t bRes; /*The setting for the RES attribute of the nth subrange of the addressed Control*/ \
+ } subrange[numSubRanges]; \
+ }
/// 5.2.3.2 2-byte Control RANGE Parameter Block
-#define audio_control_range_2_n_t(numSubRanges) \
- struct TU_ATTR_PACKED { \
- uint16_t wNumSubRanges; \
- struct TU_ATTR_PACKED { \
- 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*/\
- uint16_t bRes ; /*The setting for the RES attribute of the nth subrange of the addressed Control*/\
- } subrange[numSubRanges]; \
-}
+#define audio20_control_range_2_n_t(numSubRanges) \
+ struct TU_ATTR_PACKED { \
+ uint16_t wNumSubRanges; \
+ struct TU_ATTR_PACKED { \
+ 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*/ \
+ uint16_t bRes; /*The setting for the RES attribute of the nth subrange of the addressed Control*/ \
+ } subrange[numSubRanges]; \
+ }
// 5.2.3.3 4-byte Control RANGE Parameter Block
-#define audio_control_range_4_n_t(numSubRanges) \
- struct TU_ATTR_PACKED { \
- uint16_t wNumSubRanges; \
- struct TU_ATTR_PACKED { \
- 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*/\
- uint32_t bRes ; /*The setting for the RES attribute of the nth subrange of the addressed Control*/\
- } subrange[numSubRanges]; \
-}
+#define audio20_control_range_4_n_t(numSubRanges) \
+ struct TU_ATTR_PACKED { \
+ uint16_t wNumSubRanges; \
+ struct TU_ATTR_PACKED { \
+ 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*/ \
+ uint32_t bRes; /*The setting for the RES attribute of the nth subrange of the addressed Control*/ \
+ } subrange[numSubRanges]; \
+ }
// 6.1 Interrupt Data Message Format
-typedef struct TU_ATTR_PACKED
-{
+typedef struct TU_ATTR_PACKED {
uint8_t bInfo;
uint8_t bAttribute;
- union
- {
+ union {
uint16_t wValue;
- struct
- {
+ struct {
uint8_t wValue_cn_or_mcn;
uint8_t wValue_cs;
};
};
- union
- {
+ union {
uint16_t wIndex;
- struct
- {
+ struct {
uint8_t wIndex_ep_or_int;
uint8_t wIndex_entity_id;
};
};
+} audio20_interrupt_data_t;
+
+//--------------------------------------------------------------------+
+// APPLICATION HELPER DEFINITIONS
+//--------------------------------------------------------------------+
+
+// Combined Interrupt Data Message Format for both UAC1 and UAC2
+typedef union {
+ audio10_interrupt_data_t v1;
+ audio20_interrupt_data_t v2;
} audio_interrupt_data_t;
+// MIDI1.0 use the same CS AC Interface Descriptor as UAC1
+typedef audio10_desc_cs_ac_interface_n_t(1) midi10_desc_cs_ac_interface_t;
+
+// UAC1.0 AC Interface Descriptor with 1 interface, used to read fields other than baInterfaceNr
+typedef audio10_desc_cs_ac_interface_n_t(1) audio10_desc_cs_ac_interface_1_t;
+
/** @} */
#ifdef __cplusplus
diff --git a/src/class/audio/audio_device.c b/src/class/audio/audio_device.c
index 6c972ca7a..731834357 100644
--- a/src/class/audio/audio_device.c
+++ b/src/class/audio/audio_device.c
@@ -180,16 +180,8 @@ tu_static CFG_TUD_MEM_SECTION struct {
} lin_buf_out;
#endif// CFG_TUD_AUDIO_ENABLE_EP_OUT && USE_LINEAR_BUFFER
-// Control buffers
-tu_static CFG_TUD_MEM_SECTION struct {
- TUD_EPBUF_DEF(buf1, CFG_TUD_AUDIO_FUNC_1_CTRL_BUF_SZ);
- #if CFG_TUD_AUDIO > 1
- TUD_EPBUF_DEF(buf2, CFG_TUD_AUDIO_FUNC_2_CTRL_BUF_SZ);
- #endif
- #if CFG_TUD_AUDIO > 2
- TUD_EPBUF_DEF(buf3, CFG_TUD_AUDIO_FUNC_3_CTRL_BUF_SZ);
- #endif
-} ctrl_buf;
+// Control buffer
+CFG_TUD_MEM_ALIGN uint8_t ctrl_buf[CFG_TUD_AUDIO_CTRL_BUF_SZ];
// Aligned buffer for feedback EP
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
@@ -217,6 +209,8 @@ typedef struct
{
uint8_t rhport;
uint8_t const *p_desc;// Pointer pointing to Standard AC Interface Descriptor(4.7.1) - Audio Control descriptor defining audio function
+ uint8_t const *p_desc_as;// Pointer pointing to 1st Standard AS Interface Descriptor(4.9.1) - Audio Streaming descriptor defining audio function
+ uint16_t desc_length;// Length of audio function descriptor
#if CFG_TUD_AUDIO_ENABLE_EP_IN
uint8_t ep_in; // TX audio data EP.
@@ -242,8 +236,6 @@ typedef struct
bool mounted;// Device opened
- uint16_t desc_length;// Length of audio function descriptor
-
#if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
struct {
uint32_t value; // Feedback value for asynchronous mode (in 16.16 format).
@@ -252,7 +244,6 @@ typedef struct
uint8_t frame_shift;// bInterval-1 in unit of frame (FS), micro-frame (HS)
uint8_t compute_method;
- bool format_correction;
union {
uint8_t power_of_2;// pre-computed power of 2 shift
float float_const; // pre-computed float constant
@@ -282,17 +273,13 @@ typedef struct
// Encoding parameters - parameters are set when alternate AS interface is set by host
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL
- audio_format_type_t format_type_tx;
+ uint8_t format_type_tx;
uint8_t n_channels_tx;
uint8_t n_bytes_per_sample_tx;
#endif
/*------------- From this point, data is not cleared by bus reset -------------*/
- // Buffer for control requests
- uint8_t *ctrl_buf;
- uint8_t ctrl_buf_sz;
-
// EP Transfer buffers and FIFOs
#if CFG_TUD_AUDIO_ENABLE_EP_OUT
tu_fifo_t ep_out_ff;
@@ -326,7 +313,11 @@ typedef struct
#define USE_LINEAR_BUFFER_RX 0
#endif
-#define ITF_MEM_RESET_SIZE offsetof(audiod_function_t, ctrl_buf)
+#if CFG_TUD_AUDIO_ENABLE_EP_OUT
+#define ITF_MEM_RESET_SIZE offsetof(audiod_function_t, ep_out_ff)
+#else
+#define ITF_MEM_RESET_SIZE offsetof(audiod_function_t, ep_in_ff)
+#endif
//--------------------------------------------------------------------+
// WEAK FUNCTION STUBS
@@ -362,11 +353,6 @@ TU_ATTR_WEAK void tud_audio_feedback_params_cb(uint8_t func_id, uint8_t alt_itf,
feedback_param->method = AUDIO_FEEDBACK_METHOD_DISABLED;
}
-TU_ATTR_WEAK bool tud_audio_feedback_format_correction_cb(uint8_t func_id) {
- (void) func_id;
- return CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION;
-}
-
TU_ATTR_WEAK TU_ATTR_FAST_FUNC void tud_audio_feedback_interval_isr(uint8_t func_id, uint32_t frame_number, uint8_t interval_shift) {
(void) func_id;
(void) frame_number;
@@ -375,7 +361,7 @@ TU_ATTR_WEAK TU_ATTR_FAST_FUNC void tud_audio_feedback_interval_isr(uint8_t func
#endif
#if CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
-TU_ATTR_WEAK void tud_audio_int_xfer_cb(uint8_t rhport) {
+TU_ATTR_WEAK void tud_audio_int_done_cb(uint8_t rhport) {
(void) rhport;
}
#endif
@@ -464,7 +450,7 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *p
static bool audiod_verify_entity_exists(uint8_t itf, uint8_t entityID, uint8_t *func_id);
static bool audiod_verify_itf_exists(uint8_t itf, uint8_t *func_id);
static bool audiod_verify_ep_exists(uint8_t ep, uint8_t *func_id);
-static uint8_t audiod_get_audio_fct_idx(audiod_function_t *audio);
+static inline uint8_t audiod_get_audio_fct_idx(audiod_function_t *audio);
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL
static void audiod_parse_flow_control_params(audiod_function_t *audio, uint8_t const *p_desc);
@@ -473,7 +459,7 @@ static uint16_t audiod_tx_packet_size(const uint16_t *norminal_size, uint16_t da
#endif
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
-static bool audiod_set_fb_params_freq(audiod_function_t *audio, uint32_t sample_freq, uint32_t mclk_freq);
+static bool audiod_fb_params_prepare(uint8_t func_id, uint8_t alt);
static void audiod_fb_fifo_count_update(audiod_function_t *audio, uint16_t lvl_new);
#endif
@@ -594,6 +580,10 @@ static bool audiod_tx_xfer_isr(uint8_t rhport, audiod_function_t * audio, uint16
#endif
+//--------------------------------------------------------------------+
+// OTHER API
+//--------------------------------------------------------------------+
+
#if CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
// If no interrupt transmit is pending bytes get written into buffer and a transmit is scheduled - once transmit completed tud_audio_int_done_cb() is called in inform user
bool tud_audio_int_n_write(uint8_t func_id, const audio_interrupt_data_t *data) {
@@ -604,10 +594,15 @@ bool tud_audio_int_n_write(uint8_t func_id, const audio_interrupt_data_t *data)
// We write directly into the EP's buffer - abort if previous transfer not complete
TU_VERIFY(usbd_edpt_claim(_audiod_fct[func_id].rhport, _audiod_fct[func_id].ep_int));
+ uint8_t size = tud_audio_n_version(func_id) == 2 ? sizeof(audio20_interrupt_data_t) : sizeof(audio10_interrupt_data_t);
+
+ // INT EP buffer must be large enough
+ TU_ASSERT(size <= sizeof(int_ep_buf[func_id].buf));
+
// Check length
- if (tu_memcpy_s(int_ep_buf[func_id].buf, sizeof(int_ep_buf[func_id].buf), data, sizeof(audio_interrupt_data_t)) == 0) {
+ if (tu_memcpy_s(int_ep_buf[func_id].buf, sizeof(int_ep_buf[func_id].buf), data, size) == 0) {
// Schedule transmit
- TU_ASSERT(usbd_edpt_xfer(_audiod_fct[func_id].rhport, _audiod_fct[func_id].ep_int, int_ep_buf[func_id].buf, sizeof(int_ep_buf[func_id].buf), false));
+ TU_ASSERT(usbd_edpt_xfer(_audiod_fct[func_id].rhport, _audiod_fct[func_id].ep_int, int_ep_buf[func_id].buf, size, false));
} else {
// Release endpoint since we don't make any transfer
usbd_edpt_release(_audiod_fct[func_id].rhport, _audiod_fct[func_id].ep_int);
@@ -619,10 +614,11 @@ bool tud_audio_int_n_write(uint8_t func_id, const audio_interrupt_data_t *data)
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
// This function is called once a transmit of a feedback packet was successfully completed. Here, we get the next feedback value to be sent
-static inline bool audiod_fb_send(audiod_function_t *audio, bool is_isr) {
- bool apply_correction = (TUSB_SPEED_FULL == tud_speed_get()) && audio->feedback.format_correction;
+static inline bool audiod_fb_send(uint8_t func_id, bool is_isr) {
+ audiod_function_t *audio = &_audiod_fct[func_id];
+ uint8_t uac_version = tud_audio_n_version(func_id);
// Format the feedback value
- if (apply_correction) {
+ if (uac_version == 1) {
uint8_t *fb = (uint8_t *) audio->fb_buf;
// For FS format is 10.14
@@ -647,10 +643,66 @@ static inline bool audiod_fb_send(audiod_function_t *audio, bool is_isr) {
// 10.14 3 3 Linux, OSX
//
// We send 3 bytes since sending packet larger than wMaxPacketSize is pretty ugly
- return usbd_edpt_xfer(audio->rhport, audio->ep_fb, (uint8_t *) audio->fb_buf, apply_correction ? 3 : 4, is_isr);
+ return usbd_edpt_xfer(audio->rhport, audio->ep_fb, (uint8_t *) audio->fb_buf, uac_version == 1 ? 3 : 4, is_isr);
+}
+
+uint32_t tud_audio_feedback_update(uint8_t func_id, uint32_t cycles) {
+ audiod_function_t *audio = &_audiod_fct[func_id];
+ uint32_t feedback;
+
+ switch (audio->feedback.compute_method) {
+ case AUDIO_FEEDBACK_METHOD_FREQUENCY_POWER_OF_2:
+ feedback = (cycles << audio->feedback.compute.power_of_2);
+ break;
+
+ case AUDIO_FEEDBACK_METHOD_FREQUENCY_FLOAT:
+ feedback = (uint32_t) ((float) cycles * audio->feedback.compute.float_const);
+ break;
+
+ case AUDIO_FEEDBACK_METHOD_FREQUENCY_FIXED: {
+ uint64_t fb64 = (((uint64_t) cycles) * audio->feedback.compute.fixed.sample_freq) << (16 - (audio->feedback.frame_shift - 1));
+ feedback = (uint32_t) (fb64 / audio->feedback.compute.fixed.mclk_freq);
+ } break;
+
+ default:
+ return 0;
+ }
+
+ // For Windows: https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/usb-2-0-audio-drivers
+ // The size of isochronous packets created by the device must be within the limits specified in FMT-2.0 section 2.3.1.1.
+ // This means that the deviation of actual packet size from nominal size must not exceed +/- one audio slot
+ // (audio slot = channel count samples).
+ if (feedback > audio->feedback.max_value) feedback = audio->feedback.max_value;
+ if (feedback < audio->feedback.min_value) feedback = audio->feedback.min_value;
+
+ tud_audio_n_fb_set(func_id, feedback);
+
+ return feedback;
+}
+
+bool tud_audio_n_fb_set(uint8_t func_id, uint32_t feedback) {
+ TU_VERIFY(func_id < CFG_TUD_AUDIO && _audiod_fct[func_id].p_desc != NULL);
+
+ _audiod_fct[func_id].feedback.value = feedback;
+
+ return true;
}
#endif
+uint8_t tud_audio_n_version(uint8_t func_id) {
+ TU_VERIFY(func_id < CFG_TUD_AUDIO && _audiod_fct[func_id].p_desc != NULL);
+
+ uint8_t bIntfProtocol = ((tusb_desc_interface_t const *)_audiod_fct[func_id].p_desc)->bInterfaceProtocol;
+
+ if (bIntfProtocol == AUDIO_INT_PROTOCOL_CODE_V1) {
+ return 1;
+ } else if (bIntfProtocol == AUDIO_INT_PROTOCOL_CODE_V2) {
+ return 2;
+ } else {
+ return 0; // Unknown version
+ }
+}
+
//--------------------------------------------------------------------+
// USBD Driver API
//--------------------------------------------------------------------+
@@ -660,26 +712,6 @@ void audiod_init(void) {
for (uint8_t i = 0; i < CFG_TUD_AUDIO; i++) {
audiod_function_t *audio = &_audiod_fct[i];
- // Initialize control buffers
- switch (i) {
- case 0:
- audio->ctrl_buf = ctrl_buf.buf1;
- audio->ctrl_buf_sz = CFG_TUD_AUDIO_FUNC_1_CTRL_BUF_SZ;
- break;
-#if CFG_TUD_AUDIO > 1 && CFG_TUD_AUDIO_FUNC_2_CTRL_BUF_SZ > 0
- case 1:
- audio->ctrl_buf = ctrl_buf.buf2;
- audio->ctrl_buf_sz = CFG_TUD_AUDIO_FUNC_2_CTRL_BUF_SZ;
- break;
-#endif
-#if CFG_TUD_AUDIO > 2 && CFG_TUD_AUDIO_FUNC_3_CTRL_BUF_SZ > 0
- case 2:
- audio->ctrl_buf = ctrl_buf.buf3;
- audio->ctrl_buf_sz = CFG_TUD_AUDIO_FUNC_3_CTRL_BUF_SZ;
- break;
-#endif
- }
-
// Initialize IN EP FIFO if required
#if CFG_TUD_AUDIO_ENABLE_EP_IN
@@ -816,7 +848,8 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint
AUDIO_SUBCLASS_CONTROL == itf_desc->bInterfaceSubClass);
// Verify version is correct - this check can be omitted
- TU_VERIFY(itf_desc->bInterfaceProtocol == AUDIO_INT_PROTOCOL_CODE_V2);
+ TU_VERIFY(itf_desc->bInterfaceProtocol == AUDIO_INT_PROTOCOL_CODE_V1 ||
+ itf_desc->bInterfaceProtocol == AUDIO_INT_PROTOCOL_CODE_V2);
// Verify interrupt control EP is enabled if demanded by descriptor
TU_ASSERT(itf_desc->bNumEndpoints <= 1);// 0 or 1 EPs are allowed
@@ -834,21 +867,30 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint
_audiod_fct[i].p_desc = (uint8_t const *) itf_desc;// Save pointer to AC descriptor which is by specification always the first one
_audiod_fct[i].rhport = rhport;
- // Setup descriptor lengths
- switch (i) {
- case 0:
- _audiod_fct[i].desc_length = CFG_TUD_AUDIO_FUNC_1_DESC_LEN;
- break;
-#if CFG_TUD_AUDIO > 1
- case 1:
- _audiod_fct[i].desc_length = CFG_TUD_AUDIO_FUNC_2_DESC_LEN;
- break;
-#endif
-#if CFG_TUD_AUDIO > 2
- case 2:
- _audiod_fct[i].desc_length = CFG_TUD_AUDIO_FUNC_3_DESC_LEN;
- break;
-#endif
+ // Calculate descriptor length
+ {
+ uint8_t const *p_desc = (uint8_t const *) itf_desc;
+ uint8_t const *p_desc_end = p_desc + max_len;
+ uint16_t total_len = sizeof(tusb_desc_interface_t);
+ // Skip Standard AC interface descriptor
+ p_desc = tu_desc_next(p_desc);
+ while (p_desc_end - p_desc > 0) {
+ // Stop if:
+ // - Non audio streaming interface descriptor found
+ // - IAD found
+ if ((tu_desc_type(p_desc) == TUSB_DESC_INTERFACE &&
+ !(((tusb_desc_interface_t const *) p_desc)->bInterfaceClass == TUSB_CLASS_AUDIO && ((tusb_desc_interface_t const *) p_desc)->bInterfaceSubClass == AUDIO_SUBCLASS_STREAMING))
+ || tu_desc_type(p_desc) == TUSB_DESC_INTERFACE_ASSOCIATION) {
+ break;
+ } else if (tu_desc_type(p_desc) == TUSB_DESC_INTERFACE && ((tusb_desc_interface_t const *) p_desc)->bInterfaceSubClass == AUDIO_SUBCLASS_STREAMING) {
+ if (_audiod_fct[i].p_desc_as == 0) {
+ _audiod_fct[i].p_desc_as = p_desc;
+ }
+ }
+ total_len += p_desc[0];
+ p_desc = tu_desc_next(p_desc);
+ }
+ _audiod_fct[i].desc_length = total_len;
}
#ifdef TUP_DCD_EDPT_ISO_ALLOC
@@ -867,35 +909,48 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint
uint8_t ep_fb = 0;
#endif
uint8_t const *p_desc = _audiod_fct[i].p_desc;
- uint8_t const *p_desc_end = p_desc + _audiod_fct[i].desc_length - TUD_AUDIO_DESC_IAD_LEN;
+ uint8_t const *p_desc_end = p_desc + _audiod_fct[i].desc_length;
// Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
while (p_desc_end - p_desc > 0) {
if (tu_desc_type(p_desc) == TUSB_DESC_ENDPOINT) {
+ // Unified UAC1/UAC2 endpoint processing
tusb_desc_endpoint_t const *desc_ep = (tusb_desc_endpoint_t const *) p_desc;
- if (desc_ep->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS) {
- #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
- // Explicit feedback EP
- if (desc_ep->bmAttributes.usage == 1) {
- ep_fb = desc_ep->bEndpointAddress;
- }
- #endif
- #if CFG_TUD_AUDIO_ENABLE_EP_IN
- // Data or data with implicit feedback IN EP
- if (tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_IN
- && (desc_ep->bmAttributes.usage == 0 || desc_ep->bmAttributes.usage == 2)) {
- ep_in = desc_ep->bEndpointAddress;
- ep_in_size = TU_MAX(tu_edpt_packet_size(desc_ep), ep_in_size);
- }
- #endif
- #if CFG_TUD_AUDIO_ENABLE_EP_OUT
- // Data OUT EP
- if (tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_OUT
- && desc_ep->bmAttributes.usage == 0) {
- ep_out = desc_ep->bEndpointAddress;
- ep_out_size = TU_MAX(tu_edpt_packet_size(desc_ep), ep_out_size);
- }
- #endif
+ bool is_feedback_ep = false;
+ bool is_data_ep = false;
+
+ if (tud_audio_n_version(i) == 1) {
+ // UAC1: Use bRefresh field to distinguish endpoint types
+ audio10_desc_as_iso_data_ep_t const *desc_ep_uac1 = (audio10_desc_as_iso_data_ep_t const *) p_desc;
+ is_data_ep = (desc_ep_uac1->bmAttributes.sync != TUSB_ISO_EP_ATT_NO_SYNC);
+ is_feedback_ep = (desc_ep_uac1->bmAttributes.sync == TUSB_ISO_EP_ATT_NO_SYNC);
+ } else {
+ // UAC2: Use bmAttributes.usage to distinguish endpoint types
+ is_data_ep = (desc_ep->bmAttributes.usage == 0 || desc_ep->bmAttributes.usage == 2);
+ is_feedback_ep = (desc_ep->bmAttributes.usage == 1);
+ }
+
+ #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
+ // Explicit feedback EP
+ if (is_feedback_ep) {
+ ep_fb = desc_ep->bEndpointAddress;
+ }
+ #else
+ (void) is_feedback_ep;
+ #endif
+ #if CFG_TUD_AUDIO_ENABLE_EP_IN
+ // Data or data with implicit feedback IN EP
+ if (tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_IN && is_data_ep) {
+ ep_in = desc_ep->bEndpointAddress;
+ ep_in_size = TU_MAX(tu_edpt_packet_size(desc_ep), ep_in_size);
+ }
+ #endif
+ #if CFG_TUD_AUDIO_ENABLE_EP_OUT
+ // Data OUT EP
+ if (tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_OUT && is_data_ep) {
+ ep_out = desc_ep->bEndpointAddress;
+ ep_out_size = TU_MAX(tu_edpt_packet_size(desc_ep), ep_out_size);
}
+ #endif
}
p_desc = tu_desc_next(p_desc);
@@ -924,19 +979,22 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL
{
uint8_t const *p_desc = _audiod_fct[i].p_desc;
- uint8_t const *p_desc_end = p_desc + _audiod_fct[i].desc_length - TUD_AUDIO_DESC_IAD_LEN;
+ uint8_t const *p_desc_end = p_desc + _audiod_fct[i].desc_length;
// Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
while (p_desc_end - p_desc > 0) {
if (tu_desc_type(p_desc) == TUSB_DESC_ENDPOINT) {
tusb_desc_endpoint_t const *desc_ep = (tusb_desc_endpoint_t const *) p_desc;
if (desc_ep->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS) {
// For data or data with implicit feedback IN EP
+ // For UAC1 this is always the case since there is no usage field
if (tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_IN
&& (desc_ep->bmAttributes.usage == 0 || desc_ep->bmAttributes.usage == 2)) {
_audiod_fct[i].interval_tx = desc_ep->bInterval;
}
}
- } else if (tu_desc_type(p_desc) == TUSB_DESC_CS_INTERFACE && tu_desc_subtype(p_desc) == AUDIO_CS_AC_INTERFACE_OUTPUT_TERMINAL) {
+ } else if (tud_audio_n_version(i) == 2 &&
+ tu_desc_type(p_desc) == TUSB_DESC_CS_INTERFACE && tu_desc_subtype(p_desc) == AUDIO20_CS_AC_INTERFACE_OUTPUT_TERMINAL) {
+ // For UAC2 only, UAC1 doesn't have a clock source
if (tu_unaligned_read16(p_desc + 4) == AUDIO_TERM_TYPE_USB_STREAMING) {
_audiod_fct[i].bclock_id_tx = p_desc[8];
}
@@ -949,7 +1007,7 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint
#if CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
{
uint8_t const *p_desc = _audiod_fct[i].p_desc;
- uint8_t const *p_desc_end = p_desc + _audiod_fct[i].desc_length - TUD_AUDIO_DESC_IAD_LEN;
+ uint8_t const *p_desc_end = p_desc + _audiod_fct[i].desc_length;
// Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
while (p_desc_end - p_desc > 0) {
// For each endpoint
@@ -977,7 +1035,7 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint
TU_ASSERT(i < CFG_TUD_AUDIO);
// This is all we need so far - the EPs are setup by a later set_interface request (as per UAC2 specification)
- uint16_t drv_len = _audiod_fct[i].desc_length - TUD_AUDIO_DESC_IAD_LEN;// - TUD_AUDIO_DESC_IAD_LEN since tinyUSB already handles the IAD descriptor
+ uint16_t drv_len = _audiod_fct[i].desc_length;
return drv_len;
}
@@ -1087,11 +1145,10 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *p
#endif// CFG_TUD_AUDIO_ENABLE_EP_OUT
// Open new EP if necessary - EPs are only to be closed or opened for AS interfaces - Look for AS interface with correct alternate interface
- uint8_t const *p_desc = tu_desc_next(audio->p_desc);
- // Skip entire AC descriptor block
- p_desc += ((audio_desc_cs_ac_interface_t const *) p_desc)->wTotalLength;
+
+ uint8_t const *p_desc = audio->p_desc_as;
// Get pointer at end
- uint8_t const *p_desc_end = audio->p_desc + audio->desc_length - TUD_AUDIO_DESC_IAD_LEN;
+ uint8_t const *p_desc_end = audio->p_desc + audio->desc_length;
// p_desc starts at required interface with alternate setting zero
// Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
@@ -1114,12 +1171,26 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *p
#endif
uint8_t const ep_addr = desc_ep->bEndpointAddress;
+ bool is_feedback_ep = false;
+ bool is_data_ep = false;
+
+ if (tud_audio_n_version(func_id) == 1) {
+ // UAC1: Use bRefresh field to distinguish endpoint types
+ audio10_desc_as_iso_data_ep_t const *desc_ep_uac1 = (audio10_desc_as_iso_data_ep_t const *) p_desc;
+ is_data_ep = (desc_ep_uac1->bmAttributes.sync != TUSB_ISO_EP_ATT_NO_SYNC);
+ is_feedback_ep = (desc_ep_uac1->bmAttributes.sync == TUSB_ISO_EP_ATT_NO_SYNC);
+ } else {
+ // UAC2: Use bmAttributes.usage to distinguish endpoint types
+ is_data_ep = (desc_ep->bmAttributes.usage == 0 || desc_ep->bmAttributes.usage == 2);
+ is_feedback_ep = (desc_ep->bmAttributes.usage == 1);
+ }
+
//TODO: We need to set EP non busy since this is not taken care of right now in ep_close() - THIS IS A WORKAROUND!
usbd_edpt_clear_stall(rhport, ep_addr);
#if CFG_TUD_AUDIO_ENABLE_EP_IN
// For data or data with implicit feedback IN EP
- if (tu_edpt_dir(ep_addr) == TUSB_DIR_IN && (desc_ep->bmAttributes.usage == 0 || desc_ep->bmAttributes.usage == 2))
+ if (tu_edpt_dir(ep_addr) == TUSB_DIR_IN && is_data_ep)
{
// Save address
audio->ep_in = ep_addr;
@@ -1143,7 +1214,7 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *p
#if CFG_TUD_AUDIO_ENABLE_EP_OUT
// Checking usage not necessary
- if (tu_edpt_dir(ep_addr) == TUSB_DIR_OUT) {
+ if (tu_edpt_dir(ep_addr) == TUSB_DIR_OUT && is_data_ep) {
// Save address
audio->ep_out = ep_addr;
audio->ep_out_as_intf_num = itf;
@@ -1160,13 +1231,17 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *p
#if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
// Check if usage is explicit data feedback
- if (tu_edpt_dir(ep_addr) == TUSB_DIR_IN && desc_ep->bmAttributes.usage == 1) {
+ if (is_feedback_ep) {
audio->ep_fb = ep_addr;
audio->feedback.frame_shift = desc_ep->bInterval - 1;
// Schedule first feedback transmit
- audiod_fb_send(audio, false);
+ audiod_fb_send(func_id, false);
}
+ #else
+ (void) is_feedback_ep;
#endif
+#else
+ (void) is_feedback_ep;
#endif// CFG_TUD_AUDIO_ENABLE_EP_OUT
foundEPs += 1;
@@ -1180,50 +1255,8 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *p
TU_VERIFY(tud_audio_set_itf_cb(rhport, p_request));
#if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
- // Prepare feedback computation if endpoint is available
- if (audio->ep_fb != 0) {
- audio_feedback_params_t fb_param;
-
- tud_audio_feedback_params_cb(func_id, alt, &fb_param);
- audio->feedback.compute_method = fb_param.method;
-
- if (TUSB_SPEED_FULL == tud_speed_get())
- audio->feedback.format_correction = tud_audio_feedback_format_correction_cb(func_id);
-
- // Minimal/Maximum value in 16.16 format for full speed (1ms per frame) or high speed (125 us per frame)
- uint32_t const frame_div = (TUSB_SPEED_FULL == tud_speed_get()) ? 1000 : 8000;
- audio->feedback.min_value = ((fb_param.sample_freq - 1) / frame_div) << 16;
- audio->feedback.max_value = (fb_param.sample_freq / frame_div + 1) << 16;
-
- switch (fb_param.method) {
- case AUDIO_FEEDBACK_METHOD_FREQUENCY_FIXED:
- case AUDIO_FEEDBACK_METHOD_FREQUENCY_FLOAT:
- case AUDIO_FEEDBACK_METHOD_FREQUENCY_POWER_OF_2:
- audiod_set_fb_params_freq(audio, fb_param.sample_freq, fb_param.frequency.mclk_freq);
- break;
-
- case AUDIO_FEEDBACK_METHOD_FIFO_COUNT: {
- // Initialize the threshold level to half filled
- uint16_t fifo_lvl_thr = tu_fifo_depth(&audio->ep_out_ff) / 2;
- audio->feedback.compute.fifo_count.fifo_lvl_thr = fifo_lvl_thr;
- audio->feedback.compute.fifo_count.fifo_lvl_avg = ((uint32_t) fifo_lvl_thr) << 16;
- // Avoid 64bit division
- uint32_t nominal = ((fb_param.sample_freq / 100) << 16) / (frame_div / 100);
- audio->feedback.compute.fifo_count.nom_value = nominal;
- audio->feedback.compute.fifo_count.rate_const[0] = (uint16_t) ((audio->feedback.max_value - nominal) / fifo_lvl_thr);
- audio->feedback.compute.fifo_count.rate_const[1] = (uint16_t) ((nominal - audio->feedback.min_value) / fifo_lvl_thr);
- // On HS feedback is more sensitive since packet size can vary every MSOF, could cause instability
- if (tud_speed_get() == TUSB_SPEED_HIGH) {
- audio->feedback.compute.fifo_count.rate_const[0] /= 8;
- audio->feedback.compute.fifo_count.rate_const[1] /= 8;
- }
- } break;
-
- // nothing to do
- default:
- break;
- }
- }
+ // Prepare feedback computation parameters
+ TU_VERIFY(audiod_fb_params_prepare(func_id, alt));
#endif// CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
// We are done - abort loop
@@ -1275,20 +1308,23 @@ static bool audiod_control_complete(uint8_t rhport, tusb_control_request_t const
TU_VERIFY(audiod_verify_entity_exists(itf, entityID, &func_id));
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL
- uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
- if (_audiod_fct[func_id].bclock_id_tx == entityID && ctrlSel == AUDIO_CS_CTRL_SAM_FREQ && p_request->bRequest == AUDIO_CS_REQ_CUR) {
- _audiod_fct[func_id].sample_rate_tx = tu_unaligned_read32(_audiod_fct[func_id].ctrl_buf);
+ if (tud_audio_n_version(func_id) == 2) {
+ uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
+ if (_audiod_fct[func_id].bclock_id_tx == entityID && ctrlSel == AUDIO20_CS_CTRL_SAM_FREQ && p_request->bRequest == AUDIO20_CS_REQ_CUR) {
+ _audiod_fct[func_id].sample_rate_tx = tu_unaligned_read32(ctrl_buf);
+ audiod_calc_tx_packet_sz(&_audiod_fct[func_id]);
+ }
}
#endif
// Invoke callback
- return tud_audio_set_req_entity_cb(rhport, p_request, _audiod_fct[func_id].ctrl_buf);
+ return tud_audio_set_req_entity_cb(rhport, p_request, ctrl_buf);
} else {
// Find index of audio driver structure and verify interface really exists
TU_VERIFY(audiod_verify_itf_exists(itf, &func_id));
// Invoke callback
- return tud_audio_set_req_itf_cb(rhport, p_request, _audiod_fct[func_id].ctrl_buf);
+ return tud_audio_set_req_itf_cb(rhport, p_request, ctrl_buf);
}
} break;
@@ -1298,8 +1334,32 @@ static bool audiod_control_complete(uint8_t rhport, tusb_control_request_t const
// Check if entity is present and get corresponding driver index
TU_VERIFY(audiod_verify_ep_exists(ep, &func_id));
- // Invoke callback
- return tud_audio_set_req_ep_cb(rhport, p_request, _audiod_fct[func_id].ctrl_buf);
+#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL
+ if (tud_audio_n_version(func_id) == 1) {
+ if (_audiod_fct[func_id].ep_in == ep) {
+ uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
+ if (ctrlSel == AUDIO10_EP_CTRL_SAMPLING_FREQ && p_request->bRequest == AUDIO10_CS_REQ_SET_CUR) {
+ _audiod_fct[func_id].sample_rate_tx = tu_unaligned_read32(ctrl_buf) & 0x00FFFFFF;
+ audiod_calc_tx_packet_sz(&_audiod_fct[func_id]);
+ }
+ }
+ }
+#endif
+
+ // Invoke callback
+ bool ret = tud_audio_set_req_ep_cb(rhport, p_request, ctrl_buf);
+
+#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
+ if (ret && tud_audio_n_version(func_id) == 1) {
+ if (_audiod_fct[func_id].ep_out == ep) {
+ uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
+ if (ctrlSel == AUDIO10_EP_CTRL_SAMPLING_FREQ && p_request->bRequest == AUDIO10_CS_REQ_SET_CUR) {
+ audiod_fb_params_prepare(func_id, _audiod_fct[func_id].ep_out_alt);
+ }
+ }
+ }
+#endif
+ return ret;
} break;
// Unknown/Unsupported recipient
default:
@@ -1384,7 +1444,7 @@ static bool audiod_control_request(uint8_t rhport, tusb_control_request_t const
}
// If we end here, the received request is a set request - we schedule a receive for the data stage and return true here. We handle the rest later in audiod_control_complete() once the data stage was finished
- TU_VERIFY(tud_control_xfer(rhport, p_request, _audiod_fct[func_id].ctrl_buf, _audiod_fct[func_id].ctrl_buf_sz));
+ TU_VERIFY(tud_control_xfer(rhport, p_request, ctrl_buf, sizeof(ctrl_buf)));
return true;
}
@@ -1421,7 +1481,7 @@ bool audiod_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint3
// I assume here, that things above are handled by PHY
// All transmission is done - what remains to do is to inform job was completed
- tud_audio_int_xfer_cb(rhport);
+ tud_audio_int_done_cb(rhport);
return true;
}
@@ -1472,7 +1532,7 @@ bool audiod_xfer_isr(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
if (audio->ep_fb == ep_addr) {
// Schedule a transmit with the new value if EP is not busy
// Schedule next transmission - value is changed bytud_audio_n_fb_set() in the meantime or the old value gets sent
- audiod_fb_send(audio, true);
+ audiod_fb_send(func_id, true);
return true;
}
#endif
@@ -1484,30 +1544,72 @@ bool audiod_xfer_isr(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
-static bool audiod_set_fb_params_freq(audiod_function_t *audio, uint32_t sample_freq, uint32_t mclk_freq) {
- // Check if frame interval is within sane limits
- // The interval value n_frames was taken from the descriptors within audiod_set_interface()
+static bool audiod_fb_params_prepare(uint8_t func_id, uint8_t alt) {
+ audiod_function_t *audio = &_audiod_fct[func_id];
- // n_frames_min is ceil(2^10 * f_s / f_m) for full speed and ceil(2^13 * f_s / f_m) for high speed
- // this lower limit ensures the measures feedback value has sufficient precision
- uint32_t const k = (TUSB_SPEED_FULL == tud_speed_get()) ? 10 : 13;
- uint32_t const n_frame = (1UL << audio->feedback.frame_shift);
+ // Prepare feedback computation if endpoint is available
+ if (audio->ep_fb != 0) {
+ audio_feedback_params_t fb_param;
- if ((((1UL << k) * sample_freq / mclk_freq) + 1) > n_frame) {
- TU_LOG1(" UAC2 feedback interval too small\r\n");
- TU_BREAKPOINT();
- return false;
- }
+ tud_audio_feedback_params_cb(func_id, alt, &fb_param);
+ audio->feedback.compute_method = fb_param.method;
- // Check if parameters really allow for a power of two division
- if ((mclk_freq % sample_freq) == 0 && tu_is_power_of_two(mclk_freq / sample_freq)) {
- audio->feedback.compute_method = AUDIO_FEEDBACK_METHOD_FREQUENCY_POWER_OF_2;
- audio->feedback.compute.power_of_2 = (uint8_t) (16 - (audio->feedback.frame_shift - 1) - tu_log2(mclk_freq / sample_freq));
- } else if (audio->feedback.compute_method == AUDIO_FEEDBACK_METHOD_FREQUENCY_FLOAT) {
- audio->feedback.compute.float_const = (float) sample_freq / (float) mclk_freq * (1UL << (16 - (audio->feedback.frame_shift - 1)));
- } else {
- audio->feedback.compute.fixed.sample_freq = sample_freq;
- audio->feedback.compute.fixed.mclk_freq = mclk_freq;
+ // Minimal/Maximum value in 16.16 format for full speed (1ms per frame) or high speed (125 us per frame)
+ uint32_t const frame_div = (TUSB_SPEED_FULL == tud_speed_get()) ? 1000 : 8000;
+ audio->feedback.min_value = ((fb_param.sample_freq - 1) / frame_div) << 16;
+ audio->feedback.max_value = (fb_param.sample_freq / frame_div + 1) << 16;
+
+ switch (fb_param.method) {
+ case AUDIO_FEEDBACK_METHOD_FREQUENCY_FIXED:
+ case AUDIO_FEEDBACK_METHOD_FREQUENCY_FLOAT:
+ case AUDIO_FEEDBACK_METHOD_FREQUENCY_POWER_OF_2: {
+ // Check if frame interval is within sane limits
+ // The interval value n_frames was taken from the descriptors within audiod_set_interface()
+
+ // n_frames_min is ceil(2^10 * f_s / f_m) for full speed and ceil(2^13 * f_s / f_m) for high speed
+ // this lower limit ensures the measures feedback value has sufficient precision
+ uint32_t const k = (TUSB_SPEED_FULL == tud_speed_get()) ? 10 : 13;
+ uint32_t const n_frame = (1UL << audio->feedback.frame_shift);
+
+ if ((((1UL << k) * fb_param.sample_freq / fb_param.frequency.mclk_freq) + 1) > n_frame) {
+ TU_LOG1(" UAC2 feedback interval too small\r\n");
+ TU_BREAKPOINT();
+ return false;
+ }
+
+ // Check if parameters really allow for a power of two division
+ if ((fb_param.frequency.mclk_freq % fb_param.sample_freq) == 0 && tu_is_power_of_two(fb_param.frequency.mclk_freq / fb_param.sample_freq)) {
+ audio->feedback.compute_method = AUDIO_FEEDBACK_METHOD_FREQUENCY_POWER_OF_2;
+ audio->feedback.compute.power_of_2 = (uint8_t) (16 - (audio->feedback.frame_shift - 1) - tu_log2(fb_param.frequency.mclk_freq / fb_param.sample_freq));
+ } else if (audio->feedback.compute_method == AUDIO_FEEDBACK_METHOD_FREQUENCY_FLOAT) {
+ audio->feedback.compute.float_const = (float) fb_param.sample_freq / (float) fb_param.frequency.mclk_freq * (1UL << (16 - (audio->feedback.frame_shift - 1)));
+ } else {
+ audio->feedback.compute.fixed.sample_freq = fb_param.sample_freq;
+ audio->feedback.compute.fixed.mclk_freq = fb_param.frequency.mclk_freq;
+ }
+ } break;
+
+ case AUDIO_FEEDBACK_METHOD_FIFO_COUNT: {
+ // Initialize the threshold level to half filled
+ uint16_t fifo_lvl_thr = tu_fifo_depth(&audio->ep_out_ff) / 2;
+ audio->feedback.compute.fifo_count.fifo_lvl_thr = fifo_lvl_thr;
+ audio->feedback.compute.fifo_count.fifo_lvl_avg = ((uint32_t) fifo_lvl_thr) << 16;
+ // Avoid 64bit division
+ uint32_t nominal = ((fb_param.sample_freq / 100) << 16) / (frame_div / 100);
+ audio->feedback.compute.fifo_count.nom_value = nominal;
+ audio->feedback.compute.fifo_count.rate_const[0] = (uint16_t) ((audio->feedback.max_value - nominal) / fifo_lvl_thr);
+ audio->feedback.compute.fifo_count.rate_const[1] = (uint16_t) ((nominal - audio->feedback.min_value) / fifo_lvl_thr);
+ // On HS feedback is more sensitive since packet size can vary every MSOF, could cause instability
+ if (tud_speed_get() == TUSB_SPEED_HIGH) {
+ audio->feedback.compute.fifo_count.rate_const[0] /= 8;
+ audio->feedback.compute.fifo_count.rate_const[1] /= 8;
+ }
+ } break;
+
+ // nothing to do
+ default:
+ break;
+ }
}
return true;
@@ -1536,47 +1638,6 @@ static void audiod_fb_fifo_count_update(audiod_function_t *audio, uint16_t lvl_n
audio->feedback.value = feedback;
}
-uint32_t tud_audio_feedback_update(uint8_t func_id, uint32_t cycles) {
- audiod_function_t *audio = &_audiod_fct[func_id];
- uint32_t feedback;
-
- switch (audio->feedback.compute_method) {
- case AUDIO_FEEDBACK_METHOD_FREQUENCY_POWER_OF_2:
- feedback = (cycles << audio->feedback.compute.power_of_2);
- break;
-
- case AUDIO_FEEDBACK_METHOD_FREQUENCY_FLOAT:
- feedback = (uint32_t) ((float) cycles * audio->feedback.compute.float_const);
- break;
-
- case AUDIO_FEEDBACK_METHOD_FREQUENCY_FIXED: {
- uint64_t fb64 = (((uint64_t) cycles) * audio->feedback.compute.fixed.sample_freq) << (16 - (audio->feedback.frame_shift - 1));
- feedback = (uint32_t) (fb64 / audio->feedback.compute.fixed.mclk_freq);
- } break;
-
- default:
- return 0;
- }
-
- // For Windows: https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/usb-2-0-audio-drivers
- // The size of isochronous packets created by the device must be within the limits specified in FMT-2.0 section 2.3.1.1.
- // This means that the deviation of actual packet size from nominal size must not exceed +/- one audio slot
- // (audio slot = channel count samples).
- if (feedback > audio->feedback.max_value) feedback = audio->feedback.max_value;
- if (feedback < audio->feedback.min_value) feedback = audio->feedback.min_value;
-
- tud_audio_n_fb_set(func_id, feedback);
-
- return feedback;
-}
-
-bool tud_audio_n_fb_set(uint8_t func_id, uint32_t feedback) {
- TU_VERIFY(func_id < CFG_TUD_AUDIO && _audiod_fct[func_id].p_desc != NULL);
-
- _audiod_fct[func_id].feedback.value = feedback;
-
- return true;
-}
#endif
TU_ATTR_FAST_FUNC void audiod_sof_isr(uint8_t rhport, uint32_t frame_count) {
@@ -1644,24 +1705,27 @@ bool tud_audio_buffer_and_schedule_control_xfer(uint8_t rhport, tusb_control_req
}
// Crop length
- if (len > _audiod_fct[func_id].ctrl_buf_sz) len = _audiod_fct[func_id].ctrl_buf_sz;
+ if (len > sizeof(ctrl_buf)) len = sizeof(ctrl_buf);
// Copy into buffer
- TU_VERIFY(0 == tu_memcpy_s(_audiod_fct[func_id].ctrl_buf, _audiod_fct[func_id].ctrl_buf_sz, data, (size_t) len));
+ TU_VERIFY(0 == tu_memcpy_s(ctrl_buf, sizeof(ctrl_buf), data, (size_t) len));
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL
- // Find data for sampling_frequency_control
- if (p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS && p_request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE) {
- uint8_t entityID = TU_U16_HIGH(p_request->wIndex);
- uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
- if (_audiod_fct[func_id].bclock_id_tx == entityID && ctrlSel == AUDIO_CS_CTRL_SAM_FREQ && p_request->bRequest == AUDIO_CS_REQ_CUR) {
- _audiod_fct[func_id].sample_rate_tx = tu_unaligned_read32(_audiod_fct[func_id].ctrl_buf);
+ if (tud_audio_n_version(func_id) == 2) {
+ // Find data for sampling_frequency_control
+ if (p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS && p_request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE) {
+ uint8_t entityID = TU_U16_HIGH(p_request->wIndex);
+ uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
+ if (_audiod_fct[func_id].bclock_id_tx == entityID && ctrlSel == AUDIO20_CS_CTRL_SAM_FREQ && p_request->bRequest == AUDIO20_CS_REQ_CUR) {
+ _audiod_fct[func_id].sample_rate_tx = tu_unaligned_read32(ctrl_buf);
+ audiod_calc_tx_packet_sz(&_audiod_fct[func_id]);
+ }
}
}
#endif
// Schedule transmit
- return tud_control_xfer(rhport, p_request, (void *) _audiod_fct[func_id].ctrl_buf, len);
+ return tud_control_xfer(rhport, p_request, ctrl_buf, len);
}
// Verify an entity with the given ID exists and returns also the corresponding driver index
@@ -1672,11 +1736,9 @@ static bool audiod_verify_entity_exists(uint8_t itf, uint8_t entityID, uint8_t *
if (_audiod_fct[i].p_desc && ((tusb_desc_interface_t const *) _audiod_fct[i].p_desc)->bInterfaceNumber == itf) {
// Get pointers after class specific AC descriptors and end of AC descriptors - entities are defined in between
uint8_t const *p_desc = tu_desc_next(_audiod_fct[i].p_desc);// Points to CS AC descriptor
- uint8_t const *p_desc_end = ((audio_desc_cs_ac_interface_t const *) p_desc)->wTotalLength + p_desc;
p_desc = tu_desc_next(p_desc);// Get past CS AC descriptor
- // Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
- while (p_desc_end - p_desc > 0) {
+ while (_audiod_fct[i].p_desc_as - p_desc > 0) {
// Entity IDs are always at offset 3
if (p_desc[3] == entityID) {
*func_id = i;
@@ -1695,7 +1757,7 @@ static bool audiod_verify_itf_exists(uint8_t itf, uint8_t *func_id) {
if (_audiod_fct[i].p_desc) {
// Get pointer at beginning and end
uint8_t const *p_desc = _audiod_fct[i].p_desc;
- uint8_t const *p_desc_end = _audiod_fct[i].p_desc + _audiod_fct[i].desc_length - TUD_AUDIO_DESC_IAD_LEN;
+ uint8_t const *p_desc_end = _audiod_fct[i].p_desc + _audiod_fct[i].desc_length;
// Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
while (p_desc_end - p_desc > 0) {
if (tu_desc_type(p_desc) == TUSB_DESC_INTERFACE && ((tusb_desc_interface_t const *)p_desc)->bInterfaceNumber == itf) {
@@ -1717,8 +1779,7 @@ static bool audiod_verify_ep_exists(uint8_t ep, uint8_t *func_id) {
uint8_t const *p_desc_end = _audiod_fct[i].p_desc + _audiod_fct[i].desc_length;
// Advance past AC descriptors - EP we look for are streaming EPs
- uint8_t const *p_desc = tu_desc_next(_audiod_fct[i].p_desc);
- p_desc += ((audio_desc_cs_ac_interface_t const *) p_desc)->wTotalLength;
+ uint8_t const *p_desc = _audiod_fct[i].p_desc_as;
// Condition modified from p_desc < p_desc_end to prevent gcc>=12 strict-overflow warning
while (p_desc_end - p_desc > 0) {
@@ -1738,20 +1799,34 @@ static void audiod_parse_flow_control_params(audiod_function_t *audio, uint8_t c
p_desc = tu_desc_next(p_desc);// Exclude standard AS interface descriptor of current alternate interface descriptor
- // Look for a Class-Specific AS Interface Descriptor(4.9.2) to verify format type and format and also to get number of physical channels
- if (tu_desc_type(p_desc) == TUSB_DESC_CS_INTERFACE && tu_desc_subtype(p_desc) == AUDIO_CS_AS_INTERFACE_AS_GENERAL) {
- audio->n_channels_tx = ((audio_desc_cs_as_interface_t const *) p_desc)->bNrChannels;
- audio->format_type_tx = (audio_format_type_t) (((audio_desc_cs_as_interface_t const *) p_desc)->bFormatType);
- // Look for a Type I Format Type Descriptor(2.3.1.6 - Audio Formats)
- p_desc = tu_desc_next(p_desc);
- if (tu_desc_type(p_desc) == TUSB_DESC_CS_INTERFACE && tu_desc_subtype(p_desc) == AUDIO_CS_AS_INTERFACE_FORMAT_TYPE && ((audio_desc_type_I_format_t const *) p_desc)->bFormatType == AUDIO_FORMAT_TYPE_I) {
- audio->n_bytes_per_sample_tx = ((audio_desc_type_I_format_t const *) p_desc)->bSubslotSize;
+ if (tud_audio_n_version(audiod_get_audio_fct_idx(audio)) == 1) {
+ p_desc = tu_desc_next(p_desc);// Exclude Class-Specific AS Interface Descriptor(4.5.2) to get to format type descriptor
+ if (tu_desc_type(p_desc) == TUSB_DESC_CS_INTERFACE && tu_desc_subtype(p_desc) == AUDIO10_CS_AS_INTERFACE_FORMAT_TYPE) {
+ audio->format_type_tx = ((audio10_desc_type_I_format_n_t(1) const *) p_desc)->bFormatType;
+ if (audio->format_type_tx == AUDIO10_FORMAT_TYPE_I) {
+ audio->n_channels_tx = ((audio10_desc_type_I_format_n_t(1) const *) p_desc)->bNrChannels;
+ audio->n_bytes_per_sample_tx = ((audio10_desc_type_I_format_n_t(1) const *) p_desc)->bSubFrameSize;
+ // Save sample rate - needed when EP doesn't support setting sample rate
+ audio->sample_rate_tx = tu_unaligned_read32(((audio10_desc_type_I_format_n_t(1) const *) p_desc)->tSamFreq) & 0x00FFFFFF;
+ }
+ }
+ } else {
+ // Look for a Class-Specific AS Interface Descriptor(4.9.2) to verify format type and format and also to get number of physical channels
+ if (tu_desc_type(p_desc) == TUSB_DESC_CS_INTERFACE && tu_desc_subtype(p_desc) == AUDIO20_CS_AS_INTERFACE_AS_GENERAL) {
+ audio->n_channels_tx = ((audio20_desc_cs_as_interface_t const *) p_desc)->bNrChannels;
+ audio->format_type_tx = ((audio20_desc_cs_as_interface_t const *) p_desc)->bFormatType;
+ // Look for a Type I Format Type Descriptor(2.3.1.6 - Audio Formats)
+ p_desc = tu_desc_next(p_desc);
+ if (tu_desc_type(p_desc) == TUSB_DESC_CS_INTERFACE && tu_desc_subtype(p_desc) == AUDIO20_CS_AS_INTERFACE_FORMAT_TYPE && ((audio20_desc_type_I_format_t const *) p_desc)->bFormatType == AUDIO20_FORMAT_TYPE_I) {
+ audio->n_bytes_per_sample_tx = ((audio20_desc_type_I_format_t const *) p_desc)->bSubslotSize;
+ }
}
}
}
static bool audiod_calc_tx_packet_sz(audiod_function_t *audio) {
- TU_VERIFY(audio->format_type_tx == AUDIO_FORMAT_TYPE_I);
+ // AUDIO20_FORMAT_TYPE_I = AUDIO10_FORMAT_TYPE_I
+ TU_VERIFY(audio->format_type_tx == AUDIO20_FORMAT_TYPE_I);
TU_VERIFY(audio->n_channels_tx);
TU_VERIFY(audio->n_bytes_per_sample_tx);
TU_VERIFY(audio->interval_tx);
@@ -1824,11 +1899,8 @@ static uint16_t audiod_tx_packet_size(const uint16_t *norminal_size, uint16_t da
#endif
// No security checks here - internal function only which should always succeed
-static uint8_t audiod_get_audio_fct_idx(audiod_function_t *audio) {
- for (uint8_t cnt = 0; cnt < CFG_TUD_AUDIO; cnt++) {
- if (&_audiod_fct[cnt] == audio) return cnt;
- }
- return 0;
+static inline uint8_t audiod_get_audio_fct_idx(audiod_function_t *audio) {
+ return (uint8_t) (audio - _audiod_fct);
}
#endif // (CFG_TUD_ENABLED && CFG_TUD_AUDIO)
diff --git a/src/class/audio/audio_device.h b/src/class/audio/audio_device.h
index 00948767e..2bd432d48 100644
--- a/src/class/audio/audio_device.h
+++ b/src/class/audio/audio_device.h
@@ -37,35 +37,10 @@
// All sizes are in bytes!
-#ifndef CFG_TUD_AUDIO_FUNC_1_DESC_LEN
-#error You must tell the driver the length of the audio function descriptor including IAD descriptor
-#endif
-#if CFG_TUD_AUDIO > 1
-#ifndef CFG_TUD_AUDIO_FUNC_2_DESC_LEN
-#error You must tell the driver the length of the audio function descriptor including IAD descriptor
-#endif
-#endif
-#if CFG_TUD_AUDIO > 2
-#ifndef CFG_TUD_AUDIO_FUNC_3_DESC_LEN
-#error You must tell the driver the length of the audio function descriptor including IAD descriptor
-#endif
-#endif
-
-// Size of control buffer used to receive and send control messages via EP0 - has to be big enough to hold your biggest request structure e.g. range requests with multiple intervals defined or cluster descriptors
-#ifndef CFG_TUD_AUDIO_FUNC_1_CTRL_BUF_SZ
-#error You must define an audio class control request buffer size!
-#endif
-
-#if CFG_TUD_AUDIO > 1
-#ifndef CFG_TUD_AUDIO_FUNC_2_CTRL_BUF_SZ
-#error You must define an audio class control request buffer size!
-#endif
-#endif
-
-#if CFG_TUD_AUDIO > 2
-#ifndef CFG_TUD_AUDIO_FUNC_3_CTRL_BUF_SZ
-#error You must define an audio class control request buffer size!
-#endif
+// Size of control buffer used to receive and send control messages via EP0 - has to be big enough to hold your
+// biggest request structure e.g. range requests with multiple intervals defined or cluster descriptors
+#ifndef CFG_TUD_AUDIO_CTRL_BUF_SZ
+#define CFG_TUD_AUDIO_CTRL_BUF_SZ 64
#endif
// End point sizes IN BYTES - Limits: Full Speed <= 1023, High Speed <= 1024
@@ -167,7 +142,8 @@
#endif
#endif
-// (For TYPE-I format only) Flow control is necessary to allow IN ep send correct amount of data, unless it's a virtual device where data is perfectly synchronized to USB clock.
+// (For TYPE-I format only) Flow control is necessary to allow IN ep send correct amount of data, unless it's a
+// virtual device where data is perfectly synchronized to USB clock.
#ifndef CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL
#define CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL 1
#endif
@@ -177,12 +153,6 @@
#define CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP 0 // Feedback - 0 or 1
#endif
-// Enable/disable conversion from 16.16 to 10.14 format on full-speed devices. See tud_audio_n_fb_set().
-// Can be override by tud_audio_feedback_format_correction_cb()
-#ifndef CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION
-#define CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION 0 // 0 or 1
-#endif
-
// Enable/disable interrupt EP (required for notifying host of control changes)
#ifndef CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
#define CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP 0 // Feedback - 0 or 1
@@ -205,6 +175,7 @@ extern "C" {
// CFG_TUD_AUDIO > 1
//--------------------------------------------------------------------+
bool tud_audio_n_mounted(uint8_t func_id);
+uint8_t tud_audio_n_version(uint8_t func_id);
#if CFG_TUD_AUDIO_ENABLE_EP_OUT
uint16_t tud_audio_n_available (uint8_t func_id);
@@ -227,6 +198,7 @@ bool tud_audio_int_n_write (uint8_t func_id, const audio_
// Application API (Interface0)
//--------------------------------------------------------------------+
static inline bool tud_audio_mounted (void);
+static inline uint8_t tud_audio_version (void);
#if CFG_TUD_AUDIO_ENABLE_EP_OUT
static inline uint16_t tud_audio_available (void);
@@ -248,12 +220,15 @@ static inline bool tud_audio_int_write (const audio_interru
#endif
// Buffer control EP data and schedule a transmit
-// This function is intended to be used if you do not have a persistent buffer or memory location available (e.g. non-local variables) and need to answer onto a
-// get request. This function buffers your answer request frame into the control buffer of the corresponding audio driver and schedules a transmit for sending it.
-// Since transmission is triggered via interrupts, a persistent memory location is required onto which the buffer pointer in pointing. If you already have such
-// available you may directly use 'tud_control_xfer(...)'. In this case data does not need to be copied into an additional buffer and you save some time.
+// This function is intended to be used if you do not have a persistent buffer or memory location available
+// (e.g. non-local variables) and need to answer onto a get request. This function buffers your answer request
+// frame into the control buffer of the corresponding audio driver and schedules a transmit for sending it.
+// Since transmission is triggered via interrupts, a persistent memory location is required onto which the buffer
+// pointer in pointing. If you already have such available you may directly use 'tud_control_xfer(...)'. In this
+// case data does not need to be copied into an additional buffer and you save some time.
// If the request's wLength is zero, a status packet is sent instead.
-bool tud_audio_buffer_and_schedule_control_xfer(uint8_t rhport, tusb_control_request_t const * p_request, void* data, uint16_t len);
+bool tud_audio_buffer_and_schedule_control_xfer(uint8_t rhport, tusb_control_request_t const * p_request,
+ void* data, uint16_t len);
//--------------------------------------------------------------------+
// Application Callback API
@@ -261,14 +236,18 @@ bool tud_audio_buffer_and_schedule_control_xfer(uint8_t rhport, tusb_control_req
#if CFG_TUD_AUDIO_ENABLE_EP_IN
// Invoked in ISR context once an audio packet was sent successfully.
-// Normally this function is not needed, since the data transfer should be driven by audio clock (i.e. I2S clock), call tud_audio_write() in I2S receive callback.
-bool tud_audio_tx_done_isr(uint8_t rhport, uint16_t n_bytes_sent, uint8_t func_id, uint8_t ep_in, uint8_t cur_alt_setting);
+// Normally this function is not needed, since the data transfer should be driven by audio clock (i.e. I2S clock),
+// call tud_audio_write() in I2S receive callback.
+bool tud_audio_tx_done_isr(uint8_t rhport, uint16_t n_bytes_sent, uint8_t func_id, uint8_t ep_in,
+ uint8_t cur_alt_setting);
#endif
#if CFG_TUD_AUDIO_ENABLE_EP_OUT
// Invoked in ISR context once an audio packet was received successfully.
-// Normally this function is not needed, since the data transfer should be driven by audio clock (i.e. I2S clock), call tud_audio_read() in I2S transmit callback.
-bool tud_audio_rx_done_isr(uint8_t rhport, uint16_t n_bytes_received, uint8_t func_id, uint8_t ep_out, uint8_t cur_alt_setting);
+// Normally this function is not needed, since the data transfer should be driven by audio clock (i.e. I2S clock),
+// call tud_audio_read() in I2S transmit callback.
+bool tud_audio_rx_done_isr(uint8_t rhport, uint16_t n_bytes_received, uint8_t func_id, uint8_t ep_out,
+ uint8_t cur_alt_setting);
#endif
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
@@ -277,42 +256,55 @@ bool tud_audio_rx_done_isr(uint8_t rhport, uint16_t n_bytes_received, uint8_t fu
//
// Option 1 - AUDIO_FEEDBACK_METHOD_FIFO_COUNT
// Feedback value is calculated within the audio driver by regulating the FIFO level to half fill.
-// Advantage: No ISR interrupt is enabled, hence the CPU need not to handle an ISR every 1ms or 125us and thus less CPU load, well tested
-// (Windows, Linux, OSX) with a reliable result so far.
-// Disadvantage: A FIFO of minimal 4 frames is needed to compensate for jitter, an average delay of 2 frames is introduced.
+// Advantage: No SOF interrupt is enabled, hence the CPU need not to handle an ISR every 1ms or 125us and thus
+// less CPU load, well tested (Windows, Linux, OSX) with a reliable result so far.
+// Disadvantage: A FIFO of minimal 4 frames is needed to compensate for jitter, an average delay of 2 frames is
+// introduced.
//
// Option 2 - AUDIO_FEEDBACK_METHOD_FREQUENCY_FIXED / AUDIO_FEEDBACK_METHOD_FREQUENCY_FLOAT
-// Feedback value is calculated within the audio driver by use of SOF interrupt. The driver needs information about the master clock f_m from
-// which the audio sample frequency f_s is derived, f_s itself, and the cycle count of f_m at time of the SOF interrupt (e.g. by use of a hardware counter).
+// Feedback value is calculated within the audio driver by use of SOF interrupt. The driver needs information
+// about the master clock f_m from which the audio sample frequency f_s is derived, f_s itself, and the cycle
+// count of f_m at time of the SOF interrupt (e.g. by use of a hardware counter).
// See tud_audio_set_fb_params() and tud_audio_feedback_update()
-// Advantage: Reduced jitter in the feedback value computation, hence, the receive FIFO can be smaller and thus a smaller delay is possible.
-// Disadvantage: higher CPU load due to SOF ISR handling every frame i.e. 1ms or 125us. (The most critical point is the reading of the cycle counter value of f_m.
-// It is read from within the SOF ISR - see: audiod_sof() -, hence, the ISR must has a high priority such that no software dependent "random" delay i.e. jitter is introduced).
-// Long-term drift could occur since error is accumulated.
+// Advantage: Reduced jitter in the feedback value computation, hence, the receive FIFO can be smaller and thus a
+// smaller delay is possible.
+// Disadvantage: higher CPU load due to SOF ISR handling every frame i.e. 1ms or 125us. (The most critical point
+// is the reading of the cycle counter value of f_m. It is read from within the SOF ISR - see: audiod_sof() -,
+// hence, the ISR must has a high priority such that no software dependent "random" delay i.e. jitter is
+// introduced). Long-term drift will cause the FIFO under/overflow, you still needs to correct it somehow.
//
// Option 3 - manual
-// Determined by the user itself and set by use of tud_audio_n_fb_set(). The feedback value may be determined e.g. from some fill status of some FIFO buffer.
-// Advantage: No ISR interrupt is enabled, hence the CPU need not to handle an ISR every 1ms or 125us and thus less CPU load.
-// Disadvantage: typically a larger FIFO is needed to compensate for jitter (e.g. 6 frames), i.e. a larger delay is introduced.
+// Determined by the user itself and set by use of tud_audio_n_fb_set(). The feedback value may be determined
+// e.g. from some fill status of some FIFO buffer.
+// Advantage: No ISR interrupt is enabled, hence the CPU need not to handle an ISR every 1ms or 125us and thus
+// less CPU load.
+// Disadvantage: typically a larger FIFO is needed to compensate for jitter (e.g. 6 frames), i.e. a larger delay
+// is introduced.
-// This function is used to provide data rate feedback from an asynchronous sink. Feedback value will be sent at FB endpoint interval till it's changed.
+// This function is used to provide data rate feedback from an asynchronous sink. Feedback value will be sent at
+// FB endpoint interval till it's changed.
//
-// The feedback format is specified to be 16.16 for HS and 10.14 for FS devices (see Universal Serial Bus Specification Revision 2.0 5.12.4.2). By default,
-// the choice of format is left to the caller and feedback argument is sent as-is. If CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION is set or tud_audio_feedback_format_correction_cb()
-// return true, then tinyusb expects 16.16 format and handles the conversion to 10.14 on FS.
+// The feedback format is specified to be 16.16 for HS and 10.14 for FS devices (see Universal Serial Bus
+// Specification Revision 2.0 5.12.4.2). For simplicity, this function always uses 16.16 format. For FS devices,
+// the driver will automatically convert the value to 10.14 format.
//
-// Note that due to a bug in its USB Audio 2.0 driver, Windows currently requires 16.16 format for _all_ USB 2.0 devices. On Linux and it seems the
-// driver can work with either format.
+// Note that due to a bug in its USB Audio 2.0 driver, Windows currently requires 16.16 format for _all_ USB 2.0
+// devices. On Linux and it seems the driver can work with either format.
//
-// Feedback value can be determined from within the SOF ISR of the audio driver. This should reduce jitter. If the feature is used, the user can not set the feedback value.
+// Feedback value can be determined from within the SOF ISR of the audio driver. This should reduce jitter. If the
+// feature is used, the user can not set the feedback value.
//
// Determine feedback value - The feedback method is described in 5.12.4.2 of the USB 2.0 spec
// Boiled down, the feedback value Ff = n_samples / (micro)frame.
-// Since an accuracy of less than 1 Sample / second is desired, at least n_frames = ceil(2^K * f_s / f_m) frames need to be measured, where K = 10 for full speed and K = 13
-// for high speed, f_s is the sampling frequency e.g. 48 kHz and f_m is the cpu clock frequency e.g. 100 MHz (or any other master clock whose clock count is available and locked to f_s)
-// The update interval in the (4.10.2.1) Feedback Endpoint Descriptor must be less or equal to 2^(K - P), where P = min( ceil(log2(f_m / f_s)), K)
-// feedback = n_cycles / n_frames * f_s / f_m in 16.16 format, where n_cycles are the number of main clock cycles within fb_n_frames
+// Since an accuracy of less than 1 Sample / second is desired, at least n_frames = ceil(2^K * f_s / f_m) frames
+// need to be measured, where K = 10 for full speed and K = 13 for high speed, f_s is the sampling frequency
+// e.g. 48 kHz and f_m is the cpu clock frequency e.g. 100 MHz (or any other master clock whose clock count is
+// available and locked to f_s)
+// The update interval in the (4.10.2.1) Feedback Endpoint Descriptor must be less or equal to 2^(K - P), where
+// P = min( ceil(log2(f_m / f_s)), K)
+// feedback = n_cycles / n_frames * f_s / f_m in 16.16 format, where n_cycles are the number of main clock cycles
+// within fb_n_frames
bool tud_audio_n_fb_set(uint8_t func_id, uint32_t feedback);
// Update feedback value with passed MCLK cycles since last time this update function is called.
@@ -352,15 +344,11 @@ void tud_audio_feedback_params_cb(uint8_t func_id, uint8_t alt_itf, audio_feedba
// frame_number : current SOF count
// interval_shift: number of bit shift i.e log2(interval) from Feedback endpoint descriptor
TU_ATTR_FAST_FUNC void tud_audio_feedback_interval_isr(uint8_t func_id, uint32_t frame_number, uint8_t interval_shift);
-
-// (Full-Speed only) Callback to set feedback format correction is applied or not,
-// default to CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION if not implemented.
-bool tud_audio_feedback_format_correction_cb(uint8_t func_id);
#endif // CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
#if CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
+// Invoked when an interrupt notification transfer is complete
void tud_audio_int_done_cb(uint8_t rhport);
-void tud_audio_int_xfer_cb(uint8_t rhport);
#endif
// Invoked when audio set interface request received
@@ -398,6 +386,10 @@ TU_ATTR_ALWAYS_INLINE static inline bool tud_audio_mounted(void) {
return tud_audio_n_mounted(0);
}
+TU_ATTR_ALWAYS_INLINE static inline uint8_t tud_audio_version(void) {
+ return tud_audio_n_version(0);
+}
+
#if CFG_TUD_AUDIO_ENABLE_EP_OUT
TU_ATTR_ALWAYS_INLINE static inline uint16_t tud_audio_available(void) {
@@ -462,7 +454,7 @@ void audiod_sof_isr (uint8_t rhport, uint32_t frame_count);
}
#endif
-#endif /* _TUSB_AUDIO_DEVICE_H_ */
+#endif /* TUSB_AUDIO_DEVICE_H_ */
/** @} */
/** @} */
diff --git a/src/class/bth/bth_device.h b/src/class/bth/bth_device.h
index 68f073bff..89a056dc8 100755
--- a/src/class/bth/bth_device.h
+++ b/src/class/bth/bth_device.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_BTH_DEVICE_H_
-#define _TUSB_BTH_DEVICE_H_
+#ifndef TUSB_BTH_DEVICE_H_
+#define TUSB_BTH_DEVICE_H_
#include <common/tusb_common.h>
#include <device/usbd.h>
@@ -114,4 +114,4 @@ bool btd_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t r
}
#endif
-#endif /* _TUSB_BTH_DEVICE_H_ */
+#endif /* TUSB_BTH_DEVICE_H_ */
diff --git a/src/class/cdc/cdc.h b/src/class/cdc/cdc.h
index 10ba16a7c..6d207c717 100644
--- a/src/class/cdc/cdc.h
+++ b/src/class/cdc/cdc.h
@@ -29,8 +29,8 @@
* Currently only Abstract Control Model subclass is supported
* @{ */
-#ifndef _TUSB_CDC_H__
-#define _TUSB_CDC_H__
+#ifndef TUSB_CDC_H__
+#define TUSB_CDC_H__
#include "common/tusb_common.h"
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c
index 94c82cc77..2bf017aca 100644
--- a/src/class/cdc/cdc_device.c
+++ b/src/class/cdc/cdc_device.c
@@ -533,7 +533,7 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
// Check for wanted char and invoke callback if needed
if (((signed char) p_cdc->wanted_char) != -1) {
for (uint32_t i = 0; i < xferred_bytes; i++) {
- if ((p_cdc->wanted_char == p_epbuf->epout[i]) && !tu_fifo_empty(&p_cdc->rx_ff)) {
+ if ((p_cdc->wanted_char == (char) p_epbuf->epout[i]) && !tu_fifo_empty(&p_cdc->rx_ff)) {
tud_cdc_rx_wanted_cb(itf, p_cdc->wanted_char);
}
}
diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h
index 9673b9807..c321f3d16 100644
--- a/src/class/cdc/cdc_device.h
+++ b/src/class/cdc/cdc_device.h
@@ -257,4 +257,4 @@ bool cdcd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t re
}
#endif
-#endif /* _TUSB_CDC_DEVICE_H_ */
+#endif /* TUSB_CDC_DEVICE_H_ */
diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c
index beef03eff..3fc6a9adf 100644
--- a/src/class/cdc/cdc_host.c
+++ b/src/class/cdc/cdc_host.c
@@ -1136,7 +1136,6 @@ static inline bool ftdi_sio_reset(cdch_interface_t *p_cdc, tuh_xfer_cb_t complet
// internal control complete to update state such as line state, line_coding
static void ftdi_internal_control_complete(cdch_interface_t* p_cdc, tuh_xfer_t *xfer) {
- TU_VERIFY(xfer->result == XFER_RESULT_SUCCESS,);
const tusb_control_request_t * setup = xfer->setup;
if (xfer->result == XFER_RESULT_SUCCESS) {
if (setup->bRequest == FTDI_SIO_SET_MODEM_CTRL_REQUEST &&
@@ -1365,7 +1364,7 @@ static uint32_t ftdi_232bm_baud_base_to_divisor(uint32_t baud, uint32_t base) {
uint8_t divfrac[8] = {0, 3, 2, 4, 1, 5, 6, 7};
uint32_t divisor;
/* divisor shifted 3 bits to the left */
- uint32_t divisor3 = DIV_ROUND_CLOSEST(base, 2 * baud);
+ uint32_t divisor3 = tu_div_round_nearest(base, 2 * baud);
divisor = divisor3 >> 3;
divisor |= (uint32_t) divfrac[divisor3 & 0x7] << 14;
/* Deal with special cases for highest baud rates. */
@@ -1387,7 +1386,7 @@ static uint32_t ftdi_2232h_baud_base_to_divisor(uint32_t baud, uint32_t base) {
uint32_t divisor3;
/* hi-speed baud rate is 10-bit sampling instead of 16-bit */
- divisor3 = DIV_ROUND_CLOSEST(8 * base, 10 * baud);
+ divisor3 = tu_div_round_nearest(8 * base, 10 * baud);
divisor = divisor3 >> 3;
divisor |= (uint32_t) divfrac[divisor3 & 0x7] << 14;
diff --git a/src/class/cdc/cdc_host.h b/src/class/cdc/cdc_host.h
index bf6711d7e..e8637beac 100644
--- a/src/class/cdc/cdc_host.h
+++ b/src/class/cdc/cdc_host.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_CDC_HOST_H_
-#define _TUSB_CDC_HOST_H_
+#ifndef TUSB_CDC_HOST_H_
+#define TUSB_CDC_HOST_H_
#include "cdc.h"
@@ -255,4 +255,4 @@ void cdch_close (uint8_t dev_addr);
}
#endif
-#endif /* _TUSB_CDC_HOST_H_ */
+#endif /* TUSB_CDC_HOST_H_ */
diff --git a/src/class/cdc/cdc_rndis.h b/src/class/cdc/cdc_rndis.h
index ad153e0ac..fbbd43206 100644
--- a/src/class/cdc/cdc_rndis.h
+++ b/src/class/cdc/cdc_rndis.h
@@ -30,8 +30,8 @@
* \defgroup CDC_RNDIS_Common Common Definitions
* @{ */
-#ifndef _TUSB_CDC_RNDIS_H_
-#define _TUSB_CDC_RNDIS_H_
+#ifndef TUSB_CDC_RNDIS_H_
+#define TUSB_CDC_RNDIS_H_
#include "cdc.h"
@@ -295,7 +295,7 @@ typedef enum
}
#endif
-#endif /* _TUSB_CDC_RNDIS_H_ */
+#endif /* TUSB_CDC_RNDIS_H_ */
/** @} */
/** @} */
diff --git a/src/class/cdc/cdc_rndis_host.h b/src/class/cdc/cdc_rndis_host.h
index bb431ec1f..e70d27f79 100644
--- a/src/class/cdc/cdc_rndis_host.h
+++ b/src/class/cdc/cdc_rndis_host.h
@@ -28,8 +28,8 @@
* \defgroup CDC_RNSID_Host Host
* @{ */
-#ifndef _TUSB_CDC_RNDIS_HOST_H_
-#define _TUSB_CDC_RNDIS_HOST_H_
+#ifndef TUSB_CDC_RNDIS_HOST_H_
+#define TUSB_CDC_RNDIS_HOST_H_
#include "common/tusb_common.h"
#include "host/usbh.h"
@@ -58,6 +58,6 @@ void rndish_close(uint8_t dev_addr);
}
#endif
-#endif /* _TUSB_CDC_RNDIS_HOST_H_ */
+#endif /* TUSB_CDC_RNDIS_HOST_H_ */
/** @} */
diff --git a/src/class/cdc/serial/ftdi_sio.h b/src/class/cdc/serial/ftdi_sio.h
index 8abf74f11..9bd56cef4 100644
--- a/src/class/cdc/serial/ftdi_sio.h
+++ b/src/class/cdc/serial/ftdi_sio.h
@@ -215,17 +215,4 @@ typedef struct ftdi_private {
#define FTDI_NOT_POSSIBLE -1
#define FTDI_REQUESTED -2
-// division and round function overtaken from math.h
-#define DIV_ROUND_CLOSEST(x, divisor)( \
-{ \
- typeof(x) __x = x; \
- typeof(divisor) __d = divisor; \
- (((typeof(x))-1) > 0 || \
- ((typeof(divisor))-1) > 0 || \
- (((__x) > 0) == ((__d) > 0))) ? \
- (((__x) + ((__d) / 2)) / (__d)) : \
- (((__x) - ((__d) / 2)) / (__d)); \
-} \
-)
-
#endif //TUSB_FTDI_SIO_H
diff --git a/src/class/dfu/dfu.h b/src/class/dfu/dfu.h
index 114c827b8..8cd63656a 100644
--- a/src/class/dfu/dfu.h
+++ b/src/class/dfu/dfu.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_DFU_H_
-#define _TUSB_DFU_H_
+#ifndef TUSB_DFU_H_
+#define TUSB_DFU_H_
#include "common/tusb_common.h"
@@ -116,4 +116,4 @@ TU_VERIFY_STATIC( sizeof(dfu_status_response_t) == 6, "size is not correct");
}
#endif
-#endif /* _TUSB_DFU_H_ */
+#endif /* TUSB_DFU_H_ */
diff --git a/src/class/dfu/dfu_device.h b/src/class/dfu/dfu_device.h
index e59e61ce9..b22b4c450 100644
--- a/src/class/dfu/dfu_device.h
+++ b/src/class/dfu/dfu_device.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_DFU_DEVICE_H_
-#define _TUSB_DFU_DEVICE_H_
+#ifndef TUSB_DFU_DEVICE_H_
+#define TUSB_DFU_DEVICE_H_
#include "dfu.h"
@@ -96,4 +96,4 @@ bool dfu_moded_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_r
}
#endif
-#endif /* _TUSB_DFU_MODE_DEVICE_H_ */
+#endif /* TUSB_DFU_MODE_DEVICE_H_ */
diff --git a/src/class/dfu/dfu_rt_device.h b/src/class/dfu/dfu_rt_device.h
index 67eb26d95..c4116d8fe 100644
--- a/src/class/dfu/dfu_rt_device.h
+++ b/src/class/dfu/dfu_rt_device.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_DFU_RT_DEVICE_H_
-#define _TUSB_DFU_RT_DEVICE_H_
+#ifndef TUSB_DFU_RT_DEVICE_H_
+#define TUSB_DFU_RT_DEVICE_H_
#include "dfu.h"
@@ -52,4 +52,4 @@ bool dfu_rtd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_req
}
#endif
-#endif /* _TUSB_DFU_RT_DEVICE_H_ */
+#endif /* TUSB_DFU_RT_DEVICE_H_ */
diff --git a/src/class/hid/hid.h b/src/class/hid/hid.h
index b69f623a0..0883d95ac 100644
--- a/src/class/hid/hid.h
+++ b/src/class/hid/hid.h
@@ -28,8 +28,8 @@
* \defgroup ClassDriver_HID Human Interface Device (HID)
* @{ */
-#ifndef _TUSB_HID_H_
-#define _TUSB_HID_H_
+#ifndef TUSB_HID_H_
+#define TUSB_HID_H_
#include "common/tusb_common.h"
@@ -2071,6 +2071,6 @@ enum {
}
#endif
-#endif /* _TUSB_HID_H__ */
+#endif /* TUSB_HID_H__ */
/// @}
diff --git a/src/class/hid/hid_host.h b/src/class/hid/hid_host.h
index 032827af1..87f0e7dc9 100644
--- a/src/class/hid/hid_host.h
+++ b/src/class/hid/hid_host.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_HID_HOST_H_
-#define _TUSB_HID_HOST_H_
+#ifndef TUSB_HID_HOST_H_
+#define TUSB_HID_HOST_H_
#include "hid.h"
@@ -182,4 +182,4 @@ void hidh_close(uint8_t dev_addr);
}
#endif
-#endif /* _TUSB_HID_HOST_H_ */
+#endif /* TUSB_HID_HOST_H_ */
diff --git a/src/class/midi/midi_device.h b/src/class/midi/midi_device.h
index c2c6e9859..d23516cec 100644
--- a/src/class/midi/midi_device.h
+++ b/src/class/midi/midi_device.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_MIDI_DEVICE_H_
-#define _TUSB_MIDI_DEVICE_H_
+#ifndef TUSB_MIDI_DEVICE_H_
+#define TUSB_MIDI_DEVICE_H_
#include "class/audio/audio.h"
#include "midi.h"
@@ -168,7 +168,7 @@ bool midid_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t
}
#endif
-#endif /* _TUSB_MIDI_DEVICE_H_ */
+#endif /* TUSB_MIDI_DEVICE_H_ */
/** @} */
/** @} */
diff --git a/src/class/midi/midi_host.c b/src/class/midi/midi_host.c
index e6ace316c..8b78fe945 100644
--- a/src/class/midi/midi_host.c
+++ b/src/class/midi/midi_host.c
@@ -220,11 +220,11 @@ bool midih_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *d
// driver after parsing the audio control interface and then resume parsing
// the streaming audio interface.
if (AUDIO_SUBCLASS_CONTROL == desc_itf->bInterfaceSubClass) {
- TU_VERIFY(max_len > 2*sizeof(tusb_desc_interface_t) + sizeof(audio_desc_cs_ac_interface_t));
+ TU_VERIFY(max_len > 2*sizeof(tusb_desc_interface_t) + sizeof(midi10_desc_cs_ac_interface_t));
p_desc = tu_desc_next(p_desc);
TU_VERIFY(tu_desc_type(p_desc) == TUSB_DESC_CS_INTERFACE &&
- tu_desc_subtype(p_desc) == AUDIO_CS_AC_INTERFACE_HEADER);
+ tu_desc_subtype(p_desc) == AUDIO10_CS_AC_INTERFACE_HEADER);
desc_cb.desc_audio_control = desc_itf;
p_desc = tu_desc_next(p_desc);
diff --git a/src/class/msc/msc.h b/src/class/msc/msc.h
index b2b44eac4..3b5d4a855 100644
--- a/src/class/msc/msc.h
+++ b/src/class/msc/msc.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_MSC_H_
-#define _TUSB_MSC_H_
+#ifndef TUSB_MSC_H_
+#define TUSB_MSC_H_
#include "common/tusb_common.h"
@@ -398,4 +398,4 @@ TU_VERIFY_STATIC(sizeof(scsi_write10_t) == 10, "size is not correct");
}
#endif
-#endif /* _TUSB_MSC_H_ */
+#endif /* TUSB_MSC_H_ */
diff --git a/src/class/msc/msc_device.h b/src/class/msc/msc_device.h
index 7d898e988..21e24971b 100644
--- a/src/class/msc/msc_device.h
+++ b/src/class/msc/msc_device.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_MSC_DEVICE_H_
-#define _TUSB_MSC_DEVICE_H_
+#ifndef TUSB_MSC_DEVICE_H_
+#define TUSB_MSC_DEVICE_H_
#include "common/tusb_common.h"
#include "msc.h"
@@ -167,4 +167,4 @@ bool mscd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t ev
}
#endif
-#endif /* _TUSB_MSC_DEVICE_H_ */
+#endif /* TUSB_MSC_DEVICE_H_ */
diff --git a/src/class/net/ncm.h b/src/class/net/ncm.h
index 0245a87f2..8989fe0b4 100644
--- a/src/class/net/ncm.h
+++ b/src/class/net/ncm.h
@@ -25,8 +25,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_NCM_H_
-#define _TUSB_NCM_H_
+#ifndef TUSB_NCM_H_
+#define TUSB_NCM_H_
#include "common/tusb_common.h"
diff --git a/src/class/net/net_device.h b/src/class/net/net_device.h
index ef5ecffc8..96c03fd61 100644
--- a/src/class/net/net_device.h
+++ b/src/class/net/net_device.h
@@ -25,8 +25,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_NET_DEVICE_H_
-#define _TUSB_NET_DEVICE_H_
+#ifndef TUSB_NET_DEVICE_H_
+#define TUSB_NET_DEVICE_H_
#include <stdint.h>
#include "class/cdc/cdc.h"
@@ -114,4 +114,4 @@ void netd_report (uint8_t *buf, uint16_t len);
}
#endif
-#endif /* _TUSB_NET_DEVICE_H_ */
+#endif /* TUSB_NET_DEVICE_H_ */
diff --git a/src/class/usbtmc/usbtmc.h b/src/class/usbtmc/usbtmc.h
index 327de087c..3bf5e1a17 100644
--- a/src/class/usbtmc/usbtmc.h
+++ b/src/class/usbtmc/usbtmc.h
@@ -25,8 +25,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_USBTMC_H__
-#define _TUSB_USBTMC_H__
+#ifndef TUSB_USBTMC_H__
+#define TUSB_USBTMC_H__
#include "common/tusb_common.h"
diff --git a/src/class/vendor/vendor_device.h b/src/class/vendor/vendor_device.h
index 5fe4fc9ff..5376f3917 100644
--- a/src/class/vendor/vendor_device.h
+++ b/src/class/vendor/vendor_device.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_VENDOR_DEVICE_H_
-#define _TUSB_VENDOR_DEVICE_H_
+#ifndef TUSB_VENDOR_DEVICE_H_
+#define TUSB_VENDOR_DEVICE_H_
#include "common/tusb_common.h"
@@ -141,4 +141,4 @@ bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, u
}
#endif
-#endif /* _TUSB_VENDOR_DEVICE_H_ */
+#endif /* TUSB_VENDOR_DEVICE_H_ */
diff --git a/src/class/vendor/vendor_host.h b/src/class/vendor/vendor_host.h
index acfebe7a4..00e3c3402 100644
--- a/src/class/vendor/vendor_host.h
+++ b/src/class/vendor/vendor_host.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_VENDOR_HOST_H_
-#define _TUSB_VENDOR_HOST_H_
+#ifndef TUSB_VENDOR_HOST_H_
+#define TUSB_VENDOR_HOST_H_
#include "common/tusb_common.h"
@@ -64,4 +64,4 @@ void cush_close(uint8_t dev_addr);
}
#endif
-#endif /* _TUSB_VENDOR_HOST_H_ */
+#endif /* TUSB_VENDOR_HOST_H_ */
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 6393652a3..6aa7e0bfc 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_COMMON_H_
-#define _TUSB_COMMON_H_
+#ifndef TUSB_COMMON_H_
+#define TUSB_COMMON_H_
#ifdef __cplusplus
extern "C" {
@@ -34,30 +34,38 @@
//--------------------------------------------------------------------+
// Macros Helper
//--------------------------------------------------------------------+
-#define TU_ARRAY_SIZE(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
+#define TU_ARRAY_SIZE(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
#define TU_FIELD_SIZE(_type, _field) (sizeof(((_type *)0)->_field))
-#define TU_MIN(_x, _y) ( ( (_x) < (_y) ) ? (_x) : (_y) )
-#define TU_MAX(_x, _y) ( ( (_x) > (_y) ) ? (_x) : (_y) )
-#define TU_DIV_CEIL(n, d) (((n) + (d) - 1) / (d))
+#define TU_MIN(_x, _y) ( ( (_x) < (_y) ) ? (_x) : (_y) )
+#define TU_MAX(_x, _y) ( ( (_x) > (_y) ) ? (_x) : (_y) )
+#define TU_DIV_CEIL(n, d) (((n) + (d) - 1) / (d))
+#define TU_DIV_ROUND_NEAREST(v, d) (((v) + (d)/2) / (d) ) // round to nearest integer
-#define TU_U16(_high, _low) ((uint16_t) (((_high) << 8) | (_low)))
-#define TU_U16_HIGH(_u16) ((uint8_t) (((_u16) >> 8) & 0x00ff))
-#define TU_U16_LOW(_u16) ((uint8_t) ((_u16) & 0x00ff))
-#define U16_TO_U8S_BE(_u16) TU_U16_HIGH(_u16), TU_U16_LOW(_u16)
-#define U16_TO_U8S_LE(_u16) TU_U16_LOW(_u16), TU_U16_HIGH(_u16)
+#define TU_U16(_high, _low) ((uint16_t) ((((uint16_t) (_high)) << 8) | ((uint16_t) (_low))))
+#define TU_U16_HIGH(_u16) ((uint8_t) (((uint16_t) (_u16) >> 8) & 0x00ffu))
+#define TU_U16_LOW(_u16) ((uint8_t) ((uint16_t) (_u16) & 0x00ffu))
+#define U16_TO_U8S_BE(_u16) TU_U16_HIGH(_u16), TU_U16_LOW(_u16)
+#define U16_TO_U8S_LE(_u16) TU_U16_LOW(_u16), TU_U16_HIGH(_u16)
-#define TU_U32_BYTE3(_u32) ((uint8_t) ((((uint32_t) _u32) >> 24) & 0x000000ff)) // MSB
-#define TU_U32_BYTE2(_u32) ((uint8_t) ((((uint32_t) _u32) >> 16) & 0x000000ff))
-#define TU_U32_BYTE1(_u32) ((uint8_t) ((((uint32_t) _u32) >> 8) & 0x000000ff))
-#define TU_U32_BYTE0(_u32) ((uint8_t) (((uint32_t) _u32) & 0x000000ff)) // LSB
+#define TU_U24(_high, _mid, _low) ((uint32_t) ((((uint32_t) (_high)) << 16) | (((uint32_t) (_mid)) << 8) | ((uint32_t) (_low))))
+#define TU_U24_HIGH(_u24) ((uint8_t) (((uint32_t) (_u24) >> 16) & 0x0000ffu))
+#define TU_U24_MID(_u24) ((uint8_t) (((uint32_t) (_u24) >> 8) & 0x0000ffu))
+#define TU_U24_LOW(_u24) ((uint8_t) ((uint32_t) (_u24) & 0x0000ffu))
+#define U24_TO_U8S_BE(_u24) TU_U24_HIGH(_u24), TU_U24_MID(_u24), TU_U24_LOW(_u24)
+#define U24_TO_U8S_LE(_u24) TU_U24_LOW(_u24), TU_U24_MID(_u24), TU_U24_HIGH(_u24)
-#define U32_TO_U8S_BE(_u32) TU_U32_BYTE3(_u32), TU_U32_BYTE2(_u32), TU_U32_BYTE1(_u32), TU_U32_BYTE0(_u32)
-#define U32_TO_U8S_LE(_u32) TU_U32_BYTE0(_u32), TU_U32_BYTE1(_u32), TU_U32_BYTE2(_u32), TU_U32_BYTE3(_u32)
+#define TU_U32_BYTE3(_u32) ((uint8_t) ((((uint32_t) _u32) >> 24) & 0x000000ff)) // MSB
+#define TU_U32_BYTE2(_u32) ((uint8_t) ((((uint32_t) _u32) >> 16) & 0x000000ff))
+#define TU_U32_BYTE1(_u32) ((uint8_t) ((((uint32_t) _u32) >> 8) & 0x000000ff))
+#define TU_U32_BYTE0(_u32) ((uint8_t) (((uint32_t) _u32) & 0x000000ff)) // LSB
-#define TU_BIT(n) (1UL << (n))
+#define U32_TO_U8S_BE(_u32) TU_U32_BYTE3(_u32), TU_U32_BYTE2(_u32), TU_U32_BYTE1(_u32), TU_U32_BYTE0(_u32)
+#define U32_TO_U8S_LE(_u32) TU_U32_BYTE0(_u32), TU_U32_BYTE1(_u32), TU_U32_BYTE2(_u32), TU_U32_BYTE3(_u32)
+
+#define TU_BIT(n) (1UL << (n))
// Generate a mask with bit from high (31) to low (0) set, e.g TU_GENMASK(3, 0) = 0b1111
-#define TU_GENMASK(h, l) ( (UINT32_MAX << (l)) & (UINT32_MAX >> (31 - (h))) )
+#define TU_GENMASK(h, l) ( (UINT32_MAX << (l)) & (UINT32_MAX >> (31 - (h))) )
//--------------------------------------------------------------------+
// Includes
@@ -130,7 +138,7 @@ TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, c
}
// For memcpy, src may be NULL only if count == 0. Reject otherwise.
- if (src == NULL && count != 0) {
+ if (src == NULL && count != 0u) {
return -1;
}
@@ -215,6 +223,8 @@ TU_ATTR_ALWAYS_INLINE static inline bool tu_is_aligned64(uint64_t value) { retur
//------------- Mathematics -------------//
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_div_ceil(uint32_t v, uint32_t d) { return TU_DIV_CEIL(v, d); }
+TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_div_round_nearest(uint32_t v, uint32_t d) { return TU_DIV_ROUND_NEAREST(v, d); }
+
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_round_up(uint32_t v, uint32_t f) { return tu_div_ceil(v, f) * f; }
// log2 of a value is its MSB's position
@@ -388,4 +398,4 @@ uint8_t const * tu_desc_find3(uint8_t const* desc, uint8_t const* end, uint8_t b
}
#endif
-#endif /* _TUSB_COMMON_H_ */
+#endif /* TUSB_COMMON_H_ */
diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h
index 9b33a6f61..1ce16f060 100644
--- a/src/common/tusb_compiler.h
+++ b/src/common/tusb_compiler.h
@@ -29,8 +29,8 @@
* \brief Group_Compiler brief
* @{ */
-#ifndef _TUSB_COMPILER_H_
-#define _TUSB_COMPILER_H_
+#ifndef TUSB_COMPILER_H_
+#define TUSB_COMPILER_H_
#define TU_TOKEN(x) x
#define TU_STRING(x) #x ///< stringify without expand
@@ -45,9 +45,9 @@
#define TU_INCLUDE_PATH(_dir,_file) TU_XSTRING( TU_TOKEN(_dir)TU_TOKEN(_file) )
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
- #define _TU_COUNTER_ __COUNTER__
+ #define TU_COUNTER __COUNTER__
#else
- #define _TU_COUNTER_ __LINE__
+ #define TU_COUNTER __LINE__
#endif
// Compile-time Assert
@@ -56,9 +56,9 @@
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define TU_VERIFY_STATIC _Static_assert
#elif defined(__CCRX__)
- #define TU_VERIFY_STATIC(const_expr, _mess) typedef char TU_XSTRCAT(_verify_static_, _TU_COUNTER_)[(const_expr) ? 1 : 0];
+ #define TU_VERIFY_STATIC(const_expr, _mess) typedef char TU_XSTRCAT(_verify_static_, TU_COUNTER)[(const_expr) ? 1 : 0];
#else
- #define TU_VERIFY_STATIC(const_expr, _mess) enum { TU_XSTRCAT(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
+ #define TU_VERIFY_STATIC(const_expr, _mess) enum { TU_XSTRCAT(_verify_static_, TU_COUNTER) = 1/(!!(const_expr)) }
#endif
/* --------------------- Fuzzing types -------------------------------------- */
@@ -68,8 +68,8 @@
#define tu_static static
#endif
-// for declaration of reserved field, make use of _TU_COUNTER_
-#define TU_RESERVED TU_XSTRCAT(reserved, _TU_COUNTER_)
+// for declaration of reserved field, make use of TU_COUNTER
+#define TU_RESERVED TU_XSTRCAT(reserved, TU_COUNTER)
#define TU_LITTLE_ENDIAN (0x12u)
#define TU_BIG_ENDIAN (0x21u)
@@ -118,6 +118,18 @@
#define _TU_ARGS_APPLY_7(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6, _a7) _X(_a1) _s _TU_ARGS_APPLY_6(_X, _s, _a2, _a3, _a4, _a5, _a6, _a7)
#define _TU_ARGS_APPLY_8(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) _X(_a1) _s _TU_ARGS_APPLY_7(_X, _s, _a2, _a3, _a4, _a5, _a6, _a7, _a8)
+// Apply an macro X to each of the arguments and expand the result with comma
+#define TU_ARGS_APPLY_EXPAND(_X, ...) TU_XSTRCAT(_TU_ARGS_APPLY_EXPAND_, TU_ARGS_NUM(__VA_ARGS__))(_X, __VA_ARGS__)
+
+#define _TU_ARGS_APPLY_EXPAND_1(_X, _a1) _X(_a1)
+#define _TU_ARGS_APPLY_EXPAND_2(_X, _a1, _a2) _X(_a1), _X(_a2)
+#define _TU_ARGS_APPLY_EXPAND_3(_X, _a1, _a2, _a3) _X(_a1), _TU_ARGS_APPLY_EXPAND_2(_X, _a2, _a3)
+#define _TU_ARGS_APPLY_EXPAND_4(_X, _a1, _a2, _a3, _a4) _X(_a1), _TU_ARGS_APPLY_EXPAND_3(_X, _a2, _a3, _a4)
+#define _TU_ARGS_APPLY_EXPAND_5(_X, _a1, _a2, _a3, _a4, _a5) _X(_a1), _TU_ARGS_APPLY_EXPAND_4(_X, _a2, _a3, _a4, _a5)
+#define _TU_ARGS_APPLY_EXPAND_6(_X, _a1, _a2, _a3, _a4, _a5, _a6) _X(_a1), _TU_ARGS_APPLY_EXPAND_5(_X, _a2, _a3, _a4, _a5, _a6)
+#define _TU_ARGS_APPLY_EXPAND_7(_X, _a1, _a2, _a3, _a4, _a5, _a6, _a7) _X(_a1), _TU_ARGS_APPLY_EXPAND_6(_X, _a2, _a3, _a4, _a5, _a6, _a7)
+#define _TU_ARGS_APPLY_EXPAND_8(_X, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) _X(_a1), _TU_ARGS_APPLY_EXPAND_7(_X, _a2, _a3, _a4, _a5, _a6, _a7, _a8)
+
//--------------------------------------------------------------------+
// Macro for function default arguments
//--------------------------------------------------------------------+
@@ -305,6 +317,6 @@
#error Byte order is undefined
#endif
-#endif /* _TUSB_COMPILER_H_ */
+#endif /* TUSB_COMPILER_H_ */
/// @}
diff --git a/src/common/tusb_debug.h b/src/common/tusb_debug.h
index 1d0c6f1ad..e3f9d3f18 100644
--- a/src/common/tusb_debug.h
+++ b/src/common/tusb_debug.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_DEBUG_H_
-#define _TUSB_DEBUG_H_
+#ifndef TUSB_DEBUG_H_
+#define TUSB_DEBUG_H_
#ifdef __cplusplus
extern "C" {
@@ -58,8 +58,10 @@ void tu_print_mem(void const *buf, uint32_t count, uint8_t indent);
#define tu_printf printf
#endif
-static inline void tu_print_buf(uint8_t const* buf, uint32_t bufsize) {
- for(uint32_t i=0; i<bufsize; i++) tu_printf("%02X ", buf[i]);
+TU_ATTR_ALWAYS_INLINE static inline void tu_print_buf(uint8_t const* buf, uint32_t bufsize) {
+ for(uint32_t i=0; i<bufsize; i++) {
+ tu_printf("%02X ", buf[i]);
+ }
tu_printf("\r\n");
}
@@ -109,7 +111,9 @@ typedef struct {
static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key) {
for(uint16_t i=0; i<p_table->count; i++) {
- if (p_table->items[i].key == key) { return p_table->items[i].data; }
+ if (p_table->items[i].key == key) {
+ return p_table->items[i].data;
+ }
}
// not found return the key value in hex
@@ -130,8 +134,6 @@ static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint3
#define TU_LOG_FAILED()
#endif
-// TODO replace all TU_LOGn with TU_LOG(n)
-
#define TU_LOG0(...)
#define TU_LOG0_MEM(...)
#define TU_LOG0_BUF(...)
@@ -166,4 +168,4 @@ static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint3
}
#endif
-#endif /* _TUSB_DEBUG_H_ */
+#endif
diff --git a/src/common/tusb_fifo.h b/src/common/tusb_fifo.h
index 879acda4f..f2a6c5469 100644
--- a/src/common/tusb_fifo.h
+++ b/src/common/tusb_fifo.h
@@ -25,8 +25,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_FIFO_H_
-#define _TUSB_FIFO_H_
+#ifndef TUSB_FIFO_H_
+#define TUSB_FIFO_H_
#ifdef __cplusplus
extern "C" {
@@ -196,4 +196,4 @@ void tu_fifo_get_write_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info);
}
#endif
-#endif /* _TUSB_FIFO_H_ */
+#endif
diff --git a/src/common/tusb_mcu.h b/src/common/tusb_mcu.h
index 0b8ed1059..2ca14838b 100644
--- a/src/common/tusb_mcu.h
+++ b/src/common/tusb_mcu.h
@@ -64,6 +64,7 @@
#elif TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC40XX)
#define TUP_DCD_ENDPOINT_MAX 16
#define TUP_USBIP_OHCI
+ #define TUP_USBIP_OHCI_NXP
#define TUP_OHCI_RHPORTS 2
#elif TU_CHECK_MCU(OPT_MCU_LPC51UXX)
@@ -78,6 +79,10 @@
#elif TU_CHECK_MCU(OPT_MCU_LPC55)
// TODO USB0 has 5, USB1 has 6
#define TUP_USBIP_IP3511
+ #define TUP_USBIP_OHCI
+ #define TUP_USBIP_OHCI_NXP
+ #define TUP_OHCI_RHPORTS 1 // 1 downstream port
+
#define TUP_DCD_ENDPOINT_MAX 6
#elif TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX)
diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h
index b3ef1e9c9..55f309af8 100644
--- a/src/common/tusb_types.h
+++ b/src/common/tusb_types.h
@@ -77,7 +77,7 @@
*------------------------------------------------------------------*/
typedef enum {
- TUSB_ROLE_INVALID = 0,
+ TUSB_ROLE_INVALID = 0u,
TUSB_ROLE_DEVICE = 0x1,
TUSB_ROLE_HOST = 0x2,
} tusb_role_t;
@@ -178,7 +178,7 @@ typedef enum {
} tusb_request_feature_selector_t;
typedef enum {
- TUSB_REQ_TYPE_STANDARD = 0,
+ TUSB_REQ_TYPE_STANDARD = 0u,
TUSB_REQ_TYPE_CLASS,
TUSB_REQ_TYPE_VENDOR,
TUSB_REQ_TYPE_INVALID
@@ -350,7 +350,7 @@ typedef struct TU_ATTR_PACKED {
uint8_t bNumConfigurations ; ///< Number of possible configurations.
} tusb_desc_device_t;
-TU_VERIFY_STATIC( sizeof(tusb_desc_device_t) == 18, "size is not correct");
+TU_VERIFY_STATIC( sizeof(tusb_desc_device_t) == 18u, "size is not correct");
// USB Binary Device Object Store (BOS) Descriptor
typedef struct TU_ATTR_PACKED {
@@ -360,7 +360,7 @@ typedef struct TU_ATTR_PACKED {
uint8_t bNumDeviceCaps ; ///< Number of device capability descriptors in the BOS
} tusb_desc_bos_t;
-TU_VERIFY_STATIC( sizeof(tusb_desc_bos_t) == 5, "size is not correct");
+TU_VERIFY_STATIC( sizeof(tusb_desc_bos_t) == 5u, "size is not correct");
/// USB Configuration Descriptor
typedef struct TU_ATTR_PACKED {
@@ -375,7 +375,7 @@ typedef struct TU_ATTR_PACKED {
uint8_t bMaxPower ; ///< Maximum power consumption of the USB device from the bus in this specific configuration when the device is fully operational. Expressed in 2 mA units (i.e., 50 = 100 mA).
} tusb_desc_configuration_t;
-TU_VERIFY_STATIC( sizeof(tusb_desc_configuration_t) == 9, "size is not correct");
+TU_VERIFY_STATIC( sizeof(tusb_desc_configuration_t) == 9u, "size is not correct");
/// USB Interface Descriptor
typedef struct TU_ATTR_PACKED {
@@ -391,7 +391,7 @@ typedef struct TU_ATTR_PACKED {
uint8_t iInterface ; ///< Index of string descriptor describing this interface
} tusb_desc_interface_t;
-TU_VERIFY_STATIC( sizeof(tusb_desc_interface_t) == 9, "size is not correct");
+TU_VERIFY_STATIC( sizeof(tusb_desc_interface_t) == 9u, "size is not correct");
/// USB Endpoint Descriptor
typedef struct TU_ATTR_PACKED {
@@ -411,7 +411,7 @@ typedef struct TU_ATTR_PACKED {
uint8_t bInterval ; // Polling interval, in frames or microframes depending on the operating speed
} tusb_desc_endpoint_t;
-TU_VERIFY_STATIC( sizeof(tusb_desc_endpoint_t) == 7, "size is not correct");
+TU_VERIFY_STATIC( sizeof(tusb_desc_endpoint_t) == 7u, "size is not correct");
/// USB Other Speed Configuration Descriptor
typedef struct TU_ATTR_PACKED {
@@ -441,7 +441,7 @@ typedef struct TU_ATTR_PACKED {
uint8_t bReserved ; ///< Reserved for future use, must be zero
} tusb_desc_device_qualifier_t;
-TU_VERIFY_STATIC( sizeof(tusb_desc_device_qualifier_t) == 10, "size is not correct");
+TU_VERIFY_STATIC( sizeof(tusb_desc_device_qualifier_t) == 10u, "size is not correct");
/// USB Interface Association Descriptor (IAD ECN)
typedef struct TU_ATTR_PACKED {
@@ -458,7 +458,7 @@ typedef struct TU_ATTR_PACKED {
uint8_t iFunction ; ///< Index of the string descriptor describing the interface association.
} tusb_desc_interface_assoc_t;
-TU_VERIFY_STATIC( sizeof(tusb_desc_interface_assoc_t) == 8, "size is not correct");
+TU_VERIFY_STATIC( sizeof(tusb_desc_interface_assoc_t) == 8u, "size is not correct");
// USB String Descriptor
typedef struct TU_ATTR_PACKED {
@@ -528,7 +528,7 @@ typedef struct TU_ATTR_PACKED {
uint16_t wLength;
} tusb_control_request_t;
-TU_VERIFY_STATIC( sizeof(tusb_control_request_t) == 8, "size is not correct");
+TU_VERIFY_STATIC( sizeof(tusb_control_request_t) == 8u, "size is not correct");
TU_ATTR_PACKED_END // End of all packed definitions
TU_ATTR_BIT_FIELD_ORDER_END
diff --git a/src/device/dcd.h b/src/device/dcd.h
index f90156235..7744e4e00 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -79,7 +79,7 @@ typedef struct TU_ATTR_ALIGNED(4) {
// FUNC_CALL
struct {
- void (*func) (void*);
+ void (*func) (void* param);
void* param;
}func_call;
};
diff --git a/src/device/usbd.c b/src/device/usbd.c
index a664c2186..765bce572 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -1101,6 +1101,28 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num)
#if CFG_TUD_BTH && CFG_TUD_BTH_ISO_ALT_COUNT
if ( driver->open == btd_open ) assoc_itf_count = 2;
#endif
+
+ #if CFG_TUD_AUDIO
+ if (driver->open == audiod_open) {
+ // UAC1 device doesn't have IAD, needs to read AS interface count from CS AC descriptor
+ if (TUSB_CLASS_AUDIO == desc_itf->bInterfaceClass &&
+ AUDIO_SUBCLASS_CONTROL == desc_itf->bInterfaceSubClass &&
+ AUDIO_FUNC_PROTOCOL_CODE_UNDEF == desc_itf->bInterfaceProtocol) {
+ uint8_t const* p = tu_desc_next(p_desc);
+ uint8_t const* const itf_end = p_desc + remaining_len;
+ while (p < itf_end) {
+ if (TUSB_DESC_CS_INTERFACE == tu_desc_type(p) &&
+ AUDIO10_CS_AC_INTERFACE_HEADER == ((audio10_desc_cs_ac_interface_1_t const *) p)->bDescriptorSubType) {
+ audio10_desc_cs_ac_interface_1_t const * p_header = (audio10_desc_cs_ac_interface_1_t const *) p;
+ // AC + AS interfaces
+ assoc_itf_count = p_header->bInCollection + 1;
+ break;
+ }
+ p = tu_desc_next(p);
+ }
+ }
+ }
+ #endif
}
// bind (associated) interfaces to found driver
diff --git a/src/device/usbd.h b/src/device/usbd.h
index a4104e47d..bfff23399 100644
--- a/src/device/usbd.h
+++ b/src/device/usbd.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_USBD_H_
-#define _TUSB_USBD_H_
+#ifndef TUSB_USBD_H_
+#define TUSB_USBD_H_
#include "common/tusb_common.h"
@@ -299,7 +299,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
// Interface number, string index, protocol, report descriptor len, EP In address, size & polling interval
#define TUD_HID_DESCRIPTOR(_itfnum, _stridx, _boot_protocol, _report_desc_len, _epin, _epsize, _ep_interval) \
/* Interface */\
- 9, TUSB_DESC_INTERFACE, _itfnum, 0, 1, TUSB_CLASS_HID, (uint8_t)((_boot_protocol) ? (uint8_t)HID_SUBCLASS_BOOT : 0), _boot_protocol, _stridx,\
+ 9, TUSB_DESC_INTERFACE, _itfnum, 0, 1, TUSB_CLASS_HID, (uint8_t)((_boot_protocol != HID_ITF_PROTOCOL_NONE) ? (uint8_t)HID_SUBCLASS_BOOT : 0u), _boot_protocol, _stridx,\
/* HID descriptor */\
9, HID_DESC_TYPE_HID, U16_TO_U8S_LE(0x0111), 0, 1, HID_DESC_TYPE_REPORT, U16_TO_U8S_LE(_report_desc_len),\
/* Endpoint In */\
@@ -312,7 +312,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
// Interface number, string index, protocol, report descriptor len, EP OUT & IN address, size & polling interval
#define TUD_HID_INOUT_DESCRIPTOR(_itfnum, _stridx, _boot_protocol, _report_desc_len, _epout, _epin, _epsize, _ep_interval) \
/* Interface */\
- 9, TUSB_DESC_INTERFACE, _itfnum, 0, 2, TUSB_CLASS_HID, (uint8_t)((_boot_protocol) ? (uint8_t)HID_SUBCLASS_BOOT : 0), _boot_protocol, _stridx,\
+ 9, TUSB_DESC_INTERFACE, _itfnum, 0, 2, TUSB_CLASS_HID, (uint8_t)((_boot_protocol != HID_ITF_PROTOCOL_NONE) ? (uint8_t)HID_SUBCLASS_BOOT : 0u), _boot_protocol, _stridx,\
/* HID descriptor */\
9, HID_DESC_TYPE_HID, U16_TO_U8S_LE(0x0111), 0, 1, HID_DESC_TYPE_REPORT, U16_TO_U8S_LE(_report_desc_len),\
/* Endpoint Out */\
@@ -330,7 +330,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
/* Audio Control (AC) Interface */\
9, TUSB_DESC_INTERFACE, _itfnum, 0, 0, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_CONTROL, AUDIO_FUNC_PROTOCOL_CODE_UNDEF, _stridx,\
/* AC Header */\
- 9, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_HEADER, U16_TO_U8S_LE(0x0100), U16_TO_U8S_LE(0x0009), 1, (uint8_t)((_itfnum) + 1),\
+ 9, TUSB_DESC_CS_INTERFACE, AUDIO10_CS_AC_INTERFACE_HEADER, U16_TO_U8S_LE(0x0100), U16_TO_U8S_LE(0x0009), 1, (uint8_t)((_itfnum) + 1),\
/* MIDI Streaming (MS) Interface */\
9, TUSB_DESC_INTERFACE, (uint8_t)((_itfnum) + 1), 0, 2, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_MIDI_STREAMING, AUDIO_FUNC_PROTOCOL_CODE_UNDEF, 0,\
/* MS Header */\
@@ -383,242 +383,352 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
TUD_MIDI_JACKID_OUT_EMB(1)
//--------------------------------------------------------------------+
-// Audio v2.0 Descriptor Templates
+// Audio Descriptor Templates
//--------------------------------------------------------------------+
+
+/* Audio v1.0 Descriptor Templates */
+
+/* Standard AC Interface Descriptor UAC1 (4.3.1) */
+#define TUD_AUDIO10_DESC_STD_AC_LEN 9
+#define TUD_AUDIO10_DESC_STD_AC(_itfnum, _nEPs, _stridx) \
+ TUD_AUDIO10_DESC_STD_AC_LEN, TUSB_DESC_INTERFACE, _itfnum, 0x00, _nEPs, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_CONTROL, AUDIO_INT_PROTOCOL_CODE_V1, _stridx
+
+/* Class-Specific AC Interface Header Descriptor UAC1 (4.3.2) */
+#define TUD_AUDIO10_DESC_CS_AC_LEN(_nintfs) (8 + (_nintfs))
+// Class-Specific AC Interface Header descriptor, take list of streaming interface numbers as variable arguments
+#define TUD_AUDIO10_DESC_CS_AC(_bcdADC, _totallen, ...) \
+ TUD_AUDIO10_DESC_CS_AC_LEN(TU_ARGS_NUM(__VA_ARGS__)), TUSB_DESC_CS_INTERFACE, AUDIO10_CS_AC_INTERFACE_HEADER, U16_TO_U8S_LE(_bcdADC), U16_TO_U8S_LE(_totallen + TUD_AUDIO10_DESC_CS_AC_LEN(TU_ARGS_NUM(__VA_ARGS__))), TU_ARGS_NUM(__VA_ARGS__), __VA_ARGS__
+
+/* Input Terminal Descriptor UAC1 (4.3.2.1) */
+#define TUD_AUDIO10_DESC_INPUT_TERM_LEN 12
+#define TUD_AUDIO10_DESC_INPUT_TERM(_termid, _termtype, _assocTerm, _nchannels, _channelcfg, _idxchannelnames, _stridx) \
+ TUD_AUDIO10_DESC_INPUT_TERM_LEN, TUSB_DESC_CS_INTERFACE, AUDIO10_CS_AC_INTERFACE_INPUT_TERMINAL, _termid, U16_TO_U8S_LE(_termtype), _assocTerm, _nchannels, U16_TO_U8S_LE(_channelcfg), _idxchannelnames, _stridx
+
+/* Output Terminal Descriptor UAC1 (4.3.2.2) */
+#define TUD_AUDIO10_DESC_OUTPUT_TERM_LEN 9
+#define TUD_AUDIO10_DESC_OUTPUT_TERM(_termid, _termtype, _assocTerm, _srcid, _stridx) \
+ TUD_AUDIO10_DESC_OUTPUT_TERM_LEN, TUSB_DESC_CS_INTERFACE, AUDIO10_CS_AC_INTERFACE_OUTPUT_TERMINAL, _termid, U16_TO_U8S_LE(_termtype), _assocTerm, _srcid, _stridx
+
+/* Mixer Unit Descriptor UAC1 (4.3.2.3) - One Input Pin */
+#define TUD_AUDIO10_DESC_MIXER_UNIT_ONE_PIN_LEN(_ctrlsize) (11 + (_ctrlsize))
+#define TUD_AUDIO10_DESC_MIXER_UNIT_ONE_PIN(_unitid, _srcid, _nrchannels, _channelcfg, _idxchannelnames, _ctrlsize, _stridx, ...) \
+ TUD_AUDIO10_DESC_MIXER_UNIT_ONE_PIN_LEN(_ctrlsize), TUSB_DESC_CS_INTERFACE, AUDIO10_CS_AC_INTERFACE_MIXER_UNIT, _unitid, 1, _srcid, _nrchannels, U16_TO_U8S_LE(_channelcfg), _idxchannelnames, __VA_ARGS__, _stridx
+
+/* Selector Unit Descriptor UAC1 (4.3.2.4) - One Input Pin */
+#define TUD_AUDIO10_DESC_SELECTOR_UNIT_ONE_PIN_LEN 7
+#define TUD_AUDIO10_DESC_SELECTOR_UNIT_ONE_PIN(_unitid, _srcid, _stridx) \
+ TUD_AUDIO10_DESC_SELECTOR_UNIT_ONE_PIN_LEN, TUSB_DESC_CS_INTERFACE, AUDIO10_CS_AC_INTERFACE_SELECTOR_UNIT, _unitid, 1, _srcid, _stridx
+
+/* Feature Unit Descriptor UAC1 (4.3.2.5) - Variable Channels */
+#define TUD_AUDIO10_DESC_FEATURE_UNIT_LEN(_nchannels) (7 + (_nchannels + 1) * 2)
+// Feature Unit descriptor, take list of control bitmaps for master channel + each channel as variable arguments
+#define TUD_AUDIO10_DESC_FEATURE_UNIT(_unitid, _srcid, _stridx, ...) \
+ TUD_AUDIO10_DESC_FEATURE_UNIT_LEN(TU_ARGS_NUM(__VA_ARGS__) - 1), TUSB_DESC_CS_INTERFACE, AUDIO10_CS_AC_INTERFACE_FEATURE_UNIT, _unitid, _srcid, 2, TU_ARGS_APPLY_EXPAND(U16_TO_U8S_LE, __VA_ARGS__), _stridx
+
+/* Standard AS Interface Descriptor UAC1 (4.5.1) */
+#define TUD_AUDIO10_DESC_STD_AS_LEN 9
+#define TUD_AUDIO10_DESC_STD_AS_INT(_itfnum, _altset, _nEPs, _stridx) \
+ TUD_AUDIO10_DESC_STD_AS_LEN, TUSB_DESC_INTERFACE, _itfnum, _altset, _nEPs, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_STREAMING, AUDIO_INT_PROTOCOL_CODE_V1, _stridx
+
+/* Class-Specific AS Interface Descriptor UAC1 (4.5.2) */
+#define TUD_AUDIO10_DESC_CS_AS_INT_LEN 7
+#define TUD_AUDIO10_DESC_CS_AS_INT(_termid, _delay, _formattype) \
+ TUD_AUDIO10_DESC_CS_AS_INT_LEN, TUSB_DESC_CS_INTERFACE, AUDIO10_CS_AS_INTERFACE_AS_GENERAL, _termid, _delay, U16_TO_U8S_LE(_formattype)
+
+/* Type I Format Type Descriptor UAC1 (2.2.5) */
+#define TUD_AUDIO10_DESC_TYPE_I_FORMAT_LEN(_nfreqs) (8 + (_nfreqs)*3)
+// Type I Format descriptor, take list of sample rates in Hz as variable arguments
+#define TUD_AUDIO10_DESC_TYPE_I_FORMAT(_nrchannels, _subframesize, _bitresolution, ...) \
+ TUD_AUDIO10_DESC_TYPE_I_FORMAT_LEN(TU_ARGS_NUM(__VA_ARGS__)), TUSB_DESC_CS_INTERFACE, AUDIO10_CS_AS_INTERFACE_FORMAT_TYPE, AUDIO10_FORMAT_TYPE_I, _nrchannels, _subframesize, _bitresolution, TU_ARGS_NUM(__VA_ARGS__), TU_ARGS_APPLY_EXPAND(U24_TO_U8S_LE, __VA_ARGS__)
+
+/* Standard AS Isochronous Audio Data Endpoint Descriptor UAC1 (4.6.1.1) */
+#define TUD_AUDIO10_DESC_STD_AS_ISO_EP_LEN 9
+#define TUD_AUDIO10_DESC_STD_AS_ISO_EP(_ep, _attr, _maxEPsize, _interval, _sync_ep) \
+ TUD_AUDIO10_DESC_STD_AS_ISO_EP_LEN, TUSB_DESC_ENDPOINT, _ep, _attr, U16_TO_U8S_LE(_maxEPsize), _interval, 0x00, _sync_ep
+
+/* Class-Specific AS Isochronous Audio Data Endpoint Descriptor UAC1 (4.6.1.2) */
+#define TUD_AUDIO10_DESC_CS_AS_ISO_EP_LEN 7
+#define TUD_AUDIO10_DESC_CS_AS_ISO_EP(_attr, _lockdelayunits, _lockdelay) \
+ TUD_AUDIO10_DESC_CS_AS_ISO_EP_LEN, TUSB_DESC_CS_ENDPOINT, AUDIO10_CS_EP_SUBTYPE_GENERAL, _attr, _lockdelayunits, U16_TO_U8S_LE(_lockdelay)
+
+/* Standard AS Isochronous Synch Endpoint Descriptor UAC1 (4.6.2.1) */
+#define TUD_AUDIO10_DESC_STD_AS_ISO_SYNC_EP_LEN 9
+#define TUD_AUDIO10_DESC_STD_AS_ISO_SYNC_EP(_ep, _bRefresh) \
+ TUD_AUDIO10_DESC_STD_AS_ISO_SYNC_EP_LEN, TUSB_DESC_ENDPOINT, _ep, TUSB_XFER_ISOCHRONOUS, U16_TO_U8S_LE(3), 1, _bRefresh, 0x00
+
+/* Standard AC Interrupt Endpoint Descriptor UAC1 (4.4.2) */
+#define TUD_AUDIO10_DESC_STD_AC_INT_EP_LEN 9
+#define TUD_AUDIO10_DESC_STD_AC_INT_EP(_ep, _interval) \
+ TUD_AUDIO10_DESC_STD_AC_INT_EP_LEN, TUSB_DESC_ENDPOINT, _ep, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(2), _interval, 0x00, 0x00
+
+// AUDIO simple descriptor templates for UAC1
+
+// AUDIO simple descriptor (UAC1) for 1 microphone input
+// - 1 Input Terminal, 1 Feature Unit (Mute and Volume Control), 1 Output Terminal
+
+#define TUD_AUDIO10_MIC_ONE_CH_DESC_LEN(_nfreqs) (\
+ + TUD_AUDIO10_DESC_STD_AC_LEN\
+ + TUD_AUDIO10_DESC_CS_AC_LEN(1)\
+ + TUD_AUDIO10_DESC_INPUT_TERM_LEN\
+ + TUD_AUDIO10_DESC_OUTPUT_TERM_LEN\
+ + TUD_AUDIO10_DESC_FEATURE_UNIT_LEN(1)\
+ + TUD_AUDIO10_DESC_STD_AS_LEN\
+ + TUD_AUDIO10_DESC_STD_AS_LEN\
+ + TUD_AUDIO10_DESC_CS_AS_INT_LEN\
+ + TUD_AUDIO10_DESC_TYPE_I_FORMAT_LEN(_nfreqs)\
+ + TUD_AUDIO10_DESC_STD_AS_ISO_EP_LEN\
+ + TUD_AUDIO10_DESC_CS_AS_ISO_EP_LEN)
+
+#define TUD_AUDIO10_MIC_ONE_CH_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epin, _epsize, ...) \
+ /* Standard AC Interface Descriptor(4.3.1) */\
+ TUD_AUDIO10_DESC_STD_AC(/*_itfnum*/ _itfnum, /*_nEPs*/ 0x00, /*_stridx*/ _stridx),\
+ /* Class-Specific AC Interface Header Descriptor(4.3.2) */\
+ TUD_AUDIO10_DESC_CS_AC(/*_bcdADC*/ 0x0100, /*_totallen*/ (TUD_AUDIO10_DESC_INPUT_TERM_LEN+TUD_AUDIO10_DESC_OUTPUT_TERM_LEN+TUD_AUDIO10_DESC_FEATURE_UNIT_LEN(1)), /*_itf*/ ((_itfnum)+1)),\
+ /* Input Terminal Descriptor(4.3.2.1) */\
+ TUD_AUDIO10_DESC_INPUT_TERM(/*_termid*/ 0x01, /*_termtype*/ AUDIO_TERM_TYPE_IN_GENERIC_MIC, /*_assocTerm*/ 0x03, /*_nchannels*/ 0x01, /*_channelcfg*/ AUDIO10_CHANNEL_CONFIG_NON_PREDEFINED, /*_idxchannelnames*/ 0x00, /*_stridx*/ 0x00),\
+ /* Output Terminal Descriptor(4.3.2.2) */\
+ TUD_AUDIO10_DESC_OUTPUT_TERM(/*_termid*/ 0x03, /*_termtype*/ AUDIO_TERM_TYPE_USB_STREAMING, /*_assocTerm*/ 0x01, /*_srcid*/ 0x02, /*_stridx*/ 0x00),\
+ /* Feature Unit Descriptor(4.3.2.5) */\
+ TUD_AUDIO10_DESC_FEATURE_UNIT(/*_unitid*/ 0x02, /*_srcid*/ 0x01, /*_stridx*/ 0x00, /*_ctrlmaster*/ (AUDIO10_FU_CONTROL_BM_MUTE | AUDIO10_FU_CONTROL_BM_VOLUME), /*_ctrlch1*/ (AUDIO10_FU_CONTROL_BM_MUTE | AUDIO10_FU_CONTROL_BM_VOLUME)),\
+ /* Standard AS Interface Descriptor(4.5.1) */\
+ /* Interface 1, Alternate 0 - default alternate setting with 0 bandwidth */\
+ TUD_AUDIO10_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x00, /*_nEPs*/ 0x00, /*_stridx*/ 0x00),\
+ /* Standard AS Interface Descriptor(4.5.1) */\
+ /* Interface 1, Alternate 1 - alternate interface for data streaming */\
+ TUD_AUDIO10_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x01, /*_nEPs*/ 0x01, /*_stridx*/ 0x00),\
+ /* Class-Specific AS Interface Descriptor(4.5.2) */\
+ TUD_AUDIO10_DESC_CS_AS_INT(/*_termid*/ 0x03, /*_delay*/ 0x01, /*_formattype*/ AUDIO10_DATA_FORMAT_TYPE_I_PCM),\
+ /* Type I Format Type Descriptor(2.2.5) */\
+ TUD_AUDIO10_DESC_TYPE_I_FORMAT(/*_nrchannels*/ 0x01, /*_subframesize*/ _nBytesPerSample, /*_bitresolution*/ _nBitsUsedPerSample, /*_freq*/ __VA_ARGS__),\
+ /* Standard AS Isochronous Audio Data Endpoint Descriptor(4.6.1.1) */\
+ TUD_AUDIO10_DESC_STD_AS_ISO_EP(/*_ep*/ _epin, /*_attr*/ (uint8_t) ((uint8_t)TUSB_XFER_ISOCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_ASYNCHRONOUS), /*_maxEPsize*/ _epsize, /*_interval*/ 0x01, /* _sync_ep */ 0x00),\
+ /* Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.6.1.2) */\
+ TUD_AUDIO10_DESC_CS_AS_ISO_EP(/*_attr*/ AUDIO10_CS_AS_ISO_DATA_EP_ATT_SAMPLING_FRQ, /*_lockdelayunits*/ AUDIO10_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_MILLISEC, /*_lockdelay*/ 0x0001)
+
+/* Audio v2.0 Descriptor Templates */
+
/* Standard Interface Association Descriptor (IAD) */
-#define TUD_AUDIO_DESC_IAD_LEN 8
-#define TUD_AUDIO_DESC_IAD(_firstitf, _nitfs, _stridx) \
- TUD_AUDIO_DESC_IAD_LEN, TUSB_DESC_INTERFACE_ASSOCIATION, _firstitf, _nitfs, TUSB_CLASS_AUDIO, AUDIO_FUNCTION_SUBCLASS_UNDEFINED, AUDIO_FUNC_PROTOCOL_CODE_V2, _stridx
+#define TUD_AUDIO20_DESC_IAD_LEN 8
+#define TUD_AUDIO20_DESC_IAD(_firstitf, _nitfs, _stridx) \
+ TUD_AUDIO20_DESC_IAD_LEN, TUSB_DESC_INTERFACE_ASSOCIATION, _firstitf, _nitfs, TUSB_CLASS_AUDIO, AUDIO_FUNCTION_SUBCLASS_UNDEFINED, AUDIO_FUNC_PROTOCOL_CODE_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_INT_PROTOCOL_CODE_V2, _stridx
+#define TUD_AUDIO20_DESC_STD_AC_LEN 9
+#define TUD_AUDIO20_DESC_STD_AC(_itfnum, _nEPs, _stridx) /* _nEPs is 0 or 1 */\
+ TUD_AUDIO20_DESC_STD_AC_LEN, TUSB_DESC_INTERFACE, _itfnum, /* fixed to zero */ 0x00, _nEPs, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_CONTROL, AUDIO_INT_PROTOCOL_CODE_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
+#define TUD_AUDIO20_DESC_CS_AC_LEN 9
+#define TUD_AUDIO20_DESC_CS_AC(_bcdADC, _category, _totallen, _ctrl) /* _bcdADC : Audio Device Class Specification Release Number in Binary-Coded Decimal, _category : see audio20_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_AUDIO20_DESC_CS_AC_LEN, we already do this here*/ \
+ TUD_AUDIO20_DESC_CS_AC_LEN, TUSB_DESC_CS_INTERFACE, AUDIO20_CS_AC_INTERFACE_HEADER, U16_TO_U8S_LE(_bcdADC), _category, U16_TO_U8S_LE(_totallen + TUD_AUDIO20_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
+#define TUD_AUDIO20_DESC_CLK_SRC_LEN 8
+#define TUD_AUDIO20_DESC_CLK_SRC(_clkid, _attr, _ctrl, _assocTerm, _stridx) \
+ TUD_AUDIO20_DESC_CLK_SRC_LEN, TUSB_DESC_CS_INTERFACE, AUDIO20_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
+#define TUD_AUDIO20_DESC_INPUT_TERM_LEN 17
+#define TUD_AUDIO20_DESC_INPUT_TERM(_termid, _termtype, _assocTerm, _clkid, _nchannelslogical, _channelcfg, _idxchannelnames, _ctrl, _stridx) \
+ TUD_AUDIO20_DESC_INPUT_TERM_LEN, TUSB_DESC_CS_INTERFACE, AUDIO20_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
+#define TUD_AUDIO20_DESC_OUTPUT_TERM_LEN 12
+#define TUD_AUDIO20_DESC_OUTPUT_TERM(_termid, _termtype, _assocTerm, _srcid, _clkid, _ctrl, _stridx) \
+ TUD_AUDIO20_DESC_OUTPUT_TERM_LEN, TUSB_DESC_CS_INTERFACE, AUDIO20_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
-
-// 2 - Channels
-#define TUD_AUDIO_DESC_FEATURE_UNIT_TWO_CHANNEL_LEN (6+(2+1)*4)
-#define TUD_AUDIO_DESC_FEATURE_UNIT_TWO_CHANNEL(_unitid, _srcid, _ctrlch0master, _ctrlch1, _ctrlch2, _stridx) \
- TUD_AUDIO_DESC_FEATURE_UNIT_TWO_CHANNEL_LEN, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_FEATURE_UNIT, _unitid, _srcid, U32_TO_U8S_LE(_ctrlch0master), U32_TO_U8S_LE(_ctrlch1), U32_TO_U8S_LE(_ctrlch2), _stridx
-// 4 - Channels
-#define TUD_AUDIO_DESC_FEATURE_UNIT_FOUR_CHANNEL_LEN (6+(4+1)*4)
-#define TUD_AUDIO_DESC_FEATURE_UNIT_FOUR_CHANNEL(_unitid, _srcid, _ctrlch0master, _ctrlch1, _ctrlch2, _ctrlch3, _ctrlch4, _stridx) \
- TUD_AUDIO_DESC_FEATURE_UNIT_FOUR_CHANNEL_LEN, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_FEATURE_UNIT, _unitid, _srcid, U32_TO_U8S_LE(_ctrlch0master), U32_TO_U8S_LE(_ctrlch1), U32_TO_U8S_LE(_ctrlch2), U32_TO_U8S_LE(_ctrlch3), U32_TO_U8S_LE(_ctrlch4), _stridx
-
-// For more channels, add definitions here
+#define TUD_AUDIO20_DESC_FEATURE_UNIT_LEN(_nchannels) (6 + (_nchannels + 1) * 4)
+#define TUD_AUDIO20_DESC_FEATURE_UNIT(_unitid, _srcid, _stridx, ...) \
+ TUD_AUDIO20_DESC_FEATURE_UNIT_LEN(TU_ARGS_NUM(__VA_ARGS__) - 1), TUSB_DESC_CS_INTERFACE, AUDIO20_CS_AC_INTERFACE_FEATURE_UNIT, _unitid, _srcid, TU_ARGS_APPLY_EXPAND(U32_TO_U8S_LE, __VA_ARGS__), _stridx
/* Standard AC Interrupt Endpoint Descriptor(4.8.2.1) */
-#define TUD_AUDIO_DESC_STD_AC_INT_EP_LEN 7
-#define TUD_AUDIO_DESC_STD_AC_INT_EP(_ep, _interval) \
- TUD_AUDIO_DESC_STD_AC_INT_EP_LEN, TUSB_DESC_ENDPOINT, _ep, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(6), _interval
+#define TUD_AUDIO20_DESC_STD_AC_INT_EP_LEN 7
+#define TUD_AUDIO20_DESC_STD_AC_INT_EP(_ep, _interval) \
+ TUD_AUDIO20_DESC_STD_AC_INT_EP_LEN, TUSB_DESC_ENDPOINT, _ep, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(6), _interval
/* 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_INT_PROTOCOL_CODE_V2, _stridx
+#define TUD_AUDIO20_DESC_STD_AS_LEN 9
+#define TUD_AUDIO20_DESC_STD_AS_INT(_itfnum, _altset, _nEPs, _stridx) \
+ TUD_AUDIO20_DESC_STD_AS_LEN, TUSB_DESC_INTERFACE, _itfnum, _altset, _nEPs, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_STREAMING, AUDIO_INT_PROTOCOL_CODE_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
+#define TUD_AUDIO20_DESC_CS_AS_INT_LEN 16
+#define TUD_AUDIO20_DESC_CS_AS_INT(_termid, _ctrl, _formattype, _formats, _nchannelsphysical, _channelcfg, _stridx) \
+ TUD_AUDIO20_DESC_CS_AS_INT_LEN, TUSB_DESC_CS_INTERFACE, AUDIO20_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
+#define TUD_AUDIO20_DESC_TYPE_I_FORMAT_LEN 6
+#define TUD_AUDIO20_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_AUDIO20_DESC_TYPE_I_FORMAT_LEN, TUSB_DESC_CS_INTERFACE, AUDIO20_CS_AS_INTERFACE_FORMAT_TYPE, AUDIO20_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
+#define TUD_AUDIO20_DESC_STD_AS_ISO_EP_LEN 7
+#define TUD_AUDIO20_DESC_STD_AS_ISO_EP(_ep, _attr, _maxEPsize, _interval) \
+ TUD_AUDIO20_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)
+#define TUD_AUDIO20_DESC_CS_AS_ISO_EP_LEN 8
+#define TUD_AUDIO20_DESC_CS_AS_ISO_EP(_attr, _ctrl, _lockdelayunit, _lockdelay) \
+ TUD_AUDIO20_DESC_CS_AS_ISO_EP_LEN, TUSB_DESC_CS_ENDPOINT, AUDIO20_CS_EP_SUBTYPE_GENERAL, _attr, _ctrl, _lockdelayunit, U16_TO_U8S_LE(_lockdelay)
/* Standard AS Isochronous Feedback Endpoint Descriptor(4.10.2.1) */
-#define TUD_AUDIO_DESC_STD_AS_ISO_FB_EP_LEN 7
-#define TUD_AUDIO_DESC_STD_AS_ISO_FB_EP(_ep, _epsize, _interval) \
- TUD_AUDIO_DESC_STD_AS_ISO_FB_EP_LEN, TUSB_DESC_ENDPOINT, _ep, (uint8_t) ((uint8_t)TUSB_XFER_ISOCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_NO_SYNC | (uint8_t)TUSB_ISO_EP_ATT_EXPLICIT_FB), U16_TO_U8S_LE(_epsize), _interval
+#define TUD_AUDIO20_DESC_STD_AS_ISO_FB_EP_LEN 7
+#define TUD_AUDIO20_DESC_STD_AS_ISO_FB_EP(_ep, _epsize, _interval) \
+ TUD_AUDIO20_DESC_STD_AS_ISO_FB_EP_LEN, TUSB_DESC_ENDPOINT, _ep, (uint8_t) ((uint8_t)TUSB_XFER_ISOCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_NO_SYNC | (uint8_t)TUSB_ISO_EP_ATT_EXPLICIT_FB), U16_TO_U8S_LE(_epsize), _interval
// 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_ONE_CH_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_AUDIO20_MIC_ONE_CH_DESC_LEN (TUD_AUDIO20_DESC_IAD_LEN\
+ + TUD_AUDIO20_DESC_STD_AC_LEN\
+ + TUD_AUDIO20_DESC_CS_AC_LEN\
+ + TUD_AUDIO20_DESC_CLK_SRC_LEN\
+ + TUD_AUDIO20_DESC_INPUT_TERM_LEN\
+ + TUD_AUDIO20_DESC_OUTPUT_TERM_LEN\
+ + TUD_AUDIO20_DESC_FEATURE_UNIT_LEN(1)\
+ + TUD_AUDIO20_DESC_STD_AS_LEN\
+ + TUD_AUDIO20_DESC_STD_AS_LEN\
+ + TUD_AUDIO20_DESC_CS_AS_INT_LEN\
+ + TUD_AUDIO20_DESC_TYPE_I_FORMAT_LEN\
+ + TUD_AUDIO20_DESC_STD_AS_ISO_EP_LEN\
+ + TUD_AUDIO20_DESC_CS_AS_ISO_EP_LEN)
-#define TUD_AUDIO_MIC_ONE_CH_DESC_N_AS_INT 1 // Number of AS interfaces
+#define TUD_AUDIO20_MIC_ONE_CH_DESC_N_AS_INT 1 // Number of AS interfaces
-#define TUD_AUDIO_MIC_ONE_CH_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epin, _epsize) \
+#define TUD_AUDIO20_MIC_ONE_CH_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epin, _epsize) \
/* Standard Interface Association Descriptor (IAD) */\
- TUD_AUDIO_DESC_IAD(/*_firstitf*/ _itfnum, /*_nitfs*/ 0x02, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_IAD(/*_firstitf*/ _itfnum, /*_nitfs*/ 0x02, /*_stridx*/ 0x00),\
/* Standard AC Interface Descriptor(4.7.1) */\
- TUD_AUDIO_DESC_STD_AC(/*_itfnum*/ _itfnum, /*_nEPs*/ 0x00, /*_stridx*/ _stridx),\
+ TUD_AUDIO20_DESC_STD_AC(/*_itfnum*/ _itfnum, /*_nEPs*/ 0x00, /*_stridx*/ _stridx),\
/* Class-Specific AC Interface Header Descriptor(4.7.2) */\
- 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),\
+ TUD_AUDIO20_DESC_CS_AC(/*_bcdADC*/ 0x0200, /*_category*/ AUDIO20_FUNC_MICROPHONE, /*_totallen*/ TUD_AUDIO20_DESC_CLK_SRC_LEN+TUD_AUDIO20_DESC_INPUT_TERM_LEN+TUD_AUDIO20_DESC_OUTPUT_TERM_LEN+TUD_AUDIO20_DESC_FEATURE_UNIT_LEN(1), /*_ctrl*/ AUDIO20_CS_AS_INTERFACE_CTRL_LATENCY_POS),\
/* Clock Source Descriptor(4.7.2.1) */\
- 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),\
+ TUD_AUDIO20_DESC_CLK_SRC(/*_clkid*/ 0x04, /*_attr*/ AUDIO20_CLOCK_SOURCE_ATT_INT_FIX_CLK, /*_ctrl*/ (AUDIO20_CTRL_R << AUDIO20_CLOCK_SOURCE_CTRL_CLK_FRQ_POS), /*_assocTerm*/ 0x01, /*_stridx*/ 0x00),\
/* Input Terminal Descriptor(4.7.2.4) */\
- 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),\
+ TUD_AUDIO20_DESC_INPUT_TERM(/*_termid*/ 0x01, /*_termtype*/ AUDIO_TERM_TYPE_IN_GENERIC_MIC, /*_assocTerm*/ 0x03, /*_clkid*/ 0x04, /*_nchannelslogical*/ 0x01, /*_channelcfg*/ AUDIO20_CHANNEL_CONFIG_NON_PREDEFINED, /*_idxchannelnames*/ 0x00, /*_ctrl*/ AUDIO20_CTRL_R << AUDIO20_IN_TERM_CTRL_CONNECTOR_POS, /*_stridx*/ 0x00),\
/* Output Terminal Descriptor(4.7.2.5) */\
- TUD_AUDIO_DESC_OUTPUT_TERM(/*_termid*/ 0x03, /*_termtype*/ AUDIO_TERM_TYPE_USB_STREAMING, /*_assocTerm*/ 0x01, /*_srcid*/ 0x02, /*_clkid*/ 0x04, /*_ctrl*/ 0x0000, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_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) */\
- 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),\
+ TUD_AUDIO20_DESC_FEATURE_UNIT(/*_unitid*/ 0x02, /*_srcid*/ 0x01, /*_stridx*/ 0x00, /*_ctrlch0master*/ AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch1*/ AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_VOLUME_POS),\
/* Standard AS Interface Descriptor(4.9.1) */\
/* Interface 1, Alternate 0 - default alternate setting with 0 bandwidth */\
- TUD_AUDIO_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x00, /*_nEPs*/ 0x00, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x00, /*_nEPs*/ 0x00, /*_stridx*/ 0x00),\
/* Standard AS Interface Descriptor(4.9.1) */\
/* Interface 1, Alternate 1 - alternate interface for data streaming */\
- TUD_AUDIO_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x01, /*_nEPs*/ 0x01, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x01, /*_nEPs*/ 0x01, /*_stridx*/ 0x00),\
/* Class-Specific AS Interface Descriptor(4.9.2) */\
- 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),\
+ TUD_AUDIO20_DESC_CS_AS_INT(/*_termid*/ 0x03, /*_ctrl*/ AUDIO20_CTRL_NONE, /*_formattype*/ AUDIO20_FORMAT_TYPE_I, /*_formats*/ AUDIO20_DATA_FORMAT_TYPE_I_PCM, /*_nchannelsphysical*/ 0x01, /*_channelcfg*/ AUDIO20_CHANNEL_CONFIG_NON_PREDEFINED, /*_stridx*/ 0x00),\
/* Type I Format Type Descriptor(2.3.1.6 - Audio Formats) */\
- TUD_AUDIO_DESC_TYPE_I_FORMAT(_nBytesPerSample, _nBitsUsedPerSample),\
+ TUD_AUDIO20_DESC_TYPE_I_FORMAT(_nBytesPerSample, _nBitsUsedPerSample),\
/* Standard AS Isochronous Audio Data Endpoint Descriptor(4.10.1.1) */\
- TUD_AUDIO_DESC_STD_AS_ISO_EP(/*_ep*/ _epin, /*_attr*/ (uint8_t) ((uint8_t)TUSB_XFER_ISOCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_ASYNCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_DATA), /*_maxEPsize*/ _epsize, /*_interval*/ 0x01),\
+ TUD_AUDIO20_DESC_STD_AS_ISO_EP(/*_ep*/ _epin, /*_attr*/ (uint8_t) ((uint8_t)TUSB_XFER_ISOCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_ASYNCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_DATA), /*_maxEPsize*/ _epsize, /*_interval*/ 0x01),\
/* Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.10.1.2) */\
- 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)
+ TUD_AUDIO20_DESC_CS_AS_ISO_EP(/*_attr*/ AUDIO20_CS_AS_ISO_DATA_EP_ATT_NON_MAX_PACKETS_OK, /*_ctrl*/ AUDIO20_CTRL_NONE, /*_lockdelayunit*/ AUDIO20_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_UNDEFINED, /*_lockdelay*/ 0x0000)
// AUDIO simple descriptor (UAC2) for 4 microphone input
// - 1 Input Terminal, 1 Feature Unit (Mute and Volume Control), 1 Output Terminal, 1 Clock Source
-#define TUD_AUDIO_MIC_FOUR_CH_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_FOUR_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_AUDIO20_MIC_FOUR_CH_DESC_LEN (TUD_AUDIO20_DESC_IAD_LEN\
+ + TUD_AUDIO20_DESC_STD_AC_LEN\
+ + TUD_AUDIO20_DESC_CS_AC_LEN\
+ + TUD_AUDIO20_DESC_CLK_SRC_LEN\
+ + TUD_AUDIO20_DESC_INPUT_TERM_LEN\
+ + TUD_AUDIO20_DESC_OUTPUT_TERM_LEN\
+ + TUD_AUDIO20_DESC_FEATURE_UNIT_LEN(4)\
+ + TUD_AUDIO20_DESC_STD_AS_LEN\
+ + TUD_AUDIO20_DESC_STD_AS_LEN\
+ + TUD_AUDIO20_DESC_CS_AS_INT_LEN\
+ + TUD_AUDIO20_DESC_TYPE_I_FORMAT_LEN\
+ + TUD_AUDIO20_DESC_STD_AS_ISO_EP_LEN\
+ + TUD_AUDIO20_DESC_CS_AS_ISO_EP_LEN)
-#define TUD_AUDIO_MIC_FOUR_CH_DESC_N_AS_INT 1 // Number of AS interfaces
+#define TUD_AUDIO20_MIC_FOUR_CH_DESC_N_AS_INT 1 // Number of AS interfaces
-#define TUD_AUDIO_MIC_FOUR_CH_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epin, _epsize) \
+#define TUD_AUDIO20_MIC_FOUR_CH_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epin, _epsize) \
/* Standard Interface Association Descriptor (IAD) */\
- TUD_AUDIO_DESC_IAD(/*_firstitf*/ _itfnum, /*_nitfs*/ 0x02, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_IAD(/*_firstitf*/ _itfnum, /*_nitfs*/ 0x02, /*_stridx*/ 0x00),\
/* Standard AC Interface Descriptor(4.7.1) */\
- TUD_AUDIO_DESC_STD_AC(/*_itfnum*/ _itfnum, /*_nEPs*/ 0x00, /*_stridx*/ _stridx),\
+ TUD_AUDIO20_DESC_STD_AC(/*_itfnum*/ _itfnum, /*_nEPs*/ 0x00, /*_stridx*/ _stridx),\
/* Class-Specific AC Interface Header Descriptor(4.7.2) */\
- 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_FOUR_CHANNEL_LEN, /*_ctrl*/ AUDIO_CS_AS_INTERFACE_CTRL_LATENCY_POS),\
+ TUD_AUDIO20_DESC_CS_AC(/*_bcdADC*/ 0x0200, /*_category*/ AUDIO20_FUNC_MICROPHONE, /*_totallen*/ TUD_AUDIO20_DESC_CLK_SRC_LEN+TUD_AUDIO20_DESC_INPUT_TERM_LEN+TUD_AUDIO20_DESC_OUTPUT_TERM_LEN+TUD_AUDIO20_DESC_FEATURE_UNIT_LEN(4), /*_ctrl*/ AUDIO20_CS_AS_INTERFACE_CTRL_LATENCY_POS),\
/* Clock Source Descriptor(4.7.2.1) */\
- 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),\
+ TUD_AUDIO20_DESC_CLK_SRC(/*_clkid*/ 0x04, /*_attr*/ AUDIO20_CLOCK_SOURCE_ATT_INT_FIX_CLK, /*_ctrl*/ (AUDIO20_CTRL_R << AUDIO20_CLOCK_SOURCE_CTRL_CLK_FRQ_POS), /*_assocTerm*/ 0x01, /*_stridx*/ 0x00),\
/* Input Terminal Descriptor(4.7.2.4) */\
- TUD_AUDIO_DESC_INPUT_TERM(/*_termid*/ 0x01, /*_termtype*/ AUDIO_TERM_TYPE_IN_GENERIC_MIC, /*_assocTerm*/ 0x03, /*_clkid*/ 0x04, /*_nchannelslogical*/ 0x04, /*_channelcfg*/ AUDIO_CHANNEL_CONFIG_NON_PREDEFINED, /*_idxchannelnames*/ 0x00, /*_ctrl*/ AUDIO_CTRL_R << AUDIO_IN_TERM_CTRL_CONNECTOR_POS, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_INPUT_TERM(/*_termid*/ 0x01, /*_termtype*/ AUDIO_TERM_TYPE_IN_GENERIC_MIC, /*_assocTerm*/ 0x03, /*_clkid*/ 0x04, /*_nchannelslogical*/ 0x04, /*_channelcfg*/ AUDIO20_CHANNEL_CONFIG_NON_PREDEFINED, /*_idxchannelnames*/ 0x00, /*_ctrl*/ AUDIO20_CTRL_R << AUDIO20_IN_TERM_CTRL_CONNECTOR_POS, /*_stridx*/ 0x00),\
/* Output Terminal Descriptor(4.7.2.5) */\
- TUD_AUDIO_DESC_OUTPUT_TERM(/*_termid*/ 0x03, /*_termtype*/ AUDIO_TERM_TYPE_USB_STREAMING, /*_assocTerm*/ 0x01, /*_srcid*/ 0x02, /*_clkid*/ 0x04, /*_ctrl*/ 0x0000, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_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) */\
- TUD_AUDIO_DESC_FEATURE_UNIT_FOUR_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, /*_ctrlch2*/ AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch3*/ AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch4*/ AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_FEATURE_UNIT(/*_unitid*/ 0x02, /*_srcid*/ 0x01, /*_stridx*/ 0x00, /*_ctrlch0master*/ AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch1*/ AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch2*/ AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch3*/ AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch4*/ AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_VOLUME_POS),\
/* Standard AS Interface Descriptor(4.9.1) */\
/* Interface 1, Alternate 0 - default alternate setting with 0 bandwidth */\
- TUD_AUDIO_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x00, /*_nEPs*/ 0x00, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x00, /*_nEPs*/ 0x00, /*_stridx*/ 0x00),\
/* Standard AS Interface Descriptor(4.9.1) */\
/* Interface 1, Alternate 1 - alternate interface for data streaming */\
- TUD_AUDIO_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x01, /*_nEPs*/ 0x01, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x01, /*_nEPs*/ 0x01, /*_stridx*/ 0x00),\
/* Class-Specific AS Interface Descriptor(4.9.2) */\
- 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*/ 0x04, /*_channelcfg*/ AUDIO_CHANNEL_CONFIG_NON_PREDEFINED, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_CS_AS_INT(/*_termid*/ 0x03, /*_ctrl*/ AUDIO20_CTRL_NONE, /*_formattype*/ AUDIO20_FORMAT_TYPE_I, /*_formats*/ AUDIO20_DATA_FORMAT_TYPE_I_PCM, /*_nchannelsphysical*/ 0x04, /*_channelcfg*/ AUDIO20_CHANNEL_CONFIG_NON_PREDEFINED, /*_stridx*/ 0x00),\
/* Type I Format Type Descriptor(2.3.1.6 - Audio Formats) */\
- TUD_AUDIO_DESC_TYPE_I_FORMAT(_nBytesPerSample, _nBitsUsedPerSample),\
+ TUD_AUDIO20_DESC_TYPE_I_FORMAT(_nBytesPerSample, _nBitsUsedPerSample),\
/* Standard AS Isochronous Audio Data Endpoint Descriptor(4.10.1.1) */\
- TUD_AUDIO_DESC_STD_AS_ISO_EP(/*_ep*/ _epin, /*_attr*/ (uint8_t) ((uint8_t)TUSB_XFER_ISOCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_ASYNCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_DATA), /*_maxEPsize*/ _epsize, /*_interval*/ 0x01),\
+ TUD_AUDIO20_DESC_STD_AS_ISO_EP(/*_ep*/ _epin, /*_attr*/ (uint8_t) ((uint8_t)TUSB_XFER_ISOCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_ASYNCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_DATA), /*_maxEPsize*/ _epsize, /*_interval*/ 0x01),\
/* Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.10.1.2) */\
- 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)
+ TUD_AUDIO20_DESC_CS_AS_ISO_EP(/*_attr*/ AUDIO20_CS_AS_ISO_DATA_EP_ATT_NON_MAX_PACKETS_OK, /*_ctrl*/ AUDIO20_CTRL_NONE, /*_lockdelayunit*/ AUDIO20_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_UNDEFINED, /*_lockdelay*/ 0x0000)
// AUDIO simple descriptor (UAC2) for mono speaker
// - 1 Input Terminal, 2 Feature Unit (Mute and Volume Control), 3 Output Terminal, 4 Clock Source
-#define TUD_AUDIO_SPEAKER_MONO_FB_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\
- + TUD_AUDIO_DESC_STD_AS_ISO_FB_EP_LEN)
+#define TUD_AUDIO20_SPEAKER_MONO_FB_DESC_LEN (TUD_AUDIO20_DESC_IAD_LEN\
+ + TUD_AUDIO20_DESC_STD_AC_LEN\
+ + TUD_AUDIO20_DESC_CS_AC_LEN\
+ + TUD_AUDIO20_DESC_CLK_SRC_LEN\
+ + TUD_AUDIO20_DESC_INPUT_TERM_LEN\
+ + TUD_AUDIO20_DESC_OUTPUT_TERM_LEN\
+ + TUD_AUDIO20_DESC_FEATURE_UNIT_LEN(1)\
+ + TUD_AUDIO20_DESC_STD_AS_LEN\
+ + TUD_AUDIO20_DESC_STD_AS_LEN\
+ + TUD_AUDIO20_DESC_CS_AS_INT_LEN\
+ + TUD_AUDIO20_DESC_TYPE_I_FORMAT_LEN\
+ + TUD_AUDIO20_DESC_STD_AS_ISO_EP_LEN\
+ + TUD_AUDIO20_DESC_CS_AS_ISO_EP_LEN\
+ + TUD_AUDIO20_DESC_STD_AS_ISO_FB_EP_LEN)
-#define TUD_AUDIO_SPEAKER_MONO_FB_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epout, _epoutsize, _epfb, _epfbsize) \
+#define TUD_AUDIO20_SPEAKER_MONO_FB_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epout, _epoutsize, _epfb, _epfbsize) \
/* Standard Interface Association Descriptor (IAD) */\
- TUD_AUDIO_DESC_IAD(/*_firstitf*/ _itfnum, /*_nitfs*/ 0x02, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_IAD(/*_firstitf*/ _itfnum, /*_nitfs*/ 0x02, /*_stridx*/ 0x00),\
/* Standard AC Interface Descriptor(4.7.1) */\
- TUD_AUDIO_DESC_STD_AC(/*_itfnum*/ _itfnum, /*_nEPs*/ 0x00, /*_stridx*/ _stridx),\
+ TUD_AUDIO20_DESC_STD_AC(/*_itfnum*/ _itfnum, /*_nEPs*/ 0x00, /*_stridx*/ _stridx),\
/* Class-Specific AC Interface Header Descriptor(4.7.2) */\
- TUD_AUDIO_DESC_CS_AC(/*_bcdADC*/ 0x0200, /*_category*/ AUDIO_FUNC_DESKTOP_SPEAKER, /*_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),\
+ TUD_AUDIO20_DESC_CS_AC(/*_bcdADC*/ 0x0200, /*_category*/ AUDIO20_FUNC_DESKTOP_SPEAKER, /*_totallen*/ TUD_AUDIO20_DESC_CLK_SRC_LEN+TUD_AUDIO20_DESC_INPUT_TERM_LEN+TUD_AUDIO20_DESC_OUTPUT_TERM_LEN+TUD_AUDIO20_DESC_FEATURE_UNIT_LEN(1), /*_ctrl*/ AUDIO20_CS_AS_INTERFACE_CTRL_LATENCY_POS),\
/* Clock Source Descriptor(4.7.2.1) */\
- 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),\
+ TUD_AUDIO20_DESC_CLK_SRC(/*_clkid*/ 0x04, /*_attr*/ AUDIO20_CLOCK_SOURCE_ATT_INT_FIX_CLK, /*_ctrl*/ (AUDIO20_CTRL_R << AUDIO20_CLOCK_SOURCE_CTRL_CLK_FRQ_POS), /*_assocTerm*/ 0x01, /*_stridx*/ 0x00),\
/* Input Terminal Descriptor(4.7.2.4) */\
- TUD_AUDIO_DESC_INPUT_TERM(/*_termid*/ 0x01, /*_termtype*/ AUDIO_TERM_TYPE_USB_STREAMING, /*_assocTerm*/ 0x00, /*_clkid*/ 0x04, /*_nchannelslogical*/ 0x01, /*_channelcfg*/ AUDIO_CHANNEL_CONFIG_NON_PREDEFINED, /*_idxchannelnames*/ 0x00, /*_ctrl*/ 0 * (AUDIO_CTRL_R << AUDIO_IN_TERM_CTRL_CONNECTOR_POS), /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_INPUT_TERM(/*_termid*/ 0x01, /*_termtype*/ AUDIO_TERM_TYPE_USB_STREAMING, /*_assocTerm*/ 0x00, /*_clkid*/ 0x04, /*_nchannelslogical*/ 0x01, /*_channelcfg*/ AUDIO20_CHANNEL_CONFIG_NON_PREDEFINED, /*_idxchannelnames*/ 0x00, /*_ctrl*/ 0 * (AUDIO20_CTRL_R << AUDIO20_IN_TERM_CTRL_CONNECTOR_POS), /*_stridx*/ 0x00),\
/* Output Terminal Descriptor(4.7.2.5) */\
- TUD_AUDIO_DESC_OUTPUT_TERM(/*_termid*/ 0x03, /*_termtype*/ AUDIO_TERM_TYPE_OUT_DESKTOP_SPEAKER, /*_assocTerm*/ 0x01, /*_srcid*/ 0x02, /*_clkid*/ 0x04, /*_ctrl*/ 0x0000, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_OUTPUT_TERM(/*_termid*/ 0x03, /*_termtype*/ AUDIO_TERM_TYPE_OUT_DESKTOP_SPEAKER, /*_assocTerm*/ 0x01, /*_srcid*/ 0x02, /*_clkid*/ 0x04, /*_ctrl*/ 0x0000, /*_stridx*/ 0x00),\
/* Feature Unit Descriptor(4.7.2.8) */\
- 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),\
+ TUD_AUDIO20_DESC_FEATURE_UNIT(/*_unitid*/ 0x02, /*_srcid*/ 0x01, /*_stridx*/ 0x00, /*_ctrlch0master*/ AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch1*/ AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO20_CTRL_RW << AUDIO20_FEATURE_UNIT_CTRL_VOLUME_POS),\
/* Standard AS Interface Descriptor(4.9.1) */\
/* Interface 1, Alternate 0 - default alternate setting with 0 bandwidth */\
- TUD_AUDIO_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum) + 1), /*_altset*/ 0x00, /*_nEPs*/ 0x00, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum) + 1), /*_altset*/ 0x00, /*_nEPs*/ 0x00, /*_stridx*/ 0x00),\
/* Standard AS Interface Descriptor(4.9.1) */\
/* Interface 1, Alternate 1 - alternate interface for data streaming */\
- TUD_AUDIO_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum) + 1), /*_altset*/ 0x01, /*_nEPs*/ 0x02, /*_stridx*/ 0x00),\
+ TUD_AUDIO20_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum) + 1), /*_altset*/ 0x01, /*_nEPs*/ 0x02, /*_stridx*/ 0x00),\
/* Class-Specific AS Interface Descriptor(4.9.2) */\
- TUD_AUDIO_DESC_CS_AS_INT(/*_termid*/ 0x01, /*_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),\
+ TUD_AUDIO20_DESC_CS_AS_INT(/*_termid*/ 0x01, /*_ctrl*/ AUDIO20_CTRL_NONE, /*_formattype*/ AUDIO20_FORMAT_TYPE_I, /*_formats*/ AUDIO20_DATA_FORMAT_TYPE_I_PCM, /*_nchannelsphysical*/ 0x01, /*_channelcfg*/ AUDIO20_CHANNEL_CONFIG_NON_PREDEFINED, /*_stridx*/ 0x00),\
/* Type I Format Type Descriptor(2.3.1.6 - Audio Formats) */\
- TUD_AUDIO_DESC_TYPE_I_FORMAT(_nBytesPerSample, _nBitsUsedPerSample),\
+ TUD_AUDIO20_DESC_TYPE_I_FORMAT(_nBytesPerSample, _nBitsUsedPerSample),\
/* Standard AS Isochronous Audio Data Endpoint Descriptor(4.10.1.1) */\
- TUD_AUDIO_DESC_STD_AS_ISO_EP(/*_ep*/ _epout, /*_attr*/ (uint8_t) ((uint8_t)TUSB_XFER_ISOCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_ASYNCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_DATA), /*_maxEPsize*/ _epoutsize, /*_interval*/ 0x01),\
+ TUD_AUDIO20_DESC_STD_AS_ISO_EP(/*_ep*/ _epout, /*_attr*/ (uint8_t) ((uint8_t)TUSB_XFER_ISOCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_ASYNCHRONOUS | (uint8_t)TUSB_ISO_EP_ATT_DATA), /*_maxEPsize*/ _epoutsize, /*_interval*/ 0x01),\
/* Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.10.1.2) */\
- 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),\
+ TUD_AUDIO20_DESC_CS_AS_ISO_EP(/*_attr*/ AUDIO20_CS_AS_ISO_DATA_EP_ATT_NON_MAX_PACKETS_OK, /*_ctrl*/ AUDIO20_CTRL_NONE, /*_lockdelayunit*/ AUDIO20_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_UNDEFINED, /*_lockdelay*/ 0x0000),\
/* Standard AS Isochronous Feedback Endpoint Descriptor(4.10.2.1) */\
- TUD_AUDIO_DESC_STD_AS_ISO_FB_EP(/*_ep*/ _epfb, /*_epsize*/ _epfbsize, /*_interval*/ 1)
+ TUD_AUDIO20_DESC_STD_AS_ISO_FB_EP(/*_ep*/ _epfb, /*_epsize*/ _epfbsize, /*_interval*/ 1)
// Calculate wMaxPacketSize of Endpoints
-#define TUD_AUDIO_EP_SIZE(_maxFrequency, _nBytesPerSample, _nChannels) \
- ((((_maxFrequency + (TUD_OPT_HIGH_SPEED ? 7999 : 999)) / (TUD_OPT_HIGH_SPEED ? 8000 : 1000)) + 1) * _nBytesPerSample * _nChannels)
+#define TUD_AUDIO_EP_SIZE(_is_highspeed, _maxFrequency, _nBytesPerSample, _nChannels) \
+ ((((_maxFrequency + (_is_highspeed ? 7999 : 999)) / (_is_highspeed ? 8000 : 1000)) + 1) * _nBytesPerSample * _nChannels)
//--------------------------------------------------------------------+
@@ -904,6 +1014,6 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
}
#endif
-#endif /* _TUSB_USBD_H_ */
+#endif /* TUSB_USBD_H_ */
/** @} */
diff --git a/src/host/hcd.h b/src/host/hcd.h
index d3551bf5b..4a17326ec 100644
--- a/src/host/hcd.h
+++ b/src/host/hcd.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_HCD_H_
-#define _TUSB_HCD_H_
+#ifndef TUSB_HCD_H_
+#define TUSB_HCD_H_
#include "common/tusb_common.h"
#include "osal/osal.h"
diff --git a/src/host/usbh.h b/src/host/usbh.h
index 8d48bf90d..4b6747848 100644
--- a/src/host/usbh.h
+++ b/src/host/usbh.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_USBH_H_
-#define _TUSB_USBH_H_
+#ifndef TUSB_USBH_H_
+#define TUSB_USBH_H_
#ifdef __cplusplus
extern "C" {
@@ -179,7 +179,7 @@ TU_ATTR_ALWAYS_INLINE static inline void tuh_task(void) {
// Check if there is pending events need processing by tuh_task()
bool tuh_task_event_ready(void);
-#ifndef _TUSB_HCD_H_
+#ifndef TUSB_HCD_H_
extern void hcd_int_handler(uint8_t rhport, bool in_isr);
#endif
diff --git a/src/host/usbh_pvt.h b/src/host/usbh_pvt.h
index 9d91e52e8..d722bb7e8 100644
--- a/src/host/usbh_pvt.h
+++ b/src/host/usbh_pvt.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_USBH_PVT_H_
-#define _TUSB_USBH_PVT_H_
+#ifndef TUSB_USBH_PVT_H_
+#define TUSB_USBH_PVT_H_
#include "osal/osal.h"
#include "common/tusb_fifo.h"
diff --git a/src/osal/osal.h b/src/osal/osal.h
index a33280425..44521620f 100644
--- a/src/osal/osal.h
+++ b/src/osal/osal.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_OSAL_H_
-#define _TUSB_OSAL_H_
+#ifndef TUSB_OSAL_H_
+#define TUSB_OSAL_H_
#ifdef __cplusplus
extern "C" {
@@ -33,7 +33,7 @@
#include "common/tusb_common.h"
-typedef void (*osal_task_func_t)( void * );
+typedef void (*osal_task_func_t)(void* param);
// Timeout
#define OSAL_TIMEOUT_NOTIMEOUT (0) // Return immediately
@@ -71,10 +71,9 @@ typedef void (*osal_task_func_t)( void * );
#error OS is not supported yet
#endif
-//--------------------------------------------------------------------+
-// OSAL Porting API
-// Should be implemented as static inline function in osal_port.h header
-/*
+/*--------------------------------------------------------------------
+ OSAL Porting API
+ Should be implemented as static inline function in osal_port.h header
void osal_spin_init(osal_spinlock_t *ctx);
void osal_spin_lock(osal_spinlock_t *ctx, bool in_isr)
void osal_spin_unlock(osal_spinlock_t *ctx, bool in_isr);
@@ -83,7 +82,7 @@ typedef void (*osal_task_func_t)( void * );
bool osal_semaphore_delete(osal_semaphore_t semd_hdl);
bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr);
bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec);
- void osal_semaphore_reset(osal_semaphore_t sem_hdl); // TODO removed
+ void osal_semaphore_reset(osal_semaphore_t sem_hdl);
osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef);
bool osal_mutex_delete(osal_mutex_t mutex_hdl)
@@ -95,11 +94,11 @@ typedef void (*osal_task_func_t)( void * );
bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec);
bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr);
bool osal_queue_empty(osal_queue_t qhdl);
-*/
-//--------------------------------------------------------------------+
+--------------------------------------------------------------------------*/
+
#ifdef __cplusplus
}
#endif
-#endif /* _TUSB_OSAL_H_ */
+#endif
diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h
index 3e397ef35..bc86dcb28 100644
--- a/src/osal/osal_none.h
+++ b/src/osal/osal_none.h
@@ -35,7 +35,7 @@ extern "C" {
// Spinlock API
//--------------------------------------------------------------------+
typedef struct {
- void (* interrupt_set)(bool);
+ void (* interrupt_set)(bool enabled);
} osal_spinlock_t;
// For SMP, spinlock must be locked by hardware, cannot just use interrupt
@@ -141,7 +141,7 @@ TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hd
#include "common/tusb_fifo.h"
typedef struct {
- void (* interrupt_set)(bool);
+ void (* interrupt_set)(bool enabled);
tu_fifo_t ff;
} osal_queue_def_t;
@@ -156,7 +156,7 @@ typedef osal_queue_def_t* osal_queue_t;
}
TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) {
- tu_fifo_clear(&qdef->ff);
+ (void) tu_fifo_clear(&qdef->ff);
return (osal_queue_t) qdef;
}
diff --git a/src/portable/ehci/ehci.h b/src/portable/ehci/ehci.h
index 87659701b..719bdeafc 100644
--- a/src/portable/ehci/ehci.h
+++ b/src/portable/ehci/ehci.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_EHCI_H_
-#define _TUSB_EHCI_H_
+#ifndef TUSB_EHCI_H_
+#define TUSB_EHCI_H_
/* Abbreviation
@@ -458,4 +458,4 @@ TU_VERIFY_STATIC(sizeof(ehci_cap_registers_t) == 16, "size is not correct");
}
#endif
-#endif /* _TUSB_EHCI_H_ */
+#endif /* TUSB_EHCI_H_ */
diff --git a/src/portable/ehci/ehci_api.h b/src/portable/ehci/ehci_api.h
index 12e0a73d7..79fbe702a 100644
--- a/src/portable/ehci/ehci_api.h
+++ b/src/portable/ehci/ehci_api.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_EHCI_API_H_
-#define _TUSB_EHCI_API_H_
+#ifndef TUSB_EHCI_API_H_
+#define TUSB_EHCI_API_H_
#ifdef __cplusplus
extern "C" {
diff --git a/src/portable/nuvoton/nuc121/dcd_nuc121.c b/src/portable/nuvoton/nuc121/dcd_nuc121.c
index 067d455c6..ee27e94d3 100644
--- a/src/portable/nuvoton/nuc121/dcd_nuc121.c
+++ b/src/portable/nuvoton/nuc121/dcd_nuc121.c
@@ -39,8 +39,18 @@
#if CFG_TUD_ENABLED && ( (CFG_TUSB_MCU == OPT_MCU_NUC121) || (CFG_TUSB_MCU == OPT_MCU_NUC126) )
#include "device/dcd.h"
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wredundant-decls"
+#endif
+
#include "NuMicro.h"
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
// Since TinyUSB doesn't use SOF for now, and this interrupt too often (1ms interval)
// We disable SOF for now until needed later on
#ifndef USE_SOF
diff --git a/src/portable/nuvoton/nuc505/dcd_nuc505.c b/src/portable/nuvoton/nuc505/dcd_nuc505.c
index f7593cf25..b35bc09dc 100644
--- a/src/portable/nuvoton/nuc505/dcd_nuc505.c
+++ b/src/portable/nuvoton/nuc505/dcd_nuc505.c
@@ -39,8 +39,18 @@
#if CFG_TUD_ENABLED && (CFG_TUSB_MCU == OPT_MCU_NUC505)
#include "device/dcd.h"
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wredundant-decls"
+#endif
+
#include "NUC505Series.h"
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
/*
* The DMA functionality of the USBD peripheral does not appear to succeed with
* transfer lengths that are longer (> 64 bytes) and are not a multiple of 4.
diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.h b/src/portable/nxp/lpc17_40/dcd_lpc17_40.h
index 654b80866..25c9f9985 100644
--- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.h
+++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_DCD_LPC17_40_H_
-#define _TUSB_DCD_LPC17_40_H_
+#ifndef TUSB_DCD_LPC17_40_H_
+#define TUSB_DCD_LPC17_40_H_
#include "common/tusb_common.h"
diff --git a/src/portable/ohci/ohci.c b/src/portable/ohci/ohci.c
index f1689b5b4..a12f7d6ed 100644
--- a/src/portable/ohci/ohci.c
+++ b/src/portable/ohci/ohci.c
@@ -41,13 +41,16 @@
#include "host/usbh.h"
#include "ohci.h"
-// TODO remove
-#include "chip.h"
+#if defined(TUP_USBIP_OHCI_NXP)
+ #include "ohci_nxp.h"
+#else
+ #error Unsupported OHCI IP
+#endif
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
-#define OHCI_REG ((ohci_registers_t *) LPC_USB_BASE)
+
enum {
OHCI_CONTROL_FUNCSTATE_RESET = 0,
@@ -181,6 +184,8 @@ bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
(void) rhport;
(void) rh_init;
+ ohci_phy_init(rhport);
+
//------------- Data Structure init -------------//
tu_memclr(&ohci_data, sizeof(ohci_data_t));
for(uint8_t i=0; i<32; i++)
diff --git a/src/portable/ohci/ohci.h b/src/portable/ohci/ohci.h
index 94bad5df7..38cc84858 100644
--- a/src/portable/ohci/ohci.h
+++ b/src/portable/ohci/ohci.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_OHCI_H_
-#define _TUSB_OHCI_H_
+#ifndef TUSB_OHCI_H_
+#define TUSB_OHCI_H_
#ifdef __cplusplus
extern "C" {
@@ -192,10 +192,10 @@ typedef struct TU_ATTR_ALIGNED(256) {
//--------------------------------------------------------------------+
typedef volatile struct
{
- uint32_t revision;
+ uint32_t revision; // 0x00
union {
- uint32_t control;
+ uint32_t control; // 0x04
struct {
uint32_t control_bulk_service_ratio : 2;
uint32_t periodic_list_enable : 1;
@@ -211,7 +211,7 @@ typedef volatile struct
};
union {
- uint32_t command_status;
+ uint32_t command_status; // 0x08
struct {
uint32_t controller_reset : 1;
uint32_t control_list_filled : 1;
@@ -222,26 +222,24 @@ typedef volatile struct
}command_status_bit;
};
- uint32_t interrupt_status;
- uint32_t interrupt_enable;
- uint32_t interrupt_disable;
-
- uint32_t hcca;
- uint32_t period_current_ed;
- uint32_t control_head_ed;
- uint32_t control_current_ed;
- uint32_t bulk_head_ed;
- uint32_t bulk_current_ed;
- uint32_t done_head;
-
- uint32_t frame_interval;
- uint32_t frame_remaining;
- uint32_t frame_number;
- uint32_t periodic_start;
- uint32_t lowspeed_threshold;
+ uint32_t interrupt_status; // 0x0C
+ uint32_t interrupt_enable; // 0x10
+ uint32_t interrupt_disable; // 0x14
+ uint32_t hcca; // 0x18
+ uint32_t period_current_ed; // 0x1C
+ uint32_t control_head_ed; // 0x20
+ uint32_t control_current_ed; // 0x24
+ uint32_t bulk_head_ed; // 0x28
+ uint32_t bulk_current_ed; // 0x2C
+ uint32_t done_head; // 0x30
+ uint32_t frame_interval; // 0x34
+ uint32_t frame_remaining; // 0x38
+ uint32_t frame_number; // 0x3C
+ uint32_t periodic_start; // 0x40
+ uint32_t lowspeed_threshold; // 0x44
union {
- uint32_t rh_descriptorA;
+ uint32_t rh_descriptorA; // 0x48
struct {
uint32_t number_downstream_ports : 8;
uint32_t power_switching_mode : 1;
@@ -255,7 +253,7 @@ typedef volatile struct
};
union {
- uint32_t rh_descriptorB;
+ uint32_t rh_descriptorB; // 0x4C
struct {
uint32_t device_removable : 16;
uint32_t port_power_control_mask : 16;
@@ -263,9 +261,9 @@ typedef volatile struct
};
union {
- uint32_t rh_status;
+ uint32_t rh_status; // 0x50
struct {
- uint32_t local_power_status : 1; // read Local Power Status; write: Clear Global Power
+ uint32_t local_power_status : 1; // read Local Power Status; write: Clear Global Power
uint32_t over_current_indicator : 1;
uint32_t : 13;
uint32_t device_remote_wakeup_enable : 1;
@@ -277,7 +275,8 @@ typedef volatile struct
};
union {
- uint32_t rhport_status[TUP_OHCI_RHPORTS];
+ uint32_t rhport_status[TUP_OHCI_RHPORTS]; // 0x54
+
struct {
uint32_t current_connect_status : 1;
uint32_t port_enable_status : 1;
@@ -304,4 +303,4 @@ TU_VERIFY_STATIC( sizeof(ohci_registers_t) == (0x54 + (4 * TUP_OHCI_RHPORTS)), "
}
#endif
-#endif /* _TUSB_OHCI_H_ */
+#endif /* TUSB_OHCI_H_ */
diff --git a/src/portable/nxp/lpc17_40/hcd_lpc17_40.c b/src/portable/ohci/ohci_nxp.h
index fea3e2a66..9cba05e95 100644
--- a/src/portable/nxp/lpc17_40/hcd_lpc17_40.c
+++ b/src/portable/ohci/ohci_nxp.h
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2019, Ha Thach (tinyusb.org)
+ * Copyright (c) 2025 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,26 +23,48 @@
*
* This file is part of the TinyUSB stack.
*/
+#ifndef TUSB_OHCI_NXP_H
+#define TUSB_OHCI_NXP_H
-#include "tusb_option.h"
-
-#if CFG_TUH_ENABLED && \
- (CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX)
+#if TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC40XX)
#include "chip.h"
-#include "host/hcd.h"
-#include "host/usbh.h"
+#define OHCI_REG ((ohci_registers_t *) LPC_USB_BASE)
-void hcd_int_enable(uint8_t rhport)
-{
- (void) rhport;
+void hcd_int_enable(uint8_t rhport) {
+ (void)rhport;
NVIC_EnableIRQ(USB_IRQn);
}
-void hcd_int_disable(uint8_t rhport)
-{
- (void) rhport;
+void hcd_int_disable(uint8_t rhport) {
+ (void)rhport;
NVIC_DisableIRQ(USB_IRQn);
}
+static void ohci_phy_init(uint8_t rhport) {
+ (void) rhport;
+}
+
+#else
+
+#include "fsl_device_registers.h"
+
+// for LPC55 USB0 controller
+#define OHCI_REG ((ohci_registers_t *) USBFSH_BASE)
+
+static void ohci_phy_init(uint8_t rhport) {
+ (void) rhport;
+}
+
+void hcd_int_enable(uint8_t rhport) {
+ (void)rhport;
+ NVIC_EnableIRQ(USB0_IRQn);
+}
+
+void hcd_int_disable(uint8_t rhport) {
+ (void)rhport;
+ NVIC_DisableIRQ(USB0_IRQn);
+}
+#endif
+
#endif
diff --git a/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c b/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
index d59a2b4ee..90eb920e0 100644
--- a/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
+++ b/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
@@ -29,9 +29,20 @@
#if CFG_TUH_ENABLED && (CFG_TUSB_MCU == OPT_MCU_RP2040) && CFG_TUH_RPI_PIO_USB
#include "pico.h"
+
#include "pio_usb.h"
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#endif
+
#include "pio_usb_ll.h"
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
diff --git a/src/portable/renesas/rusb2/rusb2_type.h b/src/portable/renesas/rusb2/rusb2_type.h
index dd88f66a7..71837d03c 100644
--- a/src/portable/renesas/rusb2/rusb2_type.h
+++ b/src/portable/renesas/rusb2/rusb2_type.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_RUSB2_TYPE_H_
-#define _TUSB_RUSB2_TYPE_H_
+#ifndef TUSB_RUSB2_TYPE_H_
+#define TUSB_RUSB2_TYPE_H_
#include <stdint.h>
#include <stddef.h>
@@ -1777,4 +1777,4 @@ TU_VERIFY_STATIC(offsetof(rusb2_reg_t, DPUSR1R_FS ) == 0x0404, "incorrect offset
}
#endif
-#endif /* _TUSB_RUSB2_TYPE_H_ */
+#endif /* TUSB_RUSB2_TYPE_H_ */
diff --git a/src/portable/sunxi/musb_def.h b/src/portable/sunxi/musb_def.h
index 53da5ded2..ce9b89d55 100644
--- a/src/portable/sunxi/musb_def.h
+++ b/src/portable/sunxi/musb_def.h
@@ -26,8 +26,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_MUSB_DEF
-#define _TUSB_MUSB_DEF
+#ifndef TUSB_MUSB_DEF
+#define TUSB_MUSB_DEF
#define USBC_Readb(reg) (*(volatile unsigned char *)(reg))
diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c
index ab30a06e8..2effba704 100644
--- a/src/portable/synopsys/dwc2/dcd_dwc2.c
+++ b/src/portable/synopsys/dwc2/dcd_dwc2.c
@@ -380,7 +380,7 @@ static void edpt_schedule_packets(uint8_t rhport, const uint8_t epnum, const uin
// Enable tx fifo empty interrupt only if there is data. Note must after depctl enable
if (dir == TUSB_DIR_IN && total_bytes != 0) {
- dwc2->diepempmsk |= (1 << epnum);
+ dwc2->diepempmsk |= (1u << epnum);
}
}
}
@@ -403,7 +403,7 @@ bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
// Set device max speed
uint32_t dcfg = dwc2->dcfg & ~DCFG_DSPD_Msk;
if (is_highspeed) {
- dcfg |= DCFG_DSPD_HS << DCFG_DSPD_Pos;
+ // dcfg Highspeed's mask is 0
// XCVRDLY: transceiver delay between xcvr_sel and txvalid during device chirp is required
// when using with some PHYs such as USB334x (USB3341, USB3343, USB3346, USB3347)
@@ -917,7 +917,7 @@ static void handle_epin_slave(uint8_t rhport, uint8_t epnum, dwc2_diepint_t diep
// Turn off TXFE if all bytes are written.
tsiz.value = epin->tsiz;
if (tsiz.xfer_size == 0) {
- dwc2->diepempmsk &= ~(1 << epnum);
+ dwc2->diepempmsk &= ~(1u << epnum);
}
}
}
@@ -1057,6 +1057,8 @@ void dcd_int_handler(uint8_t rhport) {
if (gintsts & GINTSTS_ENUMDNE) {
// ENUMDNE is the end of reset where speed of the link is detected
dwc2->gintsts = GINTSTS_ENUMDNE;
+ // There may be a pending suspend event, so we clear it first
+ dwc2->gintsts = GINTSTS_USBSUSP;
dwc2->gintmsk |= GINTMSK_USBSUSPM;
handle_enum_done(rhport);
}
diff --git a/src/portable/synopsys/dwc2/dwc2_at32.h b/src/portable/synopsys/dwc2/dwc2_at32.h
index 37b6592c4..513495eb1 100644
--- a/src/portable/synopsys/dwc2/dwc2_at32.h
+++ b/src/portable/synopsys/dwc2/dwc2_at32.h
@@ -64,58 +64,59 @@
#endif
#ifdef __cplusplus
- extern "C" {
+extern "C" {
#endif
- static const dwc2_controller_t _dwc2_controller[] = {
-{.reg_base = DWC2_OTG1_REG_BASE, .irqnum = OTG1_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = OTG1_FIFO_SIZE},
+static const dwc2_controller_t _dwc2_controller[] = {
+ {.reg_base = DWC2_OTG1_REG_BASE, .irqnum = OTG1_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = OTG1_FIFO_SIZE},
#if defined DWC2_OTG2_REG_BASE
- {.reg_base = DWC2_OTG2_REG_BASE, .irqnum = OTG2_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = OTG2_FIFO_SIZE}
+ {.reg_base = DWC2_OTG2_REG_BASE, .irqnum = OTG2_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = OTG2_FIFO_SIZE}
#endif
- };
+};
- TU_ATTR_ALWAYS_INLINE static inline void dwc2_int_set(uint8_t rhport, tusb_role_t role, bool enabled) {
- (void) role;
- const IRQn_Type irqn = (IRQn_Type) _dwc2_controller[rhport].irqnum;
- if (enabled) {
- NVIC_EnableIRQ(irqn);
- } else {
- NVIC_DisableIRQ(irqn);
- }
- }
+TU_ATTR_ALWAYS_INLINE static inline void dwc2_int_set(uint8_t rhport, tusb_role_t role, bool enabled) {
+ (void) role;
+ const IRQn_Type irqn = (IRQn_Type) _dwc2_controller[rhport].irqnum;
+ if (enabled) {
+ NVIC_EnableIRQ(irqn);
+ } else {
+ NVIC_DisableIRQ(irqn);
+ }
+}
- TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { NVIC_EnableIRQ(_dwc2_controller[rhport].irqnum);
- }
+TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) {
+ NVIC_EnableIRQ(_dwc2_controller[rhport].irqnum);
+}
- TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable(uint8_t rhport) {
- NVIC_DisableIRQ(_dwc2_controller[rhport].irqnum);
- }
+TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable(uint8_t rhport) {
+ NVIC_DisableIRQ(_dwc2_controller[rhport].irqnum);
+}
- TU_ATTR_ALWAYS_INLINE static inline void dwc2_remote_wakeup_delay(void) {
- // try to delay for 1 ms
- uint32_t count = system_core_clock / 1000;
- while (count--) __asm volatile("nop");
- }
+TU_ATTR_ALWAYS_INLINE static inline void dwc2_remote_wakeup_delay(void) {
+ // try to delay for 1 ms
+ uint32_t count = system_core_clock / 1000;
+ while (count--) __asm volatile("nop");
+}
- // MCU specific PHY init, called BEFORE core reset
- TU_ATTR_ALWAYS_INLINE static inline void dwc2_phy_init(dwc2_regs_t *dwc2, uint8_t hs_phy_type) {
- (void) dwc2;
- // Enable on-chip HS PHY
- if (hs_phy_type == GHWCFG2_HSPHY_UTMI || hs_phy_type == GHWCFG2_HSPHY_UTMI_ULPI) {
- } else if (hs_phy_type == GHWCFG2_HSPHY_NOT_SUPPORTED) {
- }
- }
+// MCU specific PHY init, called BEFORE core reset
+TU_ATTR_ALWAYS_INLINE static inline void dwc2_phy_init(dwc2_regs_t *dwc2, uint8_t hs_phy_type) {
+ (void) dwc2;
+ // Enable on-chip HS PHY
+ if (hs_phy_type == GHWCFG2_HSPHY_UTMI || hs_phy_type == GHWCFG2_HSPHY_UTMI_ULPI) {
+ } else if (hs_phy_type == GHWCFG2_HSPHY_NOT_SUPPORTED) {
+ }
+}
- // MCU specific PHY update, it is called AFTER init() and core reset
- TU_ATTR_ALWAYS_INLINE static inline void dwc2_phy_update(dwc2_regs_t *dwc2, uint8_t hs_phy_type) {
- (void) dwc2;
- (void) hs_phy_type;
+// MCU specific PHY update, it is called AFTER init() and core reset
+TU_ATTR_ALWAYS_INLINE static inline void dwc2_phy_update(dwc2_regs_t *dwc2, uint8_t hs_phy_type) {
+ (void) dwc2;
+ (void) hs_phy_type;
- dwc2->stm32_gccfg |= STM32_GCCFG_PWRDWN | STM32_GCCFG_DCDEN | STM32_GCCFG_PDEN;
- }
+ dwc2->stm32_gccfg |= STM32_GCCFG_PWRDWN | STM32_GCCFG_DCDEN | STM32_GCCFG_PDEN;
+}
#ifdef __cplusplus
}
#endif
-#endif /* DWC2_GD32_H_ */
+#endif /* DWC2_AT32_H_ */
diff --git a/src/portable/synopsys/dwc2/dwc2_bcm.h b/src/portable/synopsys/dwc2/dwc2_bcm.h
index e5824606a..df6d4a852 100644
--- a/src/portable/synopsys/dwc2/dwc2_bcm.h
+++ b/src/portable/synopsys/dwc2/dwc2_bcm.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_DWC2_BCM_H_
-#define _TUSB_DWC2_BCM_H_
+#ifndef TUSB_DWC2_BCM_H_
+#define TUSB_DWC2_BCM_H_
#ifdef __cplusplus
extern "C" {
diff --git a/src/portable/valentyusb/eptri/dcd_eptri.h b/src/portable/valentyusb/eptri/dcd_eptri.h
index d67635d7c..2fe74a712 100644
--- a/src/portable/valentyusb/eptri/dcd_eptri.h
+++ b/src/portable/valentyusb/eptri/dcd_eptri.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_DCD_VALENTYUSB_EPTRI_H_
-#define _TUSB_DCD_VALENTYUSB_EPTRI_H_
+#ifndef TUSB_DCD_VALENTYUSB_EPTRI_H_
+#define TUSB_DCD_VALENTYUSB_EPTRI_H_
#include "common/tusb_common.h"
#ifdef __cplusplus
@@ -36,4 +36,4 @@
}
#endif
-#endif /* _TUSB_DCD_VALENTYUSB_EPTRI_H_ */
+#endif /* TUSB_DCD_VALENTYUSB_EPTRI_H_ */
diff --git a/src/tusb.c b/src/tusb.c
index 7f451ee70..08bd020e3 100644
--- a/src/tusb.c
+++ b/src/tusb.c
@@ -576,8 +576,12 @@ void tu_print_mem(void const* buf, uint32_t count, uint8_t indent) {
if (i % item_per_line == 0) {
// Print Ascii
- if (i != 0) dump_str_line(buf8 - 16, 16);
- for (uint8_t s = 0; s < indent; s++) tu_printf(" ");
+ if (i != 0) {
+ dump_str_line(buf8 - 16, 16);
+ }
+ for (uint8_t s = 0; s < indent; s++) {
+ tu_printf(" ");
+ }
// print offset or absolute address
tu_printf("%04X: ", 16 * i / item_per_line);
}
diff --git a/src/tusb.h b/src/tusb.h
index 6a469eef4..62b3b9783 100644
--- a/src/tusb.h
+++ b/src/tusb.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_H_
-#define _TUSB_H_
+#ifndef TUSB_H_
+#define TUSB_H_
#ifdef __cplusplus
extern "C" {
@@ -178,4 +178,4 @@ bool tusb_deinit(uint8_t rhport);
}
#endif
-#endif /* _TUSB_H_ */
+#endif /* TUSB_H_ */
diff --git a/src/tusb_option.h b/src/tusb_option.h
index 9d5aed252..e00311039 100644
--- a/src/tusb_option.h
+++ b/src/tusb_option.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_OPTION_H_
-#define _TUSB_OPTION_H_
+#ifndef TUSB_OPTION_H_
+#define TUSB_OPTION_H_
#include "common/tusb_compiler.h"
@@ -244,11 +244,11 @@
#define OPT_MODE_HOST 0x0002 ///< Host Mode
// High byte is max operational speed (corresponding to tusb_speed_t)
-#define OPT_MODE_DEFAULT_SPEED 0x0000 ///< Default (max) speed supported by MCU
-#define OPT_MODE_LOW_SPEED 0x0100 ///< Low Speed
-#define OPT_MODE_FULL_SPEED 0x0200 ///< Full Speed
-#define OPT_MODE_HIGH_SPEED 0x0400 ///< High Speed
-#define OPT_MODE_SPEED_MASK 0xff00
+#define OPT_MODE_DEFAULT_SPEED 0x0000u ///< Default (max) speed supported by MCU
+#define OPT_MODE_LOW_SPEED 0x0100u ///< Low Speed
+#define OPT_MODE_FULL_SPEED 0x0200u ///< Full Speed
+#define OPT_MODE_HIGH_SPEED 0x0400u ///< High Speed
+#define OPT_MODE_SPEED_MASK 0xff00u
//--------------------------------------------------------------------+
// Include tusb_config.h
@@ -727,6 +727,6 @@
// To avoid GCC compiler warnings when -pedantic option is used (strict ISO C)
typedef int make_iso_compilers_happy;
-#endif /* _TUSB_OPTION_H_ */
+#endif /* TUSB_OPTION_H_ */
/** @} */
diff --git a/src/typec/pd_types.h b/src/typec/pd_types.h
index 1b2968f65..950f4d488 100644
--- a/src/typec/pd_types.h
+++ b/src/typec/pd_types.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_PD_TYPES_H_
-#define _TUSB_PD_TYPES_H_
+#ifndef TUSB_PD_TYPES_H_
+#define TUSB_PD_TYPES_H_
#ifdef __cplusplus
extern "C" {
diff --git a/src/typec/tcd.h b/src/typec/tcd.h
index bcbdab8ed..da7ab4b13 100644
--- a/src/typec/tcd.h
+++ b/src/typec/tcd.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_TCD_H_
-#define _TUSB_TCD_H_
+#ifndef TUSB_TCD_H_
+#define TUSB_TCD_H_
#include "common/tusb_common.h"
#include "pd_types.h"
diff --git a/src/typec/usbc.h b/src/typec/usbc.h
index 448542aab..711119596 100644
--- a/src/typec/usbc.h
+++ b/src/typec/usbc.h
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_UTCD_H_
-#define _TUSB_UTCD_H_
+#ifndef TUSB_UTCD_H_
+#define TUSB_UTCD_H_
#include "common/tusb_common.h"
#include "pd_types.h"
@@ -63,7 +63,7 @@ void tuc_task (void) {
tuc_task_ext(UINT32_MAX, false);
}
-#ifndef _TUSB_TCD_H_
+#ifndef TUSB_TCD_H_
extern void tcd_int_handler(uint8_t rhport);
#endif