From 641fbdfca61ee5c2649bca841bdfba0621ccdcf4 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Thu, 17 Apr 2014 14:14:05 +0100 Subject: [PATCH] Added define OUTPUT_VOLUME_CONTROL which disables output volume control - both in the descriptors and processing. NOTE: Still could be extended to disable volume in MIXER --- module_usb_audio/devicedefines.h | 13 +++++++++- module_usb_audio/endpoint0/descriptors.h | 30 +++++++++++++++--------- module_usb_audio/usb_buffer/decouple.xc | 6 ++--- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/module_usb_audio/devicedefines.h b/module_usb_audio/devicedefines.h index 563d8de6..578dd4c4 100644 --- a/module_usb_audio/devicedefines.h +++ b/module_usb_audio/devicedefines.h @@ -617,6 +617,17 @@ enum USBEndpointNumber_Out ENDPOINT_COUNT_OUT /* End marker */ }; +/* Enable output volume control by default */ +#ifndef OUTPUT_VOLUME_CONTROL +#define OUTPUT_VOLUME_CONTROL 1 +#endif + +/* Enable input volume control by default */ +#ifndef INPUT_VOLUME_CONTROL +#define INPUT_VOLUME_CONTROL 1 +#endif + + #define AUDIO_STOP_FOR_DFU (0x12345678) #define AUDIO_START_FROM_DFU (0x87654321) #define AUDIO_REBOOT_FROM_DFU (0xa5a5a5a5) @@ -676,7 +687,7 @@ enum USBEndpointNumber_Out #ifdef MIXER #ifndef MAX_MIX_COUNT - #define MAX_MIX_COUNT 8 + #define MAX_MIX_COUNT 8 #endif #else #define MAX_MIX_COUNT 0 diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index 44b9b7ea..639b5f1c 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -840,7 +840,9 @@ typedef struct #ifdef OUTPUT /* Output path */ USB_Descriptor_Audio_InputTerminal_t Audio_Out_InputTerminal; +#if(OUTPUT_VOLUME_CONTROL==1) USB_Descriptor_Audio_FeatureUnit_Out_t Audio_Out_FeatureUnit; +#endif USB_Descriptor_Audio_OutputTerminal_t Audio_Out_OutputTerminal; #endif #ifdef INPUT @@ -1066,7 +1068,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .bDescriptorSubType = UAC_CS_AC_INTERFACE_SUBTYPE_CLOCK_SELECTOR, .bClockID = ID_CLKSEL, .bNrPins = NUM_CLOCKS, - ID_CLKSRC_INT, /* baCSourceID */ + .baCSourceId[0] = ID_CLKSRC_INT, /* baCSourceID */ #ifdef SPDIF_RX ID_CLKSRC_SPDIF, /* baCSourceID */ @@ -1083,19 +1085,20 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .Audio_Out_InputTerminal = { .bLength = sizeof(USB_Descriptor_Audio_InputTerminal_t), - UAC_CS_DESCTYPE_INTERFACE, /* 1 bDescriptorType */ - UAC_CS_AC_INTERFACE_SUBTYPE_INPUT_TERMINAL, /* 2 bDescriptorSubType: INPUT_TERMINAL */ - ID_IT_USB, /* 3 bTerminalID */ - USB_TERMTYPE_USB_STREAMING, /* 5 wTerminalType: USB Streaming */ - 0x00, /* 6 bAssocTerminal */ - ID_CLKSEL, /* 7 bCSourceID: ID of Clock Entity */ - NUM_USB_CHAN_OUT, /* 8 bNrChannels */ - 0x00000000, /* 9 bmChannelConfig TODO. Set me! */ + .bDescriptorType = UAC_CS_DESCTYPE_INTERFACE, + .bDescriptorSubtype = UAC_CS_AC_INTERFACE_SUBTYPE_INPUT_TERMINAL, + .bTerminalID = ID_IT_USB, + .wTerminalType = USB_TERMTYPE_USB_STREAMING, + .bAssocTerminal = 0x00, + .bCSourceID = ID_CLKSEL, + .bNrChannels = NUM_USB_CHAN_OUT, + .bmChannelConfig = 0x00000000, /* TODO. Set me! */ .iChannelNames = offsetof(StringDescTable_t, outputChanStr_1)/sizeof(char *), - 0x0000, /* 14 bmControls */ - 6, /* 16 iTerminal */ + .bmControls = 0x0000, + .iTerminal = offsetof(StringDescTable_t, usbInputTermStr_Audio2)/sizeof(char *) }, +#if(OUTPUT_VOLUME_CONTROL == 1) /* Feature Unit Descriptor */ .Audio_Out_FeatureUnit = { @@ -1170,6 +1173,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= }, 0, /* 60 iFeature */ }, +#endif /* Output Terminal Descriptor (Audio) */ .Audio_Out_OutputTerminal = @@ -1180,7 +1184,11 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= ID_OT_AUD, /* 3 bTerminalID */ .wTerminalType = UAC_TT_OUTPUT_TERMTYPE_SPEAKER, 0x00, /* 6 bAssocTerminal */ +#if (OUTPUT_VOLUME_CONTROL == 1) FU_USBOUT, /* 7 bSourceID Connect to analog input feature unit*/ +#else + ID_IT_USB, /* 7 bSourceID Connect to analog input feature unit*/ +#endif ID_CLKSEL, /* 8 bCSourceUD */ 0x0000, /* 9 bmControls */ 0, /* 11 iTerminal */ diff --git a/module_usb_audio/usb_buffer/decouple.xc b/module_usb_audio/usb_buffer/decouple.xc index 130f7205..2055c400 100644 --- a/module_usb_audio/usb_buffer/decouple.xc +++ b/module_usb_audio/usb_buffer/decouple.xc @@ -339,7 +339,7 @@ __builtin_unreachable(); g_aud_from_host_rdptr+=2; sample <<= 16; -#ifndef OUT_VOLUME_IN_MIXER +#if (OUTPUT_VOLUME_CONTROL == 1) && !defined(OUT_VOLUME_IN_MIXER) asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multOut),"r"(i)); {h, l} = macs(mult, sample, 0, 0); /* Note, in 2 byte subslot mode - ignore lower result of macs */ @@ -367,7 +367,7 @@ __builtin_unreachable(); read_via_xc_ptr(sample, g_aud_from_host_rdptr); g_aud_from_host_rdptr+=4; -#ifndef OUT_VOLUME_IN_MIXER +#if (OUTPUT_VOLUME_CONTROL == 1) && !defined(OUT_VOLUME_IN_MIXER) asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multOut),"r"(i)); {h, l} = macs(mult, sample, 0, 0); h <<= 3; @@ -422,7 +422,7 @@ __builtin_unreachable(); } unpackState++; -#ifndef OUT_VOLUME_IN_MIXER +#if (OUTPUT_VOLUME_CONTROL == 1) && !defined(OUT_VOLUME_IN_MIXER) asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multOut),"r"(i)); {h, l} = macs(mult, sample, 0, 0); h <<= 3;