Hello,
I have configured dma with alsa and alsa works well with arecord and aplay.
But I'm not sure about the DMA: Does alsa always use dma, or does it depends on how we use the alsa libraries APIs ?
Thanks,
Ran
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi Pavel,
It seems according to code that DMA is always used whenever there is data transfer (without care for the specific alsa function for the data transfer).
davinci_pcm.c:
davinci_pcm_open() -> davinci_pcm_dma_request(substream) -> link = prtd->asp_channel = edma_alloc_channel(params->channel)
I also see that without configuring dma correct in kernel then davinci_pcm_open will return error.
Best Regards,
Ran
Hi Pavel,
I am mainly interetsed in working with dma in ping-pong mode.
I see in davinci_pcm.c a comment "not used with ping/pong" :
/*
* Not used with ping/pong
*/
static void davinci_pcm_enqueue_dma(struct snd_pcm_substream *substream)
{
.....
period_size = snd_pcm_lib_period_bytes(substream);
dma_offset = prtd->period * period_size;
dma_pos = runtime->dma_addr + dma_offset;
....
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
src = dma_pos;
dst = prtd->params->dma_addr;
src_bidx = data_type;
dst_bidx = 0;
src_cidx = data_type * fifo_level;
dst_cidx = 0;
} else {
....
acnt = prtd->params->acnt;
edma_set_src(link, src, INCR, W8BIT);
edma_set_dest(link, dst, INCR, W8BIT);
}
But this comment is not well understood becuase you can see that dma with offset/length according to alsa period parameter.
So what is the meaning of the comment "not used with ping/pong" ?
Regards,
Ran
Ran,
Ran Shalit said:It seems according to code that DMA is always used whenever there is data transfer (without care for the specific alsa function for the data transfer).
davinci_pcm.c:
davinci_pcm_open() -> davinci_pcm_dma_request(substream) -> link = prtd->asp_channel = edma_alloc_channel(params->channel)
Which ALSA API function invokes davinci_pcm_open() ?
BR
Pavel
Ran Shalit said:But Isn't using period with dma_pos inside dma buffer is already a ping-pong method (which is already embedded in davinci code) ?
I don't think so.
Ping-pong buffering is a simple technique that allows the CPU activity to be distanced from the EDMA activity. This means that there are multiple (usually two) sets of data buffers for all incoming and outgoing data streams. While the EDMA transfers the data into and out of the ping buffers, the CPU manipulates the data in the pong buffers. When both CPU and EDMA activity completes, they switch. The EDMA then writes over the old input data and transfers the new output data.
To change the continuous operation example, such that a ping-pong buffering scheme is used, the EDMA channels need only a moderate change. Instead of one parameter set, there are two; one for transferring data to/from the ping buffers and one for transferring data to/from the pong buffers. As soon as one transfer completes, the channel loads the PaRAM set for the other and the data transfers continue.
davinci_pcm_enqueue_dma() use only asp_link[0]. While for ping-pong, asp_link[0] and asp_link[1] should be used, see:
ping_pong_dma_setup()
request_ping_pong()
BR
Pavel