diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index ab8648dd..68107c1e 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -170,6 +170,31 @@ typedef struct #endif #if (NUM_USB_CHAN_IN > 18) #error NUM_USB_CHAN > 18 +#endif + +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + STR_TABLE_ENTRY(mixOutStr_1); +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 1) + STR_TABLE_ENTRY(mixOutStr_2); +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 2) + STR_TABLE_ENTRY(mixOutStr_3); +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 3) + STR_TABLE_ENTRY(mixOutStr_4); +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 4) + STR_TABLE_ENTRY(mixOutStr_5); +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 5) + STR_TABLE_ENTRY(mixOutStr_6); +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 6) + STR_TABLE_ENTRY(mixOutStr_7); +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 7) + STR_TABLE_ENTRY(mixOutStr_8); #endif STR_TABLE_ENTRY(iAPInterfaceStr); } StringDescTable_t; @@ -849,6 +874,34 @@ StringDescTable_t g_strTable = #if (NUM_USB_CHAN_IN > 18) #error NUM_USB_CHAN_IN > 18 +#endif + +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + .mixOutStr_1 = "Mix 1", +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + .mixOutStr_2 = "Mix 2", +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + .mixOutStr_3 = "Mix 3", +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + .mixOutStr_4 = "Mix 4", +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + .mixOutStr_5 = "Mix 5", +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + .mixOutStr_6 = "Mix 6", +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + .mixOutStr_7 = "Mix 7", +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + .mixOutStr_8 = "Mix 8", +#endif +#if defined(MIXER) && (MAX_MIX_COUNT > 8) +#error #endif .iAPInterfaceStr = "iAP Interface", @@ -1021,7 +1074,7 @@ unsigned char devQualDesc_Null[] = #if defined(MIXER) && !defined(AUDIO_PATH_XUS) && (MAX_MIX_COUNT > 0) -#warning Extention units on the audio path are required for mixer. Enabling them now. +//#warning Extension units on the audio path are required for mixer. Enabling them now. #define AUDIO_PATH_XUS #endif @@ -1037,6 +1090,18 @@ unsigned char devQualDesc_Null[] = #define DFU_LENGTH (0) #endif +#ifdef MIXER + #define MIX_BMCONTROLS_LEN_TMP ((MAX_MIX_COUNT * MIX_INPUTS) / 8) + + #if ((MAX_MIX_COUNT * MIX_INPUTS)%8)==0 + #define MIX_BMCONTROLS_LEN (MIX_BMCONTROLS_LEN_TMP) + #else + #define MIX_BMCONTROLS_LEN (MIX_BMCONTROLS_LEN_TMP+1) + #endif + #define MIXER_LENGTH (13+1+MIX_BMCONTROLS_LEN) +#else + #define MIXER_LENGTH (0) +#endif #ifdef HID_CONTROLS @@ -1106,6 +1171,9 @@ typedef struct #if (NUM_USB_CHAN_OUT > 0) /* Output path */ USB_Descriptor_Audio_InputTerminal_t Audio_Out_InputTerminal; +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + USB_Descriptor_Audio_ExtensionUnit_t Audio_Out_ExtensionUnit; +#endif #if(OUTPUT_VOLUME_CONTROL == 1) USB_Descriptor_Audio_FeatureUnit_Out_t Audio_Out_FeatureUnit; #endif @@ -1114,12 +1182,22 @@ typedef struct #if (NUM_USB_CHAN_IN > 0) /* Input path */ USB_Descriptor_Audio_InputTerminal_t Audio_In_InputTerminal; +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + USB_Descriptor_Audio_ExtensionUnit_t Audio_In_ExtensionUnit; +#endif #if(INPUT_VOLUME_CONTROL == 1) USB_Descriptor_Audio_FeatureUnit_In_t Audio_In_FeatureUnit; #endif USB_Descriptor_Audio_OutputTerminal_t Audio_In_OutputTerminal; #endif +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + USB_Descriptor_Audio_ExtensionUnit2_t Audio_Mix_ExtensionUnit; + // Currently no struct for mixer unit + // USB_Descriptor_Audio_MixerUnit_t Audio_MixerUnit; + unsigned char configDesc_MixerUnit[MIXER_LENGTH]; +#endif #if defined (SPDIF_RX) || defined (ADAT_RX) + /* Interrupt EP */ USB_Descriptor_Endpoint_t Audio_Int_Endpoint; #endif } __attribute__((packed)) USB_CfgDesc_Audio2_CS_Control_Int; @@ -1369,6 +1447,23 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .iTerminal = offsetof(StringDescTable_t, usbInputTermStr_Audio2)/sizeof(char *) }, +#if defined (MIXER) && (MAX_MIX_COUNT > 0) + .Audio_Out_ExtensionUnit = + { + .bLength = sizeof(USB_Descriptor_Audio_ExtensionUnit_t), + .bDescriptorType = UAC_CS_DESCTYPE_INTERFACE, + .bDescriptorSubtype = UAC_CS_AC_INTERFACE_SUBTYPE_EXTENSION_UNIT, + .bUnitID = ID_XU_OUT, + .wExtensionCode = 0x00, + .bNrInPins = 1, + .baSourceID[0] = ID_IT_USB, + .bNrChannels = NUM_USB_CHAN_OUT, + .bmChannelConfig = 0x00000000, + .bmControls = 0x03, + .iExtension = 0 + }, +#endif + #if(OUTPUT_VOLUME_CONTROL == 1) /* Feature Unit Descriptor */ .Audio_Out_FeatureUnit = @@ -1377,7 +1472,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= 0x24, /* 1 bDescriptorType: CS_INTERFACE */ 0x06, /* 2 bDescriptorSubType: FEATURE_UNIT */ FU_USBOUT, /* 3 bUnitID */ -#ifdef AUDIO_PATH_XUS +#if defined (MIXER) && (MAX_MIX_COUNT > 0) ID_XU_OUT, /* 4 bSourceID */ #else ID_IT_USB, /* 4 bSourceID */ @@ -1465,6 +1560,9 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= 0, /* 11 iTerminal */ }, #endif + + + #if (NUM_USB_CHAN_IN > 0) /* Input Terminal Descriptor (Analogue Input Terminal) */ .Audio_In_InputTerminal = @@ -1483,6 +1581,23 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .iTerminal = 0, }, +#if defined (MIXER) && (MAX_MIX_COUNT > 0) + .Audio_In_ExtensionUnit = + { + .bLength = sizeof(USB_Descriptor_Audio_ExtensionUnit_t), + .bDescriptorType = UAC_CS_DESCTYPE_INTERFACE, + .bDescriptorSubtype = UAC_CS_AC_INTERFACE_SUBTYPE_EXTENSION_UNIT, + .bUnitID = ID_XU_IN, + .wExtensionCode = 0x00, + .bNrInPins = 1, + .baSourceID[0] = ID_IT_AUD, + .bNrChannels = NUM_USB_CHAN_IN, + .bmChannelConfig = 0x00000000, + .bmControls = 0x03, + .iExtension = 0 + }, +#endif + #if (INPUT_VOLUME_CONTROL == 1) .Audio_In_FeatureUnit = { @@ -1490,7 +1605,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= UAC_CS_DESCTYPE_INTERFACE, /* 1 bDescriptorType: CS_INTERFACE */ UAC_CS_AC_INTERFACE_SUBTYPE_FEATURE_UNIT, /* 2 bDescriptorSubType: FEATURE_UNIT */ FU_USBIN, /* 3 bUnitID */ -#ifdef AUDIO_PATH_XUS +#if defined(MIXER) && (MAX_MIX_COUNT > 0) ID_XU_IN, /* 4 bSourceID */ #else ID_IT_AUD, /* 4 bSourceID */ @@ -1580,6 +1695,100 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= }, #endif +#if defined(MIXER) && (MAX_MIX_COUNT > 0) + /* Extension Unit Descriptor (4.7.2.12) */ + .Audio_Mix_ExtensionUnit = + { + .bLength = sizeof(USB_Descriptor_Audio_ExtensionUnit2_t), + .bDescriptorType = UAC_CS_DESCTYPE_INTERFACE, + .bDescriptorSubtype = UAC_CS_AC_INTERFACE_SUBTYPE_EXTENSION_UNIT, + .bUnitID = ID_XU_MIXSEL, + .wExtensionCode = 0x00, + .bNrInPins = 2, + .baSourceID[0] = ID_IT_USB, + .baSourceID[1] = ID_IT_AUD, + .bNrChannels = MIX_INPUTS, + .bmChannelConfig = 0x00000000, + .bmControls = 0x03, + .iExtension = 0 + }, + + /* Mixer Unit Descriptors */ + /* N = 144 (18 * 8) */ + /* Mixer Unit Bitmap - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff */ + { + MIXER_LENGTH, /* 0 bLength : 13 + num inputs + bit map (inputs * outputs) */ + UAC_CS_DESCTYPE_INTERFACE, /* bDescriptorType */ + 0x04, /* bDescriptorSubtype: MIXER_UNIT */ + ID_MIXER_1, /* Mixer unit id */ + 0x01, /* Number of input pins */ + ID_XU_MIXSEL, /* Connected terminal or unit id for input pin */ + MAX_MIX_COUNT, /* Number of mixer output channels */ + 0x00, 0x00, 0x00, 0x00, /* Spacial location ???? */ + offsetof(StringDescTable_t, mixOutStr_1)/sizeof(char *), /* iChannelNames */ +#if MIX_BMCONTROLS_LEN > 0 /* Mixer programmable control bitmap */ + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 1 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 2 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 3 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 4 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 5 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 6 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 7 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 8 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 9 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 10 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 11 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 12 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 13 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 14 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 15 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 16 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 17 + 0xff, +#endif +#if MIX_BMCONTROLS_LEN > 18 +#error unxpected BMCONTROLS_LEN +#endif + 0x00, /* bmControls */ + 0 /* Mixer unit string descriptor index */ + }, +#endif + #if defined(SPDIF_RX) || defined(ADAT_RX) /* Standard AS Interrupt Endpoint Descriptor (4.8.2.1): */ .Audio_Int_Endpoint =