Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Functions | Variables
pcm_lib.c File Reference
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/math64.h>
#include <linux/export.h>
#include <sound/core.h>
#include <sound/control.h>
#include <sound/tlv.h>
#include <sound/info.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/timer.h>

Go to the source code of this file.

Macros

#define XRUN_DEBUG_BASIC   (1<<0)
 
#define XRUN_DEBUG_STACK   (1<<1) /* dump also stack */
 
#define XRUN_DEBUG_JIFFIESCHECK   (1<<2) /* do jiffies check */
 
#define XRUN_DEBUG_PERIODUPDATE   (1<<3) /* full period update info */
 
#define XRUN_DEBUG_HWPTRUPDATE   (1<<4) /* full hwptr update info */
 
#define XRUN_DEBUG_LOG   (1<<5) /* show last 10 positions on err */
 
#define XRUN_DEBUG_LOGONCE   (1<<6) /* do above only once */
 
#define xrun_debug(substream, mask)   0
 
#define dump_stack_on_xrun(substream)
 
#define hw_ptr_error(substream, fmt, args...)   do { } while (0)
 
#define xrun_log(substream, pos, in_interrupt)   do { } while (0)
 
#define xrun_log_show(substream)   do { } while (0)
 

Typedefs

typedef int(* transfer_f )(struct snd_pcm_substream *substream, unsigned int hwoff, unsigned long data, unsigned int off, snd_pcm_uframes_t size)
 

Functions

void snd_pcm_playback_silence (struct snd_pcm_substream *substream, snd_pcm_uframes_t new_hw_ptr)
 
int snd_pcm_update_state (struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime)
 
int snd_pcm_update_hw_ptr (struct snd_pcm_substream *substream)
 
void snd_pcm_set_ops (struct snd_pcm *pcm, int direction, struct snd_pcm_ops *ops)
 
 EXPORT_SYMBOL (snd_pcm_set_ops)
 
void snd_pcm_set_sync (struct snd_pcm_substream *substream)
 
 EXPORT_SYMBOL (snd_pcm_set_sync)
 
int snd_interval_refine (struct snd_interval *i, const struct snd_interval *v)
 
 EXPORT_SYMBOL (snd_interval_refine)
 
void snd_interval_mul (const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c)
 
void snd_interval_div (const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c)
 
void snd_interval_muldivk (const struct snd_interval *a, const struct snd_interval *b, unsigned int k, struct snd_interval *c)
 
void snd_interval_mulkdiv (const struct snd_interval *a, unsigned int k, const struct snd_interval *b, struct snd_interval *c)
 
int snd_interval_ratnum (struct snd_interval *i, unsigned int rats_count, struct snd_ratnum *rats, unsigned int *nump, unsigned int *denp)
 
 EXPORT_SYMBOL (snd_interval_ratnum)
 
int snd_interval_list (struct snd_interval *i, unsigned int count, const unsigned int *list, unsigned int mask)
 
 EXPORT_SYMBOL (snd_interval_list)
 
int snd_pcm_hw_rule_add (struct snd_pcm_runtime *runtime, unsigned int cond, int var, snd_pcm_hw_rule_func_t func, void *private, int dep,...)
 
 EXPORT_SYMBOL (snd_pcm_hw_rule_add)
 
int snd_pcm_hw_constraint_mask (struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, u_int32_t mask)
 
int snd_pcm_hw_constraint_mask64 (struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, u_int64_t mask)
 
int snd_pcm_hw_constraint_integer (struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var)
 
 EXPORT_SYMBOL (snd_pcm_hw_constraint_integer)
 
int snd_pcm_hw_constraint_minmax (struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, unsigned int min, unsigned int max)
 
 EXPORT_SYMBOL (snd_pcm_hw_constraint_minmax)
 
int snd_pcm_hw_constraint_list (struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, const struct snd_pcm_hw_constraint_list *l)
 
 EXPORT_SYMBOL (snd_pcm_hw_constraint_list)
 
int snd_pcm_hw_constraint_ratnums (struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, struct snd_pcm_hw_constraint_ratnums *r)
 
 EXPORT_SYMBOL (snd_pcm_hw_constraint_ratnums)
 
int snd_pcm_hw_constraint_ratdens (struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, struct snd_pcm_hw_constraint_ratdens *r)
 
 EXPORT_SYMBOL (snd_pcm_hw_constraint_ratdens)
 
int snd_pcm_hw_constraint_msbits (struct snd_pcm_runtime *runtime, unsigned int cond, unsigned int width, unsigned int msbits)
 
 EXPORT_SYMBOL (snd_pcm_hw_constraint_msbits)
 
