aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/generic
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/generic')
-rw-r--r--sound/soc/generic/audio-graph-card.c30
-rw-r--r--sound/soc/generic/simple-card-utils.c34
-rw-r--r--sound/soc/generic/simple-card.c47
3 files changed, 43 insertions, 68 deletions
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index ec7e673ba475..e438011f5e45 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -111,29 +111,14 @@ static int graph_get_dai_id(struct device_node *ep)
static int asoc_simple_parse_dai(struct device_node *ep,
struct snd_soc_dai_link_component *dlc,
- struct device_node **dai_of_node,
- const char **dai_name,
int *is_single_link)
{
struct device_node *node;
struct of_phandle_args args;
int ret;
- /*
- * Use snd_soc_dai_link_component instead of legacy style.
- * It is only for codec, but cpu will be supported in the future.
- * see
- * soc-core.c :: snd_soc_init_multicodec()
- */
- if (dlc) {
- dai_name = &dlc->dai_name;
- dai_of_node = &dlc->of_node;
- }
-
if (!ep)
return 0;
- if (!dai_name)
- return 0;
node = of_graph_get_port_parent(ep);
@@ -142,11 +127,11 @@ static int asoc_simple_parse_dai(struct device_node *ep,
args.args[0] = graph_get_dai_id(ep);
args.args_count = (of_graph_get_endpoint_count(node) > 1);
- ret = snd_soc_get_dai_name(&args, dai_name);
+ ret = snd_soc_get_dai_name(&args, &dlc->dai_name);
if (ret < 0)
return ret;
- *dai_of_node = node;
+ dlc->of_node = node;
if (is_single_link)
*is_single_link = of_graph_get_endpoint_count(node) == 1;
@@ -207,6 +192,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
struct device_node *ports;
struct device_node *node;
struct asoc_simple_dai *dai;
+ struct snd_soc_dai_link_component *cpus = dai_link->cpus;
struct snd_soc_dai_link_component *codecs = dai_link->codecs;
int ret;
@@ -251,7 +237,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
ret = asoc_simple_set_dailink_name(dev, dai_link,
"fe.%s",
- dai_link->cpu_dai_name);
+ cpus->dai_name);
if (ret < 0)
return ret;
@@ -261,9 +247,9 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
struct snd_soc_codec_conf *cconf;
/* FE is dummy */
- dai_link->cpu_of_node = NULL;
- dai_link->cpu_dai_name = "snd-soc-dummy-dai";
- dai_link->cpu_name = "snd-soc-dummy";
+ cpus->of_node = NULL;
+ cpus->dai_name = "snd-soc-dummy-dai";
+ cpus->name = "snd-soc-dummy";
/* BE settings */
dai_link->no_pcm = 1;
@@ -383,7 +369,7 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv,
ret = asoc_simple_set_dailink_name(dev, dai_link,
"%s-%s",
- dai_link->cpu_dai_name,
+ dai_link->cpus->dai_name,
dai_link->codecs->dai_name);
if (ret < 0)
return ret;
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index f4c6375d11c7..3cf5cb21ea52 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -159,24 +159,13 @@ static void asoc_simple_clk_disable(struct asoc_simple_dai *dai)
int asoc_simple_parse_clk(struct device *dev,
struct device_node *node,
- struct device_node *dai_of_node,
struct asoc_simple_dai *simple_dai,
- const char *dai_name,
struct snd_soc_dai_link_component *dlc)
{
struct clk *clk;
u32 val;
/*
- * Use snd_soc_dai_link_component instead of legacy style.
- * It is only for codec, but cpu will be supported in the future.
- * see
- * soc-core.c :: snd_soc_init_multicodec()
- */
- if (dlc)
- dai_of_node = dlc->of_node;
-
- /*
* Parse dai->sysclk come from "clocks = <&xxx>"
* (if system has common clock)
* or "system-clock-frequency = <xxx>"
@@ -190,7 +179,7 @@ int asoc_simple_parse_clk(struct device *dev,
} else if (!of_property_read_u32(node, "system-clock-frequency", &val)) {
simple_dai->sysclk = val;
} else {
- clk = devm_get_clk_from_child(dev, dai_of_node, NULL);
+ clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
if (!IS_ERR(clk))
simple_dai->sysclk = clk_get_rate(clk);
}
@@ -357,9 +346,18 @@ EXPORT_SYMBOL_GPL(asoc_simple_dai_init);
void asoc_simple_canonicalize_platform(struct snd_soc_dai_link *dai_link)
{
- /* Assumes platform == cpu */
- if (!dai_link->platforms->of_node)
- dai_link->platforms->of_node = dai_link->cpu_of_node;
+ /*
+ * no Platform
+ *
+ * It will be waste of memory, but not be memory leak.
+ * see
+ * asoc_simple_init_priv()
+ * asoc_simple_priv
+ */
+ if (!dai_link->platforms->of_node) {
+ dai_link->platforms = NULL;
+ dai_link->num_platforms = 0;
+ }
}
EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_platform);
@@ -376,7 +374,7 @@ void asoc_simple_canonicalize_cpu(struct snd_soc_dai_link *dai_link,
* fmt_multiple_name()
*/
if (is_single_links)
- dai_link->cpu_dai_name = NULL;
+ dai_link->cpus->dai_name = NULL;
}
EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_cpu);
@@ -386,7 +384,7 @@ int asoc_simple_clean_reference(struct snd_soc_card *card)
int i;
for_each_card_prelinks(card, i, dai_link) {
- of_node_put(dai_link->cpu_of_node);
+ of_node_put(dai_link->cpus->of_node);
of_node_put(dai_link->codecs->of_node);
}
return 0;
@@ -576,6 +574,8 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
* simple-card-utils.c :: asoc_simple_canonicalize_platform()
*/
for (i = 0; i < li->link; i++) {
+ dai_link[i].cpus = &dai_props[i].cpus;
+ dai_link[i].num_cpus = 1;
dai_link[i].codecs = &dai_props[i].codecs;
dai_link[i].num_codecs = 1;
dai_link[i].platforms = &dai_props[i].platforms;
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 9b568f578bcd..e5cde0d5e63c 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -30,8 +30,6 @@ static const struct snd_soc_ops simple_ops = {
static int asoc_simple_parse_dai(struct device_node *node,
struct snd_soc_dai_link_component *dlc,
- struct device_node **dai_of_node,
- const char **dai_name,
int *is_single_link)
{
struct of_phandle_args args;
@@ -41,17 +39,6 @@ static int asoc_simple_parse_dai(struct device_node *node,
return 0;
/*
- * Use snd_soc_dai_link_component instead of legacy style.
- * It is only for codec, but cpu will be supported in the future.
- * see
- * soc-core.c :: snd_soc_init_multicodec()
- */
- if (dlc) {
- dai_name = &dlc->dai_name;
- dai_of_node = &dlc->of_node;
- }
-
- /*
* Get node via "sound-dai = <&phandle port>"
* it will be used as xxx_of_node on soc_bind_dai_link()
*/
@@ -60,13 +47,11 @@ static int asoc_simple_parse_dai(struct device_node *node,
return ret;
/* Get dai->name */
- if (dai_name) {
- ret = snd_soc_of_get_dai_name(node, dai_name);
- if (ret < 0)
- return ret;
- }
+ ret = snd_soc_of_get_dai_name(node, &dlc->dai_name);
+ if (ret < 0)
+ return ret;
- *dai_of_node = args.np;
+ dlc->of_node = args.np;
if (is_single_link)
*is_single_link = !args.args_count;
@@ -119,6 +104,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link);
struct asoc_simple_dai *dai;
+ struct snd_soc_dai_link_component *cpus = dai_link->cpus;
struct snd_soc_dai_link_component *codecs = dai_link->codecs;
struct device_node *top = dev->of_node;
struct device_node *node = of_get_parent(np);
@@ -169,7 +155,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
ret = asoc_simple_set_dailink_name(dev, dai_link,
"fe.%s",
- dai_link->cpu_dai_name);
+ cpus->dai_name);
if (ret < 0)
return ret;
@@ -178,9 +164,9 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
struct snd_soc_codec_conf *cconf;
/* FE is dummy */
- dai_link->cpu_of_node = NULL;
- dai_link->cpu_dai_name = "snd-soc-dummy-dai";
- dai_link->cpu_name = "snd-soc-dummy";
+ cpus->of_node = NULL;
+ cpus->dai_name = "snd-soc-dummy-dai";
+ cpus->name = "snd-soc-dummy";
/* BE settings */
dai_link->no_pcm = 1;
@@ -320,7 +306,7 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,
ret = asoc_simple_set_dailink_name(dev, dai_link,
"%s-%s",
- dai_link->cpu_dai_name,
+ dai_link->cpus->dai_name,
dai_link->codecs->dai_name);
if (ret < 0)
goto dai_link_of_err;
@@ -607,7 +593,7 @@ static int simple_soc_probe(struct snd_soc_card *card)
return 0;
}
-static int simple_probe(struct platform_device *pdev)
+static int asoc_simple_probe(struct platform_device *pdev)
{
struct asoc_simple_priv *priv;
struct device *dev = &pdev->dev;
@@ -646,6 +632,7 @@ static int simple_probe(struct platform_device *pdev)
} else {
struct asoc_simple_card_info *cinfo;
+ struct snd_soc_dai_link_component *cpus;
struct snd_soc_dai_link_component *codecs;
struct snd_soc_dai_link_component *platform;
struct snd_soc_dai_link *dai_link = priv->dai_link;
@@ -671,6 +658,9 @@ static int simple_probe(struct platform_device *pdev)
dai_props->cpu_dai = &priv->dais[dai_idx++];
dai_props->codec_dai = &priv->dais[dai_idx++];
+ cpus = dai_link->cpus;
+ cpus->dai_name = cinfo->cpu_dai.name;
+
codecs = dai_link->codecs;
codecs->name = cinfo->codec;
codecs->dai_name = cinfo->codec_dai.name;
@@ -681,7 +671,6 @@ static int simple_probe(struct platform_device *pdev)
card->name = (cinfo->card) ? cinfo->card : cinfo->name;
dai_link->name = cinfo->name;
dai_link->stream_name = cinfo->name;
- dai_link->cpu_dai_name = cinfo->cpu_dai.name;
dai_link->dai_fmt = cinfo->daifmt;
dai_link->init = asoc_simple_dai_init;
memcpy(dai_props->cpu_dai, &cinfo->cpu_dai,
@@ -705,7 +694,7 @@ err:
return ret;
}
-static int simple_remove(struct platform_device *pdev)
+static int asoc_simple_remove(struct platform_device *pdev)
{
struct snd_soc_card *card = platform_get_drvdata(pdev);
@@ -726,8 +715,8 @@ static struct platform_driver asoc_simple_card = {
.pm = &snd_soc_pm_ops,
.of_match_table = simple_of_match,
},
- .probe = simple_probe,
- .remove = simple_remove,
+ .probe = asoc_simple_probe,
+ .remove = asoc_simple_remove,
};
module_platform_driver(asoc_simple_card);