Commit 09f75f09 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-dai.c: add DAI get/match functions

Current ASoC is specifying and checking DAI name.
But where it came from and how to check was ambiguous.
This patch adds snd_soc_dai_name_get() / snd_soc_dlc_dai_is_match()
and makes it clear.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h6qco952.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 083912c2
...@@ -271,6 +271,8 @@ int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai, ...@@ -271,6 +271,8 @@ int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai,
struct snd_compr_stream *cstream, struct snd_compr_stream *cstream,
struct snd_compr_metadata *metadata); struct snd_compr_metadata *metadata);
const char *snd_soc_dai_name_get(struct snd_soc_dai *dai);
struct snd_soc_dai_ops { struct snd_soc_dai_ops {
/* /*
* DAI clocking configuration, all optional. * DAI clocking configuration, all optional.
......
...@@ -253,6 +253,47 @@ static inline int snd_soc_dlc_dai_is_empty(struct snd_soc_dai_link_component *dl ...@@ -253,6 +253,47 @@ static inline int snd_soc_dlc_dai_is_empty(struct snd_soc_dai_link_component *dl
return !dlc->dai_name; return !dlc->dai_name;
} }
static int snd_soc_is_matching_dai(const struct snd_soc_dai_link_component *dlc,
struct snd_soc_dai *dai)
{
if (!dlc)
return 0;
if (!dlc->dai_name)
return 1;
/* see snd_soc_dai_name_get() */
if (strcmp(dlc->dai_name, dai->name) == 0)
return 1;
if (dai->driver->name &&
strcmp(dai->driver->name, dlc->dai_name) == 0)
return 1;
if (dai->component->name &&
strcmp(dlc->dai_name, dai->component->name) == 0)
return 1;
return 0;
}
const char *snd_soc_dai_name_get(struct snd_soc_dai *dai)
{
/* see snd_soc_is_matching_dai() */
if (dai->name)
return dai->name;
if (dai->driver->name)
return dai->driver->name;
if (dai->component->name)
return dai->component->name;
return NULL;
}
EXPORT_SYMBOL_GPL(snd_soc_dai_name_get);
static int snd_soc_rtd_add_component(struct snd_soc_pcm_runtime *rtd, static int snd_soc_rtd_add_component(struct snd_soc_pcm_runtime *rtd,
struct snd_soc_component *component) struct snd_soc_component *component)
{ {
...@@ -810,18 +851,11 @@ struct snd_soc_dai *snd_soc_find_dai( ...@@ -810,18 +851,11 @@ struct snd_soc_dai *snd_soc_find_dai(
lockdep_assert_held(&client_mutex); lockdep_assert_held(&client_mutex);
/* Find CPU DAI from registered DAIs */ /* Find CPU DAI from registered DAIs */
for_each_component(component) { for_each_component(component)
if (!snd_soc_is_matching_component(dlc, component)) if (snd_soc_is_matching_component(dlc, component))
continue; for_each_component_dais(component, dai)
for_each_component_dais(component, dai) { if (snd_soc_is_matching_dai(dlc, dai))
if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
&& (!dai->driver->name
|| strcmp(dai->driver->name, dlc->dai_name)))
continue;
return dai; return dai;
}
}
return NULL; return NULL;
} }
...@@ -3316,9 +3350,7 @@ int snd_soc_get_dlc(const struct of_phandle_args *args, struct snd_soc_dai_link_ ...@@ -3316,9 +3350,7 @@ int snd_soc_get_dlc(const struct of_phandle_args *args, struct snd_soc_dai_link_
id--; id--;
} }
dlc->dai_name = dai->driver->name; dlc->dai_name = snd_soc_dai_name_get(dai);
if (!dlc->dai_name)
dlc->dai_name = pos->name;
} else if (ret) { } else if (ret) {
/* /*
* if another error than ENOTSUPP is returned go on and * if another error than ENOTSUPP is returned go on and
......
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