alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-3.2 1/2] ASoC: omap-mcbsp: Fix FS polarity for LEFT_J, DSP_A and DSP_B formats
@ 2011-09-30  7:55 Jarkko Nikula
  2011-09-30  7:55 ` [PATCH for-3.2 2/2] ASoC: Davinci: Fix FS polarity for I2S format Jarkko Nikula
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jarkko Nikula @ 2011-09-30  7:55 UTC (permalink / raw)
  To: alsa-devel; +Cc: Peter Ujfalusi, Mark Brown, Liam Girdwood, Jarkko Nikula

Commit 75d9ac4 ("ASoC: Allow DAI formats to be specified in the dai_link")
changed DAI format flag values and we cannot simply invert anymore e.g.
frame-sync with ^= SND_SOC_DAIFMT_NB_IF (which was anyway misuse) as there
is no anymore fixed bit position for bit-clock or frame-sync inversion.

Fix this by relying only on DAI format flag values passed to us and by not
making any assumption on individual bit positions.

Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-mcbsp.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 1391ea0..894f2f3 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -398,7 +398,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 {
 	struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
 	struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
-	unsigned int temp_fmt = fmt;
+	bool inv_fs = false;
 
 	if (mcbsp_data->configured)
 		return 0;
@@ -430,21 +430,21 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 		regs->xcr2	|= XDATDLY(0);
 		regs->spcr1	|= RJUST(2);
 		/* Invert FS polarity configuration */
-		temp_fmt ^= SND_SOC_DAIFMT_NB_IF;
+		inv_fs = true;
 		break;
 	case SND_SOC_DAIFMT_DSP_A:
 		/* 1-bit data delay */
 		regs->rcr2      |= RDATDLY(1);
 		regs->xcr2      |= XDATDLY(1);
 		/* Invert FS polarity configuration */
-		temp_fmt ^= SND_SOC_DAIFMT_NB_IF;
+		inv_fs = true;
 		break;
 	case SND_SOC_DAIFMT_DSP_B:
 		/* 0-bit data delay */
 		regs->rcr2      |= RDATDLY(0);
 		regs->xcr2      |= XDATDLY(0);
 		/* Invert FS polarity configuration */
-		temp_fmt ^= SND_SOC_DAIFMT_NB_IF;
+		inv_fs = true;
 		break;
 	default:
 		/* Unsupported data format */
@@ -468,7 +468,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 	}
 
 	/* Set bit clock (CLKX/CLKR) and FS polarities */
-	switch (temp_fmt & SND_SOC_DAIFMT_INV_MASK) {
+	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
 	case SND_SOC_DAIFMT_NB_NF:
 		/*
 		 * Normal BCLK + FS.
@@ -489,6 +489,8 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 	default:
 		return -EINVAL;
 	}
+	if (inv_fs == true)
+		regs->pcr0 ^= FSXP | FSRP;
 
 	return 0;
 }
-- 
1.7.6.3

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

* [PATCH for-3.2 2/2] ASoC: Davinci: Fix FS polarity for I2S format
  2011-09-30  7:55 [PATCH for-3.2 1/2] ASoC: omap-mcbsp: Fix FS polarity for LEFT_J, DSP_A and DSP_B formats Jarkko Nikula
@ 2011-09-30  7:55 ` Jarkko Nikula
  2011-09-30 11:49   ` Mark Brown
  2011-09-30 11:55   ` Mark Brown
  2011-09-30  8:47 ` [PATCH for-3.2 1/2] ASoC: omap-mcbsp: Fix FS polarity for LEFT_J, DSP_A and DSP_B formats Péter Ujfalusi
  2011-09-30 11:51 ` Mark Brown
  2 siblings, 2 replies; 7+ messages in thread
From: Jarkko Nikula @ 2011-09-30  7:55 UTC (permalink / raw)
  To: alsa-devel
  Cc: Kevin Hilman, Mark Brown, Sekhar Nori, Vaibhav Bedia,
	Liam Girdwood, Jarkko Nikula

