summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorMengdong Lin <mengdong.lin@linux.intel.com>2016-11-03 01:04:12 +0800
committerMark Brown <broonie@kernel.org>2016-11-04 11:16:51 -0600
commit17fb175520e5497d71351aa66a125324fcb625a7 (patch)
tree1224910f851f3d9ba89818ef6922666c416f578f /sound
parent676c6b5208f7ce6ccc7933ab210f24358ca99a7a (diff)
downloadop-kernel-dev-17fb175520e5497d71351aa66a125324fcb625a7.zip
op-kernel-dev-17fb175520e5497d71351aa66a125324fcb625a7.tar.gz
ASoC: Define API to find a dai link
Define the API to find an existing DAI link of the soc card by matching the ID, name and stream name. Some cards may use unique ID for each DAI link, so matching ID is enough, and name or stream name are not necessary. But user need to specify name or stream name as well if not sure whether link ID is unique since most cards use 0 as the default link ID. Topology can use this API to find an existing BE link and configure it. Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-core.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c0bbcd9..a7a1ca4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -972,6 +972,48 @@ struct snd_soc_dai *snd_soc_find_dai(
}
EXPORT_SYMBOL_GPL(snd_soc_find_dai);
+
+/**
+ * snd_soc_find_dai_link - Find a DAI link
+ *
+ * @card: soc card
+ * @id: DAI link ID to match
+ * @name: DAI link name to match, optional
+ * @stream name: DAI link stream name to match, optional
+ *
+ * This function will search all existing DAI links of the soc card to
+ * find the link of the same ID. Since DAI links may not have their
+ * unique ID, so name and stream name should also match if being
+ * specified.
+ *
+ * Return: pointer of DAI link, or NULL if not found.
+ */
+struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,
+ int id, const char *name,
+ const char *stream_name)
+{
+ struct snd_soc_dai_link *link, *_link;
+
+ lockdep_assert_held(&client_mutex);
+
+ list_for_each_entry_safe(link, _link, &card->dai_link_list, list) {
+ if (link->id != id)
+ continue;
+
+ if (name && (!link->name || strcmp(name, link->name)))
+ continue;
+
+ if (stream_name && (!link->stream_name
+ || strcmp(stream_name, link->stream_name)))
+ continue;
+
+ return link;
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(snd_soc_find_dai_link);
+
static bool soc_is_dai_link_bound(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_link)
{
OpenPOWER on IntegriCloud