Commit 205eb17e authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: simple-card-utils: share dummy DAI and reduce memory

Current simple-card / audio-graph creates 1xCPU + 1xCodec + 1xPlatform
for all dai_link, but some of them is not needed.
For example Platform is not needed for DPCM BE case.
Moreover, we can share snd-soc-dummy DAI for CPU-dummy / dummy-Codec
in DPCM.

This patch adds dummy DAI and share it when DPCM case,
I beliave it can contribute to reduce memory.

By this patch, CPU-dummy / dummy-CPU are set at asoc_simple_init_priv(),
thus, its settings are no longer needed at DPCM detecting timing
on simple-card / audio-graph.
Moreover, we can remove triky Platform settings code for DPCM BE,
because un-needed Platform is not created.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tuoqod22.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f2138aed
......@@ -62,6 +62,7 @@ struct asoc_simple_priv {
struct snd_soc_dai_link *dai_link;
struct asoc_simple_dai *dais;
struct snd_soc_dai_link_component *dlcs;
struct snd_soc_dai_link_component dummy;
struct snd_soc_codec_conf *codec_conf;
struct gpio_desc *pa_gpio;
const struct snd_soc_ops *ops;
......
......@@ -240,9 +240,6 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
int is_single_links = 0;
/* Codec is dummy */
codecs->of_node = NULL;
codecs->dai_name = "snd-soc-dummy-dai";
codecs->name = "snd-soc-dummy";
/* FE settings */
dai_link->dynamic = 1;
......@@ -281,13 +278,11 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
/* card->num_links includes Codec */
asoc_simple_canonicalize_cpu(dai_link, is_single_links);
asoc_simple_canonicalize_platform(dai_link);
} else {
struct snd_soc_codec_conf *cconf;
/* CPU is dummy */
cpus->of_node = NULL;
cpus->dai_name = "snd-soc-dummy-dai";
cpus->name = "snd-soc-dummy";
/* BE settings */
dai_link->no_pcm = 1;
......@@ -328,8 +323,6 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
graph_parse_convert(dev, ep, &dai_props->adata);
graph_parse_mclk_fs(top, ep, dai_props);
asoc_simple_canonicalize_platform(dai_link);
ret = asoc_simple_parse_tdm(ep, dai);
if (ret)
goto out_put_node;
......@@ -659,15 +652,12 @@ static int graph_count_dpcm(struct asoc_simple_priv *priv,
if (li->cpu) {
li->num[li->link].cpus = 1;
li->num[li->link].codecs = 1;
li->num[li->link].platforms = 1;
li->link++; /* 1xCPU-dummy */
li->dais++; /* 1xCPU */
} else {
li->num[li->link].cpus = 1;
li->num[li->link].codecs = 1;
li->num[li->link].platforms = 1;
li->link++; /* 1xdummy-Codec */
li->conf++; /* 1xdummy-Codec */
......
......@@ -404,13 +404,6 @@ 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->cpus->of_node;
/*
* DPCM BE can be no platform.
* Alloced memory will be waste, but not leak.
*/
if (!dai_link->platforms->of_node)
dai_link->num_platforms = 0;
}
EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_platform);
......@@ -633,6 +626,11 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
return -ENOMEM;
}
/* dummy CPU/Codec */
priv->dummy.of_node = NULL;
priv->dummy.dai_name = "snd-soc-dummy-dai";
priv->dummy.name = "snd-soc-dummy";
priv->dai_props = dai_props;
priv->dai_link = dai_link;
priv->dais = dais;
......@@ -653,6 +651,12 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
dai_link[i].num_cpus = li->num[i].cpus;
dlcs += li->num[i].cpus;
} else {
/* DPCM Be's CPU = dummy */
dai_props[i].cpus =
dai_link[i].cpus = &priv->dummy;
dai_props[i].num.cpus =
dai_link[i].num_cpus = 1;
}
if (li->num[i].codecs) {
......@@ -663,6 +667,12 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
dai_link[i].num_codecs = li->num[i].codecs;
dlcs += li->num[i].codecs;
} else {
/* DPCM Fe's Codec = dummy */
dai_props[i].codecs =
dai_link[i].codecs = &priv->dummy;
dai_props[i].num.codecs =
dai_link[i].num_codecs = 1;
}
if (li->num[i].platforms) {
......@@ -673,6 +683,12 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
dai_link[i].num_platforms = li->num[i].platforms;
dlcs += li->num[i].platforms;
} else {
/* Doesn't have Platform */
dai_props[i].platforms =
dai_link[i].platforms = NULL;
dai_props[i].num.platforms =
dai_link[i].num_platforms = 0;
}
}
......
......@@ -141,9 +141,6 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
int is_single_links = 0;
/* Codec is dummy */
codecs->of_node = NULL;
codecs->dai_name = "snd-soc-dummy-dai";
codecs->name = "snd-soc-dummy";
/* FE settings */
dai_link->dynamic = 1;
......@@ -167,13 +164,11 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
goto out_put_node;
asoc_simple_canonicalize_cpu(dai_link, is_single_links);
asoc_simple_canonicalize_platform(dai_link);
} else {
struct snd_soc_codec_conf *cconf;
/* CPU is dummy */
cpus->of_node = NULL;
cpus->dai_name = "snd-soc-dummy-dai";
cpus->name = "snd-soc-dummy";
/* BE settings */
dai_link->no_pcm = 1;
......@@ -211,8 +206,6 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
simple_parse_convert(dev, np, &dai_props->adata);
simple_parse_mclk_fs(top, np, codec, dai_props, prefix);
asoc_simple_canonicalize_platform(dai_link);
ret = asoc_simple_parse_tdm(np, dai);
if (ret)
goto out_put_node;
......@@ -530,15 +523,12 @@ static int simple_count_dpcm(struct asoc_simple_priv *priv,
if (li->cpu) {
li->num[li->link].cpus = 1;
li->num[li->link].codecs = 1;
li->num[li->link].platforms = 1;
li->link++; /* CPU-dummy */
li->dais++;
} else {
li->num[li->link].cpus = 1;
li->num[li->link].codecs = 1;
li->num[li->link].platforms = 1;
li->link++; /* dummy-Codec */
li->dais++;
......
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