FreeBSD kernel sound device code
channel.h File Reference
#include "channel_if.h"
Include dependency graph for channel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pcmchan_caps
 
struct  pcmchan_matrix
 
struct  pcmchan_syncgroup
 Specifies an audio device sync group. More...
 
struct  pcmchan_syncmember
 Specifies a container for members of a sync group. More...
 
struct  pcm_channel
 

Macros

#define PCM_SG_LOCK()   mtx_lock(&snd_pcm_syncgroups_mtx)
 
#define PCM_SG_TRYLOCK()   mtx_trylock(&snd_pcm_syncgroups_mtx)
 
#define PCM_SG_UNLOCK()   mtx_unlock(&snd_pcm_syncgroups_mtx)
 
#define PCM_SG_LOCKASSERT(arg)   mtx_assert(&snd_pcm_syncgroups_mtx, arg)
 
#define CHN_NAMELEN   32
 
#define CHN_COMM_UNUSED   "<UNUSED>"
 
#define CHN_COMM_UNKNOWN   "<UNKNOWN>"
 
#define CHN_HEAD(x, y)   &(x)->y.head
 
#define CHN_INIT(x, y)   SLIST_INIT(CHN_HEAD(x, y))
 
#define CHN_LINK(y)   y.link
 
#define CHN_EMPTY(x, y)   SLIST_EMPTY(CHN_HEAD(x, y))
 
#define CHN_FIRST(x, y)   SLIST_FIRST(CHN_HEAD(x, y))
 
#define CHN_FOREACH(x, y, z)    SLIST_FOREACH(x, CHN_HEAD(y, z), CHN_LINK(z))
 
#define CHN_FOREACH_SAFE(w, x, y, z)    SLIST_FOREACH_SAFE(w, CHN_HEAD(x, z), CHN_LINK(z), y)
 
#define CHN_INSERT_HEAD(x, y, z)    SLIST_INSERT_HEAD(CHN_HEAD(x, z), y, CHN_LINK(z))
 
#define CHN_INSERT_AFTER(x, y, z)    SLIST_INSERT_AFTER(x, y, CHN_LINK(z))
 
#define CHN_REMOVE(x, y, z)    SLIST_REMOVE(CHN_HEAD(x, z), y, pcm_channel, CHN_LINK(z))
 
#define CHN_INSERT_HEAD_SAFE(x, y, z)
 
#define CHN_INSERT_AFTER_SAFE(w, x, y, z)
 
#define CHN_REMOVE_SAFE(x, y, z)
 
#define CHN_INSERT_SORT(w, x, y, z)
 
#define CHN_INSERT_SORT_ASCEND(x, y, z)   CHN_INSERT_SORT(>, x, y, z)
 
#define CHN_INSERT_SORT_DESCEND(x, y, z)   CHN_INSERT_SORT(<, x, y, z)
 
#define CHN_UNIT(x)   (snd_unit2u((x)->unit))
 
#define CHN_DEV(x)   (snd_unit2d((x)->unit))
 
#define CHN_CHAN(x)   (snd_unit2c((x)->unit))
 
#define CHN_BUF_PARENT(x, y)
 
#define CHN_BROADCAST(x)
 
#define CHN_SETVOLUME(...)   chn_setvolume_matrix(__VA_ARGS__)
 
#define CHN_GETVOLUME(x, y, z)   ((x)->volume[y][z])
 
#define CHN_GETMUTE(x, y, z)   ((x)->muted[y][z])
 
#define CHN_LOCKOWNED(c)   mtx_owned((c)->lock)
 
#define CHN_LOCK(c)   mtx_lock((c)->lock)
 
#define CHN_UNLOCK(c)   mtx_unlock((c)->lock)
 
#define CHN_TRYLOCK(c)   mtx_trylock((c)->lock)
 
#define CHN_LOCKASSERT(c)   mtx_assert((c)->lock, MA_OWNED)
 
