[alsa-devel] [PATCH v2 00/15] ASoC: soc-core cleanup step6
Hi Mark
These are v2 of soc-core cleanup step6. These doesn't add new features.
Kuninori Morimoto (15): ASoC: soc-core: remove dai_link_list ASoC: soc-core: remove snd_soc_disconnect_sync() ASoC: soc-core: remove snd_soc_get_dai_substream() ASoC: soc-core: move snd_soc_get_pcm_runtime() ASoC: soc-core: find rtd via dai_link pointer at snd_soc_get_pcm_runtime() ASoC: soc-core: move snd_soc_find_dai_link() ASoC: soc-core: rename snd_soc_add_dai_link() to snd_soc_add_pcm_runtime() ASoC: soc-core: rename snd_soc_remove_dai_link() to snd_soc_remove_pcm_runtime() ASoC: soc-core: move soc_link_dai_pcm_new() ASoC: soc-core: rename soc_link_dai_pcm_new() to soc_dai_pcm_new() ASoC: soc-core: move soc_link_init() ASoC: soc-core: add missing return value check for soc_link_init() ASoC: soc-core: rename soc_link_init() to soc_init_pcm_runtime() ASoC: soc-core: soc_set_name_prefix(): tidyup loop condition ASoC: soc-core: soc_set_name_prefix(): get component device_node at out of loop
include/sound/soc.h | 22 +-- sound/soc/fsl/fsl-asoc-card.c | 2 +- sound/soc/pxa/mioa701_wm9713.c | 2 +- sound/soc/samsung/bells.c | 12 +- sound/soc/samsung/littlemill.c | 10 +- sound/soc/samsung/snow.c | 2 +- sound/soc/samsung/speyside.c | 4 +- sound/soc/samsung/tm2_wm5110.c | 6 +- sound/soc/samsung/tobermory.c | 6 +- sound/soc/sh/rcar/core.c | 2 - sound/soc/soc-core.c | 339 ++++++++++++++++------------------------- sound/soc/soc-topology.c | 47 +++++- sound/soc/tegra/tegra_wm8903.c | 2 +- 13 files changed, 204 insertions(+), 252 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
ASoC is using many lists. Now, used dai_link is listed to card as dai_link_list.
[card]->[dai_link]->[dai_link]->...
BTW, this "dai_link" is used to create "rtd". And this rtd is listed to card as rtd_list.
[card]->[rtd]->[rtd]->...
Here, each rtd has dai_link. This means, we can track all dai_link via rtd list. This patch removes card dai_link_list, and uses rtd_list instead of it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- include/sound/soc.h | 7 ------- sound/soc/soc-core.c | 17 +++++++---------- 2 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index c28a1ed..b7ba3b9 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -852,7 +852,6 @@ struct snd_soc_dai_link { /* Do not create a PCM for this DAI link (Backend link) */ unsigned int ignore:1;
- struct list_head list; /* DAI link list of the soc card */ #ifdef CONFIG_SND_SOC_TOPOLOGY struct snd_soc_dobj dobj; /* For topology */ #endif @@ -1037,7 +1036,6 @@ struct snd_soc_card { /* CPU <--> Codec DAI links */ struct snd_soc_dai_link *dai_link; /* predefined links only */ int num_links; /* predefined links only */ - struct list_head dai_link_list; /* all links */
struct list_head rtd_list; int num_rtd; @@ -1107,11 +1105,6 @@ struct snd_soc_card { ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \ (i)++)
-#define for_each_card_links(card, link) \ - list_for_each_entry(link, &(card)->dai_link_list, list) -#define for_each_card_links_safe(card, link, _link) \ - list_for_each_entry_safe(link, _link, &(card)->dai_link_list, list) - #define for_each_card_rtds(card, rtd) \ list_for_each_entry(rtd, &(card)->rtd_list, list) #define for_each_card_rtds_safe(card, rtd, _rtd) \ diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 062653a..435a365 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -934,11 +934,14 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, int id, const char *name, const char *stream_name) { + struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *link;
lockdep_assert_held(&client_mutex);
- for_each_card_links(card, link) { + for_each_card_rtds(card, rtd) { + link = rtd->dai_link; + if (link->id != id) continue;
@@ -1075,8 +1078,6 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card, if (card->remove_dai_link) card->remove_dai_link(card, dai_link);
- list_del(&dai_link->list); - rtd = snd_soc_get_pcm_runtime(card, dai_link->name); if (rtd) soc_free_pcm_runtime(rtd); @@ -1158,9 +1159,6 @@ int snd_soc_add_dai_link(struct snd_soc_card *card, } }
- /* see for_each_card_links */ - list_add_tail(&dai_link->list, &card->dai_link_list); - return 0;
_err_defer: @@ -1931,7 +1929,7 @@ static void __soc_setup_card_name(char *name, int len, static void soc_cleanup_card_resources(struct snd_soc_card *card, int card_probed) { - struct snd_soc_dai_link *link, *_link; + struct snd_soc_pcm_runtime *rtd, *n;
if (card->snd_card) snd_card_disconnect_sync(card->snd_card); @@ -1942,8 +1940,8 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card, soc_remove_link_dais(card); soc_remove_link_components(card);
- for_each_card_links_safe(card, link, _link) - snd_soc_remove_dai_link(card, link); + for_each_card_rtds_safe(card, rtd, n) + snd_soc_remove_dai_link(card, rtd->dai_link);
/* remove auxiliary devices */ soc_remove_aux_devices(card); @@ -2393,7 +2391,6 @@ int snd_soc_register_card(struct snd_soc_card *card) INIT_LIST_HEAD(&card->aux_comp_list); INIT_LIST_HEAD(&card->component_dev_list); INIT_LIST_HEAD(&card->list); - INIT_LIST_HEAD(&card->dai_link_list); INIT_LIST_HEAD(&card->rtd_list); INIT_LIST_HEAD(&card->dapm_dirty); INIT_LIST_HEAD(&card->dobj_list);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Sound card disconnecting operation was needed when "sound driver" was unbinded without unbinding "sound card". In such case, sound driver should be stopped even though it was playbacking/capturing. Otherwise clock open/close counter mismatch happen.
One headache was that we can't skip unbind in error case because unbind operation doesn't check return value from each drivers. snd_soc_disconnect_sync() was added for these purpose, and Renesas sound card only is used it.
But now, ALSA SoC automatically disconnect sound card when sound driver was unbinded. Thus, snd_soc_disconnect_sync() is no longer needed. This patch removes it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - no change
sound/soc/sh/rcar/core.c | 2 -- sound/soc/soc-core.c | 12 ------------ 2 files changed, 14 deletions(-)
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index fc32cbb..35a6592 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1808,8 +1808,6 @@ static int rsnd_remove(struct platform_device *pdev) }; int ret = 0, i;
- snd_soc_disconnect_sync(&pdev->dev); - pm_runtime_disable(&pdev->dev);
for_each_rsnd_dai(rdai, priv, i) { diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 435a365..eeddd2c 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1444,18 +1444,6 @@ static int soc_probe_link_components(struct snd_soc_card *card) return 0; }
-void snd_soc_disconnect_sync(struct device *dev) -{ - struct snd_soc_component *component = - snd_soc_lookup_component(dev, NULL); - - if (!component || !component->card) - return; - - snd_card_disconnect_sync(component->card->snd_card); -} -EXPORT_SYMBOL_GPL(snd_soc_disconnect_sync); - static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, struct snd_soc_pcm_runtime *rtd) {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
No driver is using snd_soc_get_dai_substream(), and snd_soc_get_pcm_runtime() is enough for such purpose. We can revival it if it was needed in the future. Let's remove unused function.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - no change
include/sound/soc.h | 2 -- sound/soc/soc-core.c | 15 --------------- 2 files changed, 17 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index b7ba3b9..68ec5a0 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -464,8 +464,6 @@ static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
void snd_soc_disconnect_sync(struct device *dev);
-struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, - const char *dai_link, int stream); struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, const char *dai_link);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index eeddd2c..d6118cf 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -389,21 +389,6 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev, } EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
-struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, - const char *dai_link, int stream) -{ - struct snd_soc_pcm_runtime *rtd; - - for_each_card_rtds(card, rtd) { - if (rtd->dai_link->no_pcm && - !strcmp(rtd->dai_link->name, dai_link)) - return rtd->pcm->streams[stream].substream; - } - dev_dbg(card->dev, "ASoC: failed to find dai link %s\n", dai_link); - return NULL; -} -EXPORT_SYMBOL_GPL(snd_soc_get_dai_substream); - static const struct snd_soc_ops null_snd_soc_ops;
static void soc_release_rtd_dev(struct device *dev)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
This patch moves snd_soc_get_pcm_runtime() next to snd_soc_get_dai_substream(). This is prepare for snd_soc_get_pcm_runtime() cleanup.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - remove unneeded white-line - fixup git-log explanation
sound/soc/soc-core.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d6118cf..0081b65 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -391,6 +391,21 @@ EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
static const struct snd_soc_ops null_snd_soc_ops;
+struct snd_soc_pcm_runtime +*snd_soc_get_pcm_runtime(struct snd_soc_card *card, + const char *dai_link) +{ + struct snd_soc_pcm_runtime *rtd; + + for_each_card_rtds(card, rtd) { + if (!strcmp(rtd->dai_link->name, dai_link)) + return rtd; + } + dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link); + return NULL; +} +EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime); + static void soc_release_rtd_dev(struct device *dev) { /* "dev" means "rtd->dev" */ @@ -491,20 +506,6 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( return NULL; }
-struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, - const char *dai_link) -{ - struct snd_soc_pcm_runtime *rtd; - - for_each_card_rtds(card, rtd) { - if (!strcmp(rtd->dai_link->name, dai_link)) - return rtd; - } - dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link); - return NULL; -} -EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime); - static void snd_soc_flush_all_delayed_work(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current snd_soc_get_pcm_runtime() is finding rtd by checking dai_link name. But, it is strange and waste of CPU power, because its user want to get from rtd from dai_link, not from dai_link name. This patch find rtd via dai_link pointer instead of its name.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - no change
include/sound/soc.h | 2 +- sound/soc/fsl/fsl-asoc-card.c | 2 +- sound/soc/pxa/mioa701_wm9713.c | 2 +- sound/soc/samsung/bells.c | 12 ++++++------ sound/soc/samsung/littlemill.c | 10 +++++----- sound/soc/samsung/snow.c | 2 +- sound/soc/samsung/speyside.c | 4 ++-- sound/soc/samsung/tm2_wm5110.c | 6 +++--- sound/soc/samsung/tobermory.c | 6 +++--- sound/soc/soc-core.c | 8 ++++---- sound/soc/tegra/tegra_wm8903.c | 2 +- 11 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 68ec5a0..40c2a67 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -465,7 +465,7 @@ static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) void snd_soc_disconnect_sync(struct device *dev);
struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, - const char *dai_link); + struct snd_soc_dai_link *dai_link);
bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd); void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream); diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 39ea9bd..9ce55fe 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -256,7 +256,7 @@ static int fsl_asoc_card_set_bias_level(struct snd_soc_card *card, unsigned int pll_out; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); codec_dai = rtd->codec_dai; if (dapm->dev != codec_dai->dev) return 0; diff --git a/sound/soc/pxa/mioa701_wm9713.c b/sound/soc/pxa/mioa701_wm9713.c index 129eb52..76e054d 100644 --- a/sound/soc/pxa/mioa701_wm9713.c +++ b/sound/soc/pxa/mioa701_wm9713.c @@ -72,7 +72,7 @@ static int rear_amp_event(struct snd_soc_dapm_widget *widget, struct snd_soc_pcm_runtime *rtd; struct snd_soc_component *component;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); component = rtd->codec_dai->component; return rear_amp_power(component, SND_SOC_DAPM_EVENT_ON(event)); } diff --git a/sound/soc/samsung/bells.c b/sound/soc/samsung/bells.c index b60b226..58d8a81 100644 --- a/sound/soc/samsung/bells.c +++ b/sound/soc/samsung/bells.c @@ -59,7 +59,7 @@ static int bells_set_bias_level(struct snd_soc_card *card, struct bells_drvdata *bells = card->drvdata; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]); codec_dai = rtd->codec_dai; component = codec_dai->component;
@@ -105,7 +105,7 @@ static int bells_set_bias_level_post(struct snd_soc_card *card, struct bells_drvdata *bells = card->drvdata; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]); codec_dai = rtd->codec_dai; component = codec_dai->component;
@@ -151,10 +151,10 @@ static int bells_late_probe(struct snd_soc_card *card) struct snd_soc_dai *wm9081_dai; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_AP_DSP].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_AP_DSP]); wm0010 = rtd->codec_dai->component;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]); component = rtd->codec_dai->component; aif1_dai = rtd->codec_dai;
@@ -194,7 +194,7 @@ static int bells_late_probe(struct snd_soc_card *card) return ret; }
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_CODEC_CP].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_CODEC_CP]); aif2_dai = rtd->cpu_dai;
ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0); @@ -206,7 +206,7 @@ static int bells_late_probe(struct snd_soc_card *card) if (card->num_rtd == DAI_CODEC_SUB) return 0;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_CODEC_SUB].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_CODEC_SUB]); aif3_dai = rtd->cpu_dai; wm9081_dai = rtd->codec_dai;
diff --git a/sound/soc/samsung/littlemill.c b/sound/soc/samsung/littlemill.c index 6132cee..59904f4 100644 --- a/sound/soc/samsung/littlemill.c +++ b/sound/soc/samsung/littlemill.c @@ -22,7 +22,7 @@ static int littlemill_set_bias_level(struct snd_soc_card *card, struct snd_soc_dai *aif1_dai; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); aif1_dai = rtd->codec_dai;
if (dapm->dev != aif1_dai->dev) @@ -69,7 +69,7 @@ static int littlemill_set_bias_level_post(struct snd_soc_card *card, struct snd_soc_dai *aif1_dai; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); aif1_dai = rtd->codec_dai;
if (dapm->dev != aif1_dai->dev) @@ -180,7 +180,7 @@ static int bbclk_ev(struct snd_soc_dapm_widget *w, struct snd_soc_dai *aif2_dai; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]); aif2_dai = rtd->cpu_dai;
switch (event) { @@ -263,11 +263,11 @@ static int littlemill_late_probe(struct snd_soc_card *card) struct snd_soc_dai *aif2_dai; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); component = rtd->codec_dai->component; aif1_dai = rtd->codec_dai;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]); aif2_dai = rtd->cpu_dai;
ret = snd_soc_dai_set_sysclk(aif1_dai, WM8994_SYSCLK_MCLK2, diff --git a/sound/soc/samsung/snow.c b/sound/soc/samsung/snow.c index 8ea7799..f075aae 100644 --- a/sound/soc/samsung/snow.c +++ b/sound/soc/samsung/snow.c @@ -106,7 +106,7 @@ static int snow_late_probe(struct snd_soc_card *card) struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai *codec_dai;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
/* In the multi-codec case codec_dais 0 is MAX98095 and 1 is HDMI. */ if (rtd->num_codecs > 1) diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c index 9e58cbe..5ccdfe0 100644 --- a/sound/soc/samsung/speyside.c +++ b/sound/soc/samsung/speyside.c @@ -24,7 +24,7 @@ static int speyside_set_bias_level(struct snd_soc_card *card, struct snd_soc_dai *codec_dai; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]); codec_dai = rtd->codec_dai;
if (dapm->dev != codec_dai->dev) @@ -60,7 +60,7 @@ static int speyside_set_bias_level_post(struct snd_soc_card *card, struct snd_soc_dai *codec_dai; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]); codec_dai = rtd->codec_dai;
if (dapm->dev != codec_dai->dev) diff --git a/sound/soc/samsung/tm2_wm5110.c b/sound/soc/samsung/tm2_wm5110.c index bb9910d..10ff14b8 100644 --- a/sound/soc/samsung/tm2_wm5110.c +++ b/sound/soc/samsung/tm2_wm5110.c @@ -282,7 +282,7 @@ static int tm2_set_bias_level(struct snd_soc_card *card, { struct snd_soc_pcm_runtime *rtd;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
if (dapm->dev != rtd->codec_dai->dev) return 0; @@ -314,7 +314,7 @@ static int tm2_late_probe(struct snd_soc_card *card) struct snd_soc_dai *aif2_dai; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[TM2_DAI_AIF1].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[TM2_DAI_AIF1]); aif1_dai = rtd->codec_dai; priv->component = rtd->codec_dai->component;
@@ -324,7 +324,7 @@ static int tm2_late_probe(struct snd_soc_card *card) return ret; }
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[TM2_DAI_AIF2].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[TM2_DAI_AIF2]); aif2_dai = rtd->codec_dai;
ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0); diff --git a/sound/soc/samsung/tobermory.c b/sound/soc/samsung/tobermory.c index ef51f28..fdce28c 100644 --- a/sound/soc/samsung/tobermory.c +++ b/sound/soc/samsung/tobermory.c @@ -22,7 +22,7 @@ static int tobermory_set_bias_level(struct snd_soc_card *card, struct snd_soc_dai *codec_dai; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); codec_dai = rtd->codec_dai;
if (dapm->dev != codec_dai->dev) @@ -65,7 +65,7 @@ static int tobermory_set_bias_level_post(struct snd_soc_card *card, struct snd_soc_dai *codec_dai; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); codec_dai = rtd->codec_dai;
if (dapm->dev != codec_dai->dev) @@ -180,7 +180,7 @@ static int tobermory_late_probe(struct snd_soc_card *card) struct snd_soc_dai *codec_dai; int ret;
- rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); component = rtd->codec_dai->component; codec_dai = rtd->codec_dai;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0081b65..3373615 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -393,15 +393,15 @@ static const struct snd_soc_ops null_snd_soc_ops;
struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, - const char *dai_link) + struct snd_soc_dai_link *dai_link) { struct snd_soc_pcm_runtime *rtd;
for_each_card_rtds(card, rtd) { - if (!strcmp(rtd->dai_link->name, dai_link)) + if (rtd->dai_link == dai_link) return rtd; } - dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link); + dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link->name); return NULL; } EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime); @@ -1064,7 +1064,7 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card, if (card->remove_dai_link) card->remove_dai_link(card, dai_link);
- rtd = snd_soc_get_pcm_runtime(card, dai_link->name); + rtd = snd_soc_get_pcm_runtime(card, dai_link); if (rtd) soc_free_pcm_runtime(rtd); } diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c index 6211dfd..f08d348 100644 --- a/sound/soc/tegra/tegra_wm8903.c +++ b/sound/soc/tegra/tegra_wm8903.c @@ -186,7 +186,7 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) static int tegra_wm8903_remove(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd = - snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + snd_soc_get_pcm_runtime(card, &card->dai_link[0]); struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_component *component = codec_dai->component;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
snd_soc_find_dai_link() is soc-topology specific function. We don't need to have it at soc-core. This patch moves it to soc-topology.c
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - no change
include/sound/soc.h | 3 --- sound/soc/soc-core.c | 44 -------------------------------------------- sound/soc/soc-topology.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 47 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 40c2a67..09d3d9b 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1327,9 +1327,6 @@ int snd_soc_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); void snd_soc_remove_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); -struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, - int id, const char *name, - const char *stream_name);
struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, struct snd_soc_dai_driver *dai_drv, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3373615..3221e776 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -901,50 +901,6 @@ struct snd_soc_dai *snd_soc_find_dai( } EXPORT_SYMBOL_GPL(snd_soc_find_dai);
-/** - * snd_soc_find_dai_link - Find a DAI link - * - * @card: soc card - * @id: DAI link ID to match - * @name: DAI link name to match, optional - * @stream_name: DAI link stream name to match, optional - * - * This function will search all existing DAI links of the soc card to - * find the link of the same ID. Since DAI links may not have their - * unique ID, so name and stream name should also match if being - * specified. - * - * Return: pointer of DAI link, or NULL if not found. - */ -struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, - int id, const char *name, - const char *stream_name) -{ - struct snd_soc_pcm_runtime *rtd; - struct snd_soc_dai_link *link; - - lockdep_assert_held(&client_mutex); - - for_each_card_rtds(card, rtd) { - link = rtd->dai_link; - - if (link->id != id) - continue; - - if (name && (!link->name || strcmp(name, link->name))) - continue; - - if (stream_name && (!link->stream_name - || strcmp(stream_name, link->stream_name))) - continue; - - return link; - } - - return NULL; -} -EXPORT_SYMBOL_GPL(snd_soc_find_dai_link); - static int soc_dai_link_sanity_check(struct snd_soc_card *card, struct snd_soc_dai_link *link) { diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 81d2af0..cbd605b 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -2207,6 +2207,47 @@ static int link_new_ver(struct soc_tplg *tplg, return 0; }
+/** + * snd_soc_find_dai_link - Find a DAI link + * + * @card: soc card + * @id: DAI link ID to match + * @name: DAI link name to match, optional + * @stream_name: DAI link stream name to match, optional + * + * This function will search all existing DAI links of the soc card to + * find the link of the same ID. Since DAI links may not have their + * unique ID, so name and stream name should also match if being + * specified. + * + * Return: pointer of DAI link, or NULL if not found. + */ +static struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, + int id, const char *name, + const char *stream_name) +{ + struct snd_soc_pcm_runtime *rtd; + struct snd_soc_dai_link *link; + + for_each_card_rtds(card, rtd) { + link = rtd->dai_link; + + if (link->id != id) + continue; + + if (name && (!link->name || strcmp(name, link->name))) + continue; + + if (stream_name && (!link->stream_name + || strcmp(stream_name, link->stream_name))) + continue; + + return link; + } + + return NULL; +} + /* Find and configure an existing physical DAI link */ static int soc_tplg_link_config(struct soc_tplg *tplg, struct snd_soc_tplg_link_config *cfg)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Now soc-core and soc-topology is using snd_soc_add_dai_link(). The abstract of this function is "create pcm_runtime from dai_link information and connect it to card". Thus, "add dai_link" is wrong/confusable naming. This patch renames function name.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - tidyup git-log explanation
include/sound/soc.h | 4 ++-- sound/soc/soc-core.c | 18 +++++++++--------- sound/soc/soc-topology.c | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 09d3d9b..b223b2d 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1323,8 +1323,8 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev, struct snd_soc_dai_link *dai_link); void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
-int snd_soc_add_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link); +int snd_soc_add_pcm_runtime(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link); void snd_soc_remove_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3221e776..e1818bf 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1027,18 +1027,18 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card, EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link);
/** - * snd_soc_add_dai_link - Add a DAI link dynamically - * @card: The ASoC card to which the DAI link is added - * @dai_link: The new DAI link to add + * snd_soc_add_pcm_runtime - Add a pcm_runtime dynamically via dai_link + * @card: The ASoC card to which the pcm_runtime is added + * @dai_link: The DAI link to find pcm_runtime * - * This function adds a DAI link to the ASoC card's link list. + * This function adds a pcm_runtime ASoC card by using dai_link. * - * Note: Topology can use this API to add DAI links when probing the + * Note: Topology can use this API to add pcm_runtime when probing the * topology component. And machine drivers can still define static * DAI links in dai_link array. */ -int snd_soc_add_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) +int snd_soc_add_pcm_runtime(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link) { struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link_component *codec, *platform; @@ -1107,7 +1107,7 @@ int snd_soc_add_dai_link(struct snd_soc_card *card, soc_free_pcm_runtime(rtd); return -EPROBE_DEFER; } -EXPORT_SYMBOL_GPL(snd_soc_add_dai_link); +EXPORT_SYMBOL_GPL(snd_soc_add_pcm_runtime);
static void soc_set_of_name_prefix(struct snd_soc_component *component) { @@ -1929,7 +1929,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) /* add predefined DAI links to the list */ card->num_rtd = 0; for_each_card_prelinks(card, i, dai_link) { - ret = snd_soc_add_dai_link(card, dai_link); + ret = snd_soc_add_pcm_runtime(card, dai_link); if (ret < 0) goto probe_end; } diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index cbd605b..de42788 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1945,7 +1945,7 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg, link->dobj.type = SND_SOC_DOBJ_DAI_LINK; list_add(&link->dobj.list, &tplg->comp->dobj_list);
- snd_soc_add_dai_link(tplg->comp->card, link); + snd_soc_add_pcm_runtime(tplg->comp->card, link); return 0; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Now soc-core and soc-topology is using snd_soc_remove_dai_link(). It removes pcm_runtime (= rtd) and disconnect it from card. The purpose is removing pcm_runtime, not dai_link. This patch renames function name.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - no change
include/sound/soc.h | 4 ++-- sound/soc/soc-core.c | 29 +++++++++++------------------ sound/soc/soc-topology.c | 4 +++- 3 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index b223b2d..3923178 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1325,8 +1325,8 @@ void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
int snd_soc_add_pcm_runtime(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); -void snd_soc_remove_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link); +void snd_soc_remove_pcm_runtime(struct snd_soc_card *card, + struct snd_soc_pcm_runtime *rtd);
struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, struct snd_soc_dai_driver *dai_drv, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e1818bf..2827073 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -998,33 +998,26 @@ static int soc_dai_link_sanity_check(struct snd_soc_card *card, }
/** - * snd_soc_remove_dai_link - Remove a DAI link from the list - * @card: The ASoC card that owns the link - * @dai_link: The DAI link to remove + * snd_soc_remove_pcm_runtime - Remove a pcm_runtime from card + * @card: The ASoC card to which the pcm_runtime has + * @rtd: The pcm_runtime to remove * - * This function removes a DAI link from the ASoC card's link list. - * - * For DAI links previously added by topology, topology should - * remove them by using the dobj embedded in the link. + * This function removes a pcm_runtime from the ASoC card. */ -void snd_soc_remove_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) +void snd_soc_remove_pcm_runtime(struct snd_soc_card *card, + struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_pcm_runtime *rtd; - lockdep_assert_held(&client_mutex);
/* * Notify the machine driver for extra destruction */ if (card->remove_dai_link) - card->remove_dai_link(card, dai_link); + card->remove_dai_link(card, rtd->dai_link);
- rtd = snd_soc_get_pcm_runtime(card, dai_link); - if (rtd) - soc_free_pcm_runtime(rtd); + soc_free_pcm_runtime(rtd); } -EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link); +EXPORT_SYMBOL_GPL(snd_soc_remove_pcm_runtime);
/** * snd_soc_add_pcm_runtime - Add a pcm_runtime dynamically via dai_link @@ -1104,7 +1097,7 @@ int snd_soc_add_pcm_runtime(struct snd_soc_card *card, return 0;
_err_defer: - soc_free_pcm_runtime(rtd); + snd_soc_remove_pcm_runtime(card, rtd); return -EPROBE_DEFER; } EXPORT_SYMBOL_GPL(snd_soc_add_pcm_runtime); @@ -1871,7 +1864,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card, soc_remove_link_components(card);
for_each_card_rtds_safe(card, rtd, n) - snd_soc_remove_dai_link(card, rtd->dai_link); + snd_soc_remove_pcm_runtime(card, rtd);
/* remove auxiliary devices */ soc_remove_aux_devices(card); diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index de42788..e9b660f 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -553,7 +553,9 @@ static void remove_link(struct snd_soc_component *comp, kfree(link->cpus->dai_name);
list_del(&dobj->list); - snd_soc_remove_dai_link(comp->card, link); + + snd_soc_remove_pcm_runtime(comp->card, + snd_soc_get_pcm_runtime(comp->card, link)); kfree(link); }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
This patch moves soc_link_dai_pcm_new() to upper side. This is prepare for its cleanup.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - no change
sound/soc/soc-core.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 2827073..ded678f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1102,6 +1102,27 @@ int snd_soc_add_pcm_runtime(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(snd_soc_add_pcm_runtime);
+static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, + struct snd_soc_pcm_runtime *rtd) +{ + int i, ret = 0; + + for (i = 0; i < num_dais; ++i) { + struct snd_soc_dai_driver *drv = dais[i]->driver; + + if (drv->pcm_new) + ret = drv->pcm_new(rtd, dais[i]); + if (ret < 0) { + dev_err(dais[i]->dev, + "ASoC: Failed to bind %s with pcm device\n", + dais[i]->name); + return ret; + } + } + + return 0; +} + static void soc_set_of_name_prefix(struct snd_soc_component *component) { struct device_node *of_node = soc_component_to_node(component); @@ -1379,27 +1400,6 @@ static int soc_probe_link_components(struct snd_soc_card *card) return 0; }
-static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, - struct snd_soc_pcm_runtime *rtd) -{ - int i, ret = 0; - - for (i = 0; i < num_dais; ++i) { - struct snd_soc_dai_driver *drv = dais[i]->driver; - - if (drv->pcm_new) - ret = drv->pcm_new(rtd, dais[i]); - if (ret < 0) { - dev_err(dais[i]->dev, - "ASoC: Failed to bind %s with pcm device\n", - dais[i]->name); - return ret; - } - } - - return 0; -} - static int soc_link_init(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd) {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
soc_link_dai_pcm_new() sounds like dai_link function, but it is not related to it. This patch rename soc_link_dai_pcm_new() to soc_dai_pcm_new().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - no change
sound/soc/soc-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index ded678f..7278903 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1102,8 +1102,8 @@ int snd_soc_add_pcm_runtime(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(snd_soc_add_pcm_runtime);
-static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, - struct snd_soc_pcm_runtime *rtd) +static int soc_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, + struct snd_soc_pcm_runtime *rtd) { int i, ret = 0;
@@ -1464,11 +1464,11 @@ static int soc_link_init(struct snd_soc_card *card, dai_link->stream_name, ret); return ret; } - ret = soc_link_dai_pcm_new(&cpu_dai, 1, rtd); + ret = soc_dai_pcm_new(&cpu_dai, 1, rtd); if (ret < 0) return ret; - ret = soc_link_dai_pcm_new(rtd->codec_dais, - rtd->num_codecs, rtd); + ret = soc_dai_pcm_new(rtd->codec_dais, + rtd->num_codecs, rtd); return ret; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
This patch moves soc_link_init() to upper side. This is prepare for its cleanup.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - no change
sound/soc/soc-core.c | 144 +++++++++++++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 72 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 7278903..79a4753 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1123,6 +1123,78 @@ static int soc_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, return 0; }
+static int soc_link_init(struct snd_soc_card *card, + struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dai_link *dai_link = rtd->dai_link; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_rtdcom_list *rtdcom; + struct snd_soc_component *component; + int ret, num; + + /* set default power off timeout */ + rtd->pmdown_time = pmdown_time; + + /* do machine specific initialization */ + if (dai_link->init) { + ret = dai_link->init(rtd); + if (ret < 0) { + dev_err(card->dev, "ASoC: failed to init %s: %d\n", + dai_link->name, ret); + return ret; + } + } + + if (dai_link->dai_fmt) { + ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt); + if (ret) + return ret; + } + + /* add DPCM sysfs entries */ + soc_dpcm_debugfs_add(rtd); + + num = rtd->num; + + /* + * most drivers will register their PCMs using DAI link ordering but + * topology based drivers can use the DAI link id field to set PCM + * device number and then use rtd + a base offset of the BEs. + */ + for_each_rtd_components(rtd, rtdcom, component) { + if (!component->driver->use_dai_pcm_id) + continue; + + if (rtd->dai_link->no_pcm) + num += component->driver->be_pcm_base; + else + num = rtd->dai_link->id; + } + + /* create compress_device if possible */ + ret = snd_soc_dai_compress_new(cpu_dai, rtd, num); + if (ret != -ENOTSUPP) { + if (ret < 0) + dev_err(card->dev, "ASoC: can't create compress %s\n", + dai_link->stream_name); + return ret; + } + + /* create the pcm */ + ret = soc_new_pcm(rtd, num); + if (ret < 0) { + dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", + dai_link->stream_name, ret); + return ret; + } + ret = soc_dai_pcm_new(&cpu_dai, 1, rtd); + if (ret < 0) + return ret; + ret = soc_dai_pcm_new(rtd->codec_dais, + rtd->num_codecs, rtd); + return ret; +} + static void soc_set_of_name_prefix(struct snd_soc_component *component) { struct device_node *of_node = soc_component_to_node(component); @@ -1400,78 +1472,6 @@ static int soc_probe_link_components(struct snd_soc_card *card) return 0; }
-static int soc_link_init(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_dai_link *dai_link = rtd->dai_link; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_rtdcom_list *rtdcom; - struct snd_soc_component *component; - int ret, num; - - /* set default power off timeout */ - rtd->pmdown_time = pmdown_time; - - /* do machine specific initialization */ - if (dai_link->init) { - ret = dai_link->init(rtd); - if (ret < 0) { - dev_err(card->dev, "ASoC: failed to init %s: %d\n", - dai_link->name, ret); - return ret; - } - } - - if (dai_link->dai_fmt) { - ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt); - if (ret) - return ret; - } - - /* add DPCM sysfs entries */ - soc_dpcm_debugfs_add(rtd); - - num = rtd->num; - - /* - * most drivers will register their PCMs using DAI link ordering but - * topology based drivers can use the DAI link id field to set PCM - * device number and then use rtd + a base offset of the BEs. - */ - for_each_rtd_components(rtd, rtdcom, component) { - if (!component->driver->use_dai_pcm_id) - continue; - - if (rtd->dai_link->no_pcm) - num += component->driver->be_pcm_base; - else - num = rtd->dai_link->id; - } - - /* create compress_device if possible */ - ret = snd_soc_dai_compress_new(cpu_dai, rtd, num); - if (ret != -ENOTSUPP) { - if (ret < 0) - dev_err(card->dev, "ASoC: can't create compress %s\n", - dai_link->stream_name); - return ret; - } - - /* create the pcm */ - ret = soc_new_pcm(rtd, num); - if (ret < 0) { - dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", - dai_link->stream_name, ret); - return ret; - } - ret = soc_dai_pcm_new(&cpu_dai, 1, rtd); - if (ret < 0) - return ret; - ret = soc_dai_pcm_new(rtd->codec_dais, - rtd->num_codecs, rtd); - return ret; -} - static void soc_unbind_aux_dev(struct snd_soc_card *card) { struct snd_soc_component *component, *_component;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
soc_link_init() returns error code, but snd_soc_bind_card() is not cheking it. This patch adds missing return value check for it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - new patch - separate "missing return check" and "function rename" from v1 patch.
sound/soc/soc-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 79a4753..bdae48e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1983,8 +1983,11 @@ static int snd_soc_bind_card(struct snd_soc_card *card) goto probe_end; }
- for_each_card_rtds(card, rtd) - soc_link_init(card, rtd); + for_each_card_rtds(card, rtd) { + ret = soc_link_init(card, rtd); + if (ret < 0) + goto probe_end; + }
snd_soc_dapm_link_dai_widgets(card); snd_soc_dapm_connect_dai_link_widgets(card);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 79a4753..bdae48e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1983,8 +1983,11 @@ static int snd_soc_bind_card(struct snd_soc_card *card) goto probe_end; }
- for_each_card_rtds(card, rtd)
soc_link_init(card, rtd);
- for_each_card_rtds(card, rtd) {
ret = soc_link_init(card, rtd);
if (ret < 0)
goto probe_end;
- }
Morimoto-san, this patch proves very useful to avoid a kernel oops when a dailink init fails, but I still see a warning when cleaning-up.
I was experimenting with a topology file that wasn't complete and came across the warning below, would you have any ideas/recommendations on what might be missing? I am running out of time this week so thought I would ask, in case this rings a bell.
Thanks!
[ 21.098662] bytcr_rt5640 bytcr_rt5640: ASoC: no source widget found for modem_out [ 21.098677] bytcr_rt5640 bytcr_rt5640: ASoC: Failed to add route modem_out -> direct -> ssp0 Tx [ 21.098694] bytcr_rt5640 bytcr_rt5640: ASoC: no sink widget found for modem_in [ 21.098703] bytcr_rt5640 bytcr_rt5640: ASoC: Failed to add route ssp0 Rx -> direct -> modem_in [ 21.098732] bytcr_rt5640 bytcr_rt5640: ASoC: failed to init SSP2-Codec: -19
<<< this is the dailink init failure due to missing routes
[ 21.098790] ------------[ cut here ]------------ [ 21.098807] WARNING: CPU: 3 PID: 1028 at kernel/workqueue.c:3031 __flush_work+0x1a3/0x1c0 [ 21.098809] Modules linked in: snd_soc_sst_bytcr_rt5640(+) snd_sof_acpi snd_sof_intel_byt snd_soc_acpi_intel_match snd_sof_intel_bdw snd_sof_intel_ipc snd_sof snd_sof_xtensa_dsp snd_soc_acpi ax88179_178a usbnet intel_soc_dts_thermal intel_powerclamp hid_multitouch mei_txe mei wmi snd_soc_rt5640 snd_soc_rl6231 int3406_thermal snd_soc_core processor_thermal_device int3403_thermal intel_soc_dts_iosf int3400_thermal snd_pcm int340x_thermal_zone acpi_thermal_rel snd_timer snd soundcore efivarfs mmc_block i915 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops xhci_pci drm xhci_hcd i2c_hid sdhci_acpi sdhci [ 21.098877] CPU: 3 PID: 1028 Comm: systemd-udevd Not tainted 5.4.0-rc8-test+ #15 [ 21.098880] Hardware name: ASUSTeK COMPUTER INC. T100TAF/T100TAF, BIOS T100TAF.207 09/10/2014 [ 21.098889] RIP: 0010:__flush_work+0x1a3/0x1c0 [ 21.098896] Code: ff ff 41 c6 04 24 00 fb 45 31 f6 eb 8e 8b 0b 48 8b 53 08 83 e1 08 48 0f ba 2b 03 80 c9 f0 e9 5d ff ff ff 0f 0b e9 71 ff ff ff <0f> 0b 45 31 f6 e9 67 ff ff ff e8 de 2f fe ff 66 66 2e 0f 1f 84 00 [ 21.098901] RSP: 0018:ffff9e05804cf910 EFLAGS: 00010246 [ 21.098906] RAX: 0000000000000000 RBX: ffff8add3859c640 RCX: ffffffffc0748248 [ 21.098910] RDX: 0000000000000001 RSI: 0000000000000000 RDI: ffff8add3859c640 [ 21.098913] RBP: 0000000000000000 R08: 0000000000000000 R09: ffff8add3679ae00 [ 21.098917] R10: ffff8add35ff5840 R11: ffff9e05804cf7bd R12: ffff8add37558ed8 [ 21.098921] R13: ffff8add37558e28 R14: 0000000000000001 R15: ffff8add36d36610 [ 21.098926] FS: 00007f3ce09c7d40(0000) GS:ffff8add39580000(0000) knlGS:0000000000000000 [ 21.098930] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 21.098934] CR2: 0000561745975f10 CR3: 0000000076f26000 CR4: 00000000001006e0 [ 21.098937] Call Trace: [ 21.098951] ? try_to_del_timer_sync+0x4a/0x80 [ 21.098973] soc_free_pcm_runtime.part.0+0x38/0x50 [snd_soc_core] [ 21.098994] snd_soc_tplg_component_remove+0x2f5/0x4f0 [snd_soc_core] [ 21.099015] soc_remove_component+0x76/0x80 [snd_soc_core] [ 21.099033] soc_cleanup_card_resources+0x100/0x2b0 [snd_soc_core] [ 21.099051] snd_soc_bind_card+0x1f5/0xa00 [snd_soc_core] [ 21.099073] devm_snd_soc_register_card+0x3e/0x80 [snd_soc_core] [ 21.099094] snd_byt_rt5640_mc_probe.cold+0x4d3/0x55a [snd_soc_sst_bytcr_rt5640] [ 21.099110] platform_drv_probe+0x30/0x80 [ 21.099120] really_probe+0x293/0x3c0 [ 21.099130] driver_probe_device+0xb1/0x100 [ 21.099139] device_driver_attach+0x4e/0x60 [ 21.099148] __driver_attach+0x85/0x140 [ 21.099157] ? device_driver_attach+0x60/0x60 [ 21.099164] bus_for_each_dev+0x73/0xb0 [ 21.099174] bus_add_driver+0x148/0x1e0 [ 21.099183] driver_register+0x67/0xb0 [ 21.099191] ? 0xffffffffc042b000 [ 21.099199] do_one_initcall+0x41/0x1df [ 21.099207] ? __schedule+0x28c/0x5a0 [ 21.099217] ? free_vmap_area_noflush+0x8d/0xe0 [ 21.099223] ? _cond_resched+0x10/0x20 [ 21.099232] ? kmem_cache_alloc_trace+0x3a/0x1b0 [ 21.099243] do_init_module+0x56/0x200 [ 21.099252] load_module+0x243a/0x2730 [ 21.099268] ? __do_sys_finit_module+0xaa/0x110 [ 21.099276] __do_sys_finit_module+0xaa/0x110 [ 21.099287] do_syscall_64+0x43/0x110 [ 21.099297] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 21.099304] RIP: 0033:0x7f3ce11b1f59 [ 21.099312] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 07 6f 0c 00 f7 d8 64 89 01 48 [ 21.099316] RSP: 002b:00007ffde804cc38 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 [ 21.099324] RAX: ffffffffffffffda RBX: 000055a55f902bf0 RCX: 00007f3ce11b1f59 [ 21.099328] RDX: 0000000000000000 RSI: 00007f3ce10b6cad RDI: 0000000000000006 [ 21.099332] RBP: 00007f3ce10b6cad R08: 0000000000000000 R09: 0000000000000000 [ 21.099336] R10: 0000000000000006 R11: 0000000000000246 R12: 0000000000000000 [ 21.099341] R13: 000055a55f8f0940 R14: 0000000000020000 R15: 000055a55f902bf0 [ 21.099348] ---[ end trace c7c2a98f406474f6 ]--- [ 21.099452] ------------[ cut here ]------------
Hi Pierre-Louis
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 79a4753..bdae48e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1983,8 +1983,11 @@ static int snd_soc_bind_card(struct snd_soc_card *card) goto probe_end; }
- for_each_card_rtds(card, rtd)
soc_link_init(card, rtd);
- for_each_card_rtds(card, rtd) {
ret = soc_link_init(card, rtd);
if (ret < 0)
goto probe_end;
- }
Morimoto-san, this patch proves very useful to avoid a kernel oops when a dailink init fails, but I still see a warning when cleaning-up.
I was experimenting with a topology file that wasn't complete and came across the warning below, would you have any ideas/recommendations on what might be missing? I am running out of time this week so thought I would ask, in case this rings a bell.
Thanks!
[ 21.098662] bytcr_rt5640 bytcr_rt5640: ASoC: no source widget found for modem_out [ 21.098677] bytcr_rt5640 bytcr_rt5640: ASoC: Failed to add route modem_out -> direct -> ssp0 Tx [ 21.098694] bytcr_rt5640 bytcr_rt5640: ASoC: no sink widget found for modem_in [ 21.098703] bytcr_rt5640 bytcr_rt5640: ASoC: Failed to add route ssp0 Rx -> direct -> modem_in [ 21.098732] bytcr_rt5640 bytcr_rt5640: ASoC: failed to init SSP2-Codec: -19
Do you mean, it could save you from Oops, but you still have warning ?
It seems soc-dapm::snd_soc_dapm_add_routes() failed. Your kernel is missing widget route/path ? Or, sound card driver has some issue ?
I have been faced this error many times. I don't remember detail, but, if my memory was correct, it was always card driver setup timing, or missing something, in my case.
Thank you for your help !! Best regards --- Kuninori Morimoto
On 11/27/19 12:48 AM, Kuninori Morimoto wrote:
Hi Pierre-Louis
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 79a4753..bdae48e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1983,8 +1983,11 @@ static int snd_soc_bind_card(struct snd_soc_card *card) goto probe_end; }
- for_each_card_rtds(card, rtd)
soc_link_init(card, rtd);
- for_each_card_rtds(card, rtd) {
ret = soc_link_init(card, rtd);
if (ret < 0)
goto probe_end;
- }
Morimoto-san, this patch proves very useful to avoid a kernel oops when a dailink init fails, but I still see a warning when cleaning-up.
I was experimenting with a topology file that wasn't complete and came across the warning below, would you have any ideas/recommendations on what might be missing? I am running out of time this week so thought I would ask, in case this rings a bell.
Thanks!
[ 21.098662] bytcr_rt5640 bytcr_rt5640: ASoC: no source widget found for modem_out [ 21.098677] bytcr_rt5640 bytcr_rt5640: ASoC: Failed to add route modem_out -> direct -> ssp0 Tx [ 21.098694] bytcr_rt5640 bytcr_rt5640: ASoC: no sink widget found for modem_in [ 21.098703] bytcr_rt5640 bytcr_rt5640: ASoC: Failed to add route ssp0 Rx -> direct -> modem_in [ 21.098732] bytcr_rt5640 bytcr_rt5640: ASoC: failed to init SSP2-Codec: -19
Do you mean, it could save you from Oops, but you still have warning ?
Correct.
It seems soc-dapm::snd_soc_dapm_add_routes() failed. Your kernel is missing widget route/path ? Or, sound card driver has some issue ?
I have been faced this error many times. I don't remember detail, but, if my memory was correct, it was always card driver setup timing, or missing something, in my case.
In this case it's a bad topology that does not contain widgets that the machine driver uses. Still that should be handled gracefully without warnings.
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
soc-core is using soc_link_init(). It sounds like dai_link function, but it is for pcm_runtime. This patch renames soc_link_init() to soc_init_pcm_runtime().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - separate "missing return check" and "rename function" - This is for "rename function"
sound/soc/soc-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index bdae48e..6396556 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1123,8 +1123,8 @@ static int soc_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, return 0; }
-static int soc_link_init(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd) +static int soc_init_pcm_runtime(struct snd_soc_card *card, + struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -1984,7 +1984,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) }
for_each_card_rtds(card, rtd) { - ret = soc_link_init(card, rtd); + ret = soc_init_pcm_runtime(card, rtd); if (ret < 0) goto probe_end; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current soc_set_name_prefix() for loop is checking both codec_conf pointer and its number
for (...; i < card->num_configs && card->codec_conf; ...)
But, if card->num_configs exists but card->codec_conf was NULL, it is just bug. This patch cleanups for loop condition.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - no change
sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 6396556..057c97c 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1211,7 +1211,7 @@ static void soc_set_name_prefix(struct snd_soc_card *card, { int i;
- for (i = 0; i < card->num_configs && card->codec_conf; i++) { + for (i = 0; i < card->num_configs; i++) { struct snd_soc_codec_conf *map = &card->codec_conf[i]; struct device_node *of_node = soc_component_to_node(component);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Component device_node is not related to codec_conf loop at soc_set_name_prefix(). This patch moves it to out of loop.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- v1 -> v2 - no change
sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 057c97c..0180d3a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1209,11 +1209,11 @@ static void soc_set_of_name_prefix(struct snd_soc_component *component) static void soc_set_name_prefix(struct snd_soc_card *card, struct snd_soc_component *component) { + struct device_node *of_node = soc_component_to_node(component); int i;
for (i = 0; i < card->num_configs; i++) { struct snd_soc_codec_conf *map = &card->codec_conf[i]; - struct device_node *of_node = soc_component_to_node(component);
if (map->of_node && of_node != map->of_node) continue;
On 11/24/19 6:42 PM, Kuninori Morimoto wrote:
Hi Mark
These are v2 of soc-core cleanup step6. These doesn't add new features.
Kuninori Morimoto (15): ASoC: soc-core: remove dai_link_list ASoC: soc-core: remove snd_soc_disconnect_sync() ASoC: soc-core: remove snd_soc_get_dai_substream() ASoC: soc-core: move snd_soc_get_pcm_runtime() ASoC: soc-core: find rtd via dai_link pointer at snd_soc_get_pcm_runtime() ASoC: soc-core: move snd_soc_find_dai_link() ASoC: soc-core: rename snd_soc_add_dai_link() to snd_soc_add_pcm_runtime() ASoC: soc-core: rename snd_soc_remove_dai_link() to snd_soc_remove_pcm_runtime() ASoC: soc-core: move soc_link_dai_pcm_new() ASoC: soc-core: rename soc_link_dai_pcm_new() to soc_dai_pcm_new() ASoC: soc-core: move soc_link_init() ASoC: soc-core: add missing return value check for soc_link_init() ASoC: soc-core: rename soc_link_init() to soc_init_pcm_runtime() ASoC: soc-core: soc_set_name_prefix(): tidyup loop condition ASoC: soc-core: soc_set_name_prefix(): get component device_node at out of loop
For the v2 series
Reviewed-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com
Thanks Morimoto-san
participants (2)
-
Kuninori Morimoto
-
Pierre-Louis Bossart