diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2018-12-13 21:35:15 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-12-14 06:48:27 -0500 |
commit | 79e834914d1fa2d078c586094ad347cc05aa428c (patch) | |
tree | 286bfdecc6ce6c5883180b98fd5033738b43ba66 /sound | |
parent | da215354eb55c382d3d5c426ea0e9aa7ef7c10e1 (diff) |
ASoC: simple-card: tidyup mclk-fs method
Current simple-card is handling "mclk-fs" by many way.
But, it is not useful and readable.
We want to do is that allow having mclk-fs everywere.
This patch support it.
It will be overwrote if lower node has it.
sound {
simple-audio-card,mclk-fs = <xxx>; // for initial
simple-audio-card,dai-link {
mclk-fs = <xxx>; // overwrite
cpu {
mclk-fs = <xxx>; // overwrite
};
codec {
mclk-fs = <xxx>; // overwrite
};
};
};
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/generic/simple-card.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index c93f2e7dec4b..8593d51e0c6c 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
@@ -26,7 +26,6 @@ struct simple_card_data { | |||
26 | struct snd_soc_codec_conf *codec_conf; | 26 | struct snd_soc_codec_conf *codec_conf; |
27 | unsigned int mclk_fs; | 27 | unsigned int mclk_fs; |
28 | } *dai_props; | 28 | } *dai_props; |
29 | unsigned int mclk_fs; | ||
30 | struct asoc_simple_jack hp_jack; | 29 | struct asoc_simple_jack hp_jack; |
31 | struct asoc_simple_jack mic_jack; | 30 | struct asoc_simple_jack mic_jack; |
32 | struct snd_soc_dai_link *dai_link; | 31 | struct snd_soc_dai_link *dai_link; |
@@ -102,9 +101,7 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, | |||
102 | unsigned int mclk, mclk_fs = 0; | 101 | unsigned int mclk, mclk_fs = 0; |
103 | int ret = 0; | 102 | int ret = 0; |
104 | 103 | ||
105 | if (priv->mclk_fs) | 104 | if (dai_props->mclk_fs) |
106 | mclk_fs = priv->mclk_fs; | ||
107 | else if (dai_props->mclk_fs) | ||
108 | mclk_fs = dai_props->mclk_fs; | 105 | mclk_fs = dai_props->mclk_fs; |
109 | 106 | ||
110 | if (mclk_fs) { | 107 | if (mclk_fs) { |
@@ -172,7 +169,8 @@ static int asoc_simple_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, | |||
172 | return 0; | 169 | return 0; |
173 | } | 170 | } |
174 | 171 | ||
175 | static int asoc_simple_card_dai_link_of_dpcm(struct device_node *node, | 172 | static int asoc_simple_card_dai_link_of_dpcm(struct device_node *top, |
173 | struct device_node *node, | ||
176 | struct device_node *np, | 174 | struct device_node *np, |
177 | struct device_node *codec, | 175 | struct device_node *codec, |
178 | struct simple_card_data *priv, | 176 | struct simple_card_data *priv, |
@@ -185,6 +183,7 @@ static int asoc_simple_card_dai_link_of_dpcm(struct device_node *node, | |||
185 | struct simple_dai_props *dai_props = simple_priv_to_props(priv, link_idx); | 183 | struct simple_dai_props *dai_props = simple_priv_to_props(priv, link_idx); |
186 | struct snd_soc_card *card = simple_priv_to_card(priv); | 184 | struct snd_soc_card *card = simple_priv_to_card(priv); |
187 | struct asoc_simple_dai *dai; | 185 | struct asoc_simple_dai *dai; |
186 | char prop[128]; | ||
188 | char *prefix = ""; | 187 | char *prefix = ""; |
189 | int ret; | 188 | int ret; |
190 | 189 | ||
@@ -278,7 +277,10 @@ static int asoc_simple_card_dai_link_of_dpcm(struct device_node *node, | |||
278 | if (ret < 0) | 277 | if (ret < 0) |
279 | return ret; | 278 | return ret; |
280 | 279 | ||
281 | of_property_read_u32(np, "mclk-fs", &dai_props->mclk_fs); | 280 | snprintf(prop, sizeof(prop), "%smclk-fs", prefix); |
281 | of_property_read_u32(top, PREFIX "mclk-fs", &dai_props->mclk_fs); | ||
282 | of_property_read_u32(node, prop, &dai_props->mclk_fs); | ||
283 | of_property_read_u32(np, prop, &dai_props->mclk_fs); | ||
282 | 284 | ||
283 | ret = asoc_simple_card_parse_daifmt(dev, node, codec, | 285 | ret = asoc_simple_card_parse_daifmt(dev, node, codec, |
284 | prefix, &dai_link->dai_fmt); | 286 | prefix, &dai_link->dai_fmt); |
@@ -293,7 +295,8 @@ static int asoc_simple_card_dai_link_of_dpcm(struct device_node *node, | |||
293 | return 0; | 295 | return 0; |
294 | } | 296 | } |
295 | 297 | ||
296 | static int asoc_simple_card_dai_link_of(struct device_node *node, | 298 | static int asoc_simple_card_dai_link_of(struct device_node *top, |
299 | struct device_node *node, | ||
297 | struct simple_card_data *priv, | 300 | struct simple_card_data *priv, |
298 | int *dai_idx, int link_idx, | 301 | int *dai_idx, int link_idx, |
299 | bool is_top_level_node) | 302 | bool is_top_level_node) |
@@ -345,7 +348,11 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, | |||
345 | if (ret < 0) | 348 | if (ret < 0) |
346 | goto dai_link_of_err; | 349 | goto dai_link_of_err; |
347 | 350 | ||
348 | of_property_read_u32(node, "mclk-fs", &dai_props->mclk_fs); | 351 | snprintf(prop, sizeof(prop), "%smclk-fs", prefix); |
352 | of_property_read_u32(top, PREFIX "mclk-fs", &dai_props->mclk_fs); | ||
353 | of_property_read_u32(node, prop, &dai_props->mclk_fs); | ||
354 | of_property_read_u32(cpu, prop, &dai_props->mclk_fs); | ||
355 | of_property_read_u32(codec, prop, &dai_props->mclk_fs); | ||
349 | 356 | ||
350 | ret = asoc_simple_card_parse_cpu(cpu, dai_link, | 357 | ret = asoc_simple_card_parse_cpu(cpu, dai_link, |
351 | DAI, CELL, &single_cpu); | 358 | DAI, CELL, &single_cpu); |
@@ -453,9 +460,6 @@ static int asoc_simple_card_parse_of(struct simple_card_data *priv) | |||
453 | if (ret < 0) | 460 | if (ret < 0) |
454 | return ret; | 461 | return ret; |
455 | 462 | ||
456 | /* Factor to mclk, used in hw_params() */ | ||
457 | of_property_read_u32(top, PREFIX "mclk-fs", &priv->mclk_fs); | ||
458 | |||
459 | asoc_simple_card_parse_convert(dev, top, PREFIX, &priv->adata); | 463 | asoc_simple_card_parse_convert(dev, top, PREFIX, &priv->adata); |
460 | 464 | ||
461 | /* Single/Muti DAI link(s) & New style of DT node */ | 465 | /* Single/Muti DAI link(s) & New style of DT node */ |
@@ -482,13 +486,13 @@ static int asoc_simple_card_parse_of(struct simple_card_data *priv) | |||
482 | is_fe = (np != codec); | 486 | is_fe = (np != codec); |
483 | 487 | ||
484 | ret = asoc_simple_card_dai_link_of_dpcm( | 488 | ret = asoc_simple_card_dai_link_of_dpcm( |
485 | node, np, codec, priv, | 489 | top, node, np, codec, priv, |
486 | &dai_idx, link_idx++, &conf_idx, | 490 | &dai_idx, link_idx++, &conf_idx, |
487 | is_fe, !loop); | 491 | is_fe, !loop); |
488 | } | 492 | } |
489 | } else { | 493 | } else { |
490 | ret = asoc_simple_card_dai_link_of( | 494 | ret = asoc_simple_card_dai_link_of( |
491 | node, priv, | 495 | top, node, priv, |
492 | &dai_idx, link_idx++, !loop); | 496 | &dai_idx, link_idx++, !loop); |
493 | } | 497 | } |
494 | if (ret < 0) | 498 | if (ret < 0) |