From aac2b4b7fbec07acf02b53a74d4fdc361040029a Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 15 Jan 2024 15:20:37 +0000 Subject: [PATCH] Initial conflict resolve following merge --- lib_xua/api/xua_audiohub.h | 25 ++++++++++++++-- lib_xua/api/xua_buffer.h | 8 +++--- lib_xua/api/xua_clocking.h | 1 + lib_xua/api/xua_conf_default.h | 13 +++------ lib_xua/module_build_info | 2 ++ lib_xua/src/core/audiohub/xua_audiohub.xc | 7 +++-- lib_xua/src/core/buffer/ep/ep_buffer.xc | 16 +++++------ lib_xua/src/core/main.xc | 35 ++++++++--------------- 8 files changed, 58 insertions(+), 49 deletions(-) diff --git a/lib_xua/api/xua_audiohub.h b/lib_xua/api/xua_audiohub.h index 12c44379..ed9da2aa 100644 --- a/lib_xua/api/xua_audiohub.h +++ b/lib_xua/api/xua_audiohub.h @@ -86,8 +86,29 @@ void AudioHwConfig(unsigned samFreq, unsigned mClk, unsigned dsdMode, #endif // __XC__ -void UserBufferManagementInit(unsigned samFreq); - +/** + * @brief User buffer management code + * + * This function is called at the sample rate of the USB Audio stack (e.g,. 48 kHz) and between the two parameter arrays + * contain a full multi-channel audio-frame. The first array carries all the data that has been received from the USB host + * and is to be presented to the audio interfaces. The second array carries all the data received from the interfaces and + * is to be presented to the USB host. The user can chose to intercept and overwrite the samples stored in these arrays. + * + * \param sampsFromUsbToAudio Samples received from USB host and to be presented to audio interfaces + * + * \param sampsFromAudioToUsb Samples received from the audio interfaces and to be presented to the USB host +*/ void UserBufferManagement(unsigned sampsFromUsbToAudio[], unsigned sampsFromAudioToUsb[]); +/** + * @brief User buffer managment init code + * + * This function is called once, before the first call to UserBufferManagement(), and can be used to initialise any + * related user state + * + * \param sampFreq The initial sample frequency + * + */ +void UserBufferManagementInit(unsigned sampFreq); + #endif // _XUA_AUDIOHUB_H_ diff --git a/lib_xua/api/xua_buffer.h b/lib_xua/api/xua_buffer.h index a1299079..7e07a113 100644 --- a/lib_xua/api/xua_buffer.h +++ b/lib_xua/api/xua_buffer.h @@ -53,10 +53,10 @@ void XUA_Buffer( #endif , chanend c_aud #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || defined(__DOYXGEN__) - #if (!XUA_USE_APP_PLL) || defined(__DOXYGEN__) + #if (!USE_SW_PLL) || defined(__DOXYGEN__) , client interface pll_ref_if i_pll_ref #endif - #if (XUA_USE_APP_PLL) || defined(__DOXYGEN__) + #if (USE_SW_PLL) || defined(__DOXYGEN__) , chanend c_swpll_update #endif #endif @@ -88,10 +88,10 @@ void XUA_Buffer_Ep(chanend c_aud_out, , chanend c_buff_ctrl #endif #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || defined(__DOYXGEN__) - #if (!XUA_USE_APP_PLL) || defined(__DOXYGEN__) + #if (!USE_SW_PLL) || defined(__DOXYGEN__) , client interface pll_ref_if i_pll_ref #endif - #if (XUA_USE_APP_PLL) || defined(__DOXYGEN__) + #if (USE_SW_PLL) || defined(__DOXYGEN__) , chanend c_swpll_update #endif #endif diff --git a/lib_xua/api/xua_clocking.h b/lib_xua/api/xua_clocking.h index f24ab1b5..f2a80c1c 100644 --- a/lib_xua/api/xua_clocking.h +++ b/lib_xua/api/xua_clocking.h @@ -39,6 +39,7 @@ void clockGen( streaming chanend ?c_spdif_rx, port ?p_for_mclk_count_aud, chanend c_mclk_change); +#if (XUA_USE_APP_PLL) interface SoftPll_if { diff --git a/lib_xua/api/xua_conf_default.h b/lib_xua/api/xua_conf_default.h index 0fbb1046..5937fe07 100644 --- a/lib_xua/api/xua_conf_default.h +++ b/lib_xua/api/xua_conf_default.h @@ -265,21 +265,16 @@ #endif /** - * @brief Enable/disable the use of the secondary/application PLL for generating master-clocks. + * @brief Enable/disable the use of the secondary/application PLL for generating and recovering master-clocks. * Only available on xcore.ai devices. * * Default: Enabled (for xcore.ai devices) */ -#ifndef XUA_USE_APP_PLL +#ifndef USE_SW_PLL #if defined(__XS3A__) - #if (XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) - /* Currently must use an external CS2100 device for syncing to external digital streams */ - #define XUA_USE_APP_PLL (0) - #else - #define XUA_USE_APP_PLL (1) - #endif + #define USE_SW_PLL (1) #else - #define XUA_USE_APP_PLL (0) + #define USE_SW_PLL (0) #endif #endif diff --git a/lib_xua/module_build_info b/lib_xua/module_build_info index 444c67ce..d11e0585 100644 --- a/lib_xua/module_build_info +++ b/lib_xua/module_build_info @@ -54,6 +54,7 @@ INCLUDE_DIRS = $(EXPORT_INCLUDE_DIRS) \ src/core/support \ src/core/user \ src/core/user/audiostream \ + src/core/user/audiohw \ src/core/user/hid \ src/core/user/hostactive \ src/hid \ @@ -70,6 +71,7 @@ SOURCE_DIRS = src/core \ src/core/ports \ src/core/support \ src/core/user/audiostream \ + src/core/user/audiohw \ src/core/user/hostactive \ src/core/xuduser \ src/dfu \ diff --git a/lib_xua/src/core/audiohub/xua_audiohub.xc b/lib_xua/src/core/audiohub/xua_audiohub.xc index 3c6ce660..279ef608 100755 --- a/lib_xua/src/core/audiohub/xua_audiohub.xc +++ b/lib_xua/src/core/audiohub/xua_audiohub.xc @@ -814,9 +814,10 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk, /* User should mute audio hardware */ AudioHwConfig_Mute(); - #if (XUA_USE_APP_PLL) - i_softPll.init(mClk); - #endif +#if (USE_SW_PLL) + // i_softPll.init(mClk); + #warning SORT THIS +#endif /* User code should configure audio harware for SampleFreq/MClk etc */ AudioHwConfig(curFreq, mClk, dsdMode, curSamRes_DAC, curSamRes_ADC); diff --git a/lib_xua/src/core/buffer/ep/ep_buffer.xc b/lib_xua/src/core/buffer/ep/ep_buffer.xc index 2a7ee928..0544b960 100644 --- a/lib_xua/src/core/buffer/ep/ep_buffer.xc +++ b/lib_xua/src/core/buffer/ep/ep_buffer.xc @@ -105,7 +105,7 @@ void XUA_Buffer( #endif , chanend c_aud #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) - #if(XUA_USE_APP_PLL) + #if(USE_SW_PLL) , chanend c_swpll_update #else , client interface pll_ref_if i_pll_ref @@ -145,7 +145,7 @@ void XUA_Buffer( , c_buff_ctrl #endif #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) - #if(XUA_USE_APP_PLL) + #if(USE_SW_PLL) , c_swpll_update #else , i_pll_ref @@ -199,7 +199,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out, , chanend c_buff_ctrl #endif #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) - #if (XUA_USE_APP_PLL) + #if (USE_SW_PLL) , chanend c_swpll_update #else , client interface pll_ref_if i_pll_ref @@ -370,7 +370,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out, #define LOCAL_CLOCK_MARGIN (1000) #endif -#if (!XUA_USE_APP_PLL) +#if (!USE_SW_PLL) timer t_sofCheck; unsigned timeLastEdge; unsigned timeNextEdge; @@ -379,7 +379,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out, i_pll_ref.toggle(); #endif -#endif +#endif /* (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) */ while(1) { @@ -525,7 +525,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out, } break; } -#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) && (!XUA_USE_APP_PLL) +#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) && (!USE_SW_PLL) case t_sofCheck when timerafter(timeNextEdge) :> void: i_pll_ref.toggle(); timeLastEdge = timeNextEdge; @@ -557,14 +557,14 @@ void XUA_Buffer_Ep(register chanend c_aud_out, { sofCount = 0; pllUpdate++; -#if (!XUA_USE_APP_PLL) +#if (!USE_SW_PLL) /* Port is accessed via interface to allow flexibilty with location */ i_pll_ref.toggle(); t_sofCheck :> timeLastEdge; timeNextEdge = timeLastEdge + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN; #endif } -#if (XUA_USE_APP_PLL) +#if (USE_SW_PLL) // Update PLL @ 100Hz if(pllUpdate == 10) { diff --git a/lib_xua/src/core/main.xc b/lib_xua/src/core/main.xc index 6bfb1b30..053dd63b 100755 --- a/lib_xua/src/core/main.xc +++ b/lib_xua/src/core/main.xc @@ -316,9 +316,6 @@ void usb_audio_io(chanend ?c_aud_in, , client interface pll_ref_if i_pll_ref , port ?p_for_mclk_count_aud #endif - #if (XUA_USE_APP_PLL) - , client interface SoftPll_if i_softPll - #endif ) { #if (MIXER) @@ -376,9 +373,6 @@ void usb_audio_io(chanend ?c_aud_in, #define AUDIO_CHANNEL c_aud_in #endif XUA_AudioHub(AUDIO_CHANNEL, clk_audio_mclk, clk_audio_bclk, p_mclk_in, p_lrclk, p_bclk, p_i2s_dac, p_i2s_adc -if (XUA_USE_APP_PLL) - , i_softPll -#endif #if (XUA_SPDIF_TX_EN) //&& (SPDIF_TX_TILE != AUDIO_IO_TILE) , c_spdif_tx #endif @@ -489,13 +483,12 @@ int main() #endif #endif -#if (((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) && !XUA_USE_APP_PLL) || XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) +#if ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC || XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) && !USE_SW_PLL) interface pll_ref_if i_pll_ref; #endif -#if (XUA_USE_APP_PLL) - interface SoftPll_if i_softPll; - chan c_swpll_update; +#if ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC || XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) && USE_SW_PLL) + chan c_sw_pll; #endif chan c_sof; chan c_xud_out[ENDPOINT_COUNT_OUT]; /* Endpoint channels for XUD */ @@ -518,7 +511,7 @@ int main() { USER_MAIN_CORES -#if (((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) && XUA_USE_APP_PLL) || XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) +#if ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC || XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) && !USE_SW_PLL) on tile[PLL_REF_TILE]: PllRefPinTask(i_pll_ref, p_pll_ref); #endif on tile[XUD_TILE]: @@ -531,7 +524,7 @@ int main() DFUHandler(dfuInterface, null); #endif -#if (XUA_USE_APP_PLL) +#if ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC || XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) && USE_SW_PLL) //XUA_SoftPll(tile[0], i_softPll, c_swpll_update); #endif @@ -593,13 +586,11 @@ int main() #endif , c_mix_out #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) - #if (!XUA_USE_APP_PLL) - + #if (!USE_SW_PLL) , i_pll_ref #else - , c_swpll_update + , c_sw_pll #endif -#endif #endif ); //: @@ -614,8 +605,8 @@ int main() #endif /* XUA_USB_EN */ } -#if(XUA_USE_APP_PLL) - on tile[AUDIO_IO_TILE]: XUA_SoftPll(tile[0], i_softPll, c_swpll_update); +#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC && !USE_SW_PLL) + // on tile[AUDIO_IO_TILE]: XUA_SoftPll(tile[0], i_softPll, c_swpll_update); #endif on tile[AUDIO_IO_TILE]: @@ -634,17 +625,15 @@ int main() , dfuInterface #endif #if (XUA_NUM_PDM_MICS > 0) -#if (PDM_TILE == AUDIO_IO_TILE) + #if (PDM_TILE == AUDIO_IO_TILE) , c_ds_output -#endif + #endif , c_pdm_pcm #endif #if (XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) , i_pll_ref #endif -if (XUA_USE_APP_PLL) - , i_softPll -#endif +#if (XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) , p_for_mclk_count_audio #endif );