* Dma query
@ 2004-02-25 10:25 Gupta, Kshitij
2004-02-25 10:34 ` Jaroslav Kysela
2004-02-25 10:52 ` Giuliano Pochini
0 siblings, 2 replies; 10+ messages in thread
From: Gupta, Kshitij @ 2004-02-25 10:25 UTC (permalink / raw)
To: alsa-devel
hi,
I have a very trivial question about the dma transfers with respect
to ALSA framework.
Let me first explain a scenario
We have a
Circularly linked Buffer pool
buf1 buf2 buf3 buf4 .... bufn
In very simple terms playing an audio stream is reading from these buffers
and continuously dma'ing it to the audio device (let's assume we have a read
and write register with the audio device). And in this circulary linked
audio buffer the user fills the data and the driver empties it to the
device.
Now I am not able to fit this scenario in the ALSA framework. I am
referrring to alsa-kernel/arm/sa11xx-uda1341.c file as a reference for my
driver. And here I don't understand where do we specify the the exact dma
parameters (like the start address of buffer and the destination address).
Can someone enlighten me on this or else suggest me some other reference
driver.
regards
-kshitij
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Dma query
2004-02-25 10:25 Gupta, Kshitij
@ 2004-02-25 10:34 ` Jaroslav Kysela
2004-02-25 10:52 ` Giuliano Pochini
1 sibling, 0 replies; 10+ messages in thread
From: Jaroslav Kysela @ 2004-02-25 10:34 UTC (permalink / raw)
To: Gupta, Kshitij; +Cc: alsa-devel
On Wed, 25 Feb 2004, Gupta, Kshitij wrote:
> hi,
> I have a very trivial question about the dma transfers with respect
> to ALSA framework.
>
> Let me first explain a scenario
> We have a
> Circularly linked Buffer pool
>
> buf1 buf2 buf3 buf4 .... bufn
>
> In very simple terms playing an audio stream is reading from these buffers
> and continuously dma'ing it to the audio device (let's assume we have a read
> and write register with the audio device). And in this circulary linked
> audio buffer the user fills the data and the driver empties it to the
> device.
>
> Now I am not able to fit this scenario in the ALSA framework. I am
> referrring to alsa-kernel/arm/sa11xx-uda1341.c file as a reference for my
> driver. And here I don't understand where do we specify the the exact dma
> parameters (like the start address of buffer and the destination address).
DMA buffer is allocated hw_params callback. It depends, how the DMA pages
have to be allocated. You didn't write any details. If pages can be in
the whole memory space (from the view of CPU and DMA controller), then we
have SNDRV_DMA_TYPE_CONTINUOUS for it (use
snd_pcm_lib_preallocate_pages_for_all at init and standard functions
like in other drivers in hw_params and hw_free callbacks).
Jaroslav
-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Dma query
2004-02-25 10:25 Gupta, Kshitij
2004-02-25 10:34 ` Jaroslav Kysela
@ 2004-02-25 10:52 ` Giuliano Pochini
1 sibling, 0 replies; 10+ messages in thread
From: Giuliano Pochini @ 2004-02-25 10:52 UTC (permalink / raw)
To: Gupta, Kshitij; +Cc: alsa-devel
On Wed, 25 Feb 2004, Gupta, Kshitij wrote:
> hi,
> I have a very trivial question about the dma transfers with respect
> to ALSA framework.
>
> Let me first explain a scenario
> We have a Circularly linked Buffer pool
>
> buf1 buf2 buf3 buf4 .... bufn
>
> In very simple terms playing an audio stream is reading from these buffers
> and continuously dma'ing it to the audio device (let's assume we have a read
> and write register with the audio device). And in this circulary linked
> audio buffer the user fills the data and the driver empties it to the
> device.
>
> Now I am not able to fit this scenario in the ALSA framework. I am
> referrring to alsa-kernel/arm/sa11xx-uda1341.c file as a reference for my
> driver. And here I don't understand where do we specify the the exact dma
> parameters (like the start address of buffer and the destination address).
You should do most of the hw setup in the .hw_params callback. You get
pointers to the substream and hw_params structures and you have to setup
the hw and the buffer as requested. These macros may be useful
params_period_bytes(), params_buffer_bytes(), snd_pcm_substream_sgbuf(),
snd_sgbuf_get_addr(). There are many others, look at the sources :)
--
Giuliano.
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Dma query
@ 2004-02-25 11:02 Gupta, Kshitij
0 siblings, 0 replies; 10+ messages in thread
From: Gupta, Kshitij @ 2004-02-25 11:02 UTC (permalink / raw)
To: 'Giuliano Pochini'; +Cc: alsa-devel
Thanx for the details....let me just figure out the full flow and then come
with some more queries ;)...
-----Original Message-----
From: Giuliano Pochini [mailto:pochini@denise.shiny.it]
Sent: Wednesday, February 25, 2004 4:23 PM
To: Gupta, Kshitij
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: [Alsa-devel] Dma query
On Wed, 25 Feb 2004, Gupta, Kshitij wrote:
> hi,
> I have a very trivial question about the dma transfers with respect
> to ALSA framework.
>
> Let me first explain a scenario
> We have a Circularly linked Buffer pool
>
> buf1 buf2 buf3 buf4 .... bufn
>
> In very simple terms playing an audio stream is reading from these buffers
> and continuously dma'ing it to the audio device (let's assume we have a
read
> and write register with the audio device). And in this circulary linked
> audio buffer the user fills the data and the driver empties it to the
> device.
>
> Now I am not able to fit this scenario in the ALSA framework. I am
> referrring to alsa-kernel/arm/sa11xx-uda1341.c file as a reference for my
> driver. And here I don't understand where do we specify the the exact dma
> parameters (like the start address of buffer and the destination address).
You should do most of the hw setup in the .hw_params callback. You get
pointers to the substream and hw_params structures and you have to setup
the hw and the buffer as requested. These macros may be useful
params_period_bytes(), params_buffer_bytes(), snd_pcm_substream_sgbuf(),
snd_sgbuf_get_addr(). There are many others, look at the sources :)
--
Giuliano.
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Dma query
@ 2004-02-25 11:29 Gupta, Kshitij
0 siblings, 0 replies; 10+ messages in thread
From: Gupta, Kshitij @ 2004-02-25 11:29 UTC (permalink / raw)
To: 'Jaroslav Kysela'; +Cc: alsa-devel
hi ,
That's correct the pages will be in whole meory space and I will be
using snd_pcm_lib_preallocate_pages_for_all api for allocating the space.
There are some DMA apis (for our dma framework) like
set_dma_transfer_params(srcaddr, destaddr, mode ...)
Now I need to call this API whenever the transmit for one of the buffers is
complete. Or is it like, these things should be done just once upfront.
But that means we need n channels if we want n buffers to be ring buffers.
regards
-kshitij
-----Original Message-----
From: Jaroslav Kysela [mailto:perex@suse.cz]
Sent: Wednesday, February 25, 2004 4:05 PM
To: Gupta, Kshitij
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: [Alsa-devel] Dma query
On Wed, 25 Feb 2004, Gupta, Kshitij wrote:
> hi,
> I have a very trivial question about the dma transfers with respect
> to ALSA framework.
>
> Let me first explain a scenario
> We have a
> Circularly linked Buffer pool
>
> buf1 buf2 buf3 buf4 .... bufn
>
> In very simple terms playing an audio stream is reading from these buffers
> and continuously dma'ing it to the audio device (let's assume we have a
read
> and write register with the audio device). And in this circulary linked
> audio buffer the user fills the data and the driver empties it to the
> device.
>
> Now I am not able to fit this scenario in the ALSA framework. I am
> referrring to alsa-kernel/arm/sa11xx-uda1341.c file as a reference for my
> driver. And here I don't understand where do we specify the the exact dma
> parameters (like the start address of buffer and the destination address).
DMA buffer is allocated hw_params callback. It depends, how the DMA pages
have to be allocated. You didn't write any details. If pages can be in
the whole memory space (from the view of CPU and DMA controller), then we
have SNDRV_DMA_TYPE_CONTINUOUS for it (use
snd_pcm_lib_preallocate_pages_for_all at init and standard functions
like in other drivers in hw_params and hw_free callbacks).
Jaroslav
-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Dma query
@ 2004-02-26 11:19 Gupta, Kshitij
2004-02-26 11:26 ` Jaroslav Kysela
0 siblings, 1 reply; 10+ messages in thread
From: Gupta, Kshitij @ 2004-02-26 11:19 UTC (permalink / raw)
To: alsa-devel
hi,
Any insights will be really helpful :) .
regards
-kshitij
-----Original Message-----
From: alsa-devel-admin@lists.sourceforge.net
[mailto:alsa-devel-admin@lists.sourceforge.net]On Behalf Of Gupta,
Kshitij
Sent: Wednesday, February 25, 2004 4:59 PM
To: 'Jaroslav Kysela'
Cc: alsa-devel@lists.sourceforge.net
Subject: RE: [Alsa-devel] Dma query
hi ,
That's correct the pages will be in whole meory space and I will be
using snd_pcm_lib_preallocate_pages_for_all api for allocating the space.
There are some DMA apis (for our dma framework) like
set_dma_transfer_params(srcaddr, destaddr, mode ...)
Now I need to call this API whenever the transmit for one of the buffers is
complete. Or is it like, these things should be done just once upfront.
But that means we need n channels if we want n buffers to be ring buffers.
regards
-kshitij
-----Original Message-----
From: Jaroslav Kysela [mailto:perex@suse.cz]
Sent: Wednesday, February 25, 2004 4:05 PM
To: Gupta, Kshitij
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: [Alsa-devel] Dma query
On Wed, 25 Feb 2004, Gupta, Kshitij wrote:
> hi,
> I have a very trivial question about the dma transfers with respect
> to ALSA framework.
>
> Let me first explain a scenario
> We have a
> Circularly linked Buffer pool
>
> buf1 buf2 buf3 buf4 .... bufn
>
> In very simple terms playing an audio stream is reading from these buffers
> and continuously dma'ing it to the audio device (let's assume we have a
read
> and write register with the audio device). And in this circulary linked
> audio buffer the user fills the data and the driver empties it to the
> device.
>
> Now I am not able to fit this scenario in the ALSA framework. I am
> referrring to alsa-kernel/arm/sa11xx-uda1341.c file as a reference for my
> driver. And here I don't understand where do we specify the the exact dma
> parameters (like the start address of buffer and the destination address).
DMA buffer is allocated hw_params callback. It depends, how the DMA pages
have to be allocated. You didn't write any details. If pages can be in
the whole memory space (from the view of CPU and DMA controller), then we
have SNDRV_DMA_TYPE_CONTINUOUS for it (use
snd_pcm_lib_preallocate_pages_for_all at init and standard functions
like in other drivers in hw_params and hw_free callbacks).
Jaroslav
-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Dma query
2004-02-26 11:19 Gupta, Kshitij
@ 2004-02-26 11:26 ` Jaroslav Kysela
0 siblings, 0 replies; 10+ messages in thread
From: Jaroslav Kysela @ 2004-02-26 11:26 UTC (permalink / raw)
To: Gupta, Kshitij; +Cc: alsa-devel
On Thu, 26 Feb 2004, Gupta, Kshitij wrote:
> hi ,
> That's correct the pages will be in whole meory space and I will be
> using snd_pcm_lib_preallocate_pages_for_all api for allocating the space.
> There are some DMA apis (for our dma framework) like
>
> set_dma_transfer_params(srcaddr, destaddr, mode ...)
>
> Now I need to call this API whenever the transmit for one of the buffers is
> complete. Or is it like, these things should be done just once upfront.
> But that means we need n channels if we want n buffers to be ring buffers.
The ALSA midlevel expects if trigger callback is called, then the data
starts the transfer from the allocated ring buffer (which is filled by the
ALSA midlevel code or application - mmap mode). It's not necessary that
ring buffer is continous from the physical memory perspective, but it must
be continuous from the user space perspective (using MMU and page
mapping).
Then after one period transfer is finished, you need to call
period_elapsed() callback from the interrupt to notify ALSA midlevel code
about this situation and continue with the DMA transfer (next period).
Note that the pointer callback must give the actual pointer in the ring
buffer at this point.
I hope this helps.
Jaroslav
-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Dma query
@ 2004-02-26 14:15 Gupta, Kshitij
2004-02-26 14:26 ` Jaroslav Kysela
0 siblings, 1 reply; 10+ messages in thread
From: Gupta, Kshitij @ 2004-02-26 14:15 UTC (permalink / raw)
To: 'Jaroslav Kysela'; +Cc: alsa-devel
Hi,
So does that mean that the __next period__ DMA transfer parameters
should be set in the interrupt routine(end of transfer of one period). But
to set the next DMA transfer params we must know the start address of the
buffer which the middle layer has filled (and if the middle layer has filled
up more than one buffers then this buffer should be at the head of the
list).
Also one more point is that the hardware provides us the mechanism of
linking the DMA channels ( linking means that once one dma channel finishes
the transfer other one starts automatically). So this feature provides us
the facility of queuing up the DMA transfers.
regards
-kshitij
ps: one more nasty question I wanted to ask on the list was about how much
time does it take to write a driver(from scratch) with such a complex
framework ;)...probably just sharing experiences....
regards
-kshitij
-----Original Message-----
From: Jaroslav Kysela [mailto:perex@suse.cz]
Sent: Thursday, February 26, 2004 4:57 PM
To: Gupta, Kshitij
Cc: alsa-devel@lists.sourceforge.net
Subject: RE: [Alsa-devel] Dma query
On Thu, 26 Feb 2004, Gupta, Kshitij wrote:
> hi ,
> That's correct the pages will be in whole meory space and I will be
> using snd_pcm_lib_preallocate_pages_for_all api for allocating the space.
> There are some DMA apis (for our dma framework) like
>
> set_dma_transfer_params(srcaddr, destaddr, mode ...)
>
> Now I need to call this API whenever the transmit for one of the buffers
is
> complete. Or is it like, these things should be done just once upfront.
> But that means we need n channels if we want n buffers to be ring buffers.
The ALSA midlevel expects if trigger callback is called, then the data
starts the transfer from the allocated ring buffer (which is filled by the
ALSA midlevel code or application - mmap mode). It's not necessary that
ring buffer is continous from the physical memory perspective, but it must
be continuous from the user space perspective (using MMU and page
mapping).
Then after one period transfer is finished, you need to call
period_elapsed() callback from the interrupt to notify ALSA midlevel code
about this situation and continue with the DMA transfer (next period).
Note that the pointer callback must give the actual pointer in the ring
buffer at this point.
I hope this helps.
Jaroslav
-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Dma query
2004-02-26 14:15 Dma query Gupta, Kshitij
@ 2004-02-26 14:26 ` Jaroslav Kysela
0 siblings, 0 replies; 10+ messages in thread
From: Jaroslav Kysela @ 2004-02-26 14:26 UTC (permalink / raw)
To: Gupta, Kshitij; +Cc: alsa-devel
On Thu, 26 Feb 2004, Gupta, Kshitij wrote:
> Hi,
> So does that mean that the __next period__ DMA transfer parameters
> should be set in the interrupt routine(end of transfer of one period). But
> to set the next DMA transfer params we must know the start address of the
> buffer which the middle layer has filled (and if the middle layer has filled
> up more than one buffers then this buffer should be at the head of the
> list).
> Also one more point is that the hardware provides us the mechanism of
> linking the DMA channels ( linking means that once one dma channel finishes
> the transfer other one starts automatically). So this feature provides us
> the facility of queuing up the DMA transfers.
> regards
> -kshitij
Basically, we only copy the soundcard hardware and old ISA DMA engine
which is same as for PCI hardware etc.
The buffer size is divided to subblocks (we call them periods). These
periods determine spaces between interrupts and it's not necessary that
buffer_size == period_size * N (where N is an integer). Some hardware
(like ISA DMA controllers) can do any period sizes.
So, simply program your DMA controller to runtime->dma_addr + offset
for actual period and next periods. If you allow to set any period size,
then you need also handle shifts (you can avoid this by settings
snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) ).
> ps: one more nasty question I wanted to ask on the list was about how much
> time does it take to write a driver(from scratch) with such a complex
> framework ;)...probably just sharing experiences....
One week with full debugging. And I don't think that coding drivers is
complex, but it's required to know what's going on in the midlevel code
and you need to know the Linux kernel side memory handling.
Jaroslav
-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: DMA Query
[not found] <CA+Td+pvxyC9GCTroD74uBaTsou5spzw-R642n2Unc1CAKy1ECA@mail.gmail.com>
@ 2023-02-22 15:03 ` Andy Shevchenko
0 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2023-02-22 15:03 UTC (permalink / raw)
To: ARM; +Cc: dmaengine
On Wed, Feb 22, 2023 at 02:50:14PM +0530, ARM wrote:
> Hello I am vijay,
> Iam using two separate axi dma channels connected to the 2 ddr's,so i want
> to start(trigger) the both dma channels at ta time in petalinux..
I believe in DMA engine mailing list (Cc'ed) you may ask for help.
You need to formulate your question better, though.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-02-22 15:04 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CA+Td+pvxyC9GCTroD74uBaTsou5spzw-R642n2Unc1CAKy1ECA@mail.gmail.com>
2023-02-22 15:03 ` DMA Query Andy Shevchenko
2004-02-26 14:15 Dma query Gupta, Kshitij
2004-02-26 14:26 ` Jaroslav Kysela
-- strict thread matches above, loose matches on Subject: below --
2004-02-26 11:19 Gupta, Kshitij
2004-02-26 11:26 ` Jaroslav Kysela
2004-02-25 11:29 Gupta, Kshitij
2004-02-25 11:02 Gupta, Kshitij
2004-02-25 10:25 Gupta, Kshitij
2004-02-25 10:34 ` Jaroslav Kysela
2004-02-25 10:52 ` Giuliano Pochini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.