[alsa-devel] [PATCH 0/2] ASoC: soc-core: use snd_soc_dai_link_component for cpu
Hi Mark
These add snd_soc_dai_link_component support for CPU. I know multi-CPU support patch was posted to ML, but I think it is not yet accepted (or rejected ?).
If these patches were accepted, we can finally switch to modern style dai_link, and remove legacy style dai_link.
Kuninori Morimoto (2): ASoC: soc-core: add .num_platform for dai_link ASoC: soc-core: use snd_soc_dai_link_component for cpu
For switching to modern, I added "use modern style dai_link" and "remove legacy style dai_link" patches as sample. If these have no objection, I will post full patch to ML.
Kuninori Morimoto (3): ASoC: audio-graph/simple-card: use modern style dai_link for CPU ASoC: atmel: atmel-classd: use modern style dai_link ASoC: soc-core: remove regacy dai_link binding method
--- Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current snd_soc_dai_link is supporting snd_soc_dai_link_component style for platform, but it is assuming single platform so far. We might have multi platform support in the future.
Currently only simple card is using it from sound card driver, and other drivers are creating it via snd_soc_init_platform(). To avoid future problem for multi platform support, let's add num_platforms before it is too late.
In the same time, to make it same naming mothed, "platform" should be "platforms". This patch fixup it too.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 2 +- include/sound/soc.h | 3 ++- sound/soc/generic/audio-graph-card.c | 5 +++-- sound/soc/generic/simple-card-utils.c | 4 ++-- sound/soc/generic/simple-card.c | 7 ++++--- sound/soc/soc-core.c | 21 +++++++++++++++------ 6 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 6d69ed2..ab5a2ba 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -75,7 +75,7 @@ void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai); &dai_link->codec_dai_name, \ list_name, cells_name, NULL) #define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name) \ - asoc_simple_card_parse_dai(node, dai_link->platform, \ + asoc_simple_card_parse_dai(node, dai_link->platforms, \ &dai_link->platform_of_node, \ NULL, list_name, cells_name, NULL) int asoc_simple_card_parse_dai(struct device_node *node, diff --git a/include/sound/soc.h b/include/sound/soc.h index e665f11..abd3aca 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -925,7 +925,8 @@ struct snd_soc_dai_link { */ const char *platform_name; struct device_node *platform_of_node; - struct snd_soc_dai_link_component *platform; + struct snd_soc_dai_link_component *platforms; + unsigned int num_platforms;
int id; /* optional ID for machine driver link identification */
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 3ec96cd..42b077c 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -26,7 +26,7 @@ struct graph_priv { struct asoc_simple_dai *cpu_dai; struct asoc_simple_dai *codec_dai; struct snd_soc_dai_link_component codecs; /* single codec */ - struct snd_soc_dai_link_component platform; + struct snd_soc_dai_link_component platforms; struct asoc_simple_card_data adata; struct snd_soc_codec_conf *codec_conf; unsigned int mclk_fs; @@ -687,7 +687,8 @@ static int graph_probe(struct platform_device *pdev) for (i = 0; i < li.link; i++) { dai_link[i].codecs = &dai_props[i].codecs; dai_link[i].num_codecs = 1; - dai_link[i].platform = &dai_props[i].platform; + dai_link[i].platforms = &dai_props[i].platforms; + dai_link[i].num_platforms = 1; }
priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW); diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 336895f..3c0901d 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -397,8 +397,8 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_init_dai); int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link) { /* Assumes platform == cpu */ - if (!dai_link->platform->of_node) - dai_link->platform->of_node = dai_link->cpu_of_node; + if (!dai_link->platforms->of_node) + dai_link->platforms->of_node = dai_link->cpu_of_node;
return 0;
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 479de23..d8a0d1e 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -21,7 +21,7 @@ struct simple_priv { struct asoc_simple_dai *cpu_dai; struct asoc_simple_dai *codec_dai; struct snd_soc_dai_link_component codecs; /* single codec */ - struct snd_soc_dai_link_component platform; + struct snd_soc_dai_link_component platforms; struct asoc_simple_card_data adata; struct snd_soc_codec_conf *codec_conf; unsigned int mclk_fs; @@ -732,7 +732,8 @@ static int simple_probe(struct platform_device *pdev) for (i = 0; i < li.link; i++) { dai_link[i].codecs = &dai_props[i].codecs; dai_link[i].num_codecs = 1; - dai_link[i].platform = &dai_props[i].platform; + dai_link[i].platforms = &dai_props[i].platforms; + dai_link[i].num_platforms = 1; }
priv->dai_props = dai_props; @@ -782,7 +783,7 @@ static int simple_probe(struct platform_device *pdev) codecs->name = cinfo->codec; codecs->dai_name = cinfo->codec_dai.name;
- platform = dai_link->platform; + platform = dai_link->platforms; platform->name = cinfo->platform;
card->name = (cinfo->card) ? cinfo->card : cinfo->name; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4c0aaff..07a5851 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -921,7 +921,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
/* find one from the set of registered platforms */ for_each_component(component) { - if (!snd_soc_is_matching_component(dai_link->platform, + if (!snd_soc_is_matching_component(dai_link->platforms, component)) continue;
@@ -1035,7 +1035,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card) static int snd_soc_init_platform(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { - struct snd_soc_dai_link_component *platform = dai_link->platform; + struct snd_soc_dai_link_component *platform = dai_link->platforms;
/* * FIXME @@ -1050,7 +1050,8 @@ static int snd_soc_init_platform(struct snd_soc_card *card, if (!platform) return -ENOMEM;
- dai_link->platform = platform; + dai_link->platforms = platform; + dai_link->num_platforms = 1; dai_link->legacy_platform = 1; platform->name = dai_link->platform_name; platform->of_node = dai_link->platform_of_node; @@ -1129,11 +1130,19 @@ static int soc_init_dai_link(struct snd_soc_card *card, } }
+ /* FIXME */ + if (link->num_platforms > 1) { + dev_err(card->dev, + "ASoC: multi platform is not yet supported %s\n", + link->name); + return -EINVAL; + } + /* * Platform may be specified by either name or OF node, but * can be left unspecified, and a dummy platform will be used. */ - if (link->platform->name && link->platform->of_node) { + if (link->platforms->name && link->platforms->of_node) { dev_err(card->dev, "ASoC: Both platform name/of_node are set for %s\n", link->name); @@ -1144,7 +1153,7 @@ static int soc_init_dai_link(struct snd_soc_card *card, * Defer card registartion if platform dai component is not added to * component list. */ - if (!soc_find_component(link->platform->of_node, link->platform->name)) + if (!soc_find_component(link->platforms->of_node, link->platforms->name)) return -EPROBE_DEFER;
/* @@ -1943,7 +1952,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card) dev_err(card->dev, "init platform error"); continue; } - dai_link->platform->name = component->name; + dai_link->platforms->name = component->name;
/* convert non BE into BE */ dai_link->no_pcm = 1;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current struct snd_soc_dai_link is supporting multicodec, and it is supporting legacy style of codec_name codec_of_node code_dai_name This is handled as single entry of multicodec.
Now, only CPU is not yet supporting snd_soc_dai_link_component style. If we could support it for CPU, we can switch to new style for all CPU/Codec/Platform, and remove legacy code from ALSA SoC.
It is mainly used for Multi-CPU support, but no plan so far. I hope it will be support in the future. This patch is initial support for snd_soc_dai_link_component for CPU ahead of time
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 5 ++++ sound/soc/soc-core.c | 66 ++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 61 insertions(+), 10 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index abd3aca..213187e 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -906,6 +906,10 @@ struct snd_soc_dai_link { * only, which only works well when that device exposes a single DAI. */ const char *cpu_dai_name; + + struct snd_soc_dai_link_component *cpus; + unsigned int num_cpus; + /* * You MUST specify the link's codec, either by device name, or by * DT/OF node, but not both. @@ -991,6 +995,7 @@ struct snd_soc_dai_link { * drivers should not modify this value. */ unsigned int legacy_platform:1; + unsigned int legacy_cpu:1;
struct list_head list; /* DAI link list of the soc card */ struct snd_soc_dobj dobj; /* For topology */ diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 07a5851..b782f19 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -871,7 +871,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card, { struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link_component *codecs; - struct snd_soc_dai_link_component cpu_dai_component; struct snd_soc_component *component; struct snd_soc_dai **codec_dais; int i; @@ -891,13 +890,11 @@ static int soc_bind_dai_link(struct snd_soc_card *card, if (!rtd) return -ENOMEM;
- cpu_dai_component.name = dai_link->cpu_name; - cpu_dai_component.of_node = dai_link->cpu_of_node; - cpu_dai_component.dai_name = dai_link->cpu_dai_name; - rtd->cpu_dai = snd_soc_find_dai(&cpu_dai_component); + /* FIXME: we need multi CPU support in the future */ + rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus); if (!rtd->cpu_dai) { dev_info(card->dev, "ASoC: CPU DAI %s not registered\n", - dai_link->cpu_dai_name); + dai_link->cpus->dai_name); goto _err_defer; } snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component); @@ -1032,6 +1029,41 @@ static void soc_remove_dai_links(struct snd_soc_card *card) } }
+static int snd_soc_init_cpu(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link) +{ + struct snd_soc_dai_link_component *cpu = dai_link->cpus; + + /* + * FIXME + * + * this function should be removed in the future + */ + /* convert Legacy platform link */ + if (!cpu || dai_link->legacy_cpu) { + cpu = devm_kzalloc(card->dev, + sizeof(struct snd_soc_dai_link_component), + GFP_KERNEL); + if (!cpu) + return -ENOMEM; + + dai_link->cpus = cpu; + dai_link->num_cpus = 1; + dai_link->legacy_cpu = 1; + + cpu->name = dai_link->cpu_name; + cpu->of_node = dai_link->cpu_of_node; + cpu->dai_name = dai_link->cpu_dai_name; + } + + if (!dai_link->cpus) { + dev_err(card->dev, "ASoC: DAI link has no CPUs\n"); + return -EINVAL; + } + + return 0; +} + static int snd_soc_init_platform(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { @@ -1099,6 +1131,12 @@ static int soc_init_dai_link(struct snd_soc_card *card, int i, ret; struct snd_soc_dai_link_component *codec;
+ ret = snd_soc_init_cpu(card, link); + if (ret) { + dev_err(card->dev, "ASoC: failed to init cpu\n"); + return ret; + } + ret = snd_soc_init_platform(card, link); if (ret) { dev_err(card->dev, "ASoC: failed to init multiplatform\n"); @@ -1156,12 +1194,20 @@ static int soc_init_dai_link(struct snd_soc_card *card, if (!soc_find_component(link->platforms->of_node, link->platforms->name)) return -EPROBE_DEFER;
+ /* FIXME */ + if (link->num_cpus > 1) { + dev_err(card->dev, + "ASoC: multi cpu is not yet supported %s\n", + link->name); + return -EINVAL; + } + /* * CPU device may be specified by either name or OF node, but * can be left unspecified, and will be matched based on DAI * name alone.. */ - if (link->cpu_name && link->cpu_of_node) { + if (link->cpus->name && link->cpus->of_node) { dev_err(card->dev, "ASoC: Neither/both cpu name/of_node are set for %s\n", link->name); @@ -1172,15 +1218,15 @@ static int soc_init_dai_link(struct snd_soc_card *card, * Defer card registartion if cpu dai component is not added to * component list. */ - if (!soc_find_component(link->cpu_of_node, link->cpu_name)) + if (!soc_find_component(link->cpus->of_node, link->cpus->name)) return -EPROBE_DEFER;
/* * At least one of CPU DAI name or CPU device name/node must be * specified */ - if (!link->cpu_dai_name && - !(link->cpu_name || link->cpu_of_node)) { + if (!link->cpus->dai_name && + !(link->cpus->name || link->cpus->of_node)) { dev_err(card->dev, "ASoC: Neither cpu_dai_name nor cpu_name/of_node are set for %s\n", link->name);
Now ALSA SoC is supporting modern style (= snd_soc_dai_link_component) dai_link for CPU, let's switch to it.
Because audio-graph/simple-card are sharing simple-card-utils, we need to update both in the same time.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/simple_card_utils.h | 42 +++++++------------- sound/soc/generic/audio-graph-card.c | 18 +++++---- sound/soc/generic/simple-card-utils.c | 72 ++++++++--------------------------- sound/soc/generic/simple-card.c | 19 ++++++--- 4 files changed, 53 insertions(+), 98 deletions(-)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index ab5a2ba..d02de45 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -50,54 +50,38 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card, char *prefix);
#define asoc_simple_card_parse_clk_cpu(dev, node, dai_link, simple_dai) \ - asoc_simple_card_parse_clk(dev, node, dai_link->cpu_of_node, simple_dai, \ - dai_link->cpu_dai_name, NULL) + asoc_simple_card_parse_clk(dev, node, simple_dai, dai_link->cpus) #define asoc_simple_card_parse_clk_codec(dev, node, dai_link, simple_dai) \ - asoc_simple_card_parse_clk(dev, node, dai_link->codec_of_node, simple_dai,\ - dai_link->codec_dai_name, dai_link->codecs) + asoc_simple_card_parse_clk(dev, node, simple_dai, dai_link->codecs) int asoc_simple_card_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); int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai); void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai);
#define asoc_simple_card_parse_cpu(node, dai_link, \ list_name, cells_name, is_single_link) \ - asoc_simple_card_parse_dai(node, NULL, \ - &dai_link->cpu_of_node, \ - &dai_link->cpu_dai_name, list_name, cells_name, is_single_link) + asoc_simple_card_parse_dai(node, dai_link->cpus, \ + list_name, cells_name, 1, is_single_link) #define asoc_simple_card_parse_codec(node, dai_link, list_name, cells_name) \ asoc_simple_card_parse_dai(node, dai_link->codecs, \ - &dai_link->codec_of_node, \ - &dai_link->codec_dai_name, \ - list_name, cells_name, NULL) + list_name, cells_name, 1, NULL) #define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name) \ asoc_simple_card_parse_dai(node, dai_link->platforms, \ - &dai_link->platform_of_node, \ - NULL, list_name, cells_name, NULL) + list_name, cells_name, 0, NULL) int asoc_simple_card_parse_dai(struct device_node *node, - struct snd_soc_dai_link_component *dlc, - struct device_node **endpoint_np, - const char **dai_name, - const char *list_name, - const char *cells_name, - int *is_single_links); + struct snd_soc_dai_link_component *dlc, + const char *list_name, + const char *cells_name, + int with_dai, int *is_single_links);
#define asoc_simple_card_parse_graph_cpu(ep, dai_link) \ - asoc_simple_card_parse_graph_dai(ep, NULL, \ - &dai_link->cpu_of_node, \ - &dai_link->cpu_dai_name) + asoc_simple_card_parse_graph_dai(ep, dai_link->cpus) #define asoc_simple_card_parse_graph_codec(ep, dai_link) \ - asoc_simple_card_parse_graph_dai(ep, dai_link->codecs, \ - &dai_link->codec_of_node, \ - &dai_link->codec_dai_name) + asoc_simple_card_parse_graph_dai(ep, dai_link->codecs) int asoc_simple_card_parse_graph_dai(struct device_node *ep, - struct snd_soc_dai_link_component *dlc, - struct device_node **endpoint_np, - const char **dai_name); + struct snd_soc_dai_link_component *dlc);
#define asoc_simple_card_of_parse_tdm(np, dai) \ snd_soc_of_parse_tdm_slot(np, &(dai)->tx_slot_mask, \ diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 42b077c..374f041 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -25,6 +25,7 @@ struct graph_priv { struct graph_dai_props { struct asoc_simple_dai *cpu_dai; struct asoc_simple_dai *codec_dai; + struct snd_soc_dai_link_component cpus; /* single cpu */ struct snd_soc_dai_link_component codecs; /* single codec */ struct snd_soc_dai_link_component platforms; struct asoc_simple_card_data adata; @@ -208,6 +209,7 @@ static int graph_dai_link_of_dpcm(struct graph_priv *priv, struct device_node *node; struct asoc_simple_dai *dai; struct snd_soc_dai_link_component *codecs = dai_link->codecs; + struct snd_soc_dai_link_component *cpus = dai_link->cpus; int ret;
/* Do it all CPU endpoint, and 1st Codec endpoint */ @@ -257,20 +259,20 @@ static int graph_dai_link_of_dpcm(struct graph_priv *priv,
ret = asoc_simple_card_set_dailink_name(dev, dai_link, "fe.%s", - dai_link->cpu_dai_name); + cpus->dai_name); if (ret < 0) return ret;
/* card->num_links includes Codec */ asoc_simple_card_canonicalize_cpu(dai_link, - of_graph_get_endpoint_count(dai_link->cpu_of_node) == 1); + of_graph_get_endpoint_count(cpus->of_node) == 1); } else { 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; @@ -411,7 +413,7 @@ static int graph_dai_link_of(struct graph_priv *priv,
ret = asoc_simple_card_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; @@ -420,7 +422,7 @@ static int graph_dai_link_of(struct graph_priv *priv, dai_link->init = graph_dai_init;
asoc_simple_card_canonicalize_cpu(dai_link, - of_graph_get_endpoint_count(dai_link->cpu_of_node) == 1); + of_graph_get_endpoint_count(dai_link->cpus->of_node) == 1);
return 0; } @@ -685,6 +687,8 @@ static int graph_probe(struct platform_device *pdev) * soc-core.c :: snd_soc_init_multicodec() */ 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-utils.c b/sound/soc/generic/simple-card-utils.c index 3c0901d..c98a074 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -170,26 +170,13 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_clk_disable);
int asoc_simple_card_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; - dai_name = dlc->dai_name; - } - - /* * Parse dai->sysclk come from "clocks = <&xxx>" * (if system has common clock) * or "system-clock-frequency = <xxx>" @@ -203,7 +190,7 @@ int asoc_simple_card_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); } @@ -211,7 +198,7 @@ int asoc_simple_card_parse_clk(struct device *dev, if (of_property_read_bool(node, "system-clock-direction-out")) simple_dai->clk_direction = SND_SOC_CLOCK_OUT;
- dev_dbg(dev, "%s : sysclk = %d, direction %d\n", dai_name, + dev_dbg(dev, "%s : sysclk = %d, direction %d\n", dlc->dai_name, simple_dai->sysclk, simple_dai->clk_direction);
return 0; @@ -219,12 +206,11 @@ int asoc_simple_card_parse_clk(struct device *dev, EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk);
int asoc_simple_card_parse_dai(struct device_node *node, - struct snd_soc_dai_link_component *dlc, - struct device_node **dai_of_node, - const char **dai_name, - const char *list_name, - const char *cells_name, - int *is_single_link) + struct snd_soc_dai_link_component *dlc, + const char *list_name, + const char *cells_name, + int with_dai, + int *is_single_link) { struct of_phandle_args args; int ret; @@ -233,17 +219,6 @@ int asoc_simple_card_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() */ @@ -252,13 +227,13 @@ int asoc_simple_card_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 (with_dai) { + 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; @@ -320,29 +295,14 @@ static int asoc_simple_card_get_dai_id(struct device_node *ep) }
int asoc_simple_card_parse_graph_dai(struct device_node *ep, - struct snd_soc_dai_link_component *dlc, - struct device_node **dai_of_node, - const char **dai_name) + struct snd_soc_dai_link_component *dlc) { 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);
@@ -351,11 +311,11 @@ int asoc_simple_card_parse_graph_dai(struct device_node *ep, args.args[0] = asoc_simple_card_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;
return 0; } @@ -398,7 +358,7 @@ int asoc_simple_card_canonicalize_dailink(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; + dai_link->platforms->of_node = dai_link->cpus->of_node;
return 0;
@@ -418,7 +378,7 @@ void asoc_simple_card_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_card_canonicalize_cpu);
@@ -428,7 +388,7 @@ int asoc_simple_card_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; diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index d8a0d1e..1869f1f 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -20,6 +20,7 @@ struct simple_priv { struct simple_dai_props { struct asoc_simple_dai *cpu_dai; struct asoc_simple_dai *codec_dai; + struct snd_soc_dai_link_component cpus; /* single cpu */ struct snd_soc_dai_link_component codecs; /* single codec */ struct snd_soc_dai_link_component platforms; struct asoc_simple_card_data adata; @@ -198,6 +199,7 @@ static int simple_dai_link_of_dpcm(struct simple_priv *priv, struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); struct asoc_simple_dai *dai; struct snd_soc_dai_link_component *codecs = dai_link->codecs; + struct snd_soc_dai_link_component *cpus = dai_link->cpus; struct device_node *top = dev->of_node; struct device_node *node = of_get_parent(np); char prop[128]; @@ -249,7 +251,7 @@ static int simple_dai_link_of_dpcm(struct simple_priv *priv,
ret = asoc_simple_card_set_dailink_name(dev, dai_link, "fe.%s", - dai_link->cpu_dai_name); + dai_link->cpus->dai_name); if (ret < 0) return ret;
@@ -258,9 +260,9 @@ static int simple_dai_link_of_dpcm(struct 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; @@ -415,7 +417,7 @@ static int simple_dai_link_of(struct simple_priv *priv,
ret = asoc_simple_card_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; @@ -730,6 +732,8 @@ static int simple_probe(struct platform_device *pdev) * soc-core.c :: snd_soc_init_multicodec() */ 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; @@ -757,6 +761,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; int dai_idx = 0; @@ -779,6 +784,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; @@ -789,7 +797,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 = simple_dai_init; memcpy(priv->dai_props->cpu_dai, &cinfo->cpu_dai,
Now ALSA SoC is supporting modern style (= snd_soc_dai_link_component) dai_link for CPU/Codec/Platform, let's switch to it from legacy style.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/atmel/atmel-classd.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index 3d70061..5b662a2 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -499,18 +499,28 @@ static int atmel_classd_asoc_card_init(struct device *dev, struct snd_soc_card *card) { struct snd_soc_dai_link *dai_link; + struct snd_soc_dai_link_component *dlc; struct atmel_classd *dd = snd_soc_card_get_drvdata(card);
dai_link = devm_kzalloc(dev, sizeof(*dai_link), GFP_KERNEL); - if (!dai_link) + /* cpu/codec/platform */ + dlc = devm_kzalloc(dev, sizeof(*dlc) * 3, GFP_KERNEL); + if (!dai_link || !dlc) return -ENOMEM;
dai_link->name = "CLASSD"; dai_link->stream_name = "CLASSD PCM"; - dai_link->codec_dai_name = ATMEL_CLASSD_CODEC_DAI_NAME; - dai_link->cpu_dai_name = dev_name(dev); - dai_link->codec_name = dev_name(dev); - dai_link->platform_name = dev_name(dev); + dai_link->cpus = &dlc[0]; + dai_link->num_cpus = 1; + dai_link->codecs = &dlc[1]; + dai_link->num_codecs = 1; + dai_link->platforms = &dlc[2]; + dai_link->num_platforms = 1; + + dai_link->codecs->dai_name = ATMEL_CLASSD_CODEC_DAI_NAME; + dai_link->cpus->dai_name = dev_name(dev); + dai_link->codecs->name = dev_name(dev); + dai_link->platforms->name = dev_name(dev);
card->dai_link = dai_link; card->num_links = 1;
Legacy ALSA SoC used these name matching xxx_name xxx_of_node xxx_dai_name
Now we can use snd_soc_dai_link_component instead of it. No one is using legacy style now, let's remove these.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 17 -------- sound/soc/soc-core.c | 121 +-------------------------------------------------- 2 files changed, 1 insertion(+), 137 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 213187e..b6dd33a 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -898,15 +898,11 @@ struct snd_soc_dai_link { * must be globally unique. These fields are currently typically used * only for codec to codec links, or systems using device tree. */ - const char *cpu_name; - struct device_node *cpu_of_node; /* * You MAY specify the DAI name of the CPU DAI. If this information is * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node * only, which only works well when that device exposes a single DAI. */ - const char *cpu_dai_name; - struct snd_soc_dai_link_component *cpus; unsigned int num_cpus;
@@ -914,11 +910,7 @@ struct snd_soc_dai_link { * You MUST specify the link's codec, either by device name, or by * DT/OF node, but not both. */ - const char *codec_name; - struct device_node *codec_of_node; /* You MUST specify the DAI name within the codec */ - const char *codec_dai_name; - struct snd_soc_dai_link_component *codecs; unsigned int num_codecs;
@@ -927,8 +919,6 @@ struct snd_soc_dai_link { * device name, or by DT/OF node, but not both. Some forms of link * do not need a platform. */ - const char *platform_name; - struct device_node *platform_of_node; struct snd_soc_dai_link_component *platforms; unsigned int num_platforms;
@@ -990,13 +980,6 @@ struct snd_soc_dai_link { /* Do not create a PCM for this DAI link (Backend link) */ unsigned int ignore:1;
- /* - * This driver uses legacy platform naming. Set by the core, machine - * drivers should not modify this value. - */ - unsigned int legacy_platform:1; - unsigned int legacy_cpu:1; - struct list_head list; /* DAI link list of the soc card */ struct snd_soc_dobj dobj; /* For topology */ }; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b782f19..f41c9ab 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1029,126 +1029,12 @@ static void soc_remove_dai_links(struct snd_soc_card *card) } }
-static int snd_soc_init_cpu(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) -{ - struct snd_soc_dai_link_component *cpu = dai_link->cpus; - - /* - * FIXME - * - * this function should be removed in the future - */ - /* convert Legacy platform link */ - if (!cpu || dai_link->legacy_cpu) { - cpu = devm_kzalloc(card->dev, - sizeof(struct snd_soc_dai_link_component), - GFP_KERNEL); - if (!cpu) - return -ENOMEM; - - dai_link->cpus = cpu; - dai_link->num_cpus = 1; - dai_link->legacy_cpu = 1; - - cpu->name = dai_link->cpu_name; - cpu->of_node = dai_link->cpu_of_node; - cpu->dai_name = dai_link->cpu_dai_name; - } - - if (!dai_link->cpus) { - dev_err(card->dev, "ASoC: DAI link has no CPUs\n"); - return -EINVAL; - } - - return 0; -} - -static int snd_soc_init_platform(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) -{ - struct snd_soc_dai_link_component *platform = dai_link->platforms; - - /* - * FIXME - * - * this function should be removed in the future - */ - /* convert Legacy platform link */ - if (!platform || dai_link->legacy_platform) { - platform = devm_kzalloc(card->dev, - sizeof(struct snd_soc_dai_link_component), - GFP_KERNEL); - if (!platform) - return -ENOMEM; - - dai_link->platforms = platform; - dai_link->num_platforms = 1; - dai_link->legacy_platform = 1; - platform->name = dai_link->platform_name; - platform->of_node = dai_link->platform_of_node; - platform->dai_name = NULL; - } - - /* if there's no platform we match on the empty platform */ - if (!platform->name && - !platform->of_node) - platform->name = "snd-soc-dummy"; - - return 0; -} - -static int snd_soc_init_multicodec(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) -{ - /* Legacy codec/codec_dai link is a single entry in multicodec */ - if (dai_link->codec_name || dai_link->codec_of_node || - dai_link->codec_dai_name) { - dai_link->num_codecs = 1; - - dai_link->codecs = devm_kzalloc(card->dev, - sizeof(struct snd_soc_dai_link_component), - GFP_KERNEL); - if (!dai_link->codecs) - return -ENOMEM; - - dai_link->codecs[0].name = dai_link->codec_name; - dai_link->codecs[0].of_node = dai_link->codec_of_node; - dai_link->codecs[0].dai_name = dai_link->codec_dai_name; - } - - if (!dai_link->codecs) { - dev_err(card->dev, "ASoC: DAI link has no CODECs\n"); - return -EINVAL; - } - - return 0; -} - static int soc_init_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link) { - int i, ret; + int i; struct snd_soc_dai_link_component *codec;
- ret = snd_soc_init_cpu(card, link); - if (ret) { - dev_err(card->dev, "ASoC: failed to init cpu\n"); - return ret; - } - - ret = snd_soc_init_platform(card, link); - if (ret) { - dev_err(card->dev, "ASoC: failed to init multiplatform\n"); - return ret; - } - - ret = snd_soc_init_multicodec(card, link); - if (ret) { - dev_err(card->dev, "ASoC: failed to init multicodec\n"); - return ret; - } - for_each_link_codecs(link, i, codec) { /* * Codec must be specified by 1 of name or OF node, @@ -1993,11 +1879,6 @@ static void soc_check_tplg_fes(struct snd_soc_card *card) dev_info(card->dev, "info: override FE DAI link %s\n", card->dai_link[i].name);
- /* override platform component */ - if (snd_soc_init_platform(card, dai_link) < 0) { - dev_err(card->dev, "init platform error"); - continue; - } dai_link->platforms->name = component->name;
/* convert non BE into BE */
On 1/16/19 2:26 AM, Kuninori Morimoto wrote:
Hi Mark
These add snd_soc_dai_link_component support for CPU. I know multi-CPU support patch was posted to ML, but I think it is not yet accepted (or rejected ?).
If you are referring to the Intel patches, they were really too intrusive and complicated. Quite frankly I don't think anyone at Intel (me included) understands what is "legacy" and what is "modern", so adding multiple cpu support in there was really guesswork and copy/replace of the multi-codec parts, likely to break and impossible to test.
If these patches were accepted, we can finally switch to modern style dai_link, and remove legacy style dai_link.
it might be a better idea to remove the legacy first so that we have a clean slate to add multiple CPUs?
If you have a blurb or description of the end-goal and what evolutions are required for dai links, it'd be really nice. Following incremental patches over multiple kernel versions isn't straightforward and the impacts of your changes isn't clear to me, e.g. I'd really like to know if the current way Intel uses dailinks needs to be changed or if we are good.
Thanks
-Pierre
Kuninori Morimoto (2): ASoC: soc-core: add .num_platform for dai_link ASoC: soc-core: use snd_soc_dai_link_component for cpu
For switching to modern, I added "use modern style dai_link" and "remove legacy style dai_link" patches as sample. If these have no objection, I will post full patch to ML.
Kuninori Morimoto (3): ASoC: audio-graph/simple-card: use modern style dai_link for CPU ASoC: atmel: atmel-classd: use modern style dai_link ASoC: soc-core: remove regacy dai_link binding method
Kuninori Morimoto _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Hi Pierre
Thank you for your feedback
These add snd_soc_dai_link_component support for CPU. I know multi-CPU support patch was posted to ML, but I think it is not yet accepted (or rejected ?).
If you are referring to the Intel patches, they were really too intrusive and complicated. Quite frankly I don't think anyone at Intel (me included) understands what is "legacy" and what is "modern", so adding multiple cpu support in there was really guesswork and copy/replace of the multi-codec parts, likely to break and impossible to test.
Sorry, what does your "Intel patches" means ? Do you mean like this ?
Subject: [alsa-devel] [PATCH v6 0/3] ASoC: Add Multi CPU DAI support Date: Wed, 20 Jun 2018 16:24:14 +0530
If so, actually I'm very waiting this patch series. But, it seems nothing happen on ALSA ML after that. So, I thought it was rejected or something happen. I think my patch and above are basically using same idea for dai_link, I think there is no conflict around dai_link. If above patch series was delayed or temporary aborted, and will be restart/retry multi CPU support someday, then, it can based on it, I thought. If Intel still have plan about it, I'm very happy to wait.
If you have a blurb or description of the end-goal and what evolutions are required for dai links, it'd be really nice. Following incremental patches over multiple kernel versions isn't straightforward and the impacts of your changes isn't clear to me, e.g. I'd really like to know if the current way Intel uses dailinks needs to be changed or if we are good.
Best regards --- Kuninori Morimoto
On Thu, Jan 17, 2019 at 10:14:39AM +0900, Kuninori Morimoto wrote:
Subject: [alsa-devel] [PATCH v6 0/3] ASoC: Add Multi CPU DAI support Date: Wed, 20 Jun 2018 16:24:14 +0530
If so, actually I'm very waiting this patch series. But, it seems nothing happen on ALSA ML after that. So, I thought it was rejected or something happen.
It's definitely not rejected, it's just huge and goes right across the core so it's extremely difficult to do a review of.
Hi Mark
Subject: [alsa-devel] [PATCH v6 0/3] ASoC: Add Multi CPU DAI support Date: Wed, 20 Jun 2018 16:24:14 +0530
If so, actually I'm very waiting this patch series. But, it seems nothing happen on ALSA ML after that. So, I thought it was rejected or something happen.
It's definitely not rejected, it's just huge and goes right across the core so it's extremely difficult to do a review of.
OK, it is "on going" patch-set. I'm happy to know about it, thank you. Then, my posted patch is not good, please drop. But I think "platform" side patch can still survive. I will re-post it.
Best regards --- Kuninori Morimoto
On 1/17/19 6:48 AM, Mark Brown wrote:
On Thu, Jan 17, 2019 at 10:14:39AM +0900, Kuninori Morimoto wrote:
Subject: [alsa-devel] [PATCH v6 0/3] ASoC: Add Multi CPU DAI support Date: Wed, 20 Jun 2018 16:24:14 +0530
If so, actually I'm very waiting this patch series. But, it seems nothing happen on ALSA ML after that. So, I thought it was rejected or something happen.
It's definitely not rejected, it's just huge and goes right across the core so it's extremely difficult to do a review of.
It's a fair assumption that the multi-cpu stuff will only be needed for modern platforms and most likely for SoundWire support where we can have independent but synchronized links. Between my extended break and the SOF work I haven't had time to look into this so far, but it's on my radar now. What I don't quite get is that what is needed to get the "modern" representation supported for CPU dais as well? There is currently a wrapper for the codec_dais, couldn't we do the same for the cpu_dais and remove it when all drivers have moved? My point is that if internally only the modern representation is used then the extensions to multi-cpus will be easier. What am I missing?
Hi Pierre-Louis
What I don't quite get is that what is needed to get the "modern" representation supported for CPU dais as well? There is currently a wrapper for the codec_dais, couldn't we do the same for the cpu_dais and remove it when all drivers have moved?
Sorry 50% English issue, but does this "wrapper for the codec_dais" means we are converting single codec to muliti codec style via snd_soc_init_multicodec() ? If so, yes, we can have same logic for CPU.
My point is that if internally only the modern representation is used then the extensions to multi-cpus will be easier.
Yeah agree. How to do it seems need some agreement, I think...
Best regards --- Kuninori Morimoto
What I don't quite get is that what is needed to get the "modern" representation supported for CPU dais as well? There is currently a wrapper for the codec_dais, couldn't we do the same for the cpu_dais and remove it when all drivers have moved?
Sorry 50% English issue, but does this "wrapper for the codec_dais" means we are converting single codec to muliti codec style via snd_soc_init_multicodec() ? If so, yes, we can have same logic for CPU.
Yes exactly what I meant indeed.
My point is that if internally only the modern representation is used then the extensions to multi-cpus will be easier.
Yeah agree. How to do it seems need some agreement, I think...
Thank you for the clarification. I started working on updating all the Intel stuff to the modern representation, will look at cpu next.
Hi Pierre-Louis
My point is that if internally only the modern representation is used then the extensions to multi-cpus will be easier.
Yeah agree. How to do it seems need some agreement, I think...
Thank you for the clarification. I started working on updating all the Intel stuff to the modern representation, will look at cpu next.
Thanks. Nice to know. If CPU supports modern representation, then, all driver can switch to modern for CPU/Codec/Platform, and we can remove legacy code from ALSA SoC.
Best regards --- Kuninori Morimoto
participants (3)
-
Kuninori Morimoto
-
Mark Brown
-
Pierre-Louis Bossart