[alsa-devel] Driver code with mpc5200 pointer problem.

Takashi Iwai tiwai at suse.de
Tue Apr 28 08:04:27 CEST 2009


At Mon, 27 Apr 2009 17:11:39 +0200,
I wrote:
> 
> At Mon, 27 Apr 2009 17:09:27 +0200 (CEST),
> Jaroslav Kysela wrote:
> > 
> > On Mon, 27 Apr 2009, Jon Smirl wrote:
> > 
> > > I have fixed all of the other bugs. If I take out the position
> > > estimation code it fails.
> > >
> > > Jaroslav hasn't commented on this yet....
> > 
> > Appearently, FIFO is too big. I'm working on some changes to take account 
> > fifo_size to the jiffies based check. Please, set fifo_size correctly in 
> > your driver. USB drivers with big "URB FIFOs" should be changed as well, 
> > too.
> 
> Ah good, that's what I was thinking to fix up later :)

After thinking twice, I found that we basically don't need much
jiffies testing for that kind of hardware because it can't report
bad values anyway.

A test patch is below.  It suppose that such hardware should have
SNDRV_PCM_INFO_BATCH in runtime->hw.info (although most drivers don't
set it yet).


Comments?

Takashi

---
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 63d088f..a2a792c 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -249,6 +249,12 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream)
 			new_hw_ptr = hw_base + pos;
 		}
 	}
+	/* Skip the jiffies check for hardwares with BATCH flag.
+	 * Such hardware usually just increases the position at each IRQ,
+	 * thus it can't give any strange position.
+	 */
+	if (runtime->hw.info & SNDRV_PCM_INFO_BATCH)
+		goto no_jiffies_check;
 	hdelta = new_hw_ptr - old_hw_ptr;
 	jdelta = jiffies - runtime->hw_ptr_jiffies;
 	if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) {
@@ -272,6 +278,7 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream)
 		hw_base -= hw_base % runtime->buffer_size;
 		delta = 0;
 	}
+ no_jiffies_check:
 	if (delta > runtime->period_size + runtime->period_size / 2) {
 		hw_ptr_error(substream,
 			     "Lost interrupts? "


More information about the Alsa-devel mailing list