FreeBSD kernel sound device code
sound.h File Reference
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/eventhandler.h>
#include <sys/ioccom.h>
#include <sys/filio.h>
#include <sys/sockio.h>
#include <sys/fcntl.h>
#include <sys/selinfo.h>
#include <sys/proc.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/conf.h>
#include <sys/file.h>
#include <sys/uio.h>
#include <sys/syslog.h>
#include <sys/errno.h>
#include <sys/malloc.h>
#include <sys/bus.h>
#include <machine/resource.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <sys/limits.h>
#include <sys/mman.h>
#include <sys/poll.h>
#include <sys/sbuf.h>
#include <sys/soundcard.h>
#include <sys/sndstat.h>
#include <sys/sysctl.h>
#include <sys/kobj.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <dev/sound/pcm/buffer.h>
#include <dev/sound/pcm/matrix.h>
#include <dev/sound/pcm/matrix_map.h>
#include <dev/sound/pcm/channel.h>
#include <dev/sound/pcm/feeder.h>
#include <dev/sound/pcm/mixer.h>
#include <dev/sound/pcm/dsp.h>
#include <dev/sound/clone.h>
#include <dev/sound/unit.h>
Include dependency graph for sound.h:

Go to the source code of this file.

Data Structures

struct  snddev_info
 

Macros

#define KOBJMETHOD_END   { NULL, NULL }
 
#define PCM_SOFTC_SIZE   (sizeof(struct snddev_info))
 
#define SND_STATUSLEN   64
 
#define SOUND_MODVER   5
 
#define SOUND_MINVER   SOUND_MODVER
 
#define SOUND_PREFVER   SOUND_MODVER
 
#define SOUND_MAXVER   SOUND_MODVER
 
#define PCMMAXUNIT   (snd_max_u())
 
#define PCMMAXDEV   (snd_max_d())
 
#define PCMMAXCHAN   (snd_max_c())
 
#define PCMMAXCLONE   PCMMAXCHAN
 
#define PCMUNIT(x)   (snd_unit2u(dev2unit(x)))
 
#define PCMDEV(x)   (snd_unit2d(dev2unit(x)))
 
#define PCMCHAN(x)   (snd_unit2c(dev2unit(x)))
 
#define PCMMINOR(x)   (x)
 
#define SND_MAXHWCHAN   256
 
#define SND_MAXVCHANS   SND_MAXHWCHAN
 
#define SD_F_SIMPLEX   0x00000001
 
#define SD_F_AUTOVCHAN   0x00000002
 
#define SD_F_SOFTPCMVOL   0x00000004
 
#define SD_F_DYING   0x00000008
 
#define SD_F_DETACHING   0x00000010
 
#define SD_F_BUSY   0x00000020
 
#define SD_F_MPSAFE   0x00000040
 
#define SD_F_REGISTERED   0x00000080
 
#define SD_F_BITPERFECT   0x00000100
 
#define SD_F_VPC   0x00000200 /* volume-per-channel */
 
#define SD_F_EQ   0x00000400 /* EQ */
 
#define SD_F_EQ_ENABLED   0x00000800 /* EQ enabled */
 
#define SD_F_EQ_BYPASSED   0x00001000 /* EQ bypassed */
 
#define SD_F_EQ_PC   0x00002000 /* EQ per-channel */
 
#define SD_F_EQ_DEFAULT   (SD_F_EQ | SD_F_EQ_ENABLED)
 
#define SD_F_EQ_MASK
 
#define SD_F_PRIO_RD   0x10000000
 
#define SD_F_PRIO_WR   0x20000000
 
#define SD_F_PRIO_SET   (SD_F_PRIO_RD | SD_F_PRIO_WR)
 
#define SD_F_DIR_SET   0x40000000
 
#define SD_F_TRANSIENT   0xf0000000
 
#define SD_F_BITS
 
#define PCM_ALIVE(x)
 
#define PCM_REGISTERED(x)
 
#define PCM_DETACHING(x)   ((x)->flags & SD_F_DETACHING)
 
#define RANGE(var, low, high)
 
#define DSP_BUFFSIZE   (8192)
 
#define AFMT_32BIT   (AFMT_S32_LE | AFMT_S32_BE | AFMT_U32_LE | AFMT_U32_BE)
 
#define AFMT_24BIT   (AFMT_S24_LE | AFMT_S24_BE | AFMT_U24_LE | AFMT_U24_BE)
 
#define AFMT_16BIT   (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE)
 
#define AFMT_G711   (AFMT_MU_LAW | AFMT_A_LAW)
 
#define AFMT_8BIT   (AFMT_G711 | AFMT_U8 | AFMT_S8)
 
#define AFMT_SIGNED
 
#define AFMT_BIGENDIAN
 
#define AFMT_CONVERTIBLE
 
#define AFMT_VCHAN   (AFMT_CONVERTIBLE & ~AFMT_G711)
 
#define AFMT_PASSTHROUGH   AFMT_AC3
 
#define AFMT_PASSTHROUGH_RATE   48000
 
#define AFMT_PASSTHROUGH_CHANNEL   2
 
#define AFMT_PASSTHROUGH_EXTCHANNEL   0
 
#define AFMT_ENCODING_MASK   0xf00fffff
 
#define AFMT_CHANNEL_MASK   0x07f00000
 
#define AFMT_CHANNEL_SHIFT   20
 
#define AFMT_CHANNEL_MAX   0x7f
 
#define AFMT_EXTCHANNEL_MASK   0x08000000
 
#define AFMT_EXTCHANNEL_SHIFT   27
 
#define AFMT_EXTCHANNEL_MAX   1
 
#define AFMT_ENCODING(v)   ((v) & AFMT_ENCODING_MASK)
 
#define AFMT_EXTCHANNEL(v)
 
#define AFMT_CHANNEL(v)
 
#define AFMT_BIT(v)
 
#define AFMT_BPS(v)   (AFMT_BIT(v) >> 3)
 