#define CHN_UNLOCKASSERT(c)   mtx_assert((c)->lock, MA_NOTOWNED)
 
#define AFMTSTR_LEN   16
 
#define PCMDIR_PLAY   1
 
#define PCMDIR_PLAY_VIRTUAL   2
 
#define PCMDIR_REC   -1
 
#define PCMDIR_REC_VIRTUAL   -2
 
#define PCMTRIG_START   1
 
#define PCMTRIG_EMLDMAWR   2
 
#define PCMTRIG_EMLDMARD   3
 
#define PCMTRIG_STOP   0
 
#define PCMTRIG_ABORT   -1
 
#define PCMTRIG_COMMON(x)
 
#define CHN_F_CLOSING   0x00000001 /* a pending close */
 
#define CHN_F_ABORTING   0x00000002 /* a pending abort */
 
#define CHN_F_RUNNING   0x00000004 /* dma is running */
 
#define CHN_F_TRIGGERED   0x00000008
 
#define CHN_F_NOTRIGGER   0x00000010
 
#define CHN_F_SLEEPING   0x00000020
 
#define CHN_F_NBIO   0x00000040 /* do non-blocking i/o */
 
#define CHN_F_MMAP   0x00000080 /* has been mmap()ed */
 
#define CHN_F_BUSY   0x00000100 /* has been opened */
 
#define CHN_F_DIRTY   0x00000200 /* need re-config */
 
#define CHN_F_DEAD   0x00000400 /* too many errors, dead, mdk */
 
#define CHN_F_SILENCE   0x00000800 /* silence, nil, null, yada */
 
#define CHN_F_HAS_SIZE   0x00001000 /* user set block size */
 
#define CHN_F_HAS_VCHAN   0x00002000 /* vchan master */
 
#define CHN_F_VCHAN_PASSTHROUGH   0x00004000 /* digital ac3/dts passthrough */
 
#define CHN_F_VCHAN_ADAPTIVE   0x00008000 /* adaptive format/rate selection */
 
#define CHN_F_VCHAN_DYNAMIC   (CHN_F_VCHAN_PASSTHROUGH | CHN_F_VCHAN_ADAPTIVE)
 
#define CHN_F_VIRTUAL   0x10000000 /* not backed by hardware */
 
#define CHN_F_BITPERFECT   0x20000000 /* un-cooked, Heh.. */
 
#define CHN_F_PASSTHROUGH   0x40000000 /* passthrough re-config */
 
#define CHN_F_EXCLUSIVE   0x80000000 /* exclusive access */
 
#define CHN_F_BITS
 
#define CHN_F_RESET
 
#define CHN_F_MMAP_INVALID   (CHN_F_DEAD | CHN_F_RUNNING)
 
#define CHN_N_RATE   0x00000001
 
#define CHN_N_FORMAT   0x00000002
 
#define CHN_N_VOLUME   0x00000004
 
#define CHN_N_BLOCKSIZE   0x00000008
 
#define CHN_N_TRIGGER   0x00000010
 
#define CHN_LATENCY_MIN   0
 
#define CHN_LATENCY_MAX   10
 
#define CHN_LATENCY_DEFAULT   2 /* 21.3ms total buffering */
 
#define CHN_POLICY_MIN   CHN_LATENCY_MIN
 
#define CHN_POLICY_MAX   CHN_LATENCY_MAX
 
#define CHN_POLICY_DEFAULT   CHN_LATENCY_DEFAULT
 
#define CHN_LATENCY_PROFILE_MIN   0
 
#define CHN_LATENCY_PROFILE_MAX   1
 
#define CHN_LATENCY_PROFILE_DEFAULT   CHN_LATENCY_PROFILE_MAX
 
#define CHN_STARTED(c)   ((c)->flags & CHN_F_TRIGGERED)
 
#define CHN_STOPPED(c)   (!CHN_STARTED(c))
 
