Skip to contentSkip to conversation

ASoC: support adding PCM dynamically from topology

PATCH In review [email protected] 5 participants 34 messages Aug 10, 2015 – Aug 18, 2015

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

v2 cover ASoC: support adding PCM dynamically from topology

From: Mengdong Lin <[email protected]>

This series allows the topology core to create PCM devices dynamically. The user can define different DAIs in the topology files for different versions of firmware, but share a generic platform and machine driver.

A dummy DAI and DAI link can be used to register the soc card and specify the platform with topology. Then real DAIs are created in platform probing phase by the topology core, and the machine driver will be notified to create relavant DAI links.

We tested using topology to create FE DAI/DAI links on Broadwell.

Mengdong Lin (10):
ASoC: Change the PCM runtime array to a list
ASoC: Define soc_init_dai_link() to wrap link intialization.
ASoC: Change 2nd argument of soc_bind_dai_link() to DAI link pointer
ASoC: Implement DAI links in a list
ASoC: Add support for dummy DAI links and PCM runtimes
ASoC: Bind new DAI links after probing components
ASoC: Support adding a DAI dynamically
ASoC: topology: Change pass number of DAI smaller than graph
ASoC: topology: Change stream formats to bitwise flag
ASOC: topology: Add PCM DAIs dynamically when loading them

 include/sound/soc-dai.h                      |   1 +
 include/sound/soc-topology.h                 |   1 -
 include/sound/soc.h                          |  28 +-
 include/uapi/sound/asoc.h                    |   2 +-
 sound/soc/fsl/fsl-asoc-card.c                |  10 +-
 sound/soc/fsl/imx-wm8962.c                   |  10 +-
 sound/soc/generic/simple-card.c              |  12 +-
 sound/soc/intel/atom/sst-mfld-platform-pcm.c |  12 +-
 sound/soc/intel/boards/cht_bsw_rt5645.c      |   7 +-
 sound/soc/intel/boards/cht_bsw_rt5672.c      |   7 +-
 sound/soc/pxa/mioa701_wm9713.c               |   6 +-
 sound/soc/samsung/bells.c                    |  40 +-
 sound/soc/samsung/littlemill.c               |  32 +-
 sound/soc/samsung/odroidx2_max98090.c        |   9 +-
 sound/soc/samsung/snow.c                     |   9 +-
 sound/soc/samsung/speyside.c                 |  12 +-
 sound/soc/samsung/tobermory.c                |  21 +-
 sound/soc/soc-core.c                         | 642 +++++++++++++++++++--------
 sound/soc/soc-dapm.c                         |   7 +-
 sound/soc/soc-pcm.c                          |  22 +-
 sound/soc/soc-topology.c                     |  99 ++++-
 sound/soc/tegra/tegra_wm8903.c               |   3 +-
 22 files changed, 701 insertions(+), 291 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/10 ASoC: Change the PCM runtime array to a list

From: Mengdong Lin <[email protected]>

Currently the number of DAI links is statically defined by the machine driver at build time using an array. This makes it difficult to shrink/ grow the number of DAI links at runtime in order to reflect any changes in topology.

We can change the DAI link array in the core to a list so that PCMs and FE DAI links can be added and deleted at runtime to reflect changes in use case and DSP topology. The machine driver can still register DAI links as an array.

As the 1st step, this patch change the PCM runtime array to a list. A new PCM runtime is added to the list when a DAI link is bound successfully.

Later patches will further implement the DAI link list.

More:
- define snd_soc_new/free_pcm_runtime() to create/free a runtime.
- define soc_add_pcm_runtime() to add a runtime to the rtd list.
- define soc_remove_pcm_runtimes() to clean up the runtime list.

- traverse the rtd list to probe the link components and dais.

- Add a field "num" to PCM runtime struct, used to specify the device number when creating the pcm device, and for a simple card to access its dai_props array.

- The following 3rd party machine/platform drivers either iterate the rtd list or use snd_soc_get_pcm_runtime() to access a rtd:

intel/atom/sst-mfld-platform-pcm.c
intel/boards/cht_bsw_rt5672
intel/boards/cht_bsw_rt5645
fsl/imx-wm8962.c
fsl/fsl-asoc-card.c
samsung/bells.c
samsung/littlemill.c
samsung/odroidx2_max98090.c
samsung/snow.c
samsung/speyside.c
samsung/tobermory.c
pxa/mioa701_wm9713.c
tegra/tegra_wm8903.c

More 3rd party drivers will be modified later, if the basic idea is acceptable.

