Skip to contentSkip to conversation

ASoC: omap-mcbsp: Add support for highter rate up to 384000

RFC PATCH In review Michael Trimarchi 2 participants 8 messages Aug 7, 2013 – Aug 12, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ASoC: omap-mcbsp: Add support for highter rate up to 384000

Add support for highter rate up to 384000Khz. There are codecs in the market that can play up to this frequency.
Test was done just with:

#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_192000)

playing wav file 32bit/192000Khz stereo. Some glitch has observed but this should depend on the selected min buffer bytes that was left untouched in aplay and in the omap-pcm driver.

---
 sound/soc/omap/omap-mcbsp.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/omap/omap-mcbsp.c +7 -1
index 7483efb..1e95f6a 100644
@@ -39,7 +39,9 @@
 #include "mcbsp.h"
 #include "omap-mcbsp.h"
 
-#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_96000)
+#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_192000 |		\
+				 SNDRV_PCM_RATE_CONTINUOUS |		\
+				 SNDRV_PCM_RATE_KNOT)
 
 #define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
 	xhandler_get, xhandler_put) \
@@ -574,11 +576,15 @@ static struct snd_soc_dai_driver omap_mcbsp_dai = {
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
+		.rate_min = 8000,
+		.rate_max = 384000,
 	},
 	.capture = {
 		.channels_min = 1,
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
+		.rate_min = 8000,
+		.rate_max = 384000,
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
 	},
 	.ops = &mcbsp_dai_ops,
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 20 lines · Michael Trimarchi

Add support for highter rate up to 384000Khz. There are codecs in the market that can play up to this frequency.
Test was done just with:

#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_192000)

playing wav file 32bit/192000Khz stereo. Some glitch has observed but this should depend on the selected min buffer bytes that was left untouched in aplay and in the omap-pcm driver.

---
 sound/soc/omap/omap-mcbsp.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/omap/omap-mcbsp.c +0 -0
index 7483efb..1e95f6a 100644

sound/soc/omap/omap-mcbsp.c line 42

Quoted 5 lines
sound/soc/omap/omap-mcbsp.c +1 -1
@@ -39,7 +39,9 @@
 #include "mcbsp.h"
 #include "omap-mcbsp.h"
 
-#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_96000)
+#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_192000 |		\

I think only this change is enough for what you want to achieve.

sound/soc/omap/omap-mcbsp.c line 44

Quoted 2 lines
sound/soc/omap/omap-mcbsp.c +2 -0
+				 SNDRV_PCM_RATE_CONTINUOUS |		\
+				 SNDRV_PCM_RATE_KNOT)

The _KNOT is for sure not needed and I would not set the CONTINUOUS either.

sound/soc/omap/omap-mcbsp.c static struct snd_soc_dai_driver omap_mcbsp_dai = { · line 580

Quoted 9 lines
sound/soc/omap/omap-mcbsp.c +2 -0
 #define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
 	xhandler_get, xhandler_put) \
@@ -574,11 +576,15 @@ static struct snd_soc_dai_driver omap_mcbsp_dai = {
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
+		.rate_min = 8000,
+		.rate_max = 384000,

Why you want to limit the rates here?

sound/soc/omap/omap-mcbsp.c static struct snd_soc_dai_driver omap_mcbsp_dai = { · line 587

Quoted 7 lines
sound/soc/omap/omap-mcbsp.c +2 -0
 	},
 	.capture = {
 		.channels_min = 1,
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
+		.rate_min = 8000,
+		.rate_max = 384000,

Same here, do not set these.

Quoted 4 lines
sound/soc/omap/omap-mcbsp.c +0 -0
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
 	},
 	.ops = &mcbsp_dai_ops,
Signature · 5 lines
Péter
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#2 lore raw

Hi

Quoted 29 lines · Peter Ujfalusi
Quoted 20 lines · Michael Trimarchi

Add support for highter rate up to 384000Khz. There are codecs in the market that can play up to this frequency.
Test was done just with:

#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_192000)

playing wav file 32bit/192000Khz stereo. Some glitch has observed but this should depend on the selected min buffer bytes that was left untouched in aplay and in the omap-pcm driver.

---
 sound/soc/omap/omap-mcbsp.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/omap/omap-mcbsp.c +0 -0
index 7483efb..1e95f6a 100644

sound/soc/omap/omap-mcbsp.c line 42

Quoted 5 lines
sound/soc/omap/omap-mcbsp.c +1 -1
@@ -39,7 +39,9 @@
 #include "mcbsp.h"
 #include "omap-mcbsp.h"
 
-#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_96000)
+#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_192000 |		\

I think only this change is enough for what you want to achieve.

Quoted 4 lines

sound/soc/omap/omap-mcbsp.c line 44

Quoted 2 lines
sound/soc/omap/omap-mcbsp.c +2 -0
+				 SNDRV_PCM_RATE_CONTINUOUS |		\
+				 SNDRV_PCM_RATE_KNOT)