int snd_pcm_hw_constraint_step (struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, unsigned long step)
 
 EXPORT_SYMBOL (snd_pcm_hw_constraint_step)
 
int snd_pcm_hw_constraint_pow2 (struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var)
 
 EXPORT_SYMBOL (snd_pcm_hw_constraint_pow2)
 
int snd_pcm_hw_rule_noresample (struct snd_pcm_runtime *runtime, unsigned int base_rate)
 
 EXPORT_SYMBOL (snd_pcm_hw_rule_noresample)
 
void _snd_pcm_hw_params_any (struct snd_pcm_hw_params *params)
 
 EXPORT_SYMBOL (_snd_pcm_hw_params_any)
 
int snd_pcm_hw_param_value (const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir)
 
 EXPORT_SYMBOL (snd_pcm_hw_param_value)
 
void _snd_pcm_hw_param_setempty (struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var)
 
 EXPORT_SYMBOL (_snd_pcm_hw_param_setempty)
 
int snd_pcm_hw_param_first (struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir)
 
 EXPORT_SYMBOL (snd_pcm_hw_param_first)
 
int snd_pcm_hw_param_last (struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir)
 
 EXPORT_SYMBOL (snd_pcm_hw_param_last)
 
int snd_pcm_hw_params_choose (struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params)
 
int snd_pcm_lib_ioctl (struct snd_pcm_substream *substream, unsigned int cmd, void *arg)
 
 EXPORT_SYMBOL (snd_pcm_lib_ioctl)
 
void snd_pcm_period_elapsed (struct snd_pcm_substream *substream)
 
 EXPORT_SYMBOL (snd_pcm_period_elapsed)
 
snd_pcm_sframes_t snd_pcm_lib_write (struct snd_pcm_substream *substream, const void __user *buf, snd_pcm_uframes_t size)
 
 EXPORT_SYMBOL (snd_pcm_lib_write)
 
snd_pcm_sframes_t snd_pcm_lib_writev (struct snd_pcm_substream *substream, void __user **bufs, snd_pcm_uframes_t frames)
 
 EXPORT_SYMBOL (snd_pcm_lib_writev)
 
snd_pcm_sframes_t snd_pcm_lib_read (struct snd_pcm_substream *substream, void __user *buf, snd_pcm_uframes_t size)
 
 EXPORT_SYMBOL (snd_pcm_lib_read)
 
snd_pcm_sframes_t snd_pcm_lib_readv (struct snd_pcm_substream *substream, void __user **bufs, snd_pcm_uframes_t frames)
 
 EXPORT_SYMBOL (snd_pcm_lib_readv)
 
 EXPORT_SYMBOL_GPL (snd_pcm_std_chmaps)
 
 EXPORT_SYMBOL_GPL (snd_pcm_alt_chmaps)
 
int snd_pcm_add_chmap_ctls (struct snd_pcm *pcm, int stream, const struct snd_pcm_chmap_elem *chmap, int max_channels, unsigned long private_value, struct snd_pcm_chmap **info_ret)
 
 EXPORT_SYMBOL_GPL (snd_pcm_add_chmap_ctls)
 

Variables

struct snd_pcm_chmap_elem snd_pcm_std_chmaps []
 
struct snd_pcm_chmap_elem snd_pcm_alt_chmaps []
 

Macro Definition Documentation

#define dump_stack_on_xrun (   substream)
Value:
do { \
if (xrun_debug(substream, XRUN_DEBUG_STACK)) \
dump_stack(); \
} while (0)

Definition at line 162 of file pcm_lib.c.

#define hw_ptr_error (   substream,
  fmt,
  args... 
)    do { } while (0)

Definition at line 273 of file pcm_lib.c.

#define xrun_debug (   substream,
  mask 
)    0

Definition at line 159 of file pcm_lib.c.

#define XRUN_DEBUG_BASIC   (1<<0)

Definition at line 146 of file pcm_lib.c.

#define XRUN_DEBUG_HWPTRUPDATE   (1<<4) /* full hwptr update info */

Definition at line 150 of file pcm_lib.c.

#define XRUN_DEBUG_JIFFIESCHECK   (1<<2) /* do jiffies check */

Definition at line 148 of file pcm_lib.c.

#define XRUN_DEBUG_LOG   (1<<5) /* show last 10 positions on err */

Definition at line 151 of file pcm_lib.c.

#define XRUN_DEBUG_LOGONCE   (1<<6) /* do above only once */

Definition at line 152 of file pcm_lib.c.

