ASoC: soc-core: support dai_link with platforms_num != 1
Add support platforms_num != 1 in dai_link. Initially, the main purpose of this change was to make the platform optional in the dai_link, instead of inserting the dummy platform driver. This particular case had just been solved by Kuninori Morimoto with commit 1d7689892878 ("ASoC: soc-core: allow no Platform on dai_link"). However, this change may still be useful for those who need multiple platform components on a single dai_link (it solves one of the FIXME note in soc-core) Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
af18b13fed
commit
3461473998
@ -997,6 +997,12 @@ struct snd_soc_dai_link {
|
|||||||
((i) < link->num_codecs) && ((codec) = &link->codecs[i]); \
|
((i) < link->num_codecs) && ((codec) = &link->codecs[i]); \
|
||||||
(i)++)
|
(i)++)
|
||||||
|
|
||||||
|
#define for_each_link_platforms(link, i, platform) \
|
||||||
|
for ((i) = 0; \
|
||||||
|
((i) < link->num_platforms) && \
|
||||||
|
((platform) = &link->platforms[i]); \
|
||||||
|
(i)++)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sample 1 : Single CPU/Codec/Platform
|
* Sample 1 : Single CPU/Codec/Platform
|
||||||
*
|
*
|
||||||
|
@ -896,7 +896,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
|
|||||||
struct snd_soc_dai_link *dai_link)
|
struct snd_soc_dai_link *dai_link)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *rtd;
|
struct snd_soc_pcm_runtime *rtd;
|
||||||
struct snd_soc_dai_link_component *codecs;
|
struct snd_soc_dai_link_component *codec, *platform;
|
||||||
struct snd_soc_component *component;
|
struct snd_soc_component *component;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -926,13 +926,14 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
|
|||||||
|
|
||||||
/* Find CODEC from registered CODECs */
|
/* Find CODEC from registered CODECs */
|
||||||
rtd->num_codecs = dai_link->num_codecs;
|
rtd->num_codecs = dai_link->num_codecs;
|
||||||
for_each_link_codecs(dai_link, i, codecs) {
|
for_each_link_codecs(dai_link, i, codec) {
|
||||||
rtd->codec_dais[i] = snd_soc_find_dai(codecs);
|
rtd->codec_dais[i] = snd_soc_find_dai(codec);
|
||||||
if (!rtd->codec_dais[i]) {
|
if (!rtd->codec_dais[i]) {
|
||||||
dev_info(card->dev, "ASoC: CODEC DAI %s not registered\n",
|
dev_info(card->dev, "ASoC: CODEC DAI %s not registered\n",
|
||||||
codecs->dai_name);
|
codec->dai_name);
|
||||||
goto _err_defer;
|
goto _err_defer;
|
||||||
}
|
}
|
||||||
|
|
||||||
snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
|
snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -940,12 +941,13 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
|
|||||||
rtd->codec_dai = rtd->codec_dais[0];
|
rtd->codec_dai = rtd->codec_dais[0];
|
||||||
|
|
||||||
/* Find PLATFORM from registered PLATFORMs */
|
/* Find PLATFORM from registered PLATFORMs */
|
||||||
for_each_component(component) {
|
for_each_link_platforms(dai_link, i, platform) {
|
||||||
if (!snd_soc_is_matching_component(dai_link->platforms,
|
for_each_component(component) {
|
||||||
component))
|
if (!snd_soc_is_matching_component(platform, component))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
snd_soc_rtdcom_add(rtd, component);
|
snd_soc_rtdcom_add(rtd, component);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
soc_add_pcm_runtime(card, rtd);
|
soc_add_pcm_runtime(card, rtd);
|
||||||
@ -1058,15 +1060,14 @@ static int soc_init_dai_link(struct snd_soc_card *card,
|
|||||||
struct snd_soc_dai_link *link)
|
struct snd_soc_dai_link *link)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct snd_soc_dai_link_component *codec;
|
struct snd_soc_dai_link_component *codec, *platform;
|
||||||
|
|
||||||
for_each_link_codecs(link, i, codec) {
|
for_each_link_codecs(link, i, codec) {
|
||||||
/*
|
/*
|
||||||
* Codec must be specified by 1 of name or OF node,
|
* Codec must be specified by 1 of name or OF node,
|
||||||
* not both or neither.
|
* not both or neither.
|
||||||
*/
|
*/
|
||||||
if (!!codec->name ==
|
if (!!codec->name == !!codec->of_node) {
|
||||||
!!codec->of_node) {
|
|
||||||
dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n",
|
dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n",
|
||||||
link->name);
|
link->name);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -1087,36 +1088,24 @@ static int soc_init_dai_link(struct snd_soc_card *card,
|
|||||||
return -EPROBE_DEFER;
|
return -EPROBE_DEFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
for_each_link_platforms(link, i, platform) {
|
||||||
* Platform may be specified by either name or OF node,
|
/*
|
||||||
* or no Platform.
|
* Platform may be specified by either name or OF node, but it
|
||||||
*
|
* can be left unspecified, then no components will be inserted
|
||||||
* FIXME
|
* in the rtdcom list
|
||||||
*
|
*/
|
||||||
* We need multi-platform support
|
if (!!platform->name == !!platform->of_node) {
|
||||||
*/
|
|
||||||
if (link->num_platforms > 0) {
|
|
||||||
|
|
||||||
if (link->num_platforms > 1) {
|
|
||||||
dev_err(card->dev,
|
dev_err(card->dev,
|
||||||
"ASoC: multi platform is not yet supported %s\n",
|
"ASoC: Neither/both platform name/of_node are set for %s\n",
|
||||||
link->name);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (link->platforms->name && link->platforms->of_node) {
|
|
||||||
dev_err(card->dev,
|
|
||||||
"ASoC: Both platform name/of_node are set for %s\n",
|
|
||||||
link->name);
|
link->name);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defer card registartion if platform dai component is not
|
* Defer card registration if platform component is not added to
|
||||||
* added to component list.
|
* component list.
|
||||||
*/
|
*/
|
||||||
if ((link->platforms->of_node || link->platforms->name) &&
|
if (!soc_find_component(platform))
|
||||||
!soc_find_component(link->platforms))
|
|
||||||
return -EPROBE_DEFER;
|
return -EPROBE_DEFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user