All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ad1838/cs4231 -- fix MCE timeout upon initial load
@ 2007-09-10 18:29 Rene Herman
  2007-09-10 21:40 ` Krzysztof Helt
  2007-09-17 21:04 ` Trent Piepho
  0 siblings, 2 replies; 36+ messages in thread
From: Rene Herman @ 2007-09-10 18:29 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Krzysztof Helt, ALSA devel

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

Hi Takashi.

When the ad1848/cs2431 is first being initialized, auto-calibration may not 
be set causing a timeout waiting for it in snd_ad1848/cs4231_mce_down().

This has no dire consequences other than an alarming printk, but since what 
we need to wait for is for the calibration to _finish_, let's just check for 
that instead.

The early chips need a slight delay (as commented -- 5 sample periods) to be 
sure that _if_ calibration is going to happen, it has started when we check 
While the CS4231A datasheet implies it'll happen immediately on downing MCE, 
some testing is showing that there's a window there as well, so just do the 
delay everywhere.

Thanks to Krysztof Helt for pinpointing this problem.

Signed-off-by: Rene Herman <rene.herman@gmail.com>

Rene.

[-- Attachment #2: mce_down.diff --]
[-- Type: text/plain, Size: 2226 bytes --]

diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c
index 8094282..dcd4435 100644
--- a/sound/isa/ad1848/ad1848_lib.c
+++ b/sound/isa/ad1848/ad1848_lib.c
@@ -227,16 +227,15 @@ static void snd_ad1848_mce_down(struct snd_ad1848 *chip)
 		spin_unlock_irqrestore(&chip->reg_lock, flags);
 		return;
 	}
-	/* calibration process */
 
-	for (timeout = 500; timeout > 0 && (snd_ad1848_in(chip, AD1848_TEST_INIT) & AD1848_CALIB_IN_PROGRESS) == 0; timeout--);
-	if ((snd_ad1848_in(chip, AD1848_TEST_INIT) & AD1848_CALIB_IN_PROGRESS) == 0) {
-		snd_printd("mce_down - auto calibration time out (1)\n");
-		spin_unlock_irqrestore(&chip->reg_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.
+         */
+        msleep(1);
 #if 0
-	printk("(2) timeout = %i, jiffies = %li\n", timeout, jiffies);
+	printk("(2) jiffies = %li\n", jiffies);
 #endif
 	time = HZ / 4;
 	while (snd_ad1848_in(chip, AD1848_TEST_INIT) & AD1848_CALIB_IN_PROGRESS) {
diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c
index 914d77b..9e8e0f1 100644
--- a/sound/isa/cs423x/cs4231_lib.c
+++ b/sound/isa/cs423x/cs4231_lib.c
@@ -346,16 +346,14 @@ void snd_cs4231_mce_down(struct snd_cs4231 *chip)
 	}
 	snd_cs4231_busy_wait(chip);
 
-	/* calibration process */
-
-	for (timeout = 500; timeout > 0 && (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) == 0; timeout--)
-		udelay(10);
-	if ((snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) == 0) {
-		snd_printd("cs4231_mce_down - auto calibration time out (1)\n");
-		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.
+	 */
+	msleep(1);
 #if 0
-	printk("(2) timeout = %i, jiffies = %li\n", timeout, jiffies);
+	printk("(2) jiffies = %li\n", jiffies);
 #endif
 	/* in 10 ms increments, check condition, up to 250 ms */
 	timeout = 25;

[-- Attachment #3: 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 related	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2007-09-19  2:49 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-10 18:29 [PATCH] ad1838/cs4231 -- fix MCE timeout upon initial load Rene Herman
2007-09-10 21:40 ` Krzysztof Helt
2007-09-10 21:37   ` Takashi Iwai
2007-09-10 21:43   ` Rene Herman
2007-09-10 21:45     ` Rene Herman
2007-09-11  8:56     ` Krzysztof Helt
2007-09-11 20:42       ` Rene Herman
2007-09-17 21:04 ` Trent Piepho
2007-09-17 21:47   ` Krzysztof Helt
2007-09-18  1:18     ` Trent Piepho
2007-09-18  7:20       ` Krzysztof Helt
2007-09-19  1:27         ` Trent Piepho
2007-09-19  2:48           ` Rene Herman
2007-09-18  0:17   ` Rene Herman
2007-09-18  1:57     ` Rene Herman
2007-09-18  4:24       ` Rene Herman
2007-09-18 11:03         ` Rene Herman
2007-09-18 11:54         ` Takashi Iwai
2007-09-18 13:38           ` [ PATCH 1/4] alsa-kernel: schedule_timeout() fixes Rene Herman
2007-09-18 16:39             ` Takashi Iwai
2007-09-18 13:49           ` [PATCH 2/4] alsa-kernel: schedule_timeout() fix for kernel/drivers/input/touchscreen/ucb1400_ts.c Rene Herman
2007-09-18 13:58             ` Takashi Iwai
2007-09-18 13:58               ` Rene Herman
2007-09-18 13:57           ` [PATCH] ad1838/cs4231 -- fix MCE timeout upon initial load Rene Herman
2007-09-18 14:27             ` [PATCH 3/4] alsa-kernel: schedule_timeout() fix for core/seq/seq_instr.c Rene Herman
2007-09-18 16:38             ` [PATCH] ad1838/cs4231 -- fix MCE timeout upon initial load Takashi Iwai
2007-09-18 14:34           ` [PATCH 4/4] alsa-driver: schedule_timeout() fixes Rene Herman
2007-09-18 16:44             ` Takashi Iwai
2007-09-18 17:05               ` Rene Herman
2007-09-18 17:09                 ` Rene Herman
2007-09-18 17:22                   ` Takashi Iwai
2007-09-18  2:32     ` [PATCH] ad1838/cs4231 -- fix MCE timeout upon initial load Trent Piepho
2007-09-18  6:50       ` Rene Herman
2007-09-18  7:33       ` Krzysztof Helt
2007-09-18  8:02       ` Krzysztof Helt
2007-09-18  8:17         ` Rene Herman

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.