Lines Matching +full:i2s +full:- +full:rx +full:- +full:route

1 // SPDX-License-Identifier: GPL-2.0+
3 // soc-core.c -- ALSA SoC Audio Layer
11 // with code, comments and ideas from :-
18 // o Support TDM on PCM and I2S
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()
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()
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 (strcmp(dlc->dai_name, dai->name) == 0) in snd_soc_is_matching_dai()
289 if (dai->driver->name && in snd_soc_is_matching_dai()
290 strcmp(dai->driver->name, dlc->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()
303 if (dai->name) in snd_soc_dai_name_get()
304 return dai->name; in snd_soc_dai_name_get()
306 if (dai->driver->name) in snd_soc_dai_name_get()
307 return dai->driver->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->components[rtd->num_components] = component; in snd_soc_rtd_add_component()
330 rtd->num_components++; 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()
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()
503 * for rtd->dev in soc_new_pcm_runtime()
509 dev->parent = card->dev; in soc_new_pcm_runtime()
510 dev->release = soc_release_rtd_dev; in soc_new_pcm_runtime()
512 dev_set_name(dev, "%s", dai_link->name); in soc_new_pcm_runtime()
525 sizeof(component) * (dai_link->num_cpus + in soc_new_pcm_runtime()
526 dai_link->num_codecs + in soc_new_pcm_runtime()
527 dai_link->num_platforms), in soc_new_pcm_runtime()
534 rtd->dev = dev; in soc_new_pcm_runtime()
535 INIT_LIST_HEAD(&rtd->list); in soc_new_pcm_runtime()
537 INIT_LIST_HEAD(&rtd->dpcm[stream].be_clients); in soc_new_pcm_runtime()
538 INIT_LIST_HEAD(&rtd->dpcm[stream].fe_clients); in soc_new_pcm_runtime()
541 INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); in soc_new_pcm_runtime()
544 * for rtd->dais in soc_new_pcm_runtime()
546 rtd->dais = devm_kcalloc(dev, dai_link->num_cpus + dai_link->num_codecs, in soc_new_pcm_runtime()
549 if (!rtd->dais) in soc_new_pcm_runtime()
555 * |--- num_cpus ---|--- num_codecs --| in soc_new_pcm_runtime()
560 rtd->card = card; in soc_new_pcm_runtime()
561 rtd->dai_link = dai_link; in soc_new_pcm_runtime()
562 rtd->num = card->num_rtd++; in soc_new_pcm_runtime()
563 rtd->pmdown_time = pmdown_time; /* default power off timeout */ in soc_new_pcm_runtime()
566 list_add_tail(&rtd->list, &card->rtd_list); in soc_new_pcm_runtime()
584 flush_delayed_work(&rtd->delayed_work); in snd_soc_flush_all_delayed_work()
597 if (rtd->dai_link->ignore_suspend) in soc_playback_digital_mute()
614 if (rtd->dai_link->ignore_suspend) in soc_dapm_suspend_resume()
636 * suspend before that's finished - wait for it to complete. in snd_soc_suspend()
638 snd_power_wait(card->snd_card); in snd_soc_suspend()
641 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D3hot); in snd_soc_suspend()
648 if (rtd->dai_link->ignore_suspend) in snd_soc_suspend()
651 snd_pcm_suspend_all(rtd->pcm); in snd_soc_suspend()
663 snd_soc_dapm_sync(&card->dapm); in snd_soc_suspend()
668 if (rtd->dai_link->ignore_suspend) in snd_soc_suspend()
693 if (dapm->idle_bias_off) { in snd_soc_suspend()
694 dev_dbg(component->dev, in snd_soc_suspend()
702 if (component->regmap) in snd_soc_suspend()
703 regcache_mark_dirty(component->regmap); in snd_soc_suspend()
705 pinctrl_pm_select_sleep_state(component->dev); in snd_soc_suspend()
708 dev_dbg(component->dev, in snd_soc_suspend()
737 dev_dbg(card->dev, "ASoC: starting resume work\n"); in soc_resume_deferred()
740 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D2); in soc_resume_deferred()
756 dev_dbg(card->dev, "ASoC: resume work completed\n"); in soc_resume_deferred()
760 snd_soc_dapm_sync(&card->dapm); in soc_resume_deferred()
763 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0); in soc_resume_deferred()
779 pinctrl_pm_select_default_state(component->dev); in snd_soc_resume()
782 if (!schedule_work(&card->deferred_resume_work)) in snd_soc_resume()
792 INIT_WORK(&card->deferred_resume_work, soc_resume_deferred); in soc_resume_init()
805 of_node = component->dev->of_node; in soc_component_to_node()
806 if (!of_node && component->dev->parent) in soc_component_to_node()
807 of_node = component->dev->parent->of_node; in soc_component_to_node()
834 if (dlc->dai_args) { in snd_soc_is_matching_component()
845 if (dlc->of_node && component_of_node != dlc->of_node) in snd_soc_is_matching_component()
847 if (dlc->name && strcmp(component->name, dlc->name)) in snd_soc_is_matching_component()
876 * snd_soc_find_dai - Find a registered DAI
998 dev_err(card->dev, "ASoC: Both Component name/of_node are set for %s\n", link->name); in soc_dai_link_sanity_check()
999 return -EINVAL; in soc_dai_link_sanity_check()
1002 dev_err(card->dev, "ASoC: Neither Component name/of_node are set for %s\n", link->name); in soc_dai_link_sanity_check()
1003 return -EINVAL; in soc_dai_link_sanity_check()
1006 dev_dbg(card->dev, "ASoC: Component %s not found for link %s\n", dlc->name, link->name); in soc_dai_link_sanity_check()
1007 return -EPROBE_DEFER; in soc_dai_link_sanity_check()
1010 dev_err(card->dev, "ASoC: DAI name is not set for %s\n", link->name); in soc_dai_link_sanity_check()
1011 return -EINVAL; in soc_dai_link_sanity_check()
1014 dev_err(card->dev, "ASoC: Neither DAI/Component name/of_node are set for %s\n", link->name); in soc_dai_link_sanity_check()
1015 return -EINVAL; in soc_dai_link_sanity_check()
1019 * snd_soc_remove_pcm_runtime - Remove a pcm_runtime from card
1033 snd_soc_card_remove_dai_link(card, rtd->dai_link); in snd_soc_remove_pcm_runtime()
1040 * snd_soc_add_pcm_runtime - Add a pcm_runtime dynamically via dai_link
1067 if (dai_link->ignore) in snd_soc_add_pcm_runtime()
1070 dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name); in snd_soc_add_pcm_runtime()
1078 return -ENOMEM; in snd_soc_add_pcm_runtime()
1083 dev_info(card->dev, "ASoC: CPU DAI %s not registered\n", in snd_soc_add_pcm_runtime()
1084 cpu->dai_name); in snd_soc_add_pcm_runtime()
1087 snd_soc_rtd_add_component(rtd, asoc_rtd_to_cpu(rtd, i)->component); in snd_soc_add_pcm_runtime()
1094 dev_info(card->dev, "ASoC: CODEC DAI %s not registered\n", in snd_soc_add_pcm_runtime()
1095 codec->dai_name); in snd_soc_add_pcm_runtime()
1099 snd_soc_rtd_add_component(rtd, asoc_rtd_to_codec(rtd, i)->component); in snd_soc_add_pcm_runtime()
1108 if (snd_soc_component_is_dummy(component) && component->num_dai) in snd_soc_add_pcm_runtime()
1119 return -EPROBE_DEFER; in snd_soc_add_pcm_runtime()
1139 struct snd_soc_dai_link *dai_link = rtd->dai_link; in snd_soc_runtime_get_dai_fmt()
1188 pri = (j >= i) ? priority : priority - 1; in snd_soc_runtime_get_dai_fmt()
1215 for (i = 63; i >= 0; i--) { in snd_soc_runtime_get_dai_fmt()
1274 * In such case, user want to auto-select non-limitation part, in snd_soc_runtime_get_dai_fmt()
1282 if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK)) in snd_soc_runtime_get_dai_fmt()
1284 if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_CLOCK_MASK)) in snd_soc_runtime_get_dai_fmt()
1286 if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_INV_MASK)) in snd_soc_runtime_get_dai_fmt()
1288 if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK)) in snd_soc_runtime_get_dai_fmt()
1291 dai_link->dai_fmt |= (dai_fmt & mask); in snd_soc_runtime_get_dai_fmt()
1295 * snd_soc_runtime_set_dai_fmt() - Change DAI link format for a ASoC runtime
1320 if (ret != 0 && ret != -ENOTSUPP) in snd_soc_runtime_set_dai_fmt()
1329 if (ret != 0 && ret != -ENOTSUPP) in snd_soc_runtime_set_dai_fmt()
1340 struct snd_soc_dai_link *dai_link = rtd->dai_link; in soc_init_pcm_runtime()
1351 ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt); in soc_init_pcm_runtime()
1358 num = rtd->num; in soc_init_pcm_runtime()
1366 if (!component->driver->use_dai_pcm_id) in soc_init_pcm_runtime()
1369 if (rtd->dai_link->no_pcm) in soc_init_pcm_runtime()
1370 num += component->driver->be_pcm_base; in soc_init_pcm_runtime()
1372 num = rtd->dai_link->id; in soc_init_pcm_runtime()
1377 if (ret != -ENOTSUPP) in soc_init_pcm_runtime()
1383 dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", in soc_init_pcm_runtime()
1384 dai_link->stream_name, ret); in soc_init_pcm_runtime()
1392 rtd->initialized = true; in soc_init_pcm_runtime()
1407 for (i = 0; i < card->num_configs; i++) { in soc_set_name_prefix()
1408 struct snd_soc_codec_conf *map = &card->codec_conf[i]; in soc_set_name_prefix()
1410 if (snd_soc_is_matching_component(&map->dlc, component) && in soc_set_name_prefix()
1411 map->name_prefix) { in soc_set_name_prefix()
1412 component->name_prefix = map->name_prefix; in soc_set_name_prefix()
1421 ret = of_property_read_string(of_node, "sound-name-prefix", &str); in soc_set_name_prefix()
1425 component->name_prefix = str; in soc_set_name_prefix()
1432 if (!component->card) in soc_remove_component()
1438 list_del_init(&component->card_list); in soc_remove_component()
1441 component->card = NULL; in soc_remove_component()
1457 if (component->card) { in soc_probe_component()
1458 if (component->card != card) { in soc_probe_component()
1459 dev_err(component->dev, in soc_probe_component()
1461 component->name, card->name, component->card->name); in soc_probe_component()
1462 return -ENODEV; in soc_probe_component()
1471 component->card = card; in soc_probe_component()
1479 component->driver->dapm_widgets, in soc_probe_component()
1480 component->driver->num_dapm_widgets); in soc_probe_component()
1483 dev_err(component->dev, in soc_probe_component()
1491 dev_err(component->dev, in soc_probe_component()
1501 WARN(dapm->idle_bias_off && in soc_probe_component()
1502 dapm->bias_level != SND_SOC_BIAS_OFF, in soc_probe_component()
1503 "codec %s can not start from non-off bias with idle_bias_off==1\n", in soc_probe_component()
1504 component->name); in soc_probe_component()
1517 component->driver->controls, in soc_probe_component()
1518 component->driver->num_controls); in soc_probe_component()
1523 component->driver->dapm_routes, in soc_probe_component()
1524 component->driver->num_dapm_routes); in soc_probe_component()
1526 if (card->disable_route_checks) { in soc_probe_component()
1527 dev_info(card->dev, in soc_probe_component()
1531 dev_err(card->dev, in soc_probe_component()
1539 list_add(&component->card_list, &card->component_dev_list); in soc_probe_component()
1587 if (component->driver->remove_order != order) in soc_remove_link_components()
1605 if (component->driver->probe_order != order) in soc_probe_link_components()
1625 list_del(&component->card_aux_list); in soc_unbind_aux_dev()
1637 component = soc_find_component(&aux->dlc); in soc_bind_aux_dev()
1639 return -EPROBE_DEFER; in soc_bind_aux_dev()
1644 list_add(&component->card_aux_list, &card->aux_comp_list); in soc_bind_aux_dev()
1657 if (component->driver->probe_order != order) in soc_probe_aux_devices()
1676 if (comp->driver->remove_order == order) in soc_remove_aux_devices()
1685 * "Type2 - Board Manufacturer" or "Type1 - TBD by OEM"), it will be taken
1699 * Trim special characters, and replace '-' with '_' since '-' is used to
1711 else if (name[i] == '-') in cleanup_dmi_name()
1736 * Append a string to card->dmi_longname with character cleanups.
1740 char *dst = card->dmi_longname; in append_dmi_string()
1741 size_t dst_len = sizeof(card->dmi_longname); in append_dmi_string()
1745 snprintf(dst + len, dst_len - len, "-%s", str); in append_dmi_string()
1747 len++; /* skip the separator "-" */ in append_dmi_string()
1753 * snd_soc_set_dmi_name() - Register DMI names to card
1761 * device-specific configurations, this function allows DMI info to be used
1763 * "vendor-product-version-board"
1764 * (Character '-' is used to separate different DMI fields here).
1765 * This will help the user space to load the device-specific Use Case Manager
1769 * DellInc.-XPS139343-01-0310JH
1770 * ASUSTeKCOMPUTERINC.-T100TA-1.0-T100TA
1771 * Circuitco-MinnowboardMaxD0PLATFORM-D0-MinnowBoardMAX
1774 * the extra differentiation, like "vendor-product-version-board-flavor".
1787 if (card->long_name) in snd_soc_set_dmi_name()
1793 /* make up dmi long name as: vendor-product-version-board */ in snd_soc_set_dmi_name()
1796 dev_warn(card->dev, "ASoC: no DMI vendor name!\n"); in snd_soc_set_dmi_name()
1800 snprintf(card->dmi_longname, sizeof(card->dmi_longname), "%s", vendor); in snd_soc_set_dmi_name()
1801 cleanup_dmi_name(card->dmi_longname); in snd_soc_set_dmi_name()
1810 * some vendors like Lenovo may only put a self-explanatory in snd_soc_set_dmi_name()
1823 dev_warn(card->dev, "ASoC: no DMI board/product name!\n"); in snd_soc_set_dmi_name()
1832 card->long_name = card->dmi_longname; in snd_soc_set_dmi_name()
1849 if (!component->driver->ignore_machine) in soc_check_tplg_fes()
1853 if (!strcmp(component->driver->ignore_machine, in soc_check_tplg_fes()
1854 card->dev->driver->name)) in soc_check_tplg_fes()
1856 if (strcmp(component->driver->ignore_machine, in soc_check_tplg_fes()
1857 dev_name(card->dev))) in soc_check_tplg_fes()
1864 if (dai_link->dynamic) { in soc_check_tplg_fes()
1865 dai_link->ignore = true; in soc_check_tplg_fes()
1869 dev_dbg(card->dev, "info: override BE DAI link %s\n", in soc_check_tplg_fes()
1870 card->dai_link[i].name); in soc_check_tplg_fes()
1873 if (!dai_link->platforms) { in soc_check_tplg_fes()
1874 dev_err(card->dev, "init platform error"); in soc_check_tplg_fes()
1878 if (component->dev->of_node) in soc_check_tplg_fes()
1879 dai_link->platforms->of_node = component->dev->of_node; in soc_check_tplg_fes()
1881 dai_link->platforms->name = component->name; in soc_check_tplg_fes()
1884 if (!dai_link->no_pcm) { in soc_check_tplg_fes()
1885 dai_link->no_pcm = 1; in soc_check_tplg_fes()
1887 if (dai_link->dpcm_playback) in soc_check_tplg_fes()
1888 dev_warn(card->dev, in soc_check_tplg_fes()
1890 dai_link->name); in soc_check_tplg_fes()
1891 if (dai_link->dpcm_capture) in soc_check_tplg_fes()
1892 dev_warn(card->dev, in soc_check_tplg_fes()
1894 dai_link->name); in soc_check_tplg_fes()
1897 if (!(dai_link->dpcm_playback || in soc_check_tplg_fes()
1898 dai_link->dpcm_capture)) { in soc_check_tplg_fes()
1899 dai_link->dpcm_playback = !dai_link->capture_only; in soc_check_tplg_fes()
1900 dai_link->dpcm_capture = !dai_link->playback_only; in soc_check_tplg_fes()
1909 dai_link->be_hw_params_fixup = in soc_check_tplg_fes()
1910 component->driver->be_hw_params_fixup; in soc_check_tplg_fes()
1916 if (!dai_link->stream_name) in soc_check_tplg_fes()
1917 dai_link->stream_name = dai_link->name; in soc_check_tplg_fes()
1921 if (component->driver->topology_name_prefix) { in soc_check_tplg_fes()
1924 if (!card->topology_shortname_created) { in soc_check_tplg_fes()
1925 comp_drv = component->driver; in soc_check_tplg_fes()
1927 snprintf(card->topology_shortname, 32, "%s-%s", in soc_check_tplg_fes()
1928 comp_drv->topology_name_prefix, in soc_check_tplg_fes()
1929 card->name); in soc_check_tplg_fes()
1930 card->topology_shortname_created = true; in soc_check_tplg_fes()
1934 card->name = card->topology_shortname; in soc_check_tplg_fes()
1950 if (name != card->snd_card->driver) in __soc_setup_card_name()
1957 * searches in the user-space. in __soc_setup_card_name()
1960 * "abcd??efg" -> "abcd__efg" in __soc_setup_card_name()
1965 case '-': in __soc_setup_card_name()
1980 if (strlen(src) > len - 1) in __soc_setup_card_name()
1981 dev_err(card->dev, "ASoC: driver name too long '%s' -> '%s'\n", src, name); in __soc_setup_card_name()
1988 if (card->snd_card) in soc_cleanup_card_resources()
1989 snd_card_disconnect_sync(card->snd_card); in soc_cleanup_card_resources()
1995 if (rtd->initialized) in soc_cleanup_card_resources()
2008 snd_soc_dapm_free(&card->dapm); in soc_cleanup_card_resources()
2014 if (card->snd_card) { in soc_cleanup_card_resources()
2015 snd_card_free(card->snd_card); in soc_cleanup_card_resources()
2016 card->snd_card = NULL; in soc_cleanup_card_resources()
2023 card->instantiated = false; in snd_soc_unbind_card()
2028 list_add(&card->list, &unbind_card_list); in snd_soc_unbind_card()
2031 list_del(&card->list); in snd_soc_unbind_card()
2044 snd_soc_dapm_init(&card->dapm, card, NULL); in snd_soc_bind_card()
2055 card->num_rtd = 0; in snd_soc_bind_card()
2056 ret = snd_soc_add_pcm_runtimes(card, card->dai_link, card->num_links); in snd_soc_bind_card()
2061 ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, in snd_soc_bind_card()
2062 card->owner, 0, &card->snd_card); in snd_soc_bind_card()
2064 dev_err(card->dev, in snd_soc_bind_card()
2066 card->name, ret); in snd_soc_bind_card()
2074 ret = snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets, in snd_soc_bind_card()
2075 card->num_dapm_widgets); in snd_soc_bind_card()
2079 ret = snd_soc_dapm_new_controls(&card->dapm, card->of_dapm_widgets, in snd_soc_bind_card()
2080 card->num_of_dapm_widgets); in snd_soc_bind_card()
2092 if (ret != -EPROBE_DEFER) { in snd_soc_bind_card()
2093 dev_err(card->dev, in snd_soc_bind_card()
2102 dev_err(card->dev, in snd_soc_bind_card()
2110 dev_err(card->dev, in snd_soc_bind_card()
2124 ret = snd_soc_add_card_controls(card, card->controls, in snd_soc_bind_card()
2125 card->num_controls); in snd_soc_bind_card()
2129 ret = snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes, in snd_soc_bind_card()
2130 card->num_dapm_routes); in snd_soc_bind_card()
2132 if (card->disable_route_checks) { in snd_soc_bind_card()
2133 dev_info(card->dev, in snd_soc_bind_card()
2137 dev_err(card->dev, in snd_soc_bind_card()
2144 ret = snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes, in snd_soc_bind_card()
2145 card->num_of_dapm_routes); in snd_soc_bind_card()
2152 soc_setup_card_name(card, card->snd_card->shortname, in snd_soc_bind_card()
2153 card->name, NULL); in snd_soc_bind_card()
2154 soc_setup_card_name(card, card->snd_card->longname, in snd_soc_bind_card()
2155 card->long_name, card->name); in snd_soc_bind_card()
2156 soc_setup_card_name(card, card->snd_card->driver, in snd_soc_bind_card()
2157 card->driver_name, card->name); in snd_soc_bind_card()
2159 if (card->components) { in snd_soc_bind_card()
2164 ret = snd_component_add(card->snd_card, card->components); in snd_soc_bind_card()
2166 dev_err(card->dev, "ASoC: %s snd_component_add() failed: %d\n", in snd_soc_bind_card()
2167 card->name, ret); in snd_soc_bind_card()
2179 ret = snd_card_register(card->snd_card); in snd_soc_bind_card()
2181 dev_err(card->dev, "ASoC: failed to register soundcard %d\n", in snd_soc_bind_card()
2186 card->instantiated = 1; in snd_soc_bind_card()
2188 snd_soc_dapm_sync(&card->dapm); in snd_soc_bind_card()
2193 pinctrl_pm_select_sleep_state(component->dev); in snd_soc_bind_card()
2215 return -EINVAL; in soc_probe()
2217 dev_warn(&pdev->dev, in soc_probe()
2219 card->name); in soc_probe()
2222 card->dev = &pdev->dev; in soc_probe()
2224 return devm_snd_soc_register_card(&pdev->dev, card); in soc_probe()
2236 * Flush out pmdown_time work - we actually do want to run it in snd_soc_poweroff()
2245 pinctrl_pm_select_sleep_state(component->dev); in snd_soc_poweroff()
2264 .name = "soc-audio",
2271 * snd_soc_cnew - create new control
2322 control->name, prefix)); in snd_soc_add_controls()
2325 control->name, err); in snd_soc_add_controls()
2334 * snd_soc_add_component_controls - Add an array of controls to a component.
2345 struct snd_card *card = component->card->snd_card; in snd_soc_add_component_controls()
2347 return snd_soc_add_controls(card, component->dev, controls, in snd_soc_add_component_controls()
2348 num_controls, component->name_prefix, component); in snd_soc_add_component_controls()
2353 * snd_soc_add_card_controls - add an array of controls to a SoC card.
2365 struct snd_card *card = soc_card->snd_card; in snd_soc_add_card_controls()
2367 return snd_soc_add_controls(card, soc_card->dev, controls, num_controls, in snd_soc_add_card_controls()
2373 * snd_soc_add_dai_controls - add an array of controls to a DAI.
2385 struct snd_card *card = dai->component->card->snd_card; in snd_soc_add_dai_controls()
2387 return snd_soc_add_controls(card, dai->dev, controls, num_controls, in snd_soc_add_dai_controls()
2393 * snd_soc_register_card - Register a card with the ASoC core
2400 if (!card->name || !card->dev) in snd_soc_register_card()
2401 return -EINVAL; in snd_soc_register_card()
2403 dev_set_drvdata(card->dev, card); in snd_soc_register_card()
2405 INIT_LIST_HEAD(&card->widgets); in snd_soc_register_card()
2406 INIT_LIST_HEAD(&card->paths); in snd_soc_register_card()
2407 INIT_LIST_HEAD(&card->dapm_list); in snd_soc_register_card()
2408 INIT_LIST_HEAD(&card->aux_comp_list); in snd_soc_register_card()
2409 INIT_LIST_HEAD(&card->component_dev_list); in snd_soc_register_card()
2410 INIT_LIST_HEAD(&card->list); in snd_soc_register_card()
2411 INIT_LIST_HEAD(&card->rtd_list); in snd_soc_register_card()
2412 INIT_LIST_HEAD(&card->dapm_dirty); in snd_soc_register_card()
2413 INIT_LIST_HEAD(&card->dobj_list); in snd_soc_register_card()
2415 card->instantiated = 0; in snd_soc_register_card()
2416 mutex_init(&card->mutex); in snd_soc_register_card()
2417 mutex_init(&card->dapm_mutex); in snd_soc_register_card()
2418 mutex_init(&card->pcm_mutex); in snd_soc_register_card()
2425 * snd_soc_unregister_card - Unregister a card with the ASoC core
2435 dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name); in snd_soc_unregister_card()
2440 * Simplify DAI link configuration by removing ".-1" from device names
2457 found = strstr(name, dev->driver->name); in fmt_single_name()
2460 if (sscanf(&found[strlen(dev->driver->name)], ".%d", id) == 1) { in fmt_single_name()
2462 /* discard ID from name if ID == -1 */ in fmt_single_name()
2463 if (*id == -1) in fmt_single_name()
2464 found[strlen(dev->driver->name)] = '\0'; in fmt_single_name()
2467 /* I2C component devices are named "bus-addr" */ in fmt_single_name()
2468 } else if (sscanf(name, "%x-%x", &id1, &id2) == 2) { in fmt_single_name()
2476 name = devm_kasprintf(dev, GFP_KERNEL, "%s.%s", dev->driver->name, devname); in fmt_single_name()
2486 * any ".-1" and using the DAI name (instead of device name).
2491 if (dai_drv->name == NULL) { in fmt_multiple_name()
2493 "ASoC: error - multiple DAI %s registered with no name\n", in fmt_multiple_name()
2498 return devm_kstrdup(dev, dai_drv->name, GFP_KERNEL); in fmt_multiple_name()
2503 dev_dbg(dai->dev, "ASoC: Unregistered DAI '%s'\n", dai->name); in snd_soc_unregister_dai()
2504 list_del(&dai->list); in snd_soc_unregister_dai()
2509 * snd_soc_register_dai - Register a DAI dynamically & create its widgets
2513 * @legacy_dai_naming: if %true, use legacy single-name format;
2514 * if %false, use multiple-name format;
2524 struct device *dev = component->dev; in snd_soc_register_dai()
2534 * Back in the old days when we still had component-less DAIs, in snd_soc_register_dai()
2535 * instead of having a static name, component-less DAIs would in snd_soc_register_dai()
2539 * component-less anymore. in snd_soc_register_dai()
2542 (dai_drv->id == 0 || dai_drv->name == NULL)) { in snd_soc_register_dai()
2543 dai->name = fmt_single_name(dev, &dai->id); in snd_soc_register_dai()
2545 dai->name = fmt_multiple_name(dev, dai_drv); in snd_soc_register_dai()
2546 if (dai_drv->id) in snd_soc_register_dai()
2547 dai->id = dai_drv->id; in snd_soc_register_dai()
2549 dai->id = component->num_dai; in snd_soc_register_dai()
2551 if (!dai->name) in snd_soc_register_dai()
2554 dai->component = component; in snd_soc_register_dai()
2555 dai->dev = dev; in snd_soc_register_dai()
2556 dai->driver = dai_drv; in snd_soc_register_dai()
2559 list_add_tail(&dai->list, &component->dai_list); in snd_soc_register_dai()
2560 component->num_dai++; in snd_soc_register_dai()
2562 dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name); in snd_soc_register_dai()
2568 * snd_soc_unregister_dais - Unregister DAIs from the ASoC core
2581 * snd_soc_register_dais - Register a DAI with the ASoC core
2597 component->driver->legacy_dai_naming); in snd_soc_register_dais()
2599 ret = -ENOMEM; in snd_soc_register_dais()
2643 if (stream->formats & endianness_format_map[i]) in convert_endianness_formats()
2644 stream->formats |= endianness_format_map[i]; in convert_endianness_formats()
2653 list_del(&card->list); in snd_soc_try_rebind_card()
2658 struct snd_soc_card *card = component->card; in snd_soc_del_component_unlocked()
2665 list_del(&component->list); in snd_soc_del_component_unlocked()
2672 INIT_LIST_HEAD(&component->dai_list); in snd_soc_component_initialize()
2673 INIT_LIST_HEAD(&component->dobj_list); in snd_soc_component_initialize()
2674 INIT_LIST_HEAD(&component->card_list); in snd_soc_component_initialize()
2675 INIT_LIST_HEAD(&component->list); in snd_soc_component_initialize()
2676 mutex_init(&component->io_mutex); in snd_soc_component_initialize()
2678 component->name = fmt_single_name(dev, &component->id); in snd_soc_component_initialize()
2679 if (!component->name) { in snd_soc_component_initialize()
2681 return -ENOMEM; in snd_soc_component_initialize()
2684 component->dev = dev; in snd_soc_component_initialize()
2685 component->driver = driver; in snd_soc_component_initialize()
2688 if (!component->debugfs_prefix) in snd_soc_component_initialize()
2689 component->debugfs_prefix = driver->debugfs_prefix; in snd_soc_component_initialize()
2705 if (component->driver->endianness) { in snd_soc_add_component()
2714 dev_err(component->dev, "ASoC: Failed to register DAIs: %d\n", in snd_soc_add_component()
2719 if (!component->driver->write && !component->driver->read) { in snd_soc_add_component()
2720 if (!component->regmap) in snd_soc_add_component()
2721 component->regmap = dev_get_regmap(component->dev, in snd_soc_add_component()
2723 if (component->regmap) in snd_soc_add_component()
2728 list_add(&component->list, &component_list); in snd_soc_add_component()
2753 return -ENOMEM; in snd_soc_register_component()
2764 * snd_soc_unregister_component_by_driver - Unregister component using a given driver
2779 component = snd_soc_lookup_component_nolocked(dev, component_driver->name); in snd_soc_unregister_component_by_driver()
2791 * snd_soc_unregister_component - Unregister all related component
2818 if (!card->dev) { in snd_soc_of_parse_card_name()
2819 pr_err("card->dev is not set before calling %s\n", __func__); in snd_soc_of_parse_card_name()
2820 return -EINVAL; in snd_soc_of_parse_card_name()
2823 np = card->dev->of_node; in snd_soc_of_parse_card_name()
2825 ret = of_property_read_string_index(np, propname, 0, &card->name); in snd_soc_of_parse_card_name()
2828 * card->name was previously set, which is checked later in in snd_soc_of_parse_card_name()
2831 if (ret < 0 && ret != -EINVAL) { in snd_soc_of_parse_card_name()
2832 dev_err(card->dev, in snd_soc_of_parse_card_name()
2852 struct device_node *np = card->dev->of_node; in snd_soc_of_parse_audio_simple_widgets()
2859 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
2861 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
2864 dev_err(card->dev, "ASoC: Property '%s's length is zero\n", in snd_soc_of_parse_audio_simple_widgets()
2866 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
2869 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
2871 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
2876 widgets = devm_kcalloc(card->dev, num_widgets, sizeof(*widgets), in snd_soc_of_parse_audio_simple_widgets()
2879 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
2881 return -ENOMEM; in snd_soc_of_parse_audio_simple_widgets()
2888 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
2891 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
2903 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
2906 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
2913 dev_err(card->dev, in snd_soc_of_parse_audio_simple_widgets()
2916 return -EINVAL; in snd_soc_of_parse_audio_simple_widgets()
2922 card->of_dapm_widgets = widgets; in snd_soc_of_parse_audio_simple_widgets()
2923 card->num_of_dapm_widgets = num_widgets; in snd_soc_of_parse_audio_simple_widgets()
2934 struct device *dev = card->dev; in snd_soc_of_parse_pin_switches()
2938 if (!of_property_read_bool(dev->of_node, prop)) in snd_soc_of_parse_pin_switches()
2944 return -ENOMEM; in snd_soc_of_parse_pin_switches()
2946 ret = of_property_read_string_array(dev->of_node, prop, in snd_soc_of_parse_pin_switches()
2956 return -ENOMEM; in snd_soc_of_parse_pin_switches()
2962 return -ENOMEM; in snd_soc_of_parse_pin_switches()
2972 card->controls = controls; in snd_soc_of_parse_pin_switches()
2973 card->num_controls = nb_controls; in snd_soc_of_parse_pin_switches()
3008 snd_soc_of_get_slot_mask(np, "dai-tdm-slot-tx-mask", tx_mask); in snd_soc_of_parse_tdm_slot()
3010 snd_soc_of_get_slot_mask(np, "dai-tdm-slot-rx-mask", rx_mask); in snd_soc_of_parse_tdm_slot()
3012 if (of_property_read_bool(np, "dai-tdm-slot-num")) { in snd_soc_of_parse_tdm_slot()
3013 ret = of_property_read_u32(np, "dai-tdm-slot-num", &val); in snd_soc_of_parse_tdm_slot()
3021 if (of_property_read_bool(np, "dai-tdm-slot-width")) { in snd_soc_of_parse_tdm_slot()
3022 ret = of_property_read_u32(np, "dai-tdm-slot-width", &val); in snd_soc_of_parse_tdm_slot()
3037 platforms->of_node = cpus->of_node; in snd_soc_dlc_use_cpu_as_platform()
3038 platforms->dai_args = cpus->dai_args; in snd_soc_dlc_use_cpu_as_platform()
3056 codec_conf->dlc.of_node = of_node; in snd_soc_of_parse_node_prefix()
3057 codec_conf->name_prefix = str; in snd_soc_of_parse_node_prefix()
3064 struct device_node *np = card->dev->of_node; in snd_soc_of_parse_audio_routing()
3071 dev_err(card->dev, in snd_soc_of_parse_audio_routing()
3074 return -EINVAL; in snd_soc_of_parse_audio_routing()
3078 routes = devm_kcalloc(card->dev, num_routes, sizeof(*routes), in snd_soc_of_parse_audio_routing()
3081 dev_err(card->dev, in snd_soc_of_parse_audio_routing()
3082 "ASoC: Could not allocate DAPM route table\n"); in snd_soc_of_parse_audio_routing()
3083 return -ENOMEM; in snd_soc_of_parse_audio_routing()
3090 dev_err(card->dev, in snd_soc_of_parse_audio_routing()
3093 return -EINVAL; in snd_soc_of_parse_audio_routing()
3098 dev_err(card->dev, in snd_soc_of_parse_audio_routing()
3101 return -EINVAL; in snd_soc_of_parse_audio_routing()
3105 card->num_of_dapm_routes = num_routes; in snd_soc_of_parse_audio_routing()
3106 card->of_dapm_routes = routes; in snd_soc_of_parse_audio_routing()
3114 struct device_node *node = card->dev->of_node; in snd_soc_of_parse_aux_devs()
3119 if (num == -ENOENT) { in snd_soc_of_parse_aux_devs()
3122 dev_err(card->dev, "ASOC: Property '%s' could not be read: %d\n", in snd_soc_of_parse_aux_devs()
3127 aux = devm_kcalloc(card->dev, num, sizeof(*aux), GFP_KERNEL); in snd_soc_of_parse_aux_devs()
3129 return -ENOMEM; in snd_soc_of_parse_aux_devs()
3130 card->aux_dev = aux; in snd_soc_of_parse_aux_devs()
3131 card->num_aux_devs = num; in snd_soc_of_parse_aux_devs()
3134 aux->dlc.of_node = of_parse_phandle(node, propname, i); in snd_soc_of_parse_aux_devs()
3135 if (!aux->dlc.of_node) in snd_soc_of_parse_aux_devs()
3136 return -EINVAL; in snd_soc_of_parse_aux_devs()
3201 { "i2s", SND_SOC_DAIFMT_I2S }, in snd_soc_daifmt_parse_format()
3216 * check "dai-format = xxx" in snd_soc_daifmt_parse_format()
3220 ret = of_property_read_string(np, "dai-format", &str); in snd_soc_daifmt_parse_format()
3237 * check "[prefix]continuous-clock" in snd_soc_daifmt_parse_format()
3240 snprintf(prop, sizeof(prop), "%scontinuous-clock", prefix); in snd_soc_daifmt_parse_format()
3247 * check "[prefix]bitclock-inversion" in snd_soc_daifmt_parse_format()
3248 * check "[prefix]frame-inversion" in snd_soc_daifmt_parse_format()
3251 snprintf(prop, sizeof(prop), "%sbitclock-inversion", prefix); in snd_soc_daifmt_parse_format()
3254 snprintf(prop, sizeof(prop), "%sframe-inversion", prefix); in snd_soc_daifmt_parse_format()
3288 * check "[prefix]bitclock-master" in snd_soc_daifmt_parse_clock_provider_raw()
3289 * check "[prefix]frame-master" in snd_soc_daifmt_parse_clock_provider_raw()
3291 snprintf(prop, sizeof(prop), "%sbitclock-master", prefix); in snd_soc_daifmt_parse_clock_provider_raw()
3296 snprintf(prop, sizeof(prop), "%sframe-master", prefix); in snd_soc_daifmt_parse_clock_provider_raw()
3323 if (!dai_link->c2c_params) in snd_soc_get_stream_cpu()
3359 ret = -ENOTSUPP; in snd_soc_get_dai_id()
3375 int ret = -EPROBE_DEFER; in snd_soc_get_dlc()
3381 if (component_of_node != args->np || !pos->num_dai) in snd_soc_get_dlc()
3384 ret = snd_soc_component_of_xlate_dai_name(pos, args, &dlc->dai_name); in snd_soc_get_dlc()
3385 if (ret == -ENOTSUPP) { in snd_soc_get_dlc()
3387 int id = -1; in snd_soc_get_dlc()
3389 switch (args->args_count) { in snd_soc_get_dlc()
3394 id = args->args[0]; in snd_soc_get_dlc()
3401 if (id < 0 || id >= pos->num_dai) { in snd_soc_get_dlc()
3402 ret = -EINVAL; in snd_soc_get_dlc()
3412 id--; in snd_soc_get_dlc()
3415 dlc->dai_name = snd_soc_dai_name_get(dai); in snd_soc_get_dlc()
3430 dlc->of_node = args->np; in snd_soc_get_dlc()
3448 ret = of_parse_phandle_with_args(of_node, "sound-dai", in snd_soc_of_get_dlc()
3449 "#sound-dai-cells", index, args); in snd_soc_of_get_dlc()
3491 if (snd_soc_is_match_dai_args(dai->driver->dai_args, dai_args)) in snd_soc_get_dai_via_args()
3503 if (component->of_node) { in __snd_soc_of_put_component()
3504 of_node_put(component->of_node); in __snd_soc_of_put_component()
3505 component->of_node = NULL; in __snd_soc_of_put_component()
3518 num = of_count_phandle_with_args(of_node, "sound-dai", "#sound-dai-cells"); in __snd_soc_of_get_dai_link_component_alloc()
3520 if (num == -ENOENT) in __snd_soc_of_get_dai_link_component_alloc()
3521 dev_err(dev, "No 'sound-dai' property\n"); in __snd_soc_of_get_dai_link_component_alloc()
3523 dev_err(dev, "Bad phandle in 'sound-dai'\n"); in __snd_soc_of_get_dai_link_component_alloc()
3528 return -ENOMEM; in __snd_soc_of_get_dai_link_component_alloc()
3537 * snd_soc_of_put_dai_link_codecs - Dereference device nodes in the codecs array
3553 * snd_soc_of_get_dai_link_codecs - Parse a list of CODECs in the devicetree
3559 * 'sound-dai'.
3574 &dai_link->codecs, &dai_link->num_codecs); in snd_soc_of_get_dai_link_codecs()
3587 dai_link->codecs = NULL; in snd_soc_of_get_dai_link_codecs()
3588 dai_link->num_codecs = 0; in snd_soc_of_get_dai_link_codecs()
3594 * snd_soc_of_put_dai_link_cpus - Dereference device nodes in the codecs array
3610 * snd_soc_of_get_dai_link_cpus - Parse a list of CPU DAIs in the devicetree
3629 &dai_link->cpus, &dai_link->num_cpus); in snd_soc_of_get_dai_link_cpus()
3642 dai_link->cpus = NULL; in snd_soc_of_get_dai_link_cpus()
3643 dai_link->num_cpus = 0; in snd_soc_of_get_dai_link_cpus()
3683 MODULE_ALIAS("platform:soc-audio");