#define XRUN_DEBUG_PERIODUPDATE   (1<<3) /* full period update info */

Definition at line 149 of file pcm_lib.c.

#define XRUN_DEBUG_STACK   (1<<1) /* dump also stack */

Definition at line 147 of file pcm_lib.c.

#define xrun_log (   substream,
  pos,
  in_interrupt 
)    do { } while (0)

Definition at line 274 of file pcm_lib.c.

#define xrun_log_show (   substream)    do { } while (0)

Definition at line 275 of file pcm_lib.c.

Typedef Documentation

typedef int(* transfer_f)(struct snd_pcm_substream *substream, unsigned int hwoff, unsigned long data, unsigned int off, snd_pcm_uframes_t size)

Definition at line 1898 of file pcm_lib.c.

Function Documentation

void _snd_pcm_hw_param_setempty ( struct snd_pcm_hw_params params,
snd_pcm_hw_param_t  var 
)

Definition at line 1508 of file pcm_lib.c.

void _snd_pcm_hw_params_any ( struct snd_pcm_hw_params params)

Definition at line 1462 of file pcm_lib.c.

EXPORT_SYMBOL ( snd_pcm_set_ops  )
EXPORT_SYMBOL ( snd_pcm_set_sync  )
EXPORT_SYMBOL ( snd_interval_refine  )
EXPORT_SYMBOL ( snd_interval_ratnum  )
EXPORT_SYMBOL ( snd_interval_list  )
EXPORT_SYMBOL ( snd_pcm_hw_rule_add  )
EXPORT_SYMBOL ( snd_pcm_hw_constraint_integer  )
EXPORT_SYMBOL ( snd_pcm_hw_constraint_minmax  )
EXPORT_SYMBOL ( snd_pcm_hw_constraint_list  )
EXPORT_SYMBOL ( snd_pcm_hw_constraint_ratnums  )
EXPORT_SYMBOL ( snd_pcm_hw_constraint_ratdens  )
EXPORT_SYMBOL ( snd_pcm_hw_constraint_msbits  )
EXPORT_SYMBOL ( snd_pcm_hw_constraint_step  )
EXPORT_SYMBOL ( snd_pcm_hw_constraint_pow2  )
EXPORT_SYMBOL ( snd_pcm_hw_rule_noresample  )
EXPORT_SYMBOL ( _snd_pcm_hw_params_any  )
EXPORT_SYMBOL ( snd_pcm_hw_param_value  )
EXPORT_SYMBOL ( _snd_pcm_hw_param_setempty  )
EXPORT_SYMBOL ( snd_pcm_hw_param_first  )
EXPORT_SYMBOL ( snd_pcm_hw_param_last  )
EXPORT_SYMBOL ( snd_pcm_lib_ioctl  )
EXPORT_SYMBOL ( snd_pcm_period_elapsed  )
EXPORT_SYMBOL ( snd_pcm_lib_write  )
EXPORT_SYMBOL ( snd_pcm_lib_writev  )
EXPORT_SYMBOL ( snd_pcm_lib_read  )
EXPORT_SYMBOL ( snd_pcm_lib_readv  )
EXPORT_SYMBOL_GPL ( snd_pcm_std_chmaps  )
EXPORT_SYMBOL_GPL ( snd_pcm_alt_chmaps  )
EXPORT_SYMBOL_GPL ( snd_pcm_add_chmap_ctls  )
void snd_interval_div ( const struct snd_interval a,
const struct snd_interval b,
struct snd_interval c 
)

snd_interval_div - refine the interval value with division : dividend : divisor : quotient

c = a / b

Returns non-zero if the value is changed, zero if not changed.

Definition at line 725 of file pcm_lib.c.

int snd_interval_list ( struct snd_interval i,
unsigned int  count,
const unsigned int list,
unsigned int  mask 
)

snd_interval_list - refine the interval value from the list : the interval value to refine : the number of elements in the list : the value list : the bit-mask to evaluate

Refines the interval value from the list. When mask is non-zero, only the elements corresponding to bit 1 are evaluated.

Returns non-zero if the value is changed, zero if not changed.

Definition at line 1046 of file pcm_lib.c.

void snd_interval_mul ( const struct snd_interval a,
const struct snd_interval b,
struct snd_interval c 
)

Definition at line 701 of file pcm_lib.c.

void snd_interval_muldivk ( const struct snd_interval a,
const struct snd_interval b,
unsigned int  k,
struct snd_interval c 
)

snd_interval_muldivk - refine the interval value : dividend 1 : dividend 2 : divisor (as integer) : result

c = a * b / k

