All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Timur Tabi <timur@freescale.com>
Cc: alsa-devel@alsa-project.org,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH] ALSA: soc - fsl_ssi.c fix audio capture
Date: Thu, 3 Jul 2008 18:37:14 +0400	[thread overview]
Message-ID: <20080703143714.GA7003@polina.dev.rtsoft.ru> (raw)

Since we're using SSI in synchronous mode, the STCCR register controls
both the receive and transmit sections. So, when we're trying to record
anything, stccr register does not get initialized, thus the output file
filled with the white noise.

Fix this by initializing the STCCR for both playback and capture. If
TX/RX widths don't match, return that we're busy at the moment.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 sound/soc/fsl/fsl_ssi.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index f588545..31f689e 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -372,16 +372,24 @@ static int fsl_ssi_prepare(struct snd_pcm_substream *substream)
 
 	struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
 	u32 wl;
+	u32 cur_wl;
 
 	wl = CCSR_SSI_SxCCR_WL(snd_pcm_format_width(runtime->format));
 
-	clrbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN);
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		clrsetbits_be32(&ssi->stccr, CCSR_SSI_SxCCR_WL_MASK, wl);
-	else
-		clrsetbits_be32(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl);
+	/*
+	 * MPC8610 spec says: "The STCCR register is dedicated to the transmit
+	 * section, and the SRCCR register is dedicated to the receive section
+	 * except in Synchronous mode, in which the STCCR register controls
+	 * both the receive and transmit sections."
+	 * So, the width for TX and RX should match, otherwise we're busy with
+	 * either TX or RX.
+	 */
+	cur_wl = in_be32(&ssi->stccr) & CCSR_SSI_SxCCR_WL_MASK;
+	if (cur_wl && cur_wl != wl)
+		return -EBUSY;
 
+	clrbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN);
+	clrsetbits_be32(&ssi->stccr, CCSR_SSI_SxCCR_WL_MASK, wl);
 	setbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN);
 
 	return 0;
@@ -460,6 +468,7 @@ static void fsl_ssi_shutdown(struct snd_pcm_substream *substream)
 		struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
 
 		clrbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN);
+		clrsetbits_be32(&ssi->stccr, CCSR_SSI_SxCCR_WL_MASK, 0);
 
 		free_irq(ssi_private->irq, ssi_private);
 	}
-- 
1.5.5.4

             reply	other threads:[~2008-07-03 14:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-03 14:37 Anton Vorontsov [this message]
2008-07-03 14:42 ` [PATCH] ALSA: soc - fsl_ssi.c fix audio capture Mark Brown
2008-07-04 11:02   ` Timur Tabi
2008-07-04 11:01     ` Mark Brown
2008-07-04 11:08       ` Timur Tabi
2008-07-04 14:49     ` Takashi Iwai
2008-07-04 15:43     ` Anton Vorontsov
2008-07-04 15:43       ` [PATCH 1/2] " Anton Vorontsov
2008-07-21 14:56         ` Timur Tabi
2008-07-04 15:44       ` [PATCH 2/2] ALSA: soc - cs4270: fix ADC/DAC rate matching Anton Vorontsov
2008-07-21 14:54         ` Timur Tabi
2008-07-21 11:15       ` [PATCH] ALSA: soc - fsl_ssi.c fix audio capture Anton Vorontsov
2008-07-21 14:35         ` Timur Tabi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080703143714.GA7003@polina.dev.rtsoft.ru \
    --to=avorontsov@ru.mvista.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=timur@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.