FreeBSD kernel sound device code
sndstat.c File Reference
#include <sys/param.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/nv.h>
#include <sys/dnv.h>
#include <sys/sx.h>
#include <dev/sound/pcm/sound.h>
#include <dev/sound/pcm/pcm.h>
#include <dev/sound/version.h>
Include dependency graph for sndstat.c:

Go to the source code of this file.

Data Structures

struct  sndstat_entry
 
struct  sndstat_userdev
 
struct  sndstat_file
 

Macros

#define SS_TYPE_MODULE   0
 
#define SS_TYPE_PCM   1
 
#define SS_TYPE_MIDI   2
 
#define SS_TYPE_SEQUENCER   3
 
#define SNDSTAT_LOCK()   sx_xlock(&sndstat_lock)
 
#define SNDSTAT_UNLOCK()   sx_xunlock(&sndstat_lock)
 

Functions

 SND_DECLARE_FILE ("$FreeBSD$")
 
static void sndstat_close (void *)
 
static TAILQ_HEAD (sndstat_entry)
 
 SYSCTL_PROC (_hw_snd, OID_AUTO, verbose, CTLTYPE_INT|CTLFLAG_RWTUN|CTLFLAG_MPSAFE, 0, sizeof(int), sysctl_hw_sndverbose, "I", "verbosity level")
 
static int sndstat_open (struct cdev *i_dev, int flags, int mode, struct thread *td)
 
static void sndstat_remove_all_userdevs (struct sndstat_file *pf)
 
static int sndstat_read (struct cdev *i_dev, struct uio *buf, int flag)
 
static int sndstat_write (struct cdev *i_dev, struct uio *buf, int flag)
 
static void sndstat_get_caps (struct snddev_info *d, bool play, uint32_t *min_rate, uint32_t *max_rate, uint32_t *fmts, uint32_t *minchn, uint32_t *maxchn)
 
static nvlist_t * sndstat_create_diinfo_nv (uint32_t min_rate, uint32_t max_rate, uint32_t formats, uint32_t min_chn, uint32_t max_chn)
 
static int sndstat_build_sound4_nvlist (struct snddev_info *d, nvlist_t **dip)
 
static int sndstat_build_userland_nvlist (struct sndstat_userdev *ud, nvlist_t **dip)
 
static int sndstat_create_devs_nvlist (nvlist_t **nvlp)
 
static int sndstat_refresh_devs (struct sndstat_file *pf)
 
static int sndstat_get_devs (struct sndstat_file *pf, caddr_t data)
 
static int sndstat_unpack_user_nvlbuf (const void *unvlbuf, size_t nbytes, nvlist_t **nvl)
 
static bool sndstat_diinfo_is_sane (const nvlist_t *diinfo)
 
static bool sndstat_dsp_nvlist_is_sane (const nvlist_t *nvlist)
 
static void sndstat_get_diinfo_nv (const nvlist_t *nv, uint32_t *min_rate, uint32_t *max_rate, uint32_t *formats, uint32_t *min_chn, uint32_t *max_chn)
 
static int sndstat_dsp_unpack_nvlist (const nvlist_t *nvlist, struct sndstat_userdev *ud)
 
static int sndstat_add_user_devs (struct sndstat_file *pf, caddr_t data)
 
static int sndstat_flush_user_devs (struct sndstat_file *pf)
 
static int sndstat_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
 
static struct sndstat_userdevsndstat_line2userdev (struct sndstat_file *pf, const char *line, int n)
 
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)
 
static int sndstat_prepare (struct sndstat_file *pf_self)
 
static void sndstat_sysinit (void *p)
 
 SYSINIT (sndstat_sysinit, SI_SUB_DRIVERS, SI_ORDER_FIRST, sndstat_sysinit, NULL)
 
static void sndstat_sysuninit (void *p)
 
 SYSUNINIT (sndstat_sysuninit, SI_SUB_DRIVERS, SI_ORDER_FIRST, sndstat_sysuninit, NULL)
 

