ASoC: Export DAI register and widget ctor and dctor functions

To allow for more flexibility i.e. populating component DAIs dynamically
during its initialization, without being limited to topology loading
procedure, expose snd_soc_register(), snd_soc_dapm_new_dai_widgets() and
snd_soc_dapm_free_widget() functions.

Allows users to first check available resources e.g. number of PCMs
supported by HDAudio codec before allocating the number of DAPM
widgets needed. This prevents superfluous objects from being created or
allows driver to adjust to situation when resources are limited.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220311153544.136854-3-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Cezary Rojewski 2022-03-11 16:35:29 +01:00 коммит произвёл Mark Brown
Родитель c19bd02e90
Коммит da0398099a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 24D68B725D5487D0
3 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -429,6 +429,7 @@ struct snd_soc_dapm_widget *snd_soc_dapm_new_control_unlocked(
const struct snd_soc_dapm_widget *widget); const struct snd_soc_dapm_widget *widget);
int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm, int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
struct snd_soc_dai *dai); struct snd_soc_dai *dai);
void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w);
int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card); int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card);
void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card); void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);

Просмотреть файл

@ -2465,6 +2465,7 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name); dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name);
return dai; return dai;
} }
EXPORT_SYMBOL_GPL(snd_soc_register_dai);
/** /**
* snd_soc_unregister_dais - Unregister DAIs from the ASoC core * snd_soc_unregister_dais - Unregister DAIs from the ASoC core

Просмотреть файл

@ -2484,6 +2484,12 @@ static void dapm_free_path(struct snd_soc_dapm_path *path)
kfree(path); kfree(path);
} }
/**
* snd_soc_dapm_free_widget - Free specified widget
* @w: widget to free
*
* Removes widget from all paths and frees memory occupied by it.
*/
void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w)
{ {
struct snd_soc_dapm_path *p, *next_p; struct snd_soc_dapm_path *p, *next_p;
@ -2506,6 +2512,7 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w)
kfree_const(w->sname); kfree_const(w->sname);
kfree(w); kfree(w);
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_free_widget);
void snd_soc_dapm_reset_cache(struct snd_soc_dapm_context *dapm) void snd_soc_dapm_reset_cache(struct snd_soc_dapm_context *dapm)
{ {
@ -4208,6 +4215,13 @@ param_fail:
return ERR_PTR(ret); return ERR_PTR(ret);
} }
/**
* snd_soc_dapm_new_dai_widgets - Create new DAPM widgets
* @dapm: DAPM context
* @dai: parent DAI
*
* Returns 0 on success, error code otherwise.
*/
int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm, int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
@ -4253,6 +4267,7 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_new_dai_widgets);
int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card) int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
{ {