Lines Matching refs:rtd

29 #define soc_pcm_ret(rtd, ret) _soc_pcm_ret(rtd, __func__, ret)
30 static inline int _soc_pcm_ret(struct snd_soc_pcm_runtime *rtd,
33 return snd_soc_ret(rtd->dev, ret,
34 "at %s() on %s\n", func, rtd->dai_link->name);
138 static inline const char *soc_cpu_dai_name(struct snd_soc_pcm_runtime *rtd)
140 return (rtd)->dai_link->num_cpus == 1 ? snd_soc_rtd_to_cpu(rtd, 0)->name : "multicpu";
142 static inline const char *soc_codec_dai_name(struct snd_soc_pcm_runtime *rtd)
144 return (rtd)->dai_link->num_codecs == 1 ? snd_soc_rtd_to_codec(rtd, 0)->name : "multicodec";
269 void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd)
271 if (!rtd->dai_link->dynamic)
274 if (!rtd->card->debugfs_card_root)
277 rtd->debugfs_dpcm_root = debugfs_create_dir(rtd->dai_link->name,
278 rtd->card->debugfs_card_root);
280 debugfs_create_file("state", 0444, rtd->debugfs_dpcm_root,
281 rtd, &dpcm_state_fops);
346 * @rtd: ASoC PCM runtime that is activated
354 * Must be called with the rtd->card->pcm_mutex being held
356 void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
363 snd_soc_dpcm_mutex_assert_held(rtd);
365 for_each_rtd_dais(rtd, i, dai)
369 for_each_rtd_components(rtd, i, component) {
379 * @rtd: The ASoC PCM runtime that should be checked.
386 bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd)
391 if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time)
394 for_each_rtd_components(rtd, i, component)
443 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
451 (soc_dai->driver->symmetric_##name || rtd->dai_link->symmetric_##name)) { \
473 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
483 symmetry = rtd->dai_link->symmetric_##xxx; \
484 for_each_rtd_dais(rtd, i, dai) \
488 for_each_rtd_cpu_dais(rtd, i, cpu_dai) \
492 return snd_soc_ret(rtd->dev, -EINVAL, \
507 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
508 struct snd_soc_dai_link *link = rtd->dai_link;
516 for_each_rtd_dais(rtd, i, dai)
528 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
536 dev_warn(rtd->dev, "ASoC: Failed to set MSB %d: %d\n",
542 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
549 for_each_rtd_codec_dais(rtd, i, codec_dai) {
559 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
612 * @rtd: ASoC PCM runtime
619 int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
632 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
653 for_each_rtd_codec_dais(rtd, i, codec_dai) {
680 if (rtd->dai_link->num_codecs > 1) {
692 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
700 snd_soc_runtime_calc_hw(rtd, hw, substream->stream);
708 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
712 for_each_rtd_components(rtd, i, component) {
728 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
732 for_each_rtd_components(rtd, i, component) {
743 static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd,
750 snd_soc_dpcm_mutex_assert_held(rtd);
753 snd_soc_runtime_deactivate(rtd, substream->stream);
756 for_each_rtd_dais(rtd, i, dai) {
762 for_each_rtd_dais_reverse(rtd, i, dai)
769 snd_soc_pcm_component_pm_runtime_put(rtd, substream, rollback);
771 for_each_rtd_components(rtd, i, component)
783 static int __soc_pcm_close(struct snd_soc_pcm_runtime *rtd,
786 return soc_pcm_clean(rtd, substream, 0);
792 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
794 snd_soc_dpcm_mutex_lock(rtd);
795 __soc_pcm_close(rtd, substream);
796 snd_soc_dpcm_mutex_unlock(rtd);
802 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
804 const char *name_cpu = soc_cpu_dai_name(rtd);
805 const char *name_codec = soc_codec_dai_name(rtd);
807 struct device *dev = rtd->dev;
842 static int __soc_pcm_open(struct snd_soc_pcm_runtime *rtd,
849 snd_soc_dpcm_mutex_assert_held(rtd);
851 for_each_rtd_components(rtd, i, component)
854 ret = snd_soc_pcm_component_pm_runtime_get(rtd, substream);
867 for_each_rtd_dais(rtd, i, dai) {
874 if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm)
889 for_each_rtd_dais(rtd, i, dai) {
895 snd_soc_runtime_activate(rtd, substream->stream);
899 soc_pcm_clean(rtd, substream, 1);
901 return soc_pcm_ret(rtd, ret);
907 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
910 snd_soc_dpcm_mutex_lock(rtd);
911 ret = __soc_pcm_open(rtd, substream);
912 snd_soc_dpcm_mutex_unlock(rtd);
921 static int __soc_pcm_prepare(struct snd_soc_pcm_runtime *rtd,
927 snd_soc_dpcm_mutex_assert_held(rtd);
943 rtd->pop_wait) {
944 rtd->pop_wait = 0;
945 cancel_delayed_work(&rtd->delayed_work);
948 snd_soc_dapm_stream_event(rtd, substream->stream,
951 for_each_rtd_dais(rtd, i, dai) {
969 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
972 snd_soc_dpcm_mutex_lock(rtd);
973 ret = __soc_pcm_prepare(rtd, substream);
974 snd_soc_dpcm_mutex_unlock(rtd);
996 static int soc_pcm_hw_clean(struct snd_soc_pcm_runtime *rtd,
1002 snd_soc_dpcm_mutex_assert_held(rtd);
1005 for_each_rtd_dais(rtd, i, dai) {
1016 snd_soc_dapm_stream_stop(rtd, substream->stream);
1025 for_each_rtd_dais(rtd, i, dai)
1035 static int __soc_pcm_hw_free(struct snd_soc_pcm_runtime *rtd,
1038 return soc_pcm_hw_clean(rtd, substream, 0);
1044 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1047 snd_soc_dpcm_mutex_lock(rtd);
1048 ret = __soc_pcm_hw_free(rtd, substream);
1049 snd_soc_dpcm_mutex_unlock(rtd);
1061 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1067 snd_soc_dpcm_mutex_assert_held(rtd);
1077 for_each_rtd_codec_dais(rtd, i, codec_dai) {
1113 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
1134 for_each_rtd_ch_maps(rtd, j, ch_maps)
1154 soc_pcm_hw_clean(rtd, substream, 1);
1156 return soc_pcm_ret(rtd, ret);
1163 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1166 snd_soc_dpcm_mutex_lock(rtd);
1168 snd_soc_dpcm_mutex_unlock(rtd);
1188 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1197 for_each_rtd_components(rtd, i, component) {
1203 if (rtd->dai_link->trigger_start)
1204 start = rtd->dai_link->trigger_start;
1205 if (rtd->dai_link->trigger_stop)
1206 stop = rtd->dai_link->trigger_stop;
1455 struct snd_soc_pcm_runtime *rtd;
1464 rtd = dpcm_get_be(card, widget, stream);
1465 if (rtd)
1576 /* is there a valid BE rtd for this widget */
1914 struct snd_soc_pcm_runtime *rtd;
1921 rtd = snd_soc_substream_to_rtd(be_substream);
1922 if (rtd->dai_link->be_hw_params_fixup)
1928 for_each_rtd_dais(rtd, i, dai) {
2791 static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
2794 struct snd_soc_dai_link *dai_link = rtd->dai_link;
2806 return snd_soc_ret(rtd->dev, -EINVAL,
2817 for_each_rtd_ch_maps(rtd, i, ch_maps) {
2818 cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu);
2819 codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec);
2850 return snd_soc_ret(rtd->dev, -EINVAL,
2860 struct snd_soc_pcm_runtime *rtd,
2867 if (rtd->dai_link->c2c_params) {
2869 rtd->dai_link->stream_name);
2871 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, rtd->id,
2873 } else if (rtd->dai_link->no_pcm) {
2875 rtd->dai_link->stream_name);
2877 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, rtd->id,
2880 if (rtd->dai_link->dynamic)
2882 rtd->dai_link->stream_name);
2885 rtd->dai_link->stream_name,
2886 soc_codec_dai_name(rtd), rtd->id);
2888 ret = snd_pcm_new(rtd->card->snd_card, new_name, rtd->id, playback,
2892 return snd_soc_ret(rtd->dev, ret,
2893 "can't create pcm %s for dailink %s\n", new_name, rtd->dai_link->name);
2895 dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n", rtd->id, new_name);
2901 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd)
2908 ret = soc_get_playback_capture(rtd, &playback, &capture);
2912 ret = soc_create_pcm(&pcm, rtd, playback, capture);
2923 if (!rtd->dai_link->c2c_params)
2924 rtd->close_delayed_work_func = snd_soc_close_delayed_work;
2926 rtd->pcm = pcm;
2927 pcm->nonatomic = rtd->dai_link->nonatomic;
2928 pcm->private_data = rtd;
2931 if (rtd->dai_link->no_pcm || rtd->dai_link->c2c_params) {
2933 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
2935 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd;
2940 if (rtd->dai_link->dynamic) {
2941 rtd->ops.open = dpcm_fe_dai_open;
2942 rtd->ops.hw_params = dpcm_fe_dai_hw_params;
2943 rtd->ops.prepare = dpcm_fe_dai_prepare;
2944 rtd->ops.trigger = dpcm_fe_dai_trigger;
2945 rtd->ops.hw_free = dpcm_fe_dai_hw_free;
2946 rtd->ops.close = dpcm_fe_dai_close;
2947 rtd->ops.pointer = soc_pcm_pointer;
2949 rtd->ops.open = soc_pcm_open;
2950 rtd->ops.hw_params = soc_pcm_hw_params;
2951 rtd->ops.prepare = soc_pcm_prepare;
2952 rtd->ops.trigger = soc_pcm_trigger;
2953 rtd->ops.hw_free = soc_pcm_hw_free;
2954 rtd->ops.close = soc_pcm_close;
2955 rtd->ops.pointer = soc_pcm_pointer;
2958 for_each_rtd_components(rtd, i, component) {
2962 rtd->ops.ioctl = snd_soc_pcm_component_ioctl;
2964 rtd->ops.sync_stop = snd_soc_pcm_component_sync_stop;
2966 rtd->ops.copy = snd_soc_pcm_component_copy;
2968 rtd->ops.page = snd_soc_pcm_component_page;
2970 rtd->ops.mmap = snd_soc_pcm_component_mmap;
2972 rtd->ops.ack = snd_soc_pcm_component_ack;
2976 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &rtd->ops);
2979 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
2981 ret = snd_soc_pcm_component_new(rtd);
2985 dev_dbg(rtd->card->dev, "%s <-> %s mapping ok\n",
2986 soc_codec_dai_name(rtd), soc_cpu_dai_name(rtd));