Commit 910fdcab authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-core: add .num_platform for dai_link

Current snd_soc_dai_link is starting to use snd_soc_dai_link_component
(= modern) style for Platform, but it is still assuming single Platform
so far. We will need to have multi Platform support in the not far
future.

Currently only simple card is using it as sound card driver,
and other drivers are converted to it from legacy style by
snd_soc_init_platform().
To avoid future problem of multi Platform support, let's add
num_platforms before it is too late.

In the same time, to make it same naming mothed, "platform" should
be "platforms". This patch fixup it too.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 62bc79d3
...@@ -75,7 +75,7 @@ void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai); ...@@ -75,7 +75,7 @@ void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai);
&dai_link->codec_dai_name, \ &dai_link->codec_dai_name, \
list_name, cells_name, NULL) list_name, cells_name, NULL)
#define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name) \ #define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name) \
asoc_simple_card_parse_dai(node, dai_link->platform, \ asoc_simple_card_parse_dai(node, dai_link->platforms, \
&dai_link->platform_of_node, \ &dai_link->platform_of_node, \
NULL, list_name, cells_name, NULL) NULL, list_name, cells_name, NULL)
int asoc_simple_card_parse_dai(struct device_node *node, int asoc_simple_card_parse_dai(struct device_node *node,
......
...@@ -961,7 +961,8 @@ struct snd_soc_dai_link { ...@@ -961,7 +961,8 @@ struct snd_soc_dai_link {
*/ */
const char *platform_name; const char *platform_name;
struct device_node *platform_of_node; struct device_node *platform_of_node;
struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link_component *platforms;
unsigned int num_platforms;
int id; /* optional ID for machine driver link identification */ int id; /* optional ID for machine driver link identification */
......
...@@ -26,7 +26,7 @@ struct graph_priv { ...@@ -26,7 +26,7 @@ struct graph_priv {
struct asoc_simple_dai *cpu_dai; struct asoc_simple_dai *cpu_dai;
struct asoc_simple_dai *codec_dai; struct asoc_simple_dai *codec_dai;
struct snd_soc_dai_link_component codecs; /* single codec */ struct snd_soc_dai_link_component codecs; /* single codec */
struct snd_soc_dai_link_component platform; struct snd_soc_dai_link_component platforms;
struct asoc_simple_card_data adata; struct asoc_simple_card_data adata;
struct snd_soc_codec_conf *codec_conf; struct snd_soc_codec_conf *codec_conf;
unsigned int mclk_fs; unsigned int mclk_fs;
...@@ -687,7 +687,8 @@ static int graph_probe(struct platform_device *pdev) ...@@ -687,7 +687,8 @@ static int graph_probe(struct platform_device *pdev)
for (i = 0; i < li.link; i++) { for (i = 0; i < li.link; i++) {
dai_link[i].codecs = &dai_props[i].codecs; dai_link[i].codecs = &dai_props[i].codecs;
dai_link[i].num_codecs = 1; dai_link[i].num_codecs = 1;
dai_link[i].platform = &dai_props[i].platform; dai_link[i].platforms = &dai_props[i].platforms;
dai_link[i].num_platforms = 1;
} }
priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW); priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW);
......
...@@ -397,8 +397,8 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_init_dai); ...@@ -397,8 +397,8 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_init_dai);
int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link) int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link)
{ {
/* Assumes platform == cpu */ /* Assumes platform == cpu */
if (!dai_link->platform->of_node) if (!dai_link->platforms->of_node)
dai_link->platform->of_node = dai_link->cpu_of_node; dai_link->platforms->of_node = dai_link->cpu_of_node;
return 0; return 0;
......
...@@ -21,7 +21,7 @@ struct simple_priv { ...@@ -21,7 +21,7 @@ struct simple_priv {
struct asoc_simple_dai *cpu_dai; struct asoc_simple_dai *cpu_dai;
struct asoc_simple_dai *codec_dai; struct asoc_simple_dai *codec_dai;
struct snd_soc_dai_link_component codecs; /* single codec */ struct snd_soc_dai_link_component codecs; /* single codec */
struct snd_soc_dai_link_component platform; struct snd_soc_dai_link_component platforms;
struct asoc_simple_card_data adata; struct asoc_simple_card_data adata;
struct snd_soc_codec_conf *codec_conf; struct snd_soc_codec_conf *codec_conf;
unsigned int mclk_fs; unsigned int mclk_fs;
...@@ -732,7 +732,8 @@ static int simple_probe(struct platform_device *pdev) ...@@ -732,7 +732,8 @@ static int simple_probe(struct platform_device *pdev)
for (i = 0; i < li.link; i++) { for (i = 0; i < li.link; i++) {
dai_link[i].codecs = &dai_props[i].codecs; dai_link[i].codecs = &dai_props[i].codecs;
dai_link[i].num_codecs = 1; dai_link[i].num_codecs = 1;
dai_link[i].platform = &dai_props[i].platform; dai_link[i].platforms = &dai_props[i].platforms;
dai_link[i].num_platforms = 1;
} }
priv->dai_props = dai_props; priv->dai_props = dai_props;
...@@ -782,7 +783,7 @@ static int simple_probe(struct platform_device *pdev) ...@@ -782,7 +783,7 @@ static int simple_probe(struct platform_device *pdev)
codecs->name = cinfo->codec; codecs->name = cinfo->codec;
codecs->dai_name = cinfo->codec_dai.name; codecs->dai_name = cinfo->codec_dai.name;
platform = dai_link->platform; platform = dai_link->platforms;
platform->name = cinfo->platform; platform->name = cinfo->platform;
card->name = (cinfo->card) ? cinfo->card : cinfo->name; card->name = (cinfo->card) ? cinfo->card : cinfo->name;
......
...@@ -915,7 +915,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, ...@@ -915,7 +915,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
/* find one from the set of registered platforms */ /* find one from the set of registered platforms */
for_each_component(component) { for_each_component(component) {
if (!snd_soc_is_matching_component(dai_link->platform, if (!snd_soc_is_matching_component(dai_link->platforms,
component)) component))
continue; continue;
...@@ -1026,7 +1026,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card) ...@@ -1026,7 +1026,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card)
static int snd_soc_init_platform(struct snd_soc_card *card, static int snd_soc_init_platform(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_link) struct snd_soc_dai_link *dai_link)
{ {
struct snd_soc_dai_link_component *platform = dai_link->platform; struct snd_soc_dai_link_component *platform = dai_link->platforms;
/* /*
* REMOVE ME * REMOVE ME
...@@ -1046,7 +1046,8 @@ static int snd_soc_init_platform(struct snd_soc_card *card, ...@@ -1046,7 +1046,8 @@ static int snd_soc_init_platform(struct snd_soc_card *card,
if (!platform) if (!platform)
return -ENOMEM; return -ENOMEM;
dai_link->platform = platform; dai_link->platforms = platform;
dai_link->num_platforms = 1;
dai_link->legacy_platform = 1; dai_link->legacy_platform = 1;
platform->name = dai_link->platform_name; platform->name = dai_link->platform_name;
platform->of_node = dai_link->platform_of_node; platform->of_node = dai_link->platform_of_node;
...@@ -1136,11 +1137,19 @@ static int soc_init_dai_link(struct snd_soc_card *card, ...@@ -1136,11 +1137,19 @@ static int soc_init_dai_link(struct snd_soc_card *card,
} }
} }
/* FIXME */
if (link->num_platforms > 1) {
dev_err(card->dev,
"ASoC: multi platform is not yet supported %s\n",
link->name);
return -EINVAL;
}
/* /*
* Platform may be specified by either name or OF node, but * Platform may be specified by either name or OF node, but
* can be left unspecified, and a dummy platform will be used. * can be left unspecified, and a dummy platform will be used.
*/ */
if (link->platform->name && link->platform->of_node) { if (link->platforms->name && link->platforms->of_node) {
dev_err(card->dev, dev_err(card->dev,
"ASoC: Both platform name/of_node are set for %s\n", "ASoC: Both platform name/of_node are set for %s\n",
link->name); link->name);
...@@ -1151,8 +1160,8 @@ static int soc_init_dai_link(struct snd_soc_card *card, ...@@ -1151,8 +1160,8 @@ static int soc_init_dai_link(struct snd_soc_card *card,
* Defer card registartion if platform dai component is not added to * Defer card registartion if platform dai component is not added to
* component list. * component list.
*/ */
if ((link->platform->of_node || link->platform->name) && if ((link->platforms->of_node || link->platforms->name) &&
!soc_find_component(link->platform->of_node, link->platform->name)) !soc_find_component(link->platforms->of_node, link->platforms->name))
return -EPROBE_DEFER; return -EPROBE_DEFER;
/* /*
...@@ -1956,7 +1965,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card) ...@@ -1956,7 +1965,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)
dev_err(card->dev, "init platform error"); dev_err(card->dev, "init platform error");
continue; continue;
} }
dai_link->platform->name = component->name; dai_link->platforms->name = component->name;
/* convert non BE into BE */ /* convert non BE into BE */
dai_link->no_pcm = 1; dai_link->no_pcm = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment