Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
memalloc.h File Reference

Go to the source code of this file.

Data Structures

struct  snd_dma_device
 
struct  snd_dma_buffer
 

Macros

#define snd_dma_pci_data(pci)   (&(pci)->dev)
 
#define snd_dma_isa_data()   NULL
 
#define snd_dma_continuous_data(x)   ((struct device *)(unsigned long)(x))
 
#define SNDRV_DMA_TYPE_UNKNOWN   0 /* not defined */
 
#define SNDRV_DMA_TYPE_CONTINUOUS   1 /* continuous no-DMA memory */
 
#define SNDRV_DMA_TYPE_DEV   2 /* generic device continuous */
 
#define SNDRV_DMA_TYPE_DEV_SG   SNDRV_DMA_TYPE_DEV /* no SG-buf support */
 
#define snd_sgbuf_get_chunk_size(dmab, ofs, size)   (size)
 
#define snd_dma_pci_buf_id(pci)   (((unsigned int)(pci)->vendor << 16) | (pci)->device)
 

Functions

int snd_dma_alloc_pages (int type, struct device *dev, size_t size, struct snd_dma_buffer *dmab)
 
int snd_dma_alloc_pages_fallback (int type, struct device *dev, size_t size, struct snd_dma_buffer *dmab)
 
void snd_dma_free_pages (struct snd_dma_buffer *dmab)
 
size_t snd_dma_get_reserved_buf (struct snd_dma_buffer *dmab, unsigned int id)
 
int snd_dma_reserve_buf (struct snd_dma_buffer *dmab, unsigned int id)
 
voidsnd_malloc_pages (size_t size, gfp_t gfp_flags)
 
void snd_free_pages (void *ptr, size_t size)
 

Macro Definition Documentation

#define snd_dma_continuous_data (   x)    ((struct device *)(unsigned long)(x))

Definition at line 40 of file memalloc.h.

#define snd_dma_isa_data ( )    NULL

Definition at line 39 of file memalloc.h.

#define snd_dma_pci_buf_id (   pci)    (((unsigned int)(pci)->vendor << 16) | (pci)->device)

Definition at line 149 of file memalloc.h.

#define snd_dma_pci_data (   pci)    (&(pci)->dev)

Definition at line 38 of file memalloc.h.

#define snd_sgbuf_get_chunk_size (   dmab,
  ofs,
  size 
)    (size)

Definition at line 136 of file memalloc.h.

#define SNDRV_DMA_TYPE_CONTINUOUS   1 /* continuous no-DMA memory */

Definition at line 48 of file memalloc.h.

#define SNDRV_DMA_TYPE_DEV   2 /* generic device continuous */

Definition at line 49 of file memalloc.h.

#define SNDRV_DMA_TYPE_DEV_SG   SNDRV_DMA_TYPE_DEV /* no SG-buf support */

Definition at line 53 of file memalloc.h.

#define SNDRV_DMA_TYPE_UNKNOWN   0 /* not defined */

Definition at line 47 of file memalloc.h.

Function Documentation

int snd_dma_alloc_pages ( int  type,
struct device device,
size_t  size,
struct snd_dma_buffer dmab 
)

snd_dma_alloc_pages - allocate the buffer area according to the given type : the DMA buffer type : the device pointer : the buffer size to allocate : buffer allocation record to store the allocated data

Calls the memory-allocator function for the corresponding buffer type.

Returns zero if the buffer with the given size is allocated successfully, other a negative value at error.

Definition at line 182 of file memalloc.c.

int snd_dma_alloc_pages_fallback ( int  type,
struct device device,
size_t  size,
struct snd_dma_buffer dmab 
)

snd_dma_alloc_pages_fallback - allocate the buffer area according to the given type with fallback : the DMA buffer type : the device pointer : the buffer size to allocate : buffer allocation record to store the allocated data

Calls the memory-allocator function for the corresponding buffer type. When no space is left, this function reduces the size and tries to allocate again. The size actually allocated is stored in res_size argument.

Returns zero if the buffer with the given size is allocated successfully, other a negative value at error.

Definition at line 236 of file memalloc.c.

void snd_dma_free_pages ( struct snd_dma_buffer dmab)

snd_dma_free_pages - release the allocated buffer : the buffer allocation record to release

Releases the allocated buffer via snd_dma_alloc_pages().

Definition at line 265 of file memalloc.c.

size_t snd_dma_get_reserved_buf ( struct snd_dma_buffer dmab,
unsigned int  id 
)

snd_dma_get_reserved - get the reserved buffer for the given device : the buffer allocation record to store : the buffer id

Looks for the reserved-buffer list and re-uses if the same buffer is found in the list. When the buffer is found, it's removed from the free list.

Returns the size of buffer if the buffer is found, or zero if not found.

Definition at line 297 of file memalloc.c.

int snd_dma_reserve_buf ( struct snd_dma_buffer dmab,
unsigned int  id 
)

snd_dma_reserve_buf - reserve the buffer : the buffer to reserve : the buffer id

Reserves the given buffer as a reserved buffer.

Returns zero if successful, or a negative code at error.

Definition at line 332 of file memalloc.c.

void snd_free_pages ( void ptr,
size_t  size 
)

snd_free_pages - release the pages : the buffer pointer to release : the allocated buffer size

Releases the buffer allocated via snd_malloc_pages().

Definition at line 109 of file memalloc.c.

void* snd_malloc_pages ( size_t  size,
gfp_t  gfp_flags 
)

snd_malloc_pages - allocate pages with the given size : the size to allocate in bytes : the allocation conditions, GFP_XXX

Allocates the physically contiguous pages with the given size.

Returns the pointer of the buffer, or NULL if no enoguh memory.

Definition at line 86 of file memalloc.c.