diff --git a/include/sound/soc.h b/include/sound/soc.h index 37bbfc8b45cb28..6f259e21c40ec1 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -646,6 +646,9 @@ struct snd_soc_dai_link_component { const char *dai_name; }; +/* Split channels between cpu DAIs equally */ +#define SND_SOC_DAI_LINK_EVEN_CHANNEL BIT(0) + struct snd_soc_dai_link { /* config - must be set by machine driver */ const char *name; /* Codec name */ @@ -691,6 +694,8 @@ struct snd_soc_dai_link { enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */ + unsigned int flags[SNDRV_PCM_STREAM_LAST + 1]; /* dai_link flags */ + /* codec/machine specific init - e.g. add machine controls */ int (*init)(struct snd_soc_pcm_runtime *rtd); diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index d24e6134cedb96..adbb328f1b425c 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -797,6 +797,7 @@ static void init_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links dai_links->dpcm_capture = capture; dai_links->init = init; dai_links->ops = ops; + dai_links->flags[SNDRV_PCM_STREAM_CAPTURE] = SND_SOC_DAI_LINK_EVEN_CHANNEL; } static bool is_unique_device(const struct snd_soc_acpi_link_adr *link, diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index f6caa55ef322d5..52532f50459cf2 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2012,6 +2012,14 @@ int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) dev_dbg(be->dev, "ASoC: hw_params BE %s\n", be->dai_link->name); + if (be->dai_link->flags[stream] & SND_SOC_DAI_LINK_EVEN_CHANNEL) { + struct snd_interval *channels; + + channels = hw_param_interval(&hw_params, SNDRV_PCM_HW_PARAM_CHANNELS); + channels->min /= be->dai_link->num_cpus; + channels->max = channels->min; + } + ret = __soc_pcm_hw_params(be, be_substream, &hw_params); if (ret < 0) goto unwind;