dcfbb9dd1ad5589652a9ab16830c7c018dd8d432
[openwrt/staging/hauke.git] /
1 From 4ca89eb8570cb86314a5a7b55a15d15f53ce5757 Mon Sep 17 00:00:00 2001
2 From: Johannes Krude <johannes@krude.de>
3 Date: Sat, 16 Nov 2019 12:41:06 +0100
4 Subject: [PATCH] sound/soc: only first codec is master in multicodec
5 setup
6
7 When using multiple codecs, at most one codec should generate the master
8 clock. All codecs except the first are therefore configured for slave
9 mode.
10
11 Signed-off-by: Johannes Krude <johannes@krude.de>
12 ---
13 sound/soc/soc-core.c | 9 ++++++++-
14 1 file changed, 8 insertions(+), 1 deletion(-)
15
16 --- a/sound/soc/soc-core.c
17 +++ b/sound/soc/soc-core.c
18 @@ -1688,8 +1688,15 @@ int snd_soc_runtime_set_dai_fmt(struct s
19
20 for (i = 0; i < rtd->num_codecs; i++) {
21 struct snd_soc_dai *codec_dai = codec_dais[i];
22 + unsigned int codec_dai_fmt = dai_fmt;
23
24 - ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
25 + // there can only be one master when using multiple codecs
26 + if (i && (codec_dai_fmt & SND_SOC_DAIFMT_MASTER_MASK)) {
27 + codec_dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
28 + codec_dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
29 + }
30 +
31 + ret = snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt);
32 if (ret != 0 && ret != -ENOTSUPP) {
33 dev_warn(codec_dai->dev,
34 "ASoC: Failed to set DAI format: %d\n", ret);