All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: DaVinci: Audio: Fix swapping of channels at start of stereo playback
@ 2008-11-12  4:56 naresh
  2008-11-12 11:50 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: naresh @ 2008-11-12  4:56 UTC (permalink / raw)
  To: alsa-devel; +Cc: davinci-linux-open-source, Naresh Medisetty

From: Naresh Medisetty <naresh@ti.com>

Fixes swapping of channels at start of stereo playback.

Channel swap can be observed while playing left-only or right-only audio data. The channel 
swap is fixed by handling the XSYNCERR condition.

Signed-off-by: Naresh Medisetty <naresh@ti.com>
---
 sound/soc/davinci/davinci-i2s.c |   49 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index 5ebf1ff..d8279ad 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -110,16 +110,59 @@ static void davinci_mcbsp_start(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct davinci_mcbsp_dev *dev = rtd->dai->cpu_dai->private_data;
+	struct snd_soc_device *socdev = rtd->socdev;
+	struct snd_soc_platform *platform = socdev->platform;
 	u32 w;
+	int ret;
 
 	/* Start the sample generator and enable transmitter/receiver */
 	w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG);
 	MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_GRST, 1);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, w);
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		/* Stop the DMA to avoid data loss */
+		/* while the transmitter is out of reset to handle XSYNCERR */
+		if (platform->pcm_ops->trigger) {
+			ret = platform->pcm_ops->trigger(substream,
+				SNDRV_PCM_TRIGGER_STOP);
+			if (ret < 0)
+				printk(KERN_DEBUG "Playback DMA stop failed\n");
+		}
+
+		/* Enable the transmitter */
+		w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG);
 		MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_XRST, 1);
-	else
+		davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, w);
+
+		/* wait for any unexpected frame sync error to occur */
+		udelay(100);
+
+		/* Disable the transmitter to clear any outstanding XSYNCERR */
+		w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG);
+		MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_XRST, 0);
+		davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, w);
+
+		/* Restart the DMA */
+		if (platform->pcm_ops->trigger) {
+			ret = platform->pcm_ops->trigger(substream,
+				SNDRV_PCM_TRIGGER_START);
+			if (ret < 0)
+				printk(KERN_DEBUG "Playback DMA start failed\n");
+		}
+		/* Enable the transmitter */
+		w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG);
+		MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_XRST, 1);
+		davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, w);
+
+	} else {
+
+		/* Enable the reciever */
+		w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG);
 		MOD_REG_BIT(w, DAVINCI_MCBSP_SPCR_RRST, 1);
-	davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, w);
+		davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, w);
+	}
+
 
 	/* Start frame sync */
 	w = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG);
-- 
1.5.4.1

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

* Re: [PATCH] ASoC: DaVinci: Audio: Fix swapping of channels at start of stereo playback
  2008-11-12  4:56 [PATCH] ASoC: DaVinci: Audio: Fix swapping of channels at start of stereo playback naresh
@ 2008-11-12 11:50 ` Mark Brown
       [not found]   ` <20081112115001.GC8767-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  2008-11-13 14:57   ` Kevin Hilman
  0 siblings, 2 replies; 5+ messages in thread
From: Mark Brown @ 2008-11-12 11:50 UTC (permalink / raw)
  To: naresh; +Cc: alsa-devel, davinci-linux-open-source

On Wed, Nov 12, 2008 at 10:26:31AM +0530, naresh@ti.com wrote:

> Fixes swapping of channels at start of stereo playback.
> 
> Channel swap can be observed while playing left-only or right-only audio data. The channel 
> swap is fixed by handling the XSYNCERR condition.
> 
> Signed-off-by: Naresh Medisetty <naresh@ti.com>

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Do you know what the status is on merging the DMA API that the ASoC
DaVinci driver uses into mainline?

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

* Re: [alsa-devel] [PATCH] ASoC: DaVinci: Audio: Fix swapping of channels at start of stereo playback
       [not found]   ` <20081112115001.GC8767-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2008-11-13 14:32     ` Kevin Hilman
  2008-11-13 14:40       ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Hilman @ 2008-11-13 14:32 UTC (permalink / raw)
  To: Mark Brown
  Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	naresh-l0cyMroinI0, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw

Mark Brown <broonie-GFdadSzt00ze9xe1eoZjHA@public.gmane.org> writes:

> On Wed, Nov 12, 2008 at 10:26:31AM +0530, naresh-l0cyMroinI0@public.gmane.org wrote:
>
>> Fixes swapping of channels at start of stereo playback.
>> 
>> Channel swap can be observed while playing left-only or right-only audio data. The channel 
>> swap is fixed by handling the XSYNCERR condition.
>> 
>> Signed-off-by: Naresh Medisetty <naresh-l0cyMroinI0@public.gmane.org>
>
> Acked-by: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
>
> Do you know what the status is on merging the DMA API that the ASoC
> DaVinci driver uses into mainline?

Hi Mark,

I'm the current maintainer of the DaVinci git kernel[1].  I am working
on syncing the core code (including DMA) with mainline. I may have
things ready for the next merge window, but if not, I'll definitely
have it sync'd for the next one.

Kevin

[1] git://source.mvista.com/git/linux-davinci-2.6.git

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

* Re: [PATCH] ASoC: DaVinci: Audio: Fix swapping of channels at start of stereo playback
  2008-11-13 14:32     ` [alsa-devel] " Kevin Hilman
@ 2008-11-13 14:40       ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2008-11-13 14:40 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: davinci-linux-open-source, naresh, alsa-devel

On Thu, Nov 13, 2008 at 06:32:34AM -0800, Kevin Hilman wrote:
> Mark Brown <broonie@sirena.org.uk> writes:

> > Do you know what the status is on merging the DMA API that the ASoC
> > DaVinci driver uses into mainline?

> I'm the current maintainer of the DaVinci git kernel[1].  I am working
> on syncing the core code (including DMA) with mainline. I may have
> things ready for the next merge window, but if not, I'll definitely
> have it sync'd for the next one.

Ah, that's good news - we keep getting ASoC users confused by the fact
that the current ASoC driver doesn't build with mainline.  Thanks!

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

* Re: [PATCH] ASoC: DaVinci: Audio: Fix swapping of channels at start of stereo playback
  2008-11-12 11:50 ` Mark Brown
       [not found]   ` <20081112115001.GC8767-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2008-11-13 14:57   ` Kevin Hilman
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Hilman @ 2008-11-13 14:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: davinci-linux-open-source, naresh, alsa-devel

Mark Brown <broonie@sirena.org.uk> writes:

> On Wed, Nov 12, 2008 at 10:26:31AM +0530, naresh@ti.com wrote:
>
>> Fixes swapping of channels at start of stereo playback.
>> 
>> Channel swap can be observed while playing left-only or right-only audio data. The channel 
>> swap is fixed by handling the XSYNCERR condition.
>> 
>> Signed-off-by: Naresh Medisetty <naresh@ti.com>
>
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
>

OK, pulling into DaVinci git and will drop when resync with next ASoC.

Kevin

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

end of thread, other threads:[~2008-11-13 14:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-12  4:56 [PATCH] ASoC: DaVinci: Audio: Fix swapping of channels at start of stereo playback naresh
2008-11-12 11:50 ` Mark Brown
     [not found]   ` <20081112115001.GC8767-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2008-11-13 14:32     ` [alsa-devel] " Kevin Hilman
2008-11-13 14:40       ` Mark Brown
2008-11-13 14:57   ` Kevin Hilman

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.