diff options
-rw-r--r-- | firmware/drivers/tlv320.c | 12 | ||||
-rw-r--r-- | firmware/target/coldfire/pcm-coldfire.c | 12 |
2 files changed, 21 insertions, 3 deletions
diff --git a/firmware/drivers/tlv320.c b/firmware/drivers/tlv320.c index c0f28d31d9..3e27d22817 100644 --- a/firmware/drivers/tlv320.c +++ b/firmware/drivers/tlv320.c @@ -141,10 +141,22 @@ void audiohw_set_frequency(unsigned fsel) (0xf << 2), /* 88200 */ }; + unsigned value_dap, value_pc; + if (fsel >= ARRAYLEN(values_src)) fsel = 1; + /* Temporarily turn off the DAC and ADC before switching sample + rates or they don't choose their filters correctly */ + value_dap = tlv320_regs[REG_DAP]; + value_pc = tlv320_regs[REG_PC]; + + tlv320_write_reg(REG_DAP, value_dap | DAP_DACM); + tlv320_write_reg(REG_PC, value_pc | PC_DAC | PC_ADC); tlv320_write_reg(REG_SRC, values_src[fsel]); + tlv320_write_reg(REG_PC, value_pc | PC_DAC); + tlv320_write_reg(REG_PC, value_pc); + tlv320_write_reg(REG_DAP, value_dap); } /** diff --git a/firmware/target/coldfire/pcm-coldfire.c b/firmware/target/coldfire/pcm-coldfire.c index b827887636..ee9dfb3a3e 100644 --- a/firmware/target/coldfire/pcm-coldfire.c +++ b/firmware/target/coldfire/pcm-coldfire.c @@ -128,6 +128,7 @@ bool _pcm_apply_settings(bool clear_reset) { static int last_pcm_freq = 0; bool did_reset = false; + unsigned long iis_play_defparm = IIS_PLAY_DEFPARM; if (pcm_freq != last_pcm_freq) { @@ -139,13 +140,18 @@ bool _pcm_apply_settings(bool clear_reset) or starting recording will sound absolutely awful once in awhile - audiohw_set_frequency then coldfire_set_pllcr_audio_bits */ + SET_IIS_PLAY(iis_play_defparm | IIS_FIFO_RESET); audiohw_set_frequency(freq_ent[FPARM_FSEL]); coldfire_set_pllcr_audio_bits(PLLCR_SET_AUDIO_BITS_DEFPARM); did_reset = true; } - SET_IIS_PLAY(IIS_PLAY_DEFPARM | - (clear_reset ? 0 : (IIS_PLAY & IIS_FIFO_RESET))); + /* If a reset was done because of a sample rate change, IIS_PLAY will have + been set already, so only needs to be set again if the reset flag must + be cleared. If the frequency didn't change, it was never altered and + the reset flag can just be removed or no action taken. */ + if (clear_reset) + SET_IIS_PLAY(iis_play_defparm & ~IIS_FIFO_RESET); #if 0 logf("IISPLAY: %08X", IIS_PLAY); #endif @@ -259,9 +265,9 @@ void pcm_init(void) /* Setup Coldfire I2S before initializing hardware or changing other settings. */ or_l(IIS_FIFO_RESET, &IIS_PLAY); + SET_IIS_PLAY(IIS_PLAY_DEFPARM | IIS_FIFO_RESET); pcm_set_frequency(HW_FREQ_DEFAULT); audio_set_output_source(AUDIO_SRC_PLAYBACK); - SET_IIS_PLAY(IIS_FIFO_RESET | IIS_PLAY_DEFPARM); /* Initialize default register values. */ audiohw_init(); |