From 6c5253abb00a032cba824f18d424ee233a36a468 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Wed, 16 Oct 2013 19:09:21 +0100 Subject: [PATCH] A more elegant solution to the DSD stop_clock() pausing issue. Just set ALL clocks to 0 before deliver returns --- module_usb_audio/audio.xc | 5 ++++- module_usb_audio/ports/audioports.xc | 16 ++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/module_usb_audio/audio.xc b/module_usb_audio/audio.xc index a97da327..1f3ca087 100755 --- a/module_usb_audio/audio.xc +++ b/module_usb_audio/audio.xc @@ -325,7 +325,6 @@ extern void device_reboot(void); p_bclk <: 0; #if(DSD_CHANS_DAC != 0) /* DSD Clock might not be shared with lrclk or bclk... */ - if(dsdMode) p_dsd_clk <: 0; #endif command = inct(c_out); @@ -714,6 +713,7 @@ extern void device_reboot(void); // Set clocks low p_lrclk <: 0; p_bclk <: 0; + p_dsd_clk <: 0; return {0,0}; } } @@ -731,6 +731,9 @@ extern void device_reboot(void); if((DSD_MASK(samplesOut[0]) != DSD_MARKER_2) && (DSD_MASK(samplesOut[1]) != DSD_MARKER_2)) { dsdMode = 0; + // Set clocks low + p_lrclk <: 0; + p_bclk <: 0; p_dsd_clk <: 0; return {0,0}; } diff --git a/module_usb_audio/ports/audioports.xc b/module_usb_audio/ports/audioports.xc index 515deaca..ce6d4679 100644 --- a/module_usb_audio/ports/audioports.xc +++ b/module_usb_audio/ports/audioports.xc @@ -32,16 +32,7 @@ unsigned int divide) { #ifndef CODEC_MASTER - /* Output 0 on BCLK to ensure clock is low - * Required as stop_clock will only complete when the clock is low - */ - // configure_out_port_no_ready(p_bclk, clk_audio_mclk, 0); - // p_bclk <: 0; - - /* Stop_clock() will not complete if the source to the clock-block is not low - * since we are switching between DSD and I2S we grab the source from the clock - * -block and set it low - */ +#if 0 { unsigned clockResId; unsigned portResId; @@ -50,6 +41,11 @@ unsigned int divide) if(portResId !=1) asm("out res[%0], %1":: "r"(portResId), "r"(0)); } +#endif + + /* Note this call to stop_clock() will pause forever if the port clocking the clock-block is not low. + * deliver() should return with this being the case - however, if you are having trouble the code + * above can be enabled */ stop_clock(clk_audio_bclk); if(!isnull(p_lrclk))