ASoC: simple-card-utils: setup dai_props cpu_dai/codec_dai at initial timing

We couldn't setup dai_props cpu_dai/codec_dai at the initial timing,
because "counting DAIs loop" and "detecting DAIs loop" were different.
But we can do it now, because these are using same loops.

This patch setups dai_props cpu_dai/codec_dai at the initial timing.
It can removes triky code from simple-card / audio-graph.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tuocwfa8.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2021-04-12 08:51:59 +09:00 коммит произвёл Mark Brown
Родитель 13a9e21b80
Коммит 59f5cd96e9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 24D68B725D5487D0
3 изменённых файлов: 20 добавлений и 33 удалений

Просмотреть файл

@ -245,8 +245,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
dai_link->dynamic = 1;
dai_link->dpcm_merged_format = 1;
dai =
dai_props->cpu_dai = &priv->dais[li->dais++];
dai = dai_props->cpu_dai;
ret = asoc_simple_parse_cpu(ep, dai_link, &is_single_links);
if (ret)
@ -288,11 +287,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
dai_link->no_pcm = 1;
dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup;
dai =
dai_props->codec_dai = &priv->dais[li->dais++];
cconf =
dai_props->codec_conf = &priv->codec_conf[li->conf++];
dai = dai_props->codec_dai;
cconf = dai_props->codec_conf;
ret = asoc_simple_parse_codec(ep, dai_link);
if (ret < 0)
@ -358,19 +354,14 @@ static int graph_dai_link_of(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 device_node *top = dev->of_node;
struct asoc_simple_dai *cpu_dai;
struct asoc_simple_dai *codec_dai;
struct asoc_simple_dai *cpu_dai = dai_props->cpu_dai;
struct asoc_simple_dai *codec_dai = dai_props->codec_dai;
int ret, single_cpu = 0;
dev_dbg(dev, "link_of (%pOF)\n", cpu_ep);
li->link++;
cpu_dai =
dai_props->cpu_dai = &priv->dais[li->dais++];
codec_dai =
dai_props->codec_dai = &priv->dais[li->dais++];
/* Factor to mclk, used in hw_params() */
graph_parse_mclk_fs(top, cpu_ep, dai_props);
graph_parse_mclk_fs(top, codec_ep, dai_props);

Просмотреть файл

@ -649,8 +649,10 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
dai_link[i].cpus = dlcs;
dai_props[i].num.cpus =
dai_link[i].num_cpus = li->num[i].cpus;
dai_props[i].cpu_dai = dais;
dlcs += li->num[i].cpus;
dais += li->num[i].cpus;
} else {
/* DPCM Be's CPU = dummy */
dai_props[i].cpus =
@ -665,8 +667,16 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
dai_link[i].codecs = dlcs;
dai_props[i].num.codecs =
dai_link[i].num_codecs = li->num[i].codecs;
dai_props[i].codec_dai = dais;
dlcs += li->num[i].codecs;
dais += li->num[i].codecs;
if (!li->num[i].cpus) {
/* DPCM Be's Codec */
dai_props[i].codec_conf = cconf;
cconf += li->num[i].codecs;
}
} else {
/* DPCM Fe's Codec = dummy */
dai_props[i].codecs =

Просмотреть файл

@ -146,8 +146,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
dai_link->dynamic = 1;
dai_link->dpcm_merged_format = 1;
dai =
dai_props->cpu_dai = &priv->dais[li->dais++];
dai = dai_props->cpu_dai;
ret = asoc_simple_parse_cpu(np, dai_link, &is_single_links);
if (ret)
@ -174,11 +173,8 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
dai_link->no_pcm = 1;
dai_link->be_hw_params_fixup = asoc_simple_be_hw_params_fixup;
dai =
dai_props->codec_dai = &priv->dais[li->dais++];
cconf =
dai_props->codec_conf = &priv->codec_conf[li->conf++];
dai = dai_props->codec_dai;
cconf = dai_props->codec_conf;
ret = asoc_simple_parse_codec(np, dai_link);
if (ret < 0)
@ -234,8 +230,8 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,
struct device *dev = simple_priv_to_dev(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 *cpu_dai;
struct asoc_simple_dai *codec_dai;
struct asoc_simple_dai *cpu_dai = dai_props->cpu_dai;
struct asoc_simple_dai *codec_dai = dai_props->codec_dai;
struct device_node *top = dev->of_node;
struct device_node *cpu = NULL;
struct device_node *node = NULL;
@ -257,11 +253,6 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,
snprintf(prop, sizeof(prop), "%splat", prefix);
plat = of_get_child_by_name(node, prop);
cpu_dai =
dai_props->cpu_dai = &priv->dais[li->dais++];
codec_dai =
dai_props->codec_dai = &priv->dais[li->dais++];
ret = asoc_simple_parse_daifmt(dev, node, codec,
prefix, &dai_link->dai_fmt);
if (ret < 0)
@ -670,8 +661,6 @@ static int asoc_simple_probe(struct platform_device *pdev)
struct snd_soc_dai_link *dai_link = priv->dai_link;
struct simple_dai_props *dai_props = priv->dai_props;
int dai_idx = 0;
cinfo = dev->platform_data;
if (!cinfo) {
dev_err(dev, "no info for asoc-simple-card\n");
@ -687,9 +676,6 @@ static int asoc_simple_probe(struct platform_device *pdev)
return -EINVAL;
}
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;