Unverified Commit 674b9438 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown
Browse files

ASoC: audio-graph: count DAI / link numbers as in order



audio-graph checks DT links 2 times. 1st is for counting DAIs / links
to allocating memory, 2nd is for detecting DAIs.
To detecting DAIs as CPU-dummy -> dummy-Codec order when DPCM case,
it uses loops 2 times at 2nd DT link check.
But it doesn't do it at 1st DT link check.

	for (li.cpu = 1; li.cpu >= 0; li.cpu--) {
		/*
		 * Detect all CPU first, and Detect all Codec 2n
		 *
		 * In Normal sound case, all DAIs are detected
		 * as "CPU-Codec".
		 *
		 * In DPCM sound case,
		 * all CPUs   are detected as "CPU-dummy", and
		 * all Codecs are detected as "dummy-Codec".
		 * To avoid random sub-device numbering,
		 * detect "dummy-Codec" in last;
		 */
		ret = graph_for_each_link(...);
		...
	}

To prepare supporting multi-CPU/Codec, and code cleanup,
this patch use same loop for 1st DT link check, too.

Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a6qq1tpp.wl-kuninori.morimoto.gx@renesas.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 050c7950
Loading
Loading
Loading
Loading
+23 −6
Original line number Diff line number Diff line
@@ -617,6 +617,10 @@ static int graph_count_noml(struct asoc_simple_priv *priv,
{
	struct device *dev = simple_priv_to_dev(priv);

	/* Do it only CPU turn */
	if (!li->cpu)
		return 0;

	li->link += 1; /* 1xCPU-Codec */
	li->dais += 2; /* 1xCPU + 1xCodec */

@@ -633,10 +637,22 @@ static int graph_count_dpcm(struct asoc_simple_priv *priv,
{
	struct device *dev = simple_priv_to_dev(priv);

	/*
	 * Codec endpoint can be NULL for pluggable audio HW.
	 * Platform DT can populate the Codec endpoint depending on the
	 * plugged HW.
	 */
	if (!li->cpu && !codec_ep)
		return 0;

	/* Do it all CPU endpoint, and 1st Codec endpoint */
	if (!li->cpu && dup_codec)
		return 0;

	if (li->cpu) {
		li->link++; /* 1xCPU-dummy */
		li->dais++; /* 1xCPU */

	if (!dup_codec && codec_ep) {
	} else if (!dup_codec && codec_ep) {
		li->link++; /* 1xdummy-Codec */
		li->conf++; /* 1xdummy-Codec */
		li->dais++; /* 1xCodec */
@@ -698,6 +714,7 @@ static void graph_get_dais_count(struct asoc_simple_priv *priv,
	 *	=> 4 DAIs  = 2xCPU + 2xCodec
	 *	=> 1 ccnf  = 1xdummy-Codec
	 */
	for (li->cpu = 1; li->cpu >= 0; li->cpu--)
		graph_for_each_link(priv, li,
				    graph_count_noml,
				    graph_count_dpcm);