#define AFMT_ALIGN(v)   (AFMT_BPS(v) * AFMT_CHANNEL(v))
 
#define SND_FORMAT(f, c, e)
 
#define AFMT_U8_NE   AFMT_U8
 
#define AFMT_S8_NE   AFMT_S8
 
#define AFMT_SIGNED_NE   (AFMT_S8_NE | AFMT_S16_NE | AFMT_S24_NE | AFMT_S32_NE)
 
#define AFMT_NE
 
#define SND_DEV_CTL   0 /* Control port /dev/mixer */
 
#define SND_DEV_SEQ   1 /* Sequencer /dev/sequencer */
 
#define SND_DEV_MIDIN   2 /* Raw midi access */
 
#define SND_DEV_DSP   3 /* Digitized voice /dev/dsp */
 
#define SND_DEV_AUDIO   4 /* Sparc compatible /dev/audio */
 
#define SND_DEV_DSP16   5 /* Like /dev/dsp but 16 bits/sample */
 
#define SND_DEV_STATUS   6 /* /dev/sndstat */
 
#define SND_DEV_SEQ2   8 /* /dev/sequencer, level 2 interface */
 
#define SND_DEV_SNDPROC   9 /* /dev/sndproc for programmable devices */
 
#define SND_DEV_PSS   SND_DEV_SNDPROC /* ? */
 
#define SND_DEV_NORESET   10
 
#define SND_DEV_DSPHW_PLAY   11 /* specific playback channel */
 
#define SND_DEV_DSPHW_VPLAY   12 /* specific virtual playback channel */
 
#define SND_DEV_DSPHW_REC   13 /* specific record channel */
 
#define SND_DEV_DSPHW_VREC   14 /* specific virtual record channel */
 
#define SND_DEV_DSPHW_CD   15 /* s16le/stereo 44100Hz CD */
 
#define SND_DEV_DSP_MMAP   16 /* /dev/dsp_mmap */
 
#define SND_DEV_DSP_AC3   17 /* /dev/dsp_ac3 */
 
#define SND_DEV_DSP_MULTICH   18 /* /dev/dsp_multich */
 
#define SND_DEV_DSP_SPDIFOUT   19 /* /dev/dsp_spdifout */
 
#define SND_DEV_DSP_SPDIFIN   20 /* /dev/dsp_spdifin */
 
#define SND_DEV_LAST   SND_DEV_DSP_SPDIFIN
 
#define SND_DEV_MAX   PCMMAXDEV
 
#define DSP_DEFAULT_SPEED   8000
 
#define ON   1
 
#define OFF   0
 
#define BVDDB(x)   if (bootverbose) x
 
#define DEB(x)
 
#define snd_mtxlock(m)   mtx_lock(m)
 
#define snd_mtxunlock(m)   mtx_unlock(m)
 
#define SND_DECLARE_FILE(version)    _SND_DECLARE_FILE(__LINE__, version)
 
#define _SND_DECLARE_FILE(uniq, version)    __SND_DECLARE_FILE(uniq, version)
 
#define __SND_DECLARE_FILE(uniq, version)
 
#define DV_F_DRQ_MASK   0x00000007 /* mask for secondary drq */
 
#define DV_F_DUAL_DMA   0x00000010 /* set to use secondary dma channel */
 
#define DV_F_DEV_MASK   0x0000ff00 /* force device type/class */
 
#define DV_F_DEV_SHIFT   8 /* force device type/class */
 
#define PCM_MODE_MIXER   0x01
 
#define PCM_MODE_PLAY   0x02
 
#define PCM_MODE_REC   0x04
 
#define PCM_LOCKOWNED(d)   mtx_owned((d)->lock)
 
#define PCM_LOCK(d)   mtx_lock((d)->lock)
 
#define PCM_UNLOCK(d)   mtx_unlock((d)->lock)
 
#define PCM_TRYLOCK(d)   mtx_trylock((d)->lock)
 
#define PCM_LOCKASSERT(d)   mtx_assert((d)->lock, MA_OWNED)
 
#define PCM_UNLOCKASSERT(d)   mtx_assert((d)->lock, MA_NOTOWNED)
 
#define PCM_WAIT(x)
 
#define PCM_ACQUIRE(x)
 
#define PCM_RELEASE(x)
 
#define PCM_ACQUIRE_QUICK(x)
 
#define PCM_RELEASE_QUICK(x)
 
#define PCM_BUSYASSERT(x)
 
#define PCM_GIANT_ENTER(x)
 
#define PCM_GIANT_EXIT(x)
 
#define PCM_GIANT_LEAVE(x)
 
#define PCM_KLDSTRING(a)   ""
 

Typedefs

typedef int(* sndstat_handler) (struct sbuf *s, device_t dev, int verbose)
 

Functions

 SYSCTL_DECL (_hw_snd)
 
int pcm_setvchans (struct snddev_info *d, int direction, int newcnt, int num)
 
int pcm_chnalloc (struct snddev_info *d, struct pcm_channel **ch, int direction, pid_t pid, char *comm, int devunit)
 
int pcm_chnrelease (struct pcm_channel *c)
 
int pcm_chnref (struct pcm_channel *c, int ref)
 
int pcm_inprog (struct snddev_info *d, int delta)
 
struct pcm_channelpcm_chn_create (struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, int num, void *devinfo)
 
int pcm_chn_destroy (struct pcm_channel *ch)
 
int pcm_chn_add (struct snddev_info *d, struct pcm_channel *ch)
 
int pcm_chn_remove (struct snddev_info *d, struct pcm_channel *ch)
 
int pcm_addchan (device_t dev, int dir, kobj_class_t cls, void *devinfo)
 
unsigned int pcm_getbuffersize (device_t dev, unsigned int minbufsz, unsigned int deflt, unsigned int maxbufsz)
 
int pcm_register (device_t dev, void *devinfo, int numplay, int numrec)
 
int pcm_unregister (device_t dev)
 
int pcm_setstatus (device_t dev, char *str)
 
u_int32_t pcm_getflags (device_t dev)
 
