FreeBSD kernel sound device code
vibes.c File Reference
#include <dev/sound/pcm/sound.h>
#include <dev/sound/pci/vibes.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include "mixer_if.h"
Include dependency graph for vibes.c:

Go to the source code of this file.

Data Structures

struct  sc_chinfo
 
struct  sc_info
 
struct  sv_mix_props
 

Macros

#define SV_PCI_ID   0xca005333
 
#define SV_DEFAULT_BUFSZ   16384
 
#define SV_MIN_BLKSZ   128
 
#define SV_INTR_PER_BUFFER   2
 
#define DEB(x)   /* (x) */
 
#define sv_direct_set(x, y, z)   _sv_direct_set(x, y, z, __LINE__)
 
#define sv_indirect_set(x, y, z)   _sv_indirect_set(x, y, z, __LINE__)
 

Functions

 SND_DECLARE_FILE ("$FreeBSD$")
 
static u_int8_t sv_direct_get (struct sc_info *sc, u_int8_t reg)
 
static void _sv_direct_set (struct sc_info *sc, u_int8_t reg, u_int8_t val, int line)
 
static u_int8_t sv_indirect_get (struct sc_info *sc, u_int8_t reg)
 
static void _sv_indirect_set (struct sc_info *sc, u_int8_t reg, u_int8_t val, int line)
 
static void sv_dma_set_config (bus_space_tag_t st, bus_space_handle_t sh, u_int32_t base, u_int32_t count, u_int8_t mode)
 
static u_int32_t sv_dma_get_count (bus_space_tag_t st, bus_space_handle_t sh)
 
static void * svchan_init (kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
 
static struct pcmchan_capssvchan_getcaps (kobj_t obj, void *data)
 
static u_int32_t svchan_setblocksize (kobj_t obj, void *data, u_int32_t blocksize)
 
static int svchan_setformat (kobj_t obj, void *data, u_int32_t format)
 
static u_int32_t svchan_setspeed (kobj_t obj, void *data, u_int32_t speed)
 
static int sv_set_recspeed (struct sc_info *sc, u_int32_t speed)
 
static int svrchan_trigger (kobj_t obj, void *data, int go)
 
static u_int32_t svrchan_getptr (kobj_t obj, void *data)
 
 CHANNEL_DECLARE (svrchan)
 
static int svpchan_trigger (kobj_t obj, void *data, int go)
 
static u_int32_t svpchan_getptr (kobj_t obj, void *data)
 
 CHANNEL_DECLARE (svpchan)
 
static void sv_channel_gain (struct sc_info *sc, u_int32_t dev, u_int32_t gain, u_int32_t channel)
 
static int sv_gain (struct sc_info *sc, u_int32_t dev, u_int32_t left, u_int32_t right)
 
static void sv_mix_mute_all (struct sc_info *sc)
 
static int sv_mix_init (struct snd_mixer *m)
 
static int sv_mix_set (struct snd_mixer *m, u_int32_t dev, u_int32_t left, u_int32_t right)
 
static u_int32_t sv_mix_setrecsrc (struct snd_mixer *m, u_int32_t mask)
 
 MIXER_DECLARE (sv_mixer)
 
static void sv_power (struct sc_info *sc, int state)
 
static int sv_init (struct sc_info *sc)
 
static int sv_suspend (device_t dev)
 
static int sv_resume (device_t dev)
 
static void sv_intr (void *data)
 
static int sv_probe (device_t dev)
 
static int sv_attach (device_t dev)
 
static int sv_detach (device_t dev)
 
 DRIVER_MODULE (snd_vibes, pci, sonicvibes_driver, pcm_devclass, 0, 0)
 
 MODULE_DEPEND (snd_vibes, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
 
 MODULE_VERSION (snd_vibes, 1)
 

Variables

static u_int32_t sc_fmt []
 
static struct pcmchan_caps sc_caps = {8000, 48000, sc_fmt, 0}
 
static kobj_method_t svrchan_methods []
 
static kobj_method_t svpchan_methods []
 
struct sv_mix_props mt [SOUND_MIXER_NRDEVICES]
 
static kobj_method_t sv_mixer_methods []
 
static device_method_t sc_methods []
 
static driver_t sonicvibes_driver
 

Macro Definition Documentation

◆ DEB

#define DEB (   x)    /* (x) */

Definition at line 58 of file vibes.c.

◆ SV_DEFAULT_BUFSZ

#define SV_DEFAULT_BUFSZ   16384

Definition at line 53 of file vibes.c.

◆ sv_direct_set

#define sv_direct_set (   x,
  y,
 
)    _sv_direct_set(x, y, z, __LINE__)

Definition at line 120 of file vibes.c.

◆ sv_indirect_set

#define sv_indirect_set (   x,
  y,
 
)    _sv_indirect_set(x, y, z, __LINE__)

