Alsa-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio
@ 2019-08-30 21:59 Daniel Baluta
  2019-08-30 21:59 ` [alsa-devel] " Daniel Baluta
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Daniel Baluta @ 2019-08-30 21:59 UTC (permalink / raw)
  To: broonie
  Cc: festevam, shengjiu.wang, Xiubo.Lee, nicoleotsuka, timur,
	alsa-devel, linux-kernel, Viorel Suman, NXP Linux Team,
	Daniel Baluta

From: Viorel Suman <viorel.suman@nxp.com>

This is to allow machine drivers to set a certain bitclk rate
which might not be exactly rate * frame size.

Cc: NXP Linux Team <linux-imx@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
 sound/soc/fsl/fsl_sai.c | 21 +++++++++++++++++++--
 sound/soc/fsl/fsl_sai.h |  1 +
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index fe126029f4e3..e896b577b1f7 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -137,6 +137,16 @@ static int fsl_sai_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
 	return 0;
 }
 
+static int fsl_sai_set_dai_bclk_ratio(struct snd_soc_dai *dai,
+				      unsigned int ratio)
+{
+	struct fsl_sai *sai = snd_soc_dai_get_drvdata(dai);
+
+	sai->bclk_ratio = ratio;
+
+	return 0;
+}
+
 static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai,
 		int clk_id, unsigned int freq, int fsl_dir)
 {
@@ -423,8 +433,14 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
 		slot_width = sai->slot_width;
 
 	if (!sai->is_slave_mode) {
-		ret = fsl_sai_set_bclk(cpu_dai, tx,
-				slots * slot_width * params_rate(params));
+		if (sai->bclk_ratio)
+			ret = fsl_sai_set_bclk(cpu_dai, tx,
+					       sai->bclk_ratio *
+					       params_rate(params));
+		else
+			ret = fsl_sai_set_bclk(cpu_dai, tx,
+					       slots * slot_width *
+					       params_rate(params));
 		if (ret)
 			return ret;
 
@@ -640,6 +656,7 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream,
 }
 
 static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = {
+	.set_bclk_ratio	= fsl_sai_set_dai_bclk_ratio,
 	.set_sysclk	= fsl_sai_set_dai_sysclk,
 	.set_fmt	= fsl_sai_set_dai_fmt,
 	.set_tdm_slot	= fsl_sai_set_dai_tdm_slot,
diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
index 3a3f6f8e5595..f96f8d97489d 100644
--- a/sound/soc/fsl/fsl_sai.h
+++ b/sound/soc/fsl/fsl_sai.h
@@ -177,6 +177,7 @@ struct fsl_sai {
 	unsigned int mclk_streams;
 	unsigned int slots;
 	unsigned int slot_width;
+	unsigned int bclk_ratio;
 
 	const struct fsl_sai_soc_data *soc_data;
 	struct snd_dmaengine_dai_dma_data dma_params_rx;
-- 
2.17.1

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

* [alsa-devel] [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio
  2019-08-30 21:59 [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio Daniel Baluta
@ 2019-08-30 21:59 ` " Daniel Baluta
  2019-09-06  1:29 ` Nicolin Chen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Daniel Baluta @ 2019-08-30 21:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, timur, Xiubo.Lee, Daniel Baluta, shengjiu.wang,
	linux-kernel, nicoleotsuka, NXP Linux Team, Viorel Suman,
	festevam

From: Viorel Suman <viorel.suman@nxp.com>

This is to allow machine drivers to set a certain bitclk rate
which might not be exactly rate * frame size.

Cc: NXP Linux Team <linux-imx@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
 sound/soc/fsl/fsl_sai.c | 21 +++++++++++++++++++--
 sound/soc/fsl/fsl_sai.h |  1 +
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index fe126029f4e3..e896b577b1f7 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -137,6 +137,16 @@ static int fsl_sai_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
 	return 0;
 }
 
+static int fsl_sai_set_dai_bclk_ratio(struct snd_soc_dai *dai,
+				      unsigned int ratio)
+{
+	struct fsl_sai *sai = snd_soc_dai_get_drvdata(dai);
+
+	sai->bclk_ratio = ratio;
+
+	return 0;
+}
+
 static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai,
 		int clk_id, unsigned int freq, int fsl_dir)
 {
@@ -423,8 +433,14 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
 		slot_width = sai->slot_width;
 
 	if (!sai->is_slave_mode) {
-		ret = fsl_sai_set_bclk(cpu_dai, tx,
-				slots * slot_width * params_rate(params));
+		if (sai->bclk_ratio)
+			ret = fsl_sai_set_bclk(cpu_dai, tx,
+					       sai->bclk_ratio *
+					       params_rate(params));
+		else
+			ret = fsl_sai_set_bclk(cpu_dai, tx,
+					       slots * slot_width *
+					       params_rate(params));
 		if (ret)
 			return ret;
 
@@ -640,6 +656,7 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream,
 }
 
 static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = {
+	.set_bclk_ratio	= fsl_sai_set_dai_bclk_ratio,
 	.set_sysclk	= fsl_sai_set_dai_sysclk,
 	.set_fmt	= fsl_sai_set_dai_fmt,
 	.set_tdm_slot	= fsl_sai_set_dai_tdm_slot,
diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
index 3a3f6f8e5595..f96f8d97489d 100644
--- a/sound/soc/fsl/fsl_sai.h
+++ b/sound/soc/fsl/fsl_sai.h
@@ -177,6 +177,7 @@ struct fsl_sai {
 	unsigned int mclk_streams;
 	unsigned int slots;
 	unsigned int slot_width;
+	unsigned int bclk_ratio;
 
 	const struct fsl_sai_soc_data *soc_data;
 	struct snd_dmaengine_dai_dma_data dma_params_rx;
-- 
2.17.1

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

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

* Re: [alsa-devel] [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio
  2019-08-30 21:59 [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio Daniel Baluta
  2019-08-30 21:59 ` [alsa-devel] " Daniel Baluta