void pcm_setflags (device_t dev, u_int32_t val)
 
void * pcm_getdevinfo (device_t dev)
 
int snd_setup_intr (device_t dev, struct resource *res, int flags, driver_intr_t hand, void *param, void **cookiep)
 
void * snd_mtxcreate (const char *desc, const char *type)
 
void snd_mtxfree (void *m)
 
void snd_mtxassert (void *m)
 
int sndstat_register (device_t dev, char *str, sndstat_handler handler)
 
int sndstat_registerfile (char *str)
 
int sndstat_unregister (device_t dev)
 
int sndstat_unregisterfile (char *str)
 
void sound_oss_sysinfo (oss_sysinfo *)
 Handle OSSv4 SNDCTL_SYSINFO ioctl. More...
 
int sound_oss_card_info (oss_card_info *)
 

Variables

int pcm_veto_load
 
int snd_unit
 
int snd_maxautovchans
 
int snd_verbose
 
devclass_t pcm_devclass
 
struct unrhdr * pcmsg_unrhdr
 Unit number allocator for syncgroup IDs. More...
 

Macro Definition Documentation

◆ __SND_DECLARE_FILE

#define __SND_DECLARE_FILE (   uniq,
  version 
)
Value:
static char sndstat_vinfo[] = version; \
SYSINIT(sdf_ ## uniq, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, sndstat_registerfile, sndstat_vinfo); \
SYSUNINIT(sdf_ ## uniq, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, sndstat_unregisterfile, sndstat_vinfo);
int sndstat_unregisterfile(char *str)
Definition: sndstat.c:1138
int sndstat_registerfile(char *str)
Definition: sndstat.c:1112

Definition at line 362 of file sound.h.

◆ _SND_DECLARE_FILE

#define _SND_DECLARE_FILE (   uniq,
  version 
)     __SND_DECLARE_FILE(uniq, version)

Definition at line 359 of file sound.h.

◆ AFMT_16BIT

#define AFMT_16BIT   (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE)

Definition at line 191 of file sound.h.

◆ AFMT_24BIT

#define AFMT_24BIT   (AFMT_S24_LE | AFMT_S24_BE | AFMT_U24_LE | AFMT_U24_BE)

Definition at line 190 of file sound.h.

◆ AFMT_32BIT

#define AFMT_32BIT   (AFMT_S32_LE | AFMT_S32_BE | AFMT_U32_LE | AFMT_U32_BE)

Definition at line 189 of file sound.h.

◆ AFMT_8BIT

#define AFMT_8BIT   (AFMT_G711 | AFMT_U8 | AFMT_S8)

Definition at line 193 of file sound.h.

◆ AFMT_ALIGN

#define AFMT_ALIGN (   v)    (AFMT_BPS(v) * AFMT_CHANNEL(v))

Definition at line 236 of file sound.h.

◆ AFMT_BIGENDIAN

#define AFMT_BIGENDIAN
Value:
(AFMT_S32_BE | AFMT_U32_BE | AFMT_S24_BE | AFMT_U24_BE | \
AFMT_S16_BE | AFMT_U16_BE)

Definition at line 196 of file sound.h.

◆ AFMT_BIT

#define AFMT_BIT (   v)
Value:
(((v) & AFMT_32BIT) ? 32 : \
(((v) & AFMT_24BIT) ? 24 : \
((((v) & AFMT_16BIT) || \
((v) & AFMT_PASSTHROUGH)) ? 16 : 8)))
#define AFMT_24BIT
Definition: sound.h:190
#define AFMT_PASSTHROUGH
Definition: sound.h:205
#define AFMT_32BIT
Definition: sound.h:189
#define AFMT_16BIT
Definition: sound.h:191

Definition at line 230 of file sound.h.

◆ AFMT_BPS

#define AFMT_BPS (   v)    (AFMT_BIT(v) >> 3)

Definition at line 235 of file sound.h.

◆ AFMT_CHANNEL

#define AFMT_CHANNEL (   v)
Value:
(((v) & AFMT_CHANNEL_MASK) >> \
AFMT_CHANNEL_SHIFT)
#define AFMT_CHANNEL_MASK
Definition: sound.h:215

Definition at line 227 of file sound.h.

◆ AFMT_CHANNEL_MASK

#define AFMT_CHANNEL_MASK   0x07f00000

Definition at line 215 of file sound.h.

◆ AFMT_CHANNEL_MAX

#define AFMT_CHANNEL_MAX   0x7f

Definition at line 217 of file sound.h.

◆ AFMT_CHANNEL_SHIFT

#define AFMT_CHANNEL_SHIFT   20

Definition at line 216 of file sound.h.

◆ AFMT_CONVERTIBLE

#define AFMT_CONVERTIBLE
Value:
AFMT_32BIT)
#define AFMT_8BIT
Definition: sound.h:193

Definition at line 199 of file sound.h.

◆ AFMT_ENCODING

#define AFMT_ENCODING (   v)    ((v) & AFMT_ENCODING_MASK)

Definition at line 222 of file sound.h.

◆ AFMT_ENCODING_MASK

#define AFMT_ENCODING_MASK   0xf00fffff

Definition at line 214 of file sound.h.

◆ AFMT_EXTCHANNEL

#define AFMT_EXTCHANNEL (   v)
Value:
(((v) & AFMT_EXTCHANNEL_MASK) >> \
AFMT_EXTCHANNEL_SHIFT)
#define AFMT_EXTCHANNEL_MASK
Definition: sound.h:218

Definition at line 224 of file sound.h.

◆ AFMT_EXTCHANNEL_MASK

#define AFMT_EXTCHANNEL_MASK   0x08000000

Definition at line 218 of file sound.h.

◆ AFMT_EXTCHANNEL_MAX

#define AFMT_EXTCHANNEL_MAX   1

Definition at line 220 of file sound.h.

◆ AFMT_EXTCHANNEL_SHIFT

#define AFMT_EXTCHANNEL_SHIFT   27

Definition at line 219 of file sound.h.

