All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cs4231-lib: improved waiting after mce_down
@ 2007-09-09 20:11 Krzysztof Helt
  2007-09-10 21:31 ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Krzysztof Helt @ 2007-09-09 20:11 UTC (permalink / raw)
  To: Alsa-devel

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

This patch replaces long msleeps in waiting loops
with schedule_timeout() calls.

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

The cs4231 is quite fast and calibration takes about 2ms 
at 48kHz (the quickest). Loops wait in 10ms steps which
is usually too long.

This is done after the ad1848-lib driver, which waits in
this improved way. This makes the cs4231-lib and ad1848-lib
more similar and should help merging of the two.

Regards,
Krzysztof

diff -urp linux-2.6.22.old/sound/isa/cs423x/cs4231_lib.c linux-2.6.22/sound/isa/cs423x/cs4231_lib.c
--- linux-2.6.22.old/sound/isa/cs423x/cs4231_lib.c	2007-09-09 20:33:52.000000000 +0200
+++ linux-2.6.22/sound/isa/cs423x/cs4231_lib.c	2007-09-09 20:31:27.000000000 +0200
@@ -314,6 +314,7 @@ void snd_cs4231_mce_down(struct snd_cs42
 {
 	unsigned long flags;
 	int timeout;
+	long time;
 
 	snd_cs4231_busy_wait(chip);
 #if 0
@@ -340,31 +341,34 @@ void snd_cs4231_mce_down(struct snd_cs42
 
 	snd_printd("(2) jiffies = %li\n", jiffies);
 
-	/* in 10 ms increments, check condition, up to 250 ms */
-	timeout = 25;
+	time = HZ / 4;
 	while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) {
-		if (--timeout < 0) {
-			snd_printk("mce_down - auto calibration time out (2)\n");
+		spin_unlock_irqrestore(&chip->reg_lock, flags);
+		if (time <= 0) {
+			snd_printk(KERN_ERR "mce_down - "
+				   "auto calibration time out (2)\n");
 			return;
 		}
-		msleep(10);
+		time = schedule_timeout(time);
+		spin_lock_irqsave(&chip->reg_lock, flags);
 	}
-#if 0
-	printk("(3) jiffies = %li\n", jiffies);
-#endif
-	/* in 10 ms increments, check condition, up to 100 ms */
-	timeout = 10;
+
+	snd_printd("(3) jiffies = %li\n", jiffies);
+
+	time = HZ / 10;
 	while (cs4231_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) {
-		if (--timeout < 0) {
-			snd_printk(KERN_ERR "mce_down - auto calibration time out (3)\n");
+		spin_unlock_irqrestore(&chip->reg_lock, flags);
+		if (time <= 0) {
+			snd_printk(KERN_ERR "mce_down - "
+				   "auto calibration time out (3)\n");
 			return;
 		}
-		msleep(10);
+		time = schedule_timeout(time);
+		spin_lock_irqsave(&chip->reg_lock, flags);
 	}
-#if 0
-	printk("(4) jiffies = %li\n", jiffies);
-	snd_printk("mce_down - exit = 0x%x\n", cs4231_inb(chip, CS4231P(REGSEL)));
-#endif
+	snd_printd("(4) jiffies = %li\n", jiffies);
+	snd_printk("mce_down - exit = 0x%x\n",
+		   cs4231_inb(chip, CS4231P(REGSEL)));
 }
 
 static unsigned int snd_cs4231_get_count(unsigned char format, unsigned int size)

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

end of thread, other threads:[~2007-09-11  8:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-09 20:11 [PATCH] cs4231-lib: improved waiting after mce_down Krzysztof Helt
2007-09-10 21:31 ` Takashi Iwai
2007-09-10 22:40   ` [PATCH] cs4231-lib: improved waiting after mce_down (2nd rev) Krzysztof Helt
2007-09-10 22:41     ` Takashi Iwai
2007-09-10 22:43     ` Rene Herman
2007-09-10 23:08       ` Takashi Iwai
2007-09-10 23:17         ` Takashi Iwai
2007-09-11  0:40           ` Rene Herman
2007-09-11  4:52             ` Krzysztof Helt
2007-09-11  8:39           ` Krzysztof Helt

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.