Lines Matching refs:rtd
30 static inline void snd_soc_dpcm_stream_lock_irq(struct snd_soc_pcm_runtime *rtd, in snd_soc_dpcm_stream_lock_irq() argument
33 snd_pcm_stream_lock_irq(snd_soc_dpcm_get_substream(rtd, stream)); in snd_soc_dpcm_stream_lock_irq()
36 #define snd_soc_dpcm_stream_lock_irqsave_nested(rtd, stream, flags) \ argument
37 snd_pcm_stream_lock_irqsave_nested(snd_soc_dpcm_get_substream(rtd, stream), flags)
39 static inline void snd_soc_dpcm_stream_unlock_irq(struct snd_soc_pcm_runtime *rtd, in snd_soc_dpcm_stream_unlock_irq() argument
42 snd_pcm_stream_unlock_irq(snd_soc_dpcm_get_substream(rtd, stream)); in snd_soc_dpcm_stream_unlock_irq()
45 #define snd_soc_dpcm_stream_unlock_irqrestore(rtd, stream, flags) \ argument
46 snd_pcm_stream_unlock_irqrestore(snd_soc_dpcm_get_substream(rtd, stream), flags)
50 static inline const char *soc_cpu_dai_name(struct snd_soc_pcm_runtime *rtd) in soc_cpu_dai_name() argument
52 return (rtd)->num_cpus == 1 ? asoc_rtd_to_cpu(rtd, 0)->name : "multicpu"; in soc_cpu_dai_name()
54 static inline const char *soc_codec_dai_name(struct snd_soc_pcm_runtime *rtd) in soc_codec_dai_name() argument
56 return (rtd)->num_codecs == 1 ? asoc_rtd_to_codec(rtd, 0)->name : "multicodec"; in soc_codec_dai_name()
183 void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd) in soc_dpcm_debugfs_add() argument
185 if (!rtd->dai_link->dynamic) in soc_dpcm_debugfs_add()
188 if (!rtd->card->debugfs_card_root) in soc_dpcm_debugfs_add()
191 rtd->debugfs_dpcm_root = debugfs_create_dir(rtd->dai_link->name, in soc_dpcm_debugfs_add()
192 rtd->card->debugfs_card_root); in soc_dpcm_debugfs_add()
194 debugfs_create_file("state", 0444, rtd->debugfs_dpcm_root, in soc_dpcm_debugfs_add()
195 rtd, &dpcm_state_fops); in soc_dpcm_debugfs_add()
270 void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd, in snd_soc_runtime_action() argument
276 snd_soc_dpcm_mutex_assert_held(rtd); in snd_soc_runtime_action()
278 for_each_rtd_dais(rtd, i, dai) in snd_soc_runtime_action()
292 bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd) in snd_soc_runtime_ignore_pmdown_time() argument
298 if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time) in snd_soc_runtime_ignore_pmdown_time()
301 for_each_rtd_components(rtd, i, component) in snd_soc_runtime_ignore_pmdown_time()
367 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_apply_symmetry() local
375 rtd->dai_link->symmetric_##name)) { \ in soc_pcm_apply_symmetry()
400 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_params_symmetry() local
410 symmetry = rtd->dai_link->symmetric_##xxx; \ in soc_pcm_params_symmetry()
411 for_each_rtd_dais(rtd, i, dai) \ in soc_pcm_params_symmetry()
415 for_each_rtd_cpu_dais(rtd, i, cpu_dai) \ in soc_pcm_params_symmetry()
418 dev_err(rtd->dev, "ASoC: unmatched %s symmetry: %s:%d - %s:%d\n", \ in soc_pcm_params_symmetry()
433 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_update_symmetry() local
434 struct snd_soc_dai_link *link = rtd->dai_link; in soc_pcm_update_symmetry()
442 for_each_rtd_dais(rtd, i, dai) in soc_pcm_update_symmetry()
454 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_set_msb() local
462 dev_warn(rtd->dev, "ASoC: Failed to set MSB %d: %d\n", in soc_pcm_set_msb()
468 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_apply_msb() local
475 for_each_rtd_codec_dais(rtd, i, codec_dai) { in soc_pcm_apply_msb()
485 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { in soc_pcm_apply_msb()
544 int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd, in snd_soc_runtime_calc_hw() argument
557 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { in snd_soc_runtime_calc_hw()
578 for_each_rtd_codec_dais(rtd, i, codec_dai) { in snd_soc_runtime_calc_hw()
605 if (rtd->num_codecs > 1) { in snd_soc_runtime_calc_hw()
617 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_init_runtime_hw() local
625 snd_soc_runtime_calc_hw(rtd, hw, substream->stream); in soc_pcm_init_runtime_hw()
633 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_components_open() local
637 for_each_rtd_components(rtd, i, component) { in soc_pcm_components_open()
653 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_components_close() local
657 for_each_rtd_components(rtd, i, component) { in soc_pcm_components_close()
668 static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd, in soc_pcm_clean() argument
675 snd_soc_dpcm_mutex_assert_held(rtd); in soc_pcm_clean()
678 snd_soc_runtime_deactivate(rtd, substream->stream); in soc_pcm_clean()
680 for_each_rtd_dais(rtd, i, dai) in soc_pcm_clean()
687 snd_soc_pcm_component_pm_runtime_put(rtd, substream, rollback); in soc_pcm_clean()
689 for_each_rtd_components(rtd, i, component) in soc_pcm_clean()
701 static int __soc_pcm_close(struct snd_soc_pcm_runtime *rtd, in __soc_pcm_close() argument
704 return soc_pcm_clean(rtd, substream, 0); in __soc_pcm_close()
710 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_close() local
712 snd_soc_dpcm_mutex_lock(rtd); in soc_pcm_close()
713 __soc_pcm_close(rtd, substream); in soc_pcm_close()
714 snd_soc_dpcm_mutex_unlock(rtd); in soc_pcm_close()
720 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_hw_sanity_check() local
722 const char *name_cpu = soc_cpu_dai_name(rtd); in soc_hw_sanity_check()
723 const char *name_codec = soc_codec_dai_name(rtd); in soc_hw_sanity_check()
725 struct device *dev = rtd->dev; in soc_hw_sanity_check()
761 static int __soc_pcm_open(struct snd_soc_pcm_runtime *rtd, in __soc_pcm_open() argument
768 snd_soc_dpcm_mutex_assert_held(rtd); in __soc_pcm_open()
770 for_each_rtd_components(rtd, i, component) in __soc_pcm_open()
773 ret = snd_soc_pcm_component_pm_runtime_get(rtd, substream); in __soc_pcm_open()
786 for_each_rtd_dais(rtd, i, dai) { in __soc_pcm_open()
793 if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) in __soc_pcm_open()
808 for_each_rtd_dais(rtd, i, dai) { in __soc_pcm_open()
814 snd_soc_runtime_activate(rtd, substream->stream); in __soc_pcm_open()
818 soc_pcm_clean(rtd, substream, 1); in __soc_pcm_open()
819 dev_err(rtd->dev, "%s() failed (%d)", __func__, ret); in __soc_pcm_open()
828 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_open() local
831 snd_soc_dpcm_mutex_lock(rtd); in soc_pcm_open()
832 ret = __soc_pcm_open(rtd, substream); in soc_pcm_open()
833 snd_soc_dpcm_mutex_unlock(rtd); in soc_pcm_open()
837 static void codec2codec_close_delayed_work(struct snd_soc_pcm_runtime *rtd) in codec2codec_close_delayed_work() argument
852 static int __soc_pcm_prepare(struct snd_soc_pcm_runtime *rtd, in __soc_pcm_prepare() argument
858 snd_soc_dpcm_mutex_assert_held(rtd); in __soc_pcm_prepare()
874 rtd->pop_wait) { in __soc_pcm_prepare()
875 rtd->pop_wait = 0; in __soc_pcm_prepare()
876 cancel_delayed_work(&rtd->delayed_work); in __soc_pcm_prepare()
879 snd_soc_dapm_stream_event(rtd, substream->stream, in __soc_pcm_prepare()
882 for_each_rtd_dais(rtd, i, dai) in __soc_pcm_prepare()
887 dev_err(rtd->dev, "ASoC: %s() failed (%d)\n", __func__, ret); in __soc_pcm_prepare()
895 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_prepare() local
898 snd_soc_dpcm_mutex_lock(rtd); in soc_pcm_prepare()
899 ret = __soc_pcm_prepare(rtd, substream); in soc_pcm_prepare()
900 snd_soc_dpcm_mutex_unlock(rtd); in soc_pcm_prepare()
915 static int soc_pcm_hw_clean(struct snd_soc_pcm_runtime *rtd, in soc_pcm_hw_clean() argument
921 snd_soc_dpcm_mutex_assert_held(rtd); in soc_pcm_hw_clean()
924 for_each_rtd_dais(rtd, i, dai) { in soc_pcm_hw_clean()
935 snd_soc_dapm_stream_stop(rtd, substream->stream); in soc_pcm_hw_clean()
944 for_each_rtd_dais(rtd, i, dai) { in soc_pcm_hw_clean()
957 static int __soc_pcm_hw_free(struct snd_soc_pcm_runtime *rtd, in __soc_pcm_hw_free() argument
960 return soc_pcm_hw_clean(rtd, substream, 0); in __soc_pcm_hw_free()
966 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_hw_free() local
969 snd_soc_dpcm_mutex_lock(rtd); in soc_pcm_hw_free()
970 ret = __soc_pcm_hw_free(rtd, substream); in soc_pcm_hw_free()
971 snd_soc_dpcm_mutex_unlock(rtd); in soc_pcm_hw_free()
980 static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd, in __soc_pcm_hw_params() argument
988 snd_soc_dpcm_mutex_assert_held(rtd); in __soc_pcm_hw_params()
998 for_each_rtd_codec_dais(rtd, i, codec_dai) { in __soc_pcm_hw_params()
1041 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { in __soc_pcm_hw_params()
1061 soc_pcm_hw_clean(rtd, substream, 1); in __soc_pcm_hw_params()
1062 dev_err(rtd->dev, "ASoC: %s() failed (%d)\n", __func__, ret); in __soc_pcm_hw_params()
1072 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_hw_params() local
1075 snd_soc_dpcm_mutex_lock(rtd); in soc_pcm_hw_params()
1076 ret = __soc_pcm_hw_params(rtd, substream, params); in soc_pcm_hw_params()
1077 snd_soc_dpcm_mutex_unlock(rtd); in soc_pcm_hw_params()
1083 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_trigger() local
1124 if (rtd->dai_link->stop_dma_first) { in soc_pcm_trigger()
1158 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); in soc_pcm_pointer() local
1176 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { in soc_pcm_pointer()
1182 for_each_rtd_codec_dais(rtd, i, codec_dai) { in soc_pcm_pointer()
1364 struct snd_soc_pcm_runtime *rtd; in dpcm_end_walk_at_be() local
1373 rtd = dpcm_get_be(card, widget, stream); in dpcm_end_walk_at_be()
1374 if (rtd) in dpcm_end_walk_at_be()
1825 struct snd_soc_pcm_runtime *rtd; in dpcm_apply_symmetry() local
1832 rtd = asoc_substream_to_rtd(be_substream); in dpcm_apply_symmetry()
1833 if (rtd->dai_link->be_hw_params_fixup) in dpcm_apply_symmetry()
1839 for_each_rtd_dais(rtd, i, dai) { in dpcm_apply_symmetry()
2729 static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, in soc_get_playback_capture() argument
2735 if (rtd->dai_link->dynamic && rtd->num_cpus > 1) { in soc_get_playback_capture()
2736 dev_err(rtd->dev, in soc_get_playback_capture()
2741 if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) { in soc_get_playback_capture()
2744 if (rtd->dai_link->dpcm_playback) { in soc_get_playback_capture()
2747 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { in soc_get_playback_capture()
2754 dev_err(rtd->card->dev, in soc_get_playback_capture()
2756 rtd->dai_link->stream_name); in soc_get_playback_capture()
2760 if (rtd->dai_link->dpcm_capture) { in soc_get_playback_capture()
2763 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { in soc_get_playback_capture()
2771 dev_err(rtd->card->dev, in soc_get_playback_capture()
2773 rtd->dai_link->stream_name); in soc_get_playback_capture()
2781 int cpu_capture = rtd->dai_link->params ? in soc_get_playback_capture()
2783 int cpu_playback = rtd->dai_link->params ? in soc_get_playback_capture()
2786 for_each_rtd_codec_dais(rtd, i, codec_dai) { in soc_get_playback_capture()
2787 if (rtd->num_cpus == 1) { in soc_get_playback_capture()
2788 cpu_dai = asoc_rtd_to_cpu(rtd, 0); in soc_get_playback_capture()
2789 } else if (rtd->num_cpus == rtd->num_codecs) { in soc_get_playback_capture()
2790 cpu_dai = asoc_rtd_to_cpu(rtd, i); in soc_get_playback_capture()
2792 dev_err(rtd->card->dev, in soc_get_playback_capture()
2806 if (rtd->dai_link->playback_only) { in soc_get_playback_capture()
2811 if (rtd->dai_link->capture_only) { in soc_get_playback_capture()
2820 struct snd_soc_pcm_runtime *rtd, in soc_create_pcm() argument
2827 if (rtd->dai_link->params) { in soc_create_pcm()
2829 rtd->dai_link->stream_name); in soc_create_pcm()
2831 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, in soc_create_pcm()
2833 } else if (rtd->dai_link->no_pcm) { in soc_create_pcm()
2835 rtd->dai_link->stream_name); in soc_create_pcm()
2837 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, in soc_create_pcm()
2840 if (rtd->dai_link->dynamic) in soc_create_pcm()
2842 rtd->dai_link->stream_name); in soc_create_pcm()
2845 rtd->dai_link->stream_name, in soc_create_pcm()
2846 soc_codec_dai_name(rtd), num); in soc_create_pcm()
2848 ret = snd_pcm_new(rtd->card->snd_card, new_name, num, playback, in soc_create_pcm()
2852 dev_err(rtd->card->dev, "ASoC: can't create pcm %s for dailink %s: %d\n", in soc_create_pcm()
2853 new_name, rtd->dai_link->name, ret); in soc_create_pcm()
2856 dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n",num, new_name); in soc_create_pcm()
2862 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) in soc_new_pcm() argument
2869 ret = soc_get_playback_capture(rtd, &playback, &capture); in soc_new_pcm()
2873 ret = soc_create_pcm(&pcm, rtd, playback, capture, num); in soc_new_pcm()
2878 if (rtd->dai_link->params) in soc_new_pcm()
2879 rtd->close_delayed_work_func = codec2codec_close_delayed_work; in soc_new_pcm()
2881 rtd->close_delayed_work_func = snd_soc_close_delayed_work; in soc_new_pcm()
2883 rtd->pcm = pcm; in soc_new_pcm()
2884 pcm->nonatomic = rtd->dai_link->nonatomic; in soc_new_pcm()
2885 pcm->private_data = rtd; in soc_new_pcm()
2887 if (rtd->dai_link->no_pcm || rtd->dai_link->params) { in soc_new_pcm()
2889 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd; in soc_new_pcm()
2891 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd; in soc_new_pcm()
2896 if (rtd->dai_link->dynamic) { in soc_new_pcm()
2897 rtd->ops.open = dpcm_fe_dai_open; in soc_new_pcm()
2898 rtd->ops.hw_params = dpcm_fe_dai_hw_params; in soc_new_pcm()
2899 rtd->ops.prepare = dpcm_fe_dai_prepare; in soc_new_pcm()
2900 rtd->ops.trigger = dpcm_fe_dai_trigger; in soc_new_pcm()
2901 rtd->ops.hw_free = dpcm_fe_dai_hw_free; in soc_new_pcm()
2902 rtd->ops.close = dpcm_fe_dai_close; in soc_new_pcm()
2903 rtd->ops.pointer = soc_pcm_pointer; in soc_new_pcm()
2905 rtd->ops.open = soc_pcm_open; in soc_new_pcm()
2906 rtd->ops.hw_params = soc_pcm_hw_params; in soc_new_pcm()
2907 rtd->ops.prepare = soc_pcm_prepare; in soc_new_pcm()
2908 rtd->ops.trigger = soc_pcm_trigger; in soc_new_pcm()
2909 rtd->ops.hw_free = soc_pcm_hw_free; in soc_new_pcm()
2910 rtd->ops.close = soc_pcm_close; in soc_new_pcm()
2911 rtd->ops.pointer = soc_pcm_pointer; in soc_new_pcm()
2914 for_each_rtd_components(rtd, i, component) { in soc_new_pcm()
2918 rtd->ops.ioctl = snd_soc_pcm_component_ioctl; in soc_new_pcm()
2920 rtd->ops.sync_stop = snd_soc_pcm_component_sync_stop; in soc_new_pcm()
2922 rtd->ops.copy_user = snd_soc_pcm_component_copy_user; in soc_new_pcm()
2924 rtd->ops.page = snd_soc_pcm_component_page; in soc_new_pcm()
2926 rtd->ops.mmap = snd_soc_pcm_component_mmap; in soc_new_pcm()
2928 rtd->ops.ack = snd_soc_pcm_component_ack; in soc_new_pcm()
2932 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &rtd->ops); in soc_new_pcm()
2935 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops); in soc_new_pcm()
2937 ret = snd_soc_pcm_component_new(rtd); in soc_new_pcm()
2943 dev_dbg(rtd->card->dev, "%s <-> %s mapping ok\n", in soc_new_pcm()
2944 soc_codec_dai_name(rtd), soc_cpu_dai_name(rtd)); in soc_new_pcm()