◆ AFMT_G711

#define AFMT_G711   (AFMT_MU_LAW | AFMT_A_LAW)

Definition at line 192 of file sound.h.

◆ AFMT_NE

#define AFMT_NE
Value:
(AFMT_SIGNED_NE | AFMT_U8_NE | AFMT_U16_NE | \
AFMT_U24_NE | AFMT_U32_NE)
#define AFMT_U8_NE
Definition: sound.h:244
#define AFMT_SIGNED_NE
Definition: sound.h:247

Definition at line 249 of file sound.h.

◆ AFMT_PASSTHROUGH

#define AFMT_PASSTHROUGH   AFMT_AC3

Definition at line 205 of file sound.h.

◆ AFMT_PASSTHROUGH_CHANNEL

#define AFMT_PASSTHROUGH_CHANNEL   2

Definition at line 207 of file sound.h.

◆ AFMT_PASSTHROUGH_EXTCHANNEL

#define AFMT_PASSTHROUGH_EXTCHANNEL   0

Definition at line 208 of file sound.h.

◆ AFMT_PASSTHROUGH_RATE

#define AFMT_PASSTHROUGH_RATE   48000

Definition at line 206 of file sound.h.

◆ AFMT_S8_NE

#define AFMT_S8_NE   AFMT_S8

Definition at line 245 of file sound.h.

◆ AFMT_SIGNED

#define AFMT_SIGNED
Value:
(AFMT_S32_LE | AFMT_S32_BE | AFMT_S24_LE | AFMT_S24_BE | \
AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)

Definition at line 194 of file sound.h.

◆ AFMT_SIGNED_NE

#define AFMT_SIGNED_NE   (AFMT_S8_NE | AFMT_S16_NE | AFMT_S24_NE | AFMT_S32_NE)

Definition at line 247 of file sound.h.

◆ AFMT_U8_NE

#define AFMT_U8_NE   AFMT_U8

Definition at line 244 of file sound.h.

◆ AFMT_VCHAN

#define AFMT_VCHAN   (AFMT_CONVERTIBLE & ~AFMT_G711)

Definition at line 203 of file sound.h.

◆ BVDDB

#define BVDDB (   x)    if (bootverbose) x

Definition at line 312 of file sound.h.

◆ DEB

#define DEB (   x)

Definition at line 315 of file sound.h.

◆ DSP_BUFFSIZE

#define DSP_BUFFSIZE   (8192)

Definition at line 186 of file sound.h.

◆ DSP_DEFAULT_SPEED

#define DSP_DEFAULT_SPEED   8000

Definition at line 295 of file sound.h.

◆ DV_F_DEV_MASK

#define DV_F_DEV_MASK   0x0000ff00 /* force device type/class */

Definition at line 372 of file sound.h.

◆ DV_F_DEV_SHIFT

#define DV_F_DEV_SHIFT   8 /* force device type/class */

Definition at line 373 of file sound.h.

◆ DV_F_DRQ_MASK

#define DV_F_DRQ_MASK   0x00000007 /* mask for secondary drq */

Definition at line 368 of file sound.h.

◆ DV_F_DUAL_DMA

#define DV_F_DUAL_DMA   0x00000010 /* set to use secondary dma channel */

Definition at line 369 of file sound.h.

◆ KOBJMETHOD_END

#define KOBJMETHOD_END   { NULL, NULL }

Definition at line 78 of file sound.h.

◆ OFF

#define OFF   0

Definition at line 298 of file sound.h.

◆ ON

#define ON   1

Definition at line 297 of file sound.h.

◆ PCM_ACQUIRE

#define PCM_ACQUIRE (   x)
Value:
do { \
PCM_LOCKASSERT(x); \
KASSERT(!((x)->flags & SD_F_BUSY), \
("%s(%d): [PCM ACQUIRE] Trying to acquire BUSY cv!", \
__func__, __LINE__)); \
(x)->flags |= SD_F_BUSY; \
} while (0)
#define SD_F_BUSY
Definition: sound.h:137

Definition at line 546 of file sound.h.

◆ PCM_ACQUIRE_QUICK

#define PCM_ACQUIRE_QUICK (   x)
Value:
do { \
PCM_UNLOCKASSERT(x); \
PCM_LOCK(x); \
PCM_WAIT(x); \
PCM_ACQUIRE(x); \
PCM_UNLOCK(x); \
} while (0)

Definition at line 565 of file sound.h.

◆ PCM_ALIVE

#define PCM_ALIVE (   x)
Value:
((x) != NULL && (x)->lock != NULL && \
!((x)->flags & SD_F_DYING))
#define SD_F_DYING
Definition: sound.h:135

Definition at line 176 of file sound.h.

◆ PCM_BUSYASSERT

#define PCM_BUSYASSERT (   x)
Value:
KASSERT(x != NULL && \
((x)->flags & SD_F_BUSY), \
("%s(%d): [PCM BUSYASSERT] " \
"Failed, snddev_info=%p", \
__func__, __LINE__, x))

Definition at line 580 of file sound.h.

◆ PCM_DETACHING

#define PCM_DETACHING (   x)    ((x)->flags & SD_F_DETACHING)

Definition at line 181 of file sound.h.

◆ PCM_GIANT_ENTER

#define PCM_GIANT_ENTER (   x)
Value:
do { \
int _pcm_giant = 0; \
PCM_UNLOCKASSERT(x); \
if (!((x)->flags & SD_F_MPSAFE) && mtx_owned(&Giant) == 0) \
do { \
mtx_lock(&Giant); \
_pcm_giant = 1; \
} while (0)
#define SD_F_MPSAFE
Definition: sound.h:138

Definition at line 586 of file sound.h.

◆ PCM_GIANT_EXIT

#define PCM_GIANT_EXIT (   x)
Value:
do { \
PCM_UNLOCKASSERT(x); \
KASSERT(_pcm_giant == 0 || _pcm_giant == 1, \
("%s(%d): [GIANT EXIT] _pcm_giant screwed!", \
__func__, __LINE__)); \
KASSERT(!((x)->flags & SD_F_MPSAFE) || \
(((x)->flags & SD_F_MPSAFE) && _pcm_giant == 0), \
("%s(%d): [GIANT EXIT] MPSAFE Giant?", \
__func__, __LINE__)); \
if (_pcm_giant != 0) { \
mtx_assert(&Giant, MA_OWNED); \
_pcm_giant = 0; \
mtx_unlock(&Giant); \
} \
} while (0)

Definition at line 595 of file sound.h.

◆ PCM_GIANT_LEAVE

#define PCM_GIANT_LEAVE (   x)
Value:
} while (0)
#define PCM_GIANT_EXIT(x)
Definition: sound.h:595