The _KNOT is for sure not needed and I would not set the CONTINUOUS either.

pcm5102pw is a codec that support 384000 rate so I think that PCM_RATE_KNOT is requested for such rate. Correct?

Quoted 13 lines

sound/soc/omap/omap-mcbsp.c static struct snd_soc_dai_driver omap_mcbsp_dai = { · line 580

Quoted 10 lines
sound/soc/omap/omap-mcbsp.c +2 -0
 #define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
 	xhandler_get, xhandler_put) \
@@ -574,11 +576,15 @@ static struct snd_soc_dai_driver omap_mcbsp_dai = {
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
+		.rate_min = 8000,
+		.rate_max = 384000,

Why you want to limit the rates here?

I didn't find in the market somenthing up to 384000.

Michael

Quoted 18 lines

sound/soc/omap/omap-mcbsp.c static struct snd_soc_dai_driver omap_mcbsp_dai = { · line 587

Quoted 7 lines
sound/soc/omap/omap-mcbsp.c +2 -0
 	},
 	.capture = {
 		.channels_min = 1,
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
+		.rate_min = 8000,
+		.rate_max = 384000,

Same here, do not set these.

Quoted 4 lines
sound/soc/omap/omap-mcbsp.c +0 -0
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
 	},
 	.ops = &mcbsp_dai_ops,
Signature · 1 line
Péter
#3 lore raw
Quoted 30 lines · Michael Trimarchi
Quoted 29 lines · Peter Ujfalusi
Quoted 20 lines · Michael Trimarchi

Add support for highter rate up to 384000Khz. There are codecs in the market that can play up to this frequency.
Test was done just with:

#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_192000)

playing wav file 32bit/192000Khz stereo. Some glitch has observed but this should depend on the selected min buffer bytes that was left untouched in aplay and in the omap-pcm driver.

---
 sound/soc/omap/omap-mcbsp.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/omap/omap-mcbsp.c +0 -0
index 7483efb..1e95f6a 100644

sound/soc/omap/omap-mcbsp.c line 42

Quoted 5 lines
sound/soc/omap/omap-mcbsp.c +1 -1
@@ -39,7 +39,9 @@
 #include "mcbsp.h"
 #include "omap-mcbsp.h"
 
-#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_96000)
+#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_192000 |		\

I think only this change is enough for what you want to achieve.

Quoted 7 lines
Quoted 4 lines

sound/soc/omap/omap-mcbsp.c line 44

Quoted 2 lines
sound/soc/omap/omap-mcbsp.c +2 -0
+				 SNDRV_PCM_RATE_CONTINUOUS |		\
+				 SNDRV_PCM_RATE_KNOT)

The _KNOT is for sure not needed and I would not set the CONTINUOUS either.

pcm5102pw is a codec that support 384000 rate so I think that PCM_RATE_KNOT is requested for such rate. Correct?

Yes, looks that way. I had overlooked the 384000 KHz...

Quoted 14 lines
Quoted 13 lines

sound/soc/omap/omap-mcbsp.c static struct snd_soc_dai_driver omap_mcbsp_dai = { · line 580

Quoted 10 lines
sound/soc/omap/omap-mcbsp.c +2 -0
 #define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
 	xhandler_get, xhandler_put) \