Definition at line 150 of file vibes.c.

◆ SV_INTR_PER_BUFFER

#define SV_INTR_PER_BUFFER   2

Definition at line 55 of file vibes.c.

◆ SV_MIN_BLKSZ

#define SV_MIN_BLKSZ   128

Definition at line 54 of file vibes.c.

◆ SV_PCI_ID

#define SV_PCI_ID   0xca005333

Definition at line 52 of file vibes.c.

Function Documentation

◆ _sv_direct_set()

static void _sv_direct_set ( struct sc_info sc,
u_int8_t  reg,
u_int8_t  val,
int  line 
)
static

Definition at line 129 of file vibes.c.

References sc_info::dev, sc_info::enh_sh, sc_info::enh_st, n, reg, sv_direct_get(), and val.

Here is the call graph for this function:

◆ _sv_indirect_set()

static void _sv_indirect_set ( struct sc_info sc,
u_int8_t  reg,
u_int8_t  val,
int  line 
)
static

Definition at line 153 of file vibes.c.

References sc_info::dev, sc_info::enh_sh, sc_info::enh_st, n, reg, SV_CM_DATA, SV_CM_INDEX, SV_CM_INDEX_MCE, sv_indirect_get(), SV_REG_ADC_PLLM, SV_REG_ANALOG_PWR, SV_REG_FORMAT, and val.

Here is the call graph for this function:

◆ CHANNEL_DECLARE() [1/2]

CHANNEL_DECLARE ( svpchan  )

◆ CHANNEL_DECLARE() [2/2]

