FreeBSD kernel sound device code
cs4281.c File Reference
Include dependency graph for cs4281.c:

Go to the source code of this file.

Data Structures

struct  sc_chinfo
 
struct  sc_info
 

Macros

#define CS4281_DEFAULT_BUFSZ   16384
 
#define CS4281_FIFO_SIZE   15
 
#define CS4281_DMA_PLAY   0
 
#define CS4281_DMA_REC   1
 
#define inline   __inline
 
#define DEB(x)   /* x */
 
#define CS4281_NUM_RATES   sizeof(cs4281_rates)/sizeof(cs4281_rates[0])
 

Functions

 SND_DECLARE_FILE ("$FreeBSD$")
 
static u_int32_t adcdac_go (struct sc_chinfo *ch, u_int32_t go)
 
static void adcdac_prog (struct sc_chinfo *ch)
 
static void cs4281_intr (void *)
 
static int cs4281_power (struct sc_info *, int)
 
static int cs4281_init (struct sc_info *)
 
static u_int32_t cs4281_rd (struct sc_info *, int)
 
static void cs4281_wr (struct sc_info *, int, u_int32_t)
 
static u_int8_t cs4281_rate_to_rv (u_int32_t)
 
static u_int32_t cs4281_format_to_dmr (u_int32_t)
 
static u_int32_t cs4281_format_to_bps (u_int32_t)
 
static void cs4281_clr4 (struct sc_info *sc, int regno, u_int32_t mask)
 
static void cs4281_set4 (struct sc_info *sc, int regno, u_int32_t mask)
 
static int cs4281_waitset (struct sc_info *sc, int regno, u_int32_t mask, int tries)
 
static int cs4281_waitclr (struct sc_info *sc, int regno, u_int32_t mask, int tries)
 
static u_int32_t cs4281_rv_to_rate (u_int8_t rv)
 
static int cs4281_rdcd (kobj_t obj, void *devinfo, int regno)
 
static int cs4281_wrcd (kobj_t obj, void *devinfo, int regno, u_int32_t data)
 
 AC97_DECLARE (cs4281_ac97)
 
