[alsa-devel] [PATCH] sun-cs4231: mce_down cleanup after ad1848
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 ...
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);
spin_lock_irqsave(&chip->lock, flags);msleep(1);
- }
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 ...
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
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?
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
participants (2)
-
Krzysztof Helt
-
Takashi Iwai