CHANNEL_DECLARE ( svrchan  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( snd_vibes  ,
pci  ,
sonicvibes_driver  ,
pcm_devclass  ,
,
 
)

◆ MIXER_DECLARE()

MIXER_DECLARE ( sv_mixer  )

◆ MODULE_DEPEND()

MODULE_DEPEND ( snd_vibes  ,
sound  ,
SOUND_MINVER  ,
SOUND_PREFVER  ,
SOUND_MAXVER   
)

◆ MODULE_VERSION()

MODULE_VERSION ( snd_vibes  ,
 
)

◆ SND_DECLARE_FILE()

SND_DECLARE_FILE ( "$FreeBSD$"  )

◆ sv_attach()

◆ sv_channel_gain()

static void sv_channel_gain ( struct sc_info sc,
u_int32_t  dev,
u_int32_t  gain,
u_int32_t  channel 
)
static

Definition at line 483 of file vibes.c.

References channel, dev, sv_mix_props::max, mt, reg, sv_indirect_get(), sv_indirect_set, and SV_MUTE.

Referenced by sv_gain().

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

◆ sv_detach()

◆ sv_direct_get()

static u_int8_t sv_direct_get ( struct sc_info sc,
u_int8_t  reg 
)
static

Definition at line 123 of file vibes.c.

References sc_info::enh_sh, sc_info::enh_st, and reg.

Referenced by _sv_direct_set(), sv_init(), and sv_intr().

Here is the caller graph for this function:

◆ sv_dma_get_count()

static u_int32_t sv_dma_get_count ( bus_space_tag_t  st,
bus_space_handle_t  sh 
)
static

Definition at line 184 of file vibes.c.

References SV_DMA_COUNT.

Referenced by svpchan_getptr(), and svrchan_getptr().

Here is the caller graph for this function:

◆ sv_dma_set_config()

static void sv_dma_set_config ( bus_space_tag_t  st,
bus_space_handle_t  sh,
u_int32_t  base,
u_int32_t  count,
u_int8_t  mode 
)
static

Definition at line 172 of file vibes.c.

References base, count, DEB, SV_DMA_ADDR, SV_DMA_COUNT, and SV_DMA_MODE.

Referenced by svpchan_trigger(), and svrchan_trigger().

Here is the caller graph for this function:

◆ sv_gain()

static int sv_gain ( struct sc_info sc,
u_int32_t  dev,
u_int32_t  left,
u_int32_t  right 
)
static

Definition at line 505 of file vibes.c.

References dev, left, mt, right, stereo, and sv_channel_gain().

Referenced by sv_mix_mute_all(), and sv_mix_set().

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

◆ sv_indirect_get()

static u_int8_t sv_indirect_get ( struct sc_info sc,
u_int8_t  reg 
)
static

◆ sv_init()

static int sv_init ( struct sc_info sc)
static

◆ sv_intr()

static void sv_intr ( void *  data)
static

Definition at line 693 of file vibes.c.

References sc_chinfo::channel, chn_intr(), data, DEB, sc_info::pch, sc_info::rch, status, SV_CM_STATUS, SV_CM_STATUS_AINT, SV_CM_STATUS_CINT, and sv_direct_get().

Referenced by sv_attach().

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

◆ sv_mix_init()

static int sv_mix_init ( struct snd_mixer m)
static

Definition at line 523 of file vibes.c.

References m, max, mix_setdevs(), mix_setrecdevs(), and mt.

Here is the call graph for this function:

◆ sv_mix_mute_all()

static void sv_mix_mute_all ( struct sc_info sc)
static

Definition at line 514 of file vibes.c.

References mt, reg, and sv_gain().

Referenced by sv_attach(), sv_detach(), sv_resume(), and sv_suspend().

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

◆ sv_mix_set()

static int sv_mix_set ( struct snd_mixer m,
u_int32_t  dev,
u_int32_t  left,
u_int32_t  right 
)
static

Definition at line 541 of file vibes.c.

References dev, left, m, mix_getdevinfo(), right, and sv_gain().

Here is the call graph for this function:

◆ sv_mix_setrecsrc()

static u_int32_t sv_mix_setrecsrc ( struct snd_mixer m,
u_int32_t  mask 
)
static

Definition at line 548 of file vibes.c.

References DEB, sv_mix_props::iselect, m, mask, mix_getdevinfo(), mt, sv_indirect_get(), sv_indirect_set, SV_INPUT_GAIN_MASK, and SV_REG_ADC_INPUT.

Here is the call graph for this function:

◆ sv_power()

static void sv_power ( struct sc_info sc,
int  state 
)
static

Definition at line 576 of file vibes.c.

References DEB, state, SV_ANALOG_OFF, SV_ANALOG_OFF_SPLL, SV_ANALOG_OFF_SRS, SV_DIGITAL_OFF, SV_DIGITAL_OFF_GP, SV_DIGITAL_OFF_MU, SV_DIGITAL_OFF_SYN, sv_indirect_get(), sv_indirect_set, SV_REG_ANALOG_PWR, and SV_REG_DIGITAL_PWR.

Referenced by sv_attach(), sv_detach(), sv_resume(), and sv_suspend().

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

◆ sv_probe()

static int sv_probe ( device_t  dev)
static

Definition at line 712 of file vibes.c.

References dev, and SV_PCI_ID.

◆ sv_resume()

static int sv_resume ( device_t  dev)
static

◆ sv_set_recspeed()

static int sv_set_recspeed ( struct sc_info sc,
u_int32_t  speed 
)
static

Definition at line 258 of file vibes.c.

References DEB, m, n, r, r2, speed, SV_ADC_PLLN, SV_ADC_PLLR, SV_F_REF, SV_F_SCALE, sv_indirect_get(), sv_indirect_set, SV_REG_ADC_PLLM, and SV_REG_ADC_PLLN.

Referenced by svrchan_trigger().

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

◆ sv_suspend()

static int sv_suspend ( device_t  dev)
static

Definition at line 645 of file vibes.c.

References dev, sc_chinfo::dma_active, sc_chinfo::dma_was_active, sc_info::pch, pcm_getdevinfo(), PCMTRIG_ABORT, sc_info::rch, sv_mix_mute_all(), sv_power(), and svrchan_trigger().

Here is the call graph for this function:

◆ svchan_getcaps()

static struct pcmchan_caps * svchan_getcaps ( kobj_t  obj,
void *  data 
)
static

Definition at line 216 of file vibes.c.

References sc_caps.

◆ svchan_init()

static void * svchan_init ( kobj_t  obj,
void *  devinfo,
struct snd_dbuf b,
struct pcm_channel c,
int  dir 
)
static

◆ svchan_setblocksize()

static u_int32_t svchan_setblocksize ( kobj_t  obj,
void *  data,
u_int32_t  blocksize 
)
static

Definition at line 222 of file vibes.c.

References blocksize, sc_chinfo::buffer, sc_info::bufsz, sc_info::ch, data, DEB, sc_chinfo::parent, RANGE, sndbuf_resize(), SV_INTR_PER_BUFFER, and SV_MIN_BLKSZ.

Here is the call graph for this function:

◆ svchan_setformat()

static int svchan_setformat ( kobj_t  obj,
void *  data,
u_int32_t  format 
)
static

◆ svchan_setspeed()

static u_int32_t svchan_setspeed ( kobj_t  obj,
void *  data,
u_int32_t  speed 
)
static

Definition at line 246 of file vibes.c.

References data, RANGE, sc_chinfo::spd, and speed.

◆ svpchan_getptr()

static u_int32_t svpchan_getptr ( kobj_t  obj,
void *  data 
)
static

Definition at line 436 of file vibes.c.

References sc_chinfo::buffer, sc_info::ch, data, sc_info::dmaa_sh, sc_info::dmaa_st, sc_chinfo::parent, sndbuf_getsize(), and sv_dma_get_count().

Here is the call graph for this function:

◆ svpchan_trigger()

◆ svrchan_getptr()

static u_int32_t svrchan_getptr ( kobj_t  obj,
void *  data 
)
static

Definition at line 359 of file vibes.c.

References sc_chinfo::buffer, sc_info::ch, data, sc_info::dmac_sh, sc_info::dmac_st, sc_chinfo::parent, sndbuf_getsize(), and sv_dma_get_count().

Here is the call graph for this function:

◆ svrchan_trigger()

Variable Documentation

◆ mt

struct sv_mix_props mt[SOUND_MIXER_NRDEVICES]
Initial value:
= {
[SOUND_MIXER_LINE1] = {SV_REG_AUX1, 1, 1, 1, SV_DEFAULT_MAX, SV_INPUT_AUX1},
[SOUND_MIXER_CD] = {SV_REG_CD, 1, 1, 1, SV_DEFAULT_MAX, SV_INPUT_CD},
[SOUND_MIXER_LINE] = {SV_REG_LINE, 1, 1, 1, SV_DEFAULT_MAX, SV_INPUT_LINE},
[SOUND_MIXER_MIC] = {SV_REG_MIC, 0, 1, 1, SV_MIC_MAX, SV_INPUT_MIC},
[SOUND_MIXER_SYNTH] = {SV_REG_SYNTH, 0, 1, 1, SV_DEFAULT_MAX, 0},
[SOUND_MIXER_LINE2] = {SV_REG_AUX2, 1, 1, 1, SV_DEFAULT_MAX, SV_INPUT_AUX2},
[SOUND_MIXER_VOLUME] = {SV_REG_MIX, 1, 1, 1, SV_DEFAULT_MAX, 0},
[SOUND_MIXER_PCM] = {SV_REG_PCM, 1, 1, 1, SV_PCM_MAX, 0},
[SOUND_MIXER_RECLEV] = {SV_REG_ADC_INPUT, 1, 0, 0, SV_ADC_MAX, 0},
}
#define SV_INPUT_LINE
Definition: vibes.h:104
#define SV_REG_MIC
Definition: vibes.h:112
#define SV_REG_SYNTH
Definition: vibes.h:113
#define SV_INPUT_AUX2
Definition: vibes.h:103
#define SV_INPUT_AUX1
Definition: vibes.h:105
#define SV_ADC_MAX
Definition: vibes.h:118
#define SV_INPUT_CD
Definition: vibes.h:101
#define SV_REG_ADC_INPUT
Definition: vibes.h:98
#define SV_INPUT_MIC
Definition: vibes.h:106
#define SV_PCM_MAX
Definition: vibes.h:120
#define SV_REG_AUX2
Definition: vibes.h:114
#define SV_MIC_MAX
Definition: vibes.h:119
#define SV_DEFAULT_MAX
Definition: vibes.h:117
#define SV_REG_PCM
Definition: vibes.h:116
#define SV_REG_CD
Definition: vibes.h:110
#define SV_REG_MIX
Definition: vibes.h:115
#define SV_REG_LINE
Definition: vibes.h:111
#define SV_REG_AUX1
Definition: vibes.h:109

Referenced by sv_channel_gain(), sv_gain(), sv_mix_init(), sv_mix_mute_all(), and sv_mix_setrecsrc().

◆ sc_caps

struct pcmchan_caps sc_caps = {8000, 48000, sc_fmt, 0}
static

Definition at line 115 of file vibes.c.

Referenced by svchan_getcaps().

◆ sc_fmt

u_int32_t sc_fmt[]
static
Initial value:
= {
SND_FORMAT(AFMT_U8, 1, 0),
SND_FORMAT(AFMT_U8, 2, 0),
SND_FORMAT(AFMT_S16_LE, 1, 0),
SND_FORMAT(AFMT_S16_LE, 2, 0),
0
}
#define SND_FORMAT(f, c, e)
Definition: sound.h:238

Definition at line 107 of file vibes.c.

◆ sc_methods

device_method_t sc_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, sv_probe),
DEVMETHOD(device_attach, sv_attach),
DEVMETHOD(device_detach, sv_detach),
DEVMETHOD(device_resume, sv_resume),
DEVMETHOD(device_suspend, sv_suspend),
{ 0, 0 }
}
static int sv_detach(device_t dev)
Definition: vibes.c:904
static int sv_attach(device_t dev)
Definition: vibes.c:724
static int sv_probe(device_t dev)
Definition: vibes.c:712
static int sv_resume(device_t dev)
Definition: vibes.c:662
static int sv_suspend(device_t dev)
Definition: vibes.c:645

