diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7891f62e..0cf4ec8e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,13 @@ sc_usb_audio Change Log ======================= +6.15.0 +------ + - CHANGE: Removed 32kHz sample-rate support when PDM microphones enabled (lib_mic_array + currently does not support non-integer decimation factors) + - RESOLVED: UAC 1.0 descriptors now support multi-channel volume control (previously were + hard-coded as stereo) + 6.14.0 ------ - ADDED: Support for for master-clock/sample-rate divides that are not a power of 2 @@ -170,4 +177,7 @@ sc_usb_audio Change Log - CHANGE: Level meter buffer naming now resemble functionality +Legacy release history +---------------------- + Please see changelog in sw_usb_audio for changes prior to 6.8.0 release. diff --git a/module_usb_audio/devicedefines.h b/module_usb_audio/devicedefines.h index da3c8ac7..c43d30be 100644 --- a/module_usb_audio/devicedefines.h +++ b/module_usb_audio/devicedefines.h @@ -465,7 +465,7 @@ * @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number. */ #ifndef BCD_DEVICE_M -#define BCD_DEVICE_M 14 +#define BCD_DEVICE_M 15 #endif /** diff --git a/module_usb_audio/endpoint0/audiorequests.xc b/module_usb_audio/endpoint0/audiorequests.xc index 591d36fb..a5f727cb 100644 --- a/module_usb_audio/endpoint0/audiorequests.xc +++ b/module_usb_audio/endpoint0/audiorequests.xc @@ -874,7 +874,11 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c } #endif /* Special case for some low sample rates */ - unsigned lowSampleRateList[] = {8000, 11025, 12000, 16000, 32000}; + unsigned lowSampleRateList[] = {8000, 11025, 12000, 16000, +#if (NUM_PDM_MICS == 0) + 32000 +#endif + }; for (int k = 0; k < sizeof(lowSampleRateList)/sizeof(unsigned); k++) { diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index c8d02437..08f865b0 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -2227,9 +2227,11 @@ const unsigned num_freqs_a1 = MAX(3, (0 #if(MIN_FREQ <= 16000) && (MAX_FREQ_FS >= 16000) +1 #endif +#if (NUM_PDM_MICS == 0) #if(MIN_FREQ <= 32000) && (MAX_FREQ_FS >= 32000) +1 #endif +#endif #if (MIN_FREQ <= 44100) && (MAX_FREQ_FS >= 44100) +1 #endif @@ -2244,7 +2246,7 @@ const unsigned num_freqs_a1 = MAX(3, (0 #endif )); -#define AC_TOTAL_LENGTH (AC_LENGTH + (INPUT_INTERFACES_A1 * (19 + num_freqs_a1 * 3)) + (OUTPUT_INTERFACES_A1 * (19 + (num_freqs_a1 *3)))) +#define AC_TOTAL_LENGTH (AC_LENGTH + (INPUT_INTERFACES_A1 * (17 + NUM_USB_CHAN_IN_FS + num_freqs_a1 * 3)) + (OUTPUT_INTERFACES_A1 * (17 + NUM_USB_CHAN_OUT_FS + (num_freqs_a1 *3)))) #define STREAMING_INTERFACES (INPUT_INTERFACES_A1 + OUTPUT_INTERFACES_A1) /* Number of interfaces for Audio 1.0 (+1 for control ) */ @@ -2320,15 +2322,41 @@ unsigned char cfgDesc_Audio1[] = 11, /* iTerminal */ /* CS_Interface class specific AC interface feature unit descriptor - mute & volume for dac */ - 0x0A, + (8 + NUM_USB_CHAN_OUT_FS), UAC_CS_DESCTYPE_INTERFACE, UAC_CS_AC_INTERFACE_SUBTYPE_FEATURE_UNIT, /* 2 bDescriptorSubType: FEATURE_UNIT */ 0x0A, /* unitID */ 0x01, /* sourceID - ID of the unit/terminal to which this feature unit is connected */ 0x01, /* controlSize - 1 */ + 0x00, /* bmaControls(0) */ +#if (NUM_USB_CHAN_OUT_FS > 0) 0x03, /* bmaControls(1) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 1) 0x03, /* bmaControls(2) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 2) + 0x03, /* bmaControls(3) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 3) + 0x03, /* bmaControls(4) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 4) + 0x03, /* bmaControls(5) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 5) + 0x03, /* bmaControls(6) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 6) + 0x03, /* bmaControls(7) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 7) + 0x03, /* bmaControls(8) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 8) +#error NUM_USB_CHAN_OUT_FS > 8 currently supported +#endif 0x00, /* String table index */ /* CS_Interface Output Terminal Descriptor - Analogue out to speaker */ @@ -2366,15 +2394,40 @@ unsigned char cfgDesc_Audio1[] = 0x00, /* Unused */ /* CS_Interface class specific AC interface feature unit descriptor - mute & volume for adc */ - 0x0A, + (8 + NUM_USB_CHAN_IN_FS), UAC_CS_DESCTYPE_INTERFACE, UAC_CS_AC_INTERFACE_SUBTYPE_FEATURE_UNIT, /* 2 bDescriptorSubType: FEATURE_UNIT */ 0x0B, /* unitID */ 0x02, /* sourceID - ID of the unit/terminal to which this feature unit is connected */ 0x01, /* controlSize - 1 */ 0x00, /* bmaControls(0) */ +#if (NUM_USB_CHAN_IN_FS > 0) 0x03, /* bmaControls(1) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 1) 0x03, /* bmaControls(2) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 2) + 0x03, /* bmaControls(3) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 3) + 0x03, /* bmaControls(4) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 4) + 0x03, /* bmaControls(5) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 5) + 0x03, /* bmaControls(6) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 6) + 0x03, /* bmaControls(7) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 7) + 0x03, /* bmaControls(8) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 8) +#error NUM_USB_CHAN_IN_FS > 8 currently supported +#endif 0x00, /* String table index */ #endif @@ -2455,9 +2508,11 @@ unsigned char cfgDesc_Audio1[] = CHARIFY_SR(16000), /* sampleFreq - 16KHz */ #endif +#if (NUM_PDM_MICS == 0) #if(MIN_FREQ <= 32000) && (MAX_FREQ_FS >= 32000) CHARIFY_SR(32000), /* sampleFreq - 32KHz */ #endif +#endif #if (MIN_FREQ <= 44100) && (MAX_FREQ_FS >= 44100) 0x44, 0xAC, 0x00, /* sampleFreq - 44.1Khz */ @@ -2583,9 +2638,11 @@ unsigned char cfgDesc_Audio1[] = CHARIFY_SR(16000), /* sampleFreq - 32KHz */ #endif +#if (NUM_PDM_MICS == 0) #if(MIN_FREQ <= 32000) && (MAX_FREQ_FS >= 32000) CHARIFY_SR(32000), /* sampleFreq - 32KHz */ #endif +#endif #if (MIN_FREQ <= 44100) && (MAX_FREQ_FS >= 44100) 0x44, 0xAC, 0x00, /* sampleFreq - 44.1Khz */ diff --git a/module_usb_audio/pdm_mics/mic_array_conf.h b/module_usb_audio/pdm_mics/mic_array_conf.h index 35af7f29..8aca8c43 100644 --- a/module_usb_audio/pdm_mics/mic_array_conf.h +++ b/module_usb_audio/pdm_mics/mic_array_conf.h @@ -1,7 +1,6 @@ #ifndef MIC_ARRAY_CONF_H_ #define MIC_ARRAY_CONF_H_ -#define FRAME_SIZE_LOG2 0 - +#define MAX_FRAME_SIZE_LOG2 0 #endif /* MIC_ARRAY_CONF_H_ */ diff --git a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc index cf2821ce..94e65c71 100644 --- a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc +++ b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc @@ -16,6 +16,8 @@ #include "fir_decimator.h" #include "mic_array.h" +#define MAX_DECIMATION_FACTOR 12 + /* Hardware resources */ in port p_pdm_clk = PORT_PDM_CLK; in buffered port:32 p_pdm_mics = PORT_PDM_DATA; @@ -26,12 +28,12 @@ clock pdmclk = on tile[PDM_TILE]: XS1_CLKBLK_3; unsafe void user_pdm_process(frame_audio * unsafe audio, int output[]); void user_pdm_init(); -int data_0[4*COEFS_PER_PHASE*MAX_DECIMATION_FACTOR] = {0}; -int data_1[4*COEFS_PER_PHASE*MAX_DECIMATION_FACTOR] = {0}; +int data_0[4*THIRD_STAGE_COEFS_PER_STAGE * MAX_DECIMATION_FACTOR] = {0}; +int data_1[4*THIRD_STAGE_COEFS_PER_STAGE * MAX_DECIMATION_FACTOR] = {0}; frame_audio mic_audio[2]; -void pdm_process(streaming chanend c_ds_output_0, streaming chanend c_ds_output_1, chanend c_audio) +void pdm_process(streaming chanend c_ds_output[2], chanend c_audio) { unsigned buffer = 1; // Buffer index memset(mic_audio, sizeof(frame_audio), 0); @@ -45,21 +47,21 @@ void pdm_process(streaming chanend c_ds_output_0, streaming chanend c_ds_output_ c_audio :> samplerate; - unsigned decimationfactor = 48000/samplerate; + unsigned decimationfactor = 96000/samplerate; unsafe { - decimator_config_common dcc = {FRAME_SIZE_LOG2, 1, 0, 0, decimationfactor, fir_coefs[decimationfactor], 0}; - decimator_config dc0 = {&dcc, data_0, {0, 0, 0, 0}}; - decimator_config dc1 = {&dcc, data_1, {0, 0, 0, 0}}; - decimator_configure(c_ds_output_0, c_ds_output_1, dc0, dc1); - } + const int * unsafe fir_coefs[7] = {0, g_third_stage_div_2_fir, g_third_stage_div_4_fir, g_third_stage_div_6_fir, g_third_stage_div_8_fir, 0, g_third_stage_div_12_fir}; - decimator_init_audio_frame(c_ds_output_0, c_ds_output_1, buffer, mic_audio, DECIMATOR_NO_FRAME_OVERLAP); + decimator_config_common dcc = {MAX_FRAME_SIZE_LOG2, 1, 0, 0, decimationfactor, fir_coefs[decimationfactor/2], 0, 0, DECIMATOR_NO_FRAME_OVERLAP, 2}; + decimator_config dc[2] = {{&dcc, data_0, {0, 0, 0, 0}, 4}, {&dcc, data_1, {0, 0, 0, 0}, 4}}; + decimator_configure(c_ds_output, 2, dc); + + decimator_init_audio_frame(c_ds_output, 2, buffer, mic_audio, dcc); while(1) { - frame_audio * unsafe current = decimator_get_next_audio_frame(c_ds_output_0, c_ds_output_1, buffer, mic_audio); + frame_audio * unsafe current = decimator_get_next_audio_frame(c_ds_output, 2, buffer, mic_audio, dcc); unsafe { @@ -72,7 +74,7 @@ void pdm_process(streaming chanend c_ds_output_0, streaming chanend c_ds_output_ { for(int i = 0; i < NUM_PDM_MICS; i++) { - c_audio <: output[i]*decimationfactor; + c_audio <: output[i]; } } else @@ -80,6 +82,7 @@ void pdm_process(streaming chanend c_ds_output_0, streaming chanend c_ds_output_ break; } } + } } } } @@ -91,7 +94,7 @@ void pdm_process(streaming chanend c_ds_output_0, streaming chanend c_ds_output_ void pcm_pdm_mic(chanend c_pcm_out) { streaming chan c_4x_pdm_mic_0, c_4x_pdm_mic_1; - streaming chan c_ds_output_0, c_ds_output_1; + streaming chan c_ds_output[2]; /* TODO, always run mics at 3MHz */ configure_clock_src_divide(pdmclk, p_mclk, 2); @@ -102,9 +105,9 @@ void pcm_pdm_mic(chanend c_pcm_out) par { pdm_rx(p_pdm_mics, c_4x_pdm_mic_0, c_4x_pdm_mic_1); - decimate_to_pcm_4ch(c_4x_pdm_mic_0, c_ds_output_0); - decimate_to_pcm_4ch(c_4x_pdm_mic_1, c_ds_output_1); - pdm_process(c_ds_output_0, c_ds_output_1, c_pcm_out); + decimate_to_pcm_4ch(c_4x_pdm_mic_0, c_ds_output[0]); + decimate_to_pcm_4ch(c_4x_pdm_mic_1, c_ds_output[1]); + pdm_process(c_ds_output, c_pcm_out); } }