All of lore.kernel.org
 help / color / mirror / Atom feed
From: mengdong.lin@linux.intel.com
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Mengdong Lin <mengdong.lin@linux.intel.com>,
	tiwai@suse.de, mengdong.lin@intel.com,
	liam.r.girdwood@linux.intel.com, vinod.koul@intel.com,
	jeeja.kp@intel.com, subhransu.s.prusty@intel.com
Subject: [PATCH v2 12/13] ASoC: topology: Add support for FE DAI links
Date: Thu,  5 Nov 2015 18:00:06 +0800	[thread overview]
Message-ID: <5c62e7d5a59a2e861a3708ac40fa50973112c9f8.1446717205.git.mengdong.lin@linux.intel.com> (raw)
In-Reply-To: <cover.1446717205.git.mengdong.lin@linux.intel.com>

From: Mengdong Lin <mengdong.lin@linux.intel.com>

FE DAI links can be created from topology.

And a machine driver can register add_dai_link ops to the soc card,
to get notified when a new DAI link is created and bind machine-specific
info to the link.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/include/sound/soc-topology.h b/include/sound/soc-topology.h
index b51c207..6324537 100644
--- a/include/sound/soc-topology.h
+++ b/include/sound/soc-topology.h
@@ -123,6 +123,12 @@ struct snd_soc_tplg_ops {
 	int (*dai_unload)(struct snd_soc_component *,
 		struct snd_soc_dobj *);
 
+	/* DAI link - used for any driver specific init */
+	int (*link_load)(struct snd_soc_component *,
+		struct snd_soc_dai_link *link);
+	int (*link_unload)(struct snd_soc_component *,
+		struct snd_soc_dobj *);
+
 	/* callback to handle vendor bespoke data */
 	int (*vendor_load)(struct snd_soc_component *,
 		struct snd_soc_tplg_hdr *);
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 4d07a9e..31fe60a 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1039,6 +1039,7 @@ struct snd_soc_dai_link {
 	unsigned int ignore_pmdown_time:1;
 
 	struct list_head list; /* dai link list of the soc card */
+	struct snd_soc_dobj dobj;
 };
 
 struct snd_soc_codec_conf {
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 2201261..d07c6b0 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -340,6 +340,16 @@ static int soc_tplg_dai_load(struct soc_tplg *tplg,
 	return 0;
 }
 
+/* pass dynamic FE DAI configurations to component driver */
+static int soc_tplg_dai_link_load(struct soc_tplg *tplg,
+	struct snd_soc_dai_link *link)
+{
+	if (tplg->comp && tplg->ops && tplg->ops->link_load)
+		return tplg->ops->link_load(tplg->comp, link);
+
+	return 0;
+}
+
 /* tell the component driver that all firmware has been loaded in this request */
 static void soc_tplg_complete(struct soc_tplg *tplg)
 {
@@ -1617,10 +1627,46 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
 	return snd_soc_add_dai(tplg->comp, dai_drv);
 }
 
+static int soc_tplg_fe_link_create(struct soc_tplg *tplg,
+	struct snd_soc_tplg_pcm *pcm)
+{
+	struct snd_soc_dai_link *link;
+	int ret;
+
+	link = kzalloc(sizeof(struct snd_soc_dai_link), GFP_KERNEL);
+	if (link == NULL)
+		return -ENOMEM;
+
+	link->name = pcm->pcm_name;
+	link->stream_name = pcm->pcm_name;
+
+	/* pass control to component driver for optional further init */
+	ret = soc_tplg_dai_link_load(tplg, link);
+	if (ret < 0) {
+		dev_err(tplg->comp->dev, "ASoC: FE link loading failed\n");
+		kfree(link);
+		return ret;
+	}
+
+	link->dobj.index = tplg->index;
+	link->dobj.ops = tplg->ops;
+	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);
+	return 0;
+}
+
 static int soc_tplg_pcm_create(struct soc_tplg *tplg,
 	struct snd_soc_tplg_pcm *pcm)
 {
-	return soc_tplg_dai_create(tplg, pcm);
+	int ret;
+
+	ret = soc_tplg_dai_create(tplg, pcm);
+	if (ret < 0)
+		return ret;
+
+	return  soc_tplg_fe_link_create(tplg, pcm);
 }
 
 static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg,
-- 
1.9.1

  parent reply	other threads:[~2015-11-05  9:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-05  9:58 [PATCH v2 00/13] ASoC: topology: Add support for PCM, BE & CC links mengdong.lin
2015-11-05  9:58 ` [PATCH v2 01/13] ASoC: Vendor drivers get a link's runtime by snd_soc_get_pcm_runtime() mengdong.lin
2015-11-05  9:58 ` [PATCH v2 02/13] ASoC: Change the PCM runtime array to a list mengdong.lin
2015-11-05  9:58 ` [PATCH v2 03/13] ASoC: Define soc_init_dai_link() to wrap link intialization mengdong.lin
2015-11-05  9:58 ` [PATCH v2 04/13] ASoC: Change 2nd argument of soc_bind_dai_link() to DAI link pointer mengdong.lin
2015-11-25 17:57   ` Applied "ASoC: Change 2nd argument of soc_bind_dai_link() to DAI link pointer" to the asoc tree Mark Brown
2015-11-05  9:59 ` [PATCH v2 05/13] ASoC: Implement DAI links in a list & define API to add a link mengdong.lin
2015-11-05  9:59 ` [PATCH v2 06/13] ASoC: Add add_dai_link ops for a soc card mengdong.lin
2015-11-05  9:59 ` [PATCH v2 07/13] ASoC: soc_bind_dai_link() directly returns success for a bound DAI link mengdong.lin
2015-12-08 19:11   ` Applied "ASoC: soc_bind_dai_link() directly returns success for a bound DAI link" to the asoc tree Mark Brown
2015-11-05  9:59 ` [PATCH v2 08/13] ASoC: Bind new DAI links after probing components mengdong.lin
2015-12-08 19:11   ` Applied "ASoC: Bind new DAI links after probing components" to the asoc tree Mark Brown
2015-11-05  9:59 ` [PATCH v2 09/13] ASoC: The soc card can have auxiliary components mengdong.lin
2015-11-26 12:57   ` Lars-Peter Clausen
2015-11-05  9:59 ` [PATCH v2 10/13] ASoC: Support adding a DAI dynamically mengdong.lin
2015-11-05  9:59 ` [PATCH v2 11/13] ASoC: topology: Add PCM DAIs dynamically when loading them mengdong.lin
2015-11-05 10:00 ` mengdong.lin [this message]
2015-11-05 10:00 ` [PATCH v2 13/13] ASoC: topology: Add support for BE and CC DAI Links mengdong.lin
2015-11-05 10:15 ` [PATCH v2 00/13] ASoC: topology: Add support for PCM, BE & CC links Mengdong Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c62e7d5a59a2e861a3708ac40fa50973112c9f8.1446717205.git.mengdong.lin@linux.intel.com \
    --to=mengdong.lin@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jeeja.kp@intel.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=mengdong.lin@intel.com \
    --cc=subhransu.s.prusty@intel.com \
    --cc=tiwai@suse.de \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.