FreeBSD kernel sound device code
sb8.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 sb8.c:

Go to the source code of this file.

Data Structures

struct  sb_chinfo
 
struct  sb_info
 

Macros

#define SB_DEFAULT_BUFSZ   4096
 

Functions

 SND_DECLARE_FILE ("$FreeBSD$")
 
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_dspready (struct sb_info *sb)
 
static int sb_cmd (struct sb_info *sb, u_char val)
 
static int sb_cmd1 (struct sb_info *sb, u_char cmd, int val)
 
static int sb_cmd2 (struct sb_info *sb, u_char cmd, int val)
 
static u_int sb_get_byte (struct sb_info *sb)
 
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 int sb_reset_dsp (struct sb_info *sb)
 
static void sb_intr (void *arg)
 
static int sb_speed (struct sb_chinfo *ch)
 
static int sb_start (struct sb_chinfo *ch)
 
static int sb_stop (struct sb_chinfo *ch)
 
static void sb_lock (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_dspwr (struct sb_info *sb, u_char val)
 
static void sb_release_resources (struct sb_info *sb, device_t dev)
 
static int sb_alloc_resources (struct sb_info *sb, device_t dev)
 
static int sbpromix_init (struct snd_mixer *m)
 
static int sbpromix_set (struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
 
static u_int32_t sbpromix_setrecsrc (struct snd_mixer *m, u_int32_t src)
 
 MIXER_DECLARE (sbpromix_mixer)
 
static int sbmix_init (struct snd_mixer *m)
 
static int sbmix_set (struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
 
static u_int32_t sbmix_setrecsrc (struct snd_mixer *m, u_int32_t src)
 
 MIXER_DECLARE (sbmix_mixer)
 
static void * sbchan_init (kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
 
static int sbchan_setformat (kobj_t obj, void *data, u_int32_t format)
 
static u_int32_t sbchan_setspeed (kobj_t obj, void *data, u_int32_t speed)
 
static u_int32_t sbchan_setblocksize (kobj_t obj, void *data, u_int32_t blocksize)
 
static int sbchan_trigger (kobj_t obj, void *data, int go)
 
static u_int32_t sbchan_getptr (kobj_t obj, void *data)
 
static struct pcmchan_capssbchan_getcaps (kobj_t obj, void *data)
 
 CHANNEL_DECLARE (sbchan)
 
static int sb_probe (device_t dev)
 
static int sb_attach (device_t dev)
 
static int sb_detach (device_t dev)
 
 DRIVER_MODULE (snd_sb8, sbc, sb_driver, pcm_devclass, 0, 0)
 
 MODULE_DEPEND (snd_sb8, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
 
 MODULE_DEPEND (snd_sb8, snd_sbc, 1, 1, 1)
 
 MODULE_VERSION (snd_sb8, 1)
 

Variables

static u_int32_t sb_fmt []
 
static struct pcmchan_caps sb200_playcaps = {4000, 23000, sb_fmt, 0}
 
static struct pcmchan_caps sb200_reccaps = {4000, 13000, sb_fmt, 0}
 
static struct pcmchan_caps sb201_playcaps = {4000, 44100, sb_fmt, 0}
 
static struct pcmchan_caps sb201_reccaps = {4000, 15000, sb_fmt, 0}
 
static u_int32_t sbpro_fmt []
 
static struct pcmchan_caps sbpro_playcaps = {4000, 44100, sbpro_fmt, 0}
 
static struct pcmchan_caps sbpro_reccaps = {4000, 44100, sbpro_fmt, 0}
 
static kobj_method_t sbpromix_mixer_methods []
 
static kobj_method_t sbmix_mixer_methods []
 
static kobj_method_t sbchan_methods []
 
static device_method_t sb_methods []
 
static driver_t sb_driver
 

Macro Definition Documentation

◆ SB_DEFAULT_BUFSZ

#define SB_DEFAULT_BUFSZ   4096

Definition at line 49 of file sb8.c.

Function Documentation

◆ CHANNEL_DECLARE()

CHANNEL_DECLARE ( sbchan  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( snd_sb8  ,
sbc  ,
sb_driver  ,
pcm_devclass  ,
,
 
)

◆ MIXER_DECLARE() [1/2]

MIXER_DECLARE ( sbmix_mixer  )

◆ MIXER_DECLARE() [2/2]

MIXER_DECLARE ( sbpromix_mixer  )

◆ MODULE_DEPEND() [1/2]

MODULE_DEPEND ( snd_sb8  ,
snd_sbc  ,
,
,
 
)

◆ MODULE_DEPEND() [2/2]

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

◆ MODULE_VERSION()

MODULE_VERSION ( snd_sb8  ,
 
)

◆ port_rd()

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

Definition at line 128 of file sb8.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 134 of file sb8.c.

References data.

Referenced by sb_wr().

Here is the caller graph for this function:

◆ sb_alloc_resources()

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

Definition at line 287 of file sb8.c.

References sb_info::bufsize, dev, sb_info::drq, sb_info::io_base, sb_info::irq, and rid.

Referenced by sb_attach().

Here is the caller graph for this function:

◆ sb_attach()

◆ sb_cmd()

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

Definition at line 174 of file sb8.c.

References sb_dspwr(), and val.

Referenced by sb_start(), and sb_stop().

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

◆ sb_cmd1()

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

Definition at line 183 of file sb8.c.

References sb_dspwr(), and val.

Referenced by sb_speed().

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 194 of file sb8.c.

References sb_dspwr(), and val.

Referenced by sb_start().

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

◆ sb_detach()

static int sb_detach ( device_t  dev)
static

Definition at line 772 of file sb8.c.

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

Here is the call graph for this function:

◆ sb_dspready()

static int sb_dspready ( struct sb_info sb)
static

Definition at line 152 of file sb8.c.

References sb_rd(), and SBDSP_STATUS.

Referenced by sb_dspwr().

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 158 of file sb8.c.

References sb_dspready(), sb_wr(), SBDSP_CMD, and val.

Referenced by sb_cmd(), sb_cmd1(), 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 234 of file sb8.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 221 of file sb8.c.

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

Referenced by sbpromix_setrecsrc().

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 477 of file sb8.c.

References sb_chinfo::buffer, sb_chinfo::channel, chn_intr(), DSP_DATA_AVAIL, sb_info::rch, sb_lock(), sb_rd(), sb_unlock(), and sndbuf_runsz().

Referenced by sb_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 118 of file sb8.c.

References sb_info::parent_dev, and sbc_lock().

Referenced by sb_intr(), sb_speed(), sb_start(), and sb_stop().

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

◆ sb_probe()

static int sb_probe ( device_t  dev)
static

Definition at line 691 of file sb8.c.

References BD_F_ESS, buf, dev, func, r, and SCF_PCM.

◆ sb_rd()

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

Definition at line 140 of file sb8.c.

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

Referenced by sb_dspready(), 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_release_resources()

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

Definition at line 262 of file sb8.c.

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

Referenced by sb_attach(), and sb_detach().

Here is the caller graph for this function:

◆ sb_reset_dsp()

static int sb_reset_dsp ( struct sb_info sb)
static

Definition at line 248 of file sb8.c.

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

Referenced by sb_attach(), and sb_stop().

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 212 of file sb8.c.

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

Referenced by sb_start(), sbmix_init(), sbmix_set(), sbpromix_init(), sbpromix_set(), and sbpromix_setrecsrc().

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

◆ sb_speed()

static int sb_speed ( struct sb_chinfo ch)
static

Definition at line 499 of file sb8.c.

References AFMT_CHANNEL, BD_F_HISPEED, sb_info::bd_flags, sb_info::bd_id, sb_chinfo::dir, sb_chinfo::fmt, max, sb_chinfo::parent, PCMDIR_PLAY, sb_cmd1(), sb_lock(), sb_unlock(), sb_chinfo::spd, speed, and stereo.

Referenced by sbchan_setspeed().

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

◆ sb_start()

static int sb_start ( struct sb_chinfo ch)
static

Definition at line 540 of file sb8.c.

References AFMT_CHANNEL, BD_F_DMARUN, BD_F_HISPEED, sb_info::bd_flags, sb_chinfo::blksz, sb_chinfo::dir, DSP_CMD_SPKON, sb_chinfo::fmt, sb_chinfo::parent, PCMDIR_PLAY, sb_cmd(), sb_cmd2(), sb_lock(), sb_setmixer(), sb_unlock(), and stereo.

Referenced by sbchan_trigger().

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

◆ sb_stop()

static int sb_stop ( struct sb_chinfo ch)
static

Definition at line 569 of file sb8.c.

References BD_F_HISPEED, sb_info::bd_flags, sb_chinfo::dir, DSP_CMD_DMAEXIT_8, DSP_CMD_SPKOFF, sb_chinfo::parent, PCMDIR_PLAY, sb_cmd(), sb_lock(), sb_reset_dsp(), and sb_unlock().

Referenced by sbchan_trigger().

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

◆ sb_unlock()

static void sb_unlock ( struct sb_info sb)
static

Definition at line 123 of file sb8.c.

References sb_info::parent_dev, and sbc_unlock().

Referenced by sb_intr(), sb_speed(), sb_start(), and sb_stop().

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 146 of file sb8.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:

◆ sbchan_getcaps()

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

◆ sbchan_getptr()

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

Definition at line 656 of file sb8.c.

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

Here is the call graph for this function:

◆ sbchan_init()

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

◆ sbchan_setblocksize()

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

Definition at line 631 of file sb8.c.

References sb_chinfo::blksz, blocksize, and data.

◆ sbchan_setformat()

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

Definition at line 613 of file sb8.c.

References data, sb_chinfo::fmt, and format.

◆ sbchan_setspeed()

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

Definition at line 622 of file sb8.c.

References data, sb_speed(), sb_chinfo::spd, and speed.

Here is the call graph for this function:

◆ sbchan_trigger()

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

Definition at line 640 of file sb8.c.

References sb_chinfo::buffer, data, go, PCMTRIG_COMMON, PCMTRIG_START, sb_start(), sb_stop(), and sndbuf_dma().

Here is the call graph for this function:

◆ sbmix_init()

static int sbmix_init ( struct snd_mixer m)
static

Definition at line 409 of file sb8.c.

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

Here is the call graph for this function:

◆ sbmix_set()

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

Definition at line 423 of file sb8.c.

References dev, left, m, max, mix_getdevinfo(), reg, and sb_setmixer().

Here is the call graph for this function:

◆ sbmix_setrecsrc()

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

Definition at line 461 of file sb8.c.

◆ sbpromix_init()

static int sbpromix_init ( struct snd_mixer m)
static

Definition at line 315 of file sb8.c.

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

Here is the call graph for this function:

◆ sbpromix_set()

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

Definition at line 330 of file sb8.c.

References dev, left, m, max, mix_getdevinfo(), reg, right, sb_setmixer(), and val.

Here is the call graph for this function:

◆ sbpromix_setrecsrc()

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

Definition at line 380 of file sb8.c.

References m, mix_getdevinfo(), RECORD_SRC, sb_getmixer(), sb_setmixer(), and src.

Here is the call graph for this function:

◆ SND_DECLARE_FILE()

SND_DECLARE_FILE ( "$FreeBSD$"  )

Variable Documentation

◆ sb200_playcaps

struct pcmchan_caps sb200_playcaps = {4000, 23000, sb_fmt, 0}
static

Definition at line 55 of file sb8.c.

Referenced by sbchan_getcaps().

◆ sb200_reccaps

struct pcmchan_caps sb200_reccaps = {4000, 13000, sb_fmt, 0}
static

Definition at line 56 of file sb8.c.

Referenced by sbchan_getcaps().

◆ sb201_playcaps

struct pcmchan_caps sb201_playcaps = {4000, 44100, sb_fmt, 0}
static

Definition at line 57 of file sb8.c.

Referenced by sbchan_getcaps().

◆ sb201_reccaps

struct pcmchan_caps sb201_reccaps = {4000, 15000, sb_fmt, 0}
static

Definition at line 58 of file sb8.c.

Referenced by sbchan_getcaps().

◆ sb_driver

driver_t sb_driver
static
Initial value:
= {
"pcm",
}
static device_method_t sb_methods[]
Definition: sb8.c:786
#define PCM_SOFTC_SIZE
Definition: sound.h:96

Definition at line 794 of file sb8.c.

◆ sb_fmt

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

Definition at line 51 of file sb8.c.

◆ sb_methods

device_method_t sb_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, sb_probe),
DEVMETHOD(device_attach, sb_attach),
DEVMETHOD(device_detach, sb_detach),
{ 0, 0 }
}
static int sb_detach(device_t dev)
Definition: sb8.c:772
static int sb_probe(device_t dev)
Definition: sb8.c:691
static int sb_attach(device_t dev)
Definition: sb8.c:715

Definition at line 786 of file sb8.c.

◆ sbchan_methods

kobj_method_t sbchan_methods[]
static
Initial value:
= {
KOBJMETHOD(channel_init, sbchan_init),
KOBJMETHOD(channel_setformat, sbchan_setformat),
KOBJMETHOD(channel_setspeed, sbchan_setspeed),
KOBJMETHOD(channel_setblocksize, sbchan_setblocksize),
KOBJMETHOD(channel_trigger, sbchan_trigger),
KOBJMETHOD(channel_getptr, sbchan_getptr),
KOBJMETHOD(channel_getcaps, sbchan_getcaps),
}
#define KOBJMETHOD_END
Definition: midi.c:76
static u_int32_t sbchan_getptr(kobj_t obj, void *data)
Definition: sb8.c:656
static int sbchan_trigger(kobj_t obj, void *data, int go)
Definition: sb8.c:640
static int sbchan_setformat(kobj_t obj, void *data, u_int32_t format)
Definition: sb8.c:613
static struct pcmchan_caps * sbchan_getcaps(kobj_t obj, void *data)
Definition: sb8.c:664
static void * sbchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
Definition: sb8.c:597
static u_int32_t sbchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
Definition: sb8.c:631
static u_int32_t sbchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
Definition: sb8.c:622

Definition at line 676 of file sb8.c.

◆ sbmix_mixer_methods

kobj_method_t sbmix_mixer_methods[]
static
Initial value:
= {
KOBJMETHOD(mixer_init, sbmix_init),
KOBJMETHOD(mixer_set, sbmix_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 u_int32_t sbmix_setrecsrc(struct snd_mixer *m, u_int32_t src)
Definition: sb8.c:461
static int sbmix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
Definition: sb8.c:423
static int sbmix_init(struct snd_mixer *m)
Definition: sb8.c:409

Definition at line 466 of file sb8.c.

◆ sbpro_fmt

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

Definition at line 60 of file sb8.c.

◆ sbpro_playcaps

struct pcmchan_caps sbpro_playcaps = {4000, 44100, sbpro_fmt, 0}
static

Definition at line 65 of file sb8.c.

Referenced by sbchan_getcaps().

◆ sbpro_reccaps

struct pcmchan_caps sbpro_reccaps = {4000, 44100, sbpro_fmt, 0}
static

Definition at line 66 of file sb8.c.

Referenced by sbchan_getcaps().

◆ sbpromix_mixer_methods

kobj_method_t sbpromix_mixer_methods[]
static
Initial value:
= {
KOBJMETHOD(mixer_init, sbpromix_init),
KOBJMETHOD(mixer_set, sbpromix_set),
}
static int sbpromix_init(struct snd_mixer *m)
Definition: sb8.c:315
static u_int32_t sbpromix_setrecsrc(struct snd_mixer *m, u_int32_t src)
Definition: sb8.c:380
static int sbpromix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
Definition: sb8.c:330

Definition at line 398 of file sb8.c.