*参照元 [#ia02807e]
#backlinks
*説明 [#m4600dce]
-パス: [[linux-4.4.1/sound/soc/soc-core.c]]
-FIXME: これは何?
--説明
**引数 [#d58500b7]
-struct snd_soc_card *card
--
--[[linux-4.4.1/snd_soc_card]]
**返り値 [#j40d3c83]
-int
--
**参考 [#n6a8c425]
*実装 [#o5cd362c]
static int snd_soc_instantiate_card(struct snd_soc_card *card)
{
struct snd_soc_codec *codec;
int ret, i, order;
-
--[[linux-4.4.1/snd_soc_codec]]
mutex_lock(&client_mutex);
mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT);
-
--[[linux-4.4.1/mutex_lock()]]
--[[linux-4.4.1/client_mutex(global)]]
--[[linux-4.4.1/mutex_lock_nested()]]
/* bind DAIs */
for (i = 0; i < card->num_links; i++) {
ret = soc_bind_dai_link(card, i);
if (ret != 0)
goto base_error;
}
-
--[[linux-4.4.1/soc_bind_dai_link()]]
/* bind aux_devs too */
for (i = 0; i < card->num_aux_devs; i++) {
ret = soc_bind_aux_dev(card, i);
if (ret != 0)
goto base_error;
}
-
--[[linux-4.4.1/soc_bind_aux_dev()]]
/* initialize the register cache for each available codec */
list_for_each_entry(codec, &codec_list, list) {
if (codec->cache_init)
continue;
ret = snd_soc_init_codec_cache(codec);
if (ret < 0)
goto base_error;
}
-
--[[linux-4.4.1/list_for_each_entry()]]
--[[linux-4.4.1/snd_soc_init_codec_cache()]]
--[[linux-4.4.1/codec_list(global)]]
/* card bind complete so register a sound card */
ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
card->owner, 0, &card->snd_card);
if (ret < 0) {
dev_err(card->dev,
"ASoC: can't create sound card for card %s: %d\n",
card->name, ret);
goto base_error;
}
-
--[[linux-4.4.1/snd_card_new()]]
--[[linux-4.4.1/dev_err()]]
soc_init_card_debugfs(card);
-
--[[linux-4.4.1/soc_init_card_debugfs()]]
card->dapm.bias_level = SND_SOC_BIAS_OFF;
card->dapm.dev = card->dev;
card->dapm.card = card;
list_add(&card->dapm.list, &card->dapm_list);
-
--[[linux-4.4.1/list_add()]]
#ifdef CONFIG_DEBUG_FS
snd_soc_dapm_debugfs_init(&card->dapm, card->debugfs_card_root);
-
--[[linux-4.4.1/CONFIG_DEBUG_FS]]
--[[linux-4.4.1/snd_soc_dapm_debugfs_init()]]
#endif
#ifdef CONFIG_PM_SLEEP
/* deferred resume work */
INIT_WORK(&card->deferred_resume_work, soc_resume_deferred);
-
--[[linux-4.4.1/CONFIG_PM_SLEEP]]
--[[linux-4.4.1/INIT_WORK()]]
--[[linux-4.4.1/soc_resume_deferred()]]
#endif
if (card->dapm_widgets)
snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets,
card->num_dapm_widgets);
if (card->of_dapm_widgets)
snd_soc_dapm_new_controls(&card->dapm, card->of_dapm_widgets,
card->num_of_dapm_widgets);
-
--[[linux-4.4.1/snd_soc_dapm_new_controls()]]
/* initialise the sound card only once */
if (card->probe) {
ret = card->probe(card);
if (ret < 0)
goto card_probe_error;
}
/* probe all components used by DAI links on this card */
for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
order++) {
for (i = 0; i < card->num_links; i++) {
ret = soc_probe_link_components(card, i, order);
if (ret < 0) {
dev_err(card->dev,
"ASoC: failed to instantiate card %d\n",
ret);
goto probe_dai_err;
}
-
--[[linux-4.4.1/soc_probe_link_components()]]
}
}
/* probe all DAI links on this card */
for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
order++) {
for (i = 0; i < card->num_links; i++) {
ret = soc_probe_link_dais(card, i, order);
if (ret < 0) {
dev_err(card->dev,
"ASoC: failed to instantiate card %d\n",
ret);
goto probe_dai_err;
}
-
--[[linux-4.4.1/soc_probe_link_dais()]]
}
}
for (i = 0; i < card->num_aux_devs; i++) {
ret = soc_probe_aux_dev(card, i);
if (ret < 0) {
dev_err(card->dev,
"ASoC: failed to add auxiliary devices %d\n",
ret);
goto probe_aux_dev_err;
}
-
--[[linux-4.4.1/soc_probe_aux_dev()]]
}
snd_soc_dapm_link_dai_widgets(card);
snd_soc_dapm_connect_dai_link_widgets(card);
-
--[[linux-4.4.1/snd_soc_dapm_link_dai_widgets()]]
--[[linux-4.4.1/snd_soc_dapm_connect_dai_link_widgets()]]
if (card->controls)
snd_soc_add_card_controls(card, card->controls, card->num_controls);
-
--[[linux-4.4.1/snd_soc_add_card_controls()]]
if (card->dapm_routes)
snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
card->num_dapm_routes);
if (card->of_dapm_routes)
snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes,
card->num_of_dapm_routes);
-
--[[linux-4.4.1/snd_soc_dapm_add_routes()]]
snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname),
"%s", card->name);
snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
"%s", card->long_name ? card->long_name : card->name);
snprintf(card->snd_card->driver, sizeof(card->snd_card->driver),
"%s", card->driver_name ? card->driver_name : card->name);
-
--[[linux-4.4.1/snprintf()]]
for (i = 0; i < ARRAY_SIZE(card->snd_card->driver); i++) {
switch (card->snd_card->driver[i]) {
case '_':
case '-':
case '\0':
break;
default:
if (!isalnum(card->snd_card->driver[i]))
card->snd_card->driver[i] = '_';
break;
}
}
-
--[[linux-4.4.1/ARRAY_SIZE()]]
--[[linux-4.4.1/isalnum()]]
if (card->late_probe) {
ret = card->late_probe(card);
if (ret < 0) {
dev_err(card->dev, "ASoC: %s late_probe() failed: %d\n",
card->name, ret);
goto probe_aux_dev_err;
}
}
snd_soc_dapm_new_widgets(card);
-
--[[linux-4.4.1/snd_soc_dapm_new_widgets()]]
ret = snd_card_register(card->snd_card);
if (ret < 0) {
dev_err(card->dev, "ASoC: failed to register soundcard %d\n",
ret);
goto probe_aux_dev_err;
}
-
--[[linux-4.4.1/snd_card_register()]]
card->instantiated = 1;
snd_soc_dapm_sync(&card->dapm);
mutex_unlock(&card->mutex);
mutex_unlock(&client_mutex);
-
--[[linux-4.4.1/snd_soc_dapm_sync()]]
--[[linux-4.4.1/mutex_unlock()]]
return 0;
probe_aux_dev_err:
for (i = 0; i < card->num_aux_devs; i++)
soc_remove_aux_dev(card, i);
-
--[[linux-4.4.1/soc_remove_aux_dev()]]
probe_dai_err:
soc_remove_dai_links(card);
-
--[[linux-4.4.1/soc_remove_dai_links()]]
card_probe_error:
if (card->remove)
card->remove(card);
snd_soc_dapm_free(&card->dapm);
soc_cleanup_card_debugfs(card);
snd_card_free(card->snd_card);
-
--[[linux-4.4.1/snd_soc_dapm_free()]]
--[[linux-4.4.1/soc_cleanup_card_debugfs()]]
--[[linux-4.4.1/snd_card_free()]]
base_error:
mutex_unlock(&card->mutex);
mutex_unlock(&client_mutex);
return ret;
}
*コメント [#s8f39818]