Variables

static d_open_t sndstat_open
 
static d_read_t sndstat_read
 
static d_write_t sndstat_write
 
static d_ioctl_t sndstat_ioctl
 
static struct cdevsw sndstat_cdevsw
 
static struct sx sndstat_lock
 
static struct cdev * sndstat_dev
 

Macro Definition Documentation

◆ SNDSTAT_LOCK

#define SNDSTAT_LOCK ( )    sx_xlock(&sndstat_lock)

Definition at line 117 of file sndstat.c.

◆ SNDSTAT_UNLOCK

#define SNDSTAT_UNLOCK ( )    sx_xunlock(&sndstat_lock)

Definition at line 118 of file sndstat.c.

◆ SS_TYPE_MIDI

#define SS_TYPE_MIDI   2

Definition at line 57 of file sndstat.c.

◆ SS_TYPE_MODULE

#define SS_TYPE_MODULE   0

Definition at line 55 of file sndstat.c.

◆ SS_TYPE_PCM

#define SS_TYPE_PCM   1

Definition at line 56 of file sndstat.c.

◆ SS_TYPE_SEQUENCER

#define SS_TYPE_SEQUENCER   3

Definition at line 58 of file sndstat.c.

Function Documentation

◆ SND_DECLARE_FILE()

SND_DECLARE_FILE ( "$FreeBSD$"  )

◆ sndstat_add_user_devs()

static int sndstat_add_user_devs ( struct sndstat_file pf,
caddr_t  data 
)
static

Definition at line 856 of file sndstat.c.

References data, pf, sndstat_dsp_nvlist_is_sane(), sndstat_dsp_unpack_nvlist(), and sndstat_unpack_user_nvlbuf().

Referenced by sndstat_ioctl().

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

◆ sndstat_build_sound4_nvlist()

static int sndstat_build_sound4_nvlist ( struct snddev_info d,
nvlist_t **  dip 
)
static

◆ sndstat_build_userland_nvlist()

static int sndstat_build_userland_nvlist ( struct sndstat_userdev ud,
nvlist_t **  dip 
)
static

Definition at line 478 of file sndstat.c.

References sndstat_userdev::info_play, sndstat_userdev::info_rec, sndstat_userdev::provider_nvl, and sndstat_create_diinfo_nv().

Referenced by sndstat_create_devs_nvlist().

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

◆ sndstat_close()

static void sndstat_close ( void *  sndstat_file)
static

Definition at line 198 of file sndstat.c.

References free, pf, SNDSTAT_LOCK, sndstat_remove_all_userdevs(), and SNDSTAT_UNLOCK.

Referenced by sndstat_open().

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

◆ sndstat_create_devs_nvlist()

static int sndstat_create_devs_nvlist ( nvlist_t **  nvlp)
static

Definition at line 549 of file sndstat.c.

References PCM_REGISTERED, pf, sndstat_build_sound4_nvlist(), and sndstat_build_userland_nvlist().

Referenced by sndstat_get_devs().

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

◆ sndstat_create_diinfo_nv()

static nvlist_t * sndstat_create_diinfo_nv ( uint32_t  min_rate,
uint32_t  max_rate,
uint32_t  formats,
uint32_t  min_chn,
uint32_t  max_chn 
)
static

Definition at line 380 of file sndstat.c.

Referenced by sndstat_build_sound4_nvlist(), and sndstat_build_userland_nvlist().

Here is the caller graph for this function:

◆ sndstat_diinfo_is_sane()

static bool sndstat_diinfo_is_sane ( const nvlist_t *  diinfo)
static

Definition at line 718 of file sndstat.c.

Referenced by sndstat_dsp_nvlist_is_sane().

Here is the caller graph for this function:

◆ sndstat_dsp_nvlist_is_sane()

static bool sndstat_dsp_nvlist_is_sane ( const nvlist_t *  nvlist)
static

Definition at line 730 of file sndstat.c.

References sndstat_diinfo_is_sane().

