linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: linuxppc-dev@lists.ozlabs.org, alsa-devel@alsa-project.org,
	broonie@opensource.wolfsonmicro.com
Cc: lrg@slimlogic.co.uk
Subject: [PATCH 5/6] ASoC/mpc5200: fix enable/disable of AC97 slots
Date: Sat, 07 Nov 2009 01:34:43 -0700	[thread overview]
Message-ID: <20091107083436.18908.42234.stgit@angua> (raw)
In-Reply-To: <20091107081631.18908.82921.stgit@angua>

The MPC5200 AC97 driver is disabling the slots when a stop
trigger is received, but not reenabling them if the stream
is started again without processing the hw_params again.

This patch fixes the problem by caching the slot enable bit
settings calculated at hw_params time so that they can be
reapplied every time the start trigger is received.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---

 sound/soc/fsl/mpc5200_dma.h      |    4 ++++
 sound/soc/fsl/mpc5200_psc_ac97.c |   39 ++++++++++++++++++++------------------
 2 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h
index 956d6a5..22208b3 100644
--- a/sound/soc/fsl/mpc5200_dma.h
+++ b/sound/soc/fsl/mpc5200_dma.h
@@ -16,6 +16,7 @@
  * @period_end:		physical address of end of DMA region
  * @period_next_pt:	physical address of next DMA buffer to enqueue
  * @period_bytes:	size of DMA period in bytes
+ * @ac97_slot_bits:	Enable bits for turning on the correct AC97 slot
  */
 struct psc_dma_stream {
 	struct snd_pcm_runtime *runtime;
@@ -28,6 +29,9 @@ struct psc_dma_stream {
 	int period_current;
 	int period_bytes;
 	int period_count;
+
+	/* AC97 state */
+	u32 ac97_slot_bits;
 };
 
 /**
diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c
index c4ae3e0..3dbc7f7 100644
--- a/sound/soc/fsl/mpc5200_psc_ac97.c
+++ b/sound/soc/fsl/mpc5200_psc_ac97.c
@@ -130,6 +130,7 @@ static int psc_ac97_hw_analog_params(struct snd_pcm_substream *substream,
 				 struct snd_soc_dai *cpu_dai)
 {
 	struct psc_dma *psc_dma = cpu_dai->private_data;
+	struct psc_dma_stream *s = to_psc_dma_stream(substream, psc_dma);
 
 	dev_dbg(psc_dma->dev, "%s(substream=%p) p_size=%i p_bytes=%i"
 		" periods=%i buffer_size=%i  buffer_bytes=%i channels=%i"
@@ -140,20 +141,10 @@ static int psc_ac97_hw_analog_params(struct snd_pcm_substream *substream,
 		params_channels(params), params_rate(params),
 		params_format(params));
 
-
-	if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) {
-		if (params_channels(params) == 1)
-			psc_dma->slots |= 0x00000100;
-		else
-			psc_dma->slots |= 0x00000300;
-	} else {
-		if (params_channels(params) == 1)
-			psc_dma->slots |= 0x01000000;
-		else
-			psc_dma->slots |= 0x03000000;
-	}
-	out_be32(&psc_dma->psc_regs->ac97_slots, psc_dma->slots);
-
+	/* Determine the set of enable bits to turn on */
+	s->ac97_slot_bits = (params_channels(params) == 1) ? 0x100 : 0x300;
+	if (substream->pstr->stream != SNDRV_PCM_STREAM_CAPTURE)
+		s->ac97_slot_bits <<= 16;
 	return 0;
 }
 
@@ -163,6 +154,8 @@ static int psc_ac97_hw_digital_params(struct snd_pcm_substream *substream,
 {
 	struct psc_dma *psc_dma = cpu_dai->private_data;
 
+	dev_dbg(psc_dma->dev, "%s(substream=%p)\n", __func__, substream);
+
 	if (params_channels(params) == 1)
 		out_be32(&psc_dma->psc_regs->ac97_slots, 0x01000000);
 	else
@@ -176,14 +169,24 @@ static int psc_ac97_trigger(struct snd_pcm_substream *substream, int cmd,
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
+	struct psc_dma_stream *s = to_psc_dma_stream(substream, psc_dma);
 
 	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+		dev_dbg(psc_dma->dev, "AC97 START: stream=%i\n",
+			substream->pstr->stream);
+
+		/* Set the slot enable bits */
+		psc_dma->slots |= s->ac97_slot_bits;
+		out_be32(&psc_dma->psc_regs->ac97_slots, psc_dma->slots);
+		break;
+
 	case SNDRV_PCM_TRIGGER_STOP:
-		if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
-			psc_dma->slots &= 0xFFFF0000;
-		else
-			psc_dma->slots &= 0x0000FFFF;
+		dev_dbg(psc_dma->dev, "AC97 STOP: stream=%i\n",
+			substream->pstr->stream);
 
+		/* Clear the slot enable bits */
+		psc_dma->slots &= ~(s->ac97_slot_bits);
 		out_be32(&psc_dma->psc_regs->ac97_slots, psc_dma->slots);
 		break;
 	}

  parent reply	other threads:[~2009-11-07  8:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-07  8:33 [PATCH 0/6] Fixups to MPC5200 ASoC drivers Grant Likely
2009-11-07  8:33 ` [PATCH 1/6] ASoC/mpc5200: Track DMA position by period number instead of bytes Grant Likely
2009-11-07 10:35   ` [alsa-devel] " Liam Girdwood
2009-11-07 16:50     ` Grant Likely
2009-11-07  8:34 ` [PATCH 2/6] ASoC/mpc5200: get rid of the appl_ptr tracking nonsense Grant Likely
2009-11-07 12:51   ` Jon Smirl
2009-11-07 13:04     ` Jon Smirl
2009-11-07 18:53       ` Grant Likely
2009-11-07 18:51     ` Grant Likely
2009-11-07 20:12       ` [alsa-devel] " Mark Brown
2009-11-11 16:38         ` Jon Smirl
2009-11-11 18:37           ` Mark Brown
2009-11-11 19:24             ` Grant Likely
2009-11-11 20:03               ` Mark Brown
2009-11-11 21:34               ` Jon Smirl
2009-11-11 21:57                 ` Grant Likely
2009-11-11 23:13                   ` Jon Smirl
2009-11-12 12:10                     ` Mark Brown
2009-11-11 21:26             ` Jon Smirl
2009-11-07  8:34 ` [PATCH 3/6] ASoC/mpc5200: Improve printk debug output for trigger Grant Likely
2009-11-07  8:34 ` [PATCH 4/6] ASoC/mpc5200: add to_psc_dma_stream() helper Grant Likely
2009-11-07 12:33   ` [alsa-devel] " Mark Brown
2009-11-07  8:34 ` Grant Likely [this message]
2009-11-07  8:34 ` [PATCH 6/6] ASoC/mpc5200: Add fudge factor to value reported by .pointer() Grant Likely
2009-11-07 18:11   ` [alsa-devel] " Mark Brown
2009-11-07 18:19     ` Grant Likely
2009-11-07 19:33       ` Mark Brown
2009-11-07 19:46         ` Grant Likely
2009-11-07 12:57 ` [alsa-devel] [PATCH 0/6] Fixups to MPC5200 ASoC drivers Mark Brown
2009-11-07 16:52   ` Grant Likely

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=20091107083436.18908.42234.stgit@angua \
    --to=grant.likely@secretlab.ca \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lrg@slimlogic.co.uk \
    /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 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).