@ 2019-09-06  1:29 ` Nicolin Chen
  2019-09-11 11:00   ` Mark Brown
  2019-09-12 23:54 ` Nicolin Chen
  2019-09-13  9:42 ` [alsa-devel] Applied "ASoC: fsl_sai: Implement set_bclk_ratio" to the asoc tree Mark Brown
  3 siblings, 1 reply; 8+ messages in thread
From: Nicolin Chen @ 2019-09-06  1:29 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: alsa-devel, timur, Xiubo.Lee, shengjiu.wang, linux-kernel,
	broonie, NXP Linux Team, Viorel Suman, festevam

On Sat, Aug 31, 2019 at 12:59:10AM +0300, Daniel Baluta wrote:
> From: Viorel Suman <viorel.suman@nxp.com>
> 
> This is to allow machine drivers to set a certain bitclk rate
> which might not be exactly rate * frame size.

Just a quick thought of mine: slot_width and slots could be
set via set_dai_tdm_slot() actually, while set_bclk_ratio()
would override that one with your change. I'm not sure which
one could be more important...so would you mind elaborating
your use case?

Thanks
Nicolin


> 
> Cc: NXP Linux Team <linux-imx@nxp.com>
> Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
> ---
>  sound/soc/fsl/fsl_sai.c | 21 +++++++++++++++++++--
>  sound/soc/fsl/fsl_sai.h |  1 +
>  2 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
> index fe126029f4e3..e896b577b1f7 100644
> --- a/sound/soc/fsl/fsl_sai.c
> +++ b/sound/soc/fsl/fsl_sai.c
> @@ -137,6 +137,16 @@ static int fsl_sai_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
>  	return 0;
>  }
>  
> +static int fsl_sai_set_dai_bclk_ratio(struct snd_soc_dai *dai,
> +				      unsigned int ratio)
> +{
> +	struct fsl_sai *sai = snd_soc_dai_get_drvdata(dai);
> +
> +	sai->bclk_ratio = ratio;
> +
> +	return 0;
> +}
> +
>  static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai,
>  		int clk_id, unsigned int freq, int fsl_dir)
>  {
> @@ -423,8 +433,14 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
>  		slot_width = sai->slot_width;
>  
>  	if (!sai->is_slave_mode) {
> -		ret = fsl_sai_set_bclk(cpu_dai, tx,
> -				slots * slot_width * params_rate(params));
> +		if (sai->bclk_ratio)
> +			ret = fsl_sai_set_bclk(cpu_dai, tx,
> +					       sai->bclk_ratio *
> +					       params_rate(params));
> +		else
> +			ret = fsl_sai_set_bclk(cpu_dai, tx,
> +					       slots * slot_width *
> +					       params_rate(params));
>  		if (ret)
>  			return ret;
>  
> @@ -640,6 +656,7 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream,
>  }
>  
>  static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = {
> +	.set_bclk_ratio	= fsl_sai_set_dai_bclk_ratio,
>  	.set_sysclk	= fsl_sai_set_dai_sysclk,
>  	.set_fmt	= fsl_sai_set_dai_fmt,
>  	.set_tdm_slot	= fsl_sai_set_dai_tdm_slot,
> diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
> index 3a3f6f8e5595..f96f8d97489d 100644
> --- a/sound/soc/fsl/fsl_sai.h
> +++ b/sound/soc/fsl/fsl_sai.h
> @@ -177,6 +177,7 @@ struct fsl_sai {
>  	unsigned int mclk_streams;
>  	unsigned int slots;
>  	unsigned int slot_width;
> +	unsigned int bclk_ratio;
>  
>  	const struct fsl_sai_soc_data *soc_data;
>  	struct snd_dmaengine_dai_dma_data dma_params_rx;
> -- 
> 2.17.1
> 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [alsa-devel] [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio
  2019-09-06  1:29 ` Nicolin Chen
@ 2019-09-11 11:00   ` Mark Brown
  2019-09-11 13:06     ` Daniel Baluta
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2019-09-11 11:00 UTC (permalink / raw)
  To: Nicolin Chen
  Cc: alsa-devel, timur, Xiubo.Lee, Daniel Baluta, shengjiu.wang,
	linux-kernel, NXP Linux Team, Viorel Suman, festevam

[-- Attachment #1.1: Type: text/plain, Size: 873 bytes --]

On Thu, Sep 05, 2019 at 06:29:39PM -0700, Nicolin Chen wrote:
> On Sat, Aug 31, 2019 at 12:59:10AM +0300, Daniel Baluta wrote:

> > This is to allow machine drivers to set a certain bitclk rate
> > which might not be exactly rate * frame size.

> Just a quick thought of mine: slot_width and slots could be
> set via set_dai_tdm_slot() actually, while set_bclk_ratio()
> would override that one with your change. I'm not sure which
> one could be more important...so would you mind elaborating
> your use case?

The reason we have both operations is partly that some hardware
can configure the ratio but not do TDM and partly that setting
TDM slots forces us to configure the slot size depending on the
current stream configuration while just setting the ratio means
we can just fix the configuration once.  I'd say it's just a user
error to try to do both simultaneously.

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

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

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

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

* Re: [alsa-devel] [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio
  2019-09-11 11:00   ` Mark Brown
@ 2019-09-11 13:06     ` Daniel Baluta
  2019-09-12 23:55       ` Nicolin Chen
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Baluta @ 2019-09-11 13:06 UTC (permalink / raw)
  To: Mark Brown
  Cc: Linux-ALSA, Timur Tabi, Xiubo Li, Fabio Estevam, S.j. Wang,
	Linux Kernel Mailing List, Nicolin Chen, NXP Linux Team,
	Viorel Suman, Daniel Baluta

On Wed, Sep 11, 2019 at 2:01 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Thu, Sep 05, 2019 at 06:29:39PM -0700, Nicolin Chen wrote:
> > On Sat, Aug 31, 2019 at 12:59:10AM +0300, Daniel Baluta wrote:
>
> > > This is to allow machine drivers to set a certain bitclk rate
> > > which might not be exactly rate * frame size.
>
> > Just a quick thought of mine: slot_width and slots could be
> > set via set_dai_tdm_slot() actually, while set_bclk_ratio()
> > would override that one with your change. I'm not sure which
> > one could be more important...so would you mind elaborating
> > your use case?
>
> The reason we have both operations is partly that some hardware
> can configure the ratio but not do TDM and partly that setting
> TDM slots forces us to configure the slot size depending on the
> current stream configuration while just setting the ratio means
> we can just fix the configuration once.  I'd say it's just a user
> error to try to do both simultaneously.

Yes, exactly. We wanted to have a better control of bclk freq.
Sorry for the late answer, I'm traveling.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [alsa-devel] [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio
  2019-08-30 21:59 [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio Daniel Baluta
  2019-08-30 21:59 ` [alsa-devel] " Daniel Baluta
  2019-09-06  1:29 ` Nicolin Chen
@ 2019-09-12 23:54 ` Nicolin Chen
  2019-09-13  9:42 ` [alsa-devel] Applied "ASoC: fsl_sai: Implement set_bclk_ratio" to the asoc tree Mark Brown
  3 siblings, 0 replies; 8+ messages in thread
From: Nicolin Chen @ 2019-09-12 23:54 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: alsa-devel, timur, Xiubo.Lee, shengjiu.wang, linux-kernel,
	broonie, NXP Linux Team, Viorel Suman, festevam

On Sat, Aug 31, 2019 at 12:59:10AM +0300, Daniel Baluta wrote:
> From: Viorel Suman <viorel.suman@nxp.com>
> 
> This is to allow machine drivers to set a certain bitclk rate
> which might not be exactly rate * frame size.
> 
> Cc: NXP Linux Team <linux-imx@nxp.com>
> Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>

Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>

> ---
>  sound/soc/fsl/fsl_sai.c | 21 +++++++++++++++++++--
>  sound/soc/fsl/fsl_sai.h |  1 +
>  2 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
> index fe126029f4e3..e896b577b1f7 100644
> --- a/sound/soc/fsl/fsl_sai.c
> +++ b/sound/soc/fsl/fsl_sai.c
> @@ -137,6 +137,16 @@ static int fsl_sai_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
>  	return 0;
>  }
>  
> +static int fsl_sai_set_dai_bclk_ratio(struct snd_soc_dai *dai,
> +				      unsigned int ratio)
> +{
> +	struct fsl_sai *sai = snd_soc_dai_get_drvdata(dai);
> +
> +	sai->bclk_ratio = ratio;
> +
> +	return 0;
> +}
> +
>  static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai,
>  		int clk_id, unsigned int freq, int fsl_dir)
>  {
> @@ -423,8 +433,14 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
>  		slot_width = sai->slot_width;
>  
>  	if (!sai->is_slave_mode) {
> -		ret = fsl_sai_set_bclk(cpu_dai, tx,
> -				slots * slot_width * params_rate(params));
> +		if (sai->bclk_ratio)
> +			ret = fsl_sai_set_bclk(cpu_dai, tx,
> +					       sai->bclk_ratio *
> +					       params_rate(params));
> +		else
> +			ret = fsl_sai_set_bclk(cpu_dai, tx,
> +					       slots * slot_width *
> +					       params_rate(params));
>  		if (ret)
>  			return ret;
>  
> @@ -640,6 +656,7 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream,
>  }
>  
>  static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = {
> +	.set_bclk_ratio	= fsl_sai_set_dai_bclk_ratio,
>  	.set_sysclk	= fsl_sai_set_dai_sysclk,
>  	.set_fmt	= fsl_sai_set_dai_fmt,
>  	.set_tdm_slot	= fsl_sai_set_dai_tdm_slot,
> diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
> index 3a3f6f8e5595..f96f8d97489d 100644
> --- a/sound/soc/fsl/fsl_sai.h
> +++ b/sound/soc/fsl/fsl_sai.h
> @@ -177,6 +177,7 @@ struct fsl_sai {
>  	unsigned int mclk_streams;
>  	unsigned int slots;
>  	unsigned int slot_width;
> +	unsigned int bclk_ratio;
>  
>  	const struct fsl_sai_soc_data *soc_data;
>  	struct snd_dmaengine_dai_dma_data dma_params_rx;
> -- 
> 2.17.1
> 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [alsa-devel] [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio
  2019-09-11 13:06     ` Daniel Baluta
@ 2019-09-12 23:55       ` Nicolin Chen
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolin Chen @ 2019-09-12 23:55 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: Linux-ALSA, Timur Tabi, Xiubo Li, Fabio Estevam, S.j. Wang,
	Linux Kernel Mailing List, Mark Brown, NXP Linux Team,
	Viorel Suman, Daniel Baluta

On Wed, Sep 11, 2019 at 04:06:41PM +0300, Daniel Baluta wrote:
> On Wed, Sep 11, 2019 at 2:01 PM Mark Brown <broonie@kernel.org> wrote:
> >
> > On Thu, Sep 05, 2019 at 06:29:39PM -0700, Nicolin Chen wrote:
> > > On Sat, Aug 31, 2019 at 12:59:10AM +0300, Daniel Baluta wrote:
> >
> > > > This is to allow machine drivers to set a certain bitclk rate
> > > > which might not be exactly rate * frame size.
> >
> > > Just a quick thought of mine: slot_width and slots could be
> > > set via set_dai_tdm_slot() actually, while set_bclk_ratio()
> > > would override that one with your change. I'm not sure which
> > > one could be more important...so would you mind elaborating
> > > your use case?
> >
> > The reason we have both operations is partly that some hardware
> > can configure the ratio but not do TDM and partly that setting
> > TDM slots forces us to configure the slot size depending on the
> > current stream configuration while just setting the ratio means
> > we can just fix the configuration once.  I'd say it's just a user
> > error to try to do both simultaneously.
> 
> Yes, exactly. We wanted to have a better control of bclk freq.
> Sorry for the late answer, I'm traveling.

I see. Thanks for the explain. Just acked.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [alsa-devel] Applied "ASoC: fsl_sai: Implement set_bclk_ratio" to the asoc tree
  2019-08-30 21:59 [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio Daniel Baluta
                   ` (2 preceding siblings ...)
  2019-09-12 23:54 ` Nicolin Chen
@ 2019-09-13  9:42 ` Mark Brown
  3 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2019-09-13  9:42 UTC (permalink / raw)
  To: Viorel Suman
  Cc: alsa-devel, timur, Xiubo.Lee, Daniel Baluta, shengjiu.wang,
	linux-kernel, Nicolin Chen, Mark Brown, NXP Linux Team, festevam

The patch

   ASoC: fsl_sai: Implement set_bclk_ratio

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4

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

From 63d1a3488ff58e094a7f517cf93c0250f0a3f6be Mon Sep 17 00:00:00 2001
From: Viorel Suman <viorel.suman@nxp.com>
Date: Sat, 31 Aug 2019 00:59:10 +0300
Subject: [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio

This is to allow machine drivers to set a certain bitclk rate
which might not be exactly rate * frame size.

Cc: NXP Linux Team <linux-imx@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Link: https://lore.kernel.org/r/20190830215910.31590-1-daniel.baluta@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/fsl/fsl_sai.c | 21 +++++++++++++++++++--
 sound/soc/fsl/fsl_sai.h |  1 +
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 728307acab90..ef0b74693093 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -137,6 +137,16 @@ static int fsl_sai_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
 	return 0;
 }
 
+static int fsl_sai_set_dai_bclk_ratio(struct snd_soc_dai *dai,
+				      unsigned int ratio)
+{
+	struct fsl_sai *sai = snd_soc_dai_get_drvdata(dai);
+
+	sai->bclk_ratio = ratio;
+
+	return 0;
+}
+
 static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai,
 		int clk_id, unsigned int freq, int fsl_dir)
 {
@@ -423,8 +433,14 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
 		slot_width = sai->slot_width;
 
 	if (!sai->is_slave_mode) {
-		ret = fsl_sai_set_bclk(cpu_dai, tx,
-				slots * slot_width * params_rate(params));
+		if (sai->bclk_ratio)
+			ret = fsl_sai_set_bclk(cpu_dai, tx,
+					       sai->bclk_ratio *
+					       params_rate(params));
+		else
+			ret = fsl_sai_set_bclk(cpu_dai, tx,
+					       slots * slot_width *
+					       params_rate(params));
 		if (ret)
 			return ret;
 
@@ -630,6 +646,7 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream,
 }
 
 static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = {
+	.set_bclk_ratio	= fsl_sai_set_dai_bclk_ratio,
 	.set_sysclk	= fsl_sai_set_dai_sysclk,
 	.set_fmt	= fsl_sai_set_dai_fmt,
 	.set_tdm_slot	= fsl_sai_set_dai_tdm_slot,
diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
index b89b0ca26053..b12cb578f6d0 100644
--- a/sound/soc/fsl/fsl_sai.h
+++ b/sound/soc/fsl/fsl_sai.h
@@ -176,6 +176,7 @@ struct fsl_sai {
 	unsigned int mclk_streams;
 	unsigned int slots;
 	unsigned int slot_width;
+	unsigned int bclk_ratio;
 
 	const struct fsl_sai_soc_data *soc_data;
 	struct snd_dmaengine_dai_dma_data dma_params_rx;
-- 
2.20.1

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

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

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-30 21:59 [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio Daniel Baluta
2019-08-30 21:59 ` [alsa-devel] " Daniel Baluta
2019-09-06  1:29 ` Nicolin Chen
2019-09-11 11:00   ` Mark Brown
2019-09-11 13:06     ` Daniel Baluta
2019-09-12 23:55       ` Nicolin Chen
2019-09-12 23:54 ` Nicolin Chen
2019-09-13  9:42 ` [alsa-devel] Applied "ASoC: fsl_sai: Implement set_bclk_ratio" to the asoc tree Mark Brown

Alsa-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/alsa-devel/0 alsa-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 alsa-devel alsa-devel/ https://lore.kernel.org/alsa-devel \
		alsa-devel@alsa-project.org alsa-devel@archiver.kernel.org
	public-inbox-index alsa-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.alsa-project.alsa-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox