diff --git a/lib_xua/doc/rst/feat_spdif_rx.rst b/lib_xua/doc/rst/feat_spdif_rx.rst index 00dd249d..0753371d 100644 --- a/lib_xua/doc/rst/feat_spdif_rx.rst +++ b/lib_xua/doc/rst/feat_spdif_rx.rst @@ -20,11 +20,11 @@ Finally, a channel for the output samples must be declared, note, this should be The S/PDIF receiver should be called on the appropriate tile:: - SpdifReceive(p_spdif_rx, c_spdif_rx, 1, clk_spd_rx); + spdif_rx(c_spdif_rx,p_spdif_rx,clk_spd_rx,192000); .. note:: - It is recomended to use the value 1 for the ``initial_divider`` parameter + It is recomended to use the value 192000 for the ``sample_freq_estimate`` parameter With the steps above an S/PDIF stream can be captured by the xCORE. To be functionally useful the audio master clock must be able to synchronise to this external digital stream. Additionally, the host can be diff --git a/lib_xua/src/core/audiohub/xua_audiohub.xc b/lib_xua/src/core/audiohub/xua_audiohub.xc index c297c544..76229899 100755 --- a/lib_xua/src/core/audiohub/xua_audiohub.xc +++ b/lib_xua/src/core/audiohub/xua_audiohub.xc @@ -701,17 +701,16 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk, numBits = 32; } #endif - divide = mClk / ( curSamFreq * numBits); + divide = mClk / (curSamFreq * numBits); /* TODO; we should catch and handle the case when divide is 0. Currently design will lock up */ } - #if (DSD_CHANS_DAC > 0) if(dsdMode) { - /* Configure audio ports */ - ConfigAudioPortsWrapper( + /* Configure audio ports */ + ConfigAudioPortsWrapper( #if (I2S_CHANS_DAC != 0) || (DSD_CHANS_DAC != 0) p_dsd_dac, DSD_CHANS_DAC, @@ -724,7 +723,7 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk, null, p_dsd_clk, #endif - p_mclk_in, clk_audio_bclk, divide, curSamFreq, dsdMode); + p_mclk_in, clk_audio_bclk, divide, curSamFreq); } else #endif @@ -747,9 +746,8 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk, p_bclk, #endif #endif - p_mclk_in, clk_audio_bclk, divide, curSamFreq, dsdMode); -} - + p_mclk_in, clk_audio_bclk, divide, curSamFreq); + } { unsigned curFreq = curSamFreq; diff --git a/lib_xua/src/core/main.xc b/lib_xua/src/core/main.xc index d7a27d10..17c418e1 100755 --- a/lib_xua/src/core/main.xc +++ b/lib_xua/src/core/main.xc @@ -31,7 +31,7 @@ #endif #if (XUA_SPDIF_RX_EN) -#include "SpdifReceive.h" +#include "spdif.h" #endif #if (XUA_ADAT_RX_EN) @@ -142,7 +142,7 @@ on stdcore[XUD_TILE] : buffered in port:32 p_adat_rx = PORT_ADAT_IN; #endif #if (XUA_SPDIF_RX_EN) -on tile[XUD_TILE] : buffered in port:4 p_spdif_rx = PORT_SPDIF_IN; +on tile[XUD_TILE] : in port p_spdif_rx = PORT_SPDIF_IN; #endif #if (XUA_SPDIF_RX_EN) || (XUA_ADAT_RX_EN) || (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) @@ -228,7 +228,7 @@ XUD_EpType epTypeTableIn[ENDPOINT_COUNT_IN] = { XUD_EPTYPE_CTL | XUD_STATUS_ENAB XUD_EPTYPE_ISO, /* Async feedback endpoint */ #endif #if (XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN) - XUD_EPTYPE_BUL, + XUD_EPTYPE_INT, #endif #ifdef MIDI XUD_EPTYPE_BUL, @@ -685,7 +685,7 @@ int main() on tile[XUD_TILE]: { thread_speed(); - SpdifReceive(p_spdif_rx, c_spdif_rx, 1, clk_spd_rx); + spdif_rx(c_spdif_rx,p_spdif_rx,clk_spd_rx,192000); } #endif diff --git a/lib_xua/src/core/ports/audioports.c b/lib_xua/src/core/ports/audioports.c index 6c86344b..7e01219a 100644 --- a/lib_xua/src/core/ports/audioports.c +++ b/lib_xua/src/core/ports/audioports.c @@ -1,4 +1,4 @@ -// Copyright 2013-2022 XMOS LIMITED. +// Copyright 2013-2023 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. #include @@ -9,17 +9,17 @@ #include "xua.h" /* Note since DSD ports could be reused for I2S ports we do all the setup manually in C */ -#if DSD_CHANS_DAC > 0 +#if (DSD_CHANS_DAC > 0) port p_dsd_dac[DSD_CHANS_DAC] = { PORT_DSD_DAC0, #endif -#if DSD_CHANS_DAC > 1 +#if (DSD_CHANS_DAC > 1) PORT_DSD_DAC1, #endif -#if DSD_CHANS_DAC > 2 +#if (DSD_CHANS_DAC > 2) #error > 2 DSD chans currently not supported #endif -#if DSD_CHANS_DAC > 0 +#if (DSD_CHANS_DAC > 0) }; port p_dsd_clk = PORT_DSD_CLK; #endif @@ -45,7 +45,7 @@ void ConfigAudioPortsWrapper( port p_lrclk, port p_bclk, #endif - port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned curSamFreq, unsigned int dsdMode) + port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned curSamFreq) { ConfigAudioPorts( #if (I2S_CHANS_DAC != 0) || (DSD_CHANS_DAC != 0) diff --git a/lib_xua/src/core/ports/audioports.h b/lib_xua/src/core/ports/audioports.h index d0db0212..d37e86e2 100644 --- a/lib_xua/src/core/ports/audioports.h +++ b/lib_xua/src/core/ports/audioports.h @@ -1,4 +1,4 @@ -// Copyright 2011-2022 XMOS LIMITED. +// Copyright 2011-2023 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. #ifndef _AUDIOPORTS_H_ #define _AUDIOPORTS_H_ @@ -79,7 +79,7 @@ void ConfigAudioPortsWrapper( buffered in port:32 p_bclk, #endif #endif - in port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned curSamFreq, unsigned int dsdMode); + in port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned curSamFreq); #else void ConfigAudioPortsWrapper( @@ -95,7 +95,7 @@ void ConfigAudioPortsWrapper( port p_lrclk, port p_bclk, #endif - port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned curSamFreq, unsigned int dsdMode); + port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned curSamFreq); #endif /* __XC__*/ diff --git a/lib_xua/src/core/ports/audioports.xc b/lib_xua/src/core/ports/audioports.xc index dd8d9e44..10fd328f 100644 --- a/lib_xua/src/core/ports/audioports.xc +++ b/lib_xua/src/core/ports/audioports.xc @@ -1,4 +1,4 @@ -// Copyright 2011-2022 XMOS LIMITED. +// Copyright 2011-2023 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. #include #include @@ -6,9 +6,7 @@ #include "xua.h" #include "audioports.h" -//extern in port p_mclk_in; extern clock clk_audio_mclk; -//extern clock clk_audio_bclk; void ConfigAudioPorts( #if (I2S_CHANS_DAC != 0) || (DSD_CHANS_DAC != 0) @@ -58,7 +56,7 @@ void ConfigAudioPorts( } #endif -#if (I2S_CHANS_DAC != 0) +#if (I2S_CHANS_DAC != 0)|| (DSD_CHANS_DAC != 0) for(int i = 0; i < numPortsDac; i++) { clearbuf(p_i2s_dac[i]); @@ -82,7 +80,7 @@ void ConfigAudioPorts( /* Some adustments for timing. Sample ADC lines on negative edge and add some delay */ if(XUA_PCM_FORMAT == XUA_PCM_FORMAT_TDM) { - for(int i = 0; i < I2S_WIRES_ADC; i++) + for(int i = 0; i < numPortsAdc; i++) { set_port_sample_delay(p_i2s_adc[i]); set_pad_delay(p_i2s_adc[i], 4); @@ -91,7 +89,6 @@ void ConfigAudioPorts( #endif #elif (CODEC_MASTER) - /* Stop bit and master clock blocks */ stop_clock(clk_audio_bclk); @@ -112,9 +109,9 @@ void ConfigAudioPorts( set_clock_fall_delay(clk_audio_bclk, bClkDelay_fall); #endif -#if (I2S_CHANS_DAC != 0) - /* Clock I2S output data ports from b-clock clock block */ - for(int i = 0; i < I2S_WIRES_DAC; i++) +#if (I2S_CHANS_DAC != 0) || (DSD_CHANS_DAC != 0) + /* Clock I2S/DSD output data ports from b-clock clock block */ + for(int i = 0; i < numPortsDac; i++) { configure_out_port_no_ready(p_i2s_dac[i], clk_audio_bclk, 0); } @@ -122,7 +119,7 @@ void ConfigAudioPorts( #if (I2S_CHANS_ADC != 0) /* Clock I2S input data ports from clock block */ - for(int i = 0; i < I2S_WIRES_ADC; i++) + for(int i = 0; i < numPortsAdc; i++) { configure_in_port_no_ready(p_i2s_adc[i], clk_audio_bclk); }