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 ? snd_soc_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 ? snd_soc_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,
299 snd_soc_dpcm_mutex_assert_held(rtd);
301 for_each_rtd_dais(rtd, i, dai)
305 for_each_rtd_components(rtd, i, component) {
315 * @rtd: The ASoC PCM runtime that should be checked.
322 bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd)
327 if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time)
330 for_each_rtd_components(rtd, i, component)
398 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
406 rtd->dai_link->symmetric_##name)) { \
431 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
441 symmetry = rtd->dai_link->symmetric_##xxx; \
442 for_each_rtd_dais(rtd, i, dai) \
446 for_each_rtd_cpu_dais(rtd, i, cpu_dai) \
449 dev_err(rtd->dev, "ASoC: unmatched %s symmetry: %s:%d - %s:%d\n", \
464 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
465 struct snd_soc_dai_link *link = rtd->dai_link;
473 for_each_rtd_dais(rtd, i, dai)
485 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
493 dev_warn(rtd->dev, "ASoC: Failed to set MSB %d: %d\n",
499 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
506 for_each_rtd_codec_dais(rtd, i, codec_dai) {
516 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
574 * @rtd: ASoC PCM runtime
581 int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,
594 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
616 for_each_rtd_codec_dais(rtd, i, codec_dai) {
644 if (rtd->dai_link->num_codecs > 1) {
656 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
664 snd_soc_runtime_calc_hw(rtd, hw, substream->stream);
672 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
676 for_each_rtd_components(rtd, i, component) {
692 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
696 for_each_rtd_components(rtd, i, component) {
707 static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd,
714 snd_soc_dpcm_mutex_assert_held(rtd);
717 snd_soc_runtime_deactivate(rtd, substream->stream);
720 for_each_rtd_dais(rtd, i, dai) {
727 for_each_rtd_dais_reverse(rtd, i, dai)
734 snd_soc_pcm_component_pm_runtime_put(rtd, substream, rollback);
736 for_each_rtd_components(rtd, i, component)
748 static int __soc_pcm_close(struct snd_soc_pcm_runtime *rtd,
751 return soc_pcm_clean(rtd, substream, 0);
757 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
759 snd_soc_dpcm_mutex_lock(rtd);
760 __soc_pcm_close(rtd, substream);
761 snd_soc_dpcm_mutex_unlock(rtd);
767 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
769 const char *name_cpu = soc_cpu_dai_name(rtd);
770 const char *name_codec = soc_codec_dai_name(rtd);
772 struct device *dev = rtd->dev;
808 static int __soc_pcm_open(struct snd_soc_pcm_runtime *rtd,
815 snd_soc_dpcm_mutex_assert_held(rtd);
817 for_each_rtd_components(rtd, i, component)
820 ret = snd_soc_pcm_component_pm_runtime_get(rtd, substream);
833 for_each_rtd_dais(rtd, i, dai) {
840 if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm)
855 for_each_rtd_dais(rtd, i, dai) {
861 snd_soc_runtime_activate(rtd, substream->stream);
865 soc_pcm_clean(rtd, substream, 1);
867 return soc_pcm_ret(rtd, ret);
873 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
876 snd_soc_dpcm_mutex_lock(rtd);
877 ret = __soc_pcm_open(rtd, substream);
878 snd_soc_dpcm_mutex_unlock(rtd);
887 static int __soc_pcm_prepare(struct snd_soc_pcm_runtime *rtd,
893 snd_soc_dpcm_mutex_assert_held(rtd);
909 rtd->pop_wait) {
910 rtd->pop_wait = 0;
911 cancel_delayed_work(&rtd->delayed_work);
914 snd_soc_dapm_stream_event(rtd, substream->stream,
917 for_each_rtd_dais(rtd, i, dai) {
923 return soc_pcm_ret(rtd, ret);
929 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
932 snd_soc_dpcm_mutex_lock(rtd);
933 ret = __soc_pcm_prepare(rtd, substream);
934 snd_soc_dpcm_mutex_unlock(rtd);
949 static int soc_pcm_hw_clean(struct snd_soc_pcm_runtime *rtd,
955 snd_soc_dpcm_mutex_assert_held(rtd);
958 for_each_rtd_dais(rtd, i, dai) {
969 snd_soc_dapm_stream_stop(rtd, substream->stream);
978 for_each_rtd_dais(rtd, i, dai)
988 static int __soc_pcm_hw_free(struct snd_soc_pcm_runtime *rtd,
991 return soc_pcm_hw_clean(rtd, substream, 0);
997 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1000 snd_soc_dpcm_mutex_lock(rtd);
1001 ret = __soc_pcm_hw_free(rtd, substream);
1002 snd_soc_dpcm_mutex_unlock(rtd);
1011 static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd,
1020 snd_soc_dpcm_mutex_assert_held(rtd);
1030 for_each_rtd_codec_dais(rtd, i, codec_dai) {
1066 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
1087 for_each_rtd_ch_maps(rtd, j, ch_maps)
1107 soc_pcm_hw_clean(rtd, substream, 1);
1109 return soc_pcm_ret(rtd, ret);
1116 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1119 snd_soc_dpcm_mutex_lock(rtd);
1120 ret = __soc_pcm_hw_params(rtd, substream, params);
1121 snd_soc_dpcm_mutex_unlock(rtd);
1141 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
1150 for_each_rtd_components(rtd, i, component) {
1156 if (rtd->dai_link->trigger_start)
1157 start = rtd->dai_link->trigger_start;
1158 if (rtd->dai_link->trigger_stop)
1159 stop = rtd->dai_link->trigger_stop;
1408 struct snd_soc_pcm_runtime *rtd;
1417 rtd = dpcm_get_be(card, widget, stream);
1418 if (rtd)
1531 /* is there a valid BE rtd for this widget */
1881 struct snd_soc_pcm_runtime *rtd;
1888 rtd = snd_soc_substream_to_rtd(be_substream);
1889 if (rtd->dai_link->be_hw_params_fixup)
1895 for_each_rtd_dais(rtd, i, dai) {
2793 static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
2796 struct snd_soc_dai_link *dai_link = rtd->dai_link;
2803 dev_err(rtd->dev, "DPCM doesn't support Multi CPU for Front-Ends yet\n");
2813 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
2820 dev_err(rtd->card->dev,
2829 for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
2837 dev_err(rtd->card->dev,
2855 for_each_rtd_ch_maps(rtd, i, ch_maps) {
2856 cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu);
2857 codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec);
2875 dev_err(rtd->dev, "substream %s has no playback, no capture\n",
2888 struct snd_soc_pcm_runtime *rtd,
2895 if (rtd->dai_link->c2c_params) {
2897 rtd->dai_link->stream_name);
2899 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
2901 } else if (rtd->dai_link->no_pcm) {
2903 rtd->dai_link->stream_name);
2905 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
2908 if (rtd->dai_link->dynamic)
2910 rtd->dai_link->stream_name);
2913 rtd->dai_link->stream_name,
2914 soc_codec_dai_name(rtd), num);
2916 ret = snd_pcm_new(rtd->card->snd_card, new_name, num, playback,
2920 dev_err(rtd->card->dev, "ASoC: can't create pcm %s for dailink %s: %d\n",
2921 new_name, rtd->dai_link->name, ret);
2924 dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n",num, new_name);
2930 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2937 ret = soc_get_playback_capture(rtd, &playback, &capture);
2941 ret = soc_create_pcm(&pcm, rtd, playback, capture, num);
2952 if (!rtd->dai_link->c2c_params)
2953 rtd->close_delayed_work_func = snd_soc_close_delayed_work;
2955 rtd->pcm = pcm;
2956 pcm->nonatomic = rtd->dai_link->nonatomic;
2957 pcm->private_data = rtd;
2960 if (rtd->dai_link->no_pcm || rtd->dai_link->c2c_params) {
2962 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
2964 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd;
2969 if (rtd->dai_link->dynamic) {
2970 rtd->ops.open = dpcm_fe_dai_open;
2971 rtd->ops.hw_params = dpcm_fe_dai_hw_params;
2972 rtd->ops.prepare = dpcm_fe_dai_prepare;
2973 rtd->ops.trigger = dpcm_fe_dai_trigger;
2974 rtd->ops.hw_free = dpcm_fe_dai_hw_free;
2975 rtd->ops.close = dpcm_fe_dai_close;
2976 rtd->ops.pointer = soc_pcm_pointer;
2978 rtd->ops.open = soc_pcm_open;
2979 rtd->ops.hw_params = soc_pcm_hw_params;
2980 rtd->ops.prepare = soc_pcm_prepare;
2981 rtd->ops.trigger = soc_pcm_trigger;
2982 rtd->ops.hw_free = soc_pcm_hw_free;
2983 rtd->ops.close = soc_pcm_close;
2984 rtd->ops.pointer = soc_pcm_pointer;
2987 for_each_rtd_components(rtd, i, component) {
2991 rtd->ops.ioctl = snd_soc_pcm_component_ioctl;
2993 rtd->ops.sync_stop = snd_soc_pcm_component_sync_stop;
2995 rtd->ops.copy = snd_soc_pcm_component_copy;
2997 rtd->ops.page = snd_soc_pcm_component_page;
2999 rtd->ops.mmap = snd_soc_pcm_component_mmap;
3001 rtd->ops.ack = snd_soc_pcm_component_ack;
3005 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &rtd->ops);
3008 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
3010 ret = snd_soc_pcm_component_new(rtd);
3014 dev_dbg(rtd->card->dev, "%s <-> %s mapping ok\n",
3015 soc_codec_dai_name(rtd), soc_cpu_dai_name(rtd));