Lines Matching +full:current +full:- +full:num +full:- +full:sinks

1 // SPDX-License-Identifier: GPL-2.0+
3 // soc-pcm.c -- ALSA SoC PCM
25 #include <sound/soc-dpcm.h>
26 #include <sound/soc-link.h>
39 case -EPROBE_DEFER: in _soc_pcm_ret()
40 case -ENOTSUPP: in _soc_pcm_ret()
41 case -EINVAL: in _soc_pcm_ret()
44 dev_err(rtd->dev, in _soc_pcm_ret()
46 func, rtd->dai_link->name, ret); in _soc_pcm_ret()
74 return (rtd)->dai_link->num_cpus == 1 ? asoc_rtd_to_cpu(rtd, 0)->name : "multicpu"; in soc_cpu_dai_name()
78 return (rtd)->dai_link->num_codecs == 1 ? asoc_rtd_to_codec(rtd, 0)->name : "multicodec"; in soc_codec_dai_name()
113 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; in dpcm_show_state()
118 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
119 "[%s - %s]\n", fe->dai_link->name, in dpcm_show_state()
122 offset += scnprintf(buf + offset, size - offset, "State: %s\n", in dpcm_show_state()
123 dpcm_state_string(fe->dpcm[stream].state)); in dpcm_show_state()
125 if ((fe->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
126 (fe->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
127 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
135 offset += scnprintf(buf + offset, size - offset, "Backends:\n"); in dpcm_show_state()
137 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_show_state()
138 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
144 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_show_state()
145 params = &be->dpcm[stream].hw_params; in dpcm_show_state()
147 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
148 "- %s\n", be->dai_link->name); in dpcm_show_state()
150 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
152 dpcm_state_string(be->dpcm[stream].state)); in dpcm_show_state()
154 if ((be->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
155 (be->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
156 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
170 struct snd_soc_pcm_runtime *fe = file->private_data; in dpcm_state_read_file()
175 if (fe->dai_link->num_cpus > 1) { in dpcm_state_read_file()
176 dev_err(fe->dev, in dpcm_state_read_file()
178 return -EINVAL; in dpcm_state_read_file()
183 return -ENOMEM; in dpcm_state_read_file()
190 out_count - offset); in dpcm_state_read_file()
207 if (!rtd->dai_link->dynamic) in soc_dpcm_debugfs_add()
210 if (!rtd->card->debugfs_card_root) in soc_dpcm_debugfs_add()
213 rtd->debugfs_dpcm_root = debugfs_create_dir(rtd->dai_link->name, in soc_dpcm_debugfs_add()
214 rtd->card->debugfs_card_root); in soc_dpcm_debugfs_add()
216 debugfs_create_file("state", 0444, rtd->debugfs_dpcm_root, in soc_dpcm_debugfs_add()
224 name = kasprintf(GFP_KERNEL, "%s:%s", dpcm->be->dai_link->name, in dpcm_create_debugfs_state()
227 dpcm->debugfs_state = debugfs_create_dir( in dpcm_create_debugfs_state()
228 name, dpcm->fe->debugfs_dpcm_root); in dpcm_create_debugfs_state()
229 debugfs_create_u32("state", 0644, dpcm->debugfs_state, in dpcm_create_debugfs_state()
230 &dpcm->state); in dpcm_create_debugfs_state()
237 debugfs_remove_recursive(dpcm->debugfs_state); in dpcm_remove_debugfs_state()
264 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) { in dpcm_set_fe_update_state()
266 fe->dpcm[stream].trigger_pending - 1); in dpcm_set_fe_update_state()
267 fe->dpcm[stream].trigger_pending = 0; in dpcm_set_fe_update_state()
269 fe->dpcm[stream].runtime_update = state; in dpcm_set_fe_update_state()
276 be->dpcm[stream].runtime_update = state; in dpcm_set_be_update_state()
280 * snd_soc_runtime_action() - Increment/Decrement active count for
284 * @action: Activate stream if 1. Deactivate if -1.
290 * Must be called with the rtd->card->pcm_mutex being held
306 * snd_soc_runtime_ignore_pmdown_time() - Check whether to ignore the power down delay
320 if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time) in snd_soc_runtime_ignore_pmdown_time()
324 ignore &= !component->driver->use_pmdown_time; in snd_soc_runtime_ignore_pmdown_time()
330 * snd_soc_set_runtime_hwparams - set the runtime hardware parameters
339 substream->runtime->hw = *hw; in snd_soc_set_runtime_hwparams()
355 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_dapm_stream_event()
357 dev_dbg(be->dev, "ASoC: BE %s event %d dir %d\n", in dpcm_dapm_stream_event()
358 be->dai_link->name, event, dir); in dpcm_dapm_stream_event()
361 (be->dpcm[dir].users >= 1)) in dpcm_dapm_stream_event()
376 dai->rate = params_rate(params); in soc_pcm_set_dai_params()
377 dai->channels = params_channels(params); in soc_pcm_set_dai_params()
378 dai->sample_bits = snd_pcm_format_physical_width(params_format(params)); in soc_pcm_set_dai_params()
380 dai->rate = 0; in soc_pcm_set_dai_params()
381 dai->channels = 0; in soc_pcm_set_dai_params()
382 dai->sample_bits = 0; in soc_pcm_set_dai_params()
396 if (soc_dai->name && (soc_dai->driver->symmetric_##name || \ in soc_pcm_apply_symmetry()
397 rtd->dai_link->symmetric_##name)) { \ in soc_pcm_apply_symmetry()
398 dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %s to %d\n",\ in soc_pcm_apply_symmetry()
399 #name, soc_dai->name); \ in soc_pcm_apply_symmetry()
401 ret = snd_pcm_hw_constraint_single(substream->runtime, \ in soc_pcm_apply_symmetry()
403 soc_dai->name); \ in soc_pcm_apply_symmetry()
405 dev_err(soc_dai->dev, \ in soc_pcm_apply_symmetry()
432 symmetry = rtd->dai_link->symmetric_##xxx; \ in soc_pcm_params_symmetry()
434 symmetry |= dai->driver->symmetric_##xxx; \ in soc_pcm_params_symmetry()
439 cpu_dai->xxx && cpu_dai->xxx != d.xxx) { \ in soc_pcm_params_symmetry()
440 dev_err(rtd->dev, "ASoC: unmatched %s symmetry: %s:%d - %s:%d\n", \ in soc_pcm_params_symmetry()
441 #xxx, cpu_dai->name, cpu_dai->xxx, d.name, d.xxx); \ in soc_pcm_params_symmetry()
442 return -EINVAL; \ in soc_pcm_params_symmetry()
456 struct snd_soc_dai_link *link = rtd->dai_link; in soc_pcm_update_symmetry()
460 symmetry = link->symmetric_rate || in soc_pcm_update_symmetry()
461 link->symmetric_channels || in soc_pcm_update_symmetry()
462 link->symmetric_sample_bits; in soc_pcm_update_symmetry()
466 dai->driver->symmetric_rate || in soc_pcm_update_symmetry()
467 dai->driver->symmetric_channels || in soc_pcm_update_symmetry()
468 dai->driver->symmetric_sample_bits; in soc_pcm_update_symmetry()
471 substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX; in soc_pcm_update_symmetry()
482 ret = snd_pcm_hw_constraint_msbits(substream->runtime, 0, 0, bits); in soc_pcm_set_msb()
484 dev_warn(rtd->dev, "ASoC: Failed to set MSB %d: %d\n", in soc_pcm_set_msb()
493 int stream = substream->stream; in soc_pcm_apply_msb()
500 if (pcm_codec->sig_bits == 0) { in soc_pcm_apply_msb()
504 bits = max(pcm_codec->sig_bits, bits); in soc_pcm_apply_msb()
510 if (pcm_cpu->sig_bits == 0) { in soc_pcm_apply_msb()
514 cpu_bits = max(pcm_cpu->sig_bits, cpu_bits); in soc_pcm_apply_msb()
523 hw->rates = UINT_MAX; in soc_pcm_hw_init()
524 hw->rate_min = 0; in soc_pcm_hw_init()
525 hw->rate_max = UINT_MAX; in soc_pcm_hw_init()
526 hw->channels_min = 0; in soc_pcm_hw_init()
527 hw->channels_max = UINT_MAX; in soc_pcm_hw_init()
528 hw->formats = ULLONG_MAX; in soc_pcm_hw_init()
534 hw->rates = snd_pcm_rate_mask_intersect(hw->rates, p->rates); in soc_pcm_hw_update_rate()
536 /* setup hw->rate_min/max via hw->rates first */ in soc_pcm_hw_update_rate()
539 /* update hw->rate_min/max by snd_soc_pcm_stream */ in soc_pcm_hw_update_rate()
540 hw->rate_min = max(hw->rate_min, p->rate_min); in soc_pcm_hw_update_rate()
541 hw->rate_max = min_not_zero(hw->rate_max, p->rate_max); in soc_pcm_hw_update_rate()
547 hw->channels_min = max(hw->channels_min, p->channels_min); in soc_pcm_hw_update_chan()
548 hw->channels_max = min(hw->channels_max, p->channels_max); in soc_pcm_hw_update_chan()
554 hw->formats &= p->formats; in soc_pcm_hw_update_format()
558 * snd_soc_runtime_calc_hw() - Calculate hw limits for a PCM stream
582 * Skip CPUs which don't support the current stream type. in snd_soc_runtime_calc_hw()
596 cpu_chan_min = hw->channels_min; in snd_soc_runtime_calc_hw()
597 cpu_chan_max = hw->channels_max; in snd_soc_runtime_calc_hw()
603 * Skip CODECs which don't support the current stream type. in snd_soc_runtime_calc_hw()
619 if (!hw->channels_min) in snd_soc_runtime_calc_hw()
620 return -EINVAL; in snd_soc_runtime_calc_hw()
627 if (rtd->dai_link->num_codecs > 1) { in snd_soc_runtime_calc_hw()
628 hw->channels_min = cpu_chan_min; in snd_soc_runtime_calc_hw()
629 hw->channels_max = cpu_chan_max; in snd_soc_runtime_calc_hw()
638 struct snd_pcm_hardware *hw = &substream->runtime->hw; in soc_pcm_init_runtime_hw()
640 u64 formats = hw->formats; in soc_pcm_init_runtime_hw()
647 snd_soc_runtime_calc_hw(rtd, hw, substream->stream); in soc_pcm_init_runtime_hw()
650 hw->formats &= formats; in soc_pcm_init_runtime_hw()
700 snd_soc_runtime_deactivate(rtd, substream->stream); in soc_pcm_clean()
705 (dai->rate || dai->channels || dai->sample_bits)) in soc_pcm_clean()
720 pinctrl_pm_select_sleep_state(component->dev); in soc_pcm_clean()
736 /* PCM close ops for non-DPCM streams */
750 struct snd_pcm_hardware *hw = &substream->runtime->hw; in soc_hw_sanity_check()
754 struct device *dev = rtd->dev; in soc_hw_sanity_check()
757 if (!hw->rates) in soc_hw_sanity_check()
761 if (!hw->formats) in soc_hw_sanity_check()
765 if (!hw->channels_min || !hw->channels_max || in soc_hw_sanity_check()
766 hw->channels_min > hw->channels_max) in soc_hw_sanity_check()
769 dev_dbg(dev, "ASoC: %s <-> %s info:\n", name_codec, in soc_hw_sanity_check()
771 dev_dbg(dev, "ASoC: rate mask 0x%x\n", hw->rates); in soc_hw_sanity_check()
772 dev_dbg(dev, "ASoC: ch min %d max %d\n", hw->channels_min, in soc_hw_sanity_check()
773 hw->channels_max); in soc_hw_sanity_check()
774 dev_dbg(dev, "ASoC: rate min %d max %d\n", hw->rate_min, in soc_hw_sanity_check()
775 hw->rate_max); in soc_hw_sanity_check()
780 dev_err(dev, "ASoC: %s <-> %s No matching %s\n", in soc_hw_sanity_check()
782 return -EINVAL; in soc_hw_sanity_check()
786 * Called by ALSA when a PCM substream is opened, the runtime->hw record is
800 pinctrl_pm_select_default_state(component->dev); in __soc_pcm_open()
822 if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) in __soc_pcm_open()
843 snd_soc_runtime_activate(rtd, substream->stream); in __soc_pcm_open()
852 /* PCM open ops for non-DPCM streams */
890 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in __soc_pcm_prepare()
891 rtd->pop_wait) { in __soc_pcm_prepare()
892 rtd->pop_wait = 0; in __soc_pcm_prepare()
893 cancel_delayed_work(&rtd->delayed_work); in __soc_pcm_prepare()
896 snd_soc_dapm_stream_event(rtd, substream->stream, in __soc_pcm_prepare()
900 if (dai->driver->ops && !dai->driver->ops->mute_unmute_on_trigger) in __soc_pcm_prepare()
901 snd_soc_dai_digital_mute(dai, 0, substream->stream); in __soc_pcm_prepare()
908 /* PCM prepare ops for non-DPCM streams */
927 interval->min = channels; in soc_pcm_codec_params_fixup()
928 interval->max = channels; in soc_pcm_codec_params_fixup()
944 if (snd_soc_dai_stream_active(dai, substream->stream) == 1) { in soc_pcm_hw_clean()
945 if (dai->driver->ops && !dai->driver->ops->mute_unmute_on_trigger) in soc_pcm_hw_clean()
946 snd_soc_dai_digital_mute(dai, 1, substream->stream); in soc_pcm_hw_clean()
951 snd_soc_dapm_stream_stop(rtd, substream->stream); in soc_pcm_hw_clean()
961 if (snd_soc_dai_stream_valid(dai, substream->stream)) in soc_pcm_hw_clean()
976 /* hw_free PCM ops for non-DPCM streams */
991 * (using snd_pcm_lib_* ). It's non-atomic.
1013 unsigned int tdm_mask = snd_soc_dai_tdm_mask_get(codec_dai, substream->stream); in __soc_pcm_hw_params()
1016 * Skip CODECs which don't support the current stream type, in __soc_pcm_hw_params()
1023 * capture-only CODEC is acting as an LRCLK and/or BCLK master in __soc_pcm_hw_params()
1024 * for the DAI link including a playback-only CODEC. in __soc_pcm_hw_params()
1029 if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) in __soc_pcm_hw_params()
1053 * Skip CPUs which don't support the current stream in __soc_pcm_hw_params()
1056 if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream)) in __soc_pcm_hw_params()
1062 if (!rtd->dai_link->codec_ch_maps) in __soc_pcm_hw_params()
1069 if (rtd->dai_link->codec_ch_maps[j].connected_cpu_id == i) in __soc_pcm_hw_params()
1070 ch_mask |= rtd->dai_link->codec_ch_maps[j].ch_mask; in __soc_pcm_hw_params()
1095 /* hw_params PCM ops for non-DPCM streams */
1134 if (component->driver->trigger_start) in soc_pcm_trigger()
1135 start = component->driver->trigger_start; in soc_pcm_trigger()
1136 if (component->driver->trigger_stop) in soc_pcm_trigger()
1137 stop = component->driver->trigger_stop; in soc_pcm_trigger()
1139 if (rtd->dai_link->trigger_start) in soc_pcm_trigger()
1140 start = rtd->dai_link->trigger_start; in soc_pcm_trigger()
1141 if (rtd->dai_link->trigger_stop) in soc_pcm_trigger()
1142 stop = rtd->dai_link->trigger_stop; in soc_pcm_trigger()
1146 return -EINVAL; in soc_pcm_trigger()
1189 for (i = TRIGGER_MAX; i > 0; i--) { in soc_pcm_trigger()
1190 r = trigger[stop][i - 1](substream, cmd, rollback); in soc_pcm_trigger()
1202 * the runtime->delay will be updated via snd_soc_pcm_component/dai_delay().
1206 struct snd_pcm_runtime *runtime = substream->runtime; in soc_pcm_pointer()
1217 runtime->delay = cpu_delay + codec_delay; in soc_pcm_pointer()
1234 if (dpcm->be == be && dpcm->fe == fe) in dpcm_be_connect()
1241 if (!fe_substream->pcm->nonatomic && be_substream->pcm->nonatomic) { in dpcm_be_connect()
1242 dev_err(be->dev, "%s: FE is atomic but BE is nonatomic, invalid configuration\n", in dpcm_be_connect()
1244 return -EINVAL; in dpcm_be_connect()
1246 if (fe_substream->pcm->nonatomic && !be_substream->pcm->nonatomic) { in dpcm_be_connect()
1247 dev_dbg(be->dev, "FE is nonatomic but BE is not, forcing BE as nonatomic\n"); in dpcm_be_connect()
1248 be_substream->pcm->nonatomic = 1; in dpcm_be_connect()
1253 return -ENOMEM; in dpcm_be_connect()
1255 dpcm->be = be; in dpcm_be_connect()
1256 dpcm->fe = fe; in dpcm_be_connect()
1257 dpcm->state = SND_SOC_DPCM_LINK_STATE_NEW; in dpcm_be_connect()
1259 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); in dpcm_be_connect()
1260 list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); in dpcm_be_connect()
1263 dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", in dpcm_be_connect()
1264 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_connect()
1265 stream ? "<-" : "->", be->dai_link->name); in dpcm_be_connect()
1280 if (!be->dpcm[stream].users) in dpcm_be_reparent()
1288 if (dpcm->fe == fe) in dpcm_be_reparent()
1291 dev_dbg(fe->dev, "reparent %s path %s %s %s\n", in dpcm_be_reparent()
1293 dpcm->fe->dai_link->name, in dpcm_be_reparent()
1294 stream ? "<-" : "->", dpcm->be->dai_link->name); in dpcm_be_reparent()
1296 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream); in dpcm_be_reparent()
1297 be_substream->runtime = fe_substream->runtime; in dpcm_be_reparent()
1312 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n", in dpcm_be_disconnect()
1314 dpcm->be->dai_link->name); in dpcm_be_disconnect()
1316 if (dpcm->state != SND_SOC_DPCM_LINK_STATE_FREE) in dpcm_be_disconnect()
1319 dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n", in dpcm_be_disconnect()
1320 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_disconnect()
1321 stream ? "<-" : "->", dpcm->be->dai_link->name); in dpcm_be_disconnect()
1324 dpcm_be_reparent(fe, dpcm->be, stream); in dpcm_be_disconnect()
1326 list_del(&dpcm->list_be); in dpcm_be_disconnect()
1327 list_move(&dpcm->list_fe, &deleted_dpcms); in dpcm_be_disconnect()
1334 list_del(&dpcm->list_fe); in dpcm_be_disconnect()
1349 dev_dbg(card->dev, "ASoC: find BE for widget %s\n", widget->name); in dpcm_get_be()
1353 if (!be->dai_link->no_pcm) in dpcm_get_be()
1362 dev_dbg(card->dev, "ASoC: try BE : %s\n", in dpcm_get_be()
1363 w ? w->name : "(not set)"); in dpcm_get_be()
1390 struct snd_soc_card *card = widget->dapm->card; in dpcm_end_walk_at_be()
1414 if (fe->dai_link->num_cpus > 1) { in dpcm_path_get()
1415 dev_err(fe->dev, in dpcm_path_get()
1417 return -EINVAL; in dpcm_path_get()
1422 fe->card->component_chaining ? in dpcm_path_get()
1426 dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths, in dpcm_path_get()
1429 dev_dbg(fe->dev, "ASoC: %s no valid %s path\n", fe->dai_link->name, in dpcm_path_get()
1447 for_each_rtd_dais(dpcm->be, i, dai) { in dpcm_be_is_active()
1467 /* Destroy any old FE <--> BE connections */ in dpcm_prune_paths()
1472 dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n", in dpcm_prune_paths()
1474 dpcm->be->dai_link->name, fe->dai_link->name); in dpcm_prune_paths()
1475 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; in dpcm_prune_paths()
1476 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_BE); in dpcm_prune_paths()
1480 dev_dbg(fe->dev, "ASoC: found %d old BE paths for pruning\n", prune); in dpcm_prune_paths()
1487 struct snd_soc_card *card = fe->card; in dpcm_add_paths()
1495 if (!fe_substream->runtime && !fe->fe_compr) in dpcm_add_paths()
1498 /* Create any new FE <--> BE connections */ in dpcm_add_paths()
1501 switch (widget->id) { in dpcm_add_paths()
1517 dev_dbg(fe->dev, "ASoC: no BE found for %s\n", in dpcm_add_paths()
1518 widget->name); in dpcm_add_paths()
1524 * This helps to avoid unnecessary re-configuration of an in dpcm_add_paths()
1527 if (fe->card->component_chaining && in dpcm_add_paths()
1528 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_add_paths()
1529 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_add_paths()
1535 dev_err(fe->dev, "ASoC: can't connect %s\n", in dpcm_add_paths()
1536 widget->name); in dpcm_add_paths()
1546 dev_dbg(fe->dev, "ASoC: found %d new BE paths\n", new); in dpcm_add_paths()
1568 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_clear_pending_state()
1578 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_be_dai_stop()
1589 if (be->dpcm[stream].users == 0) { in dpcm_be_dai_stop()
1590 dev_err(be->dev, "ASoC: no users %s at close - state %d\n", in dpcm_be_dai_stop()
1592 be->dpcm[stream].state); in dpcm_be_dai_stop()
1596 if (--be->dpcm[stream].users != 0) in dpcm_be_dai_stop()
1599 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) { in dpcm_be_dai_stop()
1603 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) { in dpcm_be_dai_stop()
1605 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_stop()
1610 be_substream->runtime = NULL; in dpcm_be_dai_stop()
1611 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_be_dai_stop()
1622 /* only startup BE DAIs that are either sinks or sources to this FE DAI */ in dpcm_be_dai_startup()
1626 be = dpcm->be; in dpcm_be_dai_startup()
1630 dev_err(be->dev, "ASoC: no backend %s stream\n", in dpcm_be_dai_startup()
1640 if (be->dpcm[stream].users == DPCM_MAX_BE_USERS) { in dpcm_be_dai_startup()
1641 dev_err(be->dev, "ASoC: too many users %s at open %d\n", in dpcm_be_dai_startup()
1643 be->dpcm[stream].state); in dpcm_be_dai_startup()
1647 if (be->dpcm[stream].users++ != 0) in dpcm_be_dai_startup()
1650 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_be_dai_startup()
1651 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_be_dai_startup()
1654 dev_dbg(be->dev, "ASoC: open %s BE %s\n", in dpcm_be_dai_startup()
1655 stream ? "capture" : "playback", be->dai_link->name); in dpcm_be_dai_startup()
1657 be_substream->runtime = fe_substream->runtime; in dpcm_be_dai_startup()
1660 be->dpcm[stream].users--; in dpcm_be_dai_startup()
1661 if (be->dpcm[stream].users < 0) in dpcm_be_dai_startup()
1662 dev_err(be->dev, "ASoC: no users %s at unwind %d\n", in dpcm_be_dai_startup()
1664 be->dpcm[stream].state); in dpcm_be_dai_startup()
1666 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_be_dai_startup()
1669 be->dpcm[stream].be_start = 0; in dpcm_be_dai_startup()
1670 be->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_be_dai_startup()
1685 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_fe()
1686 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_fe()
1688 int stream = substream->stream; in dpcm_runtime_setup_fe()
1689 u64 formats = hw->formats; in dpcm_runtime_setup_fe()
1695 hw->formats &= formats; in dpcm_runtime_setup_fe()
1701 * Skip CPUs which don't support the current stream in dpcm_runtime_setup_fe()
1719 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_be_format()
1720 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_be_format()
1723 int stream = substream->stream; in dpcm_runtime_setup_be_format()
1725 if (!fe->dai_link->dpcm_merged_format) in dpcm_runtime_setup_be_format()
1734 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_runtime_setup_be_format()
1740 * Skip CODECs which don't support the current stream in dpcm_runtime_setup_be_format()
1756 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_be_chan()
1757 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_be_chan()
1759 int stream = substream->stream; in dpcm_runtime_setup_be_chan()
1761 if (!fe->dai_link->dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1770 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_runtime_setup_be_chan()
1777 * Skip CPUs which don't support the current stream in dpcm_runtime_setup_be_chan()
1792 if (be->dai_link->num_codecs == 1) { in dpcm_runtime_setup_be_chan()
1804 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_be_rate()
1805 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_be_rate()
1807 int stream = substream->stream; in dpcm_runtime_setup_be_rate()
1809 if (!fe->dai_link->dpcm_merged_rate) in dpcm_runtime_setup_be_rate()
1818 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_runtime_setup_be_rate()
1825 * Skip DAIs which don't support the current stream in dpcm_runtime_setup_be_rate()
1859 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_apply_symmetry()
1870 if (rtd->dai_link->be_hw_params_fixup) in dpcm_apply_symmetry()
1889 int stream = fe_substream->stream, ret = 0; in dpcm_fe_dai_startup()
1897 dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name); in dpcm_fe_dai_startup()
1904 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_fe_dai_startup()
1926 int stream = substream->stream; in dpcm_fe_dai_shutdown()
1935 dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name); in dpcm_fe_dai_shutdown()
1943 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_fe_dai_shutdown()
1952 /* only hw_params backends that are either sinks or sources in dpcm_be_dai_hw_free()
1956 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_be_dai_hw_free()
1964 /* only free hw when no longer used - check all FEs */ in dpcm_be_dai_hw_free()
1969 if (be->dpcm[stream].users > 1) in dpcm_be_dai_hw_free()
1972 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_free()
1973 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_hw_free()
1974 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_free()
1975 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED) && in dpcm_be_dai_hw_free()
1976 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_hw_free()
1977 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_hw_free()
1980 dev_dbg(be->dev, "ASoC: hw_free BE %s\n", in dpcm_be_dai_hw_free()
1981 be->dai_link->name); in dpcm_be_dai_hw_free()
1985 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_hw_free()
1992 int stream = substream->stream; in dpcm_fe_dai_hw_free()
1997 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name); in dpcm_fe_dai_hw_free()
2002 /* only hw_params backends that are either sinks or sources in dpcm_fe_dai_hw_free()
2006 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_fe_dai_hw_free()
2023 be = dpcm->be; in dpcm_be_dai_hw_params()
2031 memcpy(&hw_params, &fe->dpcm[stream].hw_params, in dpcm_be_dai_hw_params()
2039 /* copy the fixed-up hw params for BE dai */ in dpcm_be_dai_hw_params()
2040 memcpy(&be->dpcm[stream].hw_params, &hw_params, in dpcm_be_dai_hw_params()
2047 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2048 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2049 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE)) in dpcm_be_dai_hw_params()
2052 dev_dbg(be->dev, "ASoC: hw_params BE %s\n", in dpcm_be_dai_hw_params()
2053 be->dai_link->name); in dpcm_be_dai_hw_params()
2059 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_be_dai_hw_params()
2064 dev_dbg(fe->dev, "ASoC: %s() failed at %s (%d)\n", in dpcm_be_dai_hw_params()
2065 __func__, be->dai_link->name, ret); in dpcm_be_dai_hw_params()
2069 be = dpcm->be; in dpcm_be_dai_hw_params()
2079 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2080 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2081 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_params()
2082 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP)) in dpcm_be_dai_hw_params()
2095 int ret, stream = substream->stream; in dpcm_fe_dai_hw_params()
2100 memcpy(&fe->dpcm[stream].hw_params, params, in dpcm_fe_dai_hw_params()
2106 dev_dbg(fe->dev, "ASoC: hw_params FE %s rate %d chan %x fmt %d\n", in dpcm_fe_dai_hw_params()
2107 fe->dai_link->name, params_rate(params), in dpcm_fe_dai_hw_params()
2115 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_fe_dai_hw_params()
2136 be = dpcm->be; in dpcm_be_dai_trigger()
2145 dev_dbg(be->dev, "ASoC: trigger BE %s cmd %d\n", in dpcm_be_dai_trigger()
2146 be->dai_link->name, cmd); in dpcm_be_dai_trigger()
2150 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2151 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_trigger()
2152 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_trigger()
2153 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2156 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2157 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2160 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_PAUSED) in dpcm_be_dai_trigger()
2167 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2171 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2174 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_trigger()
2177 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2178 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2183 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2187 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2190 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2191 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2192 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2195 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2196 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2198 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2199 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2204 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2208 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2211 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2212 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2215 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2216 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2218 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2222 if (fe->dpcm[stream].fe_pause) { in dpcm_be_dai_trigger()
2224 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2225 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2228 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2234 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2235 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2237 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2238 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2243 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2244 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2246 be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_be_dai_trigger()
2250 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2253 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2254 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2259 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2263 be->dpcm[stream].state = SND_SOC_DPCM_STATE_SUSPEND; in dpcm_be_dai_trigger()
2266 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2269 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2270 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2272 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2273 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2278 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2282 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2302 dev_dbg(fe->dev, "ASoC: pre trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2303 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2309 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2314 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2318 dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2319 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2329 int stream = substream->stream; in dpcm_fe_dai_do_trigger()
2331 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_fe_dai_do_trigger()
2333 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in dpcm_fe_dai_do_trigger()
2350 ret = -EINVAL; in dpcm_fe_dai_do_trigger()
2368 ret = -EINVAL; in dpcm_fe_dai_do_trigger()
2373 /* bespoke trigger() - handles both FE and BEs */ in dpcm_fe_dai_do_trigger()
2375 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd %d\n", in dpcm_fe_dai_do_trigger()
2376 fe->dai_link->name, cmd); in dpcm_fe_dai_do_trigger()
2381 dev_err(fe->dev, "ASoC: invalid trigger cmd %d for %s\n", cmd, in dpcm_fe_dai_do_trigger()
2382 fe->dai_link->name); in dpcm_fe_dai_do_trigger()
2383 ret = -EINVAL; in dpcm_fe_dai_do_trigger()
2388 dev_err(fe->dev, "ASoC: trigger FE cmd: %d failed: %d\n", in dpcm_fe_dai_do_trigger()
2397 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_fe_dai_do_trigger()
2401 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_fe_dai_do_trigger()
2404 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_fe_dai_do_trigger()
2409 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in dpcm_fe_dai_do_trigger()
2416 int stream = substream->stream; in dpcm_fe_dai_trigger()
2421 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) { in dpcm_fe_dai_trigger()
2422 fe->dpcm[stream].trigger_pending = cmd + 1; in dpcm_fe_dai_trigger()
2437 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_be_dai_prepare()
2448 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_prepare()
2449 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_prepare()
2450 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND) && in dpcm_be_dai_prepare()
2451 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_prepare()
2454 dev_dbg(be->dev, "ASoC: prepare BE %s\n", in dpcm_be_dai_prepare()
2455 be->dai_link->name); in dpcm_be_dai_prepare()
2461 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_be_dai_prepare()
2470 int stream = substream->stream, ret = 0; in dpcm_fe_dai_prepare()
2474 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name); in dpcm_fe_dai_prepare()
2479 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_fe_dai_prepare()
2481 …dev_err_once(fe->dev, "ASoC: no backend DAIs enabled for %s, possibly missing ALSA mixer-based rou… in dpcm_fe_dai_prepare()
2482 fe->dai_link->name); in dpcm_fe_dai_prepare()
2483 dev_dbg(fe->dev, "ASoC: no backend DAIs enabled for %s\n", in dpcm_fe_dai_prepare()
2484 fe->dai_link->name); in dpcm_fe_dai_prepare()
2485 ret = -EINVAL; in dpcm_fe_dai_prepare()
2498 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_fe_dai_prepare()
2511 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_shutdown()
2514 dev_dbg(fe->dev, "ASoC: runtime %s close on FE %s\n", in dpcm_run_update_shutdown()
2515 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_shutdown()
2518 /* call bespoke trigger - FE takes care of all BE triggers */ in dpcm_run_update_shutdown()
2519 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd stop\n", in dpcm_run_update_shutdown()
2520 fe->dai_link->name); in dpcm_run_update_shutdown()
2524 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd stop\n", in dpcm_run_update_shutdown()
2525 fe->dai_link->name); in dpcm_run_update_shutdown()
2545 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_startup()
2548 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n", in dpcm_run_update_startup()
2549 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_startup()
2552 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_FREE || in dpcm_run_update_startup()
2553 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) { in dpcm_run_update_startup()
2554 dev_err(fe->dev, "ASoC: FE %s is not ready %d\n", in dpcm_run_update_startup()
2555 fe->dai_link->name, fe->dpcm[stream].state); in dpcm_run_update_startup()
2556 ret = -EINVAL; in dpcm_run_update_startup()
2566 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_OPEN) in dpcm_run_update_startup()
2574 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_PARAMS) in dpcm_run_update_startup()
2585 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_PREPARE || in dpcm_run_update_startup()
2586 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_STOP) in dpcm_run_update_startup()
2590 /* call trigger on the frontend - FE takes care of all BE triggers */ in dpcm_run_update_startup()
2591 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd start\n", in dpcm_run_update_startup()
2592 fe->dai_link->name); in dpcm_run_update_startup()
2598 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd start\n", in dpcm_run_update_startup()
2599 fe->dai_link->name); in dpcm_run_update_startup()
2616 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_run_update_startup()
2622 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE || in dpcm_run_update_startup()
2623 be->dpcm[stream].state == SND_SOC_DPCM_STATE_NEW) in dpcm_run_update_startup()
2624 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; in dpcm_run_update_startup()
2636 if (!fe->dai_link->dynamic) in soc_dpcm_fe_runtime_update()
2639 if (fe->dai_link->num_cpus > 1) { in soc_dpcm_fe_runtime_update()
2640 dev_err(fe->dev, in soc_dpcm_fe_runtime_update()
2642 return -EINVAL; in soc_dpcm_fe_runtime_update()
2650 dev_dbg(fe->dev, "ASoC: DPCM %s runtime update for FE %s\n", in soc_dpcm_fe_runtime_update()
2651 new ? "new" : "old", fe->dai_link->name); in soc_dpcm_fe_runtime_update()
2722 int stream = fe_substream->stream; in dpcm_fe_dai_cleanup()
2728 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; in dpcm_fe_dai_cleanup()
2752 int stream = fe_substream->stream; in dpcm_fe_dai_open()
2760 /* calculate valid and active FE <-> BE dpcms */ in dpcm_fe_dai_open()
2777 struct snd_soc_dai_link *dai_link = rtd->dai_link; in soc_get_playback_capture()
2783 if (dai_link->dynamic && dai_link->num_cpus > 1) { in soc_get_playback_capture()
2784 dev_err(rtd->dev, "DPCM doesn't support Multi CPU for Front-Ends yet\n"); in soc_get_playback_capture()
2785 return -EINVAL; in soc_get_playback_capture()
2788 if (dai_link->dynamic || dai_link->no_pcm) { in soc_get_playback_capture()
2791 if (dai_link->dpcm_playback) { in soc_get_playback_capture()
2801 dev_err(rtd->card->dev, in soc_get_playback_capture()
2803 dai_link->stream_name); in soc_get_playback_capture()
2804 return -EINVAL; in soc_get_playback_capture()
2807 if (dai_link->dpcm_capture) { in soc_get_playback_capture()
2818 dev_err(rtd->card->dev, in soc_get_playback_capture()
2820 dai_link->stream_name); in soc_get_playback_capture()
2821 return -EINVAL; in soc_get_playback_capture()
2832 if (dai_link->num_cpus == 1) { in soc_get_playback_capture()
2834 } else if (dai_link->num_cpus == dai_link->num_codecs) { in soc_get_playback_capture()
2836 } else if (rtd->dai_link->num_codecs > rtd->dai_link->num_cpus) { in soc_get_playback_capture()
2839 if (!rtd->dai_link->codec_ch_maps) { in soc_get_playback_capture()
2840 dev_err(rtd->card->dev, "%s: no codec channel mapping table provided\n", in soc_get_playback_capture()
2842 return -EINVAL; in soc_get_playback_capture()
2845 cpu_id = rtd->dai_link->codec_ch_maps[i].connected_cpu_id; in soc_get_playback_capture()
2848 dev_err(rtd->card->dev, in soc_get_playback_capture()
2850 __func__, rtd->dai_link->num_codecs, in soc_get_playback_capture()
2851 rtd->dai_link->num_cpus); in soc_get_playback_capture()
2852 return -EINVAL; in soc_get_playback_capture()
2864 if (dai_link->playback_only) in soc_get_playback_capture()
2867 if (dai_link->capture_only) in soc_get_playback_capture()
2871 dev_err(rtd->dev, "substream %s has no playback, no capture\n", in soc_get_playback_capture()
2872 dai_link->stream_name); in soc_get_playback_capture()
2874 return -EINVAL; in soc_get_playback_capture()
2885 int playback, int capture, int num) in soc_create_pcm() argument
2891 if (rtd->dai_link->c2c_params) { in soc_create_pcm()
2893 rtd->dai_link->stream_name); in soc_create_pcm()
2895 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, in soc_create_pcm()
2897 } else if (rtd->dai_link->no_pcm) { in soc_create_pcm()
2899 rtd->dai_link->stream_name); in soc_create_pcm()
2901 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, in soc_create_pcm()
2904 if (rtd->dai_link->dynamic) in soc_create_pcm()
2906 rtd->dai_link->stream_name); in soc_create_pcm()
2908 snprintf(new_name, sizeof(new_name), "%s %s-%d", in soc_create_pcm()
2909 rtd->dai_link->stream_name, in soc_create_pcm()
2910 soc_codec_dai_name(rtd), num); in soc_create_pcm()
2912 ret = snd_pcm_new(rtd->card->snd_card, new_name, num, playback, in soc_create_pcm()
2916 dev_err(rtd->card->dev, "ASoC: can't create pcm %s for dailink %s: %d\n", in soc_create_pcm()
2917 new_name, rtd->dai_link->name, ret); in soc_create_pcm()
2920 dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n",num, new_name); in soc_create_pcm()
2926 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) in soc_new_pcm() argument
2937 ret = soc_create_pcm(&pcm, rtd, playback, capture, num); in soc_new_pcm()
2948 if (!rtd->dai_link->c2c_params) in soc_new_pcm()
2949 rtd->close_delayed_work_func = snd_soc_close_delayed_work; in soc_new_pcm()
2951 rtd->pcm = pcm; in soc_new_pcm()
2952 pcm->nonatomic = rtd->dai_link->nonatomic; in soc_new_pcm()
2953 pcm->private_data = rtd; in soc_new_pcm()
2954 pcm->no_device_suspend = true; in soc_new_pcm()
2956 if (rtd->dai_link->no_pcm || rtd->dai_link->c2c_params) { in soc_new_pcm()
2958 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd; in soc_new_pcm()
2960 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd; in soc_new_pcm()
2965 if (rtd->dai_link->dynamic) { in soc_new_pcm()
2966 rtd->ops.open = dpcm_fe_dai_open; in soc_new_pcm()
2967 rtd->ops.hw_params = dpcm_fe_dai_hw_params; in soc_new_pcm()
2968 rtd->ops.prepare = dpcm_fe_dai_prepare; in soc_new_pcm()
2969 rtd->ops.trigger = dpcm_fe_dai_trigger; in soc_new_pcm()
2970 rtd->ops.hw_free = dpcm_fe_dai_hw_free; in soc_new_pcm()
2971 rtd->ops.close = dpcm_fe_dai_close; in soc_new_pcm()
2972 rtd->ops.pointer = soc_pcm_pointer; in soc_new_pcm()
2974 rtd->ops.open = soc_pcm_open; in soc_new_pcm()
2975 rtd->ops.hw_params = soc_pcm_hw_params; in soc_new_pcm()
2976 rtd->ops.prepare = soc_pcm_prepare; in soc_new_pcm()
2977 rtd->ops.trigger = soc_pcm_trigger; in soc_new_pcm()
2978 rtd->ops.hw_free = soc_pcm_hw_free; in soc_new_pcm()
2979 rtd->ops.close = soc_pcm_close; in soc_new_pcm()
2980 rtd->ops.pointer = soc_pcm_pointer; in soc_new_pcm()
2984 const struct snd_soc_component_driver *drv = component->driver; in soc_new_pcm()
2986 if (drv->ioctl) in soc_new_pcm()
2987 rtd->ops.ioctl = snd_soc_pcm_component_ioctl; in soc_new_pcm()
2988 if (drv->sync_stop) in soc_new_pcm()
2989 rtd->ops.sync_stop = snd_soc_pcm_component_sync_stop; in soc_new_pcm()
2990 if (drv->copy) in soc_new_pcm()
2991 rtd->ops.copy = snd_soc_pcm_component_copy; in soc_new_pcm()
2992 if (drv->page) in soc_new_pcm()
2993 rtd->ops.page = snd_soc_pcm_component_page; in soc_new_pcm()
2994 if (drv->mmap) in soc_new_pcm()
2995 rtd->ops.mmap = snd_soc_pcm_component_mmap; in soc_new_pcm()
2996 if (drv->ack) in soc_new_pcm()
2997 rtd->ops.ack = snd_soc_pcm_component_ack; in soc_new_pcm()
3001 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &rtd->ops); in soc_new_pcm()
3004 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops); in soc_new_pcm()
3010 dev_dbg(rtd->card->dev, "%s <-> %s mapping ok\n", in soc_new_pcm()
3015 /* is the current PCM operation for this FE ? */
3018 if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) in snd_soc_dpcm_fe_can_update()
3024 /* is the current PCM operation for this BE ? */
3028 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || in snd_soc_dpcm_be_can_update()
3029 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && in snd_soc_dpcm_be_can_update()
3030 be->dpcm[stream].runtime_update)) in snd_soc_dpcm_be_can_update()
3040 return be->pcm->streams[stream].substream; in snd_soc_dpcm_get_substream()
3057 if (dpcm->fe == fe) in snd_soc_dpcm_check_state()
3060 state = dpcm->fe->dpcm[stream].state; in snd_soc_dpcm_check_state()