@@ -574,11 +576,15 @@ static struct snd_soc_dai_driver omap_mcbsp_dai = {
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
+		.rate_min = 8000,
+		.rate_max = 384000,

Why you want to limit the rates here?

Quoted 1 line

I didn't find in the market somenthing up to 384000.

Sure, but it is not correct to say that McBSP supports rates up to 384000. McBSP have constraint on the BCLK speed up to 48MHz. So while 32bit/stereo/384000 is OK, 32bit/4channel/384000 is not, but 16bit/4channel/384000 is again good.
When McBSP is master we have a check for the clock speed. We might need to have similar for McBSP slave mode, but I don't think we are going to hit the 48MHz limit anyways.

Quoted 22 lines

Michael

Quoted 18 lines

sound/soc/omap/omap-mcbsp.c static struct snd_soc_dai_driver omap_mcbsp_dai = { · line 587

Quoted 7 lines
sound/soc/omap/omap-mcbsp.c +2 -0
 	},
 	.capture = {
 		.channels_min = 1,
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
+		.rate_min = 8000,
+		.rate_max = 384000,

Same here, do not set these.

Quoted 4 lines
sound/soc/omap/omap-mcbsp.c +0 -0
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
 	},
 	.ops = &mcbsp_dai_ops,
Signature · 1 line
Péter
Signature · 1 line
Péter
#4 lore raw

Hi

Quoted 36 lines · Peter Ujfalusi
Quoted 35 lines · Michael Trimarchi
Quoted 33 lines · Peter Ujfalusi
Quoted 20 lines · Michael Trimarchi

Add support for highter rate up to 384000Khz. There are codecs in the market that can play up to this frequency.
Test was done just with:

#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_192000)

playing wav file 32bit/192000Khz stereo. Some glitch has observed but this should depend on the selected min buffer bytes that was left untouched in aplay and in the omap-pcm driver.

---
 sound/soc/omap/omap-mcbsp.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/omap/omap-mcbsp.c +0 -0
index 7483efb..1e95f6a 100644

sound/soc/omap/omap-mcbsp.c line 42

Quoted 5 lines
sound/soc/omap/omap-mcbsp.c +1 -1
@@ -39,7 +39,9 @@
 #include "mcbsp.h"
 #include "omap-mcbsp.h"
 
-#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_96000)
+#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_192000 |		\

I think only this change is enough for what you want to achieve.

sound/soc/omap/omap-mcbsp.c line 44

Quoted 2 lines
sound/soc/omap/omap-mcbsp.c +2 -0
+				 SNDRV_PCM_RATE_CONTINUOUS |		\
+				 SNDRV_PCM_RATE_KNOT)

The _KNOT is for sure not needed and I would not set the CONTINUOUS either.

Quoted 5 lines
Quoted 2 lines

pcm5102pw is a codec that support 384000 rate so I think that PCM_RATE_KNOT is requested for such rate. Correct?

Yes, looks that way. I had overlooked the 384000 KHz...

Ok, I will do it better

Quoted 16 lines
Quoted 14 lines
Quoted 13 lines

sound/soc/omap/omap-mcbsp.c static struct snd_soc_dai_driver omap_mcbsp_dai = { · line 580

Quoted 10 lines
sound/soc/omap/omap-mcbsp.c +2 -0
 #define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
 	xhandler_get, xhandler_put) \