Returns non-zero if the value is changed, zero if not changed.

Definition at line 760 of file pcm_lib.c.

void snd_interval_mulkdiv ( const struct snd_interval a,
unsigned int  k,
const struct snd_interval b,
struct snd_interval c 
)

snd_interval_mulkdiv - refine the interval value : dividend 1 : dividend 2 (as integer) : divisor : result

c = a * k / b

Returns non-zero if the value is changed, zero if not changed.

Definition at line 791 of file pcm_lib.c.

int snd_interval_ratnum ( struct snd_interval i,
unsigned int  rats_count,
struct snd_ratnum rats,
unsigned int nump,
unsigned int denp 
)

snd_interval_ratnum - refine the interval value : interval to refine : number of ratnum_t : ratnum_t array : pointer to store the resultant numerator : pointer to store the resultant denominator

Returns non-zero if the value is changed, zero if not changed.

Definition at line 829 of file pcm_lib.c.

int snd_interval_refine ( struct snd_interval i,
const struct snd_interval v 
)

snd_interval_refine - refine the interval value of configurator : the interval value to refine : the interval value to refer to

Refines the interval value with the reference value. The interval is changed to the range satisfying both intervals. The interval status (min, max, integer, etc.) are evaluated.

Returns non-zero if the value is changed, zero if not changed.

Definition at line 630 of file pcm_lib.c.

int snd_pcm_add_chmap_ctls ( struct snd_pcm pcm,
int  stream,
const struct snd_pcm_chmap_elem chmap,
int  max_channels,
unsigned long  private_value,
struct snd_pcm_chmap **  info_ret 
)

snd_pcm_add_chmap_ctls - create channel-mapping control elements : the assigned PCM instance : stream direction : channel map elements (for query) : the max number of channels for the stream : the value passed to each kcontrol's private_value field : store struct snd_pcm_chmap instance if non-NULL

Create channel-mapping control elements assigned to the given PCM stream(s). Returns zero if succeed, or a negative error value.

Definition at line 2472 of file pcm_lib.c.

int snd_pcm_hw_constraint_integer ( struct snd_pcm_runtime runtime,
snd_pcm_hw_param_t  var 
)

Definition at line 1203 of file pcm_lib.c.

Definition at line 1251 of file pcm_lib.c.

int snd_pcm_hw_constraint_mask ( struct snd_pcm_runtime runtime,
snd_pcm_hw_param_t  var,
u_int32_t  mask 
)

Definition at line 1163 of file pcm_lib.c.

int snd_pcm_hw_constraint_mask64 ( struct snd_pcm_runtime runtime,
snd_pcm_hw_param_t  var,
u_int64_t  mask 
)

Definition at line 1183 of file pcm_lib.c.

int snd_pcm_hw_constraint_minmax ( struct snd_pcm_runtime runtime,
snd_pcm_hw_param_t  var,
unsigned int  min,
unsigned int  max 
)

Definition at line 1220 of file pcm_lib.c.

int snd_pcm_hw_constraint_msbits ( struct snd_pcm_runtime runtime,
unsigned int  cond,
unsigned int  width,
unsigned int  msbits 
)

snd_pcm_hw_constraint_msbits - add a hw constraint msbits rule : PCM runtime instance : condition bits : sample bits width : msbits width

Definition at line 1349 of file pcm_lib.c.

int snd_pcm_hw_constraint_pow2 ( struct snd_pcm_runtime runtime,
unsigned int  cond,
snd_pcm_hw_param_t  var 
)

Definition at line 1407 of file pcm_lib.c.

Definition at line 1318 of file pcm_lib.c.

Definition at line 1285 of file pcm_lib.c.

int snd_pcm_hw_constraint_step ( struct snd_pcm_runtime runtime,
unsigned int  cond,
snd_pcm_hw_param_t  var,
unsigned long  step 
)

Definition at line 1377 of file pcm_lib.c.

int snd_pcm_hw_param_first ( struct snd_pcm_substream pcm,
struct snd_pcm_hw_params params,
snd_pcm_hw_param_t  var,
int dir 
)

Definition at line 1555 of file pcm_lib.c.

int snd_pcm_hw_param_last ( struct snd_pcm_substream pcm,
struct snd_pcm_hw_params params,
snd_pcm_hw_param_t  var,
int dir 
)

Definition at line 1601 of file pcm_lib.c.

int snd_pcm_hw_param_value ( const struct snd_pcm_hw_params params,
snd_pcm_hw_param_t  var,
int dir 
)

Definition at line 1484 of file pcm_lib.c.

int snd_pcm_hw_params_choose ( struct snd_pcm_substream pcm,
struct snd_pcm_hw_params params 
)

snd_pcm_hw_param_choose - choose a configuration defined by : PCM instance : the hw_params instance

Choose one configuration from configuration space defined by . The configuration chosen is that obtained fixing in this order: first access, first format, first subformat, min channels, min rate, min period time, max buffer size, min tick time

Definition at line 1628 of file pcm_lib.c.

int snd_pcm_hw_rule_add ( struct snd_pcm_runtime runtime,
unsigned int  cond,
int  var,
snd_pcm_hw_rule_func_t  func,
void private,
int  dep,
  ... 
)

Definition at line 1106 of file pcm_lib.c.

int snd_pcm_hw_rule_noresample ( struct snd_pcm_runtime runtime,
unsigned int  base_rate 
)

snd_pcm_hw_rule_noresample - add a rule to allow disabling hw resampling : PCM runtime instance : the rate at which the hardware does not resample

Definition at line 1433 of file pcm_lib.c.

int snd_pcm_lib_ioctl ( struct snd_pcm_substream substream,
unsigned int  cmd,
void arg 
)

snd_pcm_lib_ioctl - a generic PCM ioctl callback : the pcm substream instance : ioctl command

  • : ioctl argument

Processes the generic ioctl commands for PCM. Can be passed as the ioctl callback for PCM ops.

Returns zero if successful, or a negative error code on failure.

Definition at line 1733 of file pcm_lib.c.

snd_pcm_sframes_t snd_pcm_lib_read ( struct snd_pcm_substream substream,
void __user buf,
snd_pcm_uframes_t  size 
)

Definition at line 2230 of file pcm_lib.c.

snd_pcm_sframes_t snd_pcm_lib_readv ( struct snd_pcm_substream substream,
void __user **  bufs,
snd_pcm_uframes_t  frames 
)

Definition at line 2284 of file pcm_lib.c.

snd_pcm_sframes_t snd_pcm_lib_write ( struct snd_pcm_substream substream,
const void __user buf,
snd_pcm_uframes_t  size 
)

Definition at line 2018 of file pcm_lib.c.

snd_pcm_sframes_t snd_pcm_lib_writev ( struct snd_pcm_substream substream,
void __user **  bufs,
snd_pcm_uframes_t  frames 
)

Definition at line 2079 of file pcm_lib.c.

void snd_pcm_period_elapsed ( struct snd_pcm_substream substream)

snd_pcm_period_elapsed - update the pcm status for the next period : the pcm substream instance

This function is called from the interrupt handler when the PCM has processed the period size. It will update the current pointer, wake up sleepers, etc.

Even if more than one periods have elapsed since the last call, you have to call this only once.

Definition at line 1762 of file pcm_lib.c.

void snd_pcm_playback_silence ( struct snd_pcm_substream substream,
snd_pcm_uframes_t  new_hw_ptr 
)

Definition at line 44 of file pcm_lib.c.

void snd_pcm_set_ops ( struct snd_pcm pcm,
int  direction,
struct snd_pcm_ops ops 
)

snd_pcm_set_ops - set the PCM operators : the pcm instance : stream direction, SNDRV_PCM_STREAM_XXX : the operator table

Sets the given PCM operators to the pcm instance.

Definition at line 530 of file pcm_lib.c.

void snd_pcm_set_sync ( struct snd_pcm_substream substream)

snd_pcm_sync - set the PCM sync id : the pcm substream

Sets the PCM sync identifier for the card.

Definition at line 547 of file pcm_lib.c.

int snd_pcm_update_hw_ptr ( struct snd_pcm_substream substream)

Definition at line 517 of file pcm_lib.c.

int snd_pcm_update_state ( struct snd_pcm_substream substream,
struct snd_pcm_runtime runtime 
)

Definition at line 279 of file pcm_lib.c.

Variable Documentation

struct snd_pcm_chmap_elem snd_pcm_alt_chmaps[]
Initial value:
= {
{ .channels = 1,
.map = { SNDRV_CHMAP_MONO } },
{ .channels = 2,
{ .channels = 4,
{ .channels = 6,
{ .channels = 8,
{ }
}

Definition at line 2334 of file pcm_lib.c.

struct snd_pcm_chmap_elem snd_pcm_std_chmaps[]
Initial value:
= {
{ .channels = 1,
.map = { SNDRV_CHMAP_MONO } },
{ .channels = 2,
{ .channels = 4,
{ .channels = 6,
{ .channels = 8,
{ }
}

Definition at line 2312 of file pcm_lib.c.