Commit 17fb1755 authored by Mengdong Lin's avatar Mengdong Lin Committed by Mark Brown

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: default avatarMengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 676c6b52
......@@ -1671,6 +1671,9 @@ int snd_soc_add_dai_link(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_link);
void snd_soc_remove_dai_link(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_link);
struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,
int id, const char *name,
const char *stream_name);
int snd_soc_register_dai(struct snd_soc_component *component,
struct snd_soc_dai_driver *dai_drv);
......
......@@ -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)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment