Skip to content

Commit

Permalink
rpi sound cards: Fix Codec Zero rate switching
Browse files Browse the repository at this point in the history
The Raspberry Pi Codec Zero (and IQaudIO Codec) don't notify the DA7213
codec when it needs to change PLL frequencies. As a result, audio can
be played at the wrong rate - play a 48kHz sound immediately after a
44.1kHz sound to see the effect, but in some configurations the codec
can lock into the wrong state and always get some rates wrong.

Add the necessary notification to fix the issue.

Signed-off-by: Phil Elwell <[email protected]>
  • Loading branch information
pelwell authored and popcornmix committed Jul 24, 2023
1 parent 9e4d5ff commit 8a6f407
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sound/soc/bcm/iqaudio-codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ static int snd_rpi_iqaudio_codec_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
unsigned int samplerate = params_rate(params);

switch (samplerate) {
Expand All @@ -152,15 +153,17 @@ static int snd_rpi_iqaudio_codec_hw_params(struct snd_pcm_substream *substream,
case 48000:
case 96000:
pll_out = DA7213_PLL_FREQ_OUT_98304000;
return 0;
break;
case 44100:
case 88200:
pll_out = DA7213_PLL_FREQ_OUT_90316800;
return 0;
break;
default:
dev_err(rtd->dev,"Unsupported samplerate %d\n", samplerate);
return -EINVAL;
}

return snd_soc_dai_set_pll(codec_dai, 0, DA7213_SYSCLK_PLL, 0, pll_out);
}

static const struct snd_soc_ops snd_rpi_iqaudio_codec_ops = {
Expand Down

0 comments on commit 8a6f407

Please sign in to comment.