Definition at line 612 of file sound.h.

◆ PCM_KLDSTRING

#define PCM_KLDSTRING (   a)    ""

Definition at line 619 of file sound.h.

◆ PCM_LOCK

#define PCM_LOCK (   d)    mtx_lock((d)->lock)

Definition at line 420 of file sound.h.

◆ PCM_LOCKASSERT

#define PCM_LOCKASSERT (   d)    mtx_assert((d)->lock, MA_OWNED)

Definition at line 423 of file sound.h.

◆ PCM_LOCKOWNED

#define PCM_LOCKOWNED (   d)    mtx_owned((d)->lock)

Definition at line 419 of file sound.h.

◆ PCM_MODE_MIXER

#define PCM_MODE_MIXER   0x01

Definition at line 415 of file sound.h.

◆ PCM_MODE_PLAY

#define PCM_MODE_PLAY   0x02

Definition at line 416 of file sound.h.

◆ PCM_MODE_REC

#define PCM_MODE_REC   0x04

Definition at line 417 of file sound.h.

◆ PCM_REGISTERED

#define PCM_REGISTERED (   x)
Value:
(PCM_ALIVE(x) && \
((x)->flags & SD_F_REGISTERED))
#define SD_F_REGISTERED
Definition: sound.h:139
#define PCM_ALIVE(x)
Definition: sound.h:176

Definition at line 178 of file sound.h.

◆ PCM_RELEASE

#define PCM_RELEASE (   x)
Value:
do { \
PCM_LOCKASSERT(x); \
KASSERT((x)->flags & SD_F_BUSY, \
("%s(%d): [PCM RELEASE] Releasing non-BUSY cv!", \
__func__, __LINE__)); \
(x)->flags &= ~SD_F_BUSY; \
if ((x)->cv.cv_waiters != 0) \
cv_broadcast(&(x)->cv); \
} while (0)

Definition at line 554 of file sound.h.

◆ PCM_RELEASE_QUICK

#define PCM_RELEASE_QUICK (   x)
Value:
do { \
PCM_UNLOCKASSERT(x); \
PCM_LOCK(x); \
PCM_RELEASE(x); \
PCM_UNLOCK(x); \
} while (0)

Definition at line 573 of file sound.h.

◆ PCM_SOFTC_SIZE

#define PCM_SOFTC_SIZE   (sizeof(struct snddev_info))

Definition at line 96 of file sound.h.

◆ PCM_TRYLOCK

#define PCM_TRYLOCK (   d)    mtx_trylock((d)->lock)

Definition at line 422 of file sound.h.

◆ PCM_UNLOCK

#define PCM_UNLOCK (   d)    mtx_unlock((d)->lock)

Definition at line 421 of file sound.h.

◆ PCM_UNLOCKASSERT

#define PCM_UNLOCKASSERT (   d)    mtx_assert((d)->lock, MA_NOTOWNED)

Definition at line 424 of file sound.h.

◆ PCM_WAIT

#define PCM_WAIT (   x)
Value:
do { \
PCM_LOCKASSERT(x); \
while ((x)->flags & SD_F_BUSY) \
cv_wait(&(x)->cv, (x)->lock); \
} while (0)

Definition at line 540 of file sound.h.

◆ PCMCHAN

#define PCMCHAN (   x)    (snd_unit2c(dev2unit(x)))

Definition at line 121 of file sound.h.

◆ PCMDEV

#define PCMDEV (   x)    (snd_unit2d(dev2unit(x)))

Definition at line 120 of file sound.h.

◆ PCMMAXCHAN

#define PCMMAXCHAN   (snd_max_c())

Definition at line 115 of file sound.h.

◆ PCMMAXCLONE

#define PCMMAXCLONE   PCMMAXCHAN

Definition at line 117 of file sound.h.

◆ PCMMAXDEV

#define PCMMAXDEV   (snd_max_d())

Definition at line 114 of file sound.h.

◆ PCMMAXUNIT

#define PCMMAXUNIT   (snd_max_u())

Definition at line 113 of file sound.h.

◆ PCMMINOR

#define PCMMINOR (   x)    (x)

Definition at line 124 of file sound.h.

◆ PCMUNIT

#define PCMUNIT (   x)    (snd_unit2u(dev2unit(x)))

Definition at line 119 of file sound.h.

◆ RANGE

#define RANGE (   var,
  low,
  high 
)
Value:
(var) = \
(((var)<(low))? (low) : ((var)>(high))? (high) : (var))

Definition at line 184 of file sound.h.

◆ SD_F_AUTOVCHAN

#define SD_F_AUTOVCHAN   0x00000002

Definition at line 133 of file sound.h.

◆ SD_F_BITPERFECT

#define SD_F_BITPERFECT   0x00000100

Definition at line 140 of file sound.h.

◆ SD_F_BITS

#define SD_F_BITS
Value:
"\020" \
"\001SIMPLEX" \
"\002AUTOVCHAN" \
"\003SOFTPCMVOL" \
"\004DYING" \
"\005DETACHING" \
"\006BUSY" \
"\007MPSAFE" \
"\010REGISTERED" \
"\011BITPERFECT" \
"\012VPC" \
"\013EQ" \
"\014EQ_ENABLED" \
"\015EQ_BYPASSED" \
"\016EQ_PC" \
"\035PRIO_RD" \
"\036PRIO_WR" \
"\037DIR_SET"

