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,
44 dev_err(rtd->dev,
46 func, rtd->dai_link->name, ret);
52 static inline void snd_soc_dpcm_stream_lock_irq(struct snd_soc_pcm_runtime *rtd,
55 snd_pcm_stream_lock_irq(snd_soc_dpcm_get_substream(rtd, stream));
58 #define snd_soc_dpcm_stream_lock_irqsave_nested(rtd, stream, flags) \
59 snd_pcm_stream_lock_irqsave_nested(snd_soc_dpcm_get_substream(rtd, stream), flags)
61 static inline void snd_soc_dpcm_stream_unlock_irq(struct snd_soc_pcm_runtime *rtd,
64 snd_pcm_stream_unlock_irq(snd_soc_dpcm_get_substream(rtd, stream));
67 #define snd_soc_dpcm_stream_unlock_irqrestore(rtd, stream, flags) \
68 snd_pcm_stream_unlock_irqrestore(snd_soc_dpcm_get_substream(rtd, stream), flags)
72 static inline const char *soc_cpu_dai_name(struct snd_soc_pcm_runtime *rtd)
74 return (rtd)->dai_link->num_cpus == 1 ? asoc_rtd_to_cpu(rtd, 0)->name : "multicpu";
76 static inline const char *soc_codec_dai_name(struct snd_soc_pcm_runtime *rtd)
78 return (rtd)->dai_link->num_codecs == 1 ? asoc_rtd_to_codec(rtd, 0)->name : "multicodec";
205 void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd)
207 if (!rtd->dai_link->dynamic)
210 if (!rtd->card->debugfs_card_root)
213 rtd->debugfs_dpcm_root = debugfs_create_dir(rtd->dai_link->name,
214 rtd->card->debugfs_card_root);
216 debugfs_create_file("state", 0444, rtd->debugfs_dpcm_root,
217 rtd, &dpcm_state_fops);
282 * @rtd: ASoC PCM runtime that is activated
290 * Must be called with the rtd->card->pcm_mutex being held
292 void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
298 snd_soc_dpcm_mutex_assert_held(rtd);
300 for_each_rtd_dais(rtd, i, dai)
307 * @rtd: The ASoC PCM runtime that should be checked.
314 bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd)
320 if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time)
323 for_each_rtd_components(rtd, i, component)
389 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
397 rtd->dai_link->symmetric_##name)) { \
422 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
432 symmetry = rtd->dai_link->symmetric_##xxx; \
433 for_each_rtd_dais(rtd, i, dai) \
437 for_each_rtd_cpu_dais(rtd, i, cpu_dai) \
440 dev_err(rtd->dev, "ASoC: unmatched %s symmetry: %s:%d - %s:%d\n", \
455 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
456 struct snd_soc_dai_link *link = rtd->dai_link;
464 for_each_rtd_dais(rtd, i, dai)
476 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
484 dev_warn(rtd->dev, "ASoC: Failed to set MSB %d: %d\n",
490 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
497 for_each_rtd_codec_dais(rtd, i, codec_dai) {
507 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
559 * @rtd: ASoC PCM runtime
566 int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
579 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
600 for_each_rtd_codec_dais(rtd, i, codec_dai) {
627 if (rtd->dai_link->num_codecs > 1) {
639 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
647 snd_soc_runtime_calc_hw(rtd, hw, substream->stream);
655 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
659 for_each_rtd_components(rtd, i, component) {
675 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
679 for_each_rtd_components(rtd, i, component) {
690 static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd,
697 snd_soc_dpcm_mutex_assert_held(rtd);
700 snd_soc_runtime_deactivate(rtd, substream->stream);
703 for_each_rtd_dais(rtd, i, dai)
709 for_each_rtd_dais(rtd, i, dai)
716 snd_soc_pcm_component_pm_runtime_put(rtd, substream, rollback);
718 for_each_rtd_components(rtd, i, component)
730 static int __soc_pcm_close(struct snd_soc_pcm_runtime *rtd,
733 return soc_pcm_clean(rtd, substream, 0);
739 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
741 snd_soc_dpcm_mutex_lock(rtd);
742 __soc_pcm_close(rtd, substream);
743 snd_soc_dpcm_mutex_unlock(rtd);
749 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
751 const char *name_cpu = soc_cpu_dai_name(rtd);
752 const char *name_codec = soc_codec_dai_name(rtd);
754 struct device *dev = rtd->dev;
790 static int __soc_pcm_open(struct snd_soc_pcm_runtime *rtd,
797 snd_soc_dpcm_mutex_assert_held(rtd);
799 for_each_rtd_components(rtd, i, component)
802 ret = snd_soc_pcm_component_pm_runtime_get(rtd, substream);
815 for_each_rtd_dais(rtd, i, dai) {
822 if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm)
837 for_each_rtd_dais(rtd, i, dai) {
843 snd_soc_runtime_activate(rtd, substream->stream);
847 soc_pcm_clean(rtd, substream, 1);
849 return soc_pcm_ret(rtd, ret);
855 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
858 snd_soc_dpcm_mutex_lock(rtd);
859 ret = __soc_pcm_open(rtd, substream);
860 snd_soc_dpcm_mutex_unlock(rtd);
869 static int __soc_pcm_prepare(struct snd_soc_pcm_runtime *rtd,
875 snd_soc_dpcm_mutex_assert_held(rtd);
891 rtd->pop_wait) {
892 rtd->pop_wait = 0;
893 cancel_delayed_work(&rtd->delayed_work);
896 snd_soc_dapm_stream_event(rtd, substream->stream,
899 for_each_rtd_dais(rtd, i, dai) {
905 return soc_pcm_ret(rtd, ret);
911 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
914 snd_soc_dpcm_mutex_lock(rtd);
915 ret = __soc_pcm_prepare(rtd, substream);
916 snd_soc_dpcm_mutex_unlock(rtd);
931 static int soc_pcm_hw_clean(struct snd_soc_pcm_runtime *rtd,
937 snd_soc_dpcm_mutex_assert_held(rtd);
940 for_each_rtd_dais(rtd, i, dai) {
951 snd_soc_dapm_stream_stop(rtd, substream->stream);
960 for_each_rtd_dais(rtd, i, dai)
970 static int __soc_pcm_hw_free(struct snd_soc_pcm_runtime *rtd,
973 return soc_pcm_hw_clean(rtd, substream, 0);
979 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
982 snd_soc_dpcm_mutex_lock(rtd);
983 ret = __soc_pcm_hw_free(rtd, substream);
984 snd_soc_dpcm_mutex_unlock(rtd);
993 static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd,
1002 snd_soc_dpcm_mutex_assert_held(rtd);
1012 for_each_rtd_codec_dais(rtd, i, codec_dai) {
1048 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
1062 if (!rtd->dai_link->codec_ch_maps)
1068 for_each_rtd_codec_dais(rtd, j, codec_dai) {
1069 if (rtd->dai_link->codec_ch_maps[j].connected_cpu_id == i)
1070 ch_mask |= rtd->dai_link->codec_ch_maps[j].ch_mask;
1090 soc_pcm_hw_clean(rtd, substream, 1);
1092 return soc_pcm_ret(rtd, ret);
1099 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1102 snd_soc_dpcm_mutex_lock(rtd);
1103 ret = __soc_pcm_hw_params(rtd, substream, params);
1104 snd_soc_dpcm_mutex_unlock(rtd);
1124 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1133 for_each_rtd_components(rtd, i, component) {
1139 if (rtd->dai_link->trigger_start)
1140 start = rtd->dai_link->trigger_start;
1141 if (rtd->dai_link->trigger_stop)
1142 stop = rtd->dai_link->trigger_stop;
1391 struct snd_soc_pcm_runtime *rtd;
1400 rtd = dpcm_get_be(card, widget, stream);
1401 if (rtd)
1514 /* is there a valid BE rtd for this widget */
1862 struct snd_soc_pcm_runtime *rtd;
1869 rtd = asoc_substream_to_rtd(be_substream);
1870 if (rtd->dai_link->be_hw_params_fixup)
1876 for_each_rtd_dais(rtd, i, dai) {
2774 static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
2777 struct snd_soc_dai_link *dai_link = rtd->dai_link;
2784 dev_err(rtd->dev, "DPCM doesn't support Multi CPU for Front-Ends yet\n");
2794 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
2801 dev_err(rtd->card->dev,
2810 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
2818 dev_err(rtd->card->dev,
2831 for_each_rtd_codec_dais(rtd, i, codec_dai) {
2833 cpu_dai = asoc_rtd_to_cpu(rtd, 0);
2835 cpu_dai = asoc_rtd_to_cpu(rtd, i);
2836 } else if (rtd->dai_link->num_codecs > rtd->dai_link->num_cpus) {
2839 if (!rtd->dai_link->codec_ch_maps) {
2840 dev_err(rtd->card->dev, "%s: no codec channel mapping table provided\n",
2845 cpu_id = rtd->dai_link->codec_ch_maps[i].connected_cpu_id;
2846 cpu_dai = asoc_rtd_to_cpu(rtd, cpu_id);
2848 dev_err(rtd->card->dev,
2850 __func__, rtd->dai_link->num_codecs,
2851 rtd->dai_link->num_cpus);
2871 dev_err(rtd->dev, "substream %s has no playback, no capture\n",
2884 struct snd_soc_pcm_runtime *rtd,
2891 if (rtd->dai_link->c2c_params) {
2893 rtd->dai_link->stream_name);
2895 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
2897 } else if (rtd->dai_link->no_pcm) {
2899 rtd->dai_link->stream_name);
2901 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
2904 if (rtd->dai_link->dynamic)
2906 rtd->dai_link->stream_name);
2909 rtd->dai_link->stream_name,
2910 soc_codec_dai_name(rtd), num);
2912 ret = snd_pcm_new(rtd->card->snd_card, new_name, num, playback,
2916 dev_err(rtd->card->dev, "ASoC: can't create pcm %s for dailink %s: %d\n",
2917 new_name, rtd->dai_link->name, ret);
2920 dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n",num, new_name);
2926 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2933 ret = soc_get_playback_capture(rtd, &playback, &capture);
2937 ret = soc_create_pcm(&pcm, rtd, playback, capture, num);
2948 if (!rtd->dai_link->c2c_params)
2949 rtd->close_delayed_work_func = snd_soc_close_delayed_work;
2951 rtd->pcm = pcm;
2952 pcm->nonatomic = rtd->dai_link->nonatomic;
2953 pcm->private_data = rtd;
2956 if (rtd->dai_link->no_pcm || rtd->dai_link->c2c_params) {
2958 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
2960 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd;
2965 if (rtd->dai_link->dynamic) {
2966 rtd->ops.open = dpcm_fe_dai_open;
2967 rtd->ops.hw_params = dpcm_fe_dai_hw_params;
2968 rtd->ops.prepare = dpcm_fe_dai_prepare;
2969 rtd->ops.trigger = dpcm_fe_dai_trigger;
2970 rtd->ops.hw_free = dpcm_fe_dai_hw_free;
2971 rtd->ops.close = dpcm_fe_dai_close;
2972 rtd->ops.pointer = soc_pcm_pointer;
2974 rtd->ops.open = soc_pcm_open;
2975 rtd->ops.hw_params = soc_pcm_hw_params;
2976 rtd->ops.prepare = soc_pcm_prepare;
2977 rtd->ops.trigger = soc_pcm_trigger;
2978 rtd->ops.hw_free = soc_pcm_hw_free;
2979 rtd->ops.close = soc_pcm_close;
2980 rtd->ops.pointer = soc_pcm_pointer;
2983 for_each_rtd_components(rtd, i, component) {
2987 rtd->ops.ioctl = snd_soc_pcm_component_ioctl;
2989 rtd->ops.sync_stop = snd_soc_pcm_component_sync_stop;
2991 rtd->ops.copy = snd_soc_pcm_component_copy;
2993 rtd->ops.page = snd_soc_pcm_component_page;
2995 rtd->ops.mmap = snd_soc_pcm_component_mmap;
2997 rtd->ops.ack = snd_soc_pcm_component_ack;
3001 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &rtd->ops);
3004 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
3006 ret = snd_soc_pcm_component_new(rtd);
3010 dev_dbg(rtd->card->dev, "%s <-> %s mapping ok\n",
3011 soc_codec_dai_name(rtd), soc_cpu_dai_name(rtd));