Commit 75d9ac4 ("ASoC: Allow DAI formats to be specified in the dai_link")
changed DAI format flag values and we cannot simply invert anymore e.g.
frame-sync with ^= SND_SOC_DAIFMT_NB_IF (which was anyway misuse) as there
is no anymore fixed bit position for bit-clock or frame-sync inversion.

Fix this by relying only on DAI format flag values passed to us and by not
making any assumption on individual bit positions

Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Cc: Vaibhav Bedia <vaibhav.bedia@ti.com>
Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
---
I don't have Davinci so only compile tested.
---
 sound/soc/davinci/davinci-i2s.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index d0d60b8..300e121 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -265,6 +265,7 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 	struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
 	unsigned int pcr;
 	unsigned int srgr;
+	bool inv_fs = false;
 	/* Attention srgr is updated by hw_params! */
 	srgr = DAVINCI_MCBSP_SRGR_FSGM |
 		DAVINCI_MCBSP_SRGR_FPER(DEFAULT_BITPERSAMPLE * 2 - 1) |
@@ -330,7 +331,7 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 		 * more empty bit clock slots between channels as the sample
 		 * rate is lowered.
 		 */
-		fmt ^= SND_SOC_DAIFMT_NB_IF;
+		inv_fs = true;
 	case SND_SOC_DAIFMT_DSP_A:
 		dev->mode = MOD_DSP_A;
 		break;
@@ -394,6 +395,8 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 	default:
 		return -EINVAL;
 	}
+	if (inv_fs == true)
+		pcr ^= (DAVINCI_MCBSP_PCR_FSXP | DAVINCI_MCBSP_PCR_FSRP);
 	davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, srgr);
 	dev->pcr = pcr;
 	davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_PCR_REG, pcr);
-- 
1.7.6.3

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

