Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: simple card: Add mclk-fs property in dai-link

Add mclk-fs ratio property per dai-link sub node. This will
allow to manage several codecs with different ratio.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Arnaud Pouliquen and committed by
Mark Brown
85a4bfd8 e0ae225b

+20 -4
+5 -1
Documentation/devicetree/bindings/sound/simple-card.txt
··· 16 16 connection's sink, the second being the connection's 17 17 source. 18 18 - simple-audio-card,mclk-fs : Multiplication factor between stream rate and codec 19 - mclk. 19 + mclk. When defined, mclk-fs property defined in 20 + dai-link sub nodes are ignored. 20 21 - simple-audio-card,hp-det-gpio : Reference to GPIO that signals when 21 22 headphones are attached. 22 23 - simple-audio-card,mic-det-gpio : Reference to GPIO that signals when ··· 56 55 dai-link uses bit clock inversion. 57 56 - frame-inversion : bool property. Add this if the 58 57 dai-link uses frame clock inversion. 58 + - mclk-fs : Multiplication factor between stream 59 + rate and codec mclk, applied only for 60 + the dai-link. 59 61 60 62 For backward compatibility the frame-master and bitclock-master 61 63 properties can be used as booleans in codec subnode to indicate if the
+15 -3
sound/soc/generic/simple-card.c
··· 26 26 struct simple_dai_props { 27 27 struct asoc_simple_dai cpu_dai; 28 28 struct asoc_simple_dai codec_dai; 29 + unsigned int mclk_fs; 29 30 } *dai_props; 30 31 unsigned int mclk_fs; 31 32 int gpio_hp_det; ··· 77 76 struct snd_soc_pcm_runtime *rtd = substream->private_data; 78 77 struct snd_soc_dai *codec_dai = rtd->codec_dai; 79 78 struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); 80 - unsigned int mclk; 79 + struct simple_dai_props *dai_props = 80 + &priv->dai_props[rtd - rtd->card->rtd]; 81 + unsigned int mclk, mclk_fs = 0; 81 82 int ret = 0; 82 83 83 - if (priv->mclk_fs) { 84 - mclk = params_rate(params) * priv->mclk_fs; 84 + if (priv->mclk_fs) 85 + mclk_fs = priv->mclk_fs; 86 + else if (dai_props->mclk_fs) 87 + mclk_fs = dai_props->mclk_fs; 88 + 89 + if (mclk_fs) { 90 + mclk = params_rate(params) * mclk_fs; 85 91 ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, 86 92 SND_SOC_CLOCK_IN); 87 93 } ··· 321 313 char prop[128]; 322 314 char *prefix = ""; 323 315 int ret, cpu_args; 316 + u32 val; 324 317 325 318 /* For single DAI link & old style of DT node */ 326 319 if (is_top_level_node) ··· 346 337 codec, prefix, idx); 347 338 if (ret < 0) 348 339 goto dai_link_of_err; 340 + 341 + if (!of_property_read_u32(node, "mclk-fs", &val)) 342 + dai_props->mclk_fs = val; 349 343 350 344 ret = asoc_simple_card_sub_parse_of(cpu, &dai_props->cpu_dai, 351 345 &dai_link->cpu_of_node,