FreeBSD kernel sound device code
sb16.c File Reference
#include <dev/sound/pcm/sound.h>
#include <dev/sound/isa/sb.h>
#include <dev/sound/chip.h>
#include <isa/isavar.h>
#include "mixer_if.h"
Include dependency graph for sb16.c:

Go to the source code of this file.

Data Structures

struct  sb_chinfo
 
struct  sb_info
 
struct  sb16_mixent
 

Macros

#define SB16_BUFFSIZE   4096
 
#define PLAIN_SB16(x)   ((((x)->bd_flags) & (BD_F_SB16|BD_F_SB16X)) == BD_F_SB16)
 

Functions

 SND_DECLARE_FILE ("$FreeBSD$")
 
static void sb_lock (struct sb_info *sb)
 
static void sb_lockassert (struct sb_info *sb)
 
static void sb_unlock (struct sb_info *sb)
 
static int port_rd (struct resource *port, int off)
 
static void port_wr (struct resource *port, int off, u_int8_t data)
 
static int sb_rd (struct sb_info *sb, int reg)
 
static void sb_wr (struct sb_info *sb, int reg, u_int8_t val)
 
static int sb_dspwr (struct sb_info *sb, u_char val)
 
static int sb_cmd (struct sb_info *sb, u_char val)
 
static int sb_cmd2 (struct sb_info *sb, u_char cmd, int val)
 
static void sb_setmixer (struct sb_info *sb, u_int port, u_int value)
 
static int sb_getmixer (struct sb_info *sb, u_int port)
 
static u_int sb_get_byte (struct sb_info *sb)
 
static int sb_reset_dsp (struct sb_info *sb)
 
static int sb16mix_init (struct snd_mixer *m)
 
static int rel2abs_volume (int x, int max)
 