Definition at line 927 of file vibes.c.

◆ sonicvibes_driver

driver_t sonicvibes_driver
static
Initial value:
= {
"pcm",
}
#define PCM_SOFTC_SIZE
Definition: sound.h:96
static device_method_t sc_methods[]
Definition: vibes.c:927

Definition at line 936 of file vibes.c.

◆ sv_mixer_methods

kobj_method_t sv_mixer_methods[]
static
Initial value:
= {
KOBJMETHOD(mixer_init, sv_mix_init),
KOBJMETHOD(mixer_set, sv_mix_set),
}
#define KOBJMETHOD_END
Definition: midi.c:76
static int mixer_setrecsrc(struct snd_mixer *mixer, u_int32_t src)
Definition: mixer.c:373
int mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
Definition: mixer.c:725
static int mixer_set(struct snd_mixer *m, u_int dev, u_int32_t muted, u_int lev)
Definition: mixer.c:247
static int sv_mix_set(struct snd_mixer *m, u_int32_t dev, u_int32_t left, u_int32_t right)
Definition: vibes.c:541
static int sv_mix_init(struct snd_mixer *m)
Definition: vibes.c:523
static u_int32_t sv_mix_setrecsrc(struct snd_mixer *m, u_int32_t mask)
Definition: vibes.c:548

