• Home
  • Raw
  • Download

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()
43 dev_err(rtd->dev, in _soc_pcm_ret()
45 func, rtd->dai_link->name, ret); in _soc_pcm_ret()
73 return (rtd)->dai_link->num_cpus == 1 ? asoc_rtd_to_cpu(rtd, 0)->name : "multicpu"; in soc_cpu_dai_name()
77 return (rtd)->dai_link->num_codecs == 1 ? asoc_rtd_to_codec(rtd, 0)->name : "multicodec"; in soc_codec_dai_name()
112 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; in dpcm_show_state()
117 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
118 "[%s - %s]\n", fe->dai_link->name, in dpcm_show_state()
121 offset += scnprintf(buf + offset, size - offset, "State: %s\n", in dpcm_show_state()
122 dpcm_state_string(fe->dpcm[stream].state)); in dpcm_show_state()
124 if ((fe->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
125 (fe->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
126 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
134 offset += scnprintf(buf + offset, size - offset, "Backends:\n"); in dpcm_show_state()
136 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_show_state()
137 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
143 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_show_state()
144 params = &be->dpcm[stream].hw_params; in dpcm_show_state()
146 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
147 "- %s\n", be->dai_link->name); in dpcm_show_state()
149 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
151 dpcm_state_string(be->dpcm[stream].state)); in dpcm_show_state()
153 if ((be->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
154 (be->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
155 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
169 struct snd_soc_pcm_runtime *fe = file->private_data; in dpcm_state_read_file()
174 if (fe->dai_link->num_cpus > 1) { in dpcm_state_read_file()
175 dev_err(fe->dev, in dpcm_state_read_file()
177 return -EINVAL; in dpcm_state_read_file()
182 return -ENOMEM; in dpcm_state_read_file()
189 out_count - offset); in dpcm_state_read_file()
206 if (!rtd->dai_link->dynamic) in soc_dpcm_debugfs_add()
209 if (!rtd->card->debugfs_card_root) in soc_dpcm_debugfs_add()
212 rtd->debugfs_dpcm_root = debugfs_create_dir(rtd->dai_link->name, in soc_dpcm_debugfs_add()
213 rtd->card->debugfs_card_root); in soc_dpcm_debugfs_add()
215 debugfs_create_file("state", 0444, rtd->debugfs_dpcm_root, in soc_dpcm_debugfs_add()
223 name = kasprintf(GFP_KERNEL, "%s:%s", dpcm->be->dai_link->name, in dpcm_create_debugfs_state()
226 dpcm->debugfs_state = debugfs_create_dir( in dpcm_create_debugfs_state()
227 name, dpcm->fe->debugfs_dpcm_root); in dpcm_create_debugfs_state()
228 debugfs_create_u32("state", 0644, dpcm->debugfs_state, in dpcm_create_debugfs_state()
229 &dpcm->state); in dpcm_create_debugfs_state()
236 debugfs_remove_recursive(dpcm->debugfs_state); in dpcm_remove_debugfs_state()
263 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) { in dpcm_set_fe_update_state()
265 fe->dpcm[stream].trigger_pending - 1); in dpcm_set_fe_update_state()
266 fe->dpcm[stream].trigger_pending = 0; in dpcm_set_fe_update_state()
268 fe->dpcm[stream].runtime_update = state; in dpcm_set_fe_update_state()
275 be->dpcm[stream].runtime_update = state; in dpcm_set_be_update_state()
279 * snd_soc_runtime_action() - Increment/Decrement active count for
283 * @action: Activate stream if 1. Deactivate if -1.
289 * Must be called with the rtd->card->pcm_mutex being held
305 * snd_soc_runtime_ignore_pmdown_time() - Check whether to ignore the power down delay
319 if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time) in snd_soc_runtime_ignore_pmdown_time()
323 ignore &= !component->driver->use_pmdown_time; in snd_soc_runtime_ignore_pmdown_time()
329 * snd_soc_set_runtime_hwparams - set the runtime hardware parameters
338 substream->runtime->hw = *hw; in snd_soc_set_runtime_hwparams()
354 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_dapm_stream_event()
356 dev_dbg(be->dev, "ASoC: BE %s event %d dir %d\n", in dpcm_dapm_stream_event()
357 be->dai_link->name, event, dir); in dpcm_dapm_stream_event()
360 (be->dpcm[dir].users >= 1)) in dpcm_dapm_stream_event()
375 dai->rate = params_rate(params); in soc_pcm_set_dai_params()
376 dai->channels = params_channels(params); in soc_pcm_set_dai_params()
377 dai->sample_bits = snd_pcm_format_physical_width(params_format(params)); in soc_pcm_set_dai_params()
379 dai->rate = 0; in soc_pcm_set_dai_params()
380 dai->channels = 0; in soc_pcm_set_dai_params()
381 dai->sample_bits = 0; in soc_pcm_set_dai_params()
395 if (soc_dai->name && (soc_dai->driver->symmetric_##name || \ in soc_pcm_apply_symmetry()
396 rtd->dai_link->symmetric_##name)) { \ in soc_pcm_apply_symmetry()
397 dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %s to %d\n",\ in soc_pcm_apply_symmetry()
398 #name, soc_dai->name); \ in soc_pcm_apply_symmetry()
400 ret = snd_pcm_hw_constraint_single(substream->runtime, \ in soc_pcm_apply_symmetry()
402 soc_dai->name); \ in soc_pcm_apply_symmetry()
404 dev_err(soc_dai->dev, \ in soc_pcm_apply_symmetry()
431 symmetry = rtd->dai_link->symmetric_##xxx; \ in soc_pcm_params_symmetry()
433 symmetry |= dai->driver->symmetric_##xxx; \ in soc_pcm_params_symmetry()
438 cpu_dai->xxx && cpu_dai->xxx != d.xxx) { \ in soc_pcm_params_symmetry()
439 dev_err(rtd->dev, "ASoC: unmatched %s symmetry: %s:%d - %s:%d\n", \ in soc_pcm_params_symmetry()
440 #xxx, cpu_dai->name, cpu_dai->xxx, d.name, d.xxx); \ in soc_pcm_params_symmetry()
441 return -EINVAL; \ in soc_pcm_params_symmetry()
455 struct snd_soc_dai_link *link = rtd->dai_link; in soc_pcm_update_symmetry()
459 symmetry = link->symmetric_rate || in soc_pcm_update_symmetry()
460 link->symmetric_channels || in soc_pcm_update_symmetry()
461 link->symmetric_sample_bits; in soc_pcm_update_symmetry()
465 dai->driver->symmetric_rate || in soc_pcm_update_symmetry()
466 dai->driver->symmetric_channels || in soc_pcm_update_symmetry()
467 dai->driver->symmetric_sample_bits; in soc_pcm_update_symmetry()
470 substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX; in soc_pcm_update_symmetry()
481 ret = snd_pcm_hw_constraint_msbits(substream->runtime, 0, 0, bits); in soc_pcm_set_msb()
483 dev_warn(rtd->dev, "ASoC: Failed to set MSB %d: %d\n", in soc_pcm_set_msb()
492 int stream = substream->stream; in soc_pcm_apply_msb()
499 if (pcm_codec->sig_bits == 0) { in soc_pcm_apply_msb()
503 bits = max(pcm_codec->sig_bits, bits); in soc_pcm_apply_msb()
509 if (pcm_cpu->sig_bits == 0) { in soc_pcm_apply_msb()
513 cpu_bits = max(pcm_cpu->sig_bits, cpu_bits); in soc_pcm_apply_msb()
522 hw->rates = UINT_MAX; in soc_pcm_hw_init()
523 hw->rate_min = 0; in soc_pcm_hw_init()
524 hw->rate_max = UINT_MAX; in soc_pcm_hw_init()
525 hw->channels_min = 0; in soc_pcm_hw_init()
526 hw->channels_max = UINT_MAX; in soc_pcm_hw_init()
527 hw->formats = ULLONG_MAX; in soc_pcm_hw_init()
533 hw->rates = snd_pcm_rate_mask_intersect(hw->rates, p->rates); in soc_pcm_hw_update_rate()
535 /* setup hw->rate_min/max via hw->rates first */ in soc_pcm_hw_update_rate()
538 /* update hw->rate_min/max by snd_soc_pcm_stream */ in soc_pcm_hw_update_rate()
539 hw->rate_min = max(hw->rate_min, p->rate_min); in soc_pcm_hw_update_rate()
540 hw->rate_max = min_not_zero(hw->rate_max, p->rate_max); in soc_pcm_hw_update_rate()
546 hw->channels_min = max(hw->channels_min, p->channels_min); in soc_pcm_hw_update_chan()
547 hw->channels_max = min(hw->channels_max, p->channels_max); in soc_pcm_hw_update_chan()
553 hw->formats &= p->formats; in soc_pcm_hw_update_format()
557 * snd_soc_runtime_calc_hw() - Calculate hw limits for a PCM stream
581 * Skip CPUs which don't support the current stream type. in snd_soc_runtime_calc_hw()
595 cpu_chan_min = hw->channels_min; in snd_soc_runtime_calc_hw()
596 cpu_chan_max = hw->channels_max; in snd_soc_runtime_calc_hw()
602 * Skip CODECs which don't support the current stream type. in snd_soc_runtime_calc_hw()
618 if (!hw->channels_min) in snd_soc_runtime_calc_hw()
619 return -EINVAL; in snd_soc_runtime_calc_hw()
626 if (rtd->dai_link->num_codecs > 1) { in snd_soc_runtime_calc_hw()
627 hw->channels_min = cpu_chan_min; in snd_soc_runtime_calc_hw()
628 hw->channels_max = cpu_chan_max; in snd_soc_runtime_calc_hw()
637 struct snd_pcm_hardware *hw = &substream->runtime->hw; in soc_pcm_init_runtime_hw()
639 u64 formats = hw->formats; in soc_pcm_init_runtime_hw()
646 snd_soc_runtime_calc_hw(rtd, hw, substream->stream); in soc_pcm_init_runtime_hw()
649 hw->formats &= formats; in soc_pcm_init_runtime_hw()
699 snd_soc_runtime_deactivate(rtd, substream->stream); in soc_pcm_clean()
704 (dai->rate || dai->channels || dai->sample_bits)) in soc_pcm_clean()
719 pinctrl_pm_select_sleep_state(component->dev); in soc_pcm_clean()
735 /* PCM close ops for non-DPCM streams */
749 struct snd_pcm_hardware *hw = &substream->runtime->hw; in soc_hw_sanity_check()
753 struct device *dev = rtd->dev; in soc_hw_sanity_check()
756 if (!hw->rates) in soc_hw_sanity_check()
760 if (!hw->formats) in soc_hw_sanity_check()
764 if (!hw->channels_min || !hw->channels_max || in soc_hw_sanity_check()
765 hw->channels_min > hw->channels_max) in soc_hw_sanity_check()
768 dev_dbg(dev, "ASoC: %s <-> %s info:\n", name_codec, in soc_hw_sanity_check()
770 dev_dbg(dev, "ASoC: rate mask 0x%x\n", hw->rates); in soc_hw_sanity_check()
771 dev_dbg(dev, "ASoC: ch min %d max %d\n", hw->channels_min, in soc_hw_sanity_check()
772 hw->channels_max); in soc_hw_sanity_check()
773 dev_dbg(dev, "ASoC: rate min %d max %d\n", hw->rate_min, in soc_hw_sanity_check()
774 hw->rate_max); in soc_hw_sanity_check()
779 dev_err(dev, "ASoC: %s <-> %s No matching %s\n", in soc_hw_sanity_check()
781 return -EINVAL; in soc_hw_sanity_check()
785 * Called by ALSA when a PCM substream is opened, the runtime->hw record is
799 pinctrl_pm_select_default_state(component->dev); in __soc_pcm_open()
821 if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) in __soc_pcm_open()
842 snd_soc_runtime_activate(rtd, substream->stream); in __soc_pcm_open()
851 /* PCM open ops for non-DPCM streams */
889 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in __soc_pcm_prepare()
890 rtd->pop_wait) { in __soc_pcm_prepare()
891 rtd->pop_wait = 0; in __soc_pcm_prepare()
892 cancel_delayed_work(&rtd->delayed_work); in __soc_pcm_prepare()
895 snd_soc_dapm_stream_event(rtd, substream->stream, in __soc_pcm_prepare()
899 if (dai->driver->ops && !dai->driver->ops->mute_unmute_on_trigger) in __soc_pcm_prepare()
900 snd_soc_dai_digital_mute(dai, 0, substream->stream); in __soc_pcm_prepare()
908 * denial-of-service attack on the syslog / diskspace. in __soc_pcm_prepare()
913 /* PCM prepare ops for non-DPCM streams */
927 * denial-of-service attack on the syslog / diskspace. in soc_pcm_prepare()
939 interval->min = channels; in soc_pcm_codec_params_fixup()
940 interval->max = channels; in soc_pcm_codec_params_fixup()
956 if (snd_soc_dai_stream_active(dai, substream->stream) == 1) { in soc_pcm_hw_clean()
957 if (dai->driver->ops && !dai->driver->ops->mute_unmute_on_trigger) in soc_pcm_hw_clean()
958 snd_soc_dai_digital_mute(dai, 1, substream->stream); in soc_pcm_hw_clean()
963 snd_soc_dapm_stream_stop(rtd, substream->stream); in soc_pcm_hw_clean()
973 if (snd_soc_dai_stream_valid(dai, substream->stream)) in soc_pcm_hw_clean()
988 /* hw_free PCM ops for non-DPCM streams */
1003 * (using snd_pcm_lib_* ). It's non-atomic.
1025 unsigned int tdm_mask = snd_soc_dai_tdm_mask_get(codec_dai, substream->stream); in __soc_pcm_hw_params()
1028 * Skip CODECs which don't support the current stream type, in __soc_pcm_hw_params()
1035 * capture-only CODEC is acting as an LRCLK and/or BCLK master in __soc_pcm_hw_params()
1036 * for the DAI link including a playback-only CODEC. in __soc_pcm_hw_params()
1041 if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) in __soc_pcm_hw_params()
1065 * Skip CPUs which don't support the current stream in __soc_pcm_hw_params()
1068 if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream)) in __soc_pcm_hw_params()
1074 if (!rtd->dai_link->codec_ch_maps) in __soc_pcm_hw_params()
1081 if (rtd->dai_link->codec_ch_maps[j].connected_cpu_id == i) in __soc_pcm_hw_params()
1082 ch_mask |= rtd->dai_link->codec_ch_maps[j].ch_mask; in __soc_pcm_hw_params()
1107 /* hw_params PCM ops for non-DPCM streams */
1146 if (component->driver->trigger_start) in soc_pcm_trigger()
1147 start = component->driver->trigger_start; in soc_pcm_trigger()
1148 if (component->driver->trigger_stop) in soc_pcm_trigger()
1149 stop = component->driver->trigger_stop; in soc_pcm_trigger()
1151 if (rtd->dai_link->trigger_start) in soc_pcm_trigger()
1152 start = rtd->dai_link->trigger_start; in soc_pcm_trigger()
1153 if (rtd->dai_link->trigger_stop) in soc_pcm_trigger()
1154 stop = rtd->dai_link->trigger_stop; in soc_pcm_trigger()
1158 return -EINVAL; in soc_pcm_trigger()
1201 for (i = TRIGGER_MAX; i > 0; i--) { in soc_pcm_trigger()
1202 r = trigger[stop][i - 1](substream, cmd, rollback); in soc_pcm_trigger()
1214 * the runtime->delay will be updated via snd_soc_pcm_component/dai_delay().
1218 struct snd_pcm_runtime *runtime = substream->runtime; in soc_pcm_pointer()
1229 runtime->delay = cpu_delay + codec_delay; in soc_pcm_pointer()
1246 if (dpcm->be == be && dpcm->fe == fe) in dpcm_be_connect()
1253 if (!fe_substream->pcm->nonatomic && be_substream->pcm->nonatomic) { in dpcm_be_connect()
1254 dev_err(be->dev, "%s: FE is atomic but BE is nonatomic, invalid configuration\n", in dpcm_be_connect()
1256 return -EINVAL; in dpcm_be_connect()
1258 if (fe_substream->pcm->nonatomic && !be_substream->pcm->nonatomic) { in dpcm_be_connect()
1259 dev_dbg(be->dev, "FE is nonatomic but BE is not, forcing BE as nonatomic\n"); in dpcm_be_connect()
1260 be_substream->pcm->nonatomic = 1; in dpcm_be_connect()
1265 return -ENOMEM; in dpcm_be_connect()
1267 dpcm->be = be; in dpcm_be_connect()
1268 dpcm->fe = fe; in dpcm_be_connect()
1269 dpcm->state = SND_SOC_DPCM_LINK_STATE_NEW; in dpcm_be_connect()
1271 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); in dpcm_be_connect()
1272 list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); in dpcm_be_connect()
1275 dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", in dpcm_be_connect()
1276 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_connect()
1277 stream ? "<-" : "->", be->dai_link->name); in dpcm_be_connect()
1292 if (!be->dpcm[stream].users) in dpcm_be_reparent()
1300 if (dpcm->fe == fe) in dpcm_be_reparent()
1303 dev_dbg(fe->dev, "reparent %s path %s %s %s\n", in dpcm_be_reparent()
1305 dpcm->fe->dai_link->name, in dpcm_be_reparent()
1306 stream ? "<-" : "->", dpcm->be->dai_link->name); in dpcm_be_reparent()
1308 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream); in dpcm_be_reparent()
1309 be_substream->runtime = fe_substream->runtime; in dpcm_be_reparent()
1324 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n", in dpcm_be_disconnect()
1326 dpcm->be->dai_link->name); in dpcm_be_disconnect()
1328 if (dpcm->state != SND_SOC_DPCM_LINK_STATE_FREE) in dpcm_be_disconnect()
1331 dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n", in dpcm_be_disconnect()
1332 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_disconnect()
1333 stream ? "<-" : "->", dpcm->be->dai_link->name); in dpcm_be_disconnect()
1336 dpcm_be_reparent(fe, dpcm->be, stream); in dpcm_be_disconnect()
1338 list_del(&dpcm->list_be); in dpcm_be_disconnect()
1339 list_move(&dpcm->list_fe, &deleted_dpcms); in dpcm_be_disconnect()
1346 list_del(&dpcm->list_fe); in dpcm_be_disconnect()
1361 dev_dbg(card->dev, "ASoC: find BE for widget %s\n", widget->name); in dpcm_get_be()
1365 if (!be->dai_link->no_pcm) in dpcm_get_be()
1374 dev_dbg(card->dev, "ASoC: try BE : %s\n", in dpcm_get_be()
1375 w ? w->name : "(not set)"); in dpcm_get_be()
1402 struct snd_soc_card *card = widget->dapm->card; in dpcm_end_walk_at_be()
1426 if (fe->dai_link->num_cpus > 1) { in dpcm_path_get()
1427 dev_err(fe->dev, in dpcm_path_get()
1429 return -EINVAL; in dpcm_path_get()
1434 fe->card->component_chaining ? in dpcm_path_get()
1438 dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths, in dpcm_path_get()
1441 dev_dbg(fe->dev, "ASoC: %s no valid %s path\n", fe->dai_link->name, in dpcm_path_get()
1459 for_each_rtd_dais(dpcm->be, i, dai) { in dpcm_be_is_active()
1479 /* Destroy any old FE <--> BE connections */ in dpcm_prune_paths()
1484 dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n", in dpcm_prune_paths()
1486 dpcm->be->dai_link->name, fe->dai_link->name); in dpcm_prune_paths()
1487 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; in dpcm_prune_paths()
1488 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_BE); in dpcm_prune_paths()
1492 dev_dbg(fe->dev, "ASoC: found %d old BE paths for pruning\n", prune); in dpcm_prune_paths()
1499 struct snd_soc_card *card = fe->card; in dpcm_add_paths()
1507 if (!fe_substream->runtime && !fe->fe_compr) in dpcm_add_paths()
1510 /* Create any new FE <--> BE connections */ in dpcm_add_paths()
1513 switch (widget->id) { in dpcm_add_paths()
1529 dev_dbg(fe->dev, "ASoC: no BE found for %s\n", in dpcm_add_paths()
1530 widget->name); in dpcm_add_paths()
1536 * This helps to avoid unnecessary re-configuration of an in dpcm_add_paths()
1540 if (fe->card->component_chaining && in dpcm_add_paths()
1541 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_add_paths()
1542 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_add_paths()
1543 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_add_paths()
1544 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_add_paths()
1550 dev_err(fe->dev, "ASoC: can't connect %s\n", in dpcm_add_paths()
1551 widget->name); in dpcm_add_paths()
1561 dev_dbg(fe->dev, "ASoC: found %d new BE paths\n", new); in dpcm_add_paths()
1583 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_clear_pending_state()
1593 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_be_dai_stop()
1604 if (be->dpcm[stream].users == 0) { in dpcm_be_dai_stop()
1605 dev_err(be->dev, "ASoC: no users %s at close - state %d\n", in dpcm_be_dai_stop()
1607 be->dpcm[stream].state); in dpcm_be_dai_stop()
1611 if (--be->dpcm[stream].users != 0) in dpcm_be_dai_stop()
1614 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) { in dpcm_be_dai_stop()
1618 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) { in dpcm_be_dai_stop()
1620 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_stop()
1625 be_substream->runtime = NULL; in dpcm_be_dai_stop()
1626 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_be_dai_stop()
1637 /* only startup BE DAIs that are either sinks or sources to this FE DAI */ in dpcm_be_dai_startup()
1641 be = dpcm->be; in dpcm_be_dai_startup()
1645 dev_err(be->dev, "ASoC: no backend %s stream\n", in dpcm_be_dai_startup()
1655 if (be->dpcm[stream].users == DPCM_MAX_BE_USERS) { in dpcm_be_dai_startup()
1656 dev_err(be->dev, "ASoC: too many users %s at open %d\n", in dpcm_be_dai_startup()
1658 be->dpcm[stream].state); in dpcm_be_dai_startup()
1662 if (be->dpcm[stream].users++ != 0) in dpcm_be_dai_startup()
1665 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_be_dai_startup()
1666 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_be_dai_startup()
1669 dev_dbg(be->dev, "ASoC: open %s BE %s\n", in dpcm_be_dai_startup()
1670 stream ? "capture" : "playback", be->dai_link->name); in dpcm_be_dai_startup()
1672 be_substream->runtime = fe_substream->runtime; in dpcm_be_dai_startup()
1675 be->dpcm[stream].users--; in dpcm_be_dai_startup()
1676 if (be->dpcm[stream].users < 0) in dpcm_be_dai_startup()
1677 dev_err(be->dev, "ASoC: no users %s at unwind %d\n", in dpcm_be_dai_startup()
1679 be->dpcm[stream].state); in dpcm_be_dai_startup()
1681 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_be_dai_startup()
1684 be->dpcm[stream].be_start = 0; in dpcm_be_dai_startup()
1685 be->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_be_dai_startup()
1700 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_fe()
1701 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_fe()
1703 int stream = substream->stream; in dpcm_runtime_setup_fe()
1704 u64 formats = hw->formats; in dpcm_runtime_setup_fe()
1710 hw->formats &= formats; in dpcm_runtime_setup_fe()
1716 * Skip CPUs which don't support the current stream in dpcm_runtime_setup_fe()
1734 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_be_format()
1735 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_be_format()
1738 int stream = substream->stream; in dpcm_runtime_setup_be_format()
1740 if (!fe->dai_link->dpcm_merged_format) in dpcm_runtime_setup_be_format()
1749 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_runtime_setup_be_format()
1755 * Skip CODECs which don't support the current stream in dpcm_runtime_setup_be_format()
1771 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_be_chan()
1772 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_be_chan()
1774 int stream = substream->stream; in dpcm_runtime_setup_be_chan()
1776 if (!fe->dai_link->dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1785 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_runtime_setup_be_chan()
1792 * Skip CPUs which don't support the current stream in dpcm_runtime_setup_be_chan()
1807 if (be->dai_link->num_codecs == 1) { in dpcm_runtime_setup_be_chan()
1819 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_be_rate()
1820 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_be_rate()
1822 int stream = substream->stream; in dpcm_runtime_setup_be_rate()
1824 if (!fe->dai_link->dpcm_merged_rate) in dpcm_runtime_setup_be_rate()
1833 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_runtime_setup_be_rate()
1840 * Skip DAIs which don't support the current stream in dpcm_runtime_setup_be_rate()
1874 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_apply_symmetry()
1885 if (rtd->dai_link->be_hw_params_fixup) in dpcm_apply_symmetry()
1904 int stream = fe_substream->stream, ret = 0; in dpcm_fe_dai_startup()
1912 dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name); in dpcm_fe_dai_startup()
1919 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_fe_dai_startup()
1941 int stream = substream->stream; in dpcm_fe_dai_shutdown()
1950 dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name); in dpcm_fe_dai_shutdown()
1958 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_fe_dai_shutdown()
1967 /* only hw_params backends that are either sinks or sources in dpcm_be_dai_hw_free()
1971 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_be_dai_hw_free()
1979 /* only free hw when no longer used - check all FEs */ in dpcm_be_dai_hw_free()
1984 if (be->dpcm[stream].users > 1) in dpcm_be_dai_hw_free()
1987 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_free()
1988 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_hw_free()
1989 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_free()
1990 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED) && in dpcm_be_dai_hw_free()
1991 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_hw_free()
1992 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_hw_free()
1995 dev_dbg(be->dev, "ASoC: hw_free BE %s\n", in dpcm_be_dai_hw_free()
1996 be->dai_link->name); in dpcm_be_dai_hw_free()
2000 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_hw_free()
2007 int stream = substream->stream; in dpcm_fe_dai_hw_free()
2012 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name); in dpcm_fe_dai_hw_free()
2017 /* only hw_params backends that are either sinks or sources in dpcm_fe_dai_hw_free()
2021 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_fe_dai_hw_free()
2038 be = dpcm->be; in dpcm_be_dai_hw_params()
2046 memcpy(&hw_params, &fe->dpcm[stream].hw_params, in dpcm_be_dai_hw_params()
2054 /* copy the fixed-up hw params for BE dai */ in dpcm_be_dai_hw_params()
2055 memcpy(&be->dpcm[stream].hw_params, &hw_params, in dpcm_be_dai_hw_params()
2062 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2063 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2064 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE)) in dpcm_be_dai_hw_params()
2067 dev_dbg(be->dev, "ASoC: hw_params BE %s\n", in dpcm_be_dai_hw_params()
2068 be->dai_link->name); in dpcm_be_dai_hw_params()
2074 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_be_dai_hw_params()
2079 dev_dbg(fe->dev, "ASoC: %s() failed at %s (%d)\n", in dpcm_be_dai_hw_params()
2080 __func__, be->dai_link->name, ret); in dpcm_be_dai_hw_params()
2084 be = dpcm->be; in dpcm_be_dai_hw_params()
2094 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2095 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2096 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_params()
2097 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP)) in dpcm_be_dai_hw_params()
2110 int ret, stream = substream->stream; in dpcm_fe_dai_hw_params()
2115 memcpy(&fe->dpcm[stream].hw_params, params, in dpcm_fe_dai_hw_params()
2121 dev_dbg(fe->dev, "ASoC: hw_params FE %s rate %d chan %x fmt %d\n", in dpcm_fe_dai_hw_params()
2122 fe->dai_link->name, params_rate(params), in dpcm_fe_dai_hw_params()
2130 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_fe_dai_hw_params()
2151 be = dpcm->be; in dpcm_be_dai_trigger()
2160 dev_dbg(be->dev, "ASoC: trigger BE %s cmd %d\n", in dpcm_be_dai_trigger()
2161 be->dai_link->name, cmd); in dpcm_be_dai_trigger()
2165 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2166 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_trigger()
2167 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_trigger()
2168 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2171 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2172 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2175 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_PAUSED) in dpcm_be_dai_trigger()
2182 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2186 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2189 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_trigger()
2192 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2193 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2198 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2202 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2205 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2206 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2207 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2210 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2211 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2213 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2214 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2219 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2223 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2226 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2227 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2230 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2231 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2233 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2237 if (fe->dpcm[stream].fe_pause) { in dpcm_be_dai_trigger()
2239 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2240 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2243 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2249 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2250 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2252 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2253 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2258 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2259 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2261 be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_be_dai_trigger()
2265 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2268 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2269 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2274 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2278 be->dpcm[stream].state = SND_SOC_DPCM_STATE_SUSPEND; in dpcm_be_dai_trigger()
2281 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2284 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2285 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2287 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2288 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2293 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2297 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2317 dev_dbg(fe->dev, "ASoC: pre trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2318 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2324 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2329 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2333 dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2334 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2344 int stream = substream->stream; in dpcm_fe_dai_do_trigger()
2346 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_fe_dai_do_trigger()
2348 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in dpcm_fe_dai_do_trigger()
2365 ret = -EINVAL; in dpcm_fe_dai_do_trigger()
2383 ret = -EINVAL; in dpcm_fe_dai_do_trigger()
2388 /* bespoke trigger() - handles both FE and BEs */ in dpcm_fe_dai_do_trigger()
2390 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd %d\n", in dpcm_fe_dai_do_trigger()
2391 fe->dai_link->name, cmd); in dpcm_fe_dai_do_trigger()
2396 dev_err(fe->dev, "ASoC: invalid trigger cmd %d for %s\n", cmd, in dpcm_fe_dai_do_trigger()
2397 fe->dai_link->name); in dpcm_fe_dai_do_trigger()
2398 ret = -EINVAL; in dpcm_fe_dai_do_trigger()
2403 dev_err(fe->dev, "ASoC: trigger FE cmd: %d failed: %d\n", in dpcm_fe_dai_do_trigger()
2412 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_fe_dai_do_trigger()
2416 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_fe_dai_do_trigger()
2419 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_fe_dai_do_trigger()
2424 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in dpcm_fe_dai_do_trigger()
2431 int stream = substream->stream; in dpcm_fe_dai_trigger()
2436 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) { in dpcm_fe_dai_trigger()
2437 fe->dpcm[stream].trigger_pending = cmd + 1; in dpcm_fe_dai_trigger()
2452 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_be_dai_prepare()
2463 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_prepare()
2464 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_prepare()
2465 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND) && in dpcm_be_dai_prepare()
2466 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_prepare()
2469 dev_dbg(be->dev, "ASoC: prepare BE %s\n", in dpcm_be_dai_prepare()
2470 be->dai_link->name); in dpcm_be_dai_prepare()
2476 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_be_dai_prepare()
2483 * denial-of-service attack on the syslog / diskspace. in dpcm_be_dai_prepare()
2491 int stream = substream->stream, ret = 0; in dpcm_fe_dai_prepare()
2495 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name); in dpcm_fe_dai_prepare()
2500 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_fe_dai_prepare()
2502 …dev_err_once(fe->dev, "ASoC: no backend DAIs enabled for %s, possibly missing ALSA mixer-based rou… in dpcm_fe_dai_prepare()
2503 fe->dai_link->name); in dpcm_fe_dai_prepare()
2504 dev_dbg(fe->dev, "ASoC: no backend DAIs enabled for %s\n", in dpcm_fe_dai_prepare()
2505 fe->dai_link->name); in dpcm_fe_dai_prepare()
2506 ret = -EINVAL; in dpcm_fe_dai_prepare()
2519 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_fe_dai_prepare()
2529 * denial-of-service attack on the syslog / diskspace. in dpcm_fe_dai_prepare()
2538 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_shutdown()
2541 dev_dbg(fe->dev, "ASoC: runtime %s close on FE %s\n", in dpcm_run_update_shutdown()
2542 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_shutdown()
2545 /* call bespoke trigger - FE takes care of all BE triggers */ in dpcm_run_update_shutdown()
2546 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd stop\n", in dpcm_run_update_shutdown()
2547 fe->dai_link->name); in dpcm_run_update_shutdown()
2551 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd stop\n", in dpcm_run_update_shutdown()
2552 fe->dai_link->name); in dpcm_run_update_shutdown()
2572 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_startup()
2575 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n", in dpcm_run_update_startup()
2576 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_startup()
2579 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_FREE || in dpcm_run_update_startup()
2580 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) { in dpcm_run_update_startup()
2581 dev_err(fe->dev, "ASoC: FE %s is not ready %d\n", in dpcm_run_update_startup()
2582 fe->dai_link->name, fe->dpcm[stream].state); in dpcm_run_update_startup()
2583 ret = -EINVAL; in dpcm_run_update_startup()
2593 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_OPEN) in dpcm_run_update_startup()
2601 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_PARAMS) in dpcm_run_update_startup()
2612 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_PREPARE || in dpcm_run_update_startup()
2613 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_STOP) in dpcm_run_update_startup()
2617 /* call trigger on the frontend - FE takes care of all BE triggers */ in dpcm_run_update_startup()
2618 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd start\n", in dpcm_run_update_startup()
2619 fe->dai_link->name); in dpcm_run_update_startup()
2625 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd start\n", in dpcm_run_update_startup()
2626 fe->dai_link->name); in dpcm_run_update_startup()
2643 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_run_update_startup()
2649 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE || in dpcm_run_update_startup()
2650 be->dpcm[stream].state == SND_SOC_DPCM_STATE_NEW) in dpcm_run_update_startup()
2651 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; in dpcm_run_update_startup()
2663 if (!fe->dai_link->dynamic) in soc_dpcm_fe_runtime_update()
2666 if (fe->dai_link->num_cpus > 1) { in soc_dpcm_fe_runtime_update()
2667 dev_err(fe->dev, in soc_dpcm_fe_runtime_update()
2669 return -EINVAL; in soc_dpcm_fe_runtime_update()
2677 dev_dbg(fe->dev, "ASoC: DPCM %s runtime update for FE %s\n", in soc_dpcm_fe_runtime_update()
2678 new ? "new" : "old", fe->dai_link->name); in soc_dpcm_fe_runtime_update()
2749 int stream = fe_substream->stream; in dpcm_fe_dai_cleanup()
2755 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; in dpcm_fe_dai_cleanup()
2779 int stream = fe_substream->stream; in dpcm_fe_dai_open()
2787 /* calculate valid and active FE <-> BE dpcms */ in dpcm_fe_dai_open()
2804 struct snd_soc_dai_link *dai_link = rtd->dai_link; in soc_get_playback_capture()
2810 if (dai_link->dynamic && dai_link->num_cpus > 1) { in soc_get_playback_capture()
2811 dev_err(rtd->dev, "DPCM doesn't support Multi CPU for Front-Ends yet\n"); in soc_get_playback_capture()
2812 return -EINVAL; in soc_get_playback_capture()
2815 if (dai_link->dynamic || dai_link->no_pcm) { in soc_get_playback_capture()
2818 if (dai_link->dpcm_playback) { in soc_get_playback_capture()
2828 dev_err(rtd->card->dev, in soc_get_playback_capture()
2830 dai_link->stream_name); in soc_get_playback_capture()
2831 return -EINVAL; in soc_get_playback_capture()
2834 if (dai_link->dpcm_capture) { in soc_get_playback_capture()
2845 dev_err(rtd->card->dev, in soc_get_playback_capture()
2847 dai_link->stream_name); in soc_get_playback_capture()
2848 return -EINVAL; in soc_get_playback_capture()
2859 if (dai_link->num_cpus == 1) { in soc_get_playback_capture()
2861 } else if (dai_link->num_cpus == dai_link->num_codecs) { in soc_get_playback_capture()
2863 } else if (rtd->dai_link->num_codecs > rtd->dai_link->num_cpus) { in soc_get_playback_capture()
2866 if (!rtd->dai_link->codec_ch_maps) { in soc_get_playback_capture()
2867 dev_err(rtd->card->dev, "%s: no codec channel mapping table provided\n", in soc_get_playback_capture()
2869 return -EINVAL; in soc_get_playback_capture()
2872 cpu_id = rtd->dai_link->codec_ch_maps[i].connected_cpu_id; in soc_get_playback_capture()
2875 dev_err(rtd->card->dev, in soc_get_playback_capture()
2877 __func__, rtd->dai_link->num_codecs, in soc_get_playback_capture()
2878 rtd->dai_link->num_cpus); in soc_get_playback_capture()
2879 return -EINVAL; in soc_get_playback_capture()
2891 if (dai_link->playback_only) in soc_get_playback_capture()
2894 if (dai_link->capture_only) in soc_get_playback_capture()
2898 dev_err(rtd->dev, "substream %s has no playback, no capture\n", in soc_get_playback_capture()
2899 dai_link->stream_name); in soc_get_playback_capture()
2901 return -EINVAL; in soc_get_playback_capture()
2912 int playback, int capture, int num) in soc_create_pcm() argument
2918 if (rtd->dai_link->c2c_params) { in soc_create_pcm()
2920 rtd->dai_link->stream_name); in soc_create_pcm()
2922 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, in soc_create_pcm()
2924 } else if (rtd->dai_link->no_pcm) { in soc_create_pcm()
2926 rtd->dai_link->stream_name); in soc_create_pcm()
2928 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, in soc_create_pcm()
2931 if (rtd->dai_link->dynamic) in soc_create_pcm()
2933 rtd->dai_link->stream_name); in soc_create_pcm()
2935 snprintf(new_name, sizeof(new_name), "%s %s-%d", in soc_create_pcm()
2936 rtd->dai_link->stream_name, in soc_create_pcm()
2937 soc_codec_dai_name(rtd), num); in soc_create_pcm()
2939 ret = snd_pcm_new(rtd->card->snd_card, new_name, num, playback, in soc_create_pcm()
2943 dev_err(rtd->card->dev, "ASoC: can't create pcm %s for dailink %s: %d\n", in soc_create_pcm()
2944 new_name, rtd->dai_link->name, ret); in soc_create_pcm()
2947 dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n",num, new_name); in soc_create_pcm()
2953 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) in soc_new_pcm() argument
2964 ret = soc_create_pcm(&pcm, rtd, playback, capture, num); in soc_new_pcm()
2975 if (!rtd->dai_link->c2c_params) in soc_new_pcm()
2976 rtd->close_delayed_work_func = snd_soc_close_delayed_work; in soc_new_pcm()
2978 rtd->pcm = pcm; in soc_new_pcm()
2979 pcm->nonatomic = rtd->dai_link->nonatomic; in soc_new_pcm()
2980 pcm->private_data = rtd; in soc_new_pcm()
2981 pcm->no_device_suspend = true; in soc_new_pcm()
2983 if (rtd->dai_link->no_pcm || rtd->dai_link->c2c_params) { in soc_new_pcm()
2985 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd; in soc_new_pcm()
2987 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd; in soc_new_pcm()
2992 if (rtd->dai_link->dynamic) { in soc_new_pcm()
2993 rtd->ops.open = dpcm_fe_dai_open; in soc_new_pcm()
2994 rtd->ops.hw_params = dpcm_fe_dai_hw_params; in soc_new_pcm()
2995 rtd->ops.prepare = dpcm_fe_dai_prepare; in soc_new_pcm()
2996 rtd->ops.trigger = dpcm_fe_dai_trigger; in soc_new_pcm()
2997 rtd->ops.hw_free = dpcm_fe_dai_hw_free; in soc_new_pcm()
2998 rtd->ops.close = dpcm_fe_dai_close; in soc_new_pcm()
2999 rtd->ops.pointer = soc_pcm_pointer; in soc_new_pcm()
3001 rtd->ops.open = soc_pcm_open; in soc_new_pcm()
3002 rtd->ops.hw_params = soc_pcm_hw_params; in soc_new_pcm()
3003 rtd->ops.prepare = soc_pcm_prepare; in soc_new_pcm()
3004 rtd->ops.trigger = soc_pcm_trigger; in soc_new_pcm()
3005 rtd->ops.hw_free = soc_pcm_hw_free; in soc_new_pcm()
3006 rtd->ops.close = soc_pcm_close; in soc_new_pcm()
3007 rtd->ops.pointer = soc_pcm_pointer; in soc_new_pcm()
3011 const struct snd_soc_component_driver *drv = component->driver; in soc_new_pcm()
3013 if (drv->ioctl) in soc_new_pcm()
3014 rtd->ops.ioctl = snd_soc_pcm_component_ioctl; in soc_new_pcm()
3015 if (drv->sync_stop) in soc_new_pcm()
3016 rtd->ops.sync_stop = snd_soc_pcm_component_sync_stop; in soc_new_pcm()
3017 if (drv->copy) in soc_new_pcm()
3018 rtd->ops.copy = snd_soc_pcm_component_copy; in soc_new_pcm()
3019 if (drv->page) in soc_new_pcm()
3020 rtd->ops.page = snd_soc_pcm_component_page; in soc_new_pcm()
3021 if (drv->mmap) in soc_new_pcm()
3022 rtd->ops.mmap = snd_soc_pcm_component_mmap; in soc_new_pcm()
3023 if (drv->ack) in soc_new_pcm()
3024 rtd->ops.ack = snd_soc_pcm_component_ack; in soc_new_pcm()
3028 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &rtd->ops); in soc_new_pcm()
3031 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops); in soc_new_pcm()
3037 dev_dbg(rtd->card->dev, "%s <-> %s mapping ok\n", in soc_new_pcm()
3042 /* is the current PCM operation for this FE ? */
3045 if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) in snd_soc_dpcm_fe_can_update()
3051 /* is the current PCM operation for this BE ? */
3055 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || in snd_soc_dpcm_be_can_update()
3056 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && in snd_soc_dpcm_be_can_update()
3057 be->dpcm[stream].runtime_update)) in snd_soc_dpcm_be_can_update()
3067 return be->pcm->streams[stream].substream; in snd_soc_dpcm_get_substream()
3084 if (dpcm->fe == fe) in snd_soc_dpcm_check_state()
3087 state = dpcm->fe->dpcm[stream].state; in snd_soc_dpcm_check_state()