#define CHN_DIRSTR(c)
 
#define CHN_BITPERFECT(c)   ((c)->flags & CHN_F_BITPERFECT)
 
#define CHN_PASSTHROUGH(c)   ((c)->flags & CHN_F_PASSTHROUGH)
 
#define CHN_TIMEOUT   5
 
#define CHN_TIMEOUT_MIN   1
 
#define CHN_TIMEOUT_MAX   10
 
#define CHN_2NDBUFBLKSIZE   (2 * 1024)
 
#define CHN_2NDBUFBLKNUM   (32)
 
#define CHN_2NDBUFMAXSIZE   (131072)
 
#define CHANNEL_DECLARE(name)   static DEFINE_CLASS(name, name ## _methods, sizeof(struct kobj))
 

Functions

 SLIST_HEAD (pcm_synclist, pcmchan_syncgroup) snd_pcm_syncgroups
 
int chn_reinit (struct pcm_channel *c)
 
int chn_write (struct pcm_channel *c, struct uio *buf)
 
int chn_read (struct pcm_channel *c, struct uio *buf)
 
u_int32_t chn_start (struct pcm_channel *c, int force)
 
int chn_sync (struct pcm_channel *c, int threshold)
 
int chn_flush (struct pcm_channel *c)
 
int chn_poll (struct pcm_channel *c, int ev, struct thread *td)
 
int chn_init (struct pcm_channel *c, void *devinfo, int dir, int direction)
 
int chn_kill (struct pcm_channel *c)
 
int chn_reset (struct pcm_channel *c, u_int32_t fmt, u_int32_t spd)
 
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)
 
void chn_vpc_reset (struct pcm_channel *c, int vc, int force)
 
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)
 
int chn_setblocksize (struct pcm_channel *c, int blkcnt, int blksz)
 
int chn_setlatency (struct pcm_channel *c, int latency)
 
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)
 
struct pcmchan_matrixchn_getmatrix (struct pcm_channel *)
 
int chn_setmatrix (struct pcm_channel *, struct pcmchan_matrix *)
 
int chn_oss_getorder (struct pcm_channel *, unsigned long long *)
 
int chn_oss_setorder (struct pcm_channel *, unsigned long long *)
 
int chn_oss_getmask (struct pcm_channel *, uint32_t *)
 
void chn_resetbuf (struct pcm_channel *c)
 
void chn_intr_locked (struct pcm_channel *c)
 
void chn_intr (struct pcm_channel *c)
 
int chn_abort (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...
 
int snd_fmtvalid (uint32_t fmt, uint32_t *fmtlist)
 
uint32_t snd_str2afmt (const char *)
 
uint32_t snd_afmt2str (uint32_t, char *, size_t)
 

Variables

struct mtx snd_pcm_syncgroups_mtx
 Channel sync group lock. More...
 
int chn_latency
 
int chn_latency_profile
 
int report_soft_formats
 
int report_soft_matrix
 

Macro Definition Documentation

◆ AFMTSTR_LEN

#define AFMTSTR_LEN   16

Definition at line 332 of file channel.h.

◆ CHANNEL_DECLARE

#define CHANNEL_DECLARE (   name)    static DEFINE_CLASS(name, name ## _methods, sizeof(struct kobj))

Definition at line 451 of file channel.h.

◆ CHN_2NDBUFBLKNUM

#define CHN_2NDBUFBLKNUM   (32)

Definition at line 447 of file channel.h.

◆ CHN_2NDBUFBLKSIZE

#define CHN_2NDBUFBLKSIZE   (2 * 1024)

Definition at line 445 of file channel.h.

◆ CHN_2NDBUFMAXSIZE

#define CHN_2NDBUFMAXSIZE   (131072)

Definition at line 449 of file channel.h.

◆ CHN_BITPERFECT

#define CHN_BITPERFECT (   c)    ((c)->flags & CHN_F_BITPERFECT)

Definition at line 433 of file channel.h.

◆ CHN_BROADCAST

#define CHN_BROADCAST (   x)
Value:
do { \
if ((x)->cv_waiters != 0) \
cv_broadcastpri(x, PRIBIO); \
} while (0)

Definition at line 252 of file channel.h.

◆ CHN_BUF_PARENT

#define CHN_BUF_PARENT (   x,
 
)
Value:
(((x) != NULL && (x)->parentchannel != NULL && \
(x)->parentchannel->bufhard != NULL) ? \
(x)->parentchannel->bufhard : (y))

