x5/M5: Finally get rid of filter selection aberrations when switching to 88.2kHz sampling rate which affected both the DAC and ADC. Turning off the DAC and ADC before changing the internal codec frequency seems to cure the remaining glitch of the filters not being correctly selected by the TLV320. Some FIFO reset changes that help keep it stable as well. Supporting 88.2KHz on iAudio has been a tricky ordeal. Also made sure to ok the HW tone controls on iRiver. :)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12757 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2007-03-14 10:06:57 +00:00
parent a5f7ef27f0
commit 6c8772d6db
2 changed files with 21 additions and 3 deletions

View file

@ -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);
}
/**

View file

@ -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();