alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: sam9x5_wm8731: fix left right channel swap issue
@ 2013-12-04  2:37 Bo Shen
  2013-12-04  2:37 ` [PATCH 1/2] ASoC: atmel_ssc_dai: add dai trigger ops Bo Shen
  2013-12-04  2:37 ` [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A mode Bo Shen
  0 siblings, 2 replies; 9+ messages in thread
From: Bo Shen @ 2013-12-04  2:37 UTC (permalink / raw)
  To: broonie
  Cc: nicolas.ferre, richard.genoud, zql, linux-sound, alsa-devel,
	linux-arm-kernel, Bo Shen

This patch series fix sam9x5 wm8731 playback left right channel swap issue
However, sam9x5 and wm8731 only can work in DSP A mode while can not work
in I2S mode.

Bo Shen (2):
  ASoC: atmel_ssc_dai: add dai trigger ops
  ASoC: sam9x5_wm8731: change to work in DSP A mode

 sound/soc/atmel/atmel_ssc_dai.c |   30 +++++++++++++++++++++++++++++-
 sound/soc/atmel/sam9x5_wm8731.c |    2 +-
 2 files changed, 30 insertions(+), 2 deletions(-)

-- 
1.7.9.5


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

* [PATCH 1/2] ASoC: atmel_ssc_dai: add dai trigger ops
  2013-12-04  2:37 [PATCH 0/2] ASoC: sam9x5_wm8731: fix left right channel swap issue Bo Shen
@ 2013-12-04  2:37 ` Bo Shen
  2013-12-04 11:38   ` Richard Genoud
  2013-12-04 11:43   ` Mark Brown
  2013-12-04  2:37 ` [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A mode Bo Shen
  1 sibling, 2 replies; 9+ messages in thread
From: Bo Shen @ 2013-12-04  2:37 UTC (permalink / raw)
  To: broonie
  Cc: zql, richard.genoud, nicolas.ferre, alsa-devel, linux-sound,
	Bo Shen, linux-arm-kernel

According to the SSC specifiation, it should be enabled after DMA is
enabled. So, add trigger operation to make sure the right sequence.

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---
 sound/soc/atmel/atmel_ssc_dai.c |   30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
index 8697ced..1ead3c9 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -648,7 +648,7 @@ static int atmel_ssc_prepare(struct snd_pcm_substream *substream,
 
 	dma_params = ssc_p->dma_params[dir];
 
-	ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_enable);
+	ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_disable);
 	ssc_writel(ssc_p->ssc->regs, IDR, dma_params->mask->ssc_error);
 
 	pr_debug("%s enabled SSC_SR=0x%08x\n",
@@ -657,6 +657,33 @@ static int atmel_ssc_prepare(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int atmel_ssc_trigger(struct snd_pcm_substream *substream,
+			     int cmd, struct snd_soc_dai *dai)
+{
+	struct atmel_ssc_info *ssc_p = &ssc_info[dai->id];
+	struct atmel_pcm_dma_params *dma_params;
+	int dir;
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		dir = 0;
+	else
+		dir = 1;
+
+	dma_params = ssc_p->dma_params[dir];
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+	case SNDRV_PCM_TRIGGER_RESUME:
+	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+		ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_enable);
+		break;
+	default:
+		ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_disable);
+		break;
+	}
+
+	return 0;
+}
 
 #ifdef CONFIG_PM
 static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai)