Definition at line 247 of file channel.h.

◆ CHN_CHAN

#define CHN_CHAN (   x)    (snd_unit2c((x)->unit))

Definition at line 245 of file channel.h.

◆ CHN_COMM_UNKNOWN

#define CHN_COMM_UNKNOWN   "<UNKNOWN>"

Definition at line 83 of file channel.h.

◆ CHN_COMM_UNUSED

#define CHN_COMM_UNUSED   "<UNUSED>"

Definition at line 82 of file channel.h.

◆ CHN_DEV

#define CHN_DEV (   x)    (snd_unit2d((x)->unit))

Definition at line 244 of file channel.h.

◆ CHN_DIRSTR

#define CHN_DIRSTR (   c)
Value:
(((c)->direction == PCMDIR_PLAY) ? \
"PCMDIR_PLAY" : "PCMDIR_REC")
#define PCMDIR_PLAY
Definition: channel.h:339
struct pcm_channel * c
Definition: channel_if.m:106

Definition at line 431 of file channel.h.

◆ CHN_EMPTY

#define CHN_EMPTY (   x,
 
)    SLIST_EMPTY(CHN_HEAD(x, y))

Definition at line 178 of file channel.h.

◆ CHN_F_ABORTING

#define CHN_F_ABORTING   0x00000002 /* a pending abort */

Definition at line 355 of file channel.h.

◆ CHN_F_BITPERFECT

#define CHN_F_BITPERFECT   0x20000000 /* un-cooked, Heh.. */

Definition at line 377 of file channel.h.

◆ CHN_F_BITS

#define CHN_F_BITS
Value:
"\020" \
"\001CLOSING" \
"\002ABORTING" \
"\003RUNNING" \
"\004TRIGGERED" \
"\005NOTRIGGER" \
"\006SLEEPING" \
"\007NBIO" \
"\010MMAP" \
"\011BUSY" \
"\012DIRTY" \
"\013DEAD" \
"\014SILENCE" \
"\015HAS_SIZE" \
"\016HAS_VCHAN" \
"\017VCHAN_PASSTHROUGH" \
"\020VCHAN_ADAPTIVE" \
"\035VIRTUAL" \
"\036BITPERFECT" \
"\037PASSTHROUGH" \
"\040EXCLUSIVE"

Definition at line 381 of file channel.h.

◆ CHN_F_BUSY

#define CHN_F_BUSY   0x00000100 /* has been opened */

Definition at line 364 of file channel.h.

◆ CHN_F_CLOSING

#define CHN_F_CLOSING   0x00000001 /* a pending close */

Definition at line 354 of file channel.h.

◆ CHN_F_DEAD

#define CHN_F_DEAD   0x00000400 /* too many errors, dead, mdk */

Definition at line 366 of file channel.h.

◆ CHN_F_DIRTY

#define CHN_F_DIRTY   0x00000200 /* need re-config */

Definition at line 365 of file channel.h.

◆ CHN_F_EXCLUSIVE

#define CHN_F_EXCLUSIVE   0x80000000 /* exclusive access */

Definition at line 379 of file channel.h.

◆ CHN_F_HAS_SIZE

#define CHN_F_HAS_SIZE   0x00001000 /* user set block size */

Definition at line 369 of file channel.h.