* Re: [PATCH for-3.2 1/2] ASoC: omap-mcbsp: Fix FS polarity for LEFT_J, DSP_A and DSP_B formats
  2011-09-30  7:55 [PATCH for-3.2 1/2] ASoC: omap-mcbsp: Fix FS polarity for LEFT_J, DSP_A and DSP_B formats Jarkko Nikula
  2011-09-30  7:55 ` [PATCH for-3.2 2/2] ASoC: Davinci: Fix FS polarity for I2S format Jarkko Nikula
@ 2011-09-30  8:47 ` Péter Ujfalusi
  2011-09-30 11:51 ` Mark Brown
  2 siblings, 0 replies; 7+ messages in thread
From: Péter Ujfalusi @ 2011-09-30  8:47 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: alsa-devel, Mark Brown, Liam Girdwood

On Friday 30 September 2011 10:55:32 Jarkko Nikula wrote:
> Commit 75d9ac4 ("ASoC: Allow DAI formats to be specified in the dai_link")
> changed DAI format flag values and we cannot simply invert anymore e.g.
> frame-sync with ^= SND_SOC_DAIFMT_NB_IF (which was anyway misuse) as there
> is no anymore fixed bit position for bit-clock or frame-sync inversion.
> 
> Fix this by relying only on DAI format flag values passed to us and by not
> making any assumption on individual bit positions.
> 
> Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
> Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>

I have missed the 75d9ac4 ;)
As a note: omap-mcbsp still needs the runtime configuration of dai format...

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

> ---
>  sound/soc/omap/omap-mcbsp.c |   12 +++++++-----
>  1 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
> index 1391ea0..894f2f3 100644
> --- a/sound/soc/omap/omap-mcbsp.c
> +++ b/sound/soc/omap/omap-mcbsp.c
> @@ -398,7 +398,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai
> *cpu_dai, {
>  	struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
>  	struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
> -	unsigned int temp_fmt = fmt;
> +	bool inv_fs = false;
> 
>  	if (mcbsp_data->configured)
>  		return 0;
> @@ -430,21 +430,21 @@ static int omap_mcbsp_dai_set_dai_fmt(struct
> snd_soc_dai *cpu_dai, regs->xcr2	|= XDATDLY(0);
>  		regs->spcr1	|= RJUST(2);
>  		/* Invert FS polarity configuration */
> -		temp_fmt ^= SND_SOC_DAIFMT_NB_IF;
> +		inv_fs = true;
>  		break;
>  	case SND_SOC_DAIFMT_DSP_A:
>  		/* 1-bit data delay */
>  		regs->rcr2      |= RDATDLY(1);
>  		regs->xcr2      |= XDATDLY(1);
>  		/* Invert FS polarity configuration */
> -		temp_fmt ^= SND_SOC_DAIFMT_NB_IF;
> +		inv_fs = true;
>  		break;
>  	case SND_SOC_DAIFMT_DSP_B:
>  		/* 0-bit data delay */
>  		regs->rcr2      |= RDATDLY(0);
>  		regs->xcr2      |= XDATDLY(0);
>  		/* Invert FS polarity configuration */
> -		temp_fmt ^= SND_SOC_DAIFMT_NB_IF;
> +		inv_fs = true;
>  		break;
>  	default:
>  		/* Unsupported data format */
> @@ -468,7 +468,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai
> *cpu_dai, }
> 
>  	/* Set bit clock (CLKX/CLKR) and FS polarities */
> -	switch (temp_fmt & SND_SOC_DAIFMT_INV_MASK) {
> +	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
>  	case SND_SOC_DAIFMT_NB_NF:
>  		/*
>  		 * Normal BCLK + FS.
> @@ -489,6 +489,8 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai
> *cpu_dai, default:
>  		return -EINVAL;
>  	}
> +	if (inv_fs == true)
> +		regs->pcr0 ^= FSXP | FSRP;
> 
>  	return 0;
>  }

--
Péter

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

* Re: [PATCH for-3.2 2/2] ASoC: Davinci: Fix FS polarity for I2S format
  2011-09-30  7:55 ` [PATCH for-3.2 2/2] ASoC: Davinci: Fix FS polarity for I2S format Jarkko Nikula
@ 2011-09-30 11:49   ` Mark Brown
  2011-09-30 11:55   ` Mark Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Brown @ 2011-09-30 11:49 UTC (permalink / raw)
  To: Jarkko Nikula
  Cc: Kevin Hilman, alsa-devel, Sekhar Nori, Liam Girdwood,
	Vaibhav Bedia

On Fri, Sep 30, 2011 at 10:55:33AM +0300, Jarkko Nikula wrote:
> Commit 75d9ac4 ("ASoC: Allow DAI formats to be specified in the dai_link")
> changed DAI format flag values and we cannot simply invert anymore e.g.
> frame-sync with ^= SND_SOC_DAIFMT_NB_IF (which was anyway misuse) as there
> is no anymore fixed bit position for bit-clock or frame-sync inversion.
> 
> Fix this by relying only on DAI format flag values passed to us and by not
> making any assumption on individual bit positions

This doesn't apply against for-3.2.

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

* Re: [PATCH for-3.2 1/2] ASoC: omap-mcbsp: Fix FS polarity for LEFT_J, DSP_A and DSP_B formats
  2011-09-30  7:55 [PATCH for-3.2 1/2] ASoC: omap-mcbsp: Fix FS polarity for LEFT_J, DSP_A and DSP_B formats Jarkko Nikula
  2011-09-30  7:55 ` [PATCH for-3.2 2/2] ASoC: Davinci: Fix FS polarity for I2S format Jarkko Nikula
  2011-09-30  8:47 ` [PATCH for-3.2 1/2] ASoC: omap-mcbsp: Fix FS polarity for LEFT_J, DSP_A and DSP_B formats Péter Ujfalusi
