Lines Matching full:rtd
29 #define soc_pcm_ret(rtd, ret) _soc_pcm_ret(rtd, __func__, ret) argument
30 static inline int _soc_pcm_ret(struct snd_soc_pcm_runtime *rtd, in _soc_pcm_ret() argument
43 dev_err(rtd->dev, in _soc_pcm_ret()
45 func, rtd->dai_link->name, ret); in _soc_pcm_ret()
51 static inline void snd_soc_dpcm_stream_lock_irq(struct snd_soc_pcm_runtime *rtd, in snd_soc_dpcm_stream_lock_irq() argument
54 snd_pcm_stream_lock_irq(snd_soc_dpcm_get_substream(rtd, stream)); in snd_soc_dpcm_stream_lock_irq()
57 #define snd_soc_dpcm_stream_lock_irqsave_nested(rtd, stream, flags) \ argument
58 snd_pcm_stream_lock_irqsave_nested(snd_soc_dpcm_get_substream(rtd, stream), flags)
60 static inline void snd_soc_dpcm_stream_unlock_irq(struct snd_soc_pcm_runtime *rtd, in snd_soc_dpcm_stream_unlock_irq() argument
63 snd_pcm_stream_unlock_irq(snd_soc_dpcm_get_substream(rtd, stream)); in snd_soc_dpcm_stream_unlock_irq()
66 #define snd_soc_dpcm_stream_unlock_irqrestore(rtd, stream, flags) \ argument
67 snd_pcm_stream_unlock_irqrestore(snd_soc_dpcm_get_substream(rtd, stream), flags)
71 static inline const char *soc_cpu_dai_name(struct snd_soc_pcm_runtime *rtd) in soc_cpu_dai_name() argument
73 return (rtd)->dai_link->num_cpus == 1 ? asoc_rtd_to_cpu(rtd, 0)->name : "multicpu"; in soc_cpu_dai_name()
75 static inline const char *soc_codec_dai_name(struct snd_soc_pcm_runtime *rtd) in soc_codec_dai_name() argument
77 return (rtd)->dai_link->num_codecs == 1 ? asoc_rtd_to_codec(rtd, 0)->name : "multicodec"; in soc_codec_dai_name()
204 void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd) in soc_dpcm_debugfs_add() argument
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()
216 rtd, &dpcm_state_fops); in soc_dpcm_debugfs_add()
281 * @rtd: ASoC PCM runtime that is activated
289 * Must be called with the rtd->card->pcm_mutex being held
291 void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd, in snd_soc_runtime_action() argument
297 snd_soc_dpcm_mutex_assert_held(rtd); in snd_soc_runtime_action()
299 for_each_rtd_dais(rtd, i, dai) in snd_soc_runtime_action()
306 * @rtd: The ASoC PCM runtime that should be checked.
313 bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd) in snd_soc_runtime_ignore_pmdown_time() argument
319 if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time) in snd_soc_runtime_ignore_pmdown_time()
322 for_each_rtd_components(rtd, i, component) in snd_soc_runtime_ignore_pmdown_time()
388 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_apply_symmetry() local
396 rtd->dai_link->symmetric_##name)) { \ in soc_pcm_apply_symmetry()
421 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_params_symmetry() local
431 symmetry = rtd->dai_link->symmetric_##xxx; \ in soc_pcm_params_symmetry()
432 for_each_rtd_dais(rtd, i, dai) \ in soc_pcm_params_symmetry()
436 for_each_rtd_cpu_dais(rtd, i, cpu_dai) \ in soc_pcm_params_symmetry()
439 dev_err(rtd->dev, "ASoC: unmatched %s symmetry: %s:%d - %s:%d\n", \ in soc_pcm_params_symmetry()
454 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_update_symmetry() local
455 struct snd_soc_dai_link *link = rtd->dai_link; in soc_pcm_update_symmetry()
463 for_each_rtd_dais(rtd, i, dai) in soc_pcm_update_symmetry()
475 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_set_msb() local
483 dev_warn(rtd->dev, "ASoC: Failed to set MSB %d: %d\n", in soc_pcm_set_msb()
489 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_apply_msb() local
496 for_each_rtd_codec_dais(rtd, i, codec_dai) { in soc_pcm_apply_msb()
506 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { in soc_pcm_apply_msb()
558 * @rtd: ASoC PCM runtime
565 int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd, in snd_soc_runtime_calc_hw() argument
578 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { in snd_soc_runtime_calc_hw()
599 for_each_rtd_codec_dais(rtd, i, codec_dai) { in snd_soc_runtime_calc_hw()
626 if (rtd->dai_link->num_codecs > 1) { in snd_soc_runtime_calc_hw()
638 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_init_runtime_hw() local
646 snd_soc_runtime_calc_hw(rtd, hw, substream->stream); in soc_pcm_init_runtime_hw()
654 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_components_open() local
658 for_each_rtd_components(rtd, i, component) { in soc_pcm_components_open()
674 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_components_close() local
678 for_each_rtd_components(rtd, i, component) { in soc_pcm_components_close()
689 static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd, in soc_pcm_clean() argument
696 snd_soc_dpcm_mutex_assert_held(rtd); in soc_pcm_clean()
699 snd_soc_runtime_deactivate(rtd, substream->stream); in soc_pcm_clean()
702 for_each_rtd_dais(rtd, i, dai) in soc_pcm_clean()
708 for_each_rtd_dais(rtd, i, dai) in soc_pcm_clean()
715 snd_soc_pcm_component_pm_runtime_put(rtd, substream, rollback); in soc_pcm_clean()
717 for_each_rtd_components(rtd, i, component) in soc_pcm_clean()
729 static int __soc_pcm_close(struct snd_soc_pcm_runtime *rtd, in __soc_pcm_close() argument
732 return soc_pcm_clean(rtd, substream, 0); in __soc_pcm_close()
738 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_close() local
740 snd_soc_dpcm_mutex_lock(rtd); in soc_pcm_close()
741 __soc_pcm_close(rtd, substream); in soc_pcm_close()
742 snd_soc_dpcm_mutex_unlock(rtd); in soc_pcm_close()
748 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_hw_sanity_check() local
750 const char *name_cpu = soc_cpu_dai_name(rtd); in soc_hw_sanity_check()
751 const char *name_codec = soc_codec_dai_name(rtd); in soc_hw_sanity_check()
753 struct device *dev = rtd->dev; in soc_hw_sanity_check()
789 static int __soc_pcm_open(struct snd_soc_pcm_runtime *rtd, in __soc_pcm_open() argument
796 snd_soc_dpcm_mutex_assert_held(rtd); in __soc_pcm_open()
798 for_each_rtd_components(rtd, i, component) in __soc_pcm_open()
801 ret = snd_soc_pcm_component_pm_runtime_get(rtd, substream); in __soc_pcm_open()
814 for_each_rtd_dais(rtd, i, dai) { in __soc_pcm_open()
821 if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) in __soc_pcm_open()
836 for_each_rtd_dais(rtd, i, dai) { in __soc_pcm_open()
842 snd_soc_runtime_activate(rtd, substream->stream); in __soc_pcm_open()
846 soc_pcm_clean(rtd, substream, 1); in __soc_pcm_open()
848 return soc_pcm_ret(rtd, ret); in __soc_pcm_open()
854 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_open() local
857 snd_soc_dpcm_mutex_lock(rtd); in soc_pcm_open()
858 ret = __soc_pcm_open(rtd, substream); in soc_pcm_open()
859 snd_soc_dpcm_mutex_unlock(rtd); in soc_pcm_open()
868 static int __soc_pcm_prepare(struct snd_soc_pcm_runtime *rtd, in __soc_pcm_prepare() argument
874 snd_soc_dpcm_mutex_assert_held(rtd); 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()
898 for_each_rtd_dais(rtd, i, dai) { in __soc_pcm_prepare()
916 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_prepare() local
919 snd_soc_dpcm_mutex_lock(rtd); in soc_pcm_prepare()
920 ret = __soc_pcm_prepare(rtd, substream); in soc_pcm_prepare()
921 snd_soc_dpcm_mutex_unlock(rtd); in soc_pcm_prepare()
943 static int soc_pcm_hw_clean(struct snd_soc_pcm_runtime *rtd, in soc_pcm_hw_clean() argument
949 snd_soc_dpcm_mutex_assert_held(rtd); in soc_pcm_hw_clean()
952 for_each_rtd_dais(rtd, i, dai) { in soc_pcm_hw_clean()
963 snd_soc_dapm_stream_stop(rtd, substream->stream); in soc_pcm_hw_clean()
972 for_each_rtd_dais(rtd, i, dai) in soc_pcm_hw_clean()
982 static int __soc_pcm_hw_free(struct snd_soc_pcm_runtime *rtd, in __soc_pcm_hw_free() argument
985 return soc_pcm_hw_clean(rtd, substream, 0); in __soc_pcm_hw_free()
991 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_hw_free() local
994 snd_soc_dpcm_mutex_lock(rtd); in soc_pcm_hw_free()
995 ret = __soc_pcm_hw_free(rtd, substream); in soc_pcm_hw_free()
996 snd_soc_dpcm_mutex_unlock(rtd); in soc_pcm_hw_free()
1005 static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd, in __soc_pcm_hw_params() argument
1014 snd_soc_dpcm_mutex_assert_held(rtd); in __soc_pcm_hw_params()
1024 for_each_rtd_codec_dais(rtd, i, codec_dai) { in __soc_pcm_hw_params()
1060 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { in __soc_pcm_hw_params()
1074 if (!rtd->dai_link->codec_ch_maps) in __soc_pcm_hw_params()
1080 for_each_rtd_codec_dais(rtd, j, codec_dai) { 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()
1102 soc_pcm_hw_clean(rtd, substream, 1); in __soc_pcm_hw_params()
1104 return soc_pcm_ret(rtd, ret); in __soc_pcm_hw_params()
1111 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_hw_params() local
1114 snd_soc_dpcm_mutex_lock(rtd); in soc_pcm_hw_params()
1115 ret = __soc_pcm_hw_params(rtd, substream, params); in soc_pcm_hw_params()
1116 snd_soc_dpcm_mutex_unlock(rtd); in soc_pcm_hw_params()
1136 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_trigger() local
1145 for_each_rtd_components(rtd, i, component) { 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()
1403 struct snd_soc_pcm_runtime *rtd; in dpcm_end_walk_at_be() local
1412 rtd = dpcm_get_be(card, widget, stream); in dpcm_end_walk_at_be()
1413 if (rtd) in dpcm_end_walk_at_be()
1526 /* is there a valid BE rtd for this widget */ in dpcm_add_paths()
1877 struct snd_soc_pcm_runtime *rtd; in dpcm_apply_symmetry() local
1884 rtd = asoc_substream_to_rtd(be_substream); in dpcm_apply_symmetry()
1885 if (rtd->dai_link->be_hw_params_fixup) in dpcm_apply_symmetry()
1891 for_each_rtd_dais(rtd, i, dai) { in dpcm_apply_symmetry()
2801 static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, in soc_get_playback_capture() argument
2804 struct snd_soc_dai_link *dai_link = rtd->dai_link; 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()
2821 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { in soc_get_playback_capture()
2828 dev_err(rtd->card->dev, in soc_get_playback_capture()
2837 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { in soc_get_playback_capture()
2845 dev_err(rtd->card->dev, in soc_get_playback_capture()
2858 for_each_rtd_codec_dais(rtd, i, codec_dai) { in soc_get_playback_capture()
2860 cpu_dai = asoc_rtd_to_cpu(rtd, 0); in soc_get_playback_capture()
2862 cpu_dai = asoc_rtd_to_cpu(rtd, i); 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()
2872 cpu_id = rtd->dai_link->codec_ch_maps[i].connected_cpu_id; in soc_get_playback_capture()
2873 cpu_dai = asoc_rtd_to_cpu(rtd, 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()
2898 dev_err(rtd->dev, "substream %s has no playback, no capture\n", in soc_get_playback_capture()
2911 struct snd_soc_pcm_runtime *rtd, 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()
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
2960 ret = soc_get_playback_capture(rtd, &playback, &capture); in soc_new_pcm()
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()
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()
3010 for_each_rtd_components(rtd, i, component) { in soc_new_pcm()
3014 rtd->ops.ioctl = snd_soc_pcm_component_ioctl; in soc_new_pcm()
3016 rtd->ops.sync_stop = snd_soc_pcm_component_sync_stop; in soc_new_pcm()
3018 rtd->ops.copy = snd_soc_pcm_component_copy; in soc_new_pcm()
3020 rtd->ops.page = snd_soc_pcm_component_page; in soc_new_pcm()
3022 rtd->ops.mmap = snd_soc_pcm_component_mmap; 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()
3033 ret = snd_soc_pcm_component_new(rtd); in soc_new_pcm()
3037 dev_dbg(rtd->card->dev, "%s <-> %s mapping ok\n", in soc_new_pcm()
3038 soc_codec_dai_name(rtd), soc_cpu_dai_name(rtd)); in soc_new_pcm()