◆ CHN_F_HAS_VCHAN

#define CHN_F_HAS_VCHAN   0x00002000 /* vchan master */

Definition at line 370 of file channel.h.

◆ CHN_F_MMAP

#define CHN_F_MMAP   0x00000080 /* has been mmap()ed */

Definition at line 362 of file channel.h.

◆ CHN_F_MMAP_INVALID

#define CHN_F_MMAP_INVALID   (CHN_F_DEAD | CHN_F_RUNNING)

Definition at line 408 of file channel.h.

◆ CHN_F_NBIO

#define CHN_F_NBIO   0x00000040 /* do non-blocking i/o */

Definition at line 361 of file channel.h.

◆ CHN_F_NOTRIGGER

#define CHN_F_NOTRIGGER   0x00000010

Definition at line 358 of file channel.h.

◆ CHN_F_PASSTHROUGH

#define CHN_F_PASSTHROUGH   0x40000000 /* passthrough re-config */

Definition at line 378 of file channel.h.

◆ CHN_F_RESET

#define CHN_F_RESET
Value:
CHN_F_VIRTUAL | CHN_F_HAS_VCHAN | \
CHN_F_VCHAN_DYNAMIC | \
CHN_F_PASSTHROUGH | CHN_F_EXCLUSIVE)
#define CHN_F_HAS_VCHAN
Definition: channel.h:370
#define CHN_F_DEAD
Definition: channel.h:366
#define CHN_F_BUSY
Definition: channel.h:364
#define CHN_F_EXCLUSIVE
Definition: channel.h:379

Definition at line 403 of file channel.h.

◆ CHN_F_RUNNING

#define CHN_F_RUNNING   0x00000004 /* dma is running */

Definition at line 356 of file channel.h.

◆ CHN_F_SILENCE

#define CHN_F_SILENCE   0x00000800 /* silence, nil, null, yada */

Definition at line 367 of file channel.h.

◆ CHN_F_SLEEPING

#define CHN_F_SLEEPING   0x00000020

Definition at line 359 of file channel.h.

◆ CHN_F_TRIGGERED

#define CHN_F_TRIGGERED   0x00000008

Definition at line 357 of file channel.h.

◆ CHN_F_VCHAN_ADAPTIVE

#define CHN_F_VCHAN_ADAPTIVE   0x00008000 /* adaptive format/rate selection */

Definition at line 373 of file channel.h.

◆ CHN_F_VCHAN_DYNAMIC

#define CHN_F_VCHAN_DYNAMIC   (CHN_F_VCHAN_PASSTHROUGH | CHN_F_VCHAN_ADAPTIVE)

Definition at line 374 of file channel.h.

◆ CHN_F_VCHAN_PASSTHROUGH

#define CHN_F_VCHAN_PASSTHROUGH   0x00004000 /* digital ac3/dts passthrough */

Definition at line 372 of file channel.h.

◆ CHN_F_VIRTUAL

#define CHN_F_VIRTUAL   0x10000000 /* not backed by hardware */

Definition at line 376 of file channel.h.

◆ CHN_FIRST

#define CHN_FIRST (   x,
 
)    SLIST_FIRST(CHN_HEAD(x, y))

Definition at line 179 of file channel.h.

◆ CHN_FOREACH

#define CHN_FOREACH (   x,
  y,
 
)     SLIST_FOREACH(x, CHN_HEAD(y, z), CHN_LINK(z))

Definition at line 181 of file channel.h.

◆ CHN_FOREACH_SAFE

#define CHN_FOREACH_SAFE (   w,
  x,
  y,
 
)     SLIST_FOREACH_SAFE(w, CHN_HEAD(x, z), CHN_LINK(z), y)

Definition at line 184 of file channel.h.

◆ CHN_GETMUTE

#define CHN_GETMUTE (   x,
  y,
 
)    ((x)->muted[y][z])