@@ -574,11 +576,15 @@ static struct snd_soc_dai_driver omap_mcbsp_dai = {
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
+		.rate_min = 8000,
+		.rate_max = 384000,

Why you want to limit the rates here?

Quoted 1 line

I didn't find in the market somenthing up to 384000.

Quoted 7 lines

Sure, but it is not correct to say that McBSP supports rates up to 384000. McBSP have constraint on the BCLK speed up to 48MHz. So while 32bit/stereo/384000 is OK, 32bit/4channel/384000 is not, but 16bit/4channel/384000 is again good.
When McBSP is master we have a check for the clock speed. We might need to have similar for McBSP slave mode, but I don't think we are going to hit the 48MHz limit anyways.

Should be possible to consider this limitation of the McBSP clock speed. I'm going to take a look on this. I will send another patch

Michael

Quoted 28 lines
Quoted 24 lines

Michael

Quoted 18 lines

sound/soc/omap/omap-mcbsp.c static struct snd_soc_dai_driver omap_mcbsp_dai = { · line 587

Quoted 7 lines
sound/soc/omap/omap-mcbsp.c +2 -0
 	},
 	.capture = {
 		.channels_min = 1,
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
+		.rate_min = 8000,
+		.rate_max = 384000,

Same here, do not set these.

Quoted 4 lines
sound/soc/omap/omap-mcbsp.c +0 -0
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
 	},
 	.ops = &mcbsp_dai_ops,
Signature · 1 line
Péter
Signature · 1 line
Péter
Signature · 3 lines
| Michael Nazzareno Trimarchi                     Amarula Solutions BV |
| COO  -  Founder                                      Cruquiuskade 47 |
| +31(0)851119172                                 Amsterdam 1018 AM NL |
#5 lore raw
In reply to Peter Ujfalusi

Hi Peter

Quoted 57 lines · Peter Ujfalusi
Quoted 30 lines · Michael Trimarchi
Quoted 29 lines · Peter Ujfalusi
Quoted 20 lines · Michael Trimarchi

Add support for highter rate up to 384000Khz. There are codecs in the market that can play up to this frequency.
Test was done just with:

#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_192000)

playing wav file 32bit/192000Khz stereo. Some glitch has observed but this should depend on the selected min buffer bytes that was left untouched in aplay and in the omap-pcm driver.

---
 sound/soc/omap/omap-mcbsp.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/omap/omap-mcbsp.c +0 -0
index 7483efb..1e95f6a 100644

sound/soc/omap/omap-mcbsp.c line 42

Quoted 5 lines
sound/soc/omap/omap-mcbsp.c +1 -1
@@ -39,7 +39,9 @@
 #include "mcbsp.h"
 #include "omap-mcbsp.h"
 
-#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_96000)
+#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_192000 |		\

I think only this change is enough for what you want to achieve.

Quoted 7 lines
Quoted 4 lines

sound/soc/omap/omap-mcbsp.c line 44

Quoted 2 lines
sound/soc/omap/omap-mcbsp.c +2 -0
+				 SNDRV_PCM_RATE_CONTINUOUS |		\
+				 SNDRV_PCM_RATE_KNOT)

The _KNOT is for sure not needed and I would not set the CONTINUOUS either.

pcm5102pw is a codec that support 384000 rate so I think that PCM_RATE_KNOT is requested for such rate. Correct?

Yes, looks that way. I had overlooked the 384000 KHz...

Quoted 14 lines
Quoted 13 lines

sound/soc/omap/omap-mcbsp.c static struct snd_soc_dai_driver omap_mcbsp_dai = { · line 580

Quoted 10 lines
sound/soc/omap/omap-mcbsp.c +2 -0
 #define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
 	xhandler_get, xhandler_put) \
@@ -574,11 +576,15 @@ static struct snd_soc_dai_driver omap_mcbsp_dai = {
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
+		.rate_min = 8000,
+		.rate_max = 384000,

Why you want to limit the rates here?

Quoted 1 line

I didn't find in the market somenthing up to 384000.

Quoted 8 lines

Sure, but it is not correct to say that McBSP supports rates up to 384000. McBSP have constraint on the BCLK speed up to 48MHz. So while 32bit/stereo/384000 is OK, 32bit/4channel/384000 is not, but 16bit/4channel/384000 is again good.
When McBSP is master we have a check for the clock speed. We might need to have similar for McBSP slave mode, but I don't think we are going to hit the 48MHz limit anyways.

I found some time but I can't not test this patch now ;) too far from my office. The idea is to check with MAX_BCLK. There are two points that should cover slave and master mode. Is it the right direction? BTW Do you think that is better to have at soc level as a new constraint?

Michael

sound/soc/omap/omap-mcbsp.c +12 -3
index 7483efb..ea95ad2 100644
@@ -39,7 +39,9 @@
 #include "mcbsp.h"
 #include "omap-mcbsp.h"
 
-#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_96000)
+#define OMAP_MCBSP_MAX_BCLK	48000000
+#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_192000 |		\
+				 SNDRV_PCM_RATE_KNOT)
 
 #define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
 	xhandler_get, xhandler_put) \
@@ -225,10 +227,14 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 	struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
 	struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs;
 	struct snd_dmaengine_dai_dma_data *dma_data;
