[alsa-devel] Getting physical address of the DMA buffer
Hi
I have allocated the DMA buffer using snd_pcm_lib_malloc_pages() and it was preallocated as:
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data (GFP_KERNEL), 128 * 1024, 128 * 1024);
and then,
snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
None of these calls fail.
The physical address of the allocated buffer is shown as 0 in my case since according to 'Writing an ALSA driver' the physical address of the DMA buffer will not be accessble from the main CPU. Is that why the physical address is shown as 0?
Also, in my pointer function, I need the DMA buffers physical address to calculate the position in buffer etc. How can do that since runtime->dma_addr is 0 for me?
Apologies for longish mail but I have to paste the actual paragraphs here to clear my understanding in less number of emails by avoiding further emails.
In chapter 5, in DMA buffer information, it is said that,
1. The dma_area holds the buffer pointer (the logical address). You can call memcpy from/to this pointer. Meanwhile, dma_addr holds the physical address of the buffer. This field is specified only when the buffer is a linear buffer.
and in descrition of prepare callback it says,
2. The physical address of the allocated buffer is set to runtime->dma_area.
Statements 1 and 2 contradict each other or I am mis reading them?
How should I get the physical address in pointer callbacks? As runtime->dma_area or runtime->dma_addr which is 0?
-pharaoh.
Pharaoh . wrote:
I have allocated the DMA buffer using snd_pcm_lib_malloc_pages() and it was preallocated as:
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data (GFP_KERNEL),
SNDRV_DMA_TYPE_CONTINUOUS is for a buffer that cannot be accessed over DMA.
What kind of bus does your hardware use, and how would you allocate memory for it?
Regards, Clemens
On 6/27/07, Clemens Ladisch cladisch@fastmail.net wrote:
Pharaoh . wrote:
I have allocated the DMA buffer using snd_pcm_lib_malloc_pages() and it was preallocated as:
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data (GFP_KERNEL),
SNDRV_DMA_TYPE_CONTINUOUS is for a buffer that cannot be accessed over DMA.
What kind of bus does your hardware use, and how would you allocate memory for it?
Regards, Clemens
Continuous buffers unrelated to the bus type can be allocated using SNDRV_DMA_TYPE_CONTINUOUS right? I am referring a standard driver from omap source tree, and the buffer allocation functions I have copied from there and they should be same for the range of OMAPs since the dma handling is same for them.
SNDRV_DMA_TYPE_CONTINUOUS is for a buffer that cannot be accessed over DMA.
Thats why I get runtime->dma_addr as 0.
Pharaoh . wrote:
On 6/27/07, Clemens Ladisch cladisch@fastmail.net wrote:
SNDRV_DMA_TYPE_CONTINUOUS is for a buffer that cannot be accessed over DMA.
What kind of bus does your hardware use, and how would you allocate memory for it?
Continuous buffers unrelated to the bus type can be allocated using SNDRV_DMA_TYPE_CONTINUOUS right? I am referring a standard driver from omap source tree, and the buffer allocation functions I have copied from there and they should be same for the range of OMAPs since the dma handling is same for them.
I don't know anything about OMAP.
If the processor doesn't use a MMU, then the memory addresses as seen by the CPU are the same as those used by a device using DMA. In that case, you could use SNDRV_DMA_TYPE_CONTINUOUS and the correct address would be available as runtime->dma_area.
HTH Clemens
Okay got it now. The omap I am using has a ARM926 which has a MMU. So I shouldn't be using SNDRV_DMA_TYPE_CONTINUOUS. I will try to allocate using other methods.
On 6/27/07, Clemens Ladisch cladisch@fastmail.net wrote:
Pharaoh . wrote:
On 6/27/07, Clemens Ladisch cladisch@fastmail.net wrote:
SNDRV_DMA_TYPE_CONTINUOUS is for a buffer that cannot be accessed over DMA.
What kind of bus does your hardware use, and how would you allocate memory for it?
Continuous buffers unrelated to the bus type can be allocated using SNDRV_DMA_TYPE_CONTINUOUS right? I am referring a standard driver from omap source tree, and the buffer allocation functions I have copied from there and they should be same for the range of OMAPs since the dma handling is same for them.
I don't know anything about OMAP.
If the processor doesn't use a MMU, then the memory addresses as seen by the CPU are the same as those used by a device using DMA. In that case, you could use SNDRV_DMA_TYPE_CONTINUOUS and the correct address would be available as runtime->dma_area.
HTH Clemens
participants (2)
-
Clemens Ladisch
-
Pharaoh .