All of lore.kernel.org
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH] sound/soc: only first codec is master in multicodec setup
@ 2019-11-20 20:23 Johannes Krude
  2020-05-08 17:13 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Krude @ 2019-11-20 20:23 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Liam Girdwood

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);
-- 
2.17.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sound/soc: only first codec is master in multicodec setup
  2019-11-20 20:23 [alsa-devel] [PATCH] sound/soc: only first codec is master in multicodec setup Johannes Krude
@ 2020-05-08 17:13 ` Mark Brown
  2020-05-11 21:34   ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2020-05-08 17:13 UTC (permalink / raw)
  To: Johannes Krude, alsa-devel; +Cc: Liam Girdwood

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sound/soc: only first codec is master in multicodec setup
  2020-05-08 17:13 ` Mark Brown
@ 2020-05-11 21:34   ` Mark Brown
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2020-05-11 21:34 UTC (permalink / raw)
  To: Johannes Krude, alsa-devel; +Cc: Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-11 21:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-20 20:23 [alsa-devel] [PATCH] sound/soc: only first codec is master in multicodec setup Johannes Krude
2020-05-08 17:13 ` Mark Brown
2020-05-11 21:34   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.