@@ -731,6 +758,7 @@ static const struct snd_soc_dai_ops atmel_ssc_dai_ops = {
 	.startup	= atmel_ssc_startup,
 	.shutdown	= atmel_ssc_shutdown,
 	.prepare	= atmel_ssc_prepare,
+	.trigger	= atmel_ssc_trigger,
 	.hw_params	= atmel_ssc_hw_params,
 	.set_fmt	= atmel_ssc_set_dai_fmt,
 	.set_clkdiv	= atmel_ssc_set_dai_clkdiv,
-- 
1.7.9.5

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

* [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A mode
  2013-12-04  2:37 [PATCH 0/2] ASoC: sam9x5_wm8731: fix left right channel swap issue Bo Shen
  2013-12-04  2:37 ` [PATCH 1/2] ASoC: atmel_ssc_dai: add dai trigger ops Bo Shen
@ 2013-12-04  2:37 ` Bo Shen
  2013-12-04 11:38   ` Richard Genoud
  2013-12-04 11:44   ` Mark Brown
  1 sibling, 2 replies; 9+ messages in thread
From: Bo Shen @ 2013-12-04  2:37 UTC (permalink / raw)
  To: broonie
  Cc: nicolas.ferre, richard.genoud, zql, linux-sound, alsa-devel,
	linux-arm-kernel, Bo Shen

Change sam9x5 with wm8731 work in DSP A mode, this will fix the
left/right channel swap issue.

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---
 sound/soc/atmel/sam9x5_wm8731.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c
index 992ae38..06c1811 100644
--- a/sound/soc/atmel/sam9x5_wm8731.c
+++ b/sound/soc/atmel/sam9x5_wm8731.c
@@ -107,7 +107,7 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev)
 	dai->stream_name = "WM8731 PCM";
 	dai->codec_dai_name = "wm8731-hifi";
 	dai->init = sam9x5_wm8731_init;
-	dai->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
+	dai->dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF
 		| SND_SOC_DAIFMT_CBM_CFM;
 
 	ret = snd_soc_of_parse_card_name(card, "atmel,model");
-- 
1.7.9.5


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

* Re: [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A mode
  2013-12-04  2:37 ` [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A mode Bo Shen
@ 2013-12-04 11:38   ` Richard Genoud
  2013-12-04 15:54     ` Zhong Li
  2013-12-04 11:44   ` Mark Brown
  1 sibling, 1 reply; 9+ messages in thread
From: Richard Genoud @ 2013-12-04 11:38 UTC (permalink / raw)
  To: Bo Shen
  Cc: zql, nicolas.ferre, alsa-devel, linux-sound, broonie,
	linux-arm-kernel

On 04/12/2013 03:37, Bo Shen wrote:
> Change sam9x5 with wm8731 work in DSP A mode, this will fix the
> left/right channel swap issue.
> 
> Signed-off-by: Bo Shen <voice.shen@atmel.com>
> ---
>  sound/soc/atmel/sam9x5_wm8731.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c
> index 992ae38..06c1811 100644
> --- a/sound/soc/atmel/sam9x5_wm8731.c
> +++ b/sound/soc/atmel/sam9x5_wm8731.c
> @@ -107,7 +107,7 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev)
>  	dai->stream_name = "WM8731 PCM";
>  	dai->codec_dai_name = "wm8731-hifi";
>  	dai->init = sam9x5_wm8731_init;
> -	dai->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
> +	dai->dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF
>  		| SND_SOC_DAIFMT_CBM_CFM;
>  
>  	ret = snd_soc_of_parse_card_name(card, "atmel,model");
> 
Tested-by: Richard Genoud <richard.genoud@gmail.com>
on at91sam9g35-ek with 3.12-rc2 + "ASoC: wm8731: fix dsp mode configuration"


Thanks !

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

* Re: [PATCH 1/2] ASoC: atmel_ssc_dai: add dai trigger ops
  2013-12-04  2:37 ` [PATCH 1/2] ASoC: atmel_ssc_dai: add dai trigger ops Bo Shen
@ 2013-12-04 11:38   ` Richard Genoud
  2013-12-04 11:43   ` Mark Brown
  1 sibling, 0 replies; 9+ messages in thread
From: Richard Genoud @ 2013-12-04 11:38 UTC (permalink / raw)
  To: Bo Shen
  Cc: broonie, nicolas.ferre, zql, linux-sound, alsa-devel,
	linux-arm-kernel

On 04/12/2013 03:37, Bo Shen wrote:
> According to the SSC specifiation, it should be enabled after DMA is
> enabled. So, add trigger operation to make sure the right sequence.
> 
> Signed-off-by: Bo Shen <voice.shen@atmel.com>
> ---
>  sound/soc/atmel/atmel_ssc_dai.c |   30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
> index 8697ced..1ead3c9 100644
> --- a/sound/soc/atmel/atmel_ssc_dai.c
> +++ b/sound/soc/atmel/atmel_ssc_dai.c
> @@ -648,7 +648,7 @@ static int atmel_ssc_prepare(struct snd_pcm_substream *substream,
>  
>  	dma_params = ssc_p->dma_params[dir];
>  
> -	ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_enable);
> +	ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_disable);
>  	ssc_writel(ssc_p->ssc->regs, IDR, dma_params->mask->ssc_error);
>  
>  	pr_debug("%s enabled SSC_SR=0x%08x\n",
> @@ -657,6 +657,33 @@ static int atmel_ssc_prepare(struct snd_pcm_substream *substream,
>  	return 0;
>  }
>  
> +static int atmel_ssc_trigger(struct snd_pcm_substream *substream,
> +			     int cmd, struct snd_soc_dai *dai)
> +{
> +	struct atmel_ssc_info *ssc_p = &ssc_info[dai->id];
> +	struct atmel_pcm_dma_params *dma_params;
> +	int dir;
> +
> +	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
> +		dir = 0;
> +	else
> +		dir = 1;
> +
> +	dma_params = ssc_p->dma_params[dir];
> +
> +	switch (cmd) {
> +	case SNDRV_PCM_TRIGGER_START:
> +	case SNDRV_PCM_TRIGGER_RESUME:
> +	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
> +		ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_enable);
> +		break;
> +	default:
> +		ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_disable);
> +		break;
> +	}
> +
> +	return 0;
> +}
>  
>  #ifdef CONFIG_PM
>  static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai)
> @@ -731,6 +758,7 @@ static const struct snd_soc_dai_ops atmel_ssc_dai_ops = {
>  	.startup	= atmel_ssc_startup,
>  	.shutdown	= atmel_ssc_shutdown,
>  	.prepare	= atmel_ssc_prepare,
> +	.trigger	= atmel_ssc_trigger,
>  	.hw_params	= atmel_ssc_hw_params,
>  	.set_fmt	= atmel_ssc_set_dai_fmt,
>  	.set_clkdiv	= atmel_ssc_set_dai_clkdiv,
> 

Tested-by: Richard Genoud <richard.genoud@gmail.com>
on at91sam9g35-ek with 3.12-rc2 + "ASoC: wm8731: fix dsp mode configuration"



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

* Re: [PATCH 1/2] ASoC: atmel_ssc_dai: add dai trigger ops
  2013-12-04  2:37 ` [PATCH 1/2] ASoC: atmel_ssc_dai: add dai trigger ops Bo Shen
  2013-12-04 11:38   ` Richard Genoud
@ 2013-12-04 11:43   ` Mark Brown
  1 sibling, 0 replies; 9+ messages in thread
From: Mark Brown @ 2013-12-04 11:43 UTC (permalink / raw)
  To: Bo Shen
  Cc: zql, richard.genoud, nicolas.ferre, alsa-devel, linux-sound,
	linux-arm-kernel


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

On Wed, Dec 04, 2013 at 10:37:03AM +0800, Bo Shen wrote:
> According to the SSC specifiation, it should be enabled after DMA is
> enabled. So, add trigger operation to make sure the right sequence.

Applied, thanks.

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

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



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

* Re: [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A mode
  2013-12-04  2:37 ` [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A mode Bo Shen
  2013-12-04 11:38   ` Richard Genoud
@ 2013-12-04 11:44   ` Mark Brown
  1 sibling, 0 replies; 9+ messages in thread
From: Mark Brown @ 2013-12-04 11:44 UTC (permalink / raw)
  To: Bo Shen
  Cc: nicolas.ferre, richard.genoud, zql, linux-sound, alsa-devel,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 174 bytes --]

On Wed, Dec 04, 2013 at 10:37:04AM +0800, Bo Shen wrote:
> Change sam9x5 with wm8731 work in DSP A mode, this will fix the
> left/right channel swap issue.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A mode
  2013-12-04 11:38   ` Richard Genoud
@ 2013-12-04 15:54     ` Zhong Li
  2013-12-04 16:06       ` Richard Genoud
  0 siblings, 1 reply; 9+ messages in thread
From: Zhong Li @ 2013-12-04 15:54 UTC (permalink / raw)
  To: 'Richard Genoud'
  Cc: alsa-devel, broonie, nicolas.ferre, linux-arm-kernel, linux-sound

Richard,

> -----Original Message-----
> From: linux-arm-kernel [mailto:linux-arm-kernel-
> bounces@lists.infradead.org] On Behalf Of Richard Genoud
> Sent: Wednesday, December 04, 2013 6:38 AM
> To: Bo Shen
> Cc: zql@glomationinc.com; nicolas.ferre@atmel.com; alsa-devel@alsa-
> project.org; linux-sound@vger.kernel.org; broonie@kernel.org; linux-
> arm-kernel@lists.infradead.org
> Subject: Re: [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A
> mode
> 
> On 04/12/2013 03:37, Bo Shen wrote:
> > Change sam9x5 with wm8731 work in DSP A mode, this will fix the
> > left/right channel swap issue.
> >

> >
> Tested-by: Richard Genoud <richard.genoud@gmail.com> on at91sam9g35-ek
> with 3.12-rc2 + "ASoC: wm8731: fix dsp mode configuration"
> 
> 
> Thanks !
> 
> 

Where can I get a snap shot of your kernel source?  My test still have the
same issue after I applied the two patches.


Thanks,

Zhong

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

* Re: [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A mode
  2013-12-04 15:54     ` Zhong Li
@ 2013-12-04 16:06       ` Richard Genoud
  0 siblings, 0 replies; 9+ messages in thread
From: Richard Genoud @ 2013-12-04 16:06 UTC (permalink / raw)
  To: Zhong Li
  Cc: Nicolas Ferre, alsa-devel, linux-sound, Mark Brown,
	linux-arm-kernel@lists.infradead.org

2013/12/4 Zhong Li <zql@glomationinc.com>:
> Richard,
>
>> -----Original Message-----
>> From: linux-arm-kernel [mailto:linux-arm-kernel-
>> bounces@lists.infradead.org] On Behalf Of Richard Genoud
>> Sent: Wednesday, December 04, 2013 6:38 AM
>> To: Bo Shen
>> Cc: zql@glomationinc.com; nicolas.ferre@atmel.com; alsa-devel@alsa-
>> project.org; linux-sound@vger.kernel.org; broonie@kernel.org; linux-
>> arm-kernel@lists.infradead.org
>> Subject: Re: [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A
>> mode
>>
>> On 04/12/2013 03:37, Bo Shen wrote:
>> > Change sam9x5 with wm8731 work in DSP A mode, this will fix the
>> > left/right channel swap issue.
>> >
>
>> >
>> Tested-by: Richard Genoud <richard.genoud@gmail.com> on at91sam9g35-ek
>> with 3.12-rc2 + "ASoC: wm8731: fix dsp mode configuration"
>>
>>
>> Thanks !
>>
>>
>
> Where can I get a snap shot of your kernel source?  My test still have the
> same issue after I applied the two patches.

I don't have a public git, but I just applied the patches :
"ASoC: wm8731: fix dsp mode configuration"
"ASoC: sam9x5_wm8731: change to work in DSP A mode"
"ASoC: atmel_ssc_dai: add dai trigger ops"
on top of 3.12-rc2
=> maybe you missed the third patch "ASoC: wm8731: fix dsp mode
configuration" which was not part of the serie.
(without it, you should have a left channel almost ok and a noisy right channel)

and if you want a git tree, you can still test with mark's :
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
branch sound_asoc/for-next or tag asoc-v3.13-rc2

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

end of thread, other threads:[~2013-12-04 16:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-04  2:37 [PATCH 0/2] ASoC: sam9x5_wm8731: fix left right channel swap issue Bo Shen
2013-12-04  2:37 ` [PATCH 1/2] ASoC: atmel_ssc_dai: add dai trigger ops Bo Shen
2013-12-04 11:38   ` Richard Genoud
2013-12-04 11:43   ` Mark Brown
2013-12-04  2:37 ` [PATCH 2/2] ASoC: sam9x5_wm8731: change to work in DSP A mode Bo Shen
2013-12-04 11:38   ` Richard Genoud
2013-12-04 15:54     ` Zhong Li
2013-12-04 16:06       ` Richard Genoud
2013-12-04 11:44   ` 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).