Skip to contentSkip to conversation

DMA feature question.

DISCUSSION James Courtier-Dutton 2 participants 4 messages Jun 26, 2004 – Jun 28, 2004

lore
Share & tools
lore
#0 lore raw

I have a sound card that requires access to 2 DMA areas per substream.
1) Is for the audio samples buffer. I can already do that with:

err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 32*1024, 32*1024);

2) Is for a table of periods..
This table will contain:-
{ u32 Pointer_into_samples_buffer,
u32 number_of_bytes }
So, each record in the table is 8 bytes long, and identify each period in the buffer.

So, the table will contain a list of the different periods.
So, if there are 8 periods, the table will have 8 entries, each 8 bytes long, so I will need a DMA map for 64 bytes.

Is there any way to use the snd_pcm_lib_preallocate_pages() for this "table or periods".

If not, I will just have to make (1) a bit bigger, and place the "table of periods" in there.

Cheers

James

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com

#1 lore raw

At Sat, 26 Jun 2004 15:44:32 +0100,

Quoted 15 lines · James Courtier-Dutton

I have a sound card that requires access to 2 DMA areas per substream.
1) Is for the audio samples buffer. I can already do that with:

err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 32*1024, 32*1024);

2) Is for a table of periods..
This table will contain:-
{ u32 Pointer_into_samples_buffer,
u32 number_of_bytes }
So, each record in the table is 8 bytes long, and identify each period in the buffer.

Quoted 6 lines

So, the table will contain a list of the different periods. So, if there are 8 periods, the table will have 8 entries, each 8 bytes long, so I will need a DMA map for 64 bytes.

Is there any way to use the snd_pcm_lib_preallocate_pages() for this "table or periods".

No. It's for the DMA buffer only.

Quoted 2 lines

If not, I will just have to make (1) a bit bigger, and place the "table of periods" in there.

I don't think it's a good idea.
The buffer will be mmapped to the user-space, and obviously you don't want to expose it.

I'd suggest to allocate a table (one page should be large enough) via snd_dma_alloc_pages() statically at the driver initialization, and sets the max. number of periods according to the page size.

Takashi

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com

#2 lore raw
Quoted 6 lines · Takashi Iwai
Quoted 1 line

If not, I will just have to make (1) a bit bigger, and place the "table of periods" in there.

I don't think it's a good idea.
The buffer will be mmapped to the user-space, and obviously you don't want to expose it.

The terms "Massive security hole!" comes to mind!

Quoted 9 lines

I'd suggest to allocate a table (one page should be large enough) via snd_dma_alloc_pages() statically at the driver initialization, and sets the max. number of periods according to the page size.

Takashi

Is a page 1024 bytes or 4096 bytes? Does it vary depending on which type of CPU is in use? Is there a sensible minimum size to set it.

I only need to allow for a max of 16 periods per buffer. (does anyone need >16 periods per buffer ? ) There are 4 channels, with 8 bytes per period, that gives 16*4*8 = 512 bytes.

Thanks, I will use snd_dma_alloc_pages().
For your info, this is for the AudigyLS driver.

Cheers
James

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com

#3 lore raw

At Mon, 28 Jun 2004 18:32:58 +0100,

Quoted 18 lines · James Courtier-Dutton
Quoted 7 lines · Takashi Iwai
Quoted 2 lines

If not, I will just have to make (1) a bit bigger, and place the "table of periods" in there.

I don't think it's a good idea.
The buffer will be mmapped to the user-space, and obviously you don't want to expose it.

The terms "Massive security hole!" comes to mind!

Quoted 6 lines

I'd suggest to allocate a table (one page should be large enough) via snd_dma_alloc_pages() statically at the driver initialization, and sets the max. number of periods according to the page size.

Quoted 5 lines
Quoted 3 lines

Takashi

Is a page 1024 bytes or 4096 bytes?

4k on i386.

Quoted 2 lines

Does it vary depending on which type
of CPU is in use?

Yes, but 4k is minimal, so far.

Quoted 6 lines

Is there a sensible minimum size to set it.

I only need to allow for a max of 16 periods per buffer. (does anyone need >16 periods per buffer ? )
There are 4 channels, with 8 bytes per period, that gives 16*4*8 = 512 bytes.

Then a single page should suffice.
(of course you can add a code to check the page size to be sure.)

Takashi

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com