Definition at line 314 of file channel.h.

◆ CHN_GETVOLUME

#define CHN_GETVOLUME (   x,
  y,
 
)    ((x)->volume[y][z])

Definition at line 311 of file channel.h.

◆ CHN_HEAD

#define CHN_HEAD (   x,
 
)    &(x)->y.head

Definition at line 175 of file channel.h.

◆ CHN_INIT

#define CHN_INIT (   x,
 
)    SLIST_INIT(CHN_HEAD(x, y))

Definition at line 176 of file channel.h.

◆ CHN_INSERT_AFTER

#define CHN_INSERT_AFTER (   x,
  y,
 
)     SLIST_INSERT_AFTER(x, y, CHN_LINK(z))

Definition at line 190 of file channel.h.

◆ CHN_INSERT_AFTER_SAFE

#define CHN_INSERT_AFTER_SAFE (   w,
  x,
  y,
 
)
Value:
do { \
struct pcm_channel *t = NULL; \
CHN_FOREACH(t, w, z) { \
if (t == y) \
break; \
} \
if (t != y) \
CHN_INSERT_AFTER(x, y, z); \
} while (0)

Definition at line 206 of file channel.h.

◆ CHN_INSERT_HEAD

#define CHN_INSERT_HEAD (   x,
  y,
 
)     SLIST_INSERT_HEAD(CHN_HEAD(x, z), y, CHN_LINK(z))

Definition at line 187 of file channel.h.

◆ CHN_INSERT_HEAD_SAFE

#define CHN_INSERT_HEAD_SAFE (   x,
  y,
 
)
Value:
do { \
struct pcm_channel *t = NULL; \
CHN_FOREACH(t, x, z) { \
if (t == y) \
break; \
} \
if (t != y) \
CHN_INSERT_HEAD(x, y, z); \
} while (0)

Definition at line 196 of file channel.h.

◆ CHN_INSERT_SORT

#define CHN_INSERT_SORT (   w,
  x,
  y,
 
)
Value:
do { \
struct pcm_channel *t, *a = NULL; \
CHN_FOREACH(t, x, z) { \
if ((y)->unit w t->unit) \
a = t; \
else \
break; \
} \
if (a != NULL) \
CHN_INSERT_AFTER(a, y, z); \
CHN_INSERT_HEAD(x, y, z); \
} while (0)
#define CHN_INSERT_HEAD(x, y, z)
Definition: channel.h:187

Definition at line 226 of file channel.h.

◆ CHN_INSERT_SORT_ASCEND

#define CHN_INSERT_SORT_ASCEND (   x,
  y,
 
)    CHN_INSERT_SORT(>, x, y, z)

Definition at line 240 of file channel.h.

◆ CHN_INSERT_SORT_DESCEND

#define CHN_INSERT_SORT_DESCEND (   x,
  y,
 
)    CHN_INSERT_SORT(<, x, y, z)

Definition at line 241 of file channel.h.

◆ CHN_LATENCY_DEFAULT

#define CHN_LATENCY_DEFAULT   2 /* 21.3ms total buffering */

Definition at line 420 of file channel.h.

◆ CHN_LATENCY_MAX

#define CHN_LATENCY_MAX   10

Definition at line 419 of file channel.h.

◆ CHN_LATENCY_MIN

#define CHN_LATENCY_MIN   0

Definition at line 418 of file channel.h.

◆ CHN_LATENCY_PROFILE_DEFAULT

#define CHN_LATENCY_PROFILE_DEFAULT   CHN_LATENCY_PROFILE_MAX

Definition at line 427 of file channel.h.

◆ CHN_LATENCY_PROFILE_MAX

#define CHN_LATENCY_PROFILE_MAX   1

Definition at line 426 of file channel.h.

◆ CHN_LATENCY_PROFILE_MIN

#define CHN_LATENCY_PROFILE_MIN   0

Definition at line 425 of file channel.h.

