bcm27xx: update 6.1 patches to latest version
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-6.1 / 950-0816-rpi-sound-cards-Fix-Codec-Zero-rate-switching.patch
1 From b84b8a9ad2046a855a7044b6368def01ddd5de6e Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Fri, 21 Jul 2023 16:50:56 +0100
4 Subject: [PATCH] rpi sound cards: Fix Codec Zero rate switching
5
6 The Raspberry Pi Codec Zero (and IQaudIO Codec) don't notify the DA7213
7 codec when it needs to change PLL frequencies. As a result, audio can
8 be played at the wrong rate - play a 48kHz sound immediately after a
9 44.1kHz sound to see the effect, but in some configurations the codec
10 can lock into the wrong state and always get some rates wrong.
11
12 Add the necessary notification to fix the issue.
13
14 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
15 ---
16 sound/soc/bcm/iqaudio-codec.c | 7 +++++--
17 1 file changed, 5 insertions(+), 2 deletions(-)
18
19 --- a/sound/soc/bcm/iqaudio-codec.c
20 +++ b/sound/soc/bcm/iqaudio-codec.c
21 @@ -143,6 +143,7 @@ static int snd_rpi_iqaudio_codec_hw_para
22 struct snd_pcm_hw_params *params)
23 {
24 struct snd_soc_pcm_runtime *rtd = substream->private_data;
25 + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
26 unsigned int samplerate = params_rate(params);
27
28 switch (samplerate) {
29 @@ -152,15 +153,17 @@ static int snd_rpi_iqaudio_codec_hw_para
30 case 48000:
31 case 96000:
32 pll_out = DA7213_PLL_FREQ_OUT_98304000;
33 - return 0;
34 + break;
35 case 44100:
36 case 88200:
37 pll_out = DA7213_PLL_FREQ_OUT_90316800;
38 - return 0;
39 + break;
40 default:
41 dev_err(rtd->dev,"Unsupported samplerate %d\n", samplerate);
42 return -EINVAL;
43 }
44 +
45 + return snd_soc_dai_set_pll(codec_dai, 0, DA7213_SYSCLK_PLL, 0, pll_out);
46 }
47
48 static const struct snd_soc_ops snd_rpi_iqaudio_codec_ops = {