@ 2011-09-30 11:51 ` Mark Brown
  2 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2011-09-30 11:51 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: Peter Ujfalusi, alsa-devel, Liam Girdwood

On Fri, Sep 30, 2011 at 10:55:32AM +0300, Jarkko Nikula wrote:
> Commit 75d9ac4 ("ASoC: Allow DAI formats to be specified in the dai_link")
> changed DAI format flag values and we cannot simply invert anymore e.g.
> frame-sync with ^= SND_SOC_DAIFMT_NB_IF (which was anyway misuse) as there
> is no anymore fixed bit position for bit-clock or frame-sync inversion.

Applied, thanks.

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

* Re: [PATCH for-3.2 2/2] ASoC: Davinci: Fix FS polarity for I2S format
  2011-09-30  7:55 ` [PATCH for-3.2 2/2] ASoC: Davinci: Fix FS polarity for I2S format Jarkko Nikula
  2011-09-30 11:49   ` Mark Brown
@ 2011-09-30 11:55   ` Mark Brown
  2011-09-30 12:14     ` Jarkko Nikula
  1 sibling, 1 reply; 7+ messages in thread
From: Mark Brown @ 2011-09-30 11:55 UTC (permalink / raw)
  To: Jarkko Nikula
  Cc: Kevin Hilman, alsa-devel, Sekhar Nori, Liam Girdwood,
	Vaibhav Bedia

On Fri, Sep 30, 2011 at 10:55:33AM +0300, Jarkko Nikula wrote:
> Commit 75d9ac4 ("ASoC: Allow DAI formats to be specified in the dai_link")
> changed DAI format flag values and we cannot simply invert anymore e.g.
> frame-sync with ^= SND_SOC_DAIFMT_NB_IF (which was anyway misuse) as there
> is no anymore fixed bit position for bit-clock or frame-sync inversion.

Actually it does, sorry - the for-3.2 bit was causing confusion (I don't
know why you started doing that?).

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

* Re: [PATCH for-3.2 2/2] ASoC: Davinci: Fix FS polarity for I2S format
  2011-09-30 11:55   ` Mark Brown
@ 2011-09-30 12:14     ` Jarkko Nikula
  0 siblings, 0 replies; 7+ messages in thread
From: Jarkko Nikula @ 2011-09-30 12:14 UTC (permalink / raw)
  To: Mark Brown
  Cc: Kevin Hilman, alsa-devel, Sekhar Nori, Liam Girdwood,
	Vaibhav Bedia

On 09/30/2011 02:55 PM, Mark Brown wrote:
> On Fri, Sep 30, 2011 at 10:55:33AM +0300, Jarkko Nikula wrote:
>> Commit 75d9ac4 ("ASoC: Allow DAI formats to be specified in the dai_link")
>> changed DAI format flag values and we cannot simply invert anymore e.g.
>> frame-sync with ^= SND_SOC_DAIFMT_NB_IF (which was anyway misuse) as there
>> is no anymore fixed bit position for bit-clock or frame-sync inversion.
>
> Actually it does, sorry - the for-3.2 bit was causing confusion (I don't
> know why you started doing that?).

Well, it's Friday. My attempt to emphasize that "Fix foo bar" is 
definitely not for 3.1 did rather opposite, sorry about that :-)

-- 
Jarkko

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

end of thread, other threads:[~2011-09-30 12:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-30  7:55 [PATCH for-3.2 1/2] ASoC: omap-mcbsp: Fix FS polarity for LEFT_J, DSP_A and DSP_B formats Jarkko Nikula
2011-09-30  7:55 ` [PATCH for-3.2 2/2] ASoC: Davinci: Fix FS polarity for I2S format Jarkko Nikula
2011-09-30 11:49   ` Mark Brown
2011-09-30 11:55   ` Mark Brown
2011-09-30 12:14     ` Jarkko Nikula
2011-09-30  8:47 ` [PATCH for-3.2 1/2] ASoC: omap-mcbsp: Fix FS polarity for LEFT_J, DSP_A and DSP_B formats Péter Ujfalusi
2011-09-30 11:51 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).