static int sb16mix_set (struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
 
static u_int32_t sb16mix_setrecsrc (struct snd_mixer *m, u_int32_t src)
 
 MIXER_DECLARE (sb16mix_mixer)
 
static void sb16_release_resources (struct sb_info *sb, device_t dev)
 
static int sb16_alloc_resources (struct sb_info *sb, device_t dev)
 
static void sb_intr (void *arg)
 
static int sb_setup (struct sb_info *sb)
 
static void * sb16chan_init (kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
 
static int sb16chan_setformat (kobj_t obj, void *data, u_int32_t format)
 
static u_int32_t sb16chan_setspeed (kobj_t obj, void *data, u_int32_t speed)
 
static u_int32_t sb16chan_setblocksize (kobj_t obj, void *data, u_int32_t blocksize)
 
static int sb16chan_trigger (kobj_t obj, void *data, int go)
 
static u_int32_t sb16chan_getptr (kobj_t obj, void *data)
 
static struct pcmchan_capssb16chan_getcaps (kobj_t obj, void *data)
 
static int sb16chan_resetdone (kobj_t obj, void *data)
 
 CHANNEL_DECLARE (sb16chan)
 
static int sb16_probe (device_t dev)
 
static int sb16_attach (device_t dev)
 
static int sb16_detach (device_t dev)
 
 DRIVER_MODULE (snd_sb16, sbc, sb16_driver, pcm_devclass, 0, 0)
 
 MODULE_DEPEND (snd_sb16, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
 
 MODULE_DEPEND (snd_sb16, snd_sbc, 1, 1, 1)
 
 MODULE_VERSION (snd_sb16, 1)
 

Variables

static u_int32_t sb16_fmt8 []
 
static struct pcmchan_caps sb16_caps8 = {5000, 45000, sb16_fmt8, 0}
 
static u_int32_t sb16_fmt16 []
 
static struct pcmchan_caps sb16_caps16 = {5000, 45000, sb16_fmt16, 0}
 
static u_int32_t sb16x_fmt []
 
static struct pcmchan_caps sb16x_caps = {5000, 49000, sb16x_fmt, 0}
 
static const struct sb16_mixent sb16_mixtab [32]
 
static kobj_method_t sb16mix_mixer_methods []
 
static kobj_method_t sb16chan_methods []
 
static device_method_t sb16_methods []
 
static driver_t sb16_driver
 

Macro Definition Documentation

◆ PLAIN_SB16

#define PLAIN_SB16 (   x)    ((((x)->bd_flags) & (BD_F_SB16|BD_F_SB16X)) == BD_F_SB16)

Definition at line 50 of file sb16.c.

◆ SB16_BUFFSIZE

#define SB16_BUFFSIZE   4096

Definition at line 49 of file sb16.c.

Function Documentation

◆ CHANNEL_DECLARE()

CHANNEL_DECLARE ( sb16chan  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( snd_sb16  ,
sbc  ,
sb16_driver  ,
pcm_devclass  ,
,
 
)

◆ MIXER_DECLARE()

MIXER_DECLARE ( sb16mix_mixer  )

◆ MODULE_DEPEND() [1/2]

MODULE_DEPEND ( snd_sb16  ,
snd_sbc  ,
,
,
 
)

◆ MODULE_DEPEND() [2/2]

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

◆ MODULE_VERSION()

MODULE_VERSION ( snd_sb16  ,
 
)

◆ port_rd()

static int port_rd ( struct resource *  port,
int  off 
)
static

Definition at line 142 of file sb16.c.

Referenced by sb_rd().

Here is the caller graph for this function:

◆ port_wr()

static void port_wr ( struct resource *  port,
int  off,
u_int8_t  data 
)
static

Definition at line 148 of file sb16.c.

References data.

Referenced by sb_wr().

Here is the caller graph for this function:

◆ rel2abs_volume()

static int rel2abs_volume ( int  x,
int  max 
)
static

Definition at line 333 of file sb16.c.

References max.

Referenced by sb16mix_set().

Here is the caller graph for this function:

◆ sb16_alloc_resources()

static int sb16_alloc_resources ( struct sb_info sb,
device_t  dev 
)
static

Definition at line 463 of file sb16.c.

References sb_info::bufsize, dev, sb_info::drq1, sb_info::drq2, sb_info::io_base, sb_info::irq, pcm_getflags(), pcm_setflags(), rid, and SD_F_SIMPLEX.

Referenced by sb16_attach().

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

◆ sb16_attach()

◆ sb16_detach()

static int sb16_detach ( device_t  dev)
static

Definition at line 881 of file sb16.c.

References dev, pcm_getdevinfo(), pcm_unregister(), r, and sb16_release_resources().

Here is the call graph for this function:

◆ sb16_probe()

static int sb16_probe ( device_t  dev)
static

Definition at line 788 of file sb16.c.

References BD_F_SB16, BD_F_SB16X, buf, dev, func, r, and SCF_PCM.

◆ sb16_release_resources()

static void sb16_release_resources ( struct sb_info sb,
device_t  dev 
)
static

Definition at line 431 of file sb16.c.

References dev, sb_info::drq1, sb_info::drq2, free, sb_info::ih, sb_info::io_base, sb_info::irq, and sb_info::parent_dmat.

Referenced by sb16_attach(), and sb16_detach().

Here is the caller graph for this function:

◆ sb16chan_getcaps()

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

◆ sb16chan_getptr()

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

Definition at line 742 of file sb16.c.

References sb_chinfo::buffer, data, and sndbuf_dmaptr().

Here is the call graph for this function:

◆ sb16chan_init()

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

Definition at line 675 of file sb16.c.

References b, sb_chinfo::buffer, sb_info::bufsize, c, sb_chinfo::channel, devinfo, sb_chinfo::dir, dir, sb_chinfo::parent, sb_info::parent_dmat, PCMDIR_PLAY, sb_info::rch, and sndbuf_alloc().

Here is the call graph for this function:

◆ sb16chan_resetdone()

static int sb16chan_resetdone ( kobj_t  obj,
void *  data 
)
static

Definition at line 762 of file sb16.c.

References data, sb_chinfo::parent, and sb_info::prio.

◆ sb16chan_setblocksize()

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

Definition at line 714 of file sb16.c.

References sb_chinfo::blksz, blocksize, and data.

◆ sb16chan_setformat()

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

◆ sb16chan_setspeed()

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

Definition at line 705 of file sb16.c.

References data, sb_chinfo::spd, and speed.

◆ sb16chan_trigger()

static int sb16chan_trigger ( kobj_t  obj,
void *  data,
int  go 
)
static

Definition at line 723 of file sb16.c.

References data, go, sb_chinfo::parent, PCMTRIG_COMMON, PCMTRIG_START, sb_chinfo::run, and sb_setup().

Here is the call graph for this function:

◆ sb16mix_init()

static int sb16mix_init ( struct snd_mixer m)
static

Definition at line 312 of file sb16.c.

References m, mix_getdevinfo(), mix_setdevs(), mix_setrecdevs(), and sb_setmixer().

Here is the call graph for this function:

◆ sb16mix_set()

static int sb16mix_set ( struct snd_mixer m,
unsigned  dev,
unsigned  left,
unsigned  right 
)
static

Definition at line 346 of file sb16.c.

References sb16_mixent::bits, dev, left, m, max, mix_getdevinfo(), sb16_mixent::ofs, sb16_mixent::reg, rel2abs_volume(), right, sb16_mixtab, sb_setmixer(), and sb16_mixent::stereo.

Here is the call graph for this function:

◆ sb16mix_setrecsrc()

static u_int32_t sb16mix_setrecsrc ( struct snd_mixer m,
u_int32_t  src 
)
static

Definition at line 371 of file sb16.c.

References m, mix_getdevinfo(), SB16_IMASK_L, SB16_IMASK_R, SB16_OMASK, sb_setmixer(), and src.

Here is the call graph for this function:

◆ sb_cmd()

static int sb_cmd ( struct sb_info sb,
u_char  val 
)
static

Definition at line 184 of file sb16.c.

References sb_dspwr(), and val.

Referenced by sb_setup().

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

◆ sb_cmd2()

static int sb_cmd2 ( struct sb_info sb,
u_char  cmd,
int  val 
)
static

Definition at line 206 of file sb16.c.

References r, sb_dspwr(), sb_lockassert(), and val.

Referenced by sb_setup().

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

◆ sb_dspwr()

static int sb_dspwr ( struct sb_info sb,
u_char  val 
)
static

Definition at line 166 of file sb16.c.

References sb_rd(), sb_wr(), SBDSP_CMD, SBDSP_STATUS, and val.

Referenced by sb_cmd(), and sb_cmd2().

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

◆ sb_get_byte()

static u_int sb_get_byte ( struct sb_info sb)
static

Definition at line 256 of file sb16.c.

References DSP_DATA_AVAIL, DSP_READ, and sb_rd().

Referenced by sb_reset_dsp().

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

◆ sb_getmixer()

static int sb_getmixer ( struct sb_info sb,
u_int  port 
)
static

Definition at line 242 of file sb16.c.

References sb_lockassert(), SB_MIX_ADDR, SB_MIX_DATA, sb_rd(), sb_wr(), and val.

Referenced by sb_intr().

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

◆ sb_intr()

static void sb_intr ( void *  arg)
static

Definition at line 504 of file sb16.c.

References AFMT_16BIT, AFMT_8BIT, BD_F_SB16X, sb_info::bd_flags, c, sb_chinfo::channel, chn_intr(), sb_chinfo::dch, DSP_DATA_AVAIL, DSP_DATA_AVL16, sb_chinfo::fmt, IRQ_STAT, sb_info::rch, sb_chinfo::run, sb_getmixer(), sb_lock(), sb_rd(), and sb_unlock().

Referenced by sb16_attach().

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

◆ sb_lock()

static void sb_lock ( struct sb_info sb)
static

Definition at line 127 of file sb16.c.

References sb_info::parent_dev, and sbc_lock().

Referenced by sb16_attach(), sb_intr(), sb_setmixer(), and sb_setup().

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

◆ sb_lockassert()

static void sb_lockassert ( struct sb_info sb)
static

Definition at line 132 of file sb16.c.

References sb_info::parent_dev, and sbc_lockassert().

Referenced by sb_cmd2(), sb_getmixer(), and sb_reset_dsp().

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

◆ sb_rd()

static int sb_rd ( struct sb_info sb,
int  reg 
)
static

Definition at line 154 of file sb16.c.

References sb_info::io_base, port_rd(), and reg.

Referenced by sb_dspwr(), sb_get_byte(), sb_getmixer(), and sb_intr().

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

◆ sb_reset_dsp()

static int sb_reset_dsp ( struct sb_info sb)
static

Definition at line 270 of file sb16.c.

References b, DEB, sb_info::io_base, sb_get_byte(), sb_lockassert(), sb_wr(), and SBDSP_RST.

Referenced by sb16_attach(), and sb_setup().

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

◆ sb_setmixer()

static void sb_setmixer ( struct sb_info sb,
u_int  port,
u_int  value 
)
static

Definition at line 231 of file sb16.c.

References sb_lock(), SB_MIX_ADDR, SB_MIX_DATA, sb_unlock(), sb_wr(), and value.

Referenced by sb16mix_init(), sb16mix_set(), and sb16mix_setrecsrc().

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

◆ sb_setup()

◆ sb_unlock()

static void sb_unlock ( struct sb_info sb)
static

Definition at line 137 of file sb16.c.

References sb_info::parent_dev, and sbc_unlock().

Referenced by sb16_attach(), sb_intr(), sb_setmixer(), and sb_setup().

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

◆ sb_wr()

static void sb_wr ( struct sb_info sb,
int  reg,
u_int8_t  val 
)
static

Definition at line 160 of file sb16.c.

References sb_info::io_base, port_wr(), reg, and val.

Referenced by sb_dspwr(), sb_getmixer(), sb_reset_dsp(), and sb_setmixer().

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

◆ SND_DECLARE_FILE()

SND_DECLARE_FILE ( "$FreeBSD$"  )

Variable Documentation

◆ sb16_caps16

struct pcmchan_caps sb16_caps16 = {5000, 45000, sb16_fmt16, 0}
static

Definition at line 64 of file sb16.c.

Referenced by sb16chan_getcaps().

◆ sb16_caps8

struct pcmchan_caps sb16_caps8 = {5000, 45000, sb16_fmt8, 0}
static

Definition at line 57 of file sb16.c.

Referenced by sb16chan_getcaps().

◆ sb16_driver

driver_t sb16_driver
static
Initial value:
= {
"pcm",
}
static device_method_t sb16_methods[]
Definition: sb16.c:895
#define PCM_SOFTC_SIZE
Definition: sound.h:96

Definition at line 903 of file sb16.c.

◆ sb16_fmt16

u_int32_t sb16_fmt16[]
static
Initial value:
= {
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 59 of file sb16.c.

◆ sb16_fmt8

u_int32_t sb16_fmt8[]
static
Initial value:
= {
SND_FORMAT(AFMT_U8, 1, 0),
SND_FORMAT(AFMT_U8, 2, 0),
0
}

Definition at line 52 of file sb16.c.

◆ sb16_methods

device_method_t sb16_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, sb16_probe),
DEVMETHOD(device_attach, sb16_attach),
DEVMETHOD(device_detach, sb16_detach),
{ 0, 0 }
}
static int sb16_attach(device_t dev)
Definition: sb16.c:811
static int sb16_detach(device_t dev)
Definition: sb16.c:881
static int sb16_probe(device_t dev)
Definition: sb16.c:788

Definition at line 895 of file sb16.c.

◆ sb16_mixtab

const struct sb16_mixent sb16_mixtab[32]
static
Initial value:
= {
[SOUND_MIXER_VOLUME] = { 0x30, 5, 3, 1 },
[SOUND_MIXER_PCM] = { 0x32, 5, 3, 1 },
[SOUND_MIXER_SYNTH] = { 0x34, 5, 3, 1 },
[SOUND_MIXER_CD] = { 0x36, 5, 3, 1 },
[SOUND_MIXER_LINE] = { 0x38, 5, 3, 1 },
[SOUND_MIXER_MIC] = { 0x3a, 5, 3, 0 },
[SOUND_MIXER_SPEAKER] = { 0x3b, 5, 3, 0 },
[SOUND_MIXER_IGAIN] = { 0x3f, 2, 6, 1 },
[SOUND_MIXER_OGAIN] = { 0x41, 2, 6, 1 },
[SOUND_MIXER_TREBLE] = { 0x44, 4, 4, 1 },
[SOUND_MIXER_BASS] = { 0x46, 4, 4, 1 },
[SOUND_MIXER_LINE1] = { 0x52, 5, 3, 1 }
}

Definition at line 296 of file sb16.c.

Referenced by sb16mix_set().

◆ sb16chan_methods

kobj_method_t sb16chan_methods[]
static
Initial value:
= {
KOBJMETHOD(channel_init, sb16chan_init),
KOBJMETHOD(channel_resetdone, sb16chan_resetdone),
KOBJMETHOD(channel_setformat, sb16chan_setformat),
KOBJMETHOD(channel_setspeed, sb16chan_setspeed),
KOBJMETHOD(channel_setblocksize, sb16chan_setblocksize),
KOBJMETHOD(channel_trigger, sb16chan_trigger),
KOBJMETHOD(channel_getptr, sb16chan_getptr),
KOBJMETHOD(channel_getcaps, sb16chan_getcaps),
}
#define KOBJMETHOD_END
Definition: midi.c:76
static u_int32_t sb16chan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
Definition: sb16.c:714
static int sb16chan_setformat(kobj_t obj, void *data, u_int32_t format)
Definition: sb16.c:692
static int sb16chan_trigger(kobj_t obj, void *data, int go)
Definition: sb16.c:723
static u_int32_t sb16chan_setspeed(kobj_t obj, void *data, u_int32_t speed)
Definition: sb16.c:705
static u_int32_t sb16chan_getptr(kobj_t obj, void *data)
Definition: sb16.c:742
static struct pcmchan_caps * sb16chan_getcaps(kobj_t obj, void *data)
Definition: sb16.c:750
static void * sb16chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
Definition: sb16.c:675
static int sb16chan_resetdone(kobj_t obj, void *data)
Definition: sb16.c:762

Definition at line 772 of file sb16.c.

◆ sb16mix_mixer_methods

kobj_method_t sb16mix_mixer_methods[]
static
Initial value:
= {
KOBJMETHOD(mixer_init, sb16mix_init),
KOBJMETHOD(mixer_set, sb16mix_set),
}
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 sb16mix_init(struct snd_mixer *m)
Definition: sb16.c:312
static int sb16mix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
Definition: sb16.c:346
static u_int32_t sb16mix_setrecsrc(struct snd_mixer *m, u_int32_t src)
Definition: sb16.c:371

Definition at line 420 of file sb16.c.

◆ sb16x_caps

struct pcmchan_caps sb16x_caps = {5000, 49000, sb16x_fmt, 0}
static

Definition at line 73 of file sb16.c.

Referenced by sb16chan_getcaps().

◆ sb16x_fmt

u_int32_t sb16x_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
}

Definition at line 66 of file sb16.c.