Definition at line 157 of file sound.h.

◆ SD_F_BUSY

#define SD_F_BUSY   0x00000020

Definition at line 137 of file sound.h.

◆ SD_F_DETACHING

#define SD_F_DETACHING   0x00000010

Definition at line 136 of file sound.h.

◆ SD_F_DIR_SET

#define SD_F_DIR_SET   0x40000000

Definition at line 154 of file sound.h.

◆ SD_F_DYING

#define SD_F_DYING   0x00000008

Definition at line 135 of file sound.h.

◆ SD_F_EQ

#define SD_F_EQ   0x00000400 /* EQ */

Definition at line 142 of file sound.h.

◆ SD_F_EQ_BYPASSED

#define SD_F_EQ_BYPASSED   0x00001000 /* EQ bypassed */

Definition at line 144 of file sound.h.

◆ SD_F_EQ_DEFAULT

#define SD_F_EQ_DEFAULT   (SD_F_EQ | SD_F_EQ_ENABLED)

Definition at line 147 of file sound.h.

◆ SD_F_EQ_ENABLED

#define SD_F_EQ_ENABLED   0x00000800 /* EQ enabled */

Definition at line 143 of file sound.h.

◆ SD_F_EQ_MASK

#define SD_F_EQ_MASK
Value:
SD_F_EQ_BYPASSED | SD_F_EQ_PC)
#define SD_F_EQ_ENABLED
Definition: sound.h:143
#define SD_F_EQ_PC
Definition: sound.h:145
#define SD_F_EQ
Definition: sound.h:142

Definition at line 148 of file sound.h.

◆ SD_F_EQ_PC

#define SD_F_EQ_PC   0x00002000 /* EQ per-channel */

Definition at line 145 of file sound.h.

◆ SD_F_MPSAFE

#define SD_F_MPSAFE   0x00000040

Definition at line 138 of file sound.h.

◆ SD_F_PRIO_RD

#define SD_F_PRIO_RD   0x10000000

Definition at line 151 of file sound.h.

◆ SD_F_PRIO_SET

#define SD_F_PRIO_SET   (SD_F_PRIO_RD | SD_F_PRIO_WR)

Definition at line 153 of file sound.h.

◆ SD_F_PRIO_WR

#define SD_F_PRIO_WR   0x20000000

Definition at line 152 of file sound.h.

◆ SD_F_REGISTERED

#define SD_F_REGISTERED   0x00000080

Definition at line 139 of file sound.h.

◆ SD_F_SIMPLEX

#define SD_F_SIMPLEX   0x00000001

Definition at line 132 of file sound.h.

◆ SD_F_SOFTPCMVOL

#define SD_F_SOFTPCMVOL   0x00000004

Definition at line 134 of file sound.h.

◆ SD_F_TRANSIENT

#define SD_F_TRANSIENT   0xf0000000

Definition at line 155 of file sound.h.

◆ SD_F_VPC

#define SD_F_VPC   0x00000200 /* volume-per-channel */

Definition at line 141 of file sound.h.

◆ SND_DECLARE_FILE

#define SND_DECLARE_FILE (   version)     _SND_DECLARE_FILE(__LINE__, version)

Definition at line 356 of file sound.h.

◆ SND_DEV_AUDIO

#define SND_DEV_AUDIO   4 /* Sparc compatible /dev/audio */

Definition at line 265 of file sound.h.

◆ SND_DEV_CTL

#define SND_DEV_CTL   0 /* Control port /dev/mixer */

Definition at line 261 of file sound.h.

◆ SND_DEV_DSP

#define SND_DEV_DSP   3 /* Digitized voice /dev/dsp */

Definition at line 264 of file sound.h.

◆ SND_DEV_DSP16

#define SND_DEV_DSP16   5 /* Like /dev/dsp but 16 bits/sample */

Definition at line 266 of file sound.h.

◆ SND_DEV_DSP_AC3

#define SND_DEV_DSP_AC3   17 /* /dev/dsp_ac3 */

Definition at line 287 of file sound.h.

◆ SND_DEV_DSP_MMAP

#define SND_DEV_DSP_MMAP   16 /* /dev/dsp_mmap */

Definition at line 286 of file sound.h.

◆ SND_DEV_DSP_MULTICH

#define SND_DEV_DSP_MULTICH   18 /* /dev/dsp_multich */

Definition at line 288 of file sound.h.

◆ SND_DEV_DSP_SPDIFIN

#define SND_DEV_DSP_SPDIFIN   20 /* /dev/dsp_spdifin */

Definition at line 290 of file sound.h.

◆ SND_DEV_DSP_SPDIFOUT

#define SND_DEV_DSP_SPDIFOUT   19 /* /dev/dsp_spdifout */

Definition at line 289 of file sound.h.

◆ SND_DEV_DSPHW_CD

#define SND_DEV_DSPHW_CD   15 /* s16le/stereo 44100Hz CD */

Definition at line 279 of file sound.h.

◆ SND_DEV_DSPHW_PLAY

#define SND_DEV_DSPHW_PLAY   11 /* specific playback channel */

Definition at line 274 of file sound.h.

◆ SND_DEV_DSPHW_REC

#define SND_DEV_DSPHW_REC   13 /* specific record channel */

Definition at line 276 of file sound.h.

◆ SND_DEV_DSPHW_VPLAY

#define SND_DEV_DSPHW_VPLAY   12 /* specific virtual playback channel */

Definition at line 275 of file sound.h.

◆ SND_DEV_DSPHW_VREC

#define SND_DEV_DSPHW_VREC   14 /* specific virtual record channel */

Definition at line 277 of file sound.h.

◆ SND_DEV_LAST

#define SND_DEV_LAST   SND_DEV_DSP_SPDIFIN

Definition at line 292 of file sound.h.

◆ SND_DEV_MAX

#define SND_DEV_MAX   PCMMAXDEV

Definition at line 293 of file sound.h.