◆ CHN_LINK

#define CHN_LINK (   y)    y.link

Definition at line 177 of file channel.h.

◆ CHN_LOCK

#define CHN_LOCK (   c)    mtx_lock((c)->lock)

Definition at line 321 of file channel.h.

◆ CHN_LOCKASSERT

#define CHN_LOCKASSERT (   c)    mtx_assert((c)->lock, MA_OWNED)

Definition at line 324 of file channel.h.

◆ CHN_LOCKOWNED

#define CHN_LOCKOWNED (   c)    mtx_owned((c)->lock)

Definition at line 320 of file channel.h.

◆ CHN_N_BLOCKSIZE

#define CHN_N_BLOCKSIZE   0x00000008

Definition at line 415 of file channel.h.

◆ CHN_N_FORMAT

#define CHN_N_FORMAT   0x00000002

Definition at line 413 of file channel.h.

◆ CHN_N_RATE

#define CHN_N_RATE   0x00000001

Definition at line 412 of file channel.h.

◆ CHN_N_TRIGGER

#define CHN_N_TRIGGER   0x00000010

Definition at line 416 of file channel.h.

◆ CHN_N_VOLUME

#define CHN_N_VOLUME   0x00000004

Definition at line 414 of file channel.h.

◆ CHN_NAMELEN

#define CHN_NAMELEN   32

Definition at line 81 of file channel.h.

◆ CHN_PASSTHROUGH

#define CHN_PASSTHROUGH (   c)    ((c)->flags & CHN_F_PASSTHROUGH)

Definition at line 434 of file channel.h.

◆ CHN_POLICY_DEFAULT

#define CHN_POLICY_DEFAULT   CHN_LATENCY_DEFAULT

Definition at line 423 of file channel.h.

◆ CHN_POLICY_MAX

#define CHN_POLICY_MAX   CHN_LATENCY_MAX

Definition at line 422 of file channel.h.

◆ CHN_POLICY_MIN

#define CHN_POLICY_MIN   CHN_LATENCY_MIN

Definition at line 421 of file channel.h.

◆ CHN_REMOVE

#define CHN_REMOVE (   x,
  y,
 
)     SLIST_REMOVE(CHN_HEAD(x, z), y, pcm_channel, CHN_LINK(z))

Definition at line 193 of file channel.h.

◆ CHN_REMOVE_SAFE

#define CHN_REMOVE_SAFE (   x,
  y,
 
)
Value:
do { \
struct pcm_channel *t = NULL; \
CHN_FOREACH(t, x, z) { \
if (t == y) \
break; \
} \
if (t == y) \
CHN_REMOVE(x, y, z); \
} while (0)

Definition at line 216 of file channel.h.

◆ CHN_SETVOLUME

#define CHN_SETVOLUME (   ...)    chn_setvolume_matrix(__VA_ARGS__)

Definition at line 307 of file channel.h.

◆ CHN_STARTED

#define CHN_STARTED (   c)    ((c)->flags & CHN_F_TRIGGERED)

Definition at line 429 of file channel.h.

◆ CHN_STOPPED

#define CHN_STOPPED (   c)    (!CHN_STARTED(c))

Definition at line 430 of file channel.h.

◆ CHN_TIMEOUT

#define CHN_TIMEOUT   5

Definition at line 436 of file channel.h.

◆ CHN_TIMEOUT_MAX

#define CHN_TIMEOUT_MAX   10

Definition at line 438 of file channel.h.

◆ CHN_TIMEOUT_MIN

#define CHN_TIMEOUT_MIN   1

Definition at line 437 of file channel.h.

◆ CHN_TRYLOCK

#define CHN_TRYLOCK (   c)    mtx_trylock((c)->lock)

Definition at line 323 of file channel.h.

◆ CHN_UNIT

#define CHN_UNIT (   x)    (snd_unit2u((x)->unit))

