All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: mcasp: don't override bclk divider if it was provided by the machine
@ 2014-07-16 12:04 Daniel Mack
  2014-07-16 12:13 ` Peter Ujfalusi
  2014-07-16 21:18 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Mack @ 2014-07-16 12:04 UTC (permalink / raw)
  To: broonie; +Cc: peter.ujfalusi, alsa-devel, Daniel Mack

If a machine driver provides an BCLK divider to the McASP driver, skip the
automatic calculation.

This fixes machines on which the physical sample transport always works
in 32 bits, even though not all of them are actually used.
snd_soc_params_to_bclk() will fail to address such cases properly.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 sound/soc/davinci/davinci-mcasp.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 0518f27..dbeb4fd 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -64,6 +64,7 @@ struct davinci_mcasp {
 	u8	num_serializer;
 	u8	*serial_dir;
 	u8	version;
+	u8	bclk_div;
 	u16	bclk_lrclk_ratio;
 	int	streams;
 
@@ -420,6 +421,7 @@ static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div
 			       ACLKXDIV(div - 1), ACLKXDIV_MASK);
 		mcasp_mod_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG,
 			       ACLKRDIV(div - 1), ACLKRDIV_MASK);
+		mcasp->bclk_div = div;
 		break;
 
 	case 2:		/* BCLK/LRCLK ratio */
@@ -722,8 +724,11 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
 	int period_size = params_period_size(params);
 	int ret;
 
-	/* If mcasp is BCLK master we need to set BCLK divider */
-	if (mcasp->bclk_master) {
+	/*
+	 * If mcasp is BCLK master, and a BCLK divider was not provided by
+	 * the machine driver, we need to calculate the ratio.
+	 */
+	if (mcasp->bclk_master && mcasp->bclk_div == 0) {
 		unsigned int bclk_freq = snd_soc_params_to_bclk(params);
 		if (mcasp->sysclk_freq % bclk_freq != 0) {
 			dev_err(mcasp->dev, "Can't produce required BCLK\n");
-- 
1.9.3

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

* Re: [PATCH] ASoC: mcasp: don't override bclk divider if it was provided by the machine
  2014-07-16 12:04 [PATCH] ASoC: mcasp: don't override bclk divider if it was provided by the machine Daniel Mack
@ 2014-07-16 12:13 ` Peter Ujfalusi
  2014-07-16 21:18 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2014-07-16 12:13 UTC (permalink / raw)
  To: Daniel Mack, broonie; +Cc: alsa-devel

On 07/16/2014 03:04 PM, Daniel Mack wrote:
> If a machine driver provides an BCLK divider to the McASP driver, skip the
> automatic calculation.
> 
> This fixes machines on which the physical sample transport always works
> in 32 bits, even though not all of them are actually used.
> snd_soc_params_to_bclk() will fail to address such cases properly.

Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>
> ---
>  sound/soc/davinci/davinci-mcasp.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
> index 0518f27..dbeb4fd 100644
> --- a/sound/soc/davinci/davinci-mcasp.c
> +++ b/sound/soc/davinci/davinci-mcasp.c
> @@ -64,6 +64,7 @@ struct davinci_mcasp {
>  	u8	num_serializer;
>  	u8	*serial_dir;
>  	u8	version;
> +	u8	bclk_div;
>  	u16	bclk_lrclk_ratio;
>  	int	streams;
>  
> @@ -420,6 +421,7 @@ static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div
>  			       ACLKXDIV(div - 1), ACLKXDIV_MASK);
>  		mcasp_mod_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG,
>  			       ACLKRDIV(div - 1), ACLKRDIV_MASK);
> +		mcasp->bclk_div = div;
>  		break;
>  
>  	case 2:		/* BCLK/LRCLK ratio */
> @@ -722,8 +724,11 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
>  	int period_size = params_period_size(params);
>  	int ret;
>  
> -	/* If mcasp is BCLK master we need to set BCLK divider */
> -	if (mcasp->bclk_master) {
> +	/*
> +	 * If mcasp is BCLK master, and a BCLK divider was not provided by
> +	 * the machine driver, we need to calculate the ratio.
> +	 */
> +	if (mcasp->bclk_master && mcasp->bclk_div == 0) {
>  		unsigned int bclk_freq = snd_soc_params_to_bclk(params);
>  		if (mcasp->sysclk_freq % bclk_freq != 0) {
>  			dev_err(mcasp->dev, "Can't produce required BCLK\n");
> 


-- 
Péter

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

* Re: [PATCH] ASoC: mcasp: don't override bclk divider if it was provided by the machine
  2014-07-16 12:04 [PATCH] ASoC: mcasp: don't override bclk divider if it was provided by the machine Daniel Mack
  2014-07-16 12:13 ` Peter Ujfalusi
@ 2014-07-16 21:18 ` Mark Brown
  2014-07-16 21:19   ` Daniel Mack
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2014-07-16 21:18 UTC (permalink / raw)
  To: Daniel Mack; +Cc: peter.ujfalusi, alsa-devel


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

On Wed, Jul 16, 2014 at 02:04:41PM +0200, Daniel Mack wrote:
> If a machine driver provides an BCLK divider to the McASP driver, skip the
> automatic calculation.

Applied, thanks.  I had to merge with Peter's changes for the DMA but
the resolution looked straightforward so hopefully it's OK - you
probably want to check though.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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



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

* Re: [PATCH] ASoC: mcasp: don't override bclk divider if it was provided by the machine
  2014-07-16 21:18 ` Mark Brown
@ 2014-07-16 21:19   ` Daniel Mack
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Mack @ 2014-07-16 21:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: peter.ujfalusi, alsa-devel


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

On 07/16/2014 11:18 PM, Mark Brown wrote:
> On Wed, Jul 16, 2014 at 02:04:41PM +0200, Daniel Mack wrote:
>> If a machine driver provides an BCLK divider to the McASP driver, skip the
>> automatic calculation.
> 
> Applied, thanks.  I had to merge with Peter's changes for the DMA but
> the resolution looked straightforward so hopefully it's OK - you
> probably want to check though.

Looking good, thanks!




[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

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



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

end of thread, other threads:[~2014-07-16 21:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-16 12:04 [PATCH] ASoC: mcasp: don't override bclk divider if it was provided by the machine Daniel Mack
2014-07-16 12:13 ` Peter Ujfalusi
2014-07-16 21:18 ` Mark Brown
2014-07-16 21:19   ` Daniel Mack

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.