[alsa-devel] [PATCH 0/3] ASoC: add/use asoc_simple_card_of_canonicalize_cpu()
Hi Mark
These fixes audio graph cards DAI counting bug. Simple Card side doesn't have this issue, but Audio Graph Card side has it.
Kuninori Morimoto (3): ASoC: simple-card-utils: add asoc_simple_card_of_canonicalize_cpu() ASoC: audio-graph-card: use asoc_simple_card_of_canonicalize_cpu() ASoC: audio-graph-scu-card: use asoc_simple_card_of_canonicalize_cpu()
include/sound/simple_card_utils.h | 1 + sound/soc/generic/audio-graph-card.c | 4 +--- sound/soc/generic/audio-graph-scu-card.c | 4 +--- sound/soc/generic/simple-card-utils.c | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 6 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
snd_soc_find_dai() will check dai_name after of_node matching if dai_link has it. but, it will never match if name was created by fmt_single_name(). Thus, we need to remove cpu_dai_name if cpu was single.
Before, simple-card assumed that CPU was single if Card has single link. It is no problem in below case
/* Card uses 1 link */ card { compatible = "audio-graph-card"; ... dais = <&cpu_port0>; };
/* CPU has single endpoints */ cpu { ... cpu_port0: port@0 { endpoint { ... }; }; };
But it can't handle correctly below case. This patch adds new asoc_simple_card_of_canonicalize_cpu() and confirm it was single or not by counting endpoint.
/* Card uses only 1 link */ card { compatible = "audio-graph-card"; ... dais = <&cpu_port0>; };
/* CPU has many endpoints */ cpu { ... ports { cpu_port0: port@0 { endpoint { ... }; }; cpu_port1: port@1 { endpoint { ... }; }; ... }; };
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 1 + sound/soc/generic/simple-card-utils.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 42c6a6a..bfb3dca 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -90,6 +90,7 @@ int asoc_simple_card_init_dai(struct snd_soc_dai *dai, struct asoc_simple_dai *simple_dai);
int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link); +void asoc_simple_card_of_canonicalize_cpu(struct snd_soc_dai_link *dai_link); void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, int is_single_links);
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 26d64fa..bc2e9a2 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -343,6 +343,26 @@ int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link) } EXPORT_SYMBOL_GPL(asoc_simple_card_canonicalize_dailink);
+void asoc_simple_card_of_canonicalize_cpu(struct snd_soc_dai_link *dai_link) +{ + /* + * soc_bind_dai_link() will check cpu name after + * of_node matching if dai_link has cpu_dai_name. + * but, it will never match if name was created by + * fmt_single_name(). remove cpu_dai_name if cpu_args + * was 0. See: + * fmt_single_name() + * fmt_multiple_name() + * + * simple card utils assumes if driver has many endpoint, + * it is using fmt_multiple_name() + */ + + if (of_graph_get_endpoint_count(dai_link->cpu_of_node) == 1) + dai_link->cpu_dai_name = NULL; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_of_canonicalize_cpu); + void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, int is_single_links) {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
snd_soc_find_dai() will check dai_name after of_node matching if dai_link has it. but, it will never match if name was created by fmt_single_name(). Thus, we need to remove cpu_dai_name if cpu was single.
Before, simple-card assumed that CPU was single if Card has single link. It is no problem in below case
/* Card uses 1 link */ card { compatible = "audio-graph-card"; ... dais = <&cpu_port0>; };
/* CPU has single endpoints */ cpu { ... cpu_port0: port@0 { endpoint { ... }; }; };
But it can't handle correctly below case. This patch uses new asoc_simple_card_of_canonicalize_cpu() and confirm it was single or not by counting endpoint.
/* Card uses only 1 link */ card { compatible = "audio-graph-card"; ... dais = <&cpu_port0>; };
/* CPU has many endpoints */ cpu { ... ports { cpu_port0: port@0 { endpoint { ... }; }; cpu_port1: port@1 { endpoint { ... }; }; ... }; };
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/audio-graph-card.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 885b405..5e5b8bb 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -100,7 +100,6 @@ static int asoc_graph_card_dai_link_of(struct device_node *cpu_port, struct graph_dai_props *dai_props = graph_priv_to_props(priv, idx); struct asoc_simple_dai *cpu_dai = &dai_props->cpu_dai; struct asoc_simple_dai *codec_dai = &dai_props->codec_dai; - struct snd_soc_card *card = graph_priv_to_card(priv); struct device_node *cpu_ep = of_get_next_child(cpu_port, NULL); struct device_node *codec_ep = of_graph_get_remote_endpoint(cpu_ep); struct device_node *rcpu_ep = of_graph_get_remote_endpoint(codec_ep); @@ -161,8 +160,7 @@ static int asoc_graph_card_dai_link_of(struct device_node *cpu_port, dai_link->ops = &asoc_graph_card_ops; dai_link->init = asoc_graph_card_dai_init;
- asoc_simple_card_canonicalize_cpu(dai_link, - card->num_links == 1); + asoc_simple_card_of_canonicalize_cpu(dai_link);
dai_link_of_err: of_node_put(cpu_ep);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
snd_soc_find_dai() will check dai_name after of_node matching if dai_link has it. but, it will never match if name was created by fmt_single_name(). Thus, we need to remove cpu_dai_name if cpu was single.
Before, simple-card assumed that CPU was single if Card has single link. It is no problem in below case
/* Card uses 1 link */ card { compatible = "audio-graph-card"; ... dais = <&cpu_port0>; };
/* CPU has single endpoints */ cpu { ... cpu_port0: port@0 { endpoint { ... }; }; };
But it can't handle correctly below case. This patch uses new asoc_simple_card_of_canonicalize_cpu() and confirm it was single or not by counting endpoint.
/* Card uses only 1 link */ card { compatible = "audio-graph-card"; ... dais = <&cpu_port0>; };
/* CPU has many endpoints */ cpu { ... ports { cpu_port0: port@0 { endpoint { ... }; }; cpu_port1: port@1 { endpoint { ... }; }; ... }; };
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/generic/audio-graph-scu-card.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/sound/soc/generic/audio-graph-scu-card.c b/sound/soc/generic/audio-graph-scu-card.c index 05934b2..bd924b1 100644 --- a/sound/soc/generic/audio-graph-scu-card.c +++ b/sound/soc/generic/audio-graph-scu-card.c @@ -123,9 +123,7 @@ static int asoc_graph_card_dai_link_of(struct device_node *ep, if (ret < 0) return ret;
- /* card->num_links includes Codec */ - asoc_simple_card_canonicalize_cpu(dai_link, - (card->num_links - 1) == 1); + asoc_simple_card_of_canonicalize_cpu(dai_link); } else { /* FE is dummy */ dai_link->cpu_of_node = NULL;
Hi Mark
Sorry for my noise, but I noticed these patches are a littile bit over-kill. Please ignore, I want to post more light v2 patches
These fixes audio graph cards DAI counting bug. Simple Card side doesn't have this issue, but Audio Graph Card side has it.
Kuninori Morimoto (3): ASoC: simple-card-utils: add asoc_simple_card_of_canonicalize_cpu() ASoC: audio-graph-card: use asoc_simple_card_of_canonicalize_cpu() ASoC: audio-graph-scu-card: use asoc_simple_card_of_canonicalize_cpu()
include/sound/simple_card_utils.h | 1 + sound/soc/generic/audio-graph-card.c | 4 +--- sound/soc/generic/audio-graph-scu-card.c | 4 +--- sound/soc/generic/simple-card-utils.c | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 6 deletions(-)
-- 1.9.1
participants (1)
-
Kuninori Morimoto