All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sun-cs4231: mce_down cleanup after ad1848
@ 2007-09-19 21:37 Krzysztof Helt
  2007-09-20 12:36 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Helt @ 2007-09-19 21:37 UTC (permalink / raw)
  To: Alsa-devel

From: Krzysztof Helt <krzysztof.h1@wp.pl>

This simplifies and fixes waiting loops of the mce_down()
function after Trent Piepho's patch for AD1848.
It also makes busy_wait() function call not atomic.

Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>

---

diff -urp linux-ref/sound/sparc/cs4231.c linux-2.6.23/sound/sparc/cs4231.c
--- linux-ref/sound/sparc/cs4231.c	2007-09-19 23:31:30.603838619 +0200
+++ linux-2.6.23/sound/sparc/cs4231.c	2007-09-19 23:23:24.552140109 +0200
@@ -392,62 +392,45 @@ static void snd_cs4231_mce_up(struct snd
 
 static void snd_cs4231_mce_down(struct snd_cs4231 *chip)
 {
-	unsigned long flags;
-	int timeout;
+	unsigned long flags, timeout;
+	int reg;
 
-	spin_lock_irqsave(&chip->lock, flags);
 	snd_cs4231_busy_wait(chip);
+	spin_lock_irqsave(&chip->lock, flags);
 #ifdef CONFIG_SND_DEBUG
 	if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT)
 		snd_printdd("mce_down [%p] - auto calibration time out (0)\n",
 			    CS4231U(chip, REGSEL));
 #endif
 	chip->mce_bit &= ~CS4231_MCE;
-	timeout = __cs4231_readb(chip, CS4231U(chip, REGSEL));
-	__cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f),
+	reg = __cs4231_readb(chip, CS4231U(chip, REGSEL));
+	__cs4231_writeb(chip, chip->mce_bit | (reg & 0x1f),
 			CS4231U(chip, REGSEL));
-	if (timeout == 0x80)
-		snd_printdd("mce_down [%p]: serious init problem - codec still busy\n", chip->port);
-	if ((timeout & CS4231_MCE) == 0) {
+	if (reg == 0x80)
+		snd_printdd("mce_down [%p]: serious init problem "
+			    "- codec still busy\n", chip->port);
+	if ((reg & CS4231_MCE) == 0) {
 		spin_unlock_irqrestore(&chip->lock, flags);
 		return;
 	}
-	snd_cs4231_busy_wait(chip);
 
-	/* calibration process */
+	/*
+	 * Wait for auto-calibration (AC) process to finish, i.e. ACI to go low.
+	 */
 
-	snd_cs4231_ready(chip);
-	snd_cs4231_ready(chip);
-	if ((snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) == 0) {
-		snd_printd("cs4231_mce_down - auto calibration time out (1)\n");
+	timeout = jiffies + msecs_to_jiffies(250);
+	do {
 		spin_unlock_irqrestore(&chip->lock, flags);
-		return;
-	}
-
-	/* in 10ms increments, check condition, up to 250ms */
-	timeout = 25;
-	while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) {
-		spin_unlock_irqrestore(&chip->lock, flags);
-		if (--timeout < 0) {
-			snd_printk("mce_down - auto calibration time out (2)\n");
-			return;
-		}
-		msleep(10);
-		spin_lock_irqsave(&chip->lock, flags);
-	}
-
-	/* in 10ms increments, check condition, up to 100ms */
-	timeout = 10;
-	while (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) {
-		spin_unlock_irqrestore(&chip->lock, flags);
-		if (--timeout < 0) {
-			snd_printk("mce_down - auto calibration time out (3)\n");
-			return;
-		}
-		msleep(10);
+		msleep(1);
 		spin_lock_irqsave(&chip->lock, flags);
-	}
+		reg = snd_cs4231_in(chip, CS4231_TEST_INIT);
+		reg &= CS4231_CALIB_IN_PROGRESS;
+	} while (reg && time_before(jiffies, timeout));
 	spin_unlock_irqrestore(&chip->lock, flags);
+
+	if (reg)
+		snd_printk(KERN_ERR
+			   "mce_down - auto calibration time out (2)\n");
 }
 
 static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont,

----------------------------------------------------------------------
Bedac w toalecie korzystala z ...

>>>  http://link.interia.pl/f1bd8 

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