Referenced by sndstat_add_user_devs().

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

◆ sndstat_dsp_unpack_nvlist()

static int sndstat_dsp_unpack_nvlist ( const nvlist_t *  nvlist,
struct sndstat_userdev ud 
)
static

Definition at line 777 of file sndstat.c.

References desc, sndstat_userdev::info_play, sndstat_userdev::info_rec, provider, sndstat_userdev::provider_nvl, and sndstat_get_diinfo_nv().

Referenced by sndstat_add_user_devs().

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

◆ sndstat_flush_user_devs()

static int sndstat_flush_user_devs ( struct sndstat_file pf)
static

Definition at line 903 of file sndstat.c.

References pf, and sndstat_remove_all_userdevs().

Referenced by sndstat_ioctl().

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

◆ sndstat_get_caps()

static void sndstat_get_caps ( struct snddev_info d,
bool  play,
uint32_t *  min_rate,
uint32_t *  max_rate,
uint32_t *  fmts,
uint32_t *  minchn,
uint32_t *  maxchn 
)
static

◆ sndstat_get_devs()

static int sndstat_get_devs ( struct sndstat_file pf,
caddr_t  data 
)
static

Definition at line 628 of file sndstat.c.

References data, free, pf, sndstat_create_devs_nvlist(), SNDSTAT_LOCK, and SNDSTAT_UNLOCK.

Referenced by sndstat_ioctl().

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

◆ sndstat_get_diinfo_nv()

static void sndstat_get_diinfo_nv ( const nvlist_t *  nv,
uint32_t *  min_rate,
uint32_t *  max_rate,
uint32_t *  formats,
uint32_t *  min_chn,
uint32_t *  max_chn 
)
static

Definition at line 765 of file sndstat.c.

Referenced by sndstat_dsp_unpack_nvlist().

Here is the caller graph for this function:

◆ sndstat_ioctl()

static int sndstat_ioctl ( struct cdev *  dev,
u_long  cmd,
caddr_t  data,
int  fflag,
struct thread *  td 
)
static

Definition at line 956 of file sndstat.c.

References data, pf, sndstat_add_user_devs(), sndstat_flush_user_devs(), sndstat_get_devs(), and sndstat_refresh_devs().

Here is the call graph for this function:

◆ sndstat_line2userdev()

static struct sndstat_userdev * sndstat_line2userdev ( struct sndstat_file pf,
const char *  line,
int  n 
)
static

Definition at line 1005 of file sndstat.c.

References fail, free, m, and sndstat_userdev::provider_nvl.

Referenced by sndstat_write().

Here is the caller graph for this function:

◆ sndstat_open()

static int sndstat_open ( struct cdev *  i_dev,
int  flags,
int  mode,
struct thread *  td 
)
static

Definition at line 150 of file sndstat.c.

References free, pf, sndstat_close(), SNDSTAT_LOCK, and SNDSTAT_UNLOCK.

Here is the call graph for this function:

◆ sndstat_prepare()

static int sndstat_prepare ( struct sndstat_file pf_self)
static

Definition at line 1160 of file sndstat.c.

References k, PCM_ACQUIRE_QUICK, PCM_REGISTERED, PCM_RELEASE_QUICK, pf, SND_DRV_VERSION, and snd_verbose.

Referenced by sndstat_read().

Here is the caller graph for this function:

◆ sndstat_read()

static int sndstat_read ( struct cdev *  i_dev,
struct uio *  buf,
int  flag 
)
static

Definition at line 217 of file sndstat.c.

References buf, len, pf, SNDSTAT_LOCK, sndstat_prepare(), and SNDSTAT_UNLOCK.

Here is the call graph for this function:

◆ sndstat_refresh_devs()

static int sndstat_refresh_devs ( struct sndstat_file pf)
static

Definition at line 616 of file sndstat.c.

References free, and pf.

Referenced by sndstat_ioctl().

Here is the caller graph for this function:

◆ 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_remove_all_userdevs()