static void * cs4281chan_init (kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
 
static u_int32_t cs4281chan_setblocksize (kobj_t obj, void *data, u_int32_t blocksize)
 
static u_int32_t cs4281chan_setspeed (kobj_t obj, void *data, u_int32_t speed)
 
static int cs4281chan_setformat (kobj_t obj, void *data, u_int32_t format)
 
static u_int32_t cs4281chan_getptr (kobj_t obj, void *data)
 
static int cs4281chan_trigger (kobj_t obj, void *data, int go)
 
static struct pcmchan_capscs4281chan_getcaps (kobj_t obj, void *data)
 
 CHANNEL_DECLARE (cs4281chan)
 
static int cs4281_pci_probe (device_t dev)
 
static int cs4281_pci_attach (device_t dev)
 
static int cs4281_pci_detach (device_t dev)
 
static int cs4281_pci_suspend (device_t dev)
 
static int cs4281_pci_resume (device_t dev)
 
 DRIVER_MODULE (snd_cs4281, pci, cs4281_driver, pcm_devclass, 0, 0)
 
 MODULE_DEPEND (snd_cs4281, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
 
 MODULE_VERSION (snd_cs4281, 1)
 

Variables

static u_int32_t cs4281_fmts []
 
static struct pcmchan_caps cs4281_caps = {6024, 48000, cs4281_fmts, 0}
 
static u_int32_t cs4281_rates [] = {48000, 44100, 22050, 16000, 11025, 8000}
 
static kobj_method_t cs4281_ac97_methods []
 
static kobj_method_t cs4281chan_methods []
 
static device_method_t cs4281_methods []
 
static driver_t cs4281_driver
 

Macro Definition Documentation

◆ CS4281_DEFAULT_BUFSZ

#define CS4281_DEFAULT_BUFSZ   16384

Definition at line 50 of file cs4281.c.

◆ CS4281_DMA_PLAY

#define CS4281_DMA_PLAY   0

Definition at line 56 of file cs4281.c.

◆ CS4281_DMA_REC

#define CS4281_DMA_REC   1

Definition at line 57 of file cs4281.c.

◆ CS4281_FIFO_SIZE

#define CS4281_FIFO_SIZE   15

Definition at line 53 of file cs4281.c.

◆ CS4281_NUM_RATES

#define CS4281_NUM_RATES   sizeof(cs4281_rates)/sizeof(cs4281_rates[0])

Definition at line 209 of file cs4281.c.

◆ DEB

#define DEB (   x)    /* x */

Definition at line 64 of file cs4281.c.

◆ inline

#define inline   __inline

Definition at line 61 of file cs4281.c.

Function Documentation

◆ AC97_DECLARE()

AC97_DECLARE ( cs4281_ac97  )

◆ adcdac_go()

static u_int32_t adcdac_go ( struct sc_chinfo ch,
u_int32_t  go 
)
static

◆ adcdac_prog()

static void adcdac_prog ( struct sc_chinfo ch)
static

Definition at line 494 of file cs4281.c.

References adcdac_go(), sc_chinfo::bps, sc_chinfo::buffer, sc_info::ch, cs4281_wr(), CS4281PCI_DBA, CS4281PCI_DBC, sc_chinfo::dma_chan, sc_chinfo::dma_setup, go, sc_chinfo::parent, sndbuf_getbufaddr(), and sndbuf_getsize().

Referenced by cs4281chan_init(), cs4281chan_setblocksize(), and cs4281chan_trigger().

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

◆ CHANNEL_DECLARE()

CHANNEL_DECLARE ( cs4281chan  )

◆ cs4281_clr4()

static void cs4281_clr4 ( struct sc_info sc,
int  regno,
u_int32_t  mask 
)
inlinestatic

Definition at line 162 of file cs4281.c.

References cs4281_rd(), cs4281_wr(), mask, r, and regno.

Referenced by adcdac_go(), cs4281_init(), and cs4281_power().

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

◆ cs4281_format_to_bps()

static u_int32_t cs4281_format_to_bps ( u_int32_t  format)
inlinestatic

Definition at line 247 of file cs4281.c.

References AFMT_8BIT, AFMT_CHANNEL, and format.

Referenced by cs4281chan_setformat().

Here is the caller graph for this function:

◆ cs4281_format_to_dmr()

static u_int32_t cs4281_format_to_dmr ( u_int32_t  format)
inlinestatic

Definition at line 236 of file cs4281.c.

References AFMT_8BIT, AFMT_BIGENDIAN, AFMT_CHANNEL, AFMT_SIGNED, CS4281PCI_DMR_BEND, CS4281PCI_DMR_MONO, CS4281PCI_DMR_SIZE8, CS4281PCI_DMR_USIGN, and format.

Referenced by cs4281chan_setformat().

Here is the caller graph for this function:

◆ cs4281_init()

static int cs4281_init ( struct sc_info sc)
static

◆ cs4281_intr()

static void cs4281_intr ( void *  p)
static

Definition at line 514 of file cs4281.c.

References sc_chinfo::channel, chn_intr(), CS4281_DMA_PLAY, CS4281_DMA_REC, cs4281_rd(), cs4281_wr(), CS4281PCI_HDSR, CS4281PCI_HICR, CS4281PCI_HICR_EOI, CS4281PCI_HISR, CS4281PCI_HISR_DMA, sc_info::pch, and sc_info::rch.

Referenced by cs4281_pci_attach().

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

◆ cs4281_pci_attach()

◆ cs4281_pci_detach()

static int cs4281_pci_detach ( device_t  dev)
static

◆ cs4281_pci_probe()

static int cs4281_pci_probe ( device_t  dev)
static

Definition at line 745 of file cs4281.c.

References CS4281_PCI_ID, and dev.

◆ cs4281_pci_resume()

static int cs4281_pci_resume ( device_t  dev)
static

◆ cs4281_pci_suspend()

static int cs4281_pci_suspend ( device_t  dev)
static

Definition at line 905 of file cs4281.c.

References adcdac_go(), cs4281_power(), dev, sc_chinfo::dma_active, sc_info::pch, pcm_getdevinfo(), and sc_info::rch.

Here is the call graph for this function:

◆ cs4281_power()

static int cs4281_power ( struct sc_info sc,
int  state 
)
static

Definition at line 541 of file cs4281.c.

References cs4281_clr4(), cs4281_set4(), cs4281_wr(), CS4281PCI_CWPR, CS4281PCI_CWPR_MAGIC, CS4281PCI_EPPMC, CS4281PCI_EPPMC_FPDN, CS4281PCI_SPMC, CS4281PCI_SPMC_RSTN, DEB, sc_info::power, and state.

Referenced by cs4281_pci_attach(), cs4281_pci_detach(), cs4281_pci_resume(), and cs4281_pci_suspend().

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

◆ cs4281_rate_to_rv()

static u_int8_t cs4281_rate_to_rv ( u_int32_t  rate)
static

Definition at line 212 of file cs4281.c.

References CS4281_NUM_RATES, cs4281_rates, and rate.

Referenced by cs4281chan_setspeed().

Here is the caller graph for this function:

◆ cs4281_rd()

static u_int32_t cs4281_rd ( struct sc_info sc,
int  regno 
)
inlinestatic

Definition at line 149 of file cs4281.c.

References regno, sc_info::sh, and sc_info::st.

Referenced by adcdac_go(), cs4281_clr4(), cs4281_intr(), cs4281_rdcd(), cs4281_set4(), cs4281_waitset(), and cs4281chan_getptr().

Here is the caller graph for this function:

◆ cs4281_rdcd()

static int cs4281_rdcd ( kobj_t  obj,
void *  devinfo,
int  regno 
)
static

◆ cs4281_rv_to_rate()

static u_int32_t cs4281_rv_to_rate ( u_int8_t  rv)
static

Definition at line 226 of file cs4281.c.

References CS4281_NUM_RATES, cs4281_rates, and r.

Referenced by cs4281chan_setspeed().

Here is the caller graph for this function:

◆ cs4281_set4()

static void cs4281_set4 ( struct sc_info sc,
int  regno,
u_int32_t  mask 
)
inlinestatic

Definition at line 170 of file cs4281.c.

References cs4281_rd(), cs4281_wr(), mask, and regno.

Referenced by adcdac_go(), cs4281_init(), and cs4281_power().

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

◆ cs4281_waitclr()

static int cs4281_waitclr ( struct sc_info sc,
int  regno,
u_int32_t  mask,
int  tries 
)
static

Definition at line 192 of file cs4281.c.

References mask, and regno.

Referenced by cs4281_rdcd(), and cs4281_wrcd().

Here is the caller graph for this function:

◆ cs4281_waitset()

static int cs4281_waitset ( struct sc_info sc,
int  regno,
u_int32_t  mask,
int  tries 
)
static

Definition at line 178 of file cs4281.c.

References cs4281_rd(), mask, and regno.

Referenced by cs4281_init(), and cs4281_rdcd().

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

◆ cs4281_wr()

static void cs4281_wr ( struct sc_info sc,
int  regno,
u_int32_t  data 
)
inlinestatic

Definition at line 155 of file cs4281.c.

References data, regno, sc_info::sh, and sc_info::st.

Referenced by adcdac_go(), adcdac_prog(), cs4281_clr4(), cs4281_init(), cs4281_intr(), cs4281_power(), cs4281_rdcd(), cs4281_set4(), cs4281_wrcd(), cs4281chan_setformat(), and cs4281chan_setspeed().

Here is the caller graph for this function:

◆ cs4281_wrcd()

static int cs4281_wrcd ( kobj_t  obj,
void *  devinfo,
int  regno,
u_int32_t  data 
)
static

Definition at line 291 of file cs4281.c.

References cs4281_waitclr(), cs4281_wr(), CS4281PCI_ACCAD, CS4281PCI_ACCDA, CS4281PCI_ACCTL, CS4281PCI_ACCTL_DCV, CS4281PCI_ACCTL_ESYN, CS4281PCI_ACCTL_VFRM, data, sc_info::dev, devinfo, and regno.

Referenced by cs4281_init().

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

◆ cs4281chan_getcaps()

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

Definition at line 452 of file cs4281.c.

References cs4281_caps.

◆ cs4281chan_getptr()

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

Definition at line 414 of file cs4281.c.

References sc_chinfo::buffer, sc_info::ch, cs4281_rd(), CS4281PCI_DBA, CS4281PCI_DCA, data, sc_chinfo::dma_chan, sc_chinfo::parent, and sndbuf_getsize().

Here is the call graph for this function:

◆ cs4281chan_init()

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

◆ cs4281chan_setblocksize()

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

Definition at line 349 of file cs4281.c.

References adcdac_go(), adcdac_prog(), sc_chinfo::blksz, blocksize, sc_chinfo::buffer, sc_info::bufsz, sc_info::ch, data, DEB, sc_chinfo::dma_setup, go, sc_chinfo::parent, and sndbuf_resize().

Referenced by cs4281_pci_resume().

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

◆ cs4281chan_setformat()

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

◆ cs4281chan_setspeed()

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

Definition at line 371 of file cs4281.c.

References adcdac_go(), sc_info::ch, CS4281_DMA_PLAY, cs4281_rate_to_rv(), cs4281_rv_to_rate(), cs4281_wr(), CS4281PCI_ADCSR, CS4281PCI_DACSR, data, sc_chinfo::dma_chan, go, sc_chinfo::parent, r, sc_chinfo::spd, and speed.

Referenced by cs4281_pci_resume().

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

◆ cs4281chan_trigger()

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

Definition at line 430 of file cs4281.c.

References adcdac_go(), adcdac_prog(), data, go, PCMTRIG_ABORT, PCMTRIG_START, and PCMTRIG_STOP.

Here is the call graph for this function:

◆ DRIVER_MODULE()

DRIVER_MODULE ( snd_cs4281  ,
pci  ,
cs4281_driver  ,
pcm_devclass  ,
,
 
)

◆ MODULE_DEPEND()

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

◆ MODULE_VERSION()

MODULE_VERSION ( snd_cs4281  ,
 
)

◆ SND_DECLARE_FILE()

SND_DECLARE_FILE ( "$FreeBSD$"  )

Variable Documentation

◆ cs4281_ac97_methods

kobj_method_t cs4281_ac97_methods[]
static
Initial value:
= {
KOBJMETHOD(ac97_read, cs4281_rdcd),
KOBJMETHOD(ac97_write, cs4281_wrcd),
}
static int cs4281_rdcd(kobj_t obj, void *devinfo, int regno)
Definition: cs4281.c:257
static int cs4281_wrcd(kobj_t obj, void *devinfo, int regno, u_int32_t data)
Definition: cs4281.c:291
#define KOBJMETHOD_END
Definition: midi.c:76

Definition at line 311 of file cs4281.c.

◆ cs4281_caps

struct pcmchan_caps cs4281_caps = {6024, 48000, cs4281_fmts, 0}
static

Definition at line 143 of file cs4281.c.

Referenced by cs4281chan_getcaps().

◆ cs4281_driver

driver_t cs4281_driver
static
Initial value:
= {
"pcm",
}
static device_method_t cs4281_methods[]
Definition: cs4281.c:955
#define PCM_SOFTC_SIZE
Definition: sound.h:96

Definition at line 965 of file cs4281.c.

◆ cs4281_fmts

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

Definition at line 127 of file cs4281.c.

◆ cs4281_methods

device_method_t cs4281_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, cs4281_pci_probe),
DEVMETHOD(device_attach, cs4281_pci_attach),
DEVMETHOD(device_detach, cs4281_pci_detach),
DEVMETHOD(device_suspend, cs4281_pci_suspend),
DEVMETHOD(device_resume, cs4281_pci_resume),
{ 0, 0 }
}
static int cs4281_pci_resume(device_t dev)
Definition: cs4281.c:920
static int cs4281_pci_attach(device_t dev)
Definition: cs4281.c:761
static int cs4281_pci_detach(device_t dev)
Definition: cs4281.c:880
static int cs4281_pci_suspend(device_t dev)
Definition: cs4281.c:905
static int cs4281_pci_probe(device_t dev)
Definition: cs4281.c:745

