Re: mapping externally allocated Scatter Gather DMA buffers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 11 Nov 2010, Manu Abraham wrote:

On Wed, Nov 10, 2010 at 11:35 PM, Jaroslav Kysela <perex@xxxxxxxx> wrote:
On Wed, 10 Nov 2010, Manu Abraham wrote:

On Wed, Nov 10, 2010 at 8:35 PM, Jaroslav Kysela <perex@xxxxxxxx> wrote:

On Wed, 10 Nov 2010, Manu Abraham wrote:

   Â/* enable stream */
   Â/* initializing 8 buffer with "pages" pages each .. */
   Âstream = saa7231_stream_init(saa7231, AUDIO_CAPTURE, ADAPTER_INT,
0, pages);
   Âif (!stream) {
       Âdprintk(SAA7231_ERROR, 1, "ERROR: Registering stream");
       Âreturn -ENOMEM;
   Â}
   Âaudio->stream = stream;
   Âbuffer = stream->dmabuf;
   Âsaa7231_add_irqevent(saa7231, 43, SAA7231_EDGE_RISING,
saa7231_audio_evhandler, "AS2D_AVIS");
   Âdprintk(SAA7231_DEBUG, 1, "Mapping %d buffers with %d pages
each",
XS2D_BUFFERS, pages);

Unfortunately, I don't understand the role of XS2D_BUFFERS. The ALSA
bufsize
is the whole DMA area (you should use params_buffer_bytes() to get this
value instead of calculating this using periods * period_size).

It means: Just allocate number of pages required for buffer_bytes. Don't
play with periods (except the interrupts).


There are 8 SG buffers for the hardware; the maximum size of each
buffer can be 512 pages,
the minimum can be a single page.

Could you describe more the whole DMA layout, including IRQ acks?

It seems to me:

SG PAGE 1 points to 1 - 512 data pages (4096 bytes long)
SG PAGE 2 .....
 Â....
SG PAGE 8 .....


I adapted the whole thing to make the buffersize divided amongst the
XS2D_BUFFERS (8):

Probably yes.

I hope the mapping of the buffers is okay ? It looks thus, now ..

From information you sent me about hw privately, I think that the period_bytes must be 4096 or multiple of this value with minumum count of periods 8 (or multiple of 8). Otherwise you get a non-continuous memory area (the hw uses only portion of system memory page, thus there'll be gaps). The problem is that we have MMAP_COMPLEX mode, but no application can handle (does not implement) this mmap mode and I'm not sure, if we can even describe the DMA buffer size layout for this case for your specific hw.

I would use:

        snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
				  4096);


	snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS,
				   8);

And define periods_min = 8 (max to multiple 8 - choose your max limit) and period_bytes_min to 4096 (max to multiple 4096 - choose your max limit).

Note that -EIO means that your driver does not called snd_pcm_period_elapsed() and/or the pointer callback returns wrong position to the audio ring buffer.

						Jaroslav

-----
Jaroslav Kysela <perex@xxxxxxxx>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux