FreeBSD kernel sound device code
channel.c File Reference
#include "opt_isa.h"
#include <dev/sound/pcm/sound.h>
#include <dev/sound/pcm/vchan.h>
#include "feeder_if.h"
Include dependency graph for channel.c:

Go to the source code of this file.

Macros

#define SND_CHN_OSS_FRONT   (SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR)
 
#define SND_CHN_OSS_SURR   (SND_CHN_T_MASK_SL | SND_CHN_T_MASK_SR)
 
#define SND_CHN_OSS_CENTER_LFE   (SND_CHN_T_MASK_FC | SND_CHN_T_MASK_LF)
 
#define SND_CHN_OSS_REAR   (SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR)
 
#define CHN_LATENCY_PBLKCNT_REF
 
#define CHN_LATENCY_PBUFSZ_REF
 
#define CHN_LATENCY_RBLKCNT_REF
 
#define CHN_LATENCY_RBUFSZ_REF
 
#define CHN_LATENCY_DATA_REF   192000 /* 48khz stereo 16bit ~ 48000 x 2 x 2 */
 

Functions

 SND_DECLARE_FILE ("$FreeBSD$")
 
 SYSCTL_INT (_hw_snd, OID_AUTO, report_soft_formats, CTLFLAG_RW, &report_soft_formats, 0, "report software-emulated formats")
 
 SYSCTL_INT (_hw_snd, OID_AUTO, report_soft_matrix, CTLFLAG_RW, &report_soft_matrix, 0, "report software-emulated channel matrixing")
 
static int sysctl_hw_snd_latency (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_hw_snd, OID_AUTO, latency, CTLTYPE_INT|CTLFLAG_RWTUN|CTLFLAG_MPSAFE, 0, sizeof(int), sysctl_hw_snd_latency, "I", "buffering latency (0=low ... 10=high)")
 
static int sysctl_hw_snd_latency_profile (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_hw_snd, OID_AUTO, latency_profile, CTLTYPE_INT|CTLFLAG_RWTUN|CTLFLAG_MPSAFE, 0, sizeof(int), sysctl_hw_snd_latency_profile, "I", "buffering latency profile (0=aggressive 1=safe)")
 
static int sysctl_hw_snd_timeout (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_hw_snd, OID_AUTO, timeout, CTLTYPE_INT|CTLFLAG_RWTUN|CTLFLAG_MPSAFE, 0, sizeof(int), sysctl_hw_snd_timeout, "I", "interrupt timeout (1 - 10) seconds")
 
 SYSCTL_INT (_hw_snd, OID_AUTO, vpc_autoreset, CTLFLAG_RWTUN, &chn_vpc_autoreset, 0, "automatically reset channels volume to 0db")
 
static void chn_vpc_proc (int reset, int db)
 
static int sysctl_hw_snd_vpc_0db (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_hw_snd, OID_AUTO, vpc_0db, CTLTYPE_INT|CTLFLAG_RWTUN|CTLFLAG_NEEDGIANT, 0, sizeof(int), sysctl_hw_snd_vpc_0db, "I", "0db relative level")
 
static int sysctl_hw_snd_vpc_reset (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_hw_snd, OID_AUTO, vpc_reset, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_NEEDGIANT, 0, sizeof(int), sysctl_hw_snd_vpc_reset, "I", "reset volume on all channels")
 
 SYSCTL_INT (_hw_snd, OID_AUTO, usefrags, CTLFLAG_RWTUN, &chn_usefrags, 0, "prefer setfragments() over setblocksize()")
 
 SYSCTL_INT (_hw_snd, OID_AUTO, syncdelay, CTLFLAG_RWTUN, &chn_syncdelay, 0, "append (0-1000) millisecond trailing buffer delay on each sync")
 
 MTX_SYSINIT (pcm_syncgroup, &snd_pcm_syncgroups_mtx, "PCM channel sync group lock", MTX_DEF)
 
static void chn_lockinit (struct pcm_channel *c, int dir)
 
static void chn_lockdestroy (struct pcm_channel *c)
 
static int chn_polltrigger (struct pcm_channel *c)
 Determine channel is ready for I/O. More...
 
static void chn_pollreset (struct pcm_channel *c)
 
static void chn_wakeup (struct pcm_channel *c)
 
static int chn_sleep (struct pcm_channel *c, int timeout)
 
static unsigned int chn_dmaupdate (struct pcm_channel *c)
 
static void chn_wrfeed (struct pcm_channel *c)
 
static void chn_wrintr (struct pcm_channel *c)
 
int chn_write (struct pcm_channel *c, struct uio *buf)
 
static void chn_rdfeed (struct pcm_channel *c)
 
static void chn_rdintr (struct pcm_channel *c)
 
int chn_read (struct pcm_channel *c, struct uio *buf)
 
void chn_intr_locked (struct pcm_channel *c)
 
void chn_intr (struct pcm_channel *c)
 
u_int32_t chn_start (struct pcm_channel *c, int force)
 
void chn_resetbuf (struct pcm_channel *c)
 
int chn_sync (struct pcm_channel *c, int threshold)
 
int chn_poll (struct pcm_channel *c, int ev, struct thread *td)
 
int chn_abort (struct pcm_channel *c)
 
int chn_flush (struct pcm_channel *c)
 
int snd_fmtvalid (uint32_t fmt, uint32_t *fmtlist)
 
uint32_t snd_str2afmt (const char *req)
 
uint32_t snd_afmt2str (uint32_t afmt, char *buf, size_t len)
 
int chn_reset (struct pcm_channel *c, uint32_t fmt, uint32_t spd)
 
int chn_init (struct pcm_channel *c, void *devinfo, int dir, int direction)
 
int chn_kill (struct pcm_channel *c)
 
int chn_setvolume (struct pcm_channel *c, int left, int right)
 
int chn_setvolume_multi (struct pcm_channel *c, int vc, int left, int right, int center)
 
int chn_setvolume_matrix (struct pcm_channel *c, int vc, int vt, int val)
 
int chn_getvolume_matrix (struct pcm_channel *c, int vc, int vt)
 
int chn_setmute_multi (struct pcm_channel *c, int vc, int mute)
 
int chn_setmute_matrix (struct pcm_channel *c, int vc, int vt, int mute)
 
int chn_getmute_matrix (struct pcm_channel *c, int vc, int vt)
 
struct pcmchan_matrixchn_getmatrix (struct pcm_channel *c)
 
int chn_setmatrix (struct pcm_channel *c, struct pcmchan_matrix *m)
 
int chn_oss_getorder (struct pcm_channel *c, unsigned long long *map)
 
int chn_oss_setorder (struct pcm_channel *c, unsigned long long *map)
 
int chn_oss_getmask (struct pcm_channel *c, uint32_t *retmask)
 
void chn_vpc_reset (struct pcm_channel *c, int vc, int force)
 
static u_int32_t round_pow2 (u_int32_t v)
 
static u_int32_t round_blksz (u_int32_t v, int round)
 
static int chn_calclatency (int dir, int latency, int bps, u_int32_t datarate, u_int32_t max, int *rblksz, int *rblkcnt)
 
static int chn_resizebuf (struct pcm_channel *c, int latency, int blkcnt, int blksz)
 
int chn_setlatency (struct pcm_channel *c, int latency)
 
int chn_setblocksize (struct pcm_channel *c, int blkcnt, int blksz)
 
int chn_setparam (struct pcm_channel *c, uint32_t format, uint32_t speed)
 
int chn_setspeed (struct pcm_channel *c, uint32_t speed)
 
int chn_setformat (struct pcm_channel *c, uint32_t format)
 
void chn_syncstate (struct pcm_channel *c)
 
int chn_trigger (struct pcm_channel *c, int go)
 
int chn_getptr (struct pcm_channel *c)
 Queries sound driver for sample-aligned hardware buffer pointer index. More...
 
struct pcmchan_capschn_getcaps (struct pcm_channel *c)
 
u_int32_t chn_getformats (struct pcm_channel *c)
 
int chn_notify (struct pcm_channel *c, u_int32_t flags)
 
int chn_getrates (struct pcm_channel *c, int **rates)
 Fetch array of supported discrete sample rates. More...
 
int chn_syncdestroy (struct pcm_channel *c)
 Remove channel from a sync group, if there is one. More...
 

Variables

int report_soft_formats = 1
 
int report_soft_matrix = 1
 
int chn_latency = CHN_LATENCY_DEFAULT
 
int chn_latency_profile = CHN_LATENCY_PROFILE_DEFAULT
 
static int chn_timeout = CHN_TIMEOUT
 
static int chn_vpc_autoreset = 1
 
static int chn_vol_0db_pcm = SND_VOL_0DB_PCM
 
static int chn_usefrags = 0
 
static int chn_syncdelay = -1
 
struct mtx snd_pcm_syncgroups_mtx
 Channel sync group lock. More...
 
struct pcm_synclist snd_pcm_syncgroups = SLIST_HEAD_INITIALIZER(snd_pcm_syncgroups)
 syncgroups' master list More...
 
struct {
   char *   name
 
   char *   alias1
 
   char *   alias2
 
   uint32_t   afmt
 
afmt_tab []
 

Macro Definition Documentation

◆ CHN_LATENCY_DATA_REF

#define CHN_LATENCY_DATA_REF   192000 /* 48khz stereo 16bit ~ 48000 x 2 x 2 */

Definition at line 1723 of file channel.c.

◆ CHN_LATENCY_PBLKCNT_REF

#define CHN_LATENCY_PBLKCNT_REF
Value:
{{1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1}, \
{1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1}}

Definition at line 1709 of file channel.c.

◆ CHN_LATENCY_PBUFSZ_REF

#define CHN_LATENCY_PBUFSZ_REF
Value:
{{7, 9, 12, 13, 14, 15, 15, 15, 15, 15, 16}, \
{11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 17}}

Definition at line 1712 of file channel.c.

◆ CHN_LATENCY_RBLKCNT_REF

#define CHN_LATENCY_RBLKCNT_REF
Value:
{{9, 8, 7, 6, 5, 5, 4, 3, 2, 1, 1}, \
{9, 8, 7, 6, 5, 5, 4, 3, 2, 1, 1}}

Definition at line 1716 of file channel.c.

◆ CHN_LATENCY_RBUFSZ_REF

#define CHN_LATENCY_RBUFSZ_REF
Value:
{{14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16}, \
{15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17}}

Definition at line 1719 of file channel.c.

◆ SND_CHN_OSS_CENTER_LFE

#define SND_CHN_OSS_CENTER_LFE   (SND_CHN_T_MASK_FC | SND_CHN_T_MASK_LF)

Definition at line 1538 of file channel.c.

◆ SND_CHN_OSS_FRONT

#define SND_CHN_OSS_FRONT   (SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR)

Definition at line 1536 of file channel.c.

◆ SND_CHN_OSS_REAR

#define SND_CHN_OSS_REAR   (SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR)

Definition at line 1539 of file channel.c.

◆ SND_CHN_OSS_SURR

#define SND_CHN_OSS_SURR   (SND_CHN_T_MASK_SL | SND_CHN_T_MASK_SR)

Definition at line 1537 of file channel.c.

Function Documentation

◆ chn_abort()

int chn_abort ( struct pcm_channel c)

◆ chn_calclatency()

static int chn_calclatency ( int  dir,
int  latency,
int  bps,
u_int32_t  datarate,
u_int32_t  max,
int *  rblksz,
int *  rblkcnt 
)
static

◆ chn_dmaupdate()

static unsigned int chn_dmaupdate ( struct pcm_channel c)
static

◆ chn_flush()

int chn_flush ( struct pcm_channel c)

Definition at line 962 of file channel.c.

References b, pcm_channel::bufhard, c, CHN_F_CLOSING, CHN_LOCKASSERT, chn_sync(), chn_trigger(), DEB, pcm_channel::direction, pcm_channel::flags, PCMDIR_PLAY, PCMTRIG_ABORT, and sndbuf_setrun().

Referenced by dsp_close().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_getcaps()

◆ chn_getformats()

u_int32_t chn_getformats ( struct pcm_channel c)

Definition at line 2284 of file channel.c.

References AFMT_CONVERTIBLE, AFMT_ENCODING, c, CHN_BITPERFECT, chn_getcaps(), pcmchan_caps::fmtlist, fmts, and report_soft_formats.

Referenced by dsp_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_getmatrix()

struct pcmchan_matrix * chn_getmatrix ( struct pcm_channel c)

Definition at line 1469 of file channel.c.

References AFMT_CONVERTIBLE, c, CHN_LOCKASSERT, pcm_channel::format, and pcm_channel::matrix.

◆ chn_getmute_matrix()

int chn_getmute_matrix ( struct pcm_channel c,
int  vc,
int  vt 
)

◆ chn_getptr()

int chn_getptr ( struct pcm_channel c)

Queries sound driver for sample-aligned hardware buffer pointer index.

This function obtains the hardware pointer location, then aligns it to the current bytes-per-sample value before returning. (E.g., a channel running in 16 bit stereo mode would require 4 bytes per sample, so a hwptr value ranging from 32-35 would be returned as 32.)

Parameters
cPCM channel context
Returns
sample-aligned hardware buffer pointer index

Definition at line 2267 of file channel.c.

References pcm_channel::bufhard, c, CHN_LOCKASSERT, CHN_STARTED, pcm_channel::devinfo, pcm_channel::methods, and sndbuf_getalign().

Referenced by chn_dmaupdate(), and dsp_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_getrates()

int chn_getrates ( struct pcm_channel c,
int **  rates 
)

Fetch array of supported discrete sample rates.

Wrapper for CHANNEL_GETRATES. Please see channel_if.m:getrates() for detailed information.

Note
If the operation isn't supported, this function will just return 0 (no rates in the array), and *rates will be set to NULL. Callers should examine rates only if this function returns non-zero.
Parameters
cpcm channel to examine
ratespointer to array of integers; rate table will be recorded here
Returns
number of rates in the array pointed to be rates

Definition at line 2529 of file channel.c.

References c, CHN_LOCKASSERT, pcm_channel::devinfo, pcm_channel::methods, and rates.

Referenced by dsp_oss_audioinfo().

Here is the caller graph for this function:

◆ chn_getvolume_matrix()

int chn_getvolume_matrix ( struct pcm_channel c,
int  vc,
int  vt 
)

◆ chn_init()

◆ chn_intr()

◆ chn_intr_locked()

void chn_intr_locked ( struct pcm_channel c)

Definition at line 646 of file channel.c.

References c, CHN_LOCKASSERT, chn_rdintr(), chn_wrintr(), pcm_channel::direction, pcm_channel::interrupts, and PCMDIR_PLAY.

Referenced by chn_intr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_kill()

int chn_kill ( struct pcm_channel c)

Definition at line 1285 of file channel.c.

References b, pcm_channel::bufhard, pcm_channel::bufsoft, c, CHN_F_DEAD, CHN_LOCK, chn_lockdestroy(), chn_removefeeder(), CHN_STARTED, chn_trigger(), CHN_UNLOCK, pcm_channel::devinfo, pcm_channel::flags, pcm_channel::methods, PCMTRIG_ABORT, sndbuf_destroy(), and sndbuf_free().

Referenced by pcm_chn_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_lockdestroy()

static void chn_lockdestroy ( struct pcm_channel c)
static

Definition at line 253 of file channel.c.

References c, CHN_BROADCAST, CHN_LOCKASSERT, pcm_channel::cv, pcm_channel::intr_cv, pcm_channel::lock, and snd_mtxfree().

Referenced by chn_init(), and chn_kill().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_lockinit()

static void chn_lockinit ( struct pcm_channel c,
int  dir 
)
static

Definition at line 225 of file channel.c.

References c, pcm_channel::cv, dir, pcm_channel::intr_cv, pcm_channel::lock, pcm_channel::name, PCMDIR_PLAY, PCMDIR_PLAY_VIRTUAL, PCMDIR_REC, PCMDIR_REC_VIRTUAL, and snd_mtxcreate().

Referenced by chn_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_notify()

◆ chn_oss_getmask()

int chn_oss_getmask ( struct pcm_channel c,
uint32_t *  retmask 
)

Definition at line 1542 of file channel.c.

References AFMT_CONVERTIBLE, c, pcmchan_caps::caps, CHN_BITPERFECT, chn_getcaps(), CHN_LOCKASSERT, pcm_channel::devinfo, format, m, pcmchan_matrix::mask, pcm_channel::methods, report_soft_matrix, SND_CHN_OSS_CENTER_LFE, SND_CHN_OSS_FRONT, SND_CHN_OSS_REAR, and SND_CHN_OSS_SURR.

Referenced by dsp_oss_getchannelmask().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_oss_getorder()

int chn_oss_getorder ( struct pcm_channel c,
unsigned long long *  map 
)

Definition at line 1502 of file channel.c.

References AFMT_CONVERTIBLE, c, CHN_LOCKASSERT, feeder_matrix_oss_get_channel_order(), pcm_channel::format, pcmchan_matrix::map, and pcm_channel::matrix.

Referenced by dsp_oss_getchnorder().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_oss_setorder()

int chn_oss_setorder ( struct pcm_channel c,
unsigned long long *  map 
)

Definition at line 1516 of file channel.c.

References AFMT_CONVERTIBLE, c, CHN_LOCKASSERT, chn_setmatrix(), feeder_matrix_oss_set_channel_order(), pcm_channel::format, m, pcmchan_matrix::map, and pcm_channel::matrix.

Referenced by dsp_oss_setchnorder().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_poll()

int chn_poll ( struct pcm_channel c,
int  ev,
struct thread *  td 
)

Definition at line 897 of file channel.c.

References pcm_channel::bufsoft, c, CHN_F_MMAP, CHN_F_TRIGGERED, CHN_LOCKASSERT, chn_pollreset(), chn_polltrigger(), chn_start(), pcm_channel::flags, and sndbuf_getsel().

Referenced by dsp_poll().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_pollreset()

static void chn_pollreset ( struct pcm_channel c)
static

Definition at line 296 of file channel.c.

References pcm_channel::bufsoft, c, CHN_LOCKASSERT, and sndbuf_updateprevtotal().

Referenced by chn_poll().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_polltrigger()

static int chn_polltrigger ( struct pcm_channel c)
static

Determine channel is ready for I/O.

Return values
1= ready for I/O
0= not ready for I/O

Definition at line 273 of file channel.c.

References pcm_channel::bufsoft, c, CHN_F_MMAP, CHN_LOCKASSERT, pcm_channel::direction, pcm_channel::flags, pcm_channel::lw, PCMDIR_PLAY, sndbuf_getfree(), sndbuf_getprevtotal(), sndbuf_getready(), and sndbuf_gettotal().

Referenced by chn_poll(), and chn_wakeup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_rdfeed()

static void chn_rdfeed ( struct pcm_channel c)
static

Definition at line 526 of file channel.c.

References amt, b, pcm_channel::bufhard, pcm_channel::bufsoft, c, CHN_F_MMAP, CHN_LOCKASSERT, chn_wakeup(), pcm_channel::feeder, pcm_channel::flags, sndbuf_dispose(), sndbuf_feed(), sndbuf_getfree(), sndbuf_getready(), and pcm_channel::xruns.

Referenced by chn_rdintr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_rdintr()

static void chn_rdintr ( struct pcm_channel c)
static

Definition at line 569 of file channel.c.

References c, chn_dmaupdate(), CHN_LOCKASSERT, chn_rdfeed(), chn_trigger(), and PCMTRIG_EMLDMARD.

Referenced by chn_intr_locked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_read()

int chn_read ( struct pcm_channel c,
struct uio *  buf 
)

◆ chn_reset()

◆ chn_resetbuf()

void chn_resetbuf ( struct pcm_channel c)

Definition at line 750 of file channel.c.

References b, pcm_channel::blocks, pcm_channel::bufhard, pcm_channel::bufsoft, c, and sndbuf_reset().

Referenced by chn_reset(), chn_resizebuf(), and dsp_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_resizebuf()

◆ chn_setblocksize()

int chn_setblocksize ( struct pcm_channel c,
int  blkcnt,
int  blksz 
)

Definition at line 1983 of file channel.c.

References blkcnt, blksz, c, CHN_LOCKASSERT, and chn_resizebuf().

Referenced by dsp_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_setformat()

int chn_setformat ( struct pcm_channel c,
uint32_t  format 
)

Definition at line 2061 of file channel.c.

References AFMT_CHANNEL, AFMT_PASSTHROUGH, AFMT_PASSTHROUGH_CHANNEL, AFMT_PASSTHROUGH_EXTCHANNEL, c, chn_setparam(), pcm_channel::dev, format, pcm_channel::format, SND_FORMAT, snd_verbose, speed, and pcm_channel::speed.

Referenced by chn_reset(), chn_setmatrix(), and dsp_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_setlatency()

int chn_setlatency ( struct pcm_channel c,
int  latency 
)

Definition at line 1975 of file channel.c.

References c, CHN_LOCKASSERT, and chn_resizebuf().

Referenced by chn_notify(), chn_reset(), and dsp_oss_policy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_setmatrix()

int chn_setmatrix ( struct pcm_channel c,
struct pcmchan_matrix m 
)

Definition at line 1482 of file channel.c.

References AFMT_CONVERTIBLE, c, pcmchan_matrix::channels, CHN_LOCKASSERT, chn_setformat(), pcmchan_matrix::ext, pcm_channel::format, pcmchan_matrix::id, m, pcm_channel::matrix, SND_CHN_MATRIX_PCMCHANNEL, and SND_FORMAT.

Referenced by chn_oss_setorder().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_setmute_matrix()

int chn_setmute_matrix ( struct pcm_channel c,
int  vc,
int  vt,
int  mute 
)

◆ chn_setmute_multi()

int chn_setmute_multi ( struct pcm_channel c,
int  vc,
int  mute 
)

Definition at line 1400 of file channel.c.

References c, chn_setmute_matrix(), SND_CHN_LEFT_MASK, SND_CHN_RIGHT_MASK, and SND_CHN_T_MAX.

Referenced by dsp_ioctl_channel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_setparam()

int chn_setparam ( struct pcm_channel c,
uint32_t  format,
uint32_t  speed 
)

◆ chn_setspeed()

int chn_setspeed ( struct pcm_channel c,
uint32_t  speed 
)

Definition at line 2032 of file channel.c.

References AFMT_PASSTHROUGH, AFMT_PASSTHROUGH_RATE, c, chn_setparam(), pcm_channel::dev, format, pcm_channel::format, snd_verbose, speed, and pcm_channel::speed.

Referenced by chn_reset(), and dsp_ioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_setvolume()

int chn_setvolume ( struct pcm_channel c,
int  left,
int  right 
)

Definition at line 1310 of file channel.c.

References c, chn_setvolume_matrix(), left, right, SND_CHN_T_FL, SND_CHN_T_FR, and SND_VOL_C_MASTER.

Here is the call graph for this function:

◆ chn_setvolume_matrix()

int chn_setvolume_matrix ( struct pcm_channel c,
int  vc,
int  vt,
int  val 
)

◆ chn_setvolume_multi()

int chn_setvolume_multi ( struct pcm_channel c,
int  vc,
int  left,
int  right,
int  center 
)

Definition at line 1322 of file channel.c.

References c, chn_setvolume_matrix(), left, right, SND_CHN_LEFT_MASK, SND_CHN_RIGHT_MASK, and SND_CHN_T_MAX.

Referenced by chn_syncstate(), dsp_ioctl_channel(), mixer_ioctl_channel(), and mixer_set_softpcmvol().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_sleep()

static int chn_sleep ( struct pcm_channel c,
int  timeout 
)
static

Definition at line 334 of file channel.c.

References c, CHN_F_DEAD, CHN_F_SLEEPING, CHN_LOCKASSERT, pcm_channel::flags, pcm_channel::intr_cv, pcm_channel::lock, and pcm_channel::timeout.

Referenced by chn_read(), chn_sync(), and chn_write().

Here is the caller graph for this function:

◆ chn_start()

◆ chn_sync()

◆ chn_syncdestroy()

int chn_syncdestroy ( struct pcm_channel c)

Remove channel from a sync group, if there is one.

This function is initially intended for the following conditions:

  • Starting a syncgroup (SNDCTL_DSP_SYNCSTART ioctl)
  • Closing a device. (A channel can't be destroyed if it's still in use.)
Note
Before calling this function, the syncgroup list mutex must be held. (Consider pcm_channel::sm protected by the SG list mutex whether c is locked or not.)
Parameters
cchannel device to be started or closed
Returns
If this channel was the only member of a group, the group ID is returned to the caller so that the caller can release it via free_unr() after giving up the syncgroup lock. Else it returns 0.

Definition at line 2554 of file channel.c.

References c, free, pcmchan_syncgroup::id, pcmchan_syncmember::parent, PCM_SG_LOCKASSERT, pcm_channel::sm, and snd_pcm_syncgroups.

Referenced by dsp_close(), and dsp_oss_syncgroup().

Here is the caller graph for this function:

◆ chn_syncstate()

◆ chn_trigger()

◆ chn_vpc_proc()

static void chn_vpc_proc ( int  reset,
int  db 
)
static

Definition at line 129 of file channel.c.

References c, pcm_channel::channels, CHN_FOREACH, CHN_LOCK, CHN_SETVOLUME, CHN_UNLOCK, chn_vpc_reset(), PCM_ACQUIRE, pcm_devclass, PCM_LOCK, PCM_REGISTERED, PCM_RELEASE, PCM_UNLOCK, PCM_WAIT, reset, SND_CHN_T_VOL_0DB, and SND_VOL_C_PCM.

Referenced by sysctl_hw_snd_vpc_0db(), and sysctl_hw_snd_vpc_reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_vpc_reset()

void chn_vpc_reset ( struct pcm_channel c,
int  vc,
int  force 
)

Definition at line 1584 of file channel.c.

References c, CHN_LOCKASSERT, CHN_SETVOLUME, chn_vpc_autoreset, SND_CHN_T_BEGIN, SND_CHN_T_END, SND_CHN_T_STEP, SND_CHN_T_VOL_0DB, SND_VOL_C_BEGIN, SND_VOL_C_END, and pcm_channel::volume.

Referenced by chn_init(), chn_vpc_proc(), and dsp_open().

Here is the caller graph for this function:

◆ chn_wakeup()

static void chn_wakeup ( struct pcm_channel c)
static

Definition at line 304 of file channel.c.

References pcm_channel::bufsoft, c, pcm_channel::children, CHN_BROADCAST, CHN_EMPTY, CHN_F_SLEEPING, CHN_FOREACH, CHN_LOCK, CHN_LOCKASSERT, chn_polltrigger(), CHN_UNLOCK, chn_wakeup(), pcm_channel::flags, pcm_channel::intr_cv, and sndbuf_getsel().

Referenced by chn_rdfeed(), chn_wakeup(), and chn_wrfeed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_wrfeed()

static void chn_wrfeed ( struct pcm_channel c)
static

Definition at line 392 of file channel.c.

References amt, b, pcm_channel::bufhard, pcm_channel::bufsoft, c, CHN_F_CLOSING, CHN_F_MMAP, CHN_LOCKASSERT, chn_wakeup(), pcm_channel::feeder, pcm_channel::flags, sndbuf_acquire(), sndbuf_feed(), sndbuf_getfree(), sndbuf_getready(), sndbuf_getsize(), sndbuf_xbytes(), and pcm_channel::xruns.

Referenced by chn_wrintr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_wrintr()

static void chn_wrintr ( struct pcm_channel c)
static

Definition at line 439 of file channel.c.

References c, chn_dmaupdate(), CHN_LOCKASSERT, chn_trigger(), chn_wrfeed(), and PCMTRIG_EMLDMAWR.

Referenced by chn_intr_locked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chn_write()

int chn_write ( struct pcm_channel c,
struct uio *  buf 
)
Todo:
Evaluate whether EAGAIN is truly desirable. 4Front drivers behave like this, but I'm not sure if it at all violates the "write should be allowed to block" model.

The idea is that, while set with CHN_F_NOTRIGGER, a channel isn't playing, but without this we end up with "interrupt timeout / channel dead".

Definition at line 459 of file channel.c.

References buf, pcm_channel::bufsoft, c, CHN_F_ABORTING, CHN_F_DEAD, CHN_F_NBIO, CHN_F_NOTRIGGER, CHN_LOCK, CHN_LOCKASSERT, chn_sleep(), chn_start(), CHN_STOPPED, chn_timeout, CHN_UNLOCK, pcm_channel::dev, pcm_channel::flags, pcm_channel::name, sndbuf_acquire(), sndbuf_getbufofs(), sndbuf_getfree(), sndbuf_getfreeptr(), and sndbuf_getsize().

Referenced by dsp_io_ops().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MTX_SYSINIT()

MTX_SYSINIT ( pcm_syncgroup  ,
snd_pcm_syncgroups_mtx,
"PCM channel sync group lock"  ,
MTX_DEF   
)

◆ round_blksz()

static u_int32_t round_blksz ( u_int32_t  v,
int  round 
)
static

Definition at line 1616 of file channel.c.

References CHN_2NDBUFMAXSIZE, and round_pow2().

Referenced by chn_calclatency(), and chn_resizebuf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ round_pow2()

static u_int32_t round_pow2 ( u_int32_t  v)
static

Definition at line 1600 of file channel.c.

Referenced by chn_calclatency(), chn_resizebuf(), and round_blksz().

Here is the caller graph for this function:

◆ snd_afmt2str()

uint32_t snd_afmt2str ( uint32_t  afmt,
char *  buf,
size_t  len 
)

Definition at line 1099 of file channel.c.

References afmt, AFMT_CHANNEL, AFMT_ENCODING, AFMT_EXTCHANNEL, afmt_tab, AFMTSTR_LEN, buf, len, name, and SND_FORMAT.

Referenced by sysctl_dev_pcm_vchanformat().

Here is the caller graph for this function:

◆ SND_DECLARE_FILE()

SND_DECLARE_FILE ( "$FreeBSD$"  )

◆ snd_fmtvalid()

int snd_fmtvalid ( uint32_t  fmt,
uint32_t *  fmtlist 
)

Definition at line 982 of file channel.c.

References AFMT_ENCODING, AFMT_PASSTHROUGH, and fmt.

Referenced by chn_notify(), feeder_chain(), snd_fmtbest(), snd_fmtbestfunc(), vchan_create(), and vchan_setformat().

Here is the caller graph for this function:

◆ snd_str2afmt()

uint32_t snd_str2afmt ( const char *  req)

Definition at line 1031 of file channel.c.

References afmt, AFMT_CHANNEL_MAX, AFMT_EXTCHANNEL_MAX, afmt_tab, alias1, alias2, name, req, and SND_FORMAT.

Referenced by sysctl_dev_pcm_vchanformat(), and vchan_create().

Here is the caller graph for this function:

◆ sysctl_hw_snd_latency()

static int sysctl_hw_snd_latency ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 56 of file channel.c.

References chn_latency, CHN_LATENCY_MAX, req, and val.

◆ sysctl_hw_snd_latency_profile()

static int sysctl_hw_snd_latency_profile ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 79 of file channel.c.

References chn_latency_profile, CHN_LATENCY_PROFILE_MAX, req, and val.

◆ sysctl_hw_snd_timeout()

static int sysctl_hw_snd_timeout ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 102 of file channel.c.

References chn_timeout, CHN_TIMEOUT_MAX, req, and val.

◆ sysctl_hw_snd_vpc_0db()

static int sysctl_hw_snd_vpc_0db ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 156 of file channel.c.

References chn_vol_0db_pcm, chn_vpc_proc(), req, SND_VOL_0DB_MAX, and val.

Here is the call graph for this function:

◆ sysctl_hw_snd_vpc_reset()

static int sysctl_hw_snd_vpc_reset ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 178 of file channel.c.

References chn_vol_0db_pcm, chn_vpc_proc(), req, SND_VOL_0DB_PCM, and val.

Here is the call graph for this function:

◆ SYSCTL_INT() [1/5]

SYSCTL_INT ( _hw_snd  ,
OID_AUTO  ,
report_soft_formats  ,
CTLFLAG_RW  ,
report_soft_formats,
,
"report software-emulated formats"   
)

◆ SYSCTL_INT() [2/5]

SYSCTL_INT ( _hw_snd  ,
OID_AUTO  ,
report_soft_matrix  ,
CTLFLAG_RW  ,
report_soft_matrix,
,
"report software-emulated channel matrixing"   
)

◆ SYSCTL_INT() [3/5]

SYSCTL_INT ( _hw_snd  ,
OID_AUTO  ,
syncdelay  ,
CTLFLAG_RWTUN  ,
chn_syncdelay,
,
"append (0-1000) millisecond trailing buffer delay on each sync"   
)

◆ SYSCTL_INT() [4/5]

SYSCTL_INT ( _hw_snd  ,
OID_AUTO  ,
usefrags  ,
CTLFLAG_RWTUN  ,
chn_usefrags,
,
"prefer setfragments() over setblocksize()"   
)

◆ SYSCTL_INT() [5/5]

SYSCTL_INT ( _hw_snd  ,
OID_AUTO  ,
vpc_autoreset  ,
CTLFLAG_RWTUN  ,
chn_vpc_autoreset,
,
"automatically reset channels volume to 0db"   
)

◆ SYSCTL_PROC() [1/5]

SYSCTL_PROC ( _hw_snd  ,
OID_AUTO  ,
latency  ,
CTLTYPE_INT|CTLFLAG_RWTUN|  CTLFLAG_MPSAFE,
,
sizeof(int)  ,
sysctl_hw_snd_latency  ,
"I"  ,
"buffering latency (0=low ... 10=high)"   
)

◆ SYSCTL_PROC() [2/5]

SYSCTL_PROC ( _hw_snd  ,
OID_AUTO  ,
latency_profile  ,
CTLTYPE_INT|CTLFLAG_RWTUN|  CTLFLAG_MPSAFE,
,
sizeof(int)  ,
sysctl_hw_snd_latency_profile  ,
"I"  ,
"buffering latency profile (0=aggressive 1=safe)"   
)

◆ SYSCTL_PROC() [3/5]

SYSCTL_PROC ( _hw_snd  ,
OID_AUTO  ,
timeout  ,
CTLTYPE_INT|CTLFLAG_RWTUN|  CTLFLAG_MPSAFE,
,
sizeof(int)  ,
sysctl_hw_snd_timeout  ,
"I"  ,
"interrupt timeout (1 - 10) seconds"   
)

◆ SYSCTL_PROC() [4/5]

SYSCTL_PROC ( _hw_snd  ,
OID_AUTO  ,
vpc_0db  ,
CTLTYPE_INT|CTLFLAG_RWTUN|  CTLFLAG_NEEDGIANT,
,
sizeof(int)  ,
sysctl_hw_snd_vpc_0db  ,
"I"  ,
"0db relative level"   
)

◆ SYSCTL_PROC() [5/5]

SYSCTL_PROC ( _hw_snd  ,
OID_AUTO  ,
vpc_reset  ,
CTLTYPE_INT|CTLFLAG_RW|  CTLFLAG_NEEDGIANT,
,
sizeof(int)  ,
sysctl_hw_snd_vpc_reset  ,
"I"  ,
"reset volume on all channels"   
)

Variable Documentation

◆ afmt

uint32_t afmt

Definition at line 998 of file channel.c.

Referenced by snd_afmt2str(), and snd_str2afmt().

◆ 

const struct { ... } afmt_tab[]
Initial value:
= {
{ "alaw", NULL, NULL, AFMT_A_LAW },
{ "mulaw", NULL, NULL, AFMT_MU_LAW },
{ "u8", "8", NULL, AFMT_U8 },
{ "s8", NULL, NULL, AFMT_S8 },
{ "s16le", "s16", "16", AFMT_S16_LE },
{ "s16be", NULL, NULL, AFMT_S16_BE },
{ "u16le", NULL, NULL, AFMT_U16_LE },
{ "u16be", NULL, NULL, AFMT_U16_BE },
{ "s24le", NULL, NULL, AFMT_S24_LE },
{ "s24be", NULL, NULL, AFMT_S24_BE },
{ "u24le", NULL, NULL, AFMT_U24_LE },
{ "u24be", NULL, NULL, AFMT_U24_BE },
{ "s32le", "s32", "32", AFMT_S32_LE },
{ "s32be", NULL, NULL, AFMT_S32_BE },
{ "u32le", NULL, NULL, AFMT_U32_LE },
{ "u32be", NULL, NULL, AFMT_U32_BE },
{ "ac3", NULL, NULL, AFMT_AC3 },
{ NULL, NULL, NULL, 0 }
}

Referenced by snd_afmt2str(), and snd_str2afmt().

◆ alias1

char * alias1

Definition at line 997 of file channel.c.

Referenced by snd_str2afmt().

◆ alias2

char * alias2

Definition at line 997 of file channel.c.

Referenced by snd_str2afmt().

◆ chn_latency

int chn_latency = CHN_LATENCY_DEFAULT

Definition at line 53 of file channel.c.

Referenced by chn_notify(), chn_reset(), chn_resizebuf(), SLIST_HEAD(), and sysctl_hw_snd_latency().

◆ chn_latency_profile

int chn_latency_profile = CHN_LATENCY_PROFILE_DEFAULT

Definition at line 76 of file channel.c.

Referenced by chn_calclatency(), SLIST_HEAD(), and sysctl_hw_snd_latency_profile().

◆ chn_syncdelay

int chn_syncdelay = -1
static

Definition at line 198 of file channel.c.

Referenced by chn_sync().

◆ chn_timeout

int chn_timeout = CHN_TIMEOUT
static

Definition at line 99 of file channel.c.

Referenced by chn_init(), chn_read(), chn_write(), and sysctl_hw_snd_timeout().

◆ chn_usefrags

int chn_usefrags = 0
static

Definition at line 197 of file channel.c.

Referenced by chn_resizebuf().

◆ chn_vol_0db_pcm

int chn_vol_0db_pcm = SND_VOL_0DB_PCM
static

Definition at line 126 of file channel.c.

Referenced by chn_init(), sysctl_hw_snd_vpc_0db(), and sysctl_hw_snd_vpc_reset().

◆ chn_vpc_autoreset

int chn_vpc_autoreset = 1
static

Definition at line 122 of file channel.c.

Referenced by chn_vpc_reset().

◆ name

char* name

Definition at line 997 of file channel.c.

Referenced by snd_afmt2str(), and snd_str2afmt().

◆ report_soft_formats

int report_soft_formats = 1

Definition at line 45 of file channel.c.

Referenced by chn_getformats().

◆ report_soft_matrix

int report_soft_matrix = 1

Definition at line 49 of file channel.c.

Referenced by chn_oss_getmask().

◆ snd_pcm_syncgroups

struct pcm_synclist snd_pcm_syncgroups = SLIST_HEAD_INITIALIZER(snd_pcm_syncgroups)

syncgroups' master list

Each time a channel syncgroup is created, it's added to this list. This list should only be accessed with

See also
snd_pcm_syncgroups_mtx held.

See SNDCTL_DSP_SYNCGROUP for more information.

Definition at line 222 of file channel.c.

Referenced by chn_syncdestroy(), dsp_oss_syncgroup(), and dsp_oss_syncstart().

◆ snd_pcm_syncgroups_mtx

struct mtx snd_pcm_syncgroups_mtx

Channel sync group lock.

Clients should acquire this lock without holding any channel locks before touching syncgroups or the main syncgroup list.

Definition at line 212 of file channel.c.

Referenced by dsp_oss_syncstart().