* Re: [PATCH] sun-cs4231: mce_down cleanup after ad1848
  2007-09-19 21:37 [PATCH] sun-cs4231: mce_down cleanup after ad1848 Krzysztof Helt
@ 2007-09-20 12:36 ` Takashi Iwai
  2007-09-20 14:46   ` Krzysztof Helt
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2007-09-20 12:36 UTC (permalink / raw)
  To: Krzysztof Helt; +Cc: Alsa-devel

At Wed, 19 Sep 2007 23:37:42 +0200,
Krzysztof Helt wrote:
> 
> From: Krzysztof Helt <krzysztof.h1@wp.pl>
> 
> This simplifies and fixes waiting loops of the mce_down()
> function after Trent Piepho's patch for AD1848.
> It also makes busy_wait() function call not atomic.
> 
> Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>

I can't apply it cleanly on HG tree.  Which patch is missing?


thanks,

Takashi

> 
> ---
> 
> diff -urp linux-ref/sound/sparc/cs4231.c linux-2.6.23/sound/sparc/cs4231.c
> --- linux-ref/sound/sparc/cs4231.c	2007-09-19 23:31:30.603838619 +0200
> +++ linux-2.6.23/sound/sparc/cs4231.c	2007-09-19 23:23:24.552140109 +0200
> @@ -392,62 +392,45 @@ static void snd_cs4231_mce_up(struct snd
>  
>  static void snd_cs4231_mce_down(struct snd_cs4231 *chip)
>  {
> -	unsigned long flags;
> -	int timeout;
> +	unsigned long flags, timeout;
> +	int reg;
>  
> -	spin_lock_irqsave(&chip->lock, flags);
>  	snd_cs4231_busy_wait(chip);
> +	spin_lock_irqsave(&chip->lock, flags);
>  #ifdef CONFIG_SND_DEBUG
>  	if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT)
>  		snd_printdd("mce_down [%p] - auto calibration time out (0)\n",
>  			    CS4231U(chip, REGSEL));
>  #endif
>  	chip->mce_bit &= ~CS4231_MCE;
> -	timeout = __cs4231_readb(chip, CS4231U(chip, REGSEL));
> -	__cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f),
> +	reg = __cs4231_readb(chip, CS4231U(chip, REGSEL));
> +	__cs4231_writeb(chip, chip->mce_bit | (reg & 0x1f),
>  			CS4231U(chip, REGSEL));
> -	if (timeout == 0x80)
> -		snd_printdd("mce_down [%p]: serious init problem - codec still busy\n", chip->port);
> -	if ((timeout & CS4231_MCE) == 0) {
> +	if (reg == 0x80)
> +		snd_printdd("mce_down [%p]: serious init problem "
> +			    "- codec still busy\n", chip->port);
> +	if ((reg & CS4231_MCE) == 0) {
>  		spin_unlock_irqrestore(&chip->lock, flags);
>  		return;
>  	}
> -	snd_cs4231_busy_wait(chip);
>  
> -	/* calibration process */
> +	/*
> +	 * Wait for auto-calibration (AC) process to finish, i.e. ACI to go low.
> +	 */
>  
> -	snd_cs4231_ready(chip);
> -	snd_cs4231_ready(chip);
> -	if ((snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) == 0) {
> -		snd_printd("cs4231_mce_down - auto calibration time out (1)\n");
> +	timeout = jiffies + msecs_to_jiffies(250);
> +	do {
>  		spin_unlock_irqrestore(&chip->lock, flags);
> -		return;
> -	}
> -
> -	/* in 10ms increments, check condition, up to 250ms */
> -	timeout = 25;
> -	while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) {
> -		spin_unlock_irqrestore(&chip->lock, flags);
> -		if (--timeout < 0) {
> -			snd_printk("mce_down - auto calibration time out (2)\n");
> -			return;
> -		}
> -		msleep(10);
> -		spin_lock_irqsave(&chip->lock, flags);
> -	}
> -
> -	/* in 10ms increments, check condition, up to 100ms */
> -	timeout = 10;
> -	while (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) {
> -		spin_unlock_irqrestore(&chip->lock, flags);
> -		if (--timeout < 0) {
> -			snd_printk("mce_down - auto calibration time out (3)\n");
> -			return;
> -		}
> -		msleep(10);
> +		msleep(1);
>  		spin_lock_irqsave(&chip->lock, flags);
> -	}
> +		reg = snd_cs4231_in(chip, CS4231_TEST_INIT);
> +		reg &= CS4231_CALIB_IN_PROGRESS;
> +	} while (reg && time_before(jiffies, timeout));
>  	spin_unlock_irqrestore(&chip->lock, flags);
> +
> +	if (reg)
> +		snd_printk(KERN_ERR
> +			   "mce_down - auto calibration time out (2)\n");
>  }
>  
>  static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont,
> 
> ----------------------------------------------------------------------
> Bedac w toalecie korzystala z ...
> 
> >>>  http://link.interia.pl/f1bd8 
> 
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

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

