Skip to content

Commit b84b8a9

Browse files
committed
rpi sound cards: Fix Codec Zero rate switching
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]>
1 parent 2addf70 commit b84b8a9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sound/soc/bcm/iqaudio-codec.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static int snd_rpi_iqaudio_codec_hw_params(struct snd_pcm_substream *substream,
143143
struct snd_pcm_hw_params *params)
144144
{
145145
struct snd_soc_pcm_runtime *rtd = substream->private_data;
146+
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
146147
unsigned int samplerate = params_rate(params);
147148

148149
switch (samplerate) {
@@ -152,15 +153,17 @@ static int snd_rpi_iqaudio_codec_hw_params(struct snd_pcm_substream *substream,
152153
case 48000:
153154
case 96000:
154155
pll_out = DA7213_PLL_FREQ_OUT_98304000;
155-
return 0;
156+
break;
156157
case 44100:
157158
case 88200:
158159
pll_out = DA7213_PLL_FREQ_OUT_90316800;
159-
return 0;
160+
break;
160161
default:
161162
dev_err(rtd->dev,"Unsupported samplerate %d\n", samplerate);
162163
return -EINVAL;
163164
}
165+
166+
return snd_soc_dai_set_pll(codec_dai, 0, DA7213_SYSCLK_PLL, 0, pll_out);
164167
}
165168

166169
static const struct snd_soc_ops snd_rpi_iqaudio_codec_ops = {

0 commit comments

Comments
 (0)