Lines Matching +full:fe +full:- +full:dai +full:- +full:link
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()
52 /* is the current PCM operation for this FE ? */
54 static int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream)
56 if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE)
63 static int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_be_can_update() argument
66 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || in snd_soc_dpcm_be_can_update()
67 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && in snd_soc_dpcm_be_can_update()
68 be->dpcm[stream].runtime_update)) in snd_soc_dpcm_be_can_update()
73 static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_check_state() argument
86 if (dpcm->fe == fe) in snd_soc_dpcm_check_state()
89 state = dpcm->fe->dpcm[stream].state; in snd_soc_dpcm_check_state()
98 /* it's safe to do this BE DAI */ in snd_soc_dpcm_check_state()
103 * We can only hw_free, stop, pause or suspend a BE DAI if any of it's FE
106 static int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_free_stop() argument
115 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_free_stop()
119 * We can only change hw params a BE DAI if any of it's FE are not prepared,
122 static int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_params() argument
132 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_params()
136 * We can only prepare a BE DAI if any of it's FE are not prepared,
139 static int snd_soc_dpcm_can_be_prepared(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_prepared() argument
148 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_prepared()
155 return (rtd)->dai_link->num_cpus == 1 ? snd_soc_rtd_to_cpu(rtd, 0)->name : "multicpu"; in soc_cpu_dai_name()
159 return (rtd)->dai_link->num_codecs == 1 ? snd_soc_rtd_to_codec(rtd, 0)->name : "multicodec"; in soc_codec_dai_name()
191 static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, in dpcm_show_state() argument
194 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; in dpcm_show_state()
198 /* FE state */ in dpcm_show_state()
199 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
200 "[%s - %s]\n", fe->dai_link->name, in dpcm_show_state()
203 offset += scnprintf(buf + offset, size - offset, "State: %s\n", in dpcm_show_state()
204 dpcm_state_string(fe->dpcm[stream].state)); in dpcm_show_state()
206 if ((fe->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
207 (fe->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
208 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
216 offset += scnprintf(buf + offset, size - offset, "Backends:\n"); in dpcm_show_state()
218 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_show_state()
219 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
224 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_show_state()
225 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_show_state()
226 params = &be->dpcm[stream].hw_params; in dpcm_show_state()
228 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
229 "- %s\n", be->dai_link->name); in dpcm_show_state()
231 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
233 dpcm_state_string(be->dpcm[stream].state)); in dpcm_show_state()
235 if ((be->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
236 (be->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
237 offset += scnprintf(buf + offset, size - offset, in dpcm_show_state()
251 struct snd_soc_pcm_runtime *fe = file->private_data; in dpcm_state_read_file() local
256 if (fe->dai_link->num_cpus > 1) { in dpcm_state_read_file()
257 dev_err(fe->dev, in dpcm_state_read_file()
259 return -EINVAL; in dpcm_state_read_file()
264 return -ENOMEM; in dpcm_state_read_file()
266 snd_soc_dpcm_mutex_lock(fe); in dpcm_state_read_file()
268 if (snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream)) in dpcm_state_read_file()
269 offset += dpcm_show_state(fe, stream, in dpcm_state_read_file()
271 out_count - offset); in dpcm_state_read_file()
272 snd_soc_dpcm_mutex_unlock(fe); in dpcm_state_read_file()
288 if (!rtd->dai_link->dynamic) in soc_dpcm_debugfs_add()
291 if (!rtd->card->debugfs_card_root) in soc_dpcm_debugfs_add()
294 rtd->debugfs_dpcm_root = debugfs_create_dir(rtd->dai_link->name, in soc_dpcm_debugfs_add()
295 rtd->card->debugfs_card_root); in soc_dpcm_debugfs_add()
297 debugfs_create_file("state", 0444, rtd->debugfs_dpcm_root, in soc_dpcm_debugfs_add()
305 name = kasprintf(GFP_KERNEL, "%s:%s", dpcm->be->dai_link->name, in dpcm_create_debugfs_state()
308 dpcm->debugfs_state = debugfs_create_dir( in dpcm_create_debugfs_state()
309 name, dpcm->fe->debugfs_dpcm_root); in dpcm_create_debugfs_state()
310 debugfs_create_u32("state", 0644, dpcm->debugfs_state, in dpcm_create_debugfs_state()
311 &dpcm->state); in dpcm_create_debugfs_state()
318 debugfs_remove_recursive(dpcm->debugfs_state); in dpcm_remove_debugfs_state()
332 /* Set FE's runtime_update state; the state is protected via PCM stream lock
338 static void dpcm_set_fe_update_state(struct snd_soc_pcm_runtime *fe, in dpcm_set_fe_update_state() argument
342 snd_soc_dpcm_get_substream(fe, stream); in dpcm_set_fe_update_state()
345 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) { in dpcm_set_fe_update_state()
347 fe->dpcm[stream].trigger_pending - 1); in dpcm_set_fe_update_state()
348 fe->dpcm[stream].trigger_pending = 0; in dpcm_set_fe_update_state()
350 fe->dpcm[stream].runtime_update = state; in dpcm_set_fe_update_state()
357 be->dpcm[stream].runtime_update = state; in dpcm_set_be_update_state()
361 * snd_soc_runtime_action() - Increment/Decrement active count for
365 * @action: Activate stream if 1. Deactivate if -1.
371 * Must be called with the rtd->card->pcm_mutex being held
377 struct snd_soc_dai *dai; in snd_soc_runtime_action() local
382 for_each_rtd_dais(rtd, i, dai) in snd_soc_runtime_action()
383 snd_soc_dai_action(dai, stream, action); in snd_soc_runtime_action()
387 if (component->num_dai) in snd_soc_runtime_action()
389 component->active += action; in snd_soc_runtime_action()
395 * snd_soc_runtime_ignore_pmdown_time() - Check whether to ignore the power down delay
399 * specific PCM runtime. Returns true if the delay is 0, if the DAI link has
408 if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time) in snd_soc_runtime_ignore_pmdown_time()
412 if (component->driver->use_pmdown_time) in snd_soc_runtime_ignore_pmdown_time()
420 * snd_soc_set_runtime_hwparams - set the runtime hardware parameters
429 substream->runtime->hw = *hw; in snd_soc_set_runtime_hwparams()
435 /* DPCM stream event, send event to FE and all active BEs. */
436 int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, in dpcm_dapm_stream_event() argument
441 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_dapm_stream_event()
443 for_each_dpcm_be(fe, dir, dpcm) { in dpcm_dapm_stream_event()
445 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_dapm_stream_event()
447 dev_dbg(be->dev, "ASoC: BE %s event %d dir %d\n", in dpcm_dapm_stream_event()
448 be->dai_link->name, event, dir); in dpcm_dapm_stream_event()
451 (be->dpcm[dir].users >= 1)) in dpcm_dapm_stream_event()
457 snd_soc_dapm_stream_event(fe, dir, event); in dpcm_dapm_stream_event()
462 static void soc_pcm_set_dai_params(struct snd_soc_dai *dai, in soc_pcm_set_dai_params() argument
466 dai->rate = params_rate(params); in soc_pcm_set_dai_params()
467 dai->channels = params_channels(params); in soc_pcm_set_dai_params()
468 dai->sample_bits = snd_pcm_format_physical_width(params_format(params)); in soc_pcm_set_dai_params()
470 dai->rate = 0; in soc_pcm_set_dai_params()
471 dai->channels = 0; in soc_pcm_set_dai_params()
472 dai->sample_bits = 0; in soc_pcm_set_dai_params()
486 if (soc_dai->name && (soc_dai->driver->symmetric_##name || \ in soc_pcm_apply_symmetry()
487 rtd->dai_link->symmetric_##name)) { \ in soc_pcm_apply_symmetry()
488 dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %s to %d\n",\ in soc_pcm_apply_symmetry()
489 #name, soc_dai->name); \ in soc_pcm_apply_symmetry()
491 ret = snd_pcm_hw_constraint_single(substream->runtime, \ in soc_pcm_apply_symmetry()
493 soc_dai->name); \ in soc_pcm_apply_symmetry()
495 dev_err(soc_dai->dev, \ in soc_pcm_apply_symmetry()
514 struct snd_soc_dai *dai; in soc_pcm_params_symmetry() local
522 symmetry = rtd->dai_link->symmetric_##xxx; \ in soc_pcm_params_symmetry()
523 for_each_rtd_dais(rtd, i, dai) \ in soc_pcm_params_symmetry()
524 symmetry |= dai->driver->symmetric_##xxx; \ in soc_pcm_params_symmetry()
529 cpu_dai->xxx && cpu_dai->xxx != d.xxx) { \ in soc_pcm_params_symmetry()
530 dev_err(rtd->dev, "ASoC: unmatched %s symmetry: %s:%d - %s:%d\n", \ in soc_pcm_params_symmetry()
531 #xxx, cpu_dai->name, cpu_dai->xxx, d.name, d.xxx); \ in soc_pcm_params_symmetry()
532 return -EINVAL; \ in soc_pcm_params_symmetry()
546 struct snd_soc_dai_link *link = rtd->dai_link; in soc_pcm_update_symmetry() local
547 struct snd_soc_dai *dai; in soc_pcm_update_symmetry() local
550 symmetry = link->symmetric_rate || in soc_pcm_update_symmetry()
551 link->symmetric_channels || in soc_pcm_update_symmetry()
552 link->symmetric_sample_bits; in soc_pcm_update_symmetry()
554 for_each_rtd_dais(rtd, i, dai) in soc_pcm_update_symmetry()
556 dai->driver->symmetric_rate || in soc_pcm_update_symmetry()
557 dai->driver->symmetric_channels || in soc_pcm_update_symmetry()
558 dai->driver->symmetric_sample_bits; in soc_pcm_update_symmetry()
561 substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX; in soc_pcm_update_symmetry()
572 ret = snd_pcm_hw_constraint_msbits(substream->runtime, 0, 0, bits); in soc_pcm_set_msb()
574 dev_warn(rtd->dev, "ASoC: Failed to set MSB %d: %d\n", in soc_pcm_set_msb()
583 int stream = substream->stream; in soc_pcm_apply_msb()
590 if (pcm_codec->sig_bits == 0) { in soc_pcm_apply_msb()
594 bits = max(pcm_codec->sig_bits, bits); in soc_pcm_apply_msb()
600 if (pcm_cpu->sig_bits == 0) { in soc_pcm_apply_msb()
604 cpu_bits = max(pcm_cpu->sig_bits, cpu_bits); in soc_pcm_apply_msb()
613 hw->rates = UINT_MAX; in soc_pcm_hw_init()
614 hw->rate_min = 0; in soc_pcm_hw_init()
615 hw->rate_max = UINT_MAX; in soc_pcm_hw_init()
616 hw->channels_min = 0; in soc_pcm_hw_init()
617 hw->channels_max = UINT_MAX; in soc_pcm_hw_init()
618 hw->formats = ULLONG_MAX; in soc_pcm_hw_init()
624 hw->rates = snd_pcm_rate_mask_intersect(hw->rates, p->rates); in soc_pcm_hw_update_rate()
626 /* setup hw->rate_min/max via hw->rates first */ in soc_pcm_hw_update_rate()
629 /* update hw->rate_min/max by snd_soc_pcm_stream */ in soc_pcm_hw_update_rate()
630 hw->rate_min = max(hw->rate_min, p->rate_min); in soc_pcm_hw_update_rate()
631 hw->rate_max = min_not_zero(hw->rate_max, p->rate_max); in soc_pcm_hw_update_rate()
637 hw->channels_min = max(hw->channels_min, p->channels_min); in soc_pcm_hw_update_chan()
638 hw->channels_max = min(hw->channels_max, p->channels_max); in soc_pcm_hw_update_chan()
644 hw->formats &= p->formats; in soc_pcm_hw_update_format()
650 hw->subformats &= p->subformats; in soc_pcm_hw_update_subformat()
654 * snd_soc_runtime_calc_hw() - Calculate hw limits for a PCM stream
674 /* first calculate min/max only for CPUs in the DAI link */ in snd_soc_runtime_calc_hw()
693 cpu_chan_min = hw->channels_min; in snd_soc_runtime_calc_hw()
694 cpu_chan_max = hw->channels_max; in snd_soc_runtime_calc_hw()
696 /* second calculate min/max only for CODECs in the DAI link */ in snd_soc_runtime_calc_hw()
716 /* Verify both a valid CPU DAI and a valid CODEC DAI were found */ in snd_soc_runtime_calc_hw()
717 if (!hw->channels_min) in snd_soc_runtime_calc_hw()
718 return -EINVAL; in snd_soc_runtime_calc_hw()
722 * connected to CPU DAI(s), use CPU DAI's directly and let in snd_soc_runtime_calc_hw()
725 if (rtd->dai_link->num_codecs > 1) { in snd_soc_runtime_calc_hw()
726 hw->channels_min = cpu_chan_min; in snd_soc_runtime_calc_hw()
727 hw->channels_max = cpu_chan_max; in snd_soc_runtime_calc_hw()
736 struct snd_pcm_hardware *hw = &substream->runtime->hw; in soc_pcm_init_runtime_hw()
738 u64 formats = hw->formats; in soc_pcm_init_runtime_hw()
745 snd_soc_runtime_calc_hw(rtd, hw, substream->stream); in soc_pcm_init_runtime_hw()
748 hw->formats &= formats; in soc_pcm_init_runtime_hw()
792 struct snd_soc_dai *dai; in soc_pcm_clean() local
798 snd_soc_runtime_deactivate(rtd, substream->stream); in soc_pcm_clean()
800 /* Make sure DAI parameters cleared if the DAI becomes inactive */ in soc_pcm_clean()
801 for_each_rtd_dais(rtd, i, dai) { in soc_pcm_clean()
802 if (snd_soc_dai_active(dai) == 0 && in soc_pcm_clean()
803 (dai->rate || dai->channels || dai->sample_bits)) in soc_pcm_clean()
804 soc_pcm_set_dai_params(dai, NULL); in soc_pcm_clean()
808 for_each_rtd_dais_reverse(rtd, i, dai) in soc_pcm_clean()
809 snd_soc_dai_shutdown(dai, substream, rollback); in soc_pcm_clean()
819 pinctrl_pm_select_sleep_state(component->dev); in soc_pcm_clean()
826 * freed here. The cpu DAI, codec DAI, machine and components are also
835 /* PCM close ops for non-DPCM streams */
849 struct snd_pcm_hardware *hw = &substream->runtime->hw; in soc_hw_sanity_check()
853 struct device *dev = rtd->dev; in soc_hw_sanity_check()
856 if (!hw->rates) in soc_hw_sanity_check()
860 if (!hw->formats) in soc_hw_sanity_check()
864 if (!hw->channels_min || !hw->channels_max || in soc_hw_sanity_check()
865 hw->channels_min > hw->channels_max) in soc_hw_sanity_check()
868 dev_dbg(dev, "ASoC: %s <-> %s info:\n", name_codec, in soc_hw_sanity_check()
870 dev_dbg(dev, "ASoC: rate mask 0x%x\n", hw->rates); in soc_hw_sanity_check()
871 dev_dbg(dev, "ASoC: ch min %d max %d\n", hw->channels_min, in soc_hw_sanity_check()
872 hw->channels_max); in soc_hw_sanity_check()
873 dev_dbg(dev, "ASoC: rate min %d max %d\n", hw->rate_min, in soc_hw_sanity_check()
874 hw->rate_max); in soc_hw_sanity_check()
879 dev_err(dev, "ASoC: %s <-> %s No matching %s\n", in soc_hw_sanity_check()
881 return -EINVAL; in soc_hw_sanity_check()
885 * Called by ALSA when a PCM substream is opened, the runtime->hw record is
887 * startup for the cpu DAI, component, machine and codec DAI.
893 struct snd_soc_dai *dai; in __soc_pcm_open() local
899 pinctrl_pm_select_default_state(component->dev); in __soc_pcm_open()
914 for_each_rtd_dais(rtd, i, dai) { in __soc_pcm_open()
915 ret = snd_soc_dai_startup(dai, substream); in __soc_pcm_open()
920 /* Dynamic PCM DAI links compat checks use dynamic capabilities */ in __soc_pcm_open()
921 if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) in __soc_pcm_open()
936 for_each_rtd_dais(rtd, i, dai) { in __soc_pcm_open()
937 ret = soc_pcm_apply_symmetry(substream, dai); in __soc_pcm_open()
942 snd_soc_runtime_activate(rtd, substream->stream); in __soc_pcm_open()
951 /* PCM open ops for non-DPCM streams */
971 struct snd_soc_dai *dai; in __soc_pcm_prepare() local
989 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in __soc_pcm_prepare()
990 rtd->pop_wait) { in __soc_pcm_prepare()
991 rtd->pop_wait = 0; in __soc_pcm_prepare()
992 cancel_delayed_work(&rtd->delayed_work); in __soc_pcm_prepare()
995 snd_soc_dapm_stream_event(rtd, substream->stream, in __soc_pcm_prepare()
998 for_each_rtd_dais(rtd, i, dai) { in __soc_pcm_prepare()
999 if (dai->driver->ops && !dai->driver->ops->mute_unmute_on_trigger) in __soc_pcm_prepare()
1000 snd_soc_dai_digital_mute(dai, 0, substream->stream); in __soc_pcm_prepare()
1007 /* PCM prepare ops for non-DPCM streams */
1026 interval->min = channels; in soc_pcm_codec_params_fixup()
1027 interval->max = channels; in soc_pcm_codec_params_fixup()
1033 struct snd_soc_dai *dai; in soc_pcm_hw_clean() local
1039 for_each_rtd_dais(rtd, i, dai) { in soc_pcm_hw_clean()
1040 if (snd_soc_dai_active(dai) == 1) in soc_pcm_hw_clean()
1041 soc_pcm_set_dai_params(dai, NULL); in soc_pcm_hw_clean()
1043 if (snd_soc_dai_stream_active(dai, substream->stream) == 1) { in soc_pcm_hw_clean()
1044 if (dai->driver->ops && !dai->driver->ops->mute_unmute_on_trigger) in soc_pcm_hw_clean()
1045 snd_soc_dai_digital_mute(dai, 1, substream->stream); in soc_pcm_hw_clean()
1050 snd_soc_dapm_stream_stop(rtd, substream->stream); in soc_pcm_hw_clean()
1059 for_each_rtd_dais(rtd, i, dai) in soc_pcm_hw_clean()
1060 if (snd_soc_dai_stream_valid(dai, substream->stream)) in soc_pcm_hw_clean()
1061 snd_soc_dai_hw_free(dai, substream, rollback); in soc_pcm_hw_clean()
1075 /* hw_free PCM ops for non-DPCM streams */
1090 * (using snd_pcm_lib_* ). It's non-atomic.
1112 unsigned int tdm_mask = snd_soc_dai_tdm_mask_get(codec_dai, substream->stream); in __soc_pcm_hw_params()
1122 * capture-only CODEC is acting as an LRCLK and/or BCLK master in __soc_pcm_hw_params()
1123 * for the DAI link including a playback-only CODEC. in __soc_pcm_hw_params()
1128 if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) in __soc_pcm_hw_params()
1156 if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream)) in __soc_pcm_hw_params()
1166 * soc.h :: [dai_link->ch_maps Image sample] in __soc_pcm_hw_params()
1169 if (ch_maps->cpu == i) in __soc_pcm_hw_params()
1170 ch_mask |= ch_maps->ch_mask; in __soc_pcm_hw_params()
1180 /* store the parameters for each DAI */ in __soc_pcm_hw_params()
1193 /* hw_params PCM ops for non-DPCM streams */
1232 if (component->driver->trigger_start) in soc_pcm_trigger()
1233 start = component->driver->trigger_start; in soc_pcm_trigger()
1234 if (component->driver->trigger_stop) in soc_pcm_trigger()
1235 stop = component->driver->trigger_stop; in soc_pcm_trigger()
1237 if (rtd->dai_link->trigger_start) in soc_pcm_trigger()
1238 start = rtd->dai_link->trigger_start; in soc_pcm_trigger()
1239 if (rtd->dai_link->trigger_stop) in soc_pcm_trigger()
1240 stop = rtd->dai_link->trigger_stop; in soc_pcm_trigger()
1244 return -EINVAL; in soc_pcm_trigger()
1287 for (i = TRIGGER_MAX; i > 0; i--) { in soc_pcm_trigger()
1288 r = trigger[stop][i - 1](substream, cmd, rollback); in soc_pcm_trigger()
1300 * the runtime->delay will be updated via snd_soc_pcm_component/dai_delay().
1304 struct snd_pcm_runtime *runtime = substream->runtime; in soc_pcm_pointer()
1315 runtime->delay = cpu_delay + codec_delay; in soc_pcm_pointer()
1320 /* connect a FE and BE */
1321 static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, in dpcm_be_connect() argument
1328 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_be_connect()
1331 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_connect()
1332 if (dpcm->be == be && dpcm->fe == fe) in dpcm_be_connect()
1336 fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_connect()
1339 if (!fe_substream->pcm->nonatomic && be_substream->pcm->nonatomic) { in dpcm_be_connect()
1340 dev_err(be->dev, "%s: FE is atomic but BE is nonatomic, invalid configuration\n", in dpcm_be_connect()
1342 return -EINVAL; in dpcm_be_connect()
1344 if (fe_substream->pcm->nonatomic && !be_substream->pcm->nonatomic) { in dpcm_be_connect()
1345 dev_dbg(be->dev, "FE is nonatomic but BE is not, forcing BE as nonatomic\n"); in dpcm_be_connect()
1346 be_substream->pcm->nonatomic = 1; in dpcm_be_connect()
1351 return -ENOMEM; in dpcm_be_connect()
1353 dpcm->be = be; in dpcm_be_connect()
1354 dpcm->fe = fe; in dpcm_be_connect()
1355 dpcm->state = SND_SOC_DPCM_LINK_STATE_NEW; in dpcm_be_connect()
1357 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); in dpcm_be_connect()
1358 list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); in dpcm_be_connect()
1361 dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", in dpcm_be_connect()
1362 snd_pcm_direction_name(stream), fe->dai_link->name, in dpcm_be_connect()
1363 stream ? "<-" : "->", be->dai_link->name); in dpcm_be_connect()
1370 /* reparent a BE onto another FE */
1371 static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, in dpcm_be_reparent() argument
1378 if (!be->dpcm[stream].users) in dpcm_be_reparent()
1386 if (dpcm->fe == fe) in dpcm_be_reparent()
1389 dev_dbg(fe->dev, "reparent %s path %s %s %s\n", in dpcm_be_reparent()
1391 dpcm->fe->dai_link->name, in dpcm_be_reparent()
1392 stream ? "<-" : "->", dpcm->be->dai_link->name); in dpcm_be_reparent()
1394 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream); in dpcm_be_reparent()
1395 be_substream->runtime = fe_substream->runtime; in dpcm_be_reparent()
1400 /* disconnect a BE and FE */
1401 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_disconnect() argument
1404 struct snd_pcm_substream *substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_disconnect()
1407 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_be_disconnect()
1410 for_each_dpcm_be_safe(fe, stream, dpcm, d) { in dpcm_be_disconnect()
1411 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n", in dpcm_be_disconnect()
1413 dpcm->be->dai_link->name); in dpcm_be_disconnect()
1415 if (dpcm->state != SND_SOC_DPCM_LINK_STATE_FREE) in dpcm_be_disconnect()
1418 dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n", in dpcm_be_disconnect()
1419 snd_pcm_direction_name(stream), fe->dai_link->name, in dpcm_be_disconnect()
1420 stream ? "<-" : "->", dpcm->be->dai_link->name); in dpcm_be_disconnect()
1422 /* BEs still alive need new FE */ in dpcm_be_disconnect()
1423 dpcm_be_reparent(fe, dpcm->be, stream); in dpcm_be_disconnect()
1425 list_del(&dpcm->list_be); in dpcm_be_disconnect()
1426 list_move(&dpcm->list_fe, &deleted_dpcms); in dpcm_be_disconnect()
1433 list_del(&dpcm->list_fe); in dpcm_be_disconnect()
1439 /* get BE for DAI widget and stream */
1445 struct snd_soc_dai *dai; in dpcm_get_be() local
1448 dev_dbg(card->dev, "ASoC: find BE for widget %s\n", widget->name); in dpcm_get_be()
1452 if (!be->dai_link->no_pcm) in dpcm_get_be()
1458 for_each_rtd_dais(be, i, dai) { in dpcm_get_be()
1459 w = snd_soc_dai_get_widget(dai, stream); in dpcm_get_be()
1461 dev_dbg(card->dev, "ASoC: try BE : %s\n", in dpcm_get_be()
1462 w ? w->name : "(not set)"); in dpcm_get_be()
1489 struct snd_soc_card *card = widget->dapm->card; in dpcm_end_walk_at_be()
1507 int dpcm_path_get(struct snd_soc_pcm_runtime *fe, in dpcm_path_get() argument
1510 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(fe, 0); in dpcm_path_get()
1513 if (fe->dai_link->num_cpus > 1) { in dpcm_path_get()
1514 dev_err(fe->dev, in dpcm_path_get()
1516 return -EINVAL; in dpcm_path_get()
1519 /* get number of valid DAI paths and their widgets */ in dpcm_path_get()
1521 fe->card->component_chaining ? in dpcm_path_get()
1525 dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths, in dpcm_path_get()
1528 dev_dbg(fe->dev, "ASoC: %s no valid %s path\n", fe->dai_link->name, in dpcm_path_get()
1542 struct snd_soc_dai *dai; in dpcm_be_is_active() local
1545 /* is there a valid DAI widget for this BE */ in dpcm_be_is_active()
1546 for_each_rtd_dais(dpcm->be, i, dai) { in dpcm_be_is_active()
1547 struct snd_soc_dapm_widget *widget = snd_soc_dai_get_widget(dai, stream); in dpcm_be_is_active()
1550 * The BE is pruned only if none of the dai in dpcm_be_is_active()
1560 static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_prune_paths() argument
1566 /* Destroy any old FE <--> BE connections */ in dpcm_prune_paths()
1567 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_prune_paths()
1571 dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n", in dpcm_prune_paths()
1573 dpcm->be->dai_link->name, fe->dai_link->name); in dpcm_prune_paths()
1574 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; in dpcm_prune_paths()
1575 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_BE); in dpcm_prune_paths()
1579 dev_dbg(fe->dev, "ASoC: found %d old BE paths for pruning\n", prune); in dpcm_prune_paths()
1583 static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_add_paths() argument
1586 struct snd_soc_card *card = fe->card; in dpcm_add_paths()
1590 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_add_paths()
1593 /* don't connect if FE is not running */ in dpcm_add_paths()
1594 if (!fe_substream->runtime && !fe->fe_compr) in dpcm_add_paths()
1597 /* Create any new FE <--> BE connections */ in dpcm_add_paths()
1600 switch (widget->id) { in dpcm_add_paths()
1616 dev_dbg(fe->dev, "ASoC: no BE found for %s\n", in dpcm_add_paths()
1617 widget->name); in dpcm_add_paths()
1623 * This helps to avoid unnecessary re-configuration of an in dpcm_add_paths()
1626 if (fe->card->component_chaining && in dpcm_add_paths()
1627 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_add_paths()
1628 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_add_paths()
1631 /* newly connected FE and BE */ in dpcm_add_paths()
1632 err = dpcm_be_connect(fe, be, stream); in dpcm_add_paths()
1634 dev_err(fe->dev, "ASoC: can't connect %s\n", in dpcm_add_paths()
1635 widget->name); in dpcm_add_paths()
1645 dev_dbg(fe->dev, "ASoC: found %d new BE paths\n", new); in dpcm_add_paths()
1651 * FE substream.
1653 int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, in dpcm_process_paths() argument
1657 return dpcm_add_paths(fe, stream, list); in dpcm_process_paths()
1659 return dpcm_prune_paths(fe, stream, list); in dpcm_process_paths()
1662 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_clear_pending_state() argument
1666 for_each_dpcm_be(fe, stream, dpcm) in dpcm_clear_pending_state()
1667 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_clear_pending_state()
1670 void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_stop() argument
1676 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_stop()
1677 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_be_dai_stop()
1685 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_stop()
1688 if (be->dpcm[stream].users == 0) { in dpcm_be_dai_stop()
1689 dev_err(be->dev, "ASoC: no users %s at close - state %d\n", in dpcm_be_dai_stop()
1691 be->dpcm[stream].state); in dpcm_be_dai_stop()
1695 if (--be->dpcm[stream].users != 0) in dpcm_be_dai_stop()
1698 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) { in dpcm_be_dai_stop()
1702 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) { in dpcm_be_dai_stop()
1704 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_stop()
1709 be_substream->runtime = NULL; in dpcm_be_dai_stop()
1710 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_be_dai_stop()
1714 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_startup() argument
1716 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_dai_startup()
1721 /* only startup BE DAIs that are either sinks or sources to this FE DAI */ in dpcm_be_dai_startup()
1722 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_startup()
1725 be = dpcm->be; in dpcm_be_dai_startup()
1729 dev_err(be->dev, "ASoC: no backend %s stream\n", in dpcm_be_dai_startup()
1735 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_startup()
1739 if (be->dpcm[stream].users == DPCM_MAX_BE_USERS) { in dpcm_be_dai_startup()
1740 dev_err(be->dev, "ASoC: too many users %s at open %d\n", in dpcm_be_dai_startup()
1742 be->dpcm[stream].state); in dpcm_be_dai_startup()
1746 if (be->dpcm[stream].users++ != 0) in dpcm_be_dai_startup()
1749 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_be_dai_startup()
1750 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_be_dai_startup()
1753 dev_dbg(be->dev, "ASoC: open %s BE %s\n", in dpcm_be_dai_startup()
1754 snd_pcm_direction_name(stream), be->dai_link->name); in dpcm_be_dai_startup()
1756 be_substream->runtime = fe_substream->runtime; in dpcm_be_dai_startup()
1759 be->dpcm[stream].users--; in dpcm_be_dai_startup()
1760 if (be->dpcm[stream].users < 0) in dpcm_be_dai_startup()
1761 dev_err(be->dev, "ASoC: no users %s at unwind %d\n", in dpcm_be_dai_startup()
1763 be->dpcm[stream].state); in dpcm_be_dai_startup()
1765 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_be_dai_startup()
1768 be->dpcm[stream].be_start = 0; in dpcm_be_dai_startup()
1769 be->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_be_dai_startup()
1776 dpcm_be_dai_startup_rollback(fe, stream, dpcm); in dpcm_be_dai_startup()
1778 return soc_pcm_ret(fe, err); in dpcm_be_dai_startup()
1783 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_fe() local
1784 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_fe()
1785 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_fe()
1786 struct snd_soc_dai *dai; in dpcm_runtime_setup_fe() local
1787 int stream = substream->stream; in dpcm_runtime_setup_fe()
1788 u64 formats = hw->formats; in dpcm_runtime_setup_fe()
1794 hw->formats &= formats; in dpcm_runtime_setup_fe()
1796 for_each_rtd_cpu_dais(fe, i, dai) { in dpcm_runtime_setup_fe()
1803 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_fe()
1806 cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_fe()
1818 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_be_format() local
1819 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_be_format()
1820 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_be_format()
1822 struct snd_soc_dai *dai; in dpcm_runtime_setup_be_format() local
1823 int stream = substream->stream; in dpcm_runtime_setup_be_format()
1825 if (!fe->dai_link->dpcm_merged_format) in dpcm_runtime_setup_be_format()
1830 * if FE want to use it (= dpcm_merged_format) in dpcm_runtime_setup_be_format()
1833 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_format()
1834 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_runtime_setup_be_format()
1838 for_each_rtd_codec_dais(be, i, dai) { in dpcm_runtime_setup_be_format()
1843 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_format()
1846 codec_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_format()
1856 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_be_chan() local
1857 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_be_chan()
1858 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_be_chan()
1860 int stream = substream->stream; in dpcm_runtime_setup_be_chan()
1862 if (!fe->dai_link->dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1867 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1870 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_chan()
1871 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_runtime_setup_be_chan()
1873 struct snd_soc_dai *dai; in dpcm_runtime_setup_be_chan() local
1876 for_each_rtd_cpu_dais(be, i, dai) { in dpcm_runtime_setup_be_chan()
1881 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_chan()
1884 cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_chan()
1891 * DAIs connected to a single CPU DAI, use CPU DAI's directly in dpcm_runtime_setup_be_chan()
1893 if (be->dai_link->num_codecs == 1) { in dpcm_runtime_setup_be_chan()
1904 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_be_rate() local
1905 struct snd_pcm_runtime *runtime = substream->runtime; in dpcm_runtime_setup_be_rate()
1906 struct snd_pcm_hardware *hw = &runtime->hw; in dpcm_runtime_setup_be_rate()
1908 int stream = substream->stream; in dpcm_runtime_setup_be_rate()
1910 if (!fe->dai_link->dpcm_merged_rate) in dpcm_runtime_setup_be_rate()
1915 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_setup_be_rate()
1918 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_rate()
1919 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_runtime_setup_be_rate()
1921 struct snd_soc_dai *dai; in dpcm_runtime_setup_be_rate() local
1924 for_each_rtd_dais(be, i, dai) { in dpcm_runtime_setup_be_rate()
1929 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_rate()
1932 pcm = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_rate()
1943 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_apply_symmetry() local
1948 /* apply symmetry for FE */ in dpcm_apply_symmetry()
1951 for_each_rtd_cpu_dais (fe, i, fe_cpu_dai) { in dpcm_apply_symmetry()
1959 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_apply_symmetry()
1960 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_apply_symmetry()
1964 struct snd_soc_dai *dai; in dpcm_apply_symmetry() local
1971 if (rtd->dai_link->be_hw_params_fixup) in dpcm_apply_symmetry()
1977 for_each_rtd_dais(rtd, i, dai) { in dpcm_apply_symmetry()
1978 err = soc_pcm_apply_symmetry(fe_substream, dai); in dpcm_apply_symmetry()
1984 return soc_pcm_ret(fe, err); in dpcm_apply_symmetry()
1989 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_startup() local
1990 int stream = fe_substream->stream, ret = 0; in dpcm_fe_dai_startup()
1992 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_startup()
1994 ret = dpcm_be_dai_startup(fe, stream); in dpcm_fe_dai_startup()
1998 dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name); in dpcm_fe_dai_startup()
2000 /* start the DAI frontend */ in dpcm_fe_dai_startup()
2001 ret = __soc_pcm_open(fe, fe_substream); in dpcm_fe_dai_startup()
2005 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_fe_dai_startup()
2017 dpcm_be_dai_startup_unwind(fe, stream); in dpcm_fe_dai_startup()
2019 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_startup()
2021 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_startup()
2026 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_shutdown() local
2027 int stream = substream->stream; in dpcm_fe_dai_shutdown()
2029 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_fe_dai_shutdown()
2031 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_shutdown()
2034 dpcm_be_dai_shutdown(fe, stream); in dpcm_fe_dai_shutdown()
2036 dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name); in dpcm_fe_dai_shutdown()
2039 __soc_pcm_close(fe, substream); in dpcm_fe_dai_shutdown()
2042 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); in dpcm_fe_dai_shutdown()
2044 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_fe_dai_shutdown()
2045 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_shutdown()
2049 void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_free() argument
2054 * to this frontend DAI */ in dpcm_be_dai_hw_free()
2055 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_free()
2057 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_be_dai_hw_free()
2062 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_free()
2065 /* only free hw when no longer used - check all FEs */ in dpcm_be_dai_hw_free()
2066 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_free()
2069 /* do not free hw if this BE is used by other FE */ in dpcm_be_dai_hw_free()
2070 if (be->dpcm[stream].users > 1) in dpcm_be_dai_hw_free()
2073 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_free()
2074 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_hw_free()
2075 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_free()
2076 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED) && in dpcm_be_dai_hw_free()
2077 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_hw_free()
2078 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_hw_free()
2081 dev_dbg(be->dev, "ASoC: hw_free BE %s\n", in dpcm_be_dai_hw_free()
2082 be->dai_link->name); in dpcm_be_dai_hw_free()
2086 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_hw_free()
2092 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_hw_free() local
2093 int stream = substream->stream; in dpcm_fe_dai_hw_free()
2095 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_hw_free()
2096 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_free()
2098 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name); in dpcm_fe_dai_hw_free()
2101 soc_pcm_hw_clean(fe, substream, 0); in dpcm_fe_dai_hw_free()
2104 * to this frontend DAI */ in dpcm_fe_dai_hw_free()
2105 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_free()
2107 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_fe_dai_hw_free()
2108 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_free()
2110 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_hw_free()
2114 int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_params() argument
2121 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2124 be = dpcm->be; in dpcm_be_dai_hw_params()
2128 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2132 memcpy(&hw_params, &fe->dpcm[stream].hw_params, in dpcm_be_dai_hw_params()
2140 /* copy the fixed-up hw params for BE dai */ in dpcm_be_dai_hw_params()
2141 memcpy(&be->dpcm[stream].hw_params, &hw_params, in dpcm_be_dai_hw_params()
2145 if (!snd_soc_dpcm_can_be_params(fe, be, stream)) in dpcm_be_dai_hw_params()
2148 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2149 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2150 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE)) in dpcm_be_dai_hw_params()
2153 dev_dbg(be->dev, "ASoC: hw_params BE %s\n", in dpcm_be_dai_hw_params()
2154 be->dai_link->name); in dpcm_be_dai_hw_params()
2160 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_be_dai_hw_params()
2165 dev_dbg(fe->dev, "ASoC: %s() failed at %s (%d)\n", in dpcm_be_dai_hw_params()
2166 __func__, be->dai_link->name, ret); in dpcm_be_dai_hw_params()
2169 for_each_dpcm_be_rollback(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2170 be = dpcm->be; in dpcm_be_dai_hw_params()
2173 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2177 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_params()
2180 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2181 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2182 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_params()
2183 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP)) in dpcm_be_dai_hw_params()
2195 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_hw_params() local
2196 int ret, stream = substream->stream; in dpcm_fe_dai_hw_params()
2198 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_hw_params()
2199 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_params()
2201 memcpy(&fe->dpcm[stream].hw_params, params, in dpcm_fe_dai_hw_params()
2203 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_fe_dai_hw_params()
2207 dev_dbg(fe->dev, "ASoC: hw_params FE %s rate %d chan %x fmt %d\n", in dpcm_fe_dai_hw_params()
2208 fe->dai_link->name, params_rate(params), in dpcm_fe_dai_hw_params()
2212 ret = __soc_pcm_hw_params(fe, substream, params); in dpcm_fe_dai_hw_params()
2214 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_params()
2216 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_fe_dai_hw_params()
2219 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_params()
2220 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_hw_params()
2222 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_hw_params()
2225 int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_trigger() argument
2234 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_trigger()
2237 be = dpcm->be; in dpcm_be_dai_trigger()
2243 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_trigger()
2246 dev_dbg(be->dev, "ASoC: trigger BE %s cmd %d\n", in dpcm_be_dai_trigger()
2247 be->dai_link->name, cmd); in dpcm_be_dai_trigger()
2251 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2252 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_trigger()
2253 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_trigger()
2254 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2257 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2258 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2261 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_PAUSED) in dpcm_be_dai_trigger()
2268 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2272 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2275 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_trigger()
2278 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2279 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2284 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2288 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2291 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2292 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2293 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2296 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2297 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2299 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2300 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2305 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2309 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2312 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2313 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2316 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2317 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2319 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2323 if (fe->dpcm[stream].fe_pause) { in dpcm_be_dai_trigger()
2325 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2326 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2329 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2335 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2336 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2338 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2339 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2344 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2345 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2347 be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_be_dai_trigger()
2351 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2354 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2355 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2360 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2364 be->dpcm[stream].state = SND_SOC_DPCM_STATE_SUSPEND; in dpcm_be_dai_trigger()
2367 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2370 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2371 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2373 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2374 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2379 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2383 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2391 return soc_pcm_ret(fe, ret); in dpcm_be_dai_trigger()
2398 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_dai_trigger_fe_be() local
2403 dev_dbg(fe->dev, "ASoC: pre trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2404 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2410 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2415 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2419 dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2420 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2429 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_do_trigger() local
2430 int stream = substream->stream; in dpcm_fe_dai_do_trigger()
2432 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_fe_dai_do_trigger()
2434 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in dpcm_fe_dai_do_trigger()
2451 ret = -EINVAL; in dpcm_fe_dai_do_trigger()
2469 ret = -EINVAL; in dpcm_fe_dai_do_trigger()
2474 dev_err(fe->dev, "ASoC: invalid trigger cmd %d for %s\n", cmd, in dpcm_fe_dai_do_trigger()
2475 fe->dai_link->name); in dpcm_fe_dai_do_trigger()
2476 ret = -EINVAL; in dpcm_fe_dai_do_trigger()
2481 dev_err(fe->dev, "ASoC: trigger FE cmd: %d failed: %d\n", in dpcm_fe_dai_do_trigger()
2490 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_fe_dai_do_trigger()
2494 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_fe_dai_do_trigger()
2497 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_fe_dai_do_trigger()
2502 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in dpcm_fe_dai_do_trigger()
2508 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_trigger() local
2509 int stream = substream->stream; in dpcm_fe_dai_trigger()
2511 /* if FE's runtime_update is already set, we're in race; in dpcm_fe_dai_trigger()
2514 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) { in dpcm_fe_dai_trigger()
2515 fe->dpcm[stream].trigger_pending = cmd + 1; in dpcm_fe_dai_trigger()
2523 int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_prepare() argument
2528 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_prepare()
2530 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_be_dai_prepare()
2535 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_prepare()
2538 if (!snd_soc_dpcm_can_be_prepared(fe, be, stream)) in dpcm_be_dai_prepare()
2541 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_prepare()
2542 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_prepare()
2543 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND) && in dpcm_be_dai_prepare()
2544 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_prepare()
2547 dev_dbg(be->dev, "ASoC: prepare BE %s\n", in dpcm_be_dai_prepare()
2548 be->dai_link->name); in dpcm_be_dai_prepare()
2554 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_be_dai_prepare()
2557 return soc_pcm_ret(fe, ret); in dpcm_be_dai_prepare()
2562 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_prepare() local
2563 int stream = substream->stream, ret = 0; in dpcm_fe_dai_prepare()
2565 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_prepare()
2567 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name); in dpcm_fe_dai_prepare()
2569 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_prepare()
2571 /* there is no point preparing this FE if there are no BEs */ in dpcm_fe_dai_prepare()
2572 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_fe_dai_prepare()
2574 …dev_err_once(fe->dev, "ASoC: no backend DAIs enabled for %s, possibly missing ALSA mixer-based rou… in dpcm_fe_dai_prepare()
2575 fe->dai_link->name); in dpcm_fe_dai_prepare()
2576 dev_dbg(fe->dev, "ASoC: no backend DAIs enabled for %s\n", in dpcm_fe_dai_prepare()
2577 fe->dai_link->name); in dpcm_fe_dai_prepare()
2578 ret = -EINVAL; in dpcm_fe_dai_prepare()
2582 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_fe_dai_prepare()
2587 ret = __soc_pcm_prepare(fe, substream); in dpcm_fe_dai_prepare()
2591 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_fe_dai_prepare()
2594 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_prepare()
2595 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_prepare()
2597 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_prepare()
2600 static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_shutdown() argument
2604 dev_dbg(fe->dev, "ASoC: runtime %s close on FE %s\n", in dpcm_run_update_shutdown()
2605 snd_pcm_direction_name(stream), fe->dai_link->name); in dpcm_run_update_shutdown()
2607 err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP); in dpcm_run_update_shutdown()
2609 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_shutdown()
2611 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_shutdown()
2614 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_shutdown()
2616 return soc_pcm_ret(fe, err); in dpcm_run_update_shutdown()
2619 static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_startup() argument
2624 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n", in dpcm_run_update_startup()
2625 snd_pcm_direction_name(stream), fe->dai_link->name); in dpcm_run_update_startup()
2627 /* Only start the BE if the FE is ready */ in dpcm_run_update_startup()
2628 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_FREE || in dpcm_run_update_startup()
2629 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) { in dpcm_run_update_startup()
2630 dev_err(fe->dev, "ASoC: FE %s is not ready %d\n", in dpcm_run_update_startup()
2631 fe->dai_link->name, fe->dpcm[stream].state); in dpcm_run_update_startup()
2632 ret = -EINVAL; in dpcm_run_update_startup()
2637 ret = dpcm_be_dai_startup(fe, stream); in dpcm_run_update_startup()
2641 /* keep going if FE state is > open */ in dpcm_run_update_startup()
2642 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_OPEN) in dpcm_run_update_startup()
2645 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_run_update_startup()
2649 /* keep going if FE state is > hw_params */ in dpcm_run_update_startup()
2650 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_PARAMS) in dpcm_run_update_startup()
2653 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_run_update_startup()
2658 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_startup()
2660 /* keep going if FE state is > prepare */ in dpcm_run_update_startup()
2661 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_PREPARE || in dpcm_run_update_startup()
2662 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_STOP) in dpcm_run_update_startup()
2665 ret = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_START); in dpcm_run_update_startup()
2672 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_startup()
2674 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_startup()
2677 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_run_update_startup()
2678 struct snd_soc_pcm_runtime *be = dpcm->be; in dpcm_run_update_startup()
2681 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_run_update_startup()
2684 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE || in dpcm_run_update_startup()
2685 be->dpcm[stream].state == SND_SOC_DPCM_STATE_NEW) in dpcm_run_update_startup()
2686 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; in dpcm_run_update_startup()
2689 return soc_pcm_ret(fe, ret); in dpcm_run_update_startup()
2692 static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new) in soc_dpcm_fe_runtime_update() argument
2698 if (!fe->dai_link->dynamic) in soc_dpcm_fe_runtime_update()
2701 if (fe->dai_link->num_cpus > 1) { in soc_dpcm_fe_runtime_update()
2702 dev_err(fe->dev, in soc_dpcm_fe_runtime_update()
2704 return -EINVAL; in soc_dpcm_fe_runtime_update()
2708 if (!snd_soc_dai_active(snd_soc_rtd_to_cpu(fe, 0))) in soc_dpcm_fe_runtime_update()
2712 dev_dbg(fe->dev, "ASoC: DPCM %s runtime update for FE %s\n", in soc_dpcm_fe_runtime_update()
2713 new ? "new" : "old", fe->dai_link->name); in soc_dpcm_fe_runtime_update()
2717 /* skip if FE doesn't have playback/capture capability */ in soc_dpcm_fe_runtime_update()
2718 if (!snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2719 !snd_soc_dai_stream_valid(snd_soc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2722 /* skip if FE isn't currently playing/capturing */ in soc_dpcm_fe_runtime_update()
2723 if (!snd_soc_dai_stream_active(snd_soc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2724 !snd_soc_dai_stream_active(snd_soc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2727 paths = dpcm_path_get(fe, stream, &list); in soc_dpcm_fe_runtime_update()
2732 count = dpcm_process_paths(fe, stream, &list, new); in soc_dpcm_fe_runtime_update()
2734 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_BE); in soc_dpcm_fe_runtime_update()
2736 dpcm_run_update_startup(fe, stream); in soc_dpcm_fe_runtime_update()
2738 dpcm_run_update_shutdown(fe, stream); in soc_dpcm_fe_runtime_update()
2739 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in soc_dpcm_fe_runtime_update()
2741 dpcm_clear_pending_state(fe, stream); in soc_dpcm_fe_runtime_update()
2742 dpcm_be_disconnect(fe, stream); in soc_dpcm_fe_runtime_update()
2752 * any DAI links.
2756 struct snd_soc_pcm_runtime *fe; in snd_soc_dpcm_runtime_update() local
2761 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2762 ret = soc_dpcm_fe_runtime_update(fe, 0); in snd_soc_dpcm_runtime_update()
2768 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2769 ret = soc_dpcm_fe_runtime_update(fe, 1); in snd_soc_dpcm_runtime_update()
2782 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_cleanup() local
2784 int stream = fe_substream->stream; in dpcm_fe_dai_cleanup()
2786 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_fe_dai_cleanup()
2788 /* mark FE's links ready to prune */ in dpcm_fe_dai_cleanup()
2789 for_each_dpcm_be(fe, stream, dpcm) in dpcm_fe_dai_cleanup()
2790 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; in dpcm_fe_dai_cleanup()
2792 dpcm_be_disconnect(fe, stream); in dpcm_fe_dai_cleanup()
2797 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_close() local
2800 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_close()
2805 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_close()
2811 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_open() local
2814 int stream = fe_substream->stream; in dpcm_fe_dai_open()
2816 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_open()
2818 ret = dpcm_path_get(fe, stream, &list); in dpcm_fe_dai_open()
2822 /* calculate valid and active FE <-> BE dpcms */ in dpcm_fe_dai_open()
2823 dpcm_process_paths(fe, stream, &list, 1); in dpcm_fe_dai_open()
2829 dpcm_clear_pending_state(fe, stream); in dpcm_fe_dai_open()
2832 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_open()
2839 struct snd_soc_dai_link *dai_link = rtd->dai_link; in soc_get_playback_capture()
2846 if (dai_link->dynamic && dai_link->num_cpus > 1) { in soc_get_playback_capture()
2847 dev_err(rtd->dev, "DPCM doesn't support Multi CPU for Front-Ends yet\n"); in soc_get_playback_capture()
2848 return -EINVAL; in soc_get_playback_capture()
2851 if (dai_link->dynamic || dai_link->no_pcm) { in soc_get_playback_capture()
2854 cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu); in soc_get_playback_capture()
2870 if ( dai_link->dpcm_playback && in soc_get_playback_capture()
2871 !dai_link->dpcm_capture && in soc_get_playback_capture()
2872 !dai_link->playback_only) { in soc_get_playback_capture()
2873 dev_warn(rtd->card->dev, in soc_get_playback_capture()
2876 dai_link->stream_name); in soc_get_playback_capture()
2877 dev_warn(rtd->card->dev, in soc_get_playback_capture()
2883 if (!dai_link->dpcm_playback && in soc_get_playback_capture()
2884 dai_link->dpcm_capture && in soc_get_playback_capture()
2885 !dai_link->capture_only) { in soc_get_playback_capture()
2886 dev_warn(rtd->card->dev, in soc_get_playback_capture()
2889 dai_link->stream_name); in soc_get_playback_capture()
2890 dev_warn(rtd->card->dev, in soc_get_playback_capture()
2905 * soc.h :: [dai_link->ch_maps Image sample] in soc_get_playback_capture()
2908 cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu); in soc_get_playback_capture()
2909 codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec); in soc_get_playback_capture()
2920 if (dai_link->playback_only) in soc_get_playback_capture()
2923 if (dai_link->capture_only) in soc_get_playback_capture()
2927 dev_err(rtd->dev, "substream %s has no playback, no capture\n", in soc_get_playback_capture()
2928 dai_link->stream_name); in soc_get_playback_capture()
2930 return -EINVAL; in soc_get_playback_capture()
2947 if (rtd->dai_link->c2c_params) { in soc_create_pcm()
2949 rtd->dai_link->stream_name); in soc_create_pcm()
2951 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, in soc_create_pcm()
2953 } else if (rtd->dai_link->no_pcm) { in soc_create_pcm()
2955 rtd->dai_link->stream_name); in soc_create_pcm()
2957 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, in soc_create_pcm()
2960 if (rtd->dai_link->dynamic) in soc_create_pcm()
2962 rtd->dai_link->stream_name); in soc_create_pcm()
2964 snprintf(new_name, sizeof(new_name), "%s %s-%d", in soc_create_pcm()
2965 rtd->dai_link->stream_name, in soc_create_pcm()
2968 ret = snd_pcm_new(rtd->card->snd_card, new_name, num, playback, in soc_create_pcm()
2972 dev_err(rtd->card->dev, "ASoC: can't create pcm %s for dailink %s: %d\n", in soc_create_pcm()
2973 new_name, rtd->dai_link->name, ret); in soc_create_pcm()
2976 dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n",num, new_name); in soc_create_pcm()
2997 /* DAPM dai link stream work */ in soc_new_pcm()
3004 if (!rtd->dai_link->c2c_params) in soc_new_pcm()
3005 rtd->close_delayed_work_func = snd_soc_close_delayed_work; in soc_new_pcm()
3007 rtd->pcm = pcm; in soc_new_pcm()
3008 pcm->nonatomic = rtd->dai_link->nonatomic; in soc_new_pcm()
3009 pcm->private_data = rtd; in soc_new_pcm()
3010 pcm->no_device_suspend = true; in soc_new_pcm()
3012 if (rtd->dai_link->no_pcm || rtd->dai_link->c2c_params) { in soc_new_pcm()
3014 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd; in soc_new_pcm()
3016 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd; in soc_new_pcm()
3021 if (rtd->dai_link->dynamic) { in soc_new_pcm()
3022 rtd->ops.open = dpcm_fe_dai_open; in soc_new_pcm()
3023 rtd->ops.hw_params = dpcm_fe_dai_hw_params; in soc_new_pcm()
3024 rtd->ops.prepare = dpcm_fe_dai_prepare; in soc_new_pcm()
3025 rtd->ops.trigger = dpcm_fe_dai_trigger; in soc_new_pcm()
3026 rtd->ops.hw_free = dpcm_fe_dai_hw_free; in soc_new_pcm()
3027 rtd->ops.close = dpcm_fe_dai_close; in soc_new_pcm()
3028 rtd->ops.pointer = soc_pcm_pointer; in soc_new_pcm()
3030 rtd->ops.open = soc_pcm_open; in soc_new_pcm()
3031 rtd->ops.hw_params = soc_pcm_hw_params; in soc_new_pcm()
3032 rtd->ops.prepare = soc_pcm_prepare; in soc_new_pcm()
3033 rtd->ops.trigger = soc_pcm_trigger; in soc_new_pcm()
3034 rtd->ops.hw_free = soc_pcm_hw_free; in soc_new_pcm()
3035 rtd->ops.close = soc_pcm_close; in soc_new_pcm()
3036 rtd->ops.pointer = soc_pcm_pointer; in soc_new_pcm()
3040 const struct snd_soc_component_driver *drv = component->driver; in soc_new_pcm()
3042 if (drv->ioctl) in soc_new_pcm()
3043 rtd->ops.ioctl = snd_soc_pcm_component_ioctl; in soc_new_pcm()
3044 if (drv->sync_stop) in soc_new_pcm()
3045 rtd->ops.sync_stop = snd_soc_pcm_component_sync_stop; in soc_new_pcm()
3046 if (drv->copy) in soc_new_pcm()
3047 rtd->ops.copy = snd_soc_pcm_component_copy; in soc_new_pcm()
3048 if (drv->page) in soc_new_pcm()
3049 rtd->ops.page = snd_soc_pcm_component_page; in soc_new_pcm()
3050 if (drv->mmap) in soc_new_pcm()
3051 rtd->ops.mmap = snd_soc_pcm_component_mmap; in soc_new_pcm()
3052 if (drv->ack) in soc_new_pcm()
3053 rtd->ops.ack = snd_soc_pcm_component_ack; in soc_new_pcm()
3057 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &rtd->ops); in soc_new_pcm()
3060 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops); in soc_new_pcm()
3066 dev_dbg(rtd->card->dev, "%s <-> %s mapping ok\n", in soc_new_pcm()
3075 return be->pcm->streams[stream].substream; in snd_soc_dpcm_get_substream()