include/sound/soc.h +4 -1
index 4cef20e..e2b7b0f 100644
@@ -1080,7 +1080,7 @@ struct snd_soc_card {
 	/* CPU <--> Codec DAI links  */
 	struct snd_soc_dai_link *dai_link;
 	int num_links;
-	struct snd_soc_pcm_runtime *rtd;
+	struct list_head rtd_list;
 	int num_rtd;
 
 	/* optional codec specific configuration */
@@ -1175,6 +1175,9 @@ struct snd_soc_pcm_runtime {
 	struct dentry *debugfs_dpcm_root;
 	struct dentry *debugfs_dpcm_state;
 #endif
+
+	unsigned int num; /* 0-based and monotonic increasing */
+	struct list_head list; /* rtd list of the soc card */
 };
 
 /* mixer control */
sound/soc/fsl/fsl-asoc-card.c +8 -2
index de43887..b80cf09 100644
@@ -211,12 +211,15 @@ static int fsl_asoc_card_set_bias_level(struct snd_soc_card *card,
 					enum snd_soc_bias_level level)
 {
 	struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(card);
-	struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
 	struct codec_priv *codec_priv = &priv->codec_priv;
 	struct device *dev = card->dev;
 	unsigned int pll_out;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	codec_dai = rtd->codec_dai;
 	if (dapm->dev != codec_dai->dev)
 		return 0;
 
@@ -383,11 +386,14 @@ static int fsl_asoc_card_audmux_init(struct device_node *np,
 static int fsl_asoc_card_late_probe(struct snd_soc_card *card)
 {
 	struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(card);
-	struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
 	struct codec_priv *codec_priv = &priv->codec_priv;
 	struct device *dev = card->dev;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	codec_dai = rtd->codec_dai;
 	ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->mclk_id,
 				     codec_priv->mclk_freq, SND_SOC_CLOCK_IN);
 	if (ret) {
sound/soc/fsl/imx-wm8962.c +8 -2
index b38b98c..201a70d 100644
@@ -69,13 +69,16 @@ static int imx_wm8962_set_bias_level(struct snd_soc_card *card,
 					struct snd_soc_dapm_context *dapm,
 					enum snd_soc_bias_level level)
 {
-	struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
 	struct imx_priv *priv = &card_priv;
 	struct imx_wm8962_data *data = snd_soc_card_get_drvdata(card);
 	struct device *dev = &priv->pdev->dev;
 	unsigned int pll_out;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	codec_dai = rtd->codec_dai;
 	if (dapm->dev != codec_dai->dev)
 		return 0;
 
@@ -135,12 +138,15 @@ static int imx_wm8962_set_bias_level(struct snd_soc_card *card,
 
 static int imx_wm8962_late_probe(struct snd_soc_card *card)
 {
-	struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
 	struct imx_priv *priv = &card_priv;
 	struct imx_wm8962_data *data = snd_soc_card_get_drvdata(card);
 	struct device *dev = &priv->pdev->dev;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	codec_dai = rtd->codec_dai;
 	ret = snd_soc_dai_set_sysclk(codec_dai, WM8962_SYSCLK_MCLK,
 			data->clk_frequency, SND_SOC_CLOCK_IN);
 	if (ret < 0)
sound/soc/generic/simple-card.c +5 -7
index 3ff76d4..95a2f91 100644
@@ -45,7 +45,7 @@ static int asoc_simple_card_startup(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
 	struct simple_dai_props *dai_props =
-		&priv->dai_props[rtd - rtd->card->rtd];
+		&priv->dai_props[rtd->num];
 	int ret;
 
 	ret = clk_prepare_enable(dai_props->cpu_dai.clk);
@@ -64,7 +64,7 @@ static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
 	struct simple_dai_props *dai_props =
-		&priv->dai_props[rtd - rtd->card->rtd];
+		&priv->dai_props[rtd->num];
 
 	clk_disable_unprepare(dai_props->cpu_dai.clk);
 
@@ -78,8 +78,7 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
-	struct simple_dai_props *dai_props =
-		&priv->dai_props[rtd - rtd->card->rtd];
+	struct simple_dai_props *dai_props = &priv->dai_props[rtd->num];
 	unsigned int mclk, mclk_fs = 0;
 	int ret = 0;
 
@@ -172,10 +171,9 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 	struct snd_soc_dai *codec = rtd->codec_dai;
 	struct snd_soc_dai *cpu = rtd->cpu_dai;
 	struct simple_dai_props *dai_props;
-	int num, ret;
+	int ret;
 
-	num = rtd - rtd->card->rtd;
-	dai_props = &priv->dai_props[num];
+	dai_props = &priv->dai_props[rtd->num];
 	ret = __asoc_simple_card_dai_init(codec, &dai_props->codec_dai);
 	if (ret < 0)
 		return ret;
sound/soc/intel/atom/sst-mfld-platform-pcm.c +6 -6
index 683e501..5ae8ae2 100644
@@ -777,15 +777,15 @@ static int sst_platform_remove(struct platform_device *pdev)
 static int sst_soc_prepare(struct device *dev)
 {
 	struct sst_data *drv = dev_get_drvdata(dev);
-	int i;
+	struct snd_soc_pcm_runtime *rtd;
 
 	/* suspend all pcms first */
 	snd_soc_suspend(drv->soc_card->dev);
 	snd_soc_poweroff(drv->soc_card->dev);
 
 	/* set the SSPs to idle */
-	for (i = 0; i < drv->soc_card->num_rtd; i++) {
-		struct snd_soc_dai *dai = drv->soc_card->rtd[i].cpu_dai;
+	list_for_each_entry(rtd, &drv->soc_card->rtd_list, list) {
+		struct snd_soc_dai *dai = rtd->cpu_dai;
 
 		if (dai->active) {
 			send_ssp_cmd(dai, dai->name, 0);
@@ -799,11 +799,11 @@ static int sst_soc_prepare(struct device *dev)
 static void sst_soc_complete(struct device *dev)
 {
 	struct sst_data *drv = dev_get_drvdata(dev);
-	int i;
+	struct snd_soc_pcm_runtime *rtd;
 
 	/* restart SSPs */
-	for (i = 0; i < drv->soc_card->num_rtd; i++) {
-		struct snd_soc_dai *dai = drv->soc_card->rtd[i].cpu_dai;
+	list_for_each_entry(rtd, &drv->soc_card->rtd_list, list) {
+		struct snd_soc_dai *dai = rtd->cpu_dai;
 
 		if (dai->active) {
 			sst_handle_vb_timer(dai, true);
sound/soc/intel/boards/cht_bsw_rt5645.c +2 -5
index bdcaf46..fade1a2 100644
@@ -47,12 +47,9 @@ struct cht_mc_private {
 
 static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
 {
-	int i;
-
-	for (i = 0; i < card->num_rtd; i++) {
-		struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_pcm_runtime *rtd;
 
-		rtd = card->rtd + i;
+	list_for_each_entry(rtd, &card->rtd_list, list) {
 		if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI,
 			     strlen(CHT_CODEC_DAI)))
 			return rtd->codec_dai;
sound/soc/intel/boards/cht_bsw_rt5672.c +2 -5
index 2c9cc5b..fee43bd 100644
@@ -46,12 +46,9 @@ static struct snd_soc_jack_pin cht_bsw_headset_pins[] = {
 
 static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
 {
-	int i;
+	struct snd_soc_pcm_runtime *rtd;
 
-	for (i = 0; i < card->num_rtd; i++) {
-		struct snd_soc_pcm_runtime *rtd;
-
-		rtd = card->rtd + i;
+	list_for_each_entry(rtd, &card->rtd_list, list) {
 		if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI,
 			     strlen(CHT_CODEC_DAI)))
 			return rtd->codec_dai;
sound/soc/pxa/mioa701_wm9713.c +5 -1
index a9615a57..4f6cafe 100644
@@ -81,8 +81,12 @@ static int rear_amp_power(struct snd_soc_codec *codec, int power)
 static int rear_amp_event(struct snd_soc_dapm_widget *widget,
 			  struct snd_kcontrol *kctl, int event)
 {
-	struct snd_soc_codec *codec = widget->dapm->card->rtd[0].codec;
+	struct snd_soc_card *card = widget->dapm->card;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_codec *codec;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	codec = rtd->codec;
 	return rear_amp_power(codec, SND_SOC_DAPM_EVENT_ON(event));
 }
 
sound/soc/samsung/bells.c +30 -10
index e5f05e6..3dd246f 100644
@@ -58,11 +58,16 @@ static int bells_set_bias_level(struct snd_soc_card *card,
 				struct snd_soc_dapm_context *dapm,
 				enum snd_soc_bias_level level)
 {
-	struct snd_soc_dai *codec_dai = card->rtd[DAI_DSP_CODEC].codec_dai;
-	struct snd_soc_codec *codec = codec_dai->codec;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
+	struct snd_soc_codec *codec;
 	struct bells_drvdata *bells = card->drvdata;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
+	codec_dai = rtd->codec_dai;
+	codec = codec_dai->codec;
+
 	if (dapm->dev != codec_dai->dev)
 		return 0;
 
@@ -99,11 +104,16 @@ static int bells_set_bias_level_post(struct snd_soc_card *card,
 				     struct snd_soc_dapm_context *dapm,
 				     enum snd_soc_bias_level level)
 {
-	struct snd_soc_dai *codec_dai = card->rtd[DAI_DSP_CODEC].codec_dai;
-	struct snd_soc_codec *codec = codec_dai->codec;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
+	struct snd_soc_codec *codec;
 	struct bells_drvdata *bells = card->drvdata;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
+	codec_dai = rtd->codec_dai;
+	codec = codec_dai->codec;
+
 	if (dapm->dev != codec_dai->dev)
 		return 0;
 
@@ -137,14 +147,22 @@ static int bells_set_bias_level_post(struct snd_soc_card *card,
 static int bells_late_probe(struct snd_soc_card *card)
 {
 	struct bells_drvdata *bells = card->drvdata;
-	struct snd_soc_codec *wm0010 = card->rtd[DAI_AP_DSP].codec;
-	struct snd_soc_codec *codec = card->rtd[DAI_DSP_CODEC].codec;
-	struct snd_soc_dai *aif1_dai = card->rtd[DAI_DSP_CODEC].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_codec *wm0010;
+	struct snd_soc_codec *codec;
+	struct snd_soc_dai *aif1_dai;
 	struct snd_soc_dai *aif2_dai;
 	struct snd_soc_dai *aif3_dai;
 	struct snd_soc_dai *wm9081_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_AP_DSP].name);
+	wm0010 = rtd->codec;
+
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
+	codec = rtd->codec;
+	aif1_dai = rtd->codec_dai;
+
 	ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_SYSCLK,
 				       ARIZONA_CLK_SRC_FLL1,
 				       bells->sysclk_rate,
@@ -181,7 +199,8 @@ static int bells_late_probe(struct snd_soc_card *card)
 		return ret;
 	}
 
-	aif2_dai = card->rtd[DAI_CODEC_CP].cpu_dai;
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_CODEC_CP].name);
+	aif2_dai = rtd->cpu_dai;
 
 	ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0);
 	if (ret != 0) {
@@ -192,8 +211,9 @@ static int bells_late_probe(struct snd_soc_card *card)
 	if (card->num_rtd == DAI_CODEC_SUB)
 		return 0;
 
-	aif3_dai = card->rtd[DAI_CODEC_SUB].cpu_dai;
-	wm9081_dai = card->rtd[DAI_CODEC_SUB].codec_dai;
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_CODEC_SUB].name);
+	aif3_dai = rtd->cpu_dai;
+	wm9081_dai = rtd->codec_dai;
 
 	ret = snd_soc_dai_set_sysclk(aif3_dai, ARIZONA_CLK_SYSCLK, 0, 0);
 	if (ret != 0) {
sound/soc/samsung/littlemill.c +26 -6
index 31a820e..7cb204e 100644
@@ -23,9 +23,13 @@ static int littlemill_set_bias_level(struct snd_soc_card *card,
 					  struct snd_soc_dapm_context *dapm,
 					  enum snd_soc_bias_level level)
 {
-	struct snd_soc_dai *aif1_dai = card->rtd[0].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *aif1_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	aif1_dai = rtd->codec_dai;
+
 	if (dapm->dev != aif1_dai->dev)
 		return 0;
 
@@ -66,9 +70,13 @@ static int littlemill_set_bias_level_post(struct snd_soc_card *card,
 					       struct snd_soc_dapm_context *dapm,
 					       enum snd_soc_bias_level level)
 {
-	struct snd_soc_dai *aif1_dai = card->rtd[0].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *aif1_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	aif1_dai = rtd->codec_dai;
+
 	if (dapm->dev != aif1_dai->dev)
 		return 0;
 
@@ -168,9 +176,13 @@ static int bbclk_ev(struct snd_soc_dapm_widget *w,
 		    struct snd_kcontrol *kcontrol, int event)
 {
 	struct snd_soc_card *card = w->dapm->card;
-	struct snd_soc_dai *aif2_dai = card->rtd[1].cpu_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *aif2_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+	aif2_dai = rtd->cpu_dai;
+
 	switch (event) {
 	case SND_SOC_DAPM_PRE_PMU:
 		ret = snd_soc_dai_set_pll(aif2_dai, WM8994_FLL2,
@@ -245,11 +257,19 @@ static struct snd_soc_jack littlemill_headset;
 
 static int littlemill_late_probe(struct snd_soc_card *card)
 {
-	struct snd_soc_codec *codec = card->rtd[0].codec;
-	struct snd_soc_dai *aif1_dai = card->rtd[0].codec_dai;
-	struct snd_soc_dai *aif2_dai = card->rtd[1].cpu_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_codec *codec;
+	struct snd_soc_dai *aif1_dai;
+	struct snd_soc_dai *aif2_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	codec = rtd->codec;
+	aif1_dai = rtd->codec_dai;
+
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+	aif2_dai = rtd->cpu_dai;
+
 	ret = snd_soc_dai_set_sysclk(aif1_dai, WM8994_SYSCLK_MCLK2,
 				     32768, SND_SOC_CLOCK_IN);
 	if (ret < 0)
sound/soc/samsung/odroidx2_max98090.c +7 -2
index 596f118..0421727 100644
@@ -25,10 +25,15 @@ static struct snd_soc_dai_link odroidx2_dai[];
 
 static int odroidx2_late_probe(struct snd_soc_card *card)
 {
-	struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
-	struct snd_soc_dai *cpu_dai = card->rtd[0].cpu_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
+	struct snd_soc_dai *cpu_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	codec_dai = rtd->codec_dai;
+	cpu_dai = rtd->cpu_dai;
+
 	ret = snd_soc_dai_set_sysclk(codec_dai, 0, MAX98090_MCLK,
 						SND_SOC_CLOCK_IN);
 
sound/soc/samsung/snow.c +7 -2
index 7651dc9..0969577 100644
@@ -35,10 +35,15 @@ static struct snd_soc_dai_link snow_dai[] = {
 
 static int snow_late_probe(struct snd_soc_card *card)
 {
-	struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
-	struct snd_soc_dai *cpu_dai = card->rtd[0].cpu_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
+	struct snd_soc_dai *cpu_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	codec_dai = rtd->codec_dai;
+	cpu_dai = rtd->cpu_dai;
+
 	/* Set the MCLK rate for the codec */
 	ret = snd_soc_dai_set_sysclk(codec_dai, 0,
 					FIN_PLL_RATE, SND_SOC_CLOCK_IN);
sound/soc/samsung/speyside.c +10 -2
index d1ae21c..083ef5e 100644
@@ -25,9 +25,13 @@ static int speyside_set_bias_level(struct snd_soc_card *card,
 				   struct snd_soc_dapm_context *dapm,
 				   enum snd_soc_bias_level level)
 {
-	struct snd_soc_dai *codec_dai = card->rtd[1].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+	codec_dai = rtd->codec_dai;
+
 	if (dapm->dev != codec_dai->dev)
 		return 0;
 
@@ -57,9 +61,13 @@ static int speyside_set_bias_level_post(struct snd_soc_card *card,
 					struct snd_soc_dapm_context *dapm,
 					enum snd_soc_bias_level level)
 {
-	struct snd_soc_dai *codec_dai = card->rtd[1].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+	codec_dai = rtd->codec_dai;
+
 	if (dapm->dev != codec_dai->dev)
 		return 0;
 
sound/soc/samsung/tobermory.c +17 -4
index 85ccfb7..3310eda 100644
@@ -23,9 +23,13 @@ static int tobermory_set_bias_level(struct snd_soc_card *card,
 					  struct snd_soc_dapm_context *dapm,
 					  enum snd_soc_bias_level level)
 {
-	struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	codec_dai = rtd->codec_dai;
+
 	if (dapm->dev != codec_dai->dev)
 		return 0;
 
@@ -62,9 +66,13 @@ static int tobermory_set_bias_level_post(struct snd_soc_card *card,
 					       struct snd_soc_dapm_context *dapm,
 					       enum snd_soc_bias_level level)
 {
-	struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *codec_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	codec_dai = rtd->codec_dai;
+
 	if (dapm->dev != codec_dai->dev)
 		return 0;
 
@@ -170,10 +178,15 @@ static struct snd_soc_jack_pin tobermory_headset_pins[] = {
 
 static int tobermory_late_probe(struct snd_soc_card *card)
 {
-	struct snd_soc_codec *codec = card->rtd[0].codec;
-	struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_codec *codec;
+	struct snd_soc_dai *codec_dai;
 	int ret;
 
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	codec = rtd->codec;
+	codec_dai = rtd->codec_dai;
+
 	ret = snd_soc_dai_set_sysclk(codec_dai, WM8962_SYSCLK_MCLK,
 				     32768, SND_SOC_CLOCK_IN);
 	if (ret < 0)
sound/soc/soc-core.c +161 -109

572 lines not on this page · raw message

sound/soc/soc-dapm.c +2 -5
index 7482c5d..6d1f066 100644
@@ -3861,13 +3861,10 @@ static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream,
 
 void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)
 {
-	struct snd_soc_pcm_runtime *rtd = card->rtd;
-	int i;
+	struct snd_soc_pcm_runtime *rtd;
 
 	/* for each BE DAI link... */
-	for (i = 0; i < card->num_rtd; i++) {
-		rtd = &card->rtd[i];
-
+	list_for_each_entry(rtd, &card->rtd_list, list)  {
 		/*
 		 * dynamic FE links have no fixed DAI mapping.
 		 * CODEC<->CODEC links have no direct connection.
sound/soc/soc-pcm.c +10 -12
index 70e4b9d..0246019 100644
@@ -1166,11 +1166,10 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,
 		struct snd_soc_dapm_widget *widget, int stream)
 {
 	struct snd_soc_pcm_runtime *be;
-	int i, j;
+	int i;
 
 	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		for (i = 0; i < card->num_links; i++) {
-			be = &card->rtd[i];
+		list_for_each_entry(be, &card->rtd_list, list) {
 
 			if (!be->dai_link->no_pcm)
 				continue;
@@ -1178,16 +1177,15 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,
 			if (be->cpu_dai->playback_widget == widget)
 				return be;
 
-			for (j = 0; j < be->num_codecs; j++) {
-				struct snd_soc_dai *dai = be->codec_dais[j];
+			for (i = 0; i < be->num_codecs; i++) {
+				struct snd_soc_dai *dai = be->codec_dais[i];
 				if (dai->playback_widget == widget)
 					return be;
 			}
 		}
 	} else {
 
-		for (i = 0; i < card->num_links; i++) {
-			be = &card->rtd[i];
+		list_for_each_entry(be, &card->rtd_list, list) {
 
 			if (!be->dai_link->no_pcm)
 				continue;
@@ -1195,8 +1193,8 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,
 			if (be->cpu_dai->capture_widget == widget)
 				return be;
 
-			for (j = 0; j < be->num_codecs; j++) {
-				struct snd_soc_dai *dai = be->codec_dais[j];
+			for (i = 0; i < be->num_codecs; i++) {
+				struct snd_soc_dai *dai = be->codec_dais[i];
 				if (dai->capture_widget == widget)
 					return be;
 			}
@@ -2296,12 +2294,12 @@ static int dpcm_run_old_update(struct snd_soc_pcm_runtime *fe, int stream)
  */
 int soc_dpcm_runtime_update(struct snd_soc_card *card)
 {
-	int i, old, new, paths;
+	struct snd_soc_pcm_runtime *fe;
+	int old, new, paths;
 
 	mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
-	for (i = 0; i < card->num_rtd; i++) {
+	list_for_each_entry(fe, &card->rtd_list, list) {
 		struct snd_soc_dapm_widget_list *list;
-		struct snd_soc_pcm_runtime *fe = &card->rtd[i];
 
 		/* make sure link is FE */
 		if (!fe->dai_link->dynamic)
sound/soc/tegra/tegra_wm8903.c +2 -1
index 2160400..e485278 100644
@@ -199,7 +199,8 @@ 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 = &(card->rtd[0]);
+	struct snd_soc_pcm_runtime *rtd =
+		snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_codec *codec = codec_dai->codec;
 	struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 2/10 ASoC: Define soc_init_dai_link() to wrap link intialization.

In reply to [email protected]

From: Mengdong Lin <[email protected]>

Define soc_init_dai_link() to wrap link initialization, to reuse it later by snd_soc_instantiate_card() when adding new DAI links from topology in component probing phase.

Move static func snd_soc_init_multicodec(), so that it can be reused by soc_init_dai_link(). This saves adding a function declaration for snd_soc_init_multicodec().

sound/soc/soc-core.c +98 -83
index fb78674..e9e8956 100644
@@ -1141,6 +1141,100 @@ static void soc_remove_dai_links(struct snd_soc_card *card)
 	}
 }
 
+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;
+
+	ret = snd_soc_init_multicodec(card, link);
+	if (ret) {
+		dev_err(card->dev, "ASoC: failed to init multicodec\n");
+		return ret;
+	}
+
+	for (i = 0; i < link->num_codecs; i++) {
+		/*
+		 * Codec must be specified by 1 of name or OF node,
+		 * not both or neither.
+		 */
+		if (!!link->codecs[i].name ==
+		    !!link->codecs[i].of_node) {
+			dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n",
+				link->name);
+			return -EINVAL;
+		}
+		/* Codec DAI name must be specified */
+		if (!link->codecs[i].dai_name) {
+			dev_err(card->dev, "ASoC: codec_dai_name not set for %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) {
+		dev_err(card->dev,
+			"ASoC: Both platform name/of_node are set for %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) {
+		dev_err(card->dev,
+			"ASoC: Neither/both cpu name/of_node are set for %s\n",
+			link->name);
+		return -EINVAL;
+	}
+	/*
+	 * 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)) {
+		dev_err(card->dev,
+			"ASoC: Neither cpu_dai_name nor cpu_name/of_node are set for %s\n",
+			link->name);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static void soc_set_name_prefix(struct snd_soc_card *card,
 				struct snd_soc_component *component)
 {
@@ -2363,33 +2457,6 @@ int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);
 
-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;
-}
-
 /**
  * snd_soc_register_card - Register a card with the ASoC core
  *
@@ -2398,7 +2465,7 @@ static int snd_soc_init_multicodec(struct snd_soc_card *card,
  */
 int snd_soc_register_card(struct snd_soc_card *card)
 {
-	int i, j, ret;
+	int i, ret;
 	struct snd_soc_pcm_runtime *rtd;
 
 	if (!card->name || !card->dev)
@@ -2407,63 +2474,11 @@ int snd_soc_register_card(struct snd_soc_card *card)
 	for (i = 0; i < card->num_links; i++) {
 		struct snd_soc_dai_link *link = &card->dai_link[i];
 
-		ret = snd_soc_init_multicodec(card, link);
+		ret = soc_init_dai_link(card, link);
 		if (ret) {
-			dev_err(card->dev, "ASoC: failed to init multicodec\n");
-			return ret;
-		}
-
-		for (j = 0; j < link->num_codecs; j++) {
-			/*
-			 * Codec must be specified by 1 of name or OF node,
-			 * not both or neither.
-			 */
-			if (!!link->codecs[j].name ==
-			    !!link->codecs[j].of_node) {
-				dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n",
-					link->name);
-				return -EINVAL;
-			}
-			/* Codec DAI name must be specified */
-			if (!link->codecs[j].dai_name) {
-				dev_err(card->dev, "ASoC: codec_dai_name not set for %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) {
-			dev_err(card->dev,
-				"ASoC: Both platform name/of_node are set for %s\n",
+			dev_err(card->dev, "ASoC: failed to init link %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) {
-			dev_err(card->dev,
-				"ASoC: Neither/both cpu name/of_node are set for %s\n",
-				link->name);
-			return -EINVAL;
-		}
-		/*
-		 * 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)) {
-			dev_err(card->dev,
-				"ASoC: Neither cpu_dai_name nor cpu_name/of_node are set for %s\n",
-				link->name);
-			return -EINVAL;
+			return ret;
 		}
 	}
 
Signature · 1 line
1.9.1
#5 lore raw

PATCH v2 3/10 ASoC: Change 2nd argument of soc_bind_dai_link() to DAI link pointer

In reply to [email protected]

From: Mengdong Lin <[email protected]>

Just code refactoring, to reuse it if new DAI Links are added later based on topology in component probing phase.

sound/soc/soc-core.c +4 -4
index e9e8956..ddfdd1d 100644
@@ -961,9 +961,9 @@ static struct snd_soc_dai *snd_soc_find_dai(
 	return NULL;
 }
 
-static int soc_bind_dai_link(struct snd_soc_card *card, int num)
+static int soc_bind_dai_link(struct snd_soc_card *card,
+	struct snd_soc_dai_link *dai_link)
 {
-	struct snd_soc_dai_link *dai_link = &card->dai_link[num];
 	struct snd_soc_pcm_runtime *rtd;
 	struct snd_soc_dai_link_component *codecs = dai_link->codecs;
 	struct snd_soc_dai_link_component cpu_dai_component;
@@ -972,7 +972,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
 	const char *platform_name;
 	int i;
 
-	dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num);
+	dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name);
 
 	if (snd_soc_get_pcm_runtime(card, dai_link->name)) {
 		dev_dbg(card->dev, "ASoC: dai link %s already bound\n",
@@ -1717,7 +1717,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 
 	/* bind DAIs */
 	for (i = 0; i < card->num_links; i++) {
-		ret = soc_bind_dai_link(card, i);
+		ret = soc_bind_dai_link(card, &card->dai_link[i]);
 		if (ret != 0)
 			goto base_error;
 	}
Signature · 1 line
1.9.1
#6 lore raw

PATCH v2 4/10 ASoC: Implement DAI links in a list

In reply to [email protected]

From: Mengdong Lin <[email protected]>

Implement a dai link list for the soc card.
And API snd_soc_add_dai_link() is defined for machine drivers to add DAI links dynamically based on topology.

include/sound/soc.h +10 -2
index e2b7b0f..79891e2 100644
@@ -1011,6 +1011,8 @@ struct snd_soc_dai_link {
 
 	/* pmdown_time is ignored at stop */
 	unsigned int ignore_pmdown_time:1;
+
+	struct list_head list; /* dai link list of the soc card */
 };
 
 struct snd_soc_codec_conf {
@@ -1078,8 +1080,11 @@ struct snd_soc_card {
 	long pmdown_time;
 
 	/* CPU <--> Codec DAI links  */
-	struct snd_soc_dai_link *dai_link;
-	int num_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 except the dummy ones */
+	int num_dai_links;
+
 	struct list_head rtd_list;
 	int num_rtd;
 
@@ -1619,6 +1624,9 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev,
 				   struct device_node *of_node,
 				   struct snd_soc_dai_link *dai_link);
 
+void snd_soc_add_dai_link(struct snd_soc_card *card,
+				struct snd_soc_dai_link *dai_link);
+
 #include <sound/soc-dai.h>
 
 #ifdef CONFIG_DEBUG_FS
sound/soc/soc-core.c +28 -0
index ddfdd1d..58eac57 100644
@@ -1235,6 +1235,27 @@ static int soc_init_dai_link(struct snd_soc_card *card,
 	return 0;
 }
 
+/**
+ * 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
+ *
+ * This function adds a DAI link to the ASoC card, and creates a ASoC
+ * runtime for the link.
+ *
+ * Note: For adding DAI links dynamically by machine drivers based on
+ * the topology info when probing the platform component. And machine
+ * drivers can still define static DAI links in dai_link array.
+ */
+void snd_soc_add_dai_link(struct snd_soc_card *card,
+		struct snd_soc_dai_link *dai_link)
+{
+	lockdep_assert_held(&client_mutex);
+	list_add_tail(&dai_link->list, &card->dai_link_list);
+	card->num_dai_links++;
+}
+EXPORT_SYMBOL_GPL(snd_soc_add_dai_link);
+
 static void soc_set_name_prefix(struct snd_soc_card *card,
 				struct snd_soc_component *component)
 {
@@ -1729,6 +1750,10 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 			goto base_error;
 	}
 
+	/* all predefined resources are ready, store non-dummy links */
+	for (i = 0; i < card->num_links; i++)
+		snd_soc_add_dai_link(card, card->dai_link+i);
+
 	/* initialize the register cache for each available codec */
 	list_for_each_entry(codec, &codec_list, list) {
 		if (codec->cache_init)
@@ -2486,6 +2511,9 @@ int snd_soc_register_card(struct snd_soc_card *card)
 
 	snd_soc_initialize_card_lists(card);
 
+	INIT_LIST_HEAD(&card->dai_link_list);
+	card->num_dai_links = 0;
+
 	INIT_LIST_HEAD(&card->rtd_list);
 	card->num_rtd = 0;
 
Signature · 1 line
1.9.1
#7 lore raw

PATCH v2 5/10 ASoC: Add support for dummy DAI links and PCM runtimes

In reply to [email protected]

From: Mengdong Lin <[email protected]>

Add dummy flag to a DAI link and PCM runtime. A dummy link will create a dummy PCM runtime.

A machine driver can define dummy dai links to specify the expected platform and codec. And its dummy runtime is used to probe the platform and codec components, which can bring real DAI/DAI links based on topology. After components probing, all dummy PCM runtimes will be removed.

Only non-dummy PCM runtimes will be assigned a valid number and create PCM streams.

The ASoC core will find the platform for a dummy DAI link, assuming the cpu DAI can be dummy but the platform can bring the topology info.

include/sound/soc.h +7 -0
index 79891e2..7e04ec0 100644
@@ -970,6 +970,11 @@ struct snd_soc_dai_link {
 
 	enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
 
+	/* This DAI link is dummy. Machine drivers can define static dummy
+	 * links to specify platform/codec with topology.
+	 */
+	bool dummy;
+
 	/* codec/machine specific init - e.g. add machine controls */
 	int (*init)(struct snd_soc_pcm_runtime *rtd);
 
@@ -1087,6 +1092,7 @@ struct snd_soc_card {
 
 	struct list_head rtd_list;
 	int num_rtd;
+	int num_rtd_dev; /* monotonic increase and exclude dummy ones */
 
 	/* optional codec specific configuration */
 	struct snd_soc_codec_conf *codec_conf;
@@ -1181,6 +1187,7 @@ struct snd_soc_pcm_runtime {
 	struct dentry *debugfs_dpcm_state;
 #endif
 
+	bool dummy;
 	unsigned int num; /* 0-based and monotonic increasing */
 	struct list_head list; /* rtd list of the soc card */
 };
sound/soc/soc-core.c +37 -1
index 58eac57..f552fa0 100644
@@ -561,6 +561,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
 
 	rtd->card = card;
 	rtd->dai_link = dai_link;
+	rtd->dummy = dai_link->dummy;
 	rtd->codec_dais = devm_kzalloc(card->dev,
 					sizeof(struct snd_soc_dai *) *
 					dai_link->num_codecs,
@@ -583,10 +584,28 @@ static void soc_add_pcm_runtime(struct snd_soc_card *card,
 		struct snd_soc_pcm_runtime *rtd)
 {
 	list_add_tail(&rtd->list, &card->rtd_list);
-	rtd->num = card->num_rtd;
+
+	if (!rtd->dummy) {
+		rtd->num = card->num_rtd_dev;
+		card->num_rtd_dev++;
+	}
+
 	card->num_rtd++;
 }
 
+static void soc_remove_dummy_pcm_runtimes(struct snd_soc_card *card)
+{
+	struct snd_soc_pcm_runtime *rtd, *_rtd;
+
+	list_for_each_entry_safe(rtd, _rtd, &card->rtd_list, list) {
+		if (rtd->dummy) {
+			list_del(&rtd->list);
+			soc_free_pcm_runtime(card, rtd);
+			card->num_rtd--;
+		}
+	}
+}
+
 static void soc_remove_pcm_runtimes(struct snd_soc_card *card)
 {
 	struct snd_soc_pcm_runtime *rtd, *_rtd;
@@ -1007,6 +1026,15 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 		}
 	}
 
+	/* Dummy link can use dummy cpu DAI but set platform to get topology */
+	if (dai_link->dummy && dai_link->platform_name) {
+		if (!soc_find_component(NULL, dai_link->platform_name)) {
+			dev_err(card->dev, "ASoC: Platform %s not registered\n",
+				dai_link->platform_name);
+			goto _err_defer;
+		}
+	}
+
 	/* Single codec links expect codec and codec_dai in runtime data */
 	rtd->codec_dai = codec_dais[0];
 	rtd->codec = rtd->codec_dai->codec;
@@ -1250,6 +1278,10 @@ static int soc_init_dai_link(struct snd_soc_card *card,
 void snd_soc_add_dai_link(struct snd_soc_card *card,
 		struct snd_soc_dai_link *dai_link)
 {
+	/* Dummy links should be static, so overlook them */
+	if (dai_link->dummy)
+		return;
+
 	lockdep_assert_held(&client_mutex);
 	list_add_tail(&dai_link->list, &card->dai_link_list);
 	card->num_dai_links++;
@@ -1818,6 +1850,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 		}
 	}
 
+	/* no longer need dummy runtimes */
+	soc_remove_dummy_pcm_runtimes(card);
+
 	/* probe all DAI links on this card */
 	for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
 			order++) {
@@ -2516,6 +2551,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
 
 	INIT_LIST_HEAD(&card->rtd_list);
 	card->num_rtd = 0;
+	card->num_rtd_dev = 0;
 
 	card->rtd_aux = devm_kzalloc(card->dev,
 				 sizeof(struct snd_soc_pcm_runtime) *
Signature · 1 line
1.9.1
#11 lore raw

PATCH v2 6/10 ASoC: Bind new DAI links after probing components

In reply to [email protected]

From: Mengdong Lin <[email protected]>

Probing components can bring new DAI or DAI links based on the topology info. This patch finds the unbound DAI links and bind them.

sound/soc/soc-core.c +29 -0
index f552fa0..2818709 100644
@@ -1169,6 +1169,19 @@ static void soc_remove_dai_links(struct snd_soc_card *card)
 	}
 }
 
+static bool soc_is_dai_link_bound(struct snd_soc_card *card,
+		struct snd_soc_dai_link *dai_link)
+{
+	struct snd_soc_pcm_runtime *rtd;
+
+	list_for_each_entry(rtd, &card->rtd_list, list) {
+		if (rtd->dai_link == dai_link)
+			return true;
+	}
+
+	return false;
+}
+
 static int snd_soc_init_multicodec(struct snd_soc_card *card,
 				   struct snd_soc_dai_link *dai_link)
 {
@@ -1763,6 +1776,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 {
 	struct snd_soc_codec *codec;
 	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai_link *dai_link;
 	int ret, i, order;
 
 	mutex_lock(&client_mutex);
@@ -1853,6 +1867,21 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 	/* no longer need dummy runtimes */
 	soc_remove_dummy_pcm_runtimes(card);
 
+	/* Find new DAI links added during probing components and bind them.
+	 * Components with topology may bring new DAIs and DAI links.
+	 */
+	list_for_each_entry(dai_link, &card->dai_link_list, list) {
+		if (dai_link->dummy || soc_is_dai_link_bound(card, dai_link))
+			continue;
+
+		ret = soc_init_dai_link(card, dai_link);
+		if (ret)
+			goto probe_dai_err;
+		ret = soc_bind_dai_link(card, dai_link);
+		if (ret)
+			goto probe_dai_err;
+	}
+
 	/* probe all DAI links on this card */
 	for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
 			order++) {
Signature · 1 line
1.9.1
#12 lore raw

PATCH v2 7/10 ASoC: Support adding a DAI dynamically

In reply to [email protected]

From: Mengdong Lin <[email protected]>

API snd_soc_add_dai() is defined to register a DAI dynamically, create its DAI widget, and notify the machine driver. This API can be used by the topology core to add DAIs dynamically.

And a callback add_dai() is defined for the soc card. The machine driver can implement this callback. Adding a new DAI dynmaically will trigger this callback, and the machine driver can create relavant DAI link in the callback context.

include/sound/soc.h +4 -0
index 7e04ec0..2a474c8 100644
@@ -1081,6 +1081,7 @@ struct snd_soc_card {
 	int (*set_bias_level_post)(struct snd_soc_card *,
 				   struct snd_soc_dapm_context *dapm,
 				   enum snd_soc_bias_level level);
+	int (*add_dai)(struct snd_soc_card *, struct snd_soc_dai_driver*);
 
 	long pmdown_time;
 
@@ -1634,6 +1635,9 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev,
 void snd_soc_add_dai_link(struct snd_soc_card *card,
 				struct snd_soc_dai_link *dai_link);
 
+int snd_soc_add_dai(struct snd_soc_component *component,
+	struct snd_soc_dai_driver *dai_drv);
+
 #include <sound/soc-dai.h>
 
 #ifdef CONFIG_DEBUG_FS
sound/soc/soc-core.c +92 -0

98 lines not on this page · raw message

Signature · 1 line
1.9.1
#13 lore raw

PATCH v2 8/10 ASoC: topology: Change pass number of DAI smaller than graph

In reply to [email protected]

From: Mengdong Lin <[email protected]>

The PCM DAIs need to be loaded and added to ASoC core ealier than the graph (route). Otherwise, adding routes will fail for missing DAIs.

sound/soc/soc-topology.c +4 -4
index 1b6728b..0f8fa0d 100644
@@ -45,12 +45,12 @@
 #define SOC_TPLG_PASS_VENDOR		1
 #define SOC_TPLG_PASS_MIXER		2
 #define SOC_TPLG_PASS_WIDGET		3
-#define SOC_TPLG_PASS_GRAPH		4
-#define SOC_TPLG_PASS_PINS		5
-#define SOC_TPLG_PASS_PCM_DAI		6
+#define SOC_TPLG_PASS_PCM_DAI		4
+#define SOC_TPLG_PASS_GRAPH		5
+#define SOC_TPLG_PASS_PINS		6
 
 #define SOC_TPLG_PASS_START	SOC_TPLG_PASS_MANIFEST
-#define SOC_TPLG_PASS_END	SOC_TPLG_PASS_PCM_DAI
+#define SOC_TPLG_PASS_END	SOC_TPLG_PASS_PINS
 
 struct soc_tplg {
 	const struct firmware *fw;
Signature · 1 line
1.9.1
#14 lore raw

PATCH v2 9/10 ASoC: topology: Change stream formats to bitwise flag

In reply to [email protected]

From: Mengdong Lin <[email protected]>

The toplogy user space tool will generate this bitwise flag by using SNDRV_PCM_FORMAT_* exposed by asound.h, and the topology core will copy this flag when generating DAI streams.

include/uapi/sound/asoc.h +1 -1
index 69383b0..eb2ad59 100644
@@ -191,7 +191,7 @@ struct snd_soc_tplg_ctl_hdr {
 struct snd_soc_tplg_stream_caps {
 	__le32 size;		/* in bytes of this structure */
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-	__le64 formats[SND_SOC_TPLG_MAX_FORMATS];	/* supported formats SNDRV_PCM_FMTBIT_* */
+	__le64 formats;	/* supported formats SNDRV_PCM_FORMAT_* */
 	__le32 rates;		/* supported rates SNDRV_PCM_RATE_* */
 	__le32 rate_min;	/* min rate */
 	__le32 rate_max;	/* max rate */
Signature · 1 line
1.9.1
#26 lore raw

PATCH v2 10/10 ASOC: topology: Add PCM DAIs dynamically when loading them

In reply to [email protected]

From: Mengdong Lin <[email protected]>

Add PCM DAIs to ASoC core when loading them from topology. Embed dobj in the DAI to free it when unloading.

include/sound/soc-dai.h +1 -0
index 2df96b1..e8f0404 100644
@@ -207,6 +207,7 @@ struct snd_soc_dai_driver {
 	const char *name;
 	unsigned int id;
 	unsigned int base;
+	struct snd_soc_dobj dobj;
 
 	/* DAI driver callbacks */
 	int (*probe)(struct snd_soc_dai *dai);
include/sound/soc-topology.h +0 -1
index 5405f64..a49c134 100644
@@ -71,7 +71,6 @@ struct snd_soc_dobj {
 	union {
 		struct snd_soc_dobj_control control;
 		struct snd_soc_dobj_widget widget;
-		struct snd_soc_dobj_pcm_dai pcm_dai;
 	};
 	void *private; /* core does not touch this */
 };
sound/soc/soc-topology.c +76 -15

127 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [PATCH v2 01/10] ASoC: Change the PCM runtime array to a list

In reply to [email protected]

sound/soc/samsung/speyside.c static int speyside_set_bias_level(struct snd_soc_card *card, · line 34

Quoted 3 lines · On Mon, Aug 10, 2015 at 10:45:28PM +0800, [email protected] wrote:
sound/soc/samsung/speyside.c +3 -0
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+	codec_dai = rtd->codec_dai;
+

For ease of review please split the addition of this new interface for getting the runtime from the change to the implementation - the same function can be written in terms of a list. As ever please make one change per commit :(

sound/soc/soc-core.c static inline void snd_soc_debugfs_exit(void) · line 560

Quoted 9 lines
sound/soc/soc-core.c +9 -0
+static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
+	struct snd_soc_card *card, struct snd_soc_dai_link *dai_link)
+{
+	struct snd_soc_pcm_runtime *rtd;
+
+	rtd = devm_kzalloc(card->dev,
+			sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL);
+	if (!rtd)
+		return NULL;

Why are we allocating something with devm_kzalloc()...

sound/soc/soc-core.c static inline void snd_soc_debugfs_exit(void) · line 580

Quoted 7 lines
sound/soc/soc-core.c +7 -0
+static void soc_free_pcm_runtime(struct snd_soc_card *card,
+	struct snd_soc_pcm_runtime *rtd)
+{
+	if (rtd->codec_dai)
+		devm_kfree(card->dev, rtd->codec_dais);
+	devm_kfree(card->dev, rtd);
+}

...things that we later explicitly free in (hopefully?) all cases.

sound/soc/soc-core.c static inline void snd_soc_debugfs_exit(void) · line 600

Quoted 11 lines
sound/soc/soc-core.c +11 -0
+static void soc_remove_pcm_runtimes(struct snd_soc_card *card)
+{
+	struct snd_soc_pcm_runtime *rtd, *_rtd;
+
+	list_for_each_entry_safe(rtd, _rtd, &card->rtd_list, list) {
+		list_del(&rtd->list);
+		soc_free_pcm_runtime(card, rtd);
+	}
+
+	card->num_rtd = 0;
+}

Why doesn't the free function do the list removal?

maintainer
#8 lore raw

Re: [PATCH v2 05/10] ASoC: Add support for dummy DAI links and PCM runtimes

In reply to [email protected]
Quoted 7 lines · On Mon, Aug 10, 2015 at 10:47:47PM +0800, [email protected] wrote:

Add dummy flag to a DAI link and PCM runtime. A dummy link will create a dummy PCM runtime.

A machine driver can define dummy dai links to specify the expected platform and codec. And its dummy runtime is used to probe the platform and codec components, which can bring real DAI/DAI links based on topology. After components probing, all dummy PCM runtimes will be removed.

This isn't very clear to me either in terms of the description or the interface. As far as I can tell these links that are being created here are placeholders representing links that will actually be instantiated later but if that's the case they're not really dummies as I'd understand them, they are real links which physically exist and will be created later by topology data. If we are going to do things this way we need a better way of talking about these not yet instantiated links.

I'm really confused as to why physical links that exist in the board are coming in via topology information loaded from userspace - it's not like the DSP firmware is going to be able to physically connect the DSP to things where no links existed before. I'd expect that these links are connections between physical devices which just exist in the system and that while the topology information might leave some of them dangling they wouldn't be created or removed.

Presumably we're also going to need to handle the case where the firmware is unloaded and we destroy the links if we do this...

maintainer
#15 lore raw

Re: [PATCH v2 09/10] ASoC: topology: Change stream formats to bitwise flag

In reply to [email protected]

include/uapi/sound/asoc.h struct snd_soc_tplg_ctl_hdr { · line 194

Quoted 5 lines · On Mon, Aug 10, 2015 at 10:48:37PM +0800, [email protected] wrote:

struct snd_soc_tplg_stream_caps {

include/uapi/sound/asoc.h +1 -1
 	__le32 size;		/* in bytes of this structure */
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-	__le64 formats[SND_SOC_TPLG_MAX_FORMATS];	/* supported formats SNDRV_PCM_FMTBIT_* */
+	__le64 formats;	/* supported formats SNDRV_PCM_FORMAT_* */

Argh, this is *another* ABI change which you've buried in the middle of a series you're sending right at the end of the release cycle (this was sent after -rc6, we may not even get a -rc7...). Given how close we are to the release and the invasiveness of the changes in this series it's very lucky I even saw it before release, I'm reading this on my flight to Plumbers which means my bandwidth next week will be limited.

This should have at the very least been sent at the start of the series, and really should have been sent separately. It is also worrying that there is nothing in the subject or changelog talking about the fact that this is an ABI change or explaining why it is required. The changelog was simply a statement of the content of the diff, not a rationale:

| The toplogy user space tool will generate this bitwise flag by using
| SNDRV_PCM_FORMAT_* exposed by asound.h, and the topology core will copy
| this flag when generating DAI streams.

Once the release goes out this sort of incompatible change will be unacceptable. Given the number of changes that are going into the ABI (we also had some others went in last week) I'm now giving some serious thought to the idea that we should ask Linus to revert the topology code for v4.2 and waiting for v4.3 so we've got more chance to make sure the ABI is one we actually want to stick with. Liam, Takashi I don't know what you think?

#16 lore raw

Re: [PATCH v2 09/10] ASoC: topology: Change stream formats to bitwise flag

Quoted 15 lines · Mark Brown

include/uapi/sound/asoc.h struct snd_soc_tplg_ctl_hdr { · line 194

Quoted 5 lines · On Mon, Aug 10, 2015 at 10:48:37PM +0800, [email protected] wrote:

struct snd_soc_tplg_stream_caps {

include/uapi/sound/asoc.h +1 -1
 	__le32 size;		/* in bytes of this structure */
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-	__le64 formats[SND_SOC_TPLG_MAX_FORMATS];	/* supported formats SNDRV_PCM_FMTBIT_* */
+	__le64 formats;	/* supported formats SNDRV_PCM_FORMAT_* */

Argh, this is *another* ABI change which you've buried in the middle of a series you're sending right at the end of the release cycle (this was sent after -rc6, we may not even get a -rc7...). Given how close we are to the release and the invasiveness of the changes in this series it's very lucky I even saw it before release, I'm reading this on my flight to Plumbers which means my bandwidth next week will be limited.

Thanks for checking this. Mengdong, if there is a change in uapi/*, this means touching ABI. So, this change isn't acceptable once when the kernel is released. At least, the backward compatibility *must* be kept no matter which version is.

Also, the patch (and even the current code) looks wrong. The current formats[] would receive SNDRV_PCM_FORMAT_* while the comment shows SNDRV_PCM_FMT_BIT_*. And your patch changes it again wrongly in the comment. Quite confusing.

Quoted 10 lines

This should have at the very least been sent at the start of the series, and really should have been sent separately. It is also worrying that there is nothing in the subject or changelog talking about the fact that this is an ABI change or explaining why it is required. The changelog was simply a statement of the content of the diff, not a rationale:

| The toplogy user space tool will generate this bitwise flag by using
| SNDRV_PCM_FORMAT_* exposed by asound.h, and the topology core will copy
| this flag when generating DAI streams.
Quoted 7 lines

Once the release goes out this sort of incompatible change will be unacceptable. Given the number of changes that are going into the ABI (we also had some others went in last week) I'm now giving some serious thought to the idea that we should ask Linus to revert the topology code for v4.2 and waiting for v4.3 so we've got more chance to make sure the ABI is one we actually want to stick with. Liam, Takashi I don't know what you think?

We can make the topology stuff disabled in Makefile (and the only call in soc-core.c) instead of the whole revert. This will be the minimal impact and safe enough.

BTW, I wonder why there is no Kconfig for topology stuff. If we had it, it would have been easy to disable.

thanks,

Takashi

#27 lore raw
In reply to [email protected]
Quoted 10 lines · On 08/10/2015 04:45 PM, [email protected] wrote:

From: Mengdong Lin <[email protected]>

This series allows the topology core to create PCM devices dynamically. The user can define different DAIs in the topology files for different versions of firmware, but share a generic platform and machine driver.

A dummy DAI and DAI link can be used to register the soc card and specify the platform with topology. Then real DAIs are created in platform probing phase by the topology core, and the machine driver will be notified to create relavant DAI links.

This all sounds as if the dynamically loaded topology information does not describe dynamic topology, e.g. like DSP firmware, but rather the static topology that would usually come from things like devicetree or ACPI. Maybe you need to rethink when the topology information is loaded and make sure that the parts that describe the static topology are available before the card is instantiated.

- Lars

#17 lore raw

Re: [PATCH v2 09/10] ASoC: topology: Change stream formats to bitwise flag

In reply to Takashi Iwai
Quoted 23 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Saturday, August 15, 2015 3:38 PM

Quoted 2 lines · Mark Brown

On Mon, Aug 10, 2015 at 10:48:37PM +0800, [email protected]

Quoted 5 lines · wrote:

include/uapi/sound/asoc.h struct snd_soc_tplg_ctl_hdr {

Quoted 5 lines

struct snd_soc_tplg_stream_caps {

include/uapi/sound/asoc.h +0 -1
 	__le32 size;		/* in bytes of this structure */
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-	__le64 formats[SND_SOC_TPLG_MAX_FORMATS];	/* supported

formats SNDRV_PCM_FMTBIT_* */

Quoted 8 lines

include/uapi/sound/asoc.h struct snd_soc_tplg_ctl_hdr { · line 194

Quoted 1 line
include/uapi/sound/asoc.h +1 -0
+	__le64 formats;	/* supported formats SNDRV_PCM_FORMAT_* */

Argh, this is *another* ABI change which you've buried in the middle of a series you're sending right at the end of the release cycle (this was sent after -rc6, we may not even get a -rc7...). Given how close we are to the release and the invasiveness of the changes in this series it's very lucky I even saw it before release, I'm reading this on my flight to Plumbers which means my bandwidth next week will be

Quoted 6 lines

limited.

Thanks for checking this. Mengdong, if there is a change in uapi/*, this means touching ABI. So, this change isn't acceptable once when the kernel is released. At least, the backward compatibility *must* be kept no matter which version is.

Thanks for your review, Mark and Takashi.
This series including the ABI change, is not for v4.2, but is an RFC to adding DAI/DAI links support in topology. I'm sorry that I should have explicitly said this in my comments.

Is there some topic branch which can accept topology patches for next kernel release? Can we change topology ABI in v4.3?

Now only Intel SKL driver is using topology code, so the affect should be limited.
And I feel using bitwise flag is simpler in both user space and in kernel coding.
We can increase the topology ABI number when there is ABI change, and the topology driver always checks this version.

Quoted 4 lines

Also, the patch (and even the current code) looks wrong. The current formats[] would receive SNDRV_PCM_FORMAT_* while the comment shows SNDRV_PCM_FMT_BIT_*. And your patch changes it again wrongly in the comment. Quite confusing.

Sorry. I will change the comments.
I hope to change "formats" to a bitwise flag of _SNDRV_PCM_FMTBIT_*.
Current upstreamed topology driver does not really handle DAIs (streams caps) so the error is not discovered.

Quoted 19 lines
Quoted 5 lines

This should have at the very least been sent at the start of the series, and really should have been sent separately. It is also worrying that there is nothing in the subject or changelog talking about the fact that this is an ABI change or explaining why it is required. The changelog was simply a statement of the content of the diff,

not a rationale:

Quoted 5 lines
| The toplogy user space tool will generate this bitwise flag by using
| SNDRV_PCM_FORMAT_* exposed by asound.h, and the topology core will
| copy this flag when generating DAI streams.
Quoted 7 lines

Once the release goes out this sort of incompatible change will be unacceptable. Given the number of changes that are going into the ABI (we also had some others went in last week) I'm now giving some serious thought to the idea that we should ask Linus to revert the topology code for v4.2 and waiting for v4.3 so we've got more chance to make sure the ABI is one we actually want to stick with. Liam, Takashi I don't know what you think?

Quoted 6 lines

We can make the topology stuff disabled in Makefile (and the only call in soc-core.c) instead of the whole revert. This will be the minimal impact and safe enough.

BTW, I wonder why there is no Kconfig for topology stuff. If we had it, it would have been easy to disable.

We'll add Kconfig for topology.

Thanks
Mengdong

#18 lore raw

Re: [PATCH v2 09/10] ASoC: topology: Change stream formats to bitwise flag

Quoted 31 lines · Mengdong
Quoted 24 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Saturday, August 15, 2015 3:38 PM

Quoted 2 lines · Mark Brown

On Mon, Aug 10, 2015 at 10:48:37PM +0800, [email protected]

Quoted 5 lines · wrote:

include/uapi/sound/asoc.h struct snd_soc_tplg_ctl_hdr {

Quoted 5 lines

struct snd_soc_tplg_stream_caps {

include/uapi/sound/asoc.h +0 -1
 	__le32 size;		/* in bytes of this structure */
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-	__le64 formats[SND_SOC_TPLG_MAX_FORMATS];	/* supported

formats SNDRV_PCM_FMTBIT_* */

Quoted 8 lines

include/uapi/sound/asoc.h struct snd_soc_tplg_ctl_hdr { · line 194

Quoted 1 line
include/uapi/sound/asoc.h +1 -0
+	__le64 formats;	/* supported formats SNDRV_PCM_FORMAT_* */

Argh, this is *another* ABI change which you've buried in the middle of a series you're sending right at the end of the release cycle (this was sent after -rc6, we may not even get a -rc7...). Given how close we are to the release and the invasiveness of the changes in this series it's very lucky I even saw it before release, I'm reading this on my flight to Plumbers which means my bandwidth next week will be

Quoted 6 lines

limited.

Thanks for checking this. Mengdong, if there is a change in uapi/*, this means touching ABI. So, this change isn't acceptable once when the kernel is released. At least, the backward compatibility *must* be kept no matter which version is.

Quoted 6 lines

Thanks for your review, Mark and Takashi.
This series including the ABI change, is not for v4.2, but is an RFC to adding DAI/DAI links support in topology. I'm sorry that I should have explicitly said this in my comments.

Is there some topic branch which can accept topology patches for next kernel release? Can we change topology ABI in v4.3?

In general "yes, but only if it's backward-compatible".

Quoted 2 lines

Now only Intel SKL driver is using topology code, so the affect should be limited. And I feel using bitwise flag is simpler in both user space and in kernel coding.

Yes, using FMTBIT_* is better, but this must not justify to break ABI. Either we disable this API/ABI for 4.2, or make the change backward compatible.

Quoted 1 line

We can increase the topology ABI number when there is ABI change, and the topology driver always checks this version.

It's a big NO, sorry, this isn't acceptable. Again, the kernel must give the backward compatibility. That is, the kernel must accept the old dialect the user space talks if user space wants. You cannot force user space to communicate in a new ABI out of sudden.

So, yes, ABI version bump is needed if you change ABI. But it means that the kernel accepts all ABIs up to this version, not meaning *only* this ABI version.

Hopefully this clarifies the situation.

thanks,

Takashi

maintainer
#24 lore raw

Re: [PATCH v2 09/10] ASoC: topology: Change stream formats to bitwise flag

In reply to Takashi Iwai
Quoted 3 lines · Takashi Iwai

We can make the topology stuff disabled in Makefile (and the only call in soc-core.c) instead of the whole revert. This will be the minimal impact and safe enough.

Yes, though it does leave the UAPI files there for people to look at which is a big part of the risk since they end up getting shipped separately to the kernel binary. Might be sufficient, though - we could just put some #errors in the headers to catch potential users. Or perhaps we're OK with the ABI as it stands.

Quoted 2 lines

BTW, I wonder why there is no Kconfig for topology stuff. If we had it, it would have been easy to disable.

It's probably worth adding that anyway - I know Intel at least are keen on having the capability to minimise memory usage!

maintainer
#23 lore raw

Re: [PATCH v2 09/10] ASoC: topology: Change stream formats to bitwise flag

In reply to Lin, Mengdong
Quoted 2 lines · Mengdong

Is there some topic branch which can accept topology patches for next kernel release? Can we change topology ABI in v4.3?

You're not quite getting the issue here - the problem is that once we have released the ABI we need to keep supporting applications using it so we can't just change the ABI, we also need to keep compatibility code for the original ABI. This makes it a lot more effort to change things.

Quoted 5 lines

Now only Intel SKL driver is using topology code, so the affect should be limited. And I feel using bitwise flag is simpler in both user space and in kernel coding. We can increase the topology ABI number when there is ABI change, and the topology driver always checks this version.

Someone else may take this kernel and use it in their product, or some distro may decide to ship v4.2 as their kernel. Once it's in a release we have to assume someone is going to start relying on the ABI.

#19 lore raw

Re: [PATCH v2 09/10] ASoC: topology: Change stream formats to bitwise flag

In reply to Takashi Iwai
Quoted 50 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Saturday, August 15, 2015 10:46 PM

Quoted 9 lines · Mengdong
Quoted 9 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Saturday, August 15, 2015 3:38 PM

Quoted 2 lines · Mark Brown

On Mon, Aug 10, 2015 at 10:48:37PM +0800, [email protected]

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines · wrote:

include/uapi/sound/asoc.h struct snd_soc_tplg_ctl_hdr {

Quoted 5 lines

struct snd_soc_tplg_stream_caps {

include/uapi/sound/asoc.h +0 -1
 	__le32 size;		/* in bytes of this structure */
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-	__le64 formats[SND_SOC_TPLG_MAX_FORMATS];	/* supported

formats SNDRV_PCM_FMTBIT_* */

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	__le64 formats;	/* supported formats SNDRV_PCM_FORMAT_*

*/

Quoted 10 lines
Quoted 10 lines
Quoted 8 lines

Argh, this is *another* ABI change which you've buried in the middle of a series you're sending right at the end of the release cycle (this was sent after -rc6, we may not even get a -rc7...). Given how close we are to the release and the invasiveness of the changes in this series it's very lucky I even saw it before release, I'm reading this on my flight to Plumbers which means my bandwidth next week will be

limited.

Quoted 7 lines
Quoted 4 lines

Thanks for checking this. Mengdong, if there is a change in uapi/*, this means touching ABI. So, this change isn't acceptable once when the kernel is released. At least, the backward compatibility *must* be kept no matter which version is.

Thanks for your review, Mark and Takashi.
This series including the ABI change, is not for v4.2, but is an RFC to adding

DAI/DAI links support in topology.

Quoted 3 lines

I'm sorry that I should have explicitly said this in my comments.

Is there some topic branch which can accept topology patches for next

kernel release?

Quoted 1 line

Can we change topology ABI in v4.3?

In general "yes, but only if it's backward-compatible".

Quoted 7 lines
Quoted 1 line

Now only Intel SKL driver is using topology code, so the affect should be

limited.

Quoted 1 line

And I feel using bitwise flag is simpler in both user space and in kernel

coding.

Yes, using FMTBIT_* is better, but this must not justify to break ABI. Either we disable this API/ABI for 4.2, or make the change backward compatible.

Many thanks for your clarification!
We'd better keep current ABI unchanged to keep backward compatibility.

In addition, does "disable this API/ABI for 4.2" mean disabling all topology features, or only some structures for v4.2? But alsa-lib already integrated this ABI version.

I'm worried that If we have to add new fields to ABI structures, how to keep the backward compatibility.

Thanks
Mengdong

Quoted 19 lines
Quoted 2 lines

We can increase the topology ABI number when there is ABI change, and

the topology driver always checks this version.

It's a big NO, sorry, this isn't acceptable. Again, the kernel must give the backward compatibility. That is, the kernel must accept the old dialect the user space talks if user space wants. You cannot force user space to communicate in a new ABI out of sudden.

So, yes, ABI version bump is needed if you change ABI. But it means that the kernel accepts all ABIs up to this version, not meaning
*only* this ABI version.

Hopefully this clarifies the situation.

thanks,

Takashi

maintainer
#28 lore raw
In reply to Lars-Peter Clausen
Quoted 6 lines · Lars-Peter Clausen

This all sounds as if the dynamically loaded topology information does not describe dynamic topology, e.g. like DSP firmware, but rather the static topology that would usually come from things like devicetree or ACPI. Maybe you need to rethink when the topology information is loaded and make sure that the parts that describe the static topology are available before the card is instantiated.

I do think that's some of it (as I said in my replies in the series), but I got the impression from some other discussion that some of this was about host<->DSP channels that exist purely in software which does seem like something that could reasonably be in the topology, but this does seem more like the fixed links stuff.

#20 lore raw

Re: [PATCH v2 09/10] ASoC: topology: Change stream formats to bitwise flag

In reply to Lin, Mengdong
Quoted 56 lines · Mengdong
Quoted 56 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Saturday, August 15, 2015 10:46 PM

Quoted 9 lines · Mengdong
Quoted 9 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Saturday, August 15, 2015 3:38 PM

Quoted 2 lines · Mark Brown

On Mon, Aug 10, 2015 at 10:48:37PM +0800, [email protected]

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines · wrote:

include/uapi/sound/asoc.h struct snd_soc_tplg_ctl_hdr {

Quoted 5 lines

struct snd_soc_tplg_stream_caps {

include/uapi/sound/asoc.h +0 -1
 	__le32 size;		/* in bytes of this structure */
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-	__le64 formats[SND_SOC_TPLG_MAX_FORMATS];	/* supported

formats SNDRV_PCM_FMTBIT_* */

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+	__le64 formats;	/* supported formats SNDRV_PCM_FORMAT_*

*/

Quoted 10 lines
Quoted 10 lines
Quoted 8 lines

Argh, this is *another* ABI change which you've buried in the middle of a series you're sending right at the end of the release cycle (this was sent after -rc6, we may not even get a -rc7...). Given how close we are to the release and the invasiveness of the changes in this series it's very lucky I even saw it before release, I'm reading this on my flight to Plumbers which means my bandwidth next week will be

limited.

Quoted 7 lines
Quoted 4 lines

Thanks for checking this. Mengdong, if there is a change in uapi/*, this means touching ABI. So, this change isn't acceptable once when the kernel is released. At least, the backward compatibility *must* be kept no matter which version is.

Thanks for your review, Mark and Takashi.
This series including the ABI change, is not for v4.2, but is an RFC to adding

DAI/DAI links support in topology.

Quoted 3 lines

I'm sorry that I should have explicitly said this in my comments.

Is there some topic branch which can accept topology patches for next

kernel release?

Quoted 1 line

Can we change topology ABI in v4.3?

In general "yes, but only if it's backward-compatible".

Quoted 1 line

Now only Intel SKL driver is using topology code, so the affect should be

limited.

Quoted 1 line

And I feel using bitwise flag is simpler in both user space and in kernel

coding.

Quoted 7 lines
Quoted 2 lines

Yes, using FMTBIT_* is better, but this must not justify to break ABI. Either we disable this API/ABI for 4.2, or make the change backward compatible.

Many thanks for your clarification!
We'd better keep current ABI unchanged to keep backward compatibility.

In addition, does "disable this API/ABI for 4.2" mean disabling all topology features, or only some structures for v4.2?

I suppose the whole topology feature.

Quoted 1 line

But alsa-lib already integrated this ABI version.

Yes, but it's no big problem, as we haven't released alsa-lib changes yet.

Quoted 1 line

I'm worried that If we have to add new fields to ABI structures, how to keep the backward compatibility.

There are reserved areas for the future extension, and usually take a part of them for the additional fields. Even if doing that, it's still very sensitive to change the structure in general, though.

Takashi

maintainer
#21 lore raw

Re: [PATCH v2 09/10] ASoC: topology: Change stream formats to bitwise flag

In reply to Lin, Mengdong
Quoted 3 lines · Mengdong

In addition, does "disable this API/ABI for 4.2" mean disabling all topology features, or only some structures for v4.2? But alsa-lib already integrated this ABI version.

I'm suggesting not including this at all in the v4.2 release so we can continue to make changes, or perhaps just leaving the code there but making sure it can't be used as Takashi suggested. alsa-lib hasn't released yet as far as I'm aware so we can continue to make changes there.

Quoted 2 lines

I'm worried that If we have to add new fields to ABI structures, how to keep the backward compatibility.

Right, it's tricky - there's a bunch of techniques like the versioning that's in the current structures but they all take work and effort.

#25 lore raw

Re: [PATCH v2 09/10] ASoC: topology: Change stream formats to bitwise flag

In reply to Mark Brown
Quoted 10 lines · Mark Brown
Quoted 3 lines · Takashi Iwai

We can make the topology stuff disabled in Makefile (and the only call in soc-core.c) instead of the whole revert. This will be the minimal impact and safe enough.

Yes, though it does leave the UAPI files there for people to look at which is a big part of the risk since they end up getting shipped separately to the kernel binary.

True, if we want really 120% safety...

Quoted 3 lines

Might be sufficient, though - we could
just put some #errors in the headers to catch potential users. Or perhaps we're OK with the ABI as it stands.

Yeah, #error or a big fat comment should suffice, I suppose.

Quoted 5 lines
Quoted 2 lines

BTW, I wonder why there is no Kconfig for topology stuff. If we had it, it would have been easy to disable.

It's probably worth adding that anyway - I know Intel at least are keen on having the capability to minimise memory usage!

Right, I had it in my mind, too.

Takashi

#29 lore raw
In reply to Mark Brown
Quoted 18 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Saturday, August 15, 2015 11:51 PM
To: Lars-Peter Clausen
Cc: Lin, Mengdong; [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [alsa-devel] [PATCH v2 00/10] ASoC: support adding PCM dynamically from topology

Quoted 6 lines · Lars-Peter Clausen

This all sounds as if the dynamically loaded topology information does not describe dynamic topology, e.g. like DSP firmware, but rather the static topology that would usually come from things like devicetree or ACPI. Maybe you need to rethink when the topology information is loaded and make sure that the parts that describe the static topology are available before the card is instantiated.

Quoted 5 lines

I do think that's some of it (as I said in my replies in the series), but I got the impression from some other discussion that some of this was about host<->DSP channels that exist purely in software which does seem like something that could reasonably be in the topology, but this does seem more like the fixed links stuff.

We hope to release different firmware for different OEM products.
Due to license restrictions, these firmware may have different features and may support different FE DAIs.

ACPI only describes physical links and does not handle FE DAIs. This is why we use topology here.

Thanks
Mengdong

#3 lore raw

Re: [PATCH v2 01/10] ASoC: Change the PCM runtime array to a list

In reply to Mark Brown
Quoted 6 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Saturday, August 15, 2015 4:03 AM

On Mon, Aug 10, 2015 at 10:45:28PM +0800, [email protected] wrote:

Quoted 7 lines

sound/soc/samsung/speyside.c static int speyside_set_bias_level(struct snd_soc_card *card, · line 34

Quoted 3 lines
sound/soc/samsung/speyside.c +3 -0
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+	codec_dai = rtd->codec_dai;
+

For ease of review please split the addition of this new interface for getting the runtime from the change to the implementation - the same function can be written in terms of a list. As ever please make one change per commit :(

Okay. I'll split adding snd_soc_get_pcm_runtime() to a new commit.

Quoted 10 lines

sound/soc/soc-core.c static inline void snd_soc_debugfs_exit(void) · line 560

Quoted 8 lines
sound/soc/soc-core.c +8 -0
+static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
+	struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) {
+	struct snd_soc_pcm_runtime *rtd;
+
+	rtd = devm_kzalloc(card->dev,
+			sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL);
+	if (!rtd)
+		return NULL;

Why are we allocating something with devm_kzalloc()...

I'll change to use kzalloc() and free the memory for the error path.

Quoted 9 lines

sound/soc/soc-core.c static inline void snd_soc_debugfs_exit(void) · line 580

Quoted 7 lines
sound/soc/soc-core.c +7 -0
+static void soc_free_pcm_runtime(struct snd_soc_card *card,
+	struct snd_soc_pcm_runtime *rtd)
+{
+	if (rtd->codec_dai)
+		devm_kfree(card->dev, rtd->codec_dais);
+	devm_kfree(card->dev, rtd);
+}

...things that we later explicitly free in (hopefully?) all cases.

Okay.

Quoted 4 lines
Quoted 4 lines
sound/soc/soc-core.c +4 -0
+static void soc_remove_pcm_runtimes(struct snd_soc_card *card) {
+	struct snd_soc_pcm_runtime *rtd, *_rtd;
+
+	list_for_each_entry_safe(rtd, _rtd, &card->rtd_list, list) {
Quoted 8 lines

sound/soc/soc-core.c static inline void snd_soc_debugfs_exit(void) · line 600

Quoted 6 lines
sound/soc/soc-core.c +6 -0
+		list_del(&rtd->list);
+		soc_free_pcm_runtime(card, rtd);
+	}
+
+	card->num_rtd = 0;
+}

Why doesn't the free function do the list removal?

Sorry, I'll add the list removal.

Thanks
Mengdong

#9 lore raw

Re: [PATCH v2 05/10] ASoC: Add support for dummy DAI links and PCM runtimes

In reply to Mark Brown
Quoted 15 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Saturday, August 15, 2015 4:22 AM

Quoted 6 lines · On Mon, Aug 10, 2015 at 10:47:47PM +0800, [email protected] wrote:

Add dummy flag to a DAI link and PCM runtime. A dummy link will create a dummy PCM runtime.

A machine driver can define dummy dai links to specify the expected platform and codec. And its dummy runtime is used to probe the platform and codec components, which can bring real DAI/DAI links based

on topology.

Quoted 1 line

After components probing, all dummy PCM runtimes will be removed.

Quoted 7 lines

This isn't very clear to me either in terms of the description or the interface. As far as I can tell these links that are being created here are placeholders representing links that will actually be instantiated later but if that's the case they're not really dummies as I'd understand them, they are real links which physically exist and will be created later by topology data. If we are going to do things this way we need a better way of talking about these not yet instantiated links.

(Sorry. I'm still trying to enable my 2nd mail account & client. So this reply can still have format problems.)

These *dummy* links are not place holders of real physical links. So they cannot come from ACPI but from topology.

Here is an example used in my test on Broadwell:

/* broadwell digital audio interface glue - connects codec <--> CPU */

 static struct snd_soc_dai_link broadwell_rt286_dais[] = {
	/* Front End dummy DAI links */
 	{
		.name = "Dummy System PCM",
		.stream_name = "Dummy System Playback/Capture",
		.cpu_dai_name = "snd-soc-dummy-dai",
 		.platform_name = "haswell-pcm-audio",
 		.dynamic = 1,
 		.codec_name = "snd-soc-dummy",
 		.codec_dai_name = "snd-soc-dummy-dai",
	}
	...

All real FE DAI links will no longer be in this link array.

We use this dummy DAI link to avoid snd_soc_instantiate_card() fail on binding DAI links.

And since this dummy link specify the platform "haswell-pcm-audio", soc_bind_dai_link() will promise the platform component is there.
And then platform probing will load topology and the topology core will create the real FE DAIs.

And the machine driver will get notified when a new FE DAI is added to the ASoC core. It can create FE links in the callback context according to the new FE DAI info.

This seems to give us small code change.

Thanks
Mengdong

Quoted 10 lines

I'm really confused as to why physical links that exist in the board are coming in via topology information loaded from userspace - it's not like the DSP firmware is going to be able to physically connect the DSP to things where no links existed before. I'd expect that these links are connections between physical devices which just exist in the system and that while the topology information might leave some of them dangling they wouldn't be created or removed.

Presumably we're also going to need to handle the case where the firmware is unloaded and we destroy the links if we do this...

Yes. The DAI/DAI links created by topology should be destroyed when unloading the topology component.

Now there is no product request to unload/change the firmware as well as its topology in the middle. We may consider this later.

Thanks
Mengdong

#22 lore raw

Re: [PATCH v2 09/10] ASoC: topology: Change stream formats to bitwise flag

In reply to Mark Brown
Quoted 6 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Sunday, August 16, 2015 12:52 AM

On Sat, Aug 15, 2015 at 03:25:18PM +0000, Lin, Mengdong wrote:

Quoted 8 lines
Quoted 3 lines

In addition, does "disable this API/ABI for 4.2" mean disabling all topology features, or only some structures for v4.2? But alsa-lib already integrated this ABI version.

I'm suggesting not including this at all in the v4.2 release so we can continue to make changes, or perhaps just leaving the code there but making sure it can't be used as Takashi suggested. alsa-lib hasn't released yet as far as I'm aware so we can continue to make changes there.

Hi Takashi/Mark,

After syncing with Liam, we hope to disable topology in the v4.2 release atm but leave the code there.

There may be topology ABI changes later and keeping backward compatibility would be difficult.

Sorry for the inconvenience.

Thanks
Mengdong

Quoted 6 lines
Quoted 3 lines

I'm worried that If we have to add new fields to ABI structures, how to keep the backward compatibility.

Right, it's tricky - there's a bunch of techniques like the versioning that's in the current structures but they all take work and effort.

maintainer
#30 lore raw
In reply to Lin, Mengdong
Quoted 24 lines · Mengdong
Quoted 18 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Saturday, August 15, 2015 11:51 PM
To: Lars-Peter Clausen
Cc: Lin, Mengdong; [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [alsa-devel] [PATCH v2 00/10] ASoC: support adding PCM dynamically from topology

Quoted 6 lines · Lars-Peter Clausen

This all sounds as if the dynamically loaded topology information does not describe dynamic topology, e.g. like DSP firmware, but rather the static topology that would usually come from things like devicetree or ACPI. Maybe you need to rethink when the topology information is loaded and make sure that the parts that describe the static topology are available before the card is instantiated.

Quoted 5 lines

I do think that's some of it (as I said in my replies in the series), but I got the impression from some other discussion that some of this was about host<->DSP channels that exist purely in software which does seem like something that could reasonably be in the topology, but this does seem more like the fixed links stuff.

Quoted 5 lines

We hope to release different firmware for different OEM products.
Due to license restrictions, these firmware may have different features and may support different FE DAIs.

ACPI only describes physical links and does not handle FE DAIs. This is why we use topology here.

To further clarify.

The intention is that the topology data for BE and codec style links is not to define the link (as this should come from DT or ACPI) but to define the links config/capabilities for a given FW. e.g. we have two different FWs that run BE0 (SSP0) with different number of channels (one is stereo, the other is 4 channel TDM). Currently the link definitions will be hard coded until the ACPI data is ready.

The FE uses the above too for config/capabilities but it can also be defined and created by the topology data (since it's a FW entity).

Liam

maintainer
#10 lore raw

Re: [PATCH v2 05/10] ASoC: Add support for dummy DAI links and PCM runtimes

In reply to Lin, Mengdong
Quoted 2 lines · Mengdong

These *dummy* links are not place holders of real physical links. So they cannot come from ACPI but from topology.

OK, so this is something that should have been apparent from the changelog and if that's what's supposed to happen that shouldn be what the code does - it needs to be limited to these software only links.

But honestly this just doesn't seem like the ideal design - what this means is that we're going to need to have a dummy link in place for any link that is defined by the topology which means that we've got a hard coded limit in the drivers for this dynamically defined thing from the firmware. It'd be much nicer if we just created the links from scratch when we detect them in firmware rather than requiring these stubs.

maintainer
#31 lore raw
In reply to Liam Girdwood
Quoted 9 lines · Liam Girdwood

The intention is that the topology data for BE and codec style links is not to define the link (as this should come from DT or ACPI) but to define the links config/capabilities for a given FW. e.g. we have two different FWs that run BE0 (SSP0) with different number of channels (one is stereo, the other is 4 channel TDM). Currently the link definitions will be hard coded until the ACPI data is ready.

The FE uses the above too for config/capabilities but it can also be defined and created by the topology data (since it's a FW entity).

So this is actually for adding further constraints to the existing physical links, not just for defining new virtual links. That is definitely a reasonable application but it seems like what we should be doing here is adding constraints to a fully defined link rather than just having a dummy link. The link is real and there, it's just that we want to further restrict how it can be used. Something that says "this is a dummy link" definitely feels wrong.

#32 lore raw
Quoted 21 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Tuesday, August 18, 2015 4:05 AM
To: Liam Girdwood
Cc: Lars-Peter Clausen; [email protected]; [email protected]; Lin, Mengdong
Subject: Re: [alsa-devel] [PATCH v2 00/10] ASoC: support adding PCM dynamically from topology

Quoted 9 lines · Liam Girdwood

The intention is that the topology data for BE and codec style links is not to define the link (as this should come from DT or ACPI) but to define the links config/capabilities for a given FW. e.g. we have two different FWs that run BE0 (SSP0) with different number of channels (one is stereo, the other is 4 channel TDM). Currently the link definitions will be hard coded until the ACPI data is ready.

The FE uses the above too for config/capabilities but it can also be defined and created by the topology data (since it's a FW entity).

Quoted 6 lines

So this is actually for adding further constraints to the existing physical links, not just for defining new virtual links. That is definitely a reasonable application but it seems like what we should be doing here is adding constraints to a fully defined link rather than just having a dummy link. The link is real and there, it's just that we want to further restrict how it can be used. Something that says "this is a dummy link" definitely feels wrong.

I feel it's not enough to just "adding constraints to a fully defined link" for FE DAIs.
We need to determine the number of FE DAIs (thus FE DAI links as well) for a specific version of FW based on its topology info.

We use a "dummy FE DAI link" in the Broadwell machine driver just to
- pass the soc_bind_dai_link() on registering the soc card and use the deferred probe mechanism;
- pull in the platform component which carries topology the info

If you prefer not using any dummy DAI link but creating the links from scratch when we detect them in firmware, can we add new field into "struct snd_soc_card" to specify the components for topology? After all, topology may not only come from the platform component.

Thanks
Mengdong

maintainer
#33 lore raw
Quoted 2 lines · Mengdong

I feel it's not enough to just "adding constraints to a fully defined link" for FE DAIs.
We need to determine the number of FE DAIs (thus FE DAI links as well) for a specific version of FW based on its topology info.

There's two things going on here. One is configuring the limits on the DAIs that represent physical connections in the system, the other is creating new fully software DAIs for DSP<->AP links. The two cases are separate.

Quoted 2 lines

If you prefer not using any dummy DAI link but creating the links from scratch when we detect them in firmware, can we add new field into "struct snd_soc_card" to specify the components for topology? After all, topology may not only come from the platform component.

We need to come up with some mechanism for it. I'm not clear what a new field in the card would be, I'd more expect some runtime calls from the topology code but perhaps there's some way of doing this in a data driven way that I've just not thought of.