* Re: [PATCH] sun-cs4231: mce_down cleanup after ad1848
  2007-09-20 12:36 ` Takashi Iwai
@ 2007-09-20 14:46   ` Krzysztof Helt
  2007-09-20 14:50     ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Helt @ 2007-09-20 14:46 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Alsa-devel

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

On Thu, 20 Sep 2007 14:36:26 +0200
Takashi Iwai <tiwai@suse.de> wrote:

> At Wed, 19 Sep 2007 23:37:42 +0200,
> Krzysztof Helt wrote:
> > 
> > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> > 
> > This simplifies and fixes waiting loops of the mce_down()
> > function after Trent Piepho's patch for AD1848.
> > It also makes busy_wait() function call not atomic.
> > 
> > Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
> 
> I can't apply it cleanly on HG tree.  Which patch is missing?
> 
> 

That's my fault. I took a wrong file as a reference. The correct patch
is attached (cs4231-mce.diff).

BTW. The file which I downloaded from the HG tree does not compile.
If you can apply the patch cs4231-compile.diff there is an error in the
HG tree (introduced by importing a patch from Linux kernel). 
The cs4231-compile fixes the compilation error.

Regards,
Krzysztof




----------------------------------------------------------------------
Wygrasz, czy przegrasz?

>>> http://link.interia.pl/f1bbd