static void sndstat_remove_all_userdevs ( struct sndstat_file pf)
static

Definition at line 180 of file sndstat.c.

References free, pf, and sndstat_userdev::provider_nvl.

Referenced by sndstat_close(), sndstat_flush_user_devs(), and sndstat_write().

Here is the caller graph for this function:

◆ sndstat_sysinit()

static void sndstat_sysinit ( void *  p)
static

Definition at line 1247 of file sndstat.c.

References SND_DEV_STATUS, sndstat_cdevsw, sndstat_dev, and sndstat_lock.

◆ sndstat_sysuninit()

static void sndstat_sysuninit ( void *  p)
static

Definition at line 1256 of file sndstat.c.

References sndstat_dev, and sndstat_lock.

◆ sndstat_unpack_user_nvlbuf()

static int sndstat_unpack_user_nvlbuf ( const void *  unvlbuf,
size_t  nbytes,
nvlist_t **  nvl 
)
static

Definition at line 697 of file sndstat.c.

References free.

Referenced by sndstat_add_user_devs().

Here is the caller 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.

◆ sndstat_write()

static int sndstat_write ( struct cdev *  i_dev,
struct uio *  buf,
int  flag 
)
static

Definition at line 255 of file sndstat.c.

References buf, len, pf, sndstat_line2userdev(), SNDSTAT_LOCK, sndstat_remove_all_userdevs(), and SNDSTAT_UNLOCK.

Here is the call graph for this function:

◆ SYSCTL_PROC()

SYSCTL_PROC ( _hw_snd  ,
OID_AUTO  ,
verbose  ,
CTLTYPE_INT|CTLFLAG_RWTUN|  CTLFLAG_MPSAFE,
,
sizeof(int)  ,
sysctl_hw_sndverbose  ,
"I"  ,
"verbosity level"   
)

◆ SYSINIT()

SYSINIT ( sndstat_sysinit  ,
SI_SUB_DRIVERS  ,
SI_ORDER_FIRST  ,
sndstat_sysinit  ,
NULL   
)

◆ SYSUNINIT()

SYSUNINIT ( sndstat_sysuninit  ,
SI_SUB_DRIVERS  ,
SI_ORDER_FIRST  ,
sndstat_sysuninit  ,
NULL   
)

◆ TAILQ_HEAD()

static TAILQ_HEAD ( sndstat_entry  )
static

Definition at line 120 of file sndstat.c.

References error, and req.

Variable Documentation

◆ sndstat_cdevsw

struct cdevsw sndstat_cdevsw
static
Initial value:
= {
.d_version = D_VERSION,
.d_open = sndstat_open,
.d_read = sndstat_read,
.d_write = sndstat_write,
.d_ioctl = sndstat_ioctl,
.d_name = "sndstat",
.d_flags = D_TRACKCLOSE,
}
static d_ioctl_t sndstat_ioctl
Definition: sndstat.c:64
static d_write_t sndstat_write
Definition: sndstat.c:63
static d_open_t sndstat_open
Definition: sndstat.c:60
static d_read_t sndstat_read
Definition: sndstat.c:62

Definition at line 66 of file sndstat.c.

Referenced by sndstat_sysinit().

◆ sndstat_dev

struct cdev* sndstat_dev
static

Definition at line 115 of file sndstat.c.

Referenced by sndstat_sysinit(), and sndstat_sysuninit().

◆ sndstat_ioctl

d_ioctl_t sndstat_ioctl
static

Definition at line 64 of file sndstat.c.

◆ sndstat_lock

struct sx sndstat_lock
static

Definition at line 114 of file sndstat.c.

Referenced by sndstat_sysinit(), and sndstat_sysuninit().

◆ sndstat_open

d_open_t sndstat_open
static

Definition at line 60 of file sndstat.c.

◆ sndstat_read

d_read_t sndstat_read
static

Definition at line 62 of file sndstat.c.

◆ sndstat_write

d_write_t sndstat_write
static

Definition at line 63 of file sndstat.c.