Skip to contentSkip to conversation

SM501 driver development: problem with start of playback

DISCUSSION Takashi Iwai 1 participant 1 message Nov 28, 2006 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

At Mon, 27 Nov 2006 19:28:38 +0100,

Quoted 41 lines · Jonas Eymann
Quoted 41 lines

At Wed, 22 Nov 2006 10:44:55 +0100,

Quoted 13 lines · Jonas Eymann

Hi everyone,

I'm currently developing/ enhancing an ALSA driver for a Silicon Motion SM501 compagnion chip which contains also an 8051 µC acting as AC97 controller. It doesn't support DMA and so the copy of audio data is done in the driver. There is a small hardware buffer of 1920 bytes which is devided into two halves and used as ring buffer. When the hardware has finished playing one half, it sends an interrupt to the driver so it can fill this half with new audio data while the hardware plays from the other one and so on. In the driver, I use an intermediate buffer with vmalloc().

Quoted 9 lines

Actually, I have a working driver now, but one small problem remains and I'm absolutely running out of ideas how to fix it: when the playback starts, the hardware expects the buffer to be filled completely (both halves), but the copy routine which does this first filling (snd_sm501_pfill()) only gets one period, not the two which are needed to fill the buffer completely. The second half it just reads zeros. It seems that the intermediate buffer is not yet filled with more data. This results in a gap of one period at the beginning of the playback (it's the second period that doesn't get copied).

Hm, this kind of implementation gets more common nowadays for small devices, so we may need a better/simpler framework in furture.

Usually, the filler routine should fill the data as much as possible at the time it's called. The size of available data on the itermediate buffer can be calculated via PCM appl_ptr.

Possibly, helper functions defined in pcm-indirect.h could be used in your case. Check the alsa-devel list archive in the last months, threads "Driver design question". The discussions went on there regarding a driver implementation without DMA. (The pcm-indirect.h routines didn't work for his case well, unforutnately, though...)

Quoted 6 lines
Quoted 1 line

Takashi

Thanks for your answer, Takashi!

when I check the appl_ptr in the trigger callback, it gives me exactly one period of available data.

It means that you set the minimum periods to 1. When it's set to 2, the trigger will be called after two periods are filled (unless the app call snd_pcm_start() explicitly with underfilled stream).

(BTW, don't forget Cc to alsa-devel ML.)

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV