Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
memalloc.c File Reference
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/seq_file.h>
#include <asm/uaccess.h>
#include <linux/dma-mapping.h>
#include <linux/moduleparam.h>
#include <linux/mutex.h>
#include <sound/memalloc.h>

Go to the source code of this file.

Data Structures

struct  snd_mem_list
 

Macros

#define SNDRV_DMA_DEVICE_UNUSED   (unsigned int)-1
 

Functions

 MODULE_AUTHOR ("Takashi Iwai <[email protected]>, Jaroslav Kysela <[email protected]>")
 
 MODULE_DESCRIPTION ("Memory allocator for ALSA system.")
 
 MODULE_LICENSE ("GPL")
 
voidsnd_malloc_pages (size_t size, gfp_t gfp_flags)
 
void snd_free_pages (void *ptr, size_t size)
 
int snd_dma_alloc_pages (int type, struct device *device, size_t size, struct snd_dma_buffer *dmab)
 
int snd_dma_alloc_pages_fallback (int type, struct device *device, 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)
 

Macro Definition Documentation

#define SNDRV_DMA_DEVICE_UNUSED   (unsigned int)-1

Definition at line 57 of file memalloc.c.

Function Documentation

MODULE_AUTHOR ( "Takashi Iwai <[email protected] ,
Jaroslav Kysela< perex @perex.cz >"   
)
MODULE_DESCRIPTION ( "Memory allocator for ALSA system."  )
MODULE_LICENSE ( "GPL"  )
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.