From: Takashi Iwai Subject: Re: How to deal with cards with a large on-board buffer? Date: Wed, 03 May 2006 14:26:34 +0200 Message-ID: References: <20060502234125.GC4109@home> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <20060502234125.GC4109@home> Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Nicolas Boullis Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Wed, 3 May 2006 01:41:25 +0200, Nicolas Boullis wrote: > > Hi, > > I'm trying to write an ALSA interface for the audio part of MPEG2 > decoder boards Sigma Designs Hollywod+ and Creative Labs DXR3, both > based on Sigma Designs EM8300 chip. > > To make it short, the trouble is that, to get correct working, it seems > to require that the audio buffer be kept at some minimal fill level. Is > there a way I can enforce this? It's no way because the data is fed from the application. If less than watermark (usually equivalent with period size) is available, it's simply an underrun. > Browsing at the code, I found out the fifo_size element of the > snd_pcm_hardware_t type, that is not documented in Takashi Iwai's > excellent "Writing an ALSA Driver" guide. Is it something that might be > used to enforce this? (I tried, of course, but my test was > unsuccessful...) No, it's an obsoleted field and actually not used in the driver. > I also discovered the SNDRV_PCM_INFO_DOUBLE, SNDRV_PCM_INFO_BATCH > and SNDRV_PCM_INFO_BLOCK_TRANSFER that are give little information, and > that sound to me like things that might be useful. Any explanation about > those? INFO_DOUBLE is just a hint to user-space and not used in the driver. INFO_BATCH and INFO_BLOCK_TRANSFER are evaluated only in the OSS emulation code. OSS DSP_CAP_REALTIME bit is reset when either of them is set. But no influence on the behavior of ALSA native apps. > Now, just in case someone has a better idea how to make things work, > here is a more comprehensive explanation about how those cards work, *as > far as I could understand* (since I got absolutely no explanation from > the manufacturer): > - there is a rather large on-chip buffer (0x3c00 bytes), that we can > neither write to or read directly > - we can read pointers to the current read and write positions in > this buffer > - this buffer is fed by chip-initiated DMA transfers from the main > memory > - the buffers for DMA transfers are declared in a FIFO; they mustn't > be too large (8kB is ok; 16kB is not since it's larger that the > on-chip buffer) > - if the on-chip buffer is "too empty" (don't know exactly when the > chip decides it is too empty) and no buffer is available for > DMA transfer, it "sends" some junk to the internal buffer > - interruptions are not raised when buffers are DMA-transfered, but > at fixed 20.2ms interval (stable experimental value) > - it might be required that DMA buffers are aligned on 4kB boundaried > (or page boundaries) > > Any idea how to correctly deal with such a beast? I tried a few ones, > but none was really successful... Are you using a system timer or any dedicated irq source? The first thing to do is to find out the bottleneck. You have two transfers running asynchronously: on the hardware buffer and between memory <-> h/w buffer. I guess the former is running continuously, but how the latter transfer is implemented? Anyway, the source code would reveal problems better. Takashi ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642