Definition at line 955 of file cs4281.c.

◆ cs4281_rates

u_int32_t cs4281_rates[] = {48000, 44100, 22050, 16000, 11025, 8000}
static

Definition at line 208 of file cs4281.c.

Referenced by cs4281_rate_to_rv(), and cs4281_rv_to_rate().

◆ cs4281chan_methods

kobj_method_t cs4281chan_methods[]
static
Initial value:
= {
KOBJMETHOD(channel_init, cs4281chan_init),
KOBJMETHOD(channel_setformat, cs4281chan_setformat),
KOBJMETHOD(channel_setspeed, cs4281chan_setspeed),
KOBJMETHOD(channel_setblocksize, cs4281chan_setblocksize),
KOBJMETHOD(channel_trigger, cs4281chan_trigger),
KOBJMETHOD(channel_getptr, cs4281chan_getptr),
KOBJMETHOD(channel_getcaps, cs4281chan_getcaps),
}
static struct pcmchan_caps * cs4281chan_getcaps(kobj_t obj, void *data)
Definition: cs4281.c:452
static u_int32_t cs4281chan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
Definition: cs4281.c:349
static u_int32_t cs4281chan_getptr(kobj_t obj, void *data)
Definition: cs4281.c:414
static int cs4281chan_trigger(kobj_t obj, void *data, int go)
Definition: cs4281.c:430
static void * cs4281chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
Definition: cs4281.c:322
static int cs4281chan_setformat(kobj_t obj, void *data, u_int32_t format)
Definition: cs4281.c:388
static u_int32_t cs4281chan_setspeed(kobj_t obj, void *data, u_int32_t speed)
Definition: cs4281.c:371

Definition at line 457 of file cs4281.c.