Lines Matching +full:pri +full:- +full:dai +full:- +full:link

1 // SPDX-License-Identifier: GPL-2.0+
3 // soc-core.c -- ALSA SoC Audio Layer
11 // with code, comments and ideas from :-
39 #include <sound/soc-dpcm.h>
40 #include <sound/soc-topology.h>
41 #include <sound/soc-link.h>
75 return sysfs_emit(buf, "%ld\n", rtd->pmdown_time); in pmdown_time_show()
85 ret = kstrtol(buf, 10, &rtd->pmdown_time); in pmdown_time_store()
109 return attr->mode; /* always visible */ in soc_dev_attr_is_visible()
110 return rtd->dai_link->num_codecs ? attr->mode : 0; /* enabled only with codec */ in soc_dev_attr_is_visible()
135 if (!component->card->debugfs_card_root) in soc_init_component_debugfs()
138 if (component->debugfs_prefix) { in soc_init_component_debugfs()
142 component->debugfs_prefix, component->name); in soc_init_component_debugfs()
144 component->debugfs_root = debugfs_create_dir(name, in soc_init_component_debugfs()
145 component->card->debugfs_card_root); in soc_init_component_debugfs()
149 component->debugfs_root = debugfs_create_dir(component->name, in soc_init_component_debugfs()
150 component->card->debugfs_card_root); in soc_init_component_debugfs()
154 component->debugfs_root); in soc_init_component_debugfs()
159 if (!component->debugfs_root) in soc_cleanup_component_debugfs()
161 debugfs_remove_recursive(component->debugfs_root); in soc_cleanup_component_debugfs()
162 component->debugfs_root = NULL; in soc_cleanup_component_debugfs()
168 struct snd_soc_dai *dai; in dai_list_show() local
173 for_each_component_dais(component, dai) in dai_list_show()
174 seq_printf(m, "%s\n", dai->name); in dai_list_show()
189 seq_printf(m, "%s\n", component->name); in component_list_show()
199 card->debugfs_card_root = debugfs_create_dir(card->name, in soc_init_card_debugfs()
202 debugfs_create_u32("dapm_pop_time", 0644, card->debugfs_card_root, in soc_init_card_debugfs()
203 &card->pop_time); in soc_init_card_debugfs()
205 snd_soc_dapm_debugfs_init(&card->dapm, card->debugfs_card_root); in soc_init_card_debugfs()
210 debugfs_remove_recursive(card->debugfs_card_root); in soc_cleanup_card_debugfs()
211 card->debugfs_card_root = NULL; in soc_cleanup_card_debugfs()
247 if (args1->np != args2->np) in snd_soc_is_match_dai_args()
250 for (int i = 0; i < args1->args_count; i++) in snd_soc_is_match_dai_args()
251 if (args1->args[i] != args2->args[i]) in snd_soc_is_match_dai_args()
259 return !(dlc->dai_args || dlc->name || dlc->of_node); in snd_soc_dlc_component_is_empty()
264 return (dlc->name && dlc->of_node); in snd_soc_dlc_component_is_invalid()
269 return !(dlc->dai_args || dlc->dai_name); in snd_soc_dlc_dai_is_empty()
273 struct snd_soc_dai *dai) in snd_soc_is_matching_dai() argument
278 if (dlc->dai_args) in snd_soc_is_matching_dai()
279 return snd_soc_is_match_dai_args(dai->driver->dai_args, dlc->dai_args); in snd_soc_is_matching_dai()
281 if (!dlc->dai_name) in snd_soc_is_matching_dai()
286 if (dai->driver->name && in snd_soc_is_matching_dai()
287 strcmp(dlc->dai_name, dai->driver->name) == 0) in snd_soc_is_matching_dai()
290 if (strcmp(dlc->dai_name, dai->name) == 0) in snd_soc_is_matching_dai()
293 if (dai->component->name && in snd_soc_is_matching_dai()
294 strcmp(dlc->dai_name, dai->component->name) == 0) in snd_soc_is_matching_dai()
300 const char *snd_soc_dai_name_get(const struct snd_soc_dai *dai) in snd_soc_dai_name_get() argument
303 if (dai->driver->name) in snd_soc_dai_name_get()
304 return dai->driver->name; in snd_soc_dai_name_get()
306 if (dai->name) in snd_soc_dai_name_get()
307 return dai->name; in snd_soc_dai_name_get()
309 if (dai->component->name) in snd_soc_dai_name_get()
310 return dai->component->name; in snd_soc_dai_name_get()
329 rtd->num_components++; // increment flex array count at first in snd_soc_rtd_add_component()
330 rtd->components[rtd->num_components - 1] = component; in snd_soc_rtd_add_component()
353 const char *component_name = component->driver->name; in snd_soc_rtdcom_lookup()
375 if ((dev == component->dev) && in snd_soc_lookup_component_nolocked()
377 (driver_name == component->driver->name) || in snd_soc_lookup_component_nolocked()
378 (strcmp(component->driver->name, driver_name) == 0))) { in snd_soc_lookup_component_nolocked()
408 if (rtd->dai_link == dai_link) in snd_soc_get_pcm_runtime()
411 dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link->name); in snd_soc_get_pcm_runtime()
428 dev_dbg(rtd->dev, in snd_soc_close_delayed_work()
430 codec_dai->driver->playback.stream_name, in snd_soc_close_delayed_work()
433 rtd->pop_wait ? "yes" : "no"); in snd_soc_close_delayed_work()
435 /* are we waiting on this codec DAI stream */ in snd_soc_close_delayed_work()
436 if (rtd->pop_wait == 1) { in snd_soc_close_delayed_work()
437 rtd->pop_wait = 0; in snd_soc_close_delayed_work()
448 /* "dev" means "rtd->dev" */ in soc_release_rtd_dev()
457 list_del(&rtd->list); in soc_free_pcm_runtime()
459 if (delayed_work_pending(&rtd->delayed_work)) in soc_free_pcm_runtime()
460 flush_delayed_work(&rtd->delayed_work); in soc_free_pcm_runtime()
464 * we don't need to call kfree() for rtd->dev in soc_free_pcm_runtime()
468 * We don't need rtd->dev NULL check, because in soc_free_pcm_runtime()
474 * because it was created from dev (= rtd->dev) in soc_free_pcm_runtime()
479 * rtd->dev = dev in soc_free_pcm_runtime()
481 device_unregister(rtd->dev); in soc_free_pcm_runtime()
489 if (rtd->close_delayed_work_func) in close_delayed_work()
490 rtd->close_delayed_work_func(rtd); in close_delayed_work()
502 * for rtd->dev in soc_new_pcm_runtime()
508 dev->parent = card->dev; in soc_new_pcm_runtime()
509 dev->release = soc_release_rtd_dev; in soc_new_pcm_runtime()
511 dev_set_name(dev, "%s", dai_link->name); in soc_new_pcm_runtime()
524 dai_link->num_cpus + in soc_new_pcm_runtime()
525 dai_link->num_codecs + in soc_new_pcm_runtime()
526 dai_link->num_platforms), in soc_new_pcm_runtime()
533 rtd->dev = dev; in soc_new_pcm_runtime()
534 INIT_LIST_HEAD(&rtd->list); in soc_new_pcm_runtime()
536 INIT_LIST_HEAD(&rtd->dpcm[stream].be_clients); in soc_new_pcm_runtime()
537 INIT_LIST_HEAD(&rtd->dpcm[stream].fe_clients); in soc_new_pcm_runtime()
540 INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); in soc_new_pcm_runtime()
543 * for rtd->dais in soc_new_pcm_runtime()
545 rtd->dais = devm_kcalloc(dev, dai_link->num_cpus + dai_link->num_codecs, in soc_new_pcm_runtime()
548 if (!rtd->dais) in soc_new_pcm_runtime()
554 * |--- num_cpus ---|--- num_codecs --| in soc_new_pcm_runtime()
559 rtd->card = card; in soc_new_pcm_runtime()
560 rtd->dai_link = dai_link; in soc_new_pcm_runtime()
561 rtd->num = card->num_rtd++; in soc_new_pcm_runtime()
562 rtd->pmdown_time = pmdown_time; /* default power off timeout */ in soc_new_pcm_runtime()
565 list_add_tail(&rtd->list, &card->rtd_list); in soc_new_pcm_runtime()
585 * Fill it as dummy DAI in case of CPU/Codec here. in snd_soc_fill_dummy_dai()
589 if (dai_link->num_cpus == 0 && dai_link->cpus) { in snd_soc_fill_dummy_dai()
590 dai_link->num_cpus = 1; in snd_soc_fill_dummy_dai()
591 dai_link->cpus = &snd_soc_dummy_dlc; in snd_soc_fill_dummy_dai()
593 if (dai_link->num_codecs == 0 && dai_link->codecs) { in snd_soc_fill_dummy_dai()
594 dai_link->num_codecs = 1; in snd_soc_fill_dummy_dai()
595 dai_link->codecs = &snd_soc_dummy_dlc; in snd_soc_fill_dummy_dai()
605 flush_delayed_work(&rtd->delayed_work); in snd_soc_flush_all_delayed_work()
612 struct snd_soc_dai *dai; in soc_playback_digital_mute() local
618 if (rtd->dai_link->ignore_suspend) in soc_playback_digital_mute()
621 for_each_rtd_dais(rtd, i, dai) { in soc_playback_digital_mute()
622 if (snd_soc_dai_stream_active(dai, playback)) in soc_playback_digital_mute()
623 snd_soc_dai_digital_mute(dai, mute, playback); in soc_playback_digital_mute()
635 if (rtd->dai_link->ignore_suspend) in soc_dapm_suspend_resume()
657 * suspend before that's finished - wait for it to complete. in snd_soc_suspend()
659 snd_power_wait(card->snd_card); in snd_soc_suspend()
662 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D3hot); in snd_soc_suspend()
669 if (rtd->dai_link->ignore_suspend) in snd_soc_suspend()
672 snd_pcm_suspend_all(rtd->pcm); in snd_soc_suspend()
684 snd_soc_dapm_sync(&card->dapm); in snd_soc_suspend()
689 if (rtd->dai_link->ignore_suspend) in snd_soc_suspend()
714 if (dapm->idle_bias_off) { in snd_soc_suspend()
715 dev_dbg(component->dev, in snd_soc_suspend()
723 if (component->regmap) in snd_soc_suspend()
724 regcache_mark_dirty(component->regmap); in snd_soc_suspend()
726 pinctrl_pm_select_sleep_state(component->dev); in snd_soc_suspend()
729 dev_dbg(component->dev, in snd_soc_suspend()
758 dev_dbg(card->dev, "ASoC: starting resume work\n"); in soc_resume_deferred()
761 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D2); in soc_resume_deferred()
777 dev_dbg(card->dev, "ASoC: resume work completed\n"); in soc_resume_deferred()
781 snd_soc_dapm_sync(&card->dapm); in soc_resume_deferred()
784 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0); in soc_resume_deferred()
800 pinctrl_pm_select_default_state(component->dev); in snd_soc_resume()
803 if (!schedule_work(&card->deferred_resume_work)) in snd_soc_resume()
813 INIT_WORK(&card->deferred_resume_work, soc_resume_deferred); in soc_resume_init()
826 of_node = component->dev->of_node; in soc_component_to_node()
827 if (!of_node && component->dev->parent) in soc_component_to_node()
828 of_node = component->dev->parent->of_node; in soc_component_to_node()
856 if (dlc->dai_args) { in snd_soc_is_matching_component()
857 struct snd_soc_dai *dai; in snd_soc_is_matching_component() local
859 for_each_component_dais(component, dai) in snd_soc_is_matching_component()
860 if (snd_soc_is_matching_dai(dlc, dai)) in snd_soc_is_matching_component()
867 if (dlc->of_node && component_of_node != dlc->of_node) in snd_soc_is_matching_component()
869 if (dlc->name && strcmp(component->name, dlc->name)) in snd_soc_is_matching_component()
898 * snd_soc_find_dai - Find a registered DAI
900 * @dlc: name of the DAI or the DAI driver and optional component info to match
903 * find the DAI of the same name. The component's of_node and name
906 * Return: pointer of DAI, or NULL if not found.
912 struct snd_soc_dai *dai; in snd_soc_find_dai() local
916 /* Find CPU DAI from registered DAIs */ in snd_soc_find_dai()
919 for_each_component_dais(component, dai) in snd_soc_find_dai()
920 if (snd_soc_is_matching_dai(dlc, dai)) in snd_soc_find_dai()
921 return dai; in snd_soc_find_dai()
930 struct snd_soc_dai *dai; in snd_soc_find_dai_with_mutex() local
933 dai = snd_soc_find_dai(dlc); in snd_soc_find_dai_with_mutex()
936 return dai; in snd_soc_find_dai_with_mutex()
941 struct snd_soc_dai_link *link) in soc_dai_link_sanity_check() argument
947 for_each_link_codecs(link, i, dlc) { in soc_dai_link_sanity_check()
958 /* Codec DAI name must be specified */ in soc_dai_link_sanity_check()
971 for_each_link_platforms(link, i, dlc) { in soc_dai_link_sanity_check()
992 for_each_link_cpus(link, i, dlc) { in soc_dai_link_sanity_check()
995 * can be left unspecified, and will be matched based on DAI in soc_dai_link_sanity_check()
1004 * At least one of CPU DAI name or CPU device name/node must be specified in soc_dai_link_sanity_check()
1020 dev_err(card->dev, "ASoC: Both Component name/of_node are set for %s\n", link->name); in soc_dai_link_sanity_check()
1021 return -EINVAL; in soc_dai_link_sanity_check()
1024 dev_err(card->dev, "ASoC: Neither Component name/of_node are set for %s\n", link->name); in soc_dai_link_sanity_check()
1025 return -EINVAL; in soc_dai_link_sanity_check()
1028 dev_dbg(card->dev, "ASoC: Component %s not found for link %s\n", dlc->name, link->name); in soc_dai_link_sanity_check()
1029 return -EPROBE_DEFER; in soc_dai_link_sanity_check()
1032 dev_err(card->dev, "ASoC: DAI name is not set for %s\n", link->name); in soc_dai_link_sanity_check()
1033 return -EINVAL; in soc_dai_link_sanity_check()
1036 dev_err(card->dev, "ASoC: Neither DAI/Component name/of_node are set for %s\n", link->name); in soc_dai_link_sanity_check()
1037 return -EINVAL; in soc_dai_link_sanity_check()
1078 * dai_link->ch_maps indicates how CPU/Codec are connected. in snd_soc_compensate_channel_connection_map()
1079 * It will be a map seen from a larger number of DAI. in snd_soc_compensate_channel_connection_map()
1081 * soc.h :: [dai_link->ch_maps Image sample] in snd_soc_compensate_channel_connection_map()
1085 if (dai_link->num_cpus > 1 && dai_link->num_codecs > 1 && in snd_soc_compensate_channel_connection_map()
1086 dai_link->num_cpus != dai_link->num_codecs && !dai_link->ch_maps) { in snd_soc_compensate_channel_connection_map()
1087 dev_err(card->dev, "need to have ch_maps when N:M connection (%s)", in snd_soc_compensate_channel_connection_map()
1088 dai_link->name); in snd_soc_compensate_channel_connection_map()
1089 return -EINVAL; in snd_soc_compensate_channel_connection_map()
1093 if (dai_link->ch_maps) in snd_soc_compensate_channel_connection_map()
1097 if (dai_link->num_cpus > MAX_DEFAULT_CH_MAP_SIZE || in snd_soc_compensate_channel_connection_map()
1098 dai_link->num_codecs > MAX_DEFAULT_CH_MAP_SIZE) { in snd_soc_compensate_channel_connection_map()
1099 dev_err(card->dev, "soc-core.c needs update default_connection_maps"); in snd_soc_compensate_channel_connection_map()
1100 return -EINVAL; in snd_soc_compensate_channel_connection_map()
1104 if (dai_link->num_cpus == dai_link->num_codecs) in snd_soc_compensate_channel_connection_map()
1105 dai_link->ch_maps = default_ch_map_sync; /* for 1:1 or N:N */ in snd_soc_compensate_channel_connection_map()
1106 else if (dai_link->num_cpus < dai_link->num_codecs) in snd_soc_compensate_channel_connection_map()
1107 dai_link->ch_maps = default_ch_map_1cpu; /* for 1:N */ in snd_soc_compensate_channel_connection_map()
1109 dai_link->ch_maps = default_ch_map_1codec; /* for N:1 */ in snd_soc_compensate_channel_connection_map()
1112 dev_dbg(card->dev, "dai_link %s\n", dai_link->stream_name); in snd_soc_compensate_channel_connection_map()
1114 if ((ch_maps->cpu >= dai_link->num_cpus) || in snd_soc_compensate_channel_connection_map()
1115 (ch_maps->codec >= dai_link->num_codecs)) { in snd_soc_compensate_channel_connection_map()
1116 dev_err(card->dev, in snd_soc_compensate_channel_connection_map()
1117 "unexpected dai_link->ch_maps[%d] index (cpu(%d/%d) codec(%d/%d))", in snd_soc_compensate_channel_connection_map()
1119 ch_maps->cpu, dai_link->num_cpus, in snd_soc_compensate_channel_connection_map()
1120 ch_maps->codec, dai_link->num_codecs); in snd_soc_compensate_channel_connection_map()
1121 return -EINVAL; in snd_soc_compensate_channel_connection_map()
1124 dev_dbg(card->dev, " [%d] cpu%d <-> codec%d\n", in snd_soc_compensate_channel_connection_map()
1125 i, ch_maps->cpu, ch_maps->codec); in snd_soc_compensate_channel_connection_map()
1132 * snd_soc_remove_pcm_runtime - Remove a pcm_runtime from card
1146 snd_soc_card_remove_dai_link(card, rtd->dai_link); in snd_soc_remove_pcm_runtime()
1153 * snd_soc_add_pcm_runtime - Add a pcm_runtime dynamically via dai_link
1155 * @dai_link: The DAI link to find pcm_runtime
1161 * DAI links in dai_link array.
1180 if (dai_link->ignore) in snd_soc_add_pcm_runtime()
1183 dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name); in snd_soc_add_pcm_runtime()
1191 return -ENOMEM; in snd_soc_add_pcm_runtime()
1196 dev_info(card->dev, "ASoC: CPU DAI %s not registered\n", in snd_soc_add_pcm_runtime()
1197 cpu->dai_name); in snd_soc_add_pcm_runtime()
1200 snd_soc_rtd_add_component(rtd, snd_soc_rtd_to_cpu(rtd, i)->component); in snd_soc_add_pcm_runtime()
1207 dev_info(card->dev, "ASoC: CODEC DAI %s not registered\n", in snd_soc_add_pcm_runtime()
1208 codec->dai_name); in snd_soc_add_pcm_runtime()
1212 snd_soc_rtd_add_component(rtd, snd_soc_rtd_to_codec(rtd, i)->component); in snd_soc_add_pcm_runtime()
1221 if (snd_soc_component_is_dummy(component) && component->num_dai) in snd_soc_add_pcm_runtime()
1232 return -EPROBE_DEFER; in snd_soc_add_pcm_runtime()
1257 struct snd_soc_dai_link *dai_link = rtd->dai_link; in snd_soc_runtime_get_dai_fmt()
1258 struct snd_soc_dai *dai, *not_used; in snd_soc_runtime_get_dai_fmt() local
1261 int i, j, priority, pri, until; in snd_soc_runtime_get_dai_fmt() local
1284 * DAI0: (pri, fmt) = (1, 000000000000000F) // 1st check (A) DAI1 is not selected in snd_soc_runtime_get_dai_fmt()
1285 * DAI1: (pri, fmt) = (0, 0000000000000000) // Necessary Waste in snd_soc_runtime_get_dai_fmt()
1286 * DAI0: (pri, fmt) = (1, 000000000000000F) // 2nd check (A) in snd_soc_runtime_get_dai_fmt()
1287 * DAI1: (pri, fmt) = (1, 000000000000F000) // (X) in snd_soc_runtime_get_dai_fmt()
1289 * DAI0: (pri, fmt) = (2, 00000000000000FF) // 3rd check (A) + (B) in snd_soc_runtime_get_dai_fmt()
1290 * DAI1: (pri, fmt) = (1, 000000000000F000) // (X) in snd_soc_runtime_get_dai_fmt()
1291 * DAI0: (pri, fmt) = (2, 00000000000000FF) // 4th check (A) + (B) in snd_soc_runtime_get_dai_fmt()
1292 * DAI1: (pri, fmt) = (2, 000000000000FF00) // (X) + (Y) in snd_soc_runtime_get_dai_fmt()
1294 * DAI0: (pri, fmt) = (3, 0000000000000FFF) // 5th check (A) + (B) + (C) in snd_soc_runtime_get_dai_fmt()
1295 * DAI1: (pri, fmt) = (2, 000000000000FF00) // (X) + (Y) in snd_soc_runtime_get_dai_fmt()
1303 for_each_rtd_dais(rtd, i, dai) { in snd_soc_runtime_get_dai_fmt()
1306 pri = (j >= i) ? priority : priority - 1; in snd_soc_runtime_get_dai_fmt()
1307 fmt = snd_soc_dai_get_fmt(dai, pri); in snd_soc_runtime_get_dai_fmt()
1333 for (i = 63; i >= 0; i--) { in snd_soc_runtime_get_dai_fmt()
1392 * In such case, user want to auto-select non-limitation part, in snd_soc_runtime_get_dai_fmt()
1400 if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK)) in snd_soc_runtime_get_dai_fmt()
1402 if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_CLOCK_MASK)) in snd_soc_runtime_get_dai_fmt()
1404 if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_INV_MASK)) in snd_soc_runtime_get_dai_fmt()
1406 if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK)) in snd_soc_runtime_get_dai_fmt()
1409 dai_link->dai_fmt |= (dai_fmt & mask); in snd_soc_runtime_get_dai_fmt()
1413 * snd_soc_runtime_set_dai_fmt() - Change DAI link format for a ASoC runtime
1414 * @rtd: The runtime for which the DAI link format should be changed
1415 * @dai_fmt: The new DAI link format
1417 * This function updates the DAI link format for all DAIs connected to the DAI
1418 * link for the specified runtime.
1438 if (ret != 0 && ret != -ENOTSUPP) in snd_soc_runtime_set_dai_fmt()
1442 /* Flip the polarity for the "CPU" end of link */ in snd_soc_runtime_set_dai_fmt()
1447 if (ret != 0 && ret != -ENOTSUPP) in snd_soc_runtime_set_dai_fmt()
1458 struct snd_soc_dai_link *dai_link = rtd->dai_link; in soc_init_pcm_runtime()
1469 ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt); in soc_init_pcm_runtime()
1476 num = rtd->num; in soc_init_pcm_runtime()
1479 * most drivers will register their PCMs using DAI link ordering but in soc_init_pcm_runtime()
1480 * topology based drivers can use the DAI link id field to set PCM in soc_init_pcm_runtime()
1484 if (!component->driver->use_dai_pcm_id) in soc_init_pcm_runtime()
1487 if (rtd->dai_link->no_pcm) in soc_init_pcm_runtime()
1488 num += component->driver->be_pcm_base; in soc_init_pcm_runtime()
1490 num = rtd->dai_link->id; in soc_init_pcm_runtime()
1495 if (ret != -ENOTSUPP) in soc_init_pcm_runtime()
1501 dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", in soc_init_pcm_runtime()
1502 dai_link->stream_name, ret); in soc_init_pcm_runtime()
1510 rtd->initialized = true; in soc_init_pcm_runtime()
1525 for (i = 0; i < card->num_configs; i++) { in soc_set_name_prefix()
1526 struct snd_soc_codec_conf *map = &card->codec_conf[i]; in soc_set_name_prefix()
1528 if (snd_soc_is_matching_component(&map->dlc, component) && in soc_set_name_prefix()
1529 map->name_prefix) { in soc_set_name_prefix()
1530 component->name_prefix = map->name_prefix; in soc_set_name_prefix()
1539 ret = of_property_read_string(of_node, "sound-name-prefix", &str); in soc_set_name_prefix()
1543 component->name_prefix = str; in soc_set_name_prefix()
1550 if (!component->card) in soc_remove_component()
1556 list_del_init(&component->card_list); in soc_remove_component()
1559 component->card = NULL; in soc_remove_component()
1568 struct snd_soc_dai *dai; in soc_probe_component() local
1575 if (component->card) { in soc_probe_component()
1576 if (component->card != card) { in soc_probe_component()
1577 dev_err(component->dev, in soc_probe_component()
1579 component->name, card->name, component->card->name); in soc_probe_component()
1580 return -ENODEV; in soc_probe_component()
1589 component->card = card; in soc_probe_component()
1597 component->driver->dapm_widgets, in soc_probe_component()
1598 component->driver->num_dapm_widgets); in soc_probe_component()
1601 dev_err(component->dev, in soc_probe_component()
1606 for_each_component_dais(component, dai) { in soc_probe_component()
1607 ret = snd_soc_dapm_new_dai_widgets(dapm, dai); in soc_probe_component()
1609 dev_err(component->dev, in soc_probe_component()
1610 "Failed to create DAI widgets %d\n", ret); in soc_probe_component()
1619 WARN(dapm->idle_bias_off && in soc_probe_component()
1620 dapm->bias_level != SND_SOC_BIAS_OFF, in soc_probe_component()
1621 "codec %s can not start from non-off bias with idle_bias_off==1\n", in soc_probe_component()
1622 component->name); in soc_probe_component()
1635 component->driver->controls, in soc_probe_component()
1636 component->driver->num_controls); in soc_probe_component()
1641 component->driver->dapm_routes, in soc_probe_component()
1642 component->driver->num_dapm_routes); in soc_probe_component()
1644 if (card->disable_route_checks) { in soc_probe_component()
1645 dev_info(card->dev, in soc_probe_component()
1649 dev_err(card->dev, in soc_probe_component()
1657 list_add(&component->card_list, &card->component_dev_list); in soc_probe_component()
1705 if (component->driver->remove_order != order) in soc_remove_link_components()
1723 if (component->driver->probe_order != order) in soc_probe_link_components()
1743 list_del(&component->card_aux_list); in soc_unbind_aux_dev()
1755 component = soc_find_component(&aux->dlc); in soc_bind_aux_dev()
1757 return -EPROBE_DEFER; in soc_bind_aux_dev()
1762 list_add(&component->card_aux_list, &card->aux_comp_list); in soc_bind_aux_dev()
1775 if (component->driver->probe_order != order) in soc_probe_aux_devices()
1794 if (comp->driver->remove_order == order) in soc_remove_aux_devices()
1803 * "Type2 - Board Manufacturer" or "Type1 - TBD by OEM"), it will be taken
1817 * Trim special characters, and replace '-' with '_' since '-' is used to
1829 else if (name[i] == '-') in cleanup_dmi_name()
1854 * Append a string to card->dmi_longname with character cleanups.
1858 char *dst = card->dmi_longname; in append_dmi_string()
1859 size_t dst_len = sizeof(card->dmi_longname); in append_dmi_string()
1863 snprintf(dst + len, dst_len - len, "-%s", str); in append_dmi_string()
1865 len++; /* skip the separator "-" */ in append_dmi_string()
1871 * snd_soc_set_dmi_name() - Register DMI names to card
1879 * device-specific configurations, this function allows DMI info to be used
1881 * "vendor-product-version-board"
1882 * (Character '-' is used to separate different DMI fields here).
1883 * This will help the user space to load the device-specific Use Case Manager
1887 * DellInc.-XPS139343-01-0310JH
1888 * ASUSTeKCOMPUTERINC.-T100TA-1.0-T100TA
1889 * Circuitco-MinnowboardMaxD0PLATFORM-D0-MinnowBoardMAX
1892 * the extra differentiation, like "vendor-product-version-board-flavor".
1905 if (card->long_name) in snd_soc_set_dmi_name()
1911 /* make up dmi long name as: vendor-product-version-board */ in snd_soc_set_dmi_name()
1914 dev_warn(card->dev, "ASoC: no DMI vendor name!\n"); in snd_soc_set_dmi_name()
1918 snprintf(card->dmi_longname, sizeof(card->dmi_longname), "%s", vendor); in snd_soc_set_dmi_name()
1919 cleanup_dmi_name(card->dmi_longname); in snd_soc_set_dmi_name()
1928 * some vendors like Lenovo may only put a self-explanatory in snd_soc_set_dmi_name()
1941 dev_warn(card->dev, "ASoC: no DMI board/product name!\n"); in snd_soc_set_dmi_name()
1950 card->long_name = card->dmi_longname; in snd_soc_set_dmi_name()
1967 if (!component->driver->ignore_machine) in soc_check_tplg_fes()
1971 if (!strcmp(component->driver->ignore_machine, in soc_check_tplg_fes()
1972 card->dev->driver->name)) in soc_check_tplg_fes()
1974 if (strcmp(component->driver->ignore_machine, in soc_check_tplg_fes()
1975 dev_name(card->dev))) in soc_check_tplg_fes()
1982 if (dai_link->dynamic) { in soc_check_tplg_fes()
1983 dai_link->ignore = true; in soc_check_tplg_fes()
1987 dev_dbg(card->dev, "info: override BE DAI link %s\n", in soc_check_tplg_fes()
1988 card->dai_link[i].name); in soc_check_tplg_fes()
1991 if (!dai_link->platforms) { in soc_check_tplg_fes()
1992 dev_err(card->dev, "init platform error"); in soc_check_tplg_fes()
1996 if (component->dev->of_node) in soc_check_tplg_fes()
1997 dai_link->platforms->of_node = component->dev->of_node; in soc_check_tplg_fes()
1999 dai_link->platforms->name = component->name; in soc_check_tplg_fes()
2002 if (!dai_link->no_pcm) { in soc_check_tplg_fes()
2003 dai_link->no_pcm = 1; in soc_check_tplg_fes()
2005 if (dai_link->dpcm_playback) in soc_check_tplg_fes()
2006 dev_warn(card->dev, in soc_check_tplg_fes()
2008 dai_link->name); in soc_check_tplg_fes()
2009 if (dai_link->dpcm_capture) in soc_check_tplg_fes()
2010 dev_warn(card->dev, in soc_check_tplg_fes()
2012 dai_link->name); in soc_check_tplg_fes()
2014 /* convert normal link into DPCM one */ in soc_check_tplg_fes()
2015 if (!(dai_link->dpcm_playback || in soc_check_tplg_fes()
2016 dai_link->dpcm_capture)) { in soc_check_tplg_fes()
2017 dai_link->dpcm_playback = !dai_link->capture_only; in soc_check_tplg_fes()
2018 dai_link->dpcm_capture = !dai_link->playback_only; in soc_check_tplg_fes()
2027 dai_link->be_hw_params_fixup = in soc_check_tplg_fes()
2028 component->driver->be_hw_params_fixup; in soc_check_tplg_fes()
2032 * dai link name if it's NULL to help bind widgets. in soc_check_tplg_fes()
2034 if (!dai_link->stream_name) in soc_check_tplg_fes()
2035 dai_link->stream_name = dai_link->name; in soc_check_tplg_fes()
2039 if (component->driver->topology_name_prefix) { in soc_check_tplg_fes()
2042 if (!card->topology_shortname_created) { in soc_check_tplg_fes()
2043 comp_drv = component->driver; in soc_check_tplg_fes()
2045 snprintf(card->topology_shortname, 32, "%s-%s", in soc_check_tplg_fes()
2046 comp_drv->topology_name_prefix, in soc_check_tplg_fes()
2047 card->name); in soc_check_tplg_fes()
2048 card->topology_shortname_created = true; in soc_check_tplg_fes()
2052 card->name = card->topology_shortname; in soc_check_tplg_fes()
2068 if (name != card->snd_card->driver) in __soc_setup_card_name()
2075 * searches in the user-space. in __soc_setup_card_name()
2078 * "abcd??efg" -> "abcd__efg" in __soc_setup_card_name()
2083 case '-': in __soc_setup_card_name()
2098 if (strlen(src) > len - 1) in __soc_setup_card_name()
2099 dev_err(card->dev, "ASoC: driver name too long '%s' -> '%s'\n", src, name); in __soc_setup_card_name()
2106 if (card->snd_card) in soc_cleanup_card_resources()
2107 snd_card_disconnect_sync(card->snd_card); in soc_cleanup_card_resources()
2113 if (rtd->initialized) in soc_cleanup_card_resources()
2115 /* remove and free each DAI */ in soc_cleanup_card_resources()
2126 snd_soc_dapm_free(&card->dapm); in soc_cleanup_card_resources()
2132 if (card->snd_card) { in soc_cleanup_card_resources()
2133 snd_card_free(card->snd_card); in soc_cleanup_card_resources()
2134 card->snd_card = NULL; in soc_cleanup_card_resources()
2141 card->instantiated = false; in snd_soc_unbind_card()
2146 list_add(&card->list, &unbind_card_list); in snd_soc_unbind_card()
2149 list_del(&card->list); in snd_soc_unbind_card()
2164 snd_soc_dapm_init(&card->dapm, card, NULL); in snd_soc_bind_card()
2174 /* add predefined DAI links to the list */ in snd_soc_bind_card()
2175 card->num_rtd = 0; in snd_soc_bind_card()
2176 ret = snd_soc_add_pcm_runtimes(card, card->dai_link, card->num_links); in snd_soc_bind_card()
2181 ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, in snd_soc_bind_card()
2182 card->owner, 0, &card->snd_card); in snd_soc_bind_card()
2184 dev_err(card->dev, in snd_soc_bind_card()
2186 card->name, ret); in snd_soc_bind_card()
2194 ret = snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets, in snd_soc_bind_card()
2195 card->num_dapm_widgets); in snd_soc_bind_card()
2199 ret = snd_soc_dapm_new_controls(&card->dapm, card->of_dapm_widgets, in snd_soc_bind_card()
2200 card->num_of_dapm_widgets); in snd_soc_bind_card()
2209 /* probe all components used by DAI links on this card */ in snd_soc_bind_card()
2212 if (ret != -EPROBE_DEFER) { in snd_soc_bind_card()
2213 dev_err(card->dev, in snd_soc_bind_card()
2222 dev_err(card->dev, in snd_soc_bind_card()
2227 /* probe all DAI links on this card */ in snd_soc_bind_card()
2230 dev_err(card->dev, in snd_soc_bind_card()
2244 ret = snd_soc_add_card_controls(card, card->controls, in snd_soc_bind_card()
2245 card->num_controls); in snd_soc_bind_card()
2249 ret = snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes, in snd_soc_bind_card()
2250 card->num_dapm_routes); in snd_soc_bind_card()
2252 if (card->disable_route_checks) { in snd_soc_bind_card()
2253 dev_info(card->dev, in snd_soc_bind_card()
2257 dev_err(card->dev, in snd_soc_bind_card()
2264 ret = snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes, in snd_soc_bind_card()
2265 card->num_of_dapm_routes); in snd_soc_bind_card()
2272 soc_setup_card_name(card, card->snd_card->shortname, in snd_soc_bind_card()
2273 card->name, NULL); in snd_soc_bind_card()
2274 soc_setup_card_name(card, card->snd_card->longname, in snd_soc_bind_card()
2275 card->long_name, card->name); in snd_soc_bind_card()
2276 soc_setup_card_name(card, card->snd_card->driver, in snd_soc_bind_card()
2277 card->driver_name, card->name); in snd_soc_bind_card()
2279 if (card->components) { in snd_soc_bind_card()
2284 ret = snd_component_add(card->snd_card, card->components); in snd_soc_bind_card()
2286 dev_err(card->dev, "ASoC: %s snd_component_add() failed: %d\n", in snd_soc_bind_card()
2287 card->name, ret); in snd_soc_bind_card()
2299 ret = snd_card_register(card->snd_card); in snd_soc_bind_card()
2301 dev_err(card->dev, "ASoC: failed to register soundcard %d\n", in snd_soc_bind_card()
2306 card->instantiated = 1; in snd_soc_bind_card()
2308 snd_soc_dapm_sync(&card->dapm); in snd_soc_bind_card()
2313 pinctrl_pm_select_sleep_state(component->dev); in snd_soc_bind_card()
2335 return -EINVAL; in soc_probe()
2337 dev_warn(&pdev->dev, in soc_probe()
2339 card->name); in soc_probe()
2342 card->dev = &pdev->dev; in soc_probe()
2344 return devm_snd_soc_register_card(&pdev->dev, card); in soc_probe()
2356 * Flush out pmdown_time work - we actually do want to run it in snd_soc_poweroff()
2365 pinctrl_pm_select_sleep_state(component->dev); in snd_soc_poweroff()
2384 .name = "soc-audio",
2391 * snd_soc_cnew - create new control
2442 control->name, prefix)); in snd_soc_add_controls()
2445 control->name, err); in snd_soc_add_controls()
2454 * snd_soc_add_component_controls - Add an array of controls to a component.
2465 struct snd_card *card = component->card->snd_card; in snd_soc_add_component_controls()
2467 return snd_soc_add_controls(card, component->dev, controls, in snd_soc_add_component_controls()
2468 num_controls, component->name_prefix, component); in snd_soc_add_component_controls()
2473 * snd_soc_add_card_controls - add an array of controls to a SoC card.
2485 struct snd_card *card = soc_card->snd_card; in snd_soc_add_card_controls()
2487 return snd_soc_add_controls(card, soc_card->dev, controls, num_controls, in snd_soc_add_card_controls()
2493 * snd_soc_add_dai_controls - add an array of controls to a DAI.
2496 * @dai: DAI to add controls to
2502 int snd_soc_add_dai_controls(struct snd_soc_dai *dai, in snd_soc_add_dai_controls() argument
2505 struct snd_card *card = dai->component->card->snd_card; in snd_soc_add_dai_controls()
2507 return snd_soc_add_controls(card, dai->dev, controls, num_controls, in snd_soc_add_dai_controls()
2508 NULL, dai); in snd_soc_add_dai_controls()
2513 * snd_soc_register_card - Register a card with the ASoC core
2520 if (!card->name || !card->dev) in snd_soc_register_card()
2521 return -EINVAL; in snd_soc_register_card()
2523 dev_set_drvdata(card->dev, card); in snd_soc_register_card()
2525 INIT_LIST_HEAD(&card->widgets); in snd_soc_register_card()
2526 INIT_LIST_HEAD(&card->paths); in snd_soc_register_card()
2527 INIT_LIST_HEAD(&card->dapm_list); in snd_soc_register_card()
2528 INIT_LIST_HEAD(&card->aux_comp_list); in snd_soc_register_card()
2529 INIT_LIST_HEAD(&card->component_dev_list); in snd_soc_register_card()
2530 INIT_LIST_HEAD(&card->list); in snd_soc_register_card()
2531 INIT_LIST_HEAD(&card->rtd_list); in snd_soc_register_card()
2532 INIT_LIST_HEAD(&card->dapm_dirty); in snd_soc_register_card()
2533 INIT_LIST_HEAD(&card->dobj_list); in snd_soc_register_card()
2535 card->instantiated = 0; in snd_soc_register_card()
2536 mutex_init(&card->mutex); in snd_soc_register_card()
2537 mutex_init(&card->dapm_mutex); in snd_soc_register_card()
2538 mutex_init(&card->pcm_mutex); in snd_soc_register_card()
2545 * snd_soc_unregister_card - Unregister a card with the ASoC core
2555 dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name); in snd_soc_unregister_card()
2560 * Simplify DAI link configuration by removing ".-1" from device names
2577 found = strstr(name, dev->driver->name); in fmt_single_name()
2580 if (sscanf(&found[strlen(dev->driver->name)], ".%d", id) == 1) { in fmt_single_name()
2582 /* discard ID from name if ID == -1 */ in fmt_single_name()
2583 if (*id == -1) in fmt_single_name()
2584 found[strlen(dev->driver->name)] = '\0'; in fmt_single_name()
2587 /* I2C component devices are named "bus-addr" */ in fmt_single_name()
2588 } else if (sscanf(name, "%x-%x", &id1, &id2) == 2) { in fmt_single_name()
2595 /* sanitize component name for DAI link creation */ in fmt_single_name()
2596 name = devm_kasprintf(dev, GFP_KERNEL, "%s.%s", dev->driver->name, devname); in fmt_single_name()
2605 * Simplify DAI link naming for single devices with multiple DAIs by removing
2606 * any ".-1" and using the DAI name (instead of device name).
2611 if (dai_drv->name == NULL) { in fmt_multiple_name()
2613 "ASoC: error - multiple DAI %s registered with no name\n", in fmt_multiple_name()
2618 return devm_kstrdup(dev, dai_drv->name, GFP_KERNEL); in fmt_multiple_name()
2621 void snd_soc_unregister_dai(struct snd_soc_dai *dai) in snd_soc_unregister_dai() argument
2623 dev_dbg(dai->dev, "ASoC: Unregistered DAI '%s'\n", dai->name); in snd_soc_unregister_dai()
2624 list_del(&dai->list); in snd_soc_unregister_dai()
2629 * snd_soc_register_dai - Register a DAI dynamically & create its widgets
2632 * @dai_drv: DAI driver to use for the DAI
2633 * @legacy_dai_naming: if %true, use legacy single-name format;
2634 * if %false, use multiple-name format;
2644 struct device *dev = component->dev; in snd_soc_register_dai()
2645 struct snd_soc_dai *dai; in snd_soc_register_dai() local
2649 dai = devm_kzalloc(dev, sizeof(*dai), GFP_KERNEL); in snd_soc_register_dai()
2650 if (dai == NULL) in snd_soc_register_dai()
2654 * Back in the old days when we still had component-less DAIs, in snd_soc_register_dai()
2655 * instead of having a static name, component-less DAIs would in snd_soc_register_dai()
2657 * register multiple instances of the DAI. We still need to keep in snd_soc_register_dai()
2659 * component-less anymore. in snd_soc_register_dai()
2662 (dai_drv->id == 0 || dai_drv->name == NULL)) { in snd_soc_register_dai()
2663 dai->name = fmt_single_name(dev, &dai->id); in snd_soc_register_dai()
2665 dai->name = fmt_multiple_name(dev, dai_drv); in snd_soc_register_dai()
2666 if (dai_drv->id) in snd_soc_register_dai()
2667 dai->id = dai_drv->id; in snd_soc_register_dai()
2669 dai->id = component->num_dai; in snd_soc_register_dai()
2671 if (!dai->name) in snd_soc_register_dai()
2674 dai->component = component; in snd_soc_register_dai()
2675 dai->dev = dev; in snd_soc_register_dai()
2676 dai->driver = dai_drv; in snd_soc_register_dai()
2679 list_add_tail(&dai->list, &component->dai_list); in snd_soc_register_dai()
2680 component->num_dai++; in snd_soc_register_dai()
2682 dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name); in snd_soc_register_dai()
2683 return dai; in snd_soc_register_dai()
2688 * snd_soc_unregister_dais - Unregister DAIs from the ASoC core
2694 struct snd_soc_dai *dai, *_dai; in snd_soc_unregister_dais() local
2696 for_each_component_dais_safe(component, dai, _dai) in snd_soc_unregister_dais()
2697 snd_soc_unregister_dai(dai); in snd_soc_unregister_dais()
2701 * snd_soc_register_dais - Register a DAI with the ASoC core
2704 * @dai_drv: DAI driver to use for the DAIs
2711 struct snd_soc_dai *dai; in snd_soc_register_dais() local
2716 dai = snd_soc_register_dai(component, dai_drv + i, count == 1 && in snd_soc_register_dais()
2717 component->driver->legacy_dai_naming); in snd_soc_register_dais()
2718 if (dai == NULL) { in snd_soc_register_dais()
2719 ret = -ENOMEM; in snd_soc_register_dais()
2753 * Fix up the DAI formats for endianness: codecs don't actually see
2763 if (stream->formats & endianness_format_map[i]) in convert_endianness_formats()
2764 stream->formats |= endianness_format_map[i]; in convert_endianness_formats()
2773 list_del(&card->list); in snd_soc_try_rebind_card()
2778 struct snd_soc_card *card = component->card; in snd_soc_del_component_unlocked()
2785 list_del(&component->list); in snd_soc_del_component_unlocked()
2792 INIT_LIST_HEAD(&component->dai_list); in snd_soc_component_initialize()
2793 INIT_LIST_HEAD(&component->dobj_list); in snd_soc_component_initialize()
2794 INIT_LIST_HEAD(&component->card_list); in snd_soc_component_initialize()
2795 INIT_LIST_HEAD(&component->list); in snd_soc_component_initialize()
2796 mutex_init(&component->io_mutex); in snd_soc_component_initialize()
2798 if (!component->name) { in snd_soc_component_initialize()
2799 component->name = fmt_single_name(dev, &component->id); in snd_soc_component_initialize()
2800 if (!component->name) { in snd_soc_component_initialize()
2802 return -ENOMEM; in snd_soc_component_initialize()
2806 component->dev = dev; in snd_soc_component_initialize()
2807 component->driver = driver; in snd_soc_component_initialize()
2810 if (!component->debugfs_prefix) in snd_soc_component_initialize()
2811 component->debugfs_prefix = driver->debugfs_prefix; in snd_soc_component_initialize()
2827 if (component->driver->endianness) { in snd_soc_add_component()
2836 dev_err(component->dev, "ASoC: Failed to register DAIs: %d\n", in snd_soc_add_component()
2841 if (!component->driver->write && !component->driver->read) { in snd_soc_add_component()
2842 if (!component->regmap) in snd_soc_add_component()
2843 component->regmap = dev_get_regmap(component->dev, in snd_soc_add_component()
2845 if (component->regmap) in snd_soc_add_component()
2850 list_add(&component->list, &component_list); in snd_soc_add_component()
2875 return -ENOMEM; in snd_soc_register_component()
2886 * snd_soc_unregister_component_by_driver - Unregister component using a given driver
2901 component = snd_soc_lookup_component_nolocked(dev, component_driver->name); in snd_soc_unregister_component_by_driver()
2913 * snd_soc_unregister_component - Unregister all related component
2940 if (!card->dev) { in snd_soc_of_parse_card_name()
2941 pr_err("card->dev is not set before calling %s\n", __func__); in snd_soc_of_parse_card_name()
2942 return -EINVAL; in snd_soc_of_parse_card_name()
2945 np = card->dev->of_node; in snd_soc_of_parse_card_name()
2947 ret = of_property_read_string_index(np, propname, 0, &card->name); in snd_soc_of_parse_card_name()
2950 * card->name was previously set, which is checked later in in snd_soc_of_parse_card_name()
2953 if (ret < 0 && ret != -EINVAL) { in snd_soc_of_parse_card_name()
2954 dev_err(card->dev, in snd_soc_of_parse_card_name()
2974 struct device_node *np = card->dev->of_node; in snd_soc_of_parse_audio_simple_widgets()
2981 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
2983 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
2986 dev_err(card->dev, "ASoC: Property '%s's length is zero\n", in snd_soc_of_parse_audio_simple_widgets()
2988 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
2991 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
2993 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
2998 widgets = devm_kcalloc(card->dev, num_widgets, sizeof(*widgets), in snd_soc_of_parse_audio_simple_widgets()
3001 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
3003 return -ENOMEM; in snd_soc_of_parse_audio_simple_widgets()
3010 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
3013 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
3025 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
3028 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
3035 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
3038 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
3044 card->of_dapm_widgets = widgets; in snd_soc_of_parse_audio_simple_widgets()
3045 card->num_of_dapm_widgets = num_widgets; in snd_soc_of_parse_audio_simple_widgets()
3056 struct device *dev = card->dev; in snd_soc_of_parse_pin_switches()
3060 if (!of_property_read_bool(dev->of_node, prop)) in snd_soc_of_parse_pin_switches()
3066 return -ENOMEM; in snd_soc_of_parse_pin_switches()
3068 ret = of_property_read_string_array(dev->of_node, prop, in snd_soc_of_parse_pin_switches()
3078 return -ENOMEM; in snd_soc_of_parse_pin_switches()
3084 return -ENOMEM; in snd_soc_of_parse_pin_switches()
3094 card->controls = controls; in snd_soc_of_parse_pin_switches()
3095 card->num_controls = nb_controls; in snd_soc_of_parse_pin_switches()
3130 snd_soc_of_get_slot_mask(np, "dai-tdm-slot-tx-mask", tx_mask); in snd_soc_of_parse_tdm_slot()
3132 snd_soc_of_get_slot_mask(np, "dai-tdm-slot-rx-mask", rx_mask); in snd_soc_of_parse_tdm_slot()
3134 if (of_property_read_bool(np, "dai-tdm-slot-num")) { in snd_soc_of_parse_tdm_slot()
3135 ret = of_property_read_u32(np, "dai-tdm-slot-num", &val); in snd_soc_of_parse_tdm_slot()
3143 if (of_property_read_bool(np, "dai-tdm-slot-width")) { in snd_soc_of_parse_tdm_slot()
3144 ret = of_property_read_u32(np, "dai-tdm-slot-width", &val); in snd_soc_of_parse_tdm_slot()
3159 platforms->of_node = cpus->of_node; in snd_soc_dlc_use_cpu_as_platform()
3160 platforms->dai_args = cpus->dai_args; in snd_soc_dlc_use_cpu_as_platform()
3178 codec_conf->dlc.of_node = of_node; in snd_soc_of_parse_node_prefix()
3179 codec_conf->name_prefix = str; in snd_soc_of_parse_node_prefix()
3186 struct device_node *np = card->dev->of_node; in snd_soc_of_parse_audio_routing()
3193 dev_err(card->dev, in snd_soc_of_parse_audio_routing()
3196 return -EINVAL; in snd_soc_of_parse_audio_routing()
3200 routes = devm_kcalloc(card->dev, num_routes, sizeof(*routes), in snd_soc_of_parse_audio_routing()
3203 dev_err(card->dev, in snd_soc_of_parse_audio_routing()
3205 return -ENOMEM; in snd_soc_of_parse_audio_routing()
3212 dev_err(card->dev, in snd_soc_of_parse_audio_routing()
3215 return -EINVAL; in snd_soc_of_parse_audio_routing()
3220 dev_err(card->dev, in snd_soc_of_parse_audio_routing()
3223 return -EINVAL; in snd_soc_of_parse_audio_routing()
3227 card->num_of_dapm_routes = num_routes; in snd_soc_of_parse_audio_routing()
3228 card->of_dapm_routes = routes; in snd_soc_of_parse_audio_routing()
3236 struct device_node *node = card->dev->of_node; in snd_soc_of_parse_aux_devs()
3241 if (num == -ENOENT) { in snd_soc_of_parse_aux_devs()
3244 dev_err(card->dev, "ASOC: Property '%s' could not be read: %d\n", in snd_soc_of_parse_aux_devs()
3249 aux = devm_kcalloc(card->dev, num, sizeof(*aux), GFP_KERNEL); in snd_soc_of_parse_aux_devs()
3251 return -ENOMEM; in snd_soc_of_parse_aux_devs()
3252 card->aux_dev = aux; in snd_soc_of_parse_aux_devs()
3253 card->num_aux_devs = num; in snd_soc_of_parse_aux_devs()
3256 aux->dlc.of_node = of_parse_phandle(node, propname, i); in snd_soc_of_parse_aux_devs()
3257 if (!aux->dlc.of_node) in snd_soc_of_parse_aux_devs()
3258 return -EINVAL; in snd_soc_of_parse_aux_devs()
3338 * check "dai-format = xxx" in snd_soc_daifmt_parse_format()
3342 ret = of_property_read_string(np, "dai-format", &str); in snd_soc_daifmt_parse_format()
3359 * check "[prefix]continuous-clock" in snd_soc_daifmt_parse_format()
3362 snprintf(prop, sizeof(prop), "%scontinuous-clock", prefix); in snd_soc_daifmt_parse_format()
3369 * check "[prefix]bitclock-inversion" in snd_soc_daifmt_parse_format()
3370 * check "[prefix]frame-inversion" in snd_soc_daifmt_parse_format()
3373 snprintf(prop, sizeof(prop), "%sbitclock-inversion", prefix); in snd_soc_daifmt_parse_format()
3376 snprintf(prop, sizeof(prop), "%sframe-inversion", prefix); in snd_soc_daifmt_parse_format()
3410 * check "[prefix]bitclock-master" in snd_soc_daifmt_parse_clock_provider_raw()
3411 * check "[prefix]frame-master" in snd_soc_daifmt_parse_clock_provider_raw()
3413 snprintf(prop, sizeof(prop), "%sbitclock-master", prefix); in snd_soc_daifmt_parse_clock_provider_raw()
3418 snprintf(prop, sizeof(prop), "%sframe-master", prefix); in snd_soc_daifmt_parse_clock_provider_raw()
3445 if (!dai_link->c2c_params) in snd_soc_get_stream_cpu()
3481 ret = -ENOTSUPP; in snd_soc_get_dai_id()
3497 int ret = -EPROBE_DEFER; in snd_soc_get_dlc()
3503 if (component_of_node != args->np || !pos->num_dai) in snd_soc_get_dlc()
3506 ret = snd_soc_component_of_xlate_dai_name(pos, args, &dlc->dai_name); in snd_soc_get_dlc()
3507 if (ret == -ENOTSUPP) { in snd_soc_get_dlc()
3508 struct snd_soc_dai *dai; in snd_soc_get_dlc() local
3509 int id = -1; in snd_soc_get_dlc()
3511 switch (args->args_count) { in snd_soc_get_dlc()
3516 id = args->args[0]; in snd_soc_get_dlc()
3523 if (id < 0 || id >= pos->num_dai) { in snd_soc_get_dlc()
3524 ret = -EINVAL; in snd_soc_get_dlc()
3530 /* find target DAI */ in snd_soc_get_dlc()
3531 for_each_component_dais(pos, dai) { in snd_soc_get_dlc()
3534 id--; in snd_soc_get_dlc()
3537 dlc->dai_name = snd_soc_dai_name_get(dai); in snd_soc_get_dlc()
3552 dlc->of_node = args->np; in snd_soc_get_dlc()
3570 ret = of_parse_phandle_with_args(of_node, "sound-dai", in snd_soc_of_get_dlc()
3571 "#sound-dai-cells", index, args); in snd_soc_of_get_dlc()
3607 struct snd_soc_dai *dai; in snd_soc_get_dai_via_args() local
3612 for_each_component_dais(component, dai) in snd_soc_get_dai_via_args()
3613 if (snd_soc_is_match_dai_args(dai->driver->dai_args, dai_args)) in snd_soc_get_dai_via_args()
3616 dai = NULL; in snd_soc_get_dai_via_args()
3619 return dai; in snd_soc_get_dai_via_args()
3625 if (component->of_node) { in __snd_soc_of_put_component()
3626 of_node_put(component->of_node); in __snd_soc_of_put_component()
3627 component->of_node = NULL; in __snd_soc_of_put_component()
3640 num = of_count_phandle_with_args(of_node, "sound-dai", "#sound-dai-cells"); in __snd_soc_of_get_dai_link_component_alloc()
3642 if (num == -ENOENT) in __snd_soc_of_get_dai_link_component_alloc()
3643 dev_err(dev, "No 'sound-dai' property\n"); in __snd_soc_of_get_dai_link_component_alloc()
3645 dev_err(dev, "Bad phandle in 'sound-dai'\n"); in __snd_soc_of_get_dai_link_component_alloc()
3650 return -ENOMEM; in __snd_soc_of_get_dai_link_component_alloc()
3659 * snd_soc_of_put_dai_link_codecs - Dereference device nodes in the codecs array
3660 * @dai_link: DAI link
3675 * snd_soc_of_get_dai_link_codecs - Parse a list of CODECs in the devicetree
3678 * @dai_link: DAI link
3680 * Builds an array of CODEC DAI components from the DAI link property
3681 * 'sound-dai'.
3682 * The array is set in the DAI link and the number of DAIs is set accordingly.
3696 &dai_link->codecs, &dai_link->num_codecs); in snd_soc_of_get_dai_link_codecs()
3709 dai_link->codecs = NULL; in snd_soc_of_get_dai_link_codecs()
3710 dai_link->num_codecs = 0; in snd_soc_of_get_dai_link_codecs()
3716 * snd_soc_of_put_dai_link_cpus - Dereference device nodes in the codecs array
3717 * @dai_link: DAI link
3732 * snd_soc_of_get_dai_link_cpus - Parse a list of CPU DAIs in the devicetree
3735 * @dai_link: DAI link
3751 &dai_link->cpus, &dai_link->num_cpus); in snd_soc_of_get_dai_link_cpus()
3764 dai_link->cpus = NULL; in snd_soc_of_get_dai_link_cpus()
3765 dai_link->num_cpus = 0; in snd_soc_of_get_dai_link_cpus()
3805 MODULE_ALIAS("platform:soc-audio");