[-- Attachment #2: cs4231-mce.diff --]
[-- Type: application/octet-stream, Size: 3025 bytes --]

diff -urp linux-sparc/sound/sparc/cs4231.c linux-2.6.23/sound/sparc/cs4231.c
--- linux-sparc/sound/sparc/cs4231.c	2007-09-19 23:31:16.000000000 +0200
+++ linux-2.6.23/sound/sparc/cs4231.c	2007-09-20 15:37:24.859844619 +0200
@@ -400,65 +400,44 @@ static void snd_cs4231_mce_up(struct snd
 
 static void snd_cs4231_mce_down(struct snd_cs4231 *chip)
 {
-	unsigned long flags;
-	unsigned long end_time;
-	int timeout;
+	unsigned long flags, timeout;
+	int reg;
 
-	spin_lock_irqsave(&chip->lock, flags);
 	snd_cs4231_busy_wait(chip);
+	spin_lock_irqsave(&chip->lock, flags);
 #ifdef CONFIG_SND_DEBUG
 	if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT)
 		snd_printdd("mce_down [%p] - auto calibration time out (0)\n",
 			    CS4231U(chip, REGSEL));
 #endif
 	chip->mce_bit &= ~CS4231_MCE;
-	timeout = __cs4231_readb(chip, CS4231U(chip, REGSEL));
-	__cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f),
+	reg = __cs4231_readb(chip, CS4231U(chip, REGSEL));
+	__cs4231_writeb(chip, chip->mce_bit | (reg & 0x1f),
 			CS4231U(chip, REGSEL));
-	if (timeout == 0x80)
-		snd_printdd("mce_down [%p]: serious init problem - "
-			    "codec still busy\n",
-			    chip->port);
-	if ((timeout & CS4231_MCE) == 0) {
+	if (reg == 0x80)
+		snd_printdd("mce_down [%p]: serious init problem "
+			    "- codec still busy\n", chip->port);
+	if ((reg & CS4231_MCE) == 0) {
 		spin_unlock_irqrestore(&chip->lock, flags);
 		return;
 	}
 
 	/*
-	 * Wait for (possible -- during init auto-calibration may not be set)
-	 * calibration process to start. Needs upto 5 sample periods on AD1848
-	 * which at the slowest possible rate of 5.5125 kHz means 907 us.
+	 * Wait for auto-calibration (AC) process to finish, i.e. ACI to go low.
 	 */
-	msleep(1);
-
-	/* check condition up to 250ms */
-	end_time = jiffies + msecs_to_jiffies(250);
-	while (snd_cs4231_in(chip, CS4231_TEST_INIT) &
-		CS4231_CALIB_IN_PROGRESS) {
-
-		spin_unlock_irqrestore(&chip->lock, flags);
-		if (time_after(jiffies, end_time)) {
-			snd_printk("mce_down - "
-				   "auto calibration time out (2)\n");
-			return;
-		}
-		msleep(1);
-		spin_lock_irqsave(&chip->lock, flags);
-	}
-
-	/* check condition up to 100ms */
-	end_time = jiffies + msecs_to_jiffies(100);
-	while (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) {
+	timeout = jiffies + msecs_to_jiffies(250);
+	do {
 		spin_unlock_irqrestore(&chip->lock, flags);
-		if (time_after(jiffies, end_time)) {
-			snd_printk("mce_down - "
-				   "auto calibration time out (3)\n");
-			return;
-		}
 		msleep(1);
 		spin_lock_irqsave(&chip->lock, flags);
-	}
+		reg = snd_cs4231_in(chip, CS4231_TEST_INIT);
+		reg &= CS4231_CALIB_IN_PROGRESS;
+	} while (reg && time_before(jiffies, timeout));
 	spin_unlock_irqrestore(&chip->lock, flags);
+
+	if (reg)
+		snd_printk(KERN_ERR
+			   "mce_down - auto calibration time out (2)\n");
 }
 
 static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont,

[-- Attachment #3: cs4231-compile.diff --]
[-- Type: application/octet-stream, Size: 645 bytes --]

Only in linux-2.6.23/sound/sparc/: .built-in.o.cmd
Only in linux-2.6.23/sound/sparc/: built-in.o
diff -urp linux-sparc/sound/sparc/cs4231.c linux-2.6.23/sound/sparc/cs4231.c
--- linux-sparc/sound/sparc/cs4231.c	2007-09-19 23:31:16.000000000 +0200
+++ linux-2.6.23/sound/sparc/cs4231.c	2007-09-20 16:43:58.423177145 +0200
@@ -1089,10 +1068,6 @@ static int __init snd_cs4231_probe(struc
 
 	spin_lock_irqsave(&chip->lock, flags);
 
-
-	/* Reset DMA engine (sbus only).  */
-	chip->p_dma.reset(chip);
-
 	/* clear any pendings IRQ */
 	__cs4231_readb(chip, CS4231U(chip, STATUS));
 	__cs4231_writeb(chip, 0, CS4231U(chip, STATUS));

[-- Attachment #4: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH] sun-cs4231: mce_down cleanup after ad1848
  2007-09-20 14:46   ` Krzysztof Helt
@ 2007-09-20 14:50     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2007-09-20 14:50 UTC (permalink / raw)
  To: Krzysztof Helt; +Cc: Alsa-devel

At Thu, 20 Sep 2007 16:46:18 +0200,
Krzysztof Helt wrote:
> 
> On Thu, 20 Sep 2007 14:36:26 +0200
> Takashi Iwai <tiwai@suse.de> wrote:
> 
> > At Wed, 19 Sep 2007 23:37:42 +0200,
> > Krzysztof Helt wrote:
> > > 
> > > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> > > 
> > > This simplifies and fixes waiting loops of the mce_down()
> > > function after Trent Piepho's patch for AD1848.
> > > It also makes busy_wait() function call not atomic.
> > > 
> > > Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
> > 
> > I can't apply it cleanly on HG tree.  Which patch is missing?
> > 
> > 
> 
> That's my fault. I took a wrong file as a reference. The correct patch
> is attached (cs4231-mce.diff).

OK, I queued it up to my local tree for the future merge.

> BTW. The file which I downloaded from the HG tree does not compile.
> If you can apply the patch cs4231-compile.diff there is an error in the
> HG tree (introduced by importing a patch from Linux kernel). 
> The cs4231-compile fixes the compilation error.

Oh, thanks, now applied to HG tree.


Takashi

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

end of thread, other threads:[~2007-09-20 14:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-19 21:37 [PATCH] sun-cs4231: mce_down cleanup after ad1848 Krzysztof Helt
2007-09-20 12:36 ` Takashi Iwai
2007-09-20 14:46   ` Krzysztof Helt
2007-09-20 14:50     ` Takashi Iwai

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.