Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* DMA feature question.
@ 2004-06-26 14:44 James Courtier-Dutton
  2004-06-28 15:57 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: James Courtier-Dutton @ 2004-06-26 14:44 UTC (permalink / raw)
  To: ALSA development

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: DMA feature question.
  2004-06-26 14:44 DMA feature question James Courtier-Dutton
@ 2004-06-28 15:57 ` Takashi Iwai
  2004-06-28 17:32   ` James Courtier-Dutton
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2004-06-28 15:57 UTC (permalink / raw)
  To: James Courtier-Dutton; +Cc: ALSA development

At Sat, 26 Jun 2004 15:44:32 +0100,
James Courtier-Dutton wrote:
> 
> 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".

No.  It's for the DMA buffer only.

> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: DMA feature question.
  2004-06-28 17:32   ` James Courtier-Dutton
@ 2004-06-28 16:48     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2004-06-28 16:48 UTC (permalink / raw)
  To: James Courtier-Dutton; +Cc: ALSA development

At Mon, 28 Jun 2004 18:32:58 +0100,
James Courtier-Dutton wrote:
> 
> Takashi Iwai wrote:
> >>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!
> 
> > 
> > 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?

4k on i386.

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

Yes, but 4k is minimal, so far.

>  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: DMA feature question.
  2004-06-28 15:57 ` Takashi Iwai
@ 2004-06-28 17:32   ` James Courtier-Dutton
  2004-06-28 16:48     ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: James Courtier-Dutton @ 2004-06-28 17:32 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: ALSA development

Takashi Iwai wrote:
>>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!

> 
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-06-28 16:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-26 14:44 DMA feature question James Courtier-Dutton
2004-06-28 15:57 ` Takashi Iwai
2004-06-28 17:32   ` James Courtier-Dutton
2004-06-28 16:48     ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox