diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index be891e529257b5..f7d69776c1d1a8 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -13,6 +13,7 @@ #include #include +#include struct snd_pcm_substream; struct snd_soc_dapm_widget; @@ -218,7 +219,9 @@ void snd_soc_dai_suspend(struct snd_soc_dai *dai); void snd_soc_dai_resume(struct snd_soc_dai *dai); int snd_soc_dai_compress_new(struct snd_soc_dai *dai, struct snd_soc_pcm_runtime *rtd, int num); -bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream); +bool snd_soc_dai_valid_via_txrx(struct snd_soc_dai *dai, enum snd_soc_dir txrx); +bool snd_soc_dai_valid_via_stream(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_dai *dai, int stream); void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link); void snd_soc_dai_action(struct snd_soc_dai *dai, int stream, int action); @@ -491,13 +494,24 @@ struct snd_soc_dai { unsigned int probed:1; }; -static inline struct snd_soc_pcm_stream * -snd_soc_dai_get_pcm_stream(const struct snd_soc_dai *dai, int stream) +#define snd_soc_convert_stream_to_txrx_for_cpu(stream) snd_soc_convert_stream_to_txrx(0, stream) +#define snd_soc_convert_stream_to_txrx_for_codec(stream) snd_soc_convert_stream_to_txrx(1, stream) +enum snd_soc_dir snd_soc_convert_stream_to_txrx(int is_codec, int stream); +enum snd_soc_dir snd_soc_convert_stream_to_txrx_via_dai(struct snd_soc_pcm_runtime *rtd, const struct snd_soc_dai *dai, int stream); + +#define snd_soc_dai_get_stream_info_tx(dai) snd_soc_dai_get_stream_info_by_txrx(dai, SNDRV_DIR_TX) +#define snd_soc_dai_get_stream_info_rx(dai) snd_soc_dai_get_stream_info_by_txrx(dai, SNDRV_DIR_RX) +static inline struct snd_soc_pcm_stream_info * +snd_soc_dai_get_stream_info_by_txrx(const struct snd_soc_dai *dai, enum snd_soc_dir txrx) { - return (stream == SNDRV_PCM_STREAM_PLAYBACK) ? - &dai->driver->playback : &dai->driver->capture; + return &dai->driver->stream_info[txrx]; } +#define snd_soc_dai_get_stream_info_playback(rtd, dai) snd_soc_dai_get_stream_info_by_stream(rtd, dai, SNDRV_PCM_STREAM_PLAYBACK) +#define snd_soc_dai_get_stream_info_capture(rtd, dai) snd_soc_dai_get_stream_info_by_stream(rtd, dai, SNDRV_PCM_STREAM_CAPTURE) +#define snd_soc_dai_get_stream_info_by_stream(rtd, dai, stream) \ + snd_soc_dai_get_stream_info_by_txrx(dai, snd_soc_convert_stream_to_txrx_via_dai(rtd, dai, stream)) + static inline struct snd_soc_dapm_widget *snd_soc_dai_get_widget( struct snd_soc_dai *dai, int stream) diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index e12f8244242b9a..710e63d9ee5715 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -918,20 +918,6 @@ int snd_soc_component_test_bits(struct snd_soc_component *component, } EXPORT_SYMBOL_GPL(snd_soc_component_test_bits); -int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct snd_soc_component *component; - int i; - - /* FIXME: use 1st pointer */ - for_each_rtd_components(rtd, i, component) - if (component->driver->pointer) - return component->driver->pointer(component, substream); - - return 0; -} - static bool snd_soc_component_is_codec_on_rtd(struct snd_soc_pcm_runtime *rtd, struct snd_soc_component *component) { @@ -946,6 +932,20 @@ static bool snd_soc_component_is_codec_on_rtd(struct snd_soc_pcm_runtime *rtd, return false; } +int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_component *component; + int i; + + /* FIXME: use 1st pointer */ + for_each_rtd_components(rtd, i, component) + if (component->driver->pointer) + return component->driver->pointer(component, substream); + + return 0; +} + void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream, snd_pcm_sframes_t *cpu_delay, snd_pcm_sframes_t *codec_delay) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 31dfb1ed69208f..a7e7cd9755af4e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -51,6 +51,8 @@ static LIST_HEAD(unbind_card_list); #define for_each_component(component) \ list_for_each_entry(component, &component_list, list) +struct snd_soc_pcm_stream_params null_stream_param = { }; + /* * This is used if driver don't need to have CPU/Codec/Platform * dai_link. see soc.h @@ -2497,6 +2499,11 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, dai_drv->stream_info[SNDRV_DIR_RX].params = &dai_drv->capture_; } + if (!dai_drv->stream_info[SNDRV_DIR_TX].params) + dai_drv->stream_info[SNDRV_DIR_TX].params = &null_stream_param; + if (!dai_drv->stream_info[SNDRV_DIR_RX].params) + dai_drv->stream_info[SNDRV_DIR_RX].params = &null_stream_param; + /* see for_each_component_dais */ list_add_tail(&dai->list, &component->dai_list); component->num_dai++; diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index d530e8c2b77b1a..99e1b5359851cb 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -32,6 +32,35 @@ static inline int _soc_dai_ret(struct snd_soc_dai *dai, return ret; } +static bool snd_soc_dai_is_codec(struct snd_soc_pcm_runtime *rtd, const struct snd_soc_dai *dai) +{ + struct snd_soc_dai *_dai; + int i; + + for_each_rtd_codec_dais(rtd, i, _dai) + if (_dai == dai) + return true; + + return false; +} + +enum snd_soc_dir snd_soc_convert_stream_to_txrx(int is_codec, int stream) +{ + /* see [TX/RX image] */ + if (( is_codec && (stream == SNDRV_PCM_STREAM_CAPTURE)) || + (!is_codec && (stream == SNDRV_PCM_STREAM_PLAYBACK))) + return SNDRV_DIR_TX; + else + return SNDRV_DIR_RX; +} + +enum snd_soc_dir snd_soc_convert_stream_to_txrx_via_dai(struct snd_soc_pcm_runtime *rtd, const struct snd_soc_dai *dai, int stream) +{ + int is_codec = snd_soc_dai_is_codec(rtd, dai); + + return snd_soc_convert_stream_to_txrx(is_codec, stream); +} + /* * We might want to check substream by using list. * In such case, we can update these macros. @@ -462,16 +491,32 @@ int snd_soc_dai_compress_new(struct snd_soc_dai *dai, } /* - * snd_soc_dai_stream_valid() - check if a DAI supports the given stream + * snd_soc_dai_valid_via_txrx() - check if a DAI supports the given stream * * Returns true if the DAI supports the indicated stream type. */ -bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir) +bool snd_soc_dai_valid_via_txrx(struct snd_soc_dai *dai, enum snd_soc_dir txrx) { - struct snd_soc_pcm_stream *stream = snd_soc_dai_get_pcm_stream(dai, dir); + struct snd_soc_pcm_stream_info *si = snd_soc_dai_get_stream_info_by_txrx(dai, txrx); /* If the codec specifies any channels at all, it supports the stream */ - return stream->channels_min; + if (!si->params || !si->params->channels_min) + return false; + + return true; +} + +/* + * snd_soc_dai_valid_via_stream() - check if a DAI supports the given stream + * + * Returns true if the DAI supports the indicated stream type. + */ +bool snd_soc_dai_valid_via_stream(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_dai *dai, int stream) +{ + int txrx = snd_soc_convert_stream_to_txrx_via_dai(rtd, dai, stream); + + return snd_soc_dai_valid_via_txrx(dai, txrx); } /* @@ -480,31 +525,35 @@ bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir) void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link) { bool supported[SNDRV_PCM_STREAM_LAST + 1]; - int direction; + int stream; - for_each_pcm_streams(direction) { + for_each_pcm_streams(stream) { struct snd_soc_dai_link_component *cpu; struct snd_soc_dai_link_component *codec; struct snd_soc_dai *dai; bool supported_cpu = false; bool supported_codec = false; + int txrx; int i; + txrx = snd_soc_convert_stream_to_txrx_for_cpu(stream); for_each_link_cpus(dai_link, i, cpu) { dai = snd_soc_find_dai_with_mutex(cpu); - if (dai && snd_soc_dai_stream_valid(dai, direction)) { + if (dai && snd_soc_dai_valid_via_txrx(dai, txrx)) { supported_cpu = true; break; } } + + txrx = snd_soc_convert_stream_to_txrx_for_codec(stream); for_each_link_codecs(dai_link, i, codec) { dai = snd_soc_find_dai_with_mutex(codec); - if (dai && snd_soc_dai_stream_valid(dai, direction)) { + if (dai && snd_soc_dai_valid_via_txrx(dai, txrx)) { supported_codec = true; break; } } - supported[direction] = supported_cpu && supported_codec; + supported[stream] = supported_cpu && supported_codec; } dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK]; diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 869c76506b669c..4ac89b11bc131b 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3834,7 +3834,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, struct snd_soc_dai *source, *sink; struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct snd_pcm_hw_params *params = NULL; - const struct snd_soc_pcm_stream *config = NULL; + const struct snd_soc_pcm_stream_params *config = NULL; struct snd_pcm_runtime *runtime = NULL; unsigned int fmt; int ret = 0; @@ -3880,7 +3880,7 @@ snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w, * either party on the link to alter the configuration if * necessary */ - config = rtd->dai_link->params + rtd->params_select; + config = (rtd->dai_link->c2c_params + rtd->params_select); if (WARN_ON(!config)) { dev_err(w->dapm->dev, "ASoC: link config missing\n"); ret = -EINVAL; diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index a827cc3c158aeb..e2faeffa7c0380 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -175,7 +175,7 @@ static ssize_t dpcm_state_read_file(struct file *file, char __user *user_buf, snd_soc_dpcm_mutex_lock(fe); for_each_pcm_streams(stream) - if (snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream)) + if (snd_soc_dai_valid_via_stream(fe, asoc_rtd_to_cpu(fe, 0), stream)) offset += dpcm_show_state(fe, stream, buf + offset, out_count - offset); @@ -481,28 +481,29 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct snd_soc_dai *cpu_dai; struct snd_soc_dai *codec_dai; + struct snd_soc_pcm_stream_info *si; int stream = substream->stream; int i; unsigned int bits = 0, cpu_bits = 0; for_each_rtd_codec_dais(rtd, i, codec_dai) { - struct snd_soc_pcm_stream *pcm_codec = snd_soc_dai_get_pcm_stream(codec_dai, stream); + si = snd_soc_dai_get_stream_info_by_stream(rtd, codec_dai, stream); - if (pcm_codec->sig_bits == 0) { + if (!si->params || si->params->sig_bits == 0) { bits = 0; break; } - bits = max(pcm_codec->sig_bits, bits); + bits = max(si->params->sig_bits, bits); } for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - struct snd_soc_pcm_stream *pcm_cpu = snd_soc_dai_get_pcm_stream(cpu_dai, stream); + si = snd_soc_dai_get_stream_info_by_stream(rtd, cpu_dai, stream); - if (pcm_cpu->sig_bits == 0) { + if (!si->params || si->params->sig_bits == 0) { cpu_bits = 0; break; } - cpu_bits = max(pcm_cpu->sig_bits, cpu_bits); + cpu_bits = max(si->params->sig_bits, cpu_bits); } soc_pcm_set_msb(substream, bits); @@ -520,7 +521,7 @@ static void soc_pcm_hw_init(struct snd_pcm_hardware *hw) } static void soc_pcm_hw_update_rate(struct snd_pcm_hardware *hw, - struct snd_soc_pcm_stream *p) + struct snd_soc_pcm_stream_params *p) { hw->rates = snd_pcm_rate_mask_intersect(hw->rates, p->rates); @@ -533,14 +534,14 @@ static void soc_pcm_hw_update_rate(struct snd_pcm_hardware *hw, } static void soc_pcm_hw_update_chan(struct snd_pcm_hardware *hw, - struct snd_soc_pcm_stream *p) + struct snd_soc_pcm_stream_params *p) { hw->channels_min = max(hw->channels_min, p->channels_min); hw->channels_max = min(hw->channels_max, p->channels_max); } static void soc_pcm_hw_update_format(struct snd_pcm_hardware *hw, - struct snd_soc_pcm_stream *p) + struct snd_soc_pcm_stream_params *p) { hw->formats &= p->formats; } @@ -559,8 +560,7 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd, { struct snd_soc_dai *codec_dai; struct snd_soc_dai *cpu_dai; - struct snd_soc_pcm_stream *codec_stream; - struct snd_soc_pcm_stream *cpu_stream; + struct snd_soc_pcm_stream_info *si; unsigned int cpu_chan_min = 0, cpu_chan_max = UINT_MAX; int i; @@ -568,6 +568,7 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd, /* first calculate min/max only for CPUs in the DAI link */ for_each_rtd_cpu_dais(rtd, i, cpu_dai) { + int txrx = snd_soc_convert_stream_to_txrx_for_cpu(stream); /* * Skip CPUs which don't support the current stream type. @@ -575,20 +576,21 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd, * zero in that case, we would have no usable settings left, * causing the resulting setup to fail. */ - if (!snd_soc_dai_stream_valid(cpu_dai, stream)) + if (!snd_soc_dai_valid_via_txrx(cpu_dai, txrx)) continue; - cpu_stream = snd_soc_dai_get_pcm_stream(cpu_dai, stream); + si = snd_soc_dai_get_stream_info_by_stream(rtd, cpu_dai, stream); - soc_pcm_hw_update_chan(hw, cpu_stream); - soc_pcm_hw_update_rate(hw, cpu_stream); - soc_pcm_hw_update_format(hw, cpu_stream); + soc_pcm_hw_update_chan(hw, si->params); + soc_pcm_hw_update_rate(hw, si->params); + soc_pcm_hw_update_format(hw, si->params); } cpu_chan_min = hw->channels_min; cpu_chan_max = hw->channels_max; /* second calculate min/max only for CODECs in the DAI link */ for_each_rtd_codec_dais(rtd, i, codec_dai) { + int txrx = snd_soc_convert_stream_to_txrx_for_codec(stream); /* * Skip CODECs which don't support the current stream type. @@ -596,14 +598,14 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd, * zero in that case, we would have no usable settings left, * causing the resulting setup to fail. */ - if (!snd_soc_dai_stream_valid(codec_dai, stream)) + if (!snd_soc_dai_valid_via_txrx(codec_dai, txrx)) continue; - codec_stream = snd_soc_dai_get_pcm_stream(codec_dai, stream); + si = snd_soc_dai_get_stream_info_by_stream(rtd, codec_dai, stream); - soc_pcm_hw_update_chan(hw, codec_stream); - soc_pcm_hw_update_rate(hw, codec_stream); - soc_pcm_hw_update_format(hw, codec_stream); + soc_pcm_hw_update_chan(hw, si->params); + soc_pcm_hw_update_rate(hw, si->params); + soc_pcm_hw_update_format(hw, si->params); } /* Verify both a valid CPU DAI and a valid CODEC DAI were found */ @@ -958,7 +960,7 @@ static int soc_pcm_hw_clean(struct snd_soc_pcm_runtime *rtd, /* now free hw params for the DAIs */ for_each_rtd_dais(rtd, i, dai) - if (snd_soc_dai_stream_valid(dai, substream->stream)) + if (snd_soc_dai_valid_via_stream(rtd, dai, substream->stream)) snd_soc_dai_hw_free(dai, substream, rollback); return 0; @@ -1010,6 +1012,7 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd, for_each_rtd_codec_dais(rtd, i, codec_dai) { struct snd_pcm_hw_params codec_params; + int txrx = snd_soc_convert_stream_to_txrx_for_codec(substream->stream); /* * Skip CODECs which don't support the current stream type, @@ -1025,7 +1028,7 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd, * machine driver setup with information on how to act, so * we can do the right thing here. */ - if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) + if (!snd_soc_dai_valid_via_txrx(codec_dai, txrx)) continue; /* copy params for each codec */ @@ -1052,11 +1055,13 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd, } for_each_rtd_cpu_dais(rtd, i, cpu_dai) { + int txrx = snd_soc_convert_stream_to_txrx_for_cpu(substream->stream); + /* * Skip CPUs which don't support the current stream * type. See soc_pcm_init_runtime_hw() for more details */ - if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream)) + if (!snd_soc_dai_valid_via_txrx(cpu_dai, txrx)) continue; ret = snd_soc_dai_hw_params(cpu_dai, substream, params); @@ -1653,20 +1658,21 @@ static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream) soc_pcm_hw_init(hw); for_each_rtd_cpu_dais(fe, i, dai) { - struct snd_soc_pcm_stream *cpu_stream; + struct snd_soc_pcm_stream_info *si; + int txrx = snd_soc_convert_stream_to_txrx_for_cpu(stream); /* * Skip CPUs which don't support the current stream * type. See soc_pcm_init_runtime_hw() for more details */ - if (!snd_soc_dai_stream_valid(dai, stream)) + if (!snd_soc_dai_valid_via_txrx(dai, txrx)) continue; - cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); + si = snd_soc_dai_get_stream_info_by_stream(fe, dai, stream); - soc_pcm_hw_update_rate(hw, cpu_stream); - soc_pcm_hw_update_chan(hw, cpu_stream); - soc_pcm_hw_update_format(hw, cpu_stream); + soc_pcm_hw_update_rate(hw, si->params); + soc_pcm_hw_update_chan(hw, si->params); + soc_pcm_hw_update_format(hw, si->params); } } @@ -1690,20 +1696,22 @@ static void dpcm_runtime_setup_be_format(struct snd_pcm_substream *substream) for_each_dpcm_be(fe, stream, dpcm) { struct snd_soc_pcm_runtime *be = dpcm->be; - struct snd_soc_pcm_stream *codec_stream; + struct snd_soc_pcm_stream_info *si; + int txrx = snd_soc_convert_stream_to_txrx_for_codec(stream); int i; for_each_rtd_codec_dais(be, i, dai) { + /* * Skip CODECs which don't support the current stream * type. See soc_pcm_init_runtime_hw() for more details */ - if (!snd_soc_dai_stream_valid(dai, stream)) + if (!snd_soc_dai_valid_via_txrx(dai, txrx)) continue; - codec_stream = snd_soc_dai_get_pcm_stream(dai, stream); + si = snd_soc_dai_get_stream_info_by_stream(be, dai, stream); - soc_pcm_hw_update_format(hw, codec_stream); + soc_pcm_hw_update_format(hw, si->params); } } } @@ -1726,8 +1734,9 @@ static void dpcm_runtime_setup_be_chan(struct snd_pcm_substream *substream) for_each_dpcm_be(fe, stream, dpcm) { struct snd_soc_pcm_runtime *be = dpcm->be; - struct snd_soc_pcm_stream *cpu_stream; + struct snd_soc_pcm_stream_info *si; struct snd_soc_dai *dai; + int txrx = snd_soc_convert_stream_to_txrx_for_cpu(stream); int i; for_each_rtd_cpu_dais(be, i, dai) { @@ -1735,12 +1744,12 @@ static void dpcm_runtime_setup_be_chan(struct snd_pcm_substream *substream) * Skip CPUs which don't support the current stream * type. See soc_pcm_init_runtime_hw() for more details */ - if (!snd_soc_dai_stream_valid(dai, stream)) + if (!snd_soc_dai_valid_via_txrx(dai, txrx)) continue; - cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); + si = snd_soc_dai_get_stream_info_by_stream(be, dai, stream); - soc_pcm_hw_update_chan(hw, cpu_stream); + soc_pcm_hw_update_chan(hw, si->params); } /* @@ -1748,10 +1757,9 @@ static void dpcm_runtime_setup_be_chan(struct snd_pcm_substream *substream) * DAIs connected to a single CPU DAI, use CPU DAI's directly */ if (be->num_codecs == 1) { - struct snd_soc_pcm_stream *codec_stream = snd_soc_dai_get_pcm_stream( - asoc_rtd_to_codec(be, 0), stream); + si = snd_soc_dai_get_stream_info_by_stream(be, asoc_rtd_to_codec(be, 0), stream); - soc_pcm_hw_update_chan(hw, codec_stream); + soc_pcm_hw_update_chan(hw, si->params); } } } @@ -1774,21 +1782,23 @@ static void dpcm_runtime_setup_be_rate(struct snd_pcm_substream *substream) for_each_dpcm_be(fe, stream, dpcm) { struct snd_soc_pcm_runtime *be = dpcm->be; - struct snd_soc_pcm_stream *pcm; + struct snd_soc_pcm_stream_info *si; struct snd_soc_dai *dai; int i; for_each_rtd_dais(be, i, dai) { + int txrx = snd_soc_convert_stream_to_txrx_via_dai(be, dai, stream); + /* * Skip DAIs which don't support the current stream * type. See soc_pcm_init_runtime_hw() for more details */ - if (!snd_soc_dai_stream_valid(dai, stream)) + if (!snd_soc_dai_valid_via_txrx(dai, txrx)) continue; - pcm = snd_soc_dai_get_pcm_stream(dai, stream); + si = snd_soc_dai_get_stream_info_by_stream(be, dai, stream); - soc_pcm_hw_update_rate(hw, pcm); + soc_pcm_hw_update_rate(hw, si->params); } } } @@ -2627,8 +2637,8 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new) for_each_pcm_streams(stream) { /* skip if FE doesn't have playback/capture capability */ - if (!snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream) || - !snd_soc_dai_stream_valid(asoc_rtd_to_codec(fe, 0), stream)) + if (!snd_soc_dai_valid_via_stream(fe, asoc_rtd_to_cpu(fe, 0), stream) || + !snd_soc_dai_valid_via_stream(fe, asoc_rtd_to_codec(fe, 0), stream)) continue; /* skip if FE isn't currently playing/capturing */ @@ -2761,13 +2771,13 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, } if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) { - int stream; + int txrx; if (rtd->dai_link->dpcm_playback) { - stream = SNDRV_PCM_STREAM_PLAYBACK; + txrx = SNDRV_DIR_TX; for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - if (snd_soc_dai_stream_valid(cpu_dai, stream)) { + if (snd_soc_dai_valid_via_txrx(cpu_dai, txrx)) { *playback = 1; break; } @@ -2780,10 +2790,10 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, } } if (rtd->dai_link->dpcm_capture) { - stream = SNDRV_PCM_STREAM_CAPTURE; + txrx = SNDRV_DIR_RX; for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - if (snd_soc_dai_stream_valid(cpu_dai, stream)) { + if (snd_soc_dai_valid_via_txrx(cpu_dai, txrx)) { *capture = 1; break; } @@ -2816,11 +2826,11 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, return -EINVAL; } - if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && - snd_soc_dai_stream_valid(cpu_dai, cpu_playback)) + if (snd_soc_dai_valid_via_stream(rtd, codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && + snd_soc_dai_valid_via_stream(rtd, cpu_dai, cpu_playback)) *playback = 1; - if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) && - snd_soc_dai_stream_valid(cpu_dai, cpu_capture)) + if (snd_soc_dai_valid_via_stream(rtd, codec_dai, SNDRV_PCM_STREAM_CAPTURE) && + snd_soc_dai_valid_via_stream(rtd, cpu_dai, cpu_capture)) *capture = 1; } } diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index 594cb311ff30a9..03a71d61fc6a5b 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -192,21 +192,24 @@ static const struct snd_soc_dai_ops dummy_dai_ops = { * which should be modelled. And the data flow graph also should be modelled * using DAPM. */ +static struct snd_soc_pcm_stream_params common_stream_params = { + .channels_min = 1, + .channels_max = 384, + .rates = STUB_RATES, + .formats = STUB_FORMATS, +}; + static struct snd_soc_dai_driver dummy_dai = { .name = "snd-soc-dummy-dai", - .playback = { - .stream_name = "Playback", - .channels_min = 1, - .channels_max = 384, - .rates = STUB_RATES, - .formats = STUB_FORMATS, - }, - .capture = { - .stream_name = "Capture", - .channels_min = 1, - .channels_max = 384, - .rates = STUB_RATES, - .formats = STUB_FORMATS, + .stream_info = { + [SNDRV_DIR_TX] = { + .stream_name = "Playback", + .params = &common_stream_params, + }, + [SNDRV_DIR_RX] = { + .stream_name = "Capture", + .params = &common_stream_params, + }, }, .ops = &dummy_dai_ops, };