◆ SND_DEV_MIDIN

#define SND_DEV_MIDIN   2 /* Raw midi access */

Definition at line 263 of file sound.h.

◆ SND_DEV_NORESET

#define SND_DEV_NORESET   10

Definition at line 272 of file sound.h.

◆ SND_DEV_PSS

#define SND_DEV_PSS   SND_DEV_SNDPROC /* ? */

Definition at line 271 of file sound.h.

◆ SND_DEV_SEQ

#define SND_DEV_SEQ   1 /* Sequencer /dev/sequencer */

Definition at line 262 of file sound.h.

◆ SND_DEV_SEQ2

#define SND_DEV_SEQ2   8 /* /dev/sequencer, level 2 interface */

Definition at line 269 of file sound.h.

◆ SND_DEV_SNDPROC

#define SND_DEV_SNDPROC   9 /* /dev/sndproc for programmable devices */

Definition at line 270 of file sound.h.

◆ SND_DEV_STATUS

#define SND_DEV_STATUS   6 /* /dev/sndstat */

Definition at line 267 of file sound.h.

◆ SND_FORMAT

#define SND_FORMAT (   f,
  c,
 
)
Value:
(AFMT_ENCODING(f) | \
(((c) << AFMT_CHANNEL_SHIFT) & \
AFMT_CHANNEL_MASK) | \
(((e) << AFMT_EXTCHANNEL_SHIFT) & \
struct pcm_channel * c
Definition: channel_if.m:106
#define AFMT_ENCODING(v)
Definition: sound.h:222
#define AFMT_CHANNEL_SHIFT
Definition: sound.h:216
#define AFMT_EXTCHANNEL_SHIFT
Definition: sound.h:219

Definition at line 238 of file sound.h.

◆ SND_MAXHWCHAN

#define SND_MAXHWCHAN   256

Definition at line 129 of file sound.h.

◆ SND_MAXVCHANS

#define SND_MAXVCHANS   SND_MAXHWCHAN

Definition at line 130 of file sound.h.

◆ snd_mtxlock

#define snd_mtxlock (   m)    mtx_lock(m)

Definition at line 347 of file sound.h.

◆ snd_mtxunlock

#define snd_mtxunlock (   m)    mtx_unlock(m)

Definition at line 348 of file sound.h.

◆ SND_STATUSLEN

#define SND_STATUSLEN   64

Definition at line 98 of file sound.h.

◆ SOUND_MAXVER

#define SOUND_MAXVER   SOUND_MODVER

Definition at line 104 of file sound.h.

◆ SOUND_MINVER

#define SOUND_MINVER   SOUND_MODVER

Definition at line 102 of file sound.h.

◆ SOUND_MODVER

#define SOUND_MODVER   5

Definition at line 100 of file sound.h.

◆ SOUND_PREFVER

#define SOUND_PREFVER   SOUND_MODVER

Definition at line 103 of file sound.h.

Typedef Documentation

◆ sndstat_handler

typedef int(* sndstat_handler) (struct sbuf *s, device_t dev, int verbose)

Definition at line 350 of file sound.h.

Function Documentation

◆ pcm_addchan()

◆ pcm_chn_add()

◆ pcm_chn_create()

◆ pcm_chn_destroy()

int pcm_chn_destroy ( struct pcm_channel ch)

Definition at line 596 of file sound.c.

References chn_kill(), pcm_channel::dev, free, pcm_channel::methods, pcm_channel::name, pcm_channel::parentsnddev, and PCM_BUSYASSERT.

Referenced by pcm_addchan(), pcm_killchan(), vchan_create(), and vchan_destroy().

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

◆ pcm_chn_remove()

◆ pcm_chnalloc()

int pcm_chnalloc ( struct snddev_info d,
struct pcm_channel **  ch,
int  direction,
pid_t  pid,
char *  comm,
int  devunit 
)

◆ pcm_chnref()

int pcm_chnref ( struct pcm_channel c,
int  ref 
)

Definition at line 387 of file sound.c.

References c, CHN_LOCKASSERT, pcm_channel::parentsnddev, PCM_BUSYASSERT, and pcm_channel::refcount.

Referenced by dsp_close(), dsp_get_volume_channel(), dsp_open(), and getchns().

Here is the caller graph for this function:

◆ pcm_chnrelease()

int pcm_chnrelease ( struct pcm_channel c)

Definition at line 373 of file sound.c.

References c, CHN_COMM_UNUSED, CHN_LOCKASSERT, CHN_UNLOCK, pcm_channel::comm, pcm_channel::flags, pcm_channel::parentsnddev, PCM_BUSYASSERT, and pcm_channel::pid.

Referenced by dsp_close(), dsp_open(), and getchns().

Here is the caller graph for this function:

◆ pcm_getbuffersize()

unsigned int pcm_getbuffersize ( device_t  dev,
unsigned int  minbufsz,
unsigned int  deflt,
unsigned int  maxbufsz 
)

◆ pcm_getdevinfo()

◆ pcm_getflags()

◆ pcm_inprog()

int pcm_inprog ( struct snddev_info d,
int  delta 
)

Definition at line 398 of file sound.c.

References snddev_info::inprog, and PCM_LOCKASSERT.

◆ pcm_register()

int pcm_register ( device_t  dev,
void *  devinfo,
int  numplay,
int  numrec 
)

Definition at line 1080 of file sound.c.

References snddev_info::channels, CHN_INIT, snddev_info::clones, snddev_info::cv, dev, snddev_info::dev, snddev_info::devcount, devinfo, snddev_info::devinfo, dsp_cdevinfo_init(), snddev_info::flags, snddev_info::inprog, snddev_info::lock, PCM_ACQUIRE_QUICK, pcm_veto_load, PCMMAXCLONE, PCMMAXUNIT, snddev_info::play_sysctl_tree, snddev_info::playcount, snddev_info::pvchancount, snddev_info::pvchanformat, snddev_info::pvchanrate, snddev_info::rec_sysctl_ctx, snddev_info::rec_sysctl_tree, snddev_info::reccount, snddev_info::rvchancount, snddev_info::rvchanformat, snddev_info::rvchanrate, SD_F_AUTOVCHAN, SD_F_BITPERFECT, SD_F_SIMPLEX, SD_F_VPC, snd_clone_create(), SND_CLONE_DEADLINE_DEFAULT, SND_CLONE_GC_ENABLE, SND_CLONE_GC_EXPIRED, SND_CLONE_GC_LASTREF, SND_CLONE_GC_UNREF, SND_CLONE_WAITOK, SND_D_MASK, snd_mtxcreate(), SND_U_MASK, sndstat_prepare_pcm(), sndstat_register(), and snddev_info::status.

Referenced by ad1816_attach(), als_pci_attach(), aoa_attach(), atiixp_chip_post_init(), audio_soc_init(), cmi_attach(), cs4281_pci_attach(), emu_pci_attach(), emu_pcm_attach(), envy24_pci_attach(), envy24ht_pci_attach(), es_pci_attach(), ess_attach(), fm801_pci_attach(), hdaa_pcm_attach(), hdspe_pcm_attach(), ich_pci_attach(), m3_pci_attach(), mss_doattach(), nm_pci_attach(), pcmcsa_attach(), sb16_attach(), sb_attach(), sv_attach(), tr_pci_attach(), uaudio_attach_sub(), and via_attach().

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

◆ pcm_setflags()

void pcm_setflags ( device_t  dev,
u_int32_t  val 
)

◆ pcm_setstatus()

◆ pcm_setvchans()

◆ pcm_unregister()

◆ snd_mtxassert()

void snd_mtxassert ( void *  m)

Definition at line 107 of file sound.c.

References m.

Referenced by sbc_lockassert().

Here is the caller graph for this function:

◆ snd_mtxcreate()

◆ snd_mtxfree()

◆ snd_setup_intr()

int snd_setup_intr ( device_t  dev,
struct resource *  res,
int  flags,
driver_intr_t  hand,
void *  param,
void **  cookiep 
)

◆ sndstat_register()

int sndstat_register ( device_t  dev,
char *  str,
sndstat_handler  handler 
)

Definition at line 1059 of file sndstat.c.

References dev, SNDSTAT_LOCK, SNDSTAT_UNLOCK, SS_TYPE_MIDI, SS_TYPE_MODULE, SS_TYPE_PCM, SS_TYPE_SEQUENCER, and type.

Referenced by pcm_register(), and sndstat_registerfile().

Here is the caller graph for this function:

◆ sndstat_registerfile()

int sndstat_registerfile ( char *  str)

Definition at line 1112 of file sndstat.c.

References sndstat_register().

Here is the call graph for this function:

◆ sndstat_unregister()

int sndstat_unregister ( device_t  dev)

Definition at line 1118 of file sndstat.c.

References dev, error, free, SNDSTAT_LOCK, and SNDSTAT_UNLOCK.

Referenced by pcm_unregister().

Here is the caller graph for this function:

◆ sndstat_unregisterfile()

int sndstat_unregisterfile ( char *  str)

Definition at line 1138 of file sndstat.c.

References error, free, SNDSTAT_LOCK, and SNDSTAT_UNLOCK.

◆ sound_oss_card_info()

int sound_oss_card_info ( oss_card_info *  si)

Definition at line 1389 of file sound.c.

References snddev_info::dev, pcm_devclass, PCM_LOCK, PCM_REGISTERED, PCM_UNLOCK, PCM_UNLOCKASSERT, and snddev_info::status.

Referenced by dsp_ioctl(), and mixer_ioctl_cmd().

Here is the caller graph for this function:

◆ sound_oss_sysinfo()

void sound_oss_sysinfo ( oss_sysinfo *  si)

Handle OSSv4 SNDCTL_SYSINFO ioctl.

Parameters
siPointer to oss_sysinfo struct where information about the sound subsystem will be written/copied.

This routine returns information about the sound system, such as the current OSS version, number of audio, MIDI, and mixer drivers, etc. Also includes a bitmask showing which of the above types of devices are open (busy).

Note
Calling threads must not hold any snddev_info or pcm_channel locks.
Author
Ryan Beasley ryanb.nosp@m.@Fre.nosp@m.eBSD..nosp@m.org
Todo:
Collect num{midis,timers}.

Need access to sound/midi/midi.c::midistat_lock in order to safely touch midi_devices and get a head count of, well, MIDI devices. midistat_lock is a global static (i.e., local to midi.c), but midi_devices is a regular global; should the mutex be publicized, or is there another way to get this information?

NB: MIDI/sequencer stuff is currently on hold.

Todo:
Fill in "busy devices" fields.

si->openedmidi = " MIDI devices

Definition at line 1296 of file sound.c.

References c, pcm_channel::channels, CHN_F_BUSY, CHN_FOREACH, CHN_LOCK, CHN_UNLOCK, CHN_UNLOCKASSERT, snddev_info::devcount, pcm_channel::flags, mixer_count, pcm_devclass, PCM_LOCK, PCM_REGISTERED, PCM_UNLOCK, and PCM_UNLOCKASSERT.

Referenced by dsp_ioctl(), and mixer_ioctl_cmd().

Here is the caller graph for this function:

◆ SYSCTL_DECL()

SYSCTL_DECL ( _hw_snd  )

Variable Documentation

◆ pcm_devclass

◆ pcm_veto_load

int pcm_veto_load
extern

Definition at line 51 of file sound.c.

Referenced by pcm_register(), and SLIST_HEAD().

◆ pcmsg_unrhdr

struct unrhdr* pcmsg_unrhdr
extern

Unit number allocator for syncgroup IDs.

Definition at line 78 of file sound.c.

Referenced by dsp_close(), dsp_oss_syncgroup(), dsp_oss_syncstart(), and sound_modevent().

◆ snd_maxautovchans

int snd_maxautovchans
extern

◆ snd_unit

int snd_unit
extern

◆ snd_verbose