From: Takashi Iwai Subject: Re: Driver code with mpc5200 pointer problem. Date: Tue, 28 Apr 2009 08:04:27 +0200 Message-ID: References: <9e4733910904260825o68d5b9dndbf92cdbc4a4e48e@mail.gmail.com> <20090427092514.GB1760@sirena.org.uk> <9e4733910904270650g204d2660y7e3b9ea03446a752@mail.gmail.com> <20090427135737.GA20591@sirena.org.uk> <9e4733910904270702w317c8c62vbee38230979ad121@mail.gmail.com> <20090427140554.GB20591@sirena.org.uk> <9e4733910904270716v289e6d5exaf6e17331786ea11@mail.gmail.com> <20090427142437.GF20591@sirena.org.uk> <9e4733910904270742l751e660bg66844b98fe261f23@mail.gmail.com> <9e4733910904270804k6ed079d4h16b433b6f8a06fc7@mail.gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 96FF72444A for ; Tue, 28 Apr 2009 08:04:27 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Jaroslav Kysela Cc: alsa-devel mailing list , Mark Brown List-Id: alsa-devel@alsa-project.org 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? "