All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: bcm2835: Add 8 channel (multitrack) capability
@ 2017-02-06 23:09 ` Matt Flax
  0 siblings, 0 replies; 72+ messages in thread
From: Matt Flax @ 2017-02-06 23:09 UTC (permalink / raw)
  To: alsa-devel, Stephen Warren, Lee Jones, Eric Anholt,
	linux-rpi-kernel, linux-arm-kernel, Florian Meier, broonie, phil
  Cc: Matt Flax

This patch adds 8 channel capability by allowing DSP modes. It
also increases the channels_max (in the bcm2835_i2s_dai structure)
to 8.

The driver guards against multitrack mode when the codec isn't
master. The driver guards against multitrack capability when in
I2S mode.

Signed-off-by: Matt Flax <flatmax@flatmax.org>
---
 sound/soc/bcm/bcm2835-i2s.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c
index 6ba2049..022ca13 100644
--- a/sound/soc/bcm/bcm2835-i2s.c
+++ b/sound/soc/bcm/bcm2835-i2s.c
@@ -276,11 +276,16 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream,
 		/* otherwise calculate a fitting block ratio */
 		bclk_ratio = 2 * data_length;
 
-	/* Clock should only be set up here if CPU is clock master */
+	/* Clock should only be set up here if CPU is clock master.
+	   If codec isn't master guard against multichannel mode. */
 	switch (dev->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
 	case SND_SOC_DAIFMT_CBS_CFS:
 	case SND_SOC_DAIFMT_CBS_CFM:
 		clk_set_rate(dev->clk, sampling_rate * bclk_ratio);
+	case SND_SOC_DAIFMT_CBM_CFS:
+		/* Codec must be master in multichannel mode */
+		if (params_channels(params) > 2)
+			return -EINVAL;
 		break;
 	default:
 		break;
@@ -294,8 +299,14 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream,
 
 	format |= BCM2835_I2S_CHWID((data_length-8)&0xf);
 
+	/* Default data delay to 1 bit.
+	   In I2S mode, we must have 2 channels */
 	switch (dev->fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
+		if (params_channels(params) != 2)
+			return -EINVAL;
+	case SND_SOC_DAIFMT_DSP_A:
+	case SND_SOC_DAIFMT_DSP_B:
 		data_delay = 1;
 		break;
 	default:
@@ -312,6 +323,7 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream,
 
 	switch (params_channels(params)) {
 	case 2:
+	case 8:
 		format = BCM2835_I2S_CH1(format) | BCM2835_I2S_CH2(format);
 		format |= BCM2835_I2S_CH1(BCM2835_I2S_CHPOS(ch1pos));
 		format |= BCM2835_I2S_CH2(BCM2835_I2S_CHPOS(ch2pos));
@@ -577,7 +589,7 @@ static struct snd_soc_dai_driver bcm2835_i2s_dai = {
 	.probe	= bcm2835_i2s_dai_probe,
 	.playback = {
 		.channels_min = 2,
-		.channels_max = 2,
+		.channels_max = 8,
 		.rates =	SNDRV_PCM_RATE_8000_192000,
 		.formats =	SNDRV_PCM_FMTBIT_S16_LE
 				| SNDRV_PCM_FMTBIT_S24_LE
@@ -585,7 +597,7 @@ static struct snd_soc_dai_driver bcm2835_i2s_dai = {
 		},
 	.capture = {
 		.channels_min = 2,
-		.channels_max = 2,
+		.channels_max = 8,
 		.rates =	SNDRV_PCM_RATE_8000_192000,
 		.formats =	SNDRV_PCM_FMTBIT_S16_LE
 				| SNDRV_PCM_FMTBIT_S24_LE
-- 
2.7.4

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

end of thread, other threads:[~2017-02-26 20:28 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-06 23:09 [PATCH] ASoC: bcm2835: Add 8 channel (multitrack) capability Matt Flax
2017-02-06 23:09 ` Matt Flax
2017-02-08 18:28 ` Mark Brown
2017-02-08 18:28   ` Mark Brown
2017-02-08 18:54   ` Matthias Reichl
2017-02-08 18:54     ` Matthias Reichl
2017-02-08 21:13     ` Matt Flax
2017-02-08 21:13       ` [alsa-devel] " Matt Flax
2017-02-08 22:48       ` Matt Flax
2017-02-08 22:48         ` [alsa-devel] " Matt Flax
2017-02-09  9:29         ` Matthias Reichl
2017-02-09  9:29           ` [alsa-devel] " Matthias Reichl
2017-02-08 20:41   ` Matt Flax
2017-02-08 20:41     ` [alsa-devel] " Matt Flax
2017-02-08 21:14     ` Matt Flax
2017-02-08 21:14       ` [alsa-devel] " Matt Flax
2017-02-12 23:27 ` [PATCH v2] " Matt Flax
2017-02-12 23:27   ` Matt Flax
2017-02-13 20:51   ` Eric Anholt
2017-02-13 20:51     ` Eric Anholt
2017-02-14  9:32   ` Charles Keepax
2017-02-14  9:32     ` [alsa-devel] " Charles Keepax
2017-02-14 20:36     ` Matt Flax
2017-02-14 20:36       ` [alsa-devel] " Matt Flax
2017-02-14 20:52   ` [PATCH v3] " Matt Flax
2017-02-14 20:52     ` Matt Flax
2017-02-14 21:00     ` Matt Flax
2017-02-14 21:00       ` [alsa-devel] " Matt Flax
2017-02-14 21:04   ` [PATCH v4] " Matt Flax
2017-02-14 21:04     ` Matt Flax
2017-02-15  8:30     ` Arnaud Mouiche
2017-02-22  5:15       ` Matt Flax
2017-02-15  9:24     ` Charles Keepax
2017-02-15  9:24       ` Charles Keepax
2017-02-15 12:37     ` Florian Kauer
2017-02-15 12:37       ` Florian Kauer
2017-02-15 19:26     ` Eric Anholt
2017-02-15 19:26       ` Eric Anholt
2017-02-22  5:18 ` [PATCH v5] " Matt Flax
2017-02-22  5:18   ` Matt Flax
2017-02-22  5:20   ` Matt Flax
2017-02-22  5:20     ` Matt Flax
2017-02-22  5:22 ` [PATCH v6] " Matt Flax
2017-02-22  5:22   ` Matt Flax
2017-02-22  6:49   ` [alsa-devel] " kbuild test robot
2017-02-22  6:49     ` kbuild test robot
2017-02-22 18:28   ` Mark Brown
2017-02-22 18:28     ` Mark Brown
2017-02-22 22:45     ` Matt Flax
2017-02-22 22:45       ` [alsa-devel] " Matt Flax
2017-02-23 17:28       ` Mark Brown
2017-02-23 17:28         ` [alsa-devel] " Mark Brown
2017-02-22  6:56 ` [PATCH v8] " Matt Flax
2017-02-22  6:56   ` Matt Flax
2017-02-24 12:18   ` Matthias Reichl
2017-02-24 12:18     ` [alsa-devel] " Matthias Reichl
2017-02-24 13:50     ` Matt Flax
2017-02-24 13:50       ` [alsa-devel] " Matt Flax
2017-02-24 20:25       ` Matthias Reichl
2017-02-24 20:25         ` [alsa-devel] " Matthias Reichl
2017-02-24 21:30         ` Matt Flax
2017-02-24 21:30           ` [alsa-devel] " Matt Flax
2017-02-24 23:02           ` Matthias Reichl
2017-02-24 23:02             ` [alsa-devel] " Matthias Reichl
2017-02-25  0:08             ` Emmanuel Fusté
2017-02-25  0:08               ` [alsa-devel] " Emmanuel Fusté
2017-02-25  2:38               ` Matt Flax
2017-02-25  2:38                 ` [alsa-devel] " Matt Flax
2017-02-25  5:04                 ` Matt Flax
2017-02-25  5:04                   ` [alsa-devel] " Matt Flax
2017-02-26 20:28                   ` Matt Flax
2017-02-26 20:28                     ` [alsa-devel] " Matt Flax

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.