[alsa-devel] [PATCH] sound/soc: only first codec is master in multicodec setup
When using multiple codecs, at most one codec should generate the master clock. All codecs except the first are therefore configured for slave mode. Before this patch all codecs in a multicodec setup had to be slaves. This is needed when e.g., connecting multiple sound hats for simultaneous playback to the raspberry pi I2S output and one of the sound hats generates the I2S clocks (https://github.com/raspberrypi/linux/pull/3337).
I checked the raspberry pi kernel tree for multicodec usage with `fgrep num_codecs -R sound/soc/` and verified that all existing multicodec drivers with hardcoded format have indeed configured all codecs for slave mode. Doing a similar check on the current for-5.5 tree is more difficult since .num_codecs is now hidden behind a preprocessor macro.
Signed-off-by: Johannes Krude johannes@krude.de --- sound/soc/soc-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 058e038df..cb8952527 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1688,6 +1688,14 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
for_each_rtd_codec_dai(rtd, i, codec_dai) { + unsigned int codec_dai_fmt = dai_fmt; + - ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + // there can only be one master when using multiple codecs + if (i && (codec_dai_fmt & SND_SOC_DAIFMT_MASTER_MASK)) { + codec_dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK; + codec_dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; + } + + ret = snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt); if (ret != 0 && ret != -ENOTSUPP) { dev_warn(codec_dai->dev, "ASoC: Failed to set DAI format: %d\n", ret);
On Wed, 20 Nov 2019 21:23:34 +0100, Johannes Krude wrote:
When using multiple codecs, at most one codec should generate the master clock. All codecs except the first are therefore configured for slave mode. Before this patch all codecs in a multicodec setup had to be slaves. This is needed when e.g., connecting multiple sound hats for simultaneous playback to the raspberry pi I2S output and one of the sound hats generates the I2S clocks (https://github.com/raspberrypi/linux/pull/3337).
[...]
Applied to
local tree regulator/for-5.7
Thanks!
[1/1] sound/soc: only first codec is master in multicodec setup (no commit info)
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
On Fri, May 08, 2020 at 06:13:43PM +0100, Mark Brown wrote:
On Wed, 20 Nov 2019 21:23:34 +0100, Johannes Krude wrote:
When using multiple codecs, at most one codec should generate the master clock. All codecs except the first are therefore configured for slave mode. Before this patch all codecs in a multicodec setup had to be slaves. This is needed when e.g., connecting multiple sound hats for simultaneous playback to the raspberry pi I2S output and one of the sound hats generates the I2S clocks (https://github.com/raspberrypi/linux/pull/3337).
[...]
Applied to
local tree regulator/for-5.7
Thanks!
[1/1] sound/soc: only first codec is master in multicodec setup (no commit info)
Sorry, this was sent in error - the patch wasn't applied.
participants (2)
-
Johannes Krude
-
Mark Brown