8888#define AUDIO_ENDPOINT_UNDEFINED 0x00U
8989#define AUDIO_ENDPOINT_GENERAL 0x01U
9090
91- /* Feature Unit Control Bits */
92- #define AUDIO_CONTROL_MUTE 0x0001
93- #define AUDIO_CONTROL_VOLUME 0x0002
94- #define AUDIO_CONTROL_BASS 0x0004
95- #define AUDIO_CONTROL_MID 0x0008
96- #define AUDIO_CONTROL_TREBLE 0x0010
97- #define AUDIO_CONTROL_GRAPHIC_EQUALIZER 0x0020
98- #define AUDIO_CONTROL_AUTOMATIC_GAIN 0x0040
99- #define AUDIO_CONTROL_DEALY 0x0080
100- #define AUDIO_CONTROL_BASS_BOOST 0x0100
101- #define AUDIO_CONTROL_LOUDNESS 0x0200
102-
10391/* Encoder Type Codes */
10492#define AUDIO_ENCODER_UNDEF 0x00
10593#define AUDIO_ENCODER_OTHER 0x01
245233#define AUDIO_FU_CONTROL_OVERFLOW 0x0f
246234#define AUDIO_FU_CONTROL_LATENCY 0x10
247235
248- #define AUDIO_V2_FU_CONTROL_UNDEF 0x00
249- #define AUDIO_V2_FU_CONTROL_MUTE (0x03 << 0)
250- #define AUDIO_V2_FU_CONTROL_VOLUME (0x03 << 2)
251- #define AUDIO_V2_FU_CONTROL_BASS (0x03 << 4)
252- #define AUDIO_V2_FU_CONTROL_MID (0x03 << 6)
253- #define AUDIO_V2_FU_CONTROL_TREBLE (0x03 << 8)
254- #define AUDIO_V2_FU_CONTROL_EQUALIZER (0x03 << 10)
255- #define AUDIO_V2_FU_CONTROL_AGC (0x03 << 12)
256- #define AUDIO_V2_FU_CONTROL_DELAY (0x03 << 14)
257- #define AUDIO_V2_FU_CONTROL_BASS_BOOST (0x03 << 16)
258- #define AUDIO_V2_FU_CONTROL_LOUDNESS (0x03 << 18)
259- #define AUDIO_V2_FU_CONTROL_INP_GAIN (0x03 << 20)
260- #define AUDIO_V2_FU_CONTROL_INP_GAIN_PAD (0x03 << 22)
261- #define AUDIO_V2_FU_CONTROL_PHASE_INVERT (0x03 << 24)
262- #define AUDIO_V2_FU_CONTROL_UNDERFLOW (0x03 << 26)
263- #define AUDIO_V2_FU_CONTROL_OVERFLOW (0x03 << 28)
236+ /* Feature Unit Control Bits */
237+ #define AUDIO_CONTROL_MUTE 0x0001
238+ #define AUDIO_CONTROL_VOLUME 0x0002
239+ #define AUDIO_CONTROL_BASS 0x0004
240+ #define AUDIO_CONTROL_MID 0x0008
241+ #define AUDIO_CONTROL_TREBLE 0x0010
242+ #define AUDIO_CONTROL_GRAPHIC_EQUALIZER 0x0020
243+ #define AUDIO_CONTROL_AUTOMATIC_GAIN 0x0040
244+ #define AUDIO_CONTROL_DEALY 0x0080
245+ #define AUDIO_CONTROL_BASS_BOOST 0x0100
246+ #define AUDIO_CONTROL_LOUDNESS 0x0200
247+
248+ #define AUDIO_V2_CONTROL_UNDEF 0x00
249+ #define AUDIO_V2_CONTROL_MUTE (0x03 << 0)
250+ #define AUDIO_V2_CONTROL_VOLUME (0x03 << 2)
251+ #define AUDIO_V2_CONTROL_BASS (0x03 << 4)
252+ #define AUDIO_V2_CONTROL_MID (0x03 << 6)
253+ #define AUDIO_V2_CONTROL_TREBLE (0x03 << 8)
254+ #define AUDIO_V2_CONTROL_EQUALIZER (0x03 << 10)
255+ #define AUDIO_V2_CONTROL_AGC (0x03 << 12)
256+ #define AUDIO_V2_CONTROL_DELAY (0x03 << 14)
257+ #define AUDIO_V2_CONTROL_BASS_BOOST (0x03 << 16)
258+ #define AUDIO_V2_CONTROL_LOUDNESS (0x03 << 18)
259+ #define AUDIO_V2_CONTROL_INP_GAIN (0x03 << 20)
260+ #define AUDIO_V2_CONTROL_INP_GAIN_PAD (0x03 << 22)
261+ #define AUDIO_V2_CONTROL_PHASE_INVERT (0x03 << 24)
262+ #define AUDIO_V2_CONTROL_UNDERFLOW (0x03 << 26)
263+ #define AUDIO_V2_CONTROL_OVERFLOW (0x03 << 28)
264264
265265/* Parametric Equalizer Section Effect Unit Control Selectors */
266266#define AUDIO_PE_CONTROL_UNDEF 0x00
@@ -605,7 +605,7 @@ struct audio_cs_if_ac_header_descriptor {
605605 uint8_t baInterfaceNr [];
606606} __PACKED ;
607607
608- #define AUDIO_SIZEOF_AC_HEADER_DESC (n ) (8 + n )
608+ #define AUDIO_SIZEOF_AC_HEADER_DESC (bInCollection ) (8 + (bInCollection) )
609609
610610struct audio_cs_if_ac_input_terminal_descriptor {
611611 uint8_t bLength ;
@@ -646,7 +646,7 @@ struct audio_cs_if_ac_feature_unit_descriptor {
646646 uint8_t iFeature ;
647647} __PACKED ;
648648
649- #define AUDIO_SIZEOF_AC_FEATURE_UNIT_DESC (ch , n ) (7 + (ch + 1) * n )
649+ #define AUDIO_SIZEOF_AC_FEATURE_UNIT_DESC (bNrChannels , bControlSize ) (7 + ((bNrChannels) + 1) * (bControlSize) )
650650
651651struct audio_cs_if_ac_selector_unit_descriptor {
652652 uint8_t bLength ;
@@ -658,7 +658,7 @@ struct audio_cs_if_ac_selector_unit_descriptor {
658658 uint8_t iSelector ;
659659} __PACKED ;
660660
661- #define AUDIO_SIZEOF_AC_SELECTOR_UNIT_DESC (n ) (6 + n )
661+ #define AUDIO_SIZEOF_AC_SELECTOR_UNIT_DESC (bNrInPins ) (6 + (bNrInPins) )
662662
663663struct audio_cs_if_as_general_descriptor {
664664 uint8_t bLength ;
@@ -683,7 +683,7 @@ struct audio_cs_if_as_format_type_descriptor {
683683 uint8_t tSamFreq [3 ];
684684} __PACKED ;
685685
686- #define AUDIO_SIZEOF_FORMAT_TYPE_DESC (n ) (8 + 3 * n )
686+ #define AUDIO_SIZEOF_FORMAT_TYPE_DESC (bSamFreqType ) (8 + 3 * (bSamFreqType) )
687687
688688struct audio_ep_descriptor {
689689 uint8_t bLength ;
@@ -738,7 +738,7 @@ struct audio_cs_ep_ep_general_descriptor {
738738 PP_NARG (__VA_ARGS__ ), /* bInCollection */ \
739739 __VA_ARGS__ /* baInterfaceNr */
740740
741- #define AUDIO_AC_DESCRIPTOR_INIT_LEN ( n ) (0x08 + 0x09 + 0x08 + n )
741+ #define AUDIO_AC_DESCRIPTOR_LEN ( bInCollection ) (0x08 + 0x09 + 0x08 + bInCollection )
742742
743743#define AUDIO_AC_INPUT_TERMINAL_DESCRIPTOR_INIT (bTerminalID , wTerminalType , bNrChannels , wChannelConfig ) \
744744 0x0C , /* bLength */ \
@@ -880,8 +880,8 @@ struct audio_cs_ep_ep_general_descriptor {
880880 0x03 , /* bRefresh, 8ms */ \
881881 0x00 /* bSynchAddress */
882882
883- #define AUDIO_AS_DESCRIPTOR_INIT_LEN ( n ) (0x09 + 0x09 + 0x07 + 0x08 + 3 * n + 0x09 + 0x07 )
884- #define AUDIO_AS_FEEDBACK_DESCRIPTOR_INIT_LEN ( n ) (0x09 + 0x09 + 0x07 + 0x08 + 3 * n + 0x09 + 0x07 + 0x09 )
883+ #define AUDIO_AS_DESCRIPTOR_LEN ( bSamFreqType ) (0x09 + 0x09 + 0x07 + 0x08 + 3 * ( bSamFreqType ) + 0x09 + 0x07 )
884+ #define AUDIO_AS_FEEDBACK_DESCRIPTOR_LEN ( bSamFreqType ) (0x09 + 0x09 + 0x07 + 0x08 + 3 * ( bSamFreqType ) + 0x09 + 0x07 + 0x09 )
885885
886886#define AUDIO_AS_ALTSETTING_DESCRIPTOR_INIT (bInterfaceNumber , bAlternateSetting , bTerminalLink , bNrChannels , bSubFrameSize , bBitResolution , bEndpointAddress , bmAttributes , wMaxPacketSize , bInterval , ...) \
887887 0x09 , /* bLength */ \
@@ -924,9 +924,9 @@ struct audio_cs_ep_ep_general_descriptor {
924924 0x00 , /* wLockDelay */ \
925925 0x00
926926
927- #define AUDIO_AS_ALTSETTING_DESCRIPTOR_INIT_LEN ( n ) (0x09 + 0x07 + 0x08 + 3 * n + 0x09 + 0x07 )
927+ #define AUDIO_AS_ALTSETTING_DESCRIPTOR_LEN ( bSamFreqType ) (0x09 + 0x07 + 0x08 + 3 * ( bSamFreqType ) + 0x09 + 0x07 )
928928
929- #define AUDIO_AS_ALTSETTING0_DESCRIPTOR_INIT (bInterfaceNumber ) \
929+ #define AUDIO_AS_ALTSETTING0_DESCRIPTOR_INIT (bInterfaceNumber ) \
930930 0x09 , /* bLength */ \
931931 USB_DESCRIPTOR_TYPE_INTERFACE , /* bDescriptorType */ \
932932 bInterfaceNumber , /* bInterfaceNumber */ \
@@ -937,19 +937,6 @@ struct audio_cs_ep_ep_general_descriptor {
937937 AUDIO_PROTOCOL_UNDEFINED , /* bInterfaceProtocol */ \
938938 0x00 /* iInterface */
939939
940- #define AUDIO_MS_STANDARD_DESCRIPTOR_INIT (bInterfaceNumber , bNumEndpoints ) \
941- 0x09 , /* bLength */ \
942- USB_DESCRIPTOR_TYPE_INTERFACE , /* bDescriptorType */ \
943- bInterfaceNumber , /* bInterfaceNumber */ \
944- 0x00 , /* bAlternateSetting */ \
945- bNumEndpoints , /* bNumEndpoints */ \
946- USB_DEVICE_CLASS_AUDIO , /* bInterfaceClass */ \
947- AUDIO_SUBCLASS_MIDISTREAMING , /* bInterfaceSubClass */ \
948- AUDIO_PROTOCOL_UNDEFINED , /* bInterfaceProtocol */ \
949- 0x00 /* iInterface */
950-
951- #define AUDIO_MS_STANDARD_DESCRIPTOR_INIT_LEN 0x09
952-
953940struct audio_v2_channel_cluster_descriptor {
954941 uint8_t bNrChannels ;
955942 uint32_t bmChannelConfig ;
@@ -993,7 +980,7 @@ struct audio_v2_cs_if_ac_clock_selector_descriptor {
993980 uint8_t iClockSelector ;
994981} __PACKED ;
995982
996- #define AUDIO_SIZEOF_AC_CLOCK_SELECTOR_DESC (n ) (7 + n )
983+ #define AUDIO_SIZEOF_AC_CLOCK_SELECTOR_DESC (bNrInPins ) (7 + ( bNrInPins ) )
997984
998985struct audio_v2_cs_if_ac_clock_multiplier_descriptor {
999986 uint8_t bLength ;
@@ -1005,7 +992,7 @@ struct audio_v2_cs_if_ac_clock_multiplier_descriptor {
1005992 uint8_t iClockMultiplier ;
1006993} __PACKED ;
1007994
1008- #define AUDIO_SIZEOF_AC_CLOCK_MULTIPLIER_DESC () (7)
995+ #define AUDIO_SIZEOF_AC_CLOCK_MULTIPLIER_DESC (7)
1009996
1010997struct audio_v2_cs_if_ac_input_terminal_descriptor {
1011998 uint8_t bLength ;
@@ -1049,7 +1036,7 @@ struct audio_v2_cs_if_ac_feature_unit_descriptor {
10491036 uint8_t iFeature ;
10501037} __PACKED ;
10511038
1052- #define AUDIO_V2_SIZEOF_AC_FEATURE_UNIT_DESC (ch ) (6 + (ch + 1) * 4)
1039+ #define AUDIO_V2_SIZEOF_AC_FEATURE_UNIT_DESC (bNrChannels ) (6 + ((bNrChannels) + 1) * 4)
10531040
10541041struct audio_v2_cs_if_as_general_descriptor {
10551042 uint8_t bLength ;
@@ -1124,7 +1111,7 @@ struct audio_v2_control_range3_param_block {
11241111 WBVAL (wTotalLength ), /* wTotalLength */ \
11251112 bmControls /* bmControls */ \
11261113
1127- #define AUDIO_V2_AC_DESCRIPTOR_INIT_LEN (0x08 + 0x09 + 0x09 )
1114+ #define AUDIO_V2_AC_DESCRIPTOR_LEN (0x08 + 0x09 + 0x09 )
11281115
11291116#define AUDIO_V2_AC_CLOCK_SOURCE_DESCRIPTOR_INIT (bClockID , bmAttributes , bmControls ) \
11301117 0x08 , /* bLength */ \
@@ -1262,7 +1249,7 @@ struct audio_v2_control_range3_param_block {
12621249 0x00 , /* wLockDelay */ \
12631250 0x00
12641251
1265- #define AUDIO_V2_AS_ALTSETTING0_DESCRIPTOR_INIT (bInterfaceNumber ) \
1252+ #define AUDIO_V2_AS_ALTSETTING0_DESCRIPTOR_INIT (bInterfaceNumber ) \
12661253 0x09 , /* bLength */ \
12671254 USB_DESCRIPTOR_TYPE_INTERFACE , /* bDescriptorType */ \
12681255 bInterfaceNumber , /* bInterfaceNumber */ \
@@ -1331,9 +1318,10 @@ struct audio_v2_control_range3_param_block {
13311318
13321319// clang-format on
13331320
1334- #define AUDIO_V2_AS_DESCRIPTOR_INIT_LEN (0x09 + 0x09 + 0x10 + 0x06 + 0x07 + 0x08 )
1335- #define AUDIO_V2_AS_ALTSETTING_DESCRIPTOR_INIT_LEN (0x09 + 0x10 + 0x06 + 0x07 + 0x08 )
1336- #define AUDIO_V2_AS_FEEDBACK_DESCRIPTOR_INIT_LEN (0x09 + 0x09 + 0x10 + 0x06 + 0x07 + 0x08 + 0x07 )
1321+ #define AUDIO_V2_AS_DESCRIPTOR_LEN (0x09 + 0x09 + 0x10 + 0x06 + 0x07 + 0x08 )
1322+ #define AUDIO_V2_AS_ALTSETTING0_DESCRIPTOR_LEN (0x09 )
1323+ #define AUDIO_V2_AS_ALTSETTING_DESCRIPTOR_LEN (0x09 + 0x10 + 0x06 + 0x07 + 0x08 )
1324+ #define AUDIO_V2_AS_FEEDBACK_DESCRIPTOR_LEN (0x09 + 0x09 + 0x10 + 0x06 + 0x07 + 0x08 + 0x07 )
13371325
13381326#define AUDIO_SAMPLE_FREQ_NUM (num ) (uint8_t )(num ), (uint8_t )((num >> 8 ))
13391327#define AUDIO_SAMPLE_FREQ_3B (frq ) (uint8_t )(frq ), (uint8_t )((frq >> 8 )), (uint8_t )((frq >> 16 ))
0 commit comments