Definition at line 243 of file channel.h.

◆ CHN_UNLOCK

#define CHN_UNLOCK (   c)    mtx_unlock((c)->lock)

Definition at line 322 of file channel.h.

◆ CHN_UNLOCKASSERT

#define CHN_UNLOCKASSERT (   c)    mtx_assert((c)->lock, MA_NOTOWNED)

Definition at line 325 of file channel.h.

◆ PCM_SG_LOCK

#define PCM_SG_LOCK ( )    mtx_lock(&snd_pcm_syncgroups_mtx)

Definition at line 58 of file channel.h.

◆ PCM_SG_LOCKASSERT

#define PCM_SG_LOCKASSERT (   arg)    mtx_assert(&snd_pcm_syncgroups_mtx, arg)

Definition at line 61 of file channel.h.

◆ PCM_SG_TRYLOCK

#define PCM_SG_TRYLOCK ( )    mtx_trylock(&snd_pcm_syncgroups_mtx)

Definition at line 59 of file channel.h.

◆ PCM_SG_UNLOCK

#define PCM_SG_UNLOCK ( )    mtx_unlock(&snd_pcm_syncgroups_mtx)

Definition at line 60 of file channel.h.

◆ PCMDIR_PLAY

#define PCMDIR_PLAY   1

Definition at line 339 of file channel.h.

◆ PCMDIR_PLAY_VIRTUAL

#define PCMDIR_PLAY_VIRTUAL   2

Definition at line 340 of file channel.h.

◆ PCMDIR_REC

#define PCMDIR_REC   -1

Definition at line 341 of file channel.h.

◆ PCMDIR_REC_VIRTUAL

#define PCMDIR_REC_VIRTUAL   -2

Definition at line 342 of file channel.h.

◆ PCMTRIG_ABORT

#define PCMTRIG_ABORT   -1

Definition at line 348 of file channel.h.

◆ PCMTRIG_COMMON

#define PCMTRIG_COMMON (   x)
Value:
((x) == PCMTRIG_START || \
(x) == PCMTRIG_STOP || \
(x) == PCMTRIG_ABORT)
#define PCMTRIG_START
Definition: channel.h:344
#define PCMTRIG_STOP
Definition: channel.h:347
#define PCMTRIG_ABORT
Definition: channel.h:348

Definition at line 350 of file channel.h.

◆ PCMTRIG_EMLDMARD

#define PCMTRIG_EMLDMARD   3

Definition at line 346 of file channel.h.

◆ PCMTRIG_EMLDMAWR

#define PCMTRIG_EMLDMAWR   2

Definition at line 345 of file channel.h.

◆ PCMTRIG_START

#define PCMTRIG_START   1

Definition at line 344 of file channel.h.

◆ PCMTRIG_STOP

#define PCMTRIG_STOP   0

Definition at line 347 of file channel.h.

Function Documentation

◆ chn_abort()

int chn_abort ( struct pcm_channel c)

◆ 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_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_read()

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

◆ chn_reinit()

int chn_reinit ( struct pcm_channel c)

◆ chn_reset()

int chn_reset ( struct pcm_channel c,
u_int32_t  fmt,
u_int32_t  spd 
)

◆ 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_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_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_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_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:

◆ SLIST_HEAD()

SLIST_HEAD ( pcm_synclist  ,
pcmchan_syncgroup   
)

◆ 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_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:

Variable Documentation

◆ chn_latency

int chn_latency
extern

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
extern

Definition at line 76 of file channel.c.

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

◆ report_soft_formats

int report_soft_formats
extern

Definition at line 45 of file channel.c.

Referenced by chn_getformats().

◆ report_soft_matrix

int report_soft_matrix
extern

Definition at line 49 of file channel.c.

Referenced by chn_oss_getmask().

◆ snd_pcm_syncgroups_mtx

struct mtx snd_pcm_syncgroups_mtx
extern

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().