Definition at line 564 of file vibes.c.

◆ svpchan_methods

kobj_method_t svpchan_methods[]
static
Initial value:
= {
KOBJMETHOD(channel_init, svchan_init),
KOBJMETHOD(channel_setformat, svchan_setformat),
KOBJMETHOD(channel_setspeed, svchan_setspeed),
KOBJMETHOD(channel_setblocksize, svchan_setblocksize),
KOBJMETHOD(channel_trigger, svpchan_trigger),
KOBJMETHOD(channel_getptr, svpchan_getptr),
KOBJMETHOD(channel_getcaps, svchan_getcaps),
}
static struct pcmchan_caps * svchan_getcaps(kobj_t obj, void *data)
Definition: vibes.c:216
static int svpchan_trigger(kobj_t obj, void *data, int go)
Definition: vibes.c:387
static int svchan_setformat(kobj_t obj, void *data, u_int32_t format)
Definition: vibes.c:235
static u_int32_t svpchan_getptr(kobj_t obj, void *data)
Definition: vibes.c:436
static u_int32_t svchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
Definition: vibes.c:222
static void * svchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
Definition: vibes.c:193
static u_int32_t svchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
Definition: vibes.c:246

Definition at line 448 of file vibes.c.

◆ svrchan_methods

kobj_method_t svrchan_methods[]
static
Initial value:
= {
KOBJMETHOD(channel_init, svchan_init),
KOBJMETHOD(channel_setformat, svchan_setformat),
KOBJMETHOD(channel_setspeed, svchan_setspeed),
KOBJMETHOD(channel_setblocksize, svchan_setblocksize),
KOBJMETHOD(channel_trigger, svrchan_trigger),
KOBJMETHOD(channel_getptr, svrchan_getptr),
KOBJMETHOD(channel_getcaps, svchan_getcaps),
}
static int svrchan_trigger(kobj_t obj, void *data, int go)
Definition: vibes.c:315
static u_int32_t svrchan_getptr(kobj_t obj, void *data)
Definition: vibes.c:359

Definition at line 371 of file vibes.c.