-	int wlen, channels, wpf;
+	int wlen, channels, wpf, bclk;
 	int pkt_size = 0;
 	unsigned int format, div, framesize, master;
 
+	bclk = snd_soc_params_to_bclk(params);
+	if (bclk < 0 || bclk > OMAP_MCBSP_MAX_BCLK)
+		return -EINVAL;
+
 	dma_data = snd_soc_dai_get_dma_data(cpu_dai, substream);
 	channels = params_channels(params);
 
@@ -326,7 +332,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 	/* In McBSP master modes, FRAME (i.e. sample rate) is generated
 	 * by _counting_ BCLKs. Calculate frame size in BCLKs */
 	master = mcbsp->fmt & SND_SOC_DAIFMT_MASTER_MASK;
-	if (master ==	SND_SOC_DAIFMT_CBS_CFS) {
+	if (master == SND_SOC_DAIFMT_CBS_CFS) {
 		div = mcbsp->clk_div ? mcbsp->clk_div : 1;
 		framesize = (mcbsp->in_freq / div) / params_rate(params);
 
@@ -500,6 +506,9 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
 			return -EBUSY;
 	}
 
+	if (freq > OMAP_MCBSP_MAX_BCLK)
+		return -EINVAL;
+
 	mcbsp->in_freq = freq;
 	regs->srgr2 &= ~CLKSM;
 	regs->pcr0 &= ~SCLKME;
Quoted 27 lines
Quoted 23 lines

Michael

Quoted 18 lines

sound/soc/omap/omap-mcbsp.c static struct snd_soc_dai_driver omap_mcbsp_dai = { · line 587

Quoted 7 lines
sound/soc/omap/omap-mcbsp.c +2 -0
 	},
 	.capture = {
 		.channels_min = 1,
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
+		.rate_min = 8000,
+		.rate_max = 384000,

Same here, do not set these.

Quoted 4 lines
sound/soc/omap/omap-mcbsp.c +0 -0
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
 	},
 	.ops = &mcbsp_dai_ops,
Signature · 1 line
Péter
Signature · 1 line
Péter
#6 lore raw
Quoted 4 lines · Michael Trimarchi

I found some time but I can't not test this patch now ;) too far from my office. The idea is to check with MAX_BCLK. There are two points that should cover slave and master mode. Is it the right direction? BTW Do you think that is better to have at soc level as a new constraint?

I would not bother with the bclk check for now. We did not had issues so far and 48MHz is quite high anyways for our users so far.

Quoted 80 lines

Michael

sound/soc/omap/omap-mcbsp.c +12 -3
index 7483efb..ea95ad2 100644
@@ -39,7 +39,9 @@
 #include "mcbsp.h"
 #include "omap-mcbsp.h"
 
-#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_96000)
+#define OMAP_MCBSP_MAX_BCLK	48000000
+#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_192000 |		\
+				 SNDRV_PCM_RATE_KNOT)
 
 #define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
 	xhandler_get, xhandler_put) \
@@ -225,10 +227,14 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 	struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
 	struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs;
 	struct snd_dmaengine_dai_dma_data *dma_data;
-	int wlen, channels, wpf;
+	int wlen, channels, wpf, bclk;
 	int pkt_size = 0;
 	unsigned int format, div, framesize, master;
 
+	bclk = snd_soc_params_to_bclk(params);
+	if (bclk < 0 || bclk > OMAP_MCBSP_MAX_BCLK)
+		return -EINVAL;
+
 	dma_data = snd_soc_dai_get_dma_data(cpu_dai, substream);
 	channels = params_channels(params);
 
@@ -326,7 +332,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 	/* In McBSP master modes, FRAME (i.e. sample rate) is generated
 	 * by _counting_ BCLKs. Calculate frame size in BCLKs */
 	master = mcbsp->fmt & SND_SOC_DAIFMT_MASTER_MASK;
