aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaud Pouliquen <arnaud.pouliquen@st.com>2015-06-05 04:19:05 -0400
committerMark Brown <broonie@kernel.org>2015-06-12 07:35:54 -0400
commit85a4bfd895778960dc2d655087ac7ff442b6ab9e (patch)
tree786435d5b7983ec6b24291659fc087a914c87ae1
parente0ae225b7e96e50daaa3ca8d3cd2c944ce48e007 (diff)
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>
-rw-r--r--Documentation/devicetree/bindings/sound/simple-card.txt6
-rw-r--r--sound/soc/generic/simple-card.c18
2 files changed, 20 insertions, 4 deletions
diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index 73bf314f7240..cf3979eb3578 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -16,7 +16,8 @@ Optional properties:
16 connection's sink, the second being the connection's 16 connection's sink, the second being the connection's
17 source. 17 source.
18- simple-audio-card,mclk-fs : Multiplication factor between stream rate and codec 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- simple-audio-card,hp-det-gpio : Reference to GPIO that signals when 21- simple-audio-card,hp-det-gpio : Reference to GPIO that signals when
21 headphones are attached. 22 headphones are attached.
22- simple-audio-card,mic-det-gpio : Reference to GPIO that signals when 23- simple-audio-card,mic-det-gpio : Reference to GPIO that signals when
@@ -55,6 +56,9 @@ Optional dai-link subnode properties:
55 dai-link uses bit clock inversion. 56 dai-link uses bit clock inversion.
56- frame-inversion : bool property. Add this if the 57- frame-inversion : bool property. Add this if the
57 dai-link uses frame clock inversion. 58 dai-link uses frame clock inversion.
59- mclk-fs : Multiplication factor between stream
60 rate and codec mclk, applied only for
61 the dai-link.
58 62
59For backward compatibility the frame-master and bitclock-master 63For backward compatibility the frame-master and bitclock-master
60properties can be used as booleans in codec subnode to indicate if the 64properties can be used as booleans in codec subnode to indicate if the
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index c87e58504a62..d5554939146e 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -26,6 +26,7 @@ struct simple_card_data {
26 struct simple_dai_props { 26 struct simple_dai_props {
27 struct asoc_simple_dai cpu_dai; 27 struct asoc_simple_dai cpu_dai;
28 struct asoc_simple_dai codec_dai; 28 struct asoc_simple_dai codec_dai;
29 unsigned int mclk_fs;
29 } *dai_props; 30 } *dai_props;
30 unsigned int mclk_fs; 31 unsigned int mclk_fs;
31 int gpio_hp_det; 32 int gpio_hp_det;
@@ -76,11 +77,18 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
76 struct snd_soc_pcm_runtime *rtd = substream->private_data; 77 struct snd_soc_pcm_runtime *rtd = substream->private_data;
77 struct snd_soc_dai *codec_dai = rtd->codec_dai; 78 struct snd_soc_dai *codec_dai = rtd->codec_dai;
78 struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); 79 struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
79 unsigned int mclk; 80 struct simple_dai_props *dai_props =
81 &priv->dai_props[rtd - rtd->card->rtd];
82 unsigned int mclk, mclk_fs = 0;
80 int ret = 0; 83 int ret = 0;
81 84
82 if (priv->mclk_fs) { 85 if (priv->mclk_fs)
83 mclk = params_rate(params) * priv->mclk_fs; 86 mclk_fs = priv->mclk_fs;
87 else if (dai_props->mclk_fs)
88 mclk_fs = dai_props->mclk_fs;
89
90 if (mclk_fs) {
91 mclk = params_rate(params) * mclk_fs;
84 ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, 92 ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
85 SND_SOC_CLOCK_IN); 93 SND_SOC_CLOCK_IN);
86 } 94 }
@@ -313,6 +321,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
313 char prop[128]; 321 char prop[128];
314 char *prefix = ""; 322 char *prefix = "";
315 int ret, cpu_args; 323 int ret, cpu_args;
324 u32 val;
316 325
317 /* For single DAI link & old style of DT node */ 326 /* For single DAI link & old style of DT node */
318 if (is_top_level_node) 327 if (is_top_level_node)
@@ -338,6 +347,9 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
338 if (ret < 0) 347 if (ret < 0)
339 goto dai_link_of_err; 348 goto dai_link_of_err;
340 349
350 if (!of_property_read_u32(node, "mclk-fs", &val))
351 dai_props->mclk_fs = val;
352
341 ret = asoc_simple_card_sub_parse_of(cpu, &dai_props->cpu_dai, 353 ret = asoc_simple_card_sub_parse_of(cpu, &dai_props->cpu_dai,
342 &dai_link->cpu_of_node, 354 &dai_link->cpu_of_node,
343 &dai_link->cpu_dai_name, 355 &dai_link->cpu_dai_name,