-	if (master ==	SND_SOC_DAIFMT_CBS_CFS) {
+	if (master == SND_SOC_DAIFMT_CBS_CFS) {
 		div = mcbsp->clk_div ? mcbsp->clk_div : 1;
 		framesize = (mcbsp->in_freq / div) / params_rate(params);
 
@@ -500,6 +506,9 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
 			return -EBUSY;
 	}
 
+	if (freq > OMAP_MCBSP_MAX_BCLK)
+		return -EINVAL;
+
 	mcbsp->in_freq = freq;
 	regs->srgr2 &= ~CLKSM;
 	regs->pcr0 &= ~SCLKME;
Quoted 27 lines
Quoted 23 lines

Michael

Quoted 18 lines

Review

Quoted 7 lines
(quoted diff) +2 -0
 	},
 	.capture = {
 		.channels_min = 1,
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
+		.rate_min = 8000,
+		.rate_max = 384000,

Same here, do not set these.

Quoted 4 lines
(quoted diff) +0 -0
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
 	},
 	.ops = &mcbsp_dai_ops,
Signature · 1 line
Péter
Signature · 1 line
Péter
Signature · 1 line
Péter
#7 lore raw

Hi

Quoted 8 lines · Peter Ujfalusi
Quoted 4 lines · Michael Trimarchi

I found some time but I can't not test this patch now ;) too far from my office. The idea is to check with MAX_BCLK. There are two points that should cover slave and master mode. Is it the right direction? BTW Do you think that is better to have at soc level as a new constraint?

I would not bother with the bclk check for now. We did not had issues so far and 48MHz is quite high anyways for our users so far.

Right now I'm working on 2 device that they need to support
384Khz 32bit stereo playback/recording and next dsd512, but we can skip this test. Check is only for consistency anyway and it doesn't cost so much in time. I will prepare a new patch and send without it.

Michael

Quoted 83 lines
Quoted 81 lines

Michael

sound/soc/omap/omap-mcbsp.c +12 -3
index 7483efb..ea95ad2 100644
@@ -39,7 +39,9 @@
 #include "mcbsp.h"
 #include "omap-mcbsp.h"
 
-#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_96000)
+#define OMAP_MCBSP_MAX_BCLK	48000000
+#define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_192000 |		\
+				 SNDRV_PCM_RATE_KNOT)
 
 #define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
 	xhandler_get, xhandler_put) \
@@ -225,10 +227,14 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 	struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
 	struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs;
 	struct snd_dmaengine_dai_dma_data *dma_data;
-	int wlen, channels, wpf;
+	int wlen, channels, wpf, bclk;
 	int pkt_size = 0;
 	unsigned int format, div, framesize, master;
 
+	bclk = snd_soc_params_to_bclk(params);
+	if (bclk < 0 || bclk > OMAP_MCBSP_MAX_BCLK)
+		return -EINVAL;
+
 	dma_data = snd_soc_dai_get_dma_data(cpu_dai, substream);
 	channels = params_channels(params);
 
@@ -326,7 +332,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 	/* In McBSP master modes, FRAME (i.e. sample rate) is generated
 	 * by _counting_ BCLKs. Calculate frame size in BCLKs */
 	master = mcbsp->fmt & SND_SOC_DAIFMT_MASTER_MASK;
-	if (master ==	SND_SOC_DAIFMT_CBS_CFS) {
+	if (master == SND_SOC_DAIFMT_CBS_CFS) {
 		div = mcbsp->clk_div ? mcbsp->clk_div : 1;
 		framesize = (mcbsp->in_freq / div) / params_rate(params);
 
@@ -500,6 +506,9 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
 			return -EBUSY;
 	}
 
+	if (freq > OMAP_MCBSP_MAX_BCLK)
+		return -EINVAL;
+
 	mcbsp->in_freq = freq;
 	regs->srgr2 &= ~CLKSM;
 	regs->pcr0 &= ~SCLKME;
Quoted 27 lines
Quoted 23 lines

Michael

Quoted 18 lines

Review

Quoted 7 lines
(quoted diff) +2 -0
 	},
 	.capture = {
 		.channels_min = 1,
 		.channels_max = 16,
 		.rates = OMAP_MCBSP_RATES,
+		.rate_min = 8000,
+		.rate_max = 384000,

Same here, do not set these.

Quoted 4 lines
(quoted diff) +0 -0
 		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
 	},
 	.ops = &mcbsp_dai_ops,
Signature · 1 line
Péter
Signature · 1 line
Péter