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

Go to the source code of this file.

Data Structures

struct  sc_chinfo
 
struct  sc_info
 
struct  playback_command
 
struct  sb16props
 

Macros

#define DEB(x)   /* x */
 
#define ALS_DEFAULT_BUFSZ   16384
 
#define ALS_8BIT_CMD(x, y)   { (x), (y), DSP_DMA8, DSP_CMD_DMAPAUSE_8 }
 
#define ALS_16BIT_CMD(x, y)   { (x), (y), DSP_DMA16, DSP_CMD_DMAPAUSE_16 }
 

Functions

 SND_DECLARE_FILE ("$FreeBSD$")
 
static u_int32_t als_gcr_rd (struct sc_info *sc, int index)
 
static void als_gcr_wr (struct sc_info *sc, int index, int data)
 
static u_int8_t als_intr_rd (struct sc_info *sc)
 
static void als_intr_wr (struct sc_info *sc, u_int8_t data)
 
static u_int8_t als_mix_rd (struct sc_info *sc, u_int8_t index)
 
static void als_mix_wr (struct sc_info *sc, u_int8_t index, u_int8_t data)
 
static void als_esp_wr (struct sc_info *sc, u_int8_t data)
 
static int als_esp_reset (struct sc_info *sc)
 
static u_int8_t als_ack_read (struct sc_info *sc, u_int8_t addr)
 
static void * alschan_init (kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
 
static int alschan_setformat (kobj_t obj, void *data, u_int32_t format)
 
static u_int32_t alschan_setspeed (kobj_t obj, void *data, u_int32_t speed)
 
static u_int32_t alschan_setblocksize (kobj_t obj, void *data, u_int32_t blocksize)
 
static u_int32_t alschan_getptr (kobj_t obj, void *data)
 
static struct pcmchan_capsalschan_getcaps (kobj_t obj, void *data)
 
static void als_set_speed (struct sc_chinfo *ch)
 
static const struct playback_commandals_get_playback_command (u_int32_t format)
 
static void als_playback_start (struct sc_chinfo *ch)
 
static int als_playback_stop (struct sc_chinfo *ch)
 
static int alspchan_trigger (kobj_t obj, void *data, int go)
 
 CHANNEL_DECLARE (alspchan)
 
static u_int8_t als_get_fifo_format (struct sc_info *sc, u_int32_t format)
 
static void als_capture_start (struct sc_chinfo *ch)
 
static int als_capture_stop (struct sc_chinfo *ch)
 
static int alsrchan_trigger (kobj_t obj, void *data, int go)
 
 CHANNEL_DECLARE (alsrchan)
 
static int alsmix_init (struct snd_mixer *m)
 
static int alsmix_set (struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
 
static u_int32_t alsmix_setrecsrc (struct snd_mixer *m, u_int32_t src)
 
 MIXER_DECLARE (als_mixer)
 
static void als_intr (void *p)
 
static int als_init (struct sc_info *sc)
 
static void als_uninit (struct sc_info *sc)
 
static int als_pci_probe (device_t dev)
 
static void als_resource_free (device_t dev, struct sc_info *sc)
 
static int als_resource_grab (device_t dev, struct sc_info *sc)
 
static int als_pci_attach (device_t dev)
 
static int als_pci_detach (device_t dev)
 
static int als_pci_suspend (device_t dev)
 
static int als_pci_resume (device_t dev)
 
 DRIVER_MODULE (snd_als4000, pci, als_driver, pcm_devclass, 0, 0)
 
 MODULE_DEPEND (snd_als4000, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
 
 MODULE_VERSION (snd_als4000, 1)
 

Variables

static u_int32_t als_format []
 
static struct pcmchan_caps als_caps = { 4000, 44100, als_format, 0 }
 
struct playback_command playback_cmds []
 
static kobj_method_t alspchan_methods []
 
static kobj_method_t alsrchan_methods []
 
struct sb16props amt [SOUND_MIXER_NRDEVICES]
 
static kobj_method_t als_mixer_methods []
 
static device_method_t als_methods []
 
static driver_t als_driver
 

Macro Definition Documentation

◆ ALS_16BIT_CMD

#define ALS_16BIT_CMD (   x,
 
)    { (x), (y), DSP_DMA16, DSP_CMD_DMAPAUSE_16 }

Definition at line 316 of file als4000.c.

◆ ALS_8BIT_CMD

#define ALS_8BIT_CMD (   x,
 
)    { (x), (y), DSP_DMA8, DSP_CMD_DMAPAUSE_8 }

Definition at line 315 of file als4000.c.

◆ ALS_DEFAULT_BUFSZ

#define ALS_DEFAULT_BUFSZ   16384

Definition at line 59 of file als4000.c.

◆ DEB

#define DEB (   x)    /* x */

Definition at line 56 of file als4000.c.

Function Documentation

◆ als_ack_read()

static u_int8_t als_ack_read ( struct sc_info sc,
u_int8_t  addr 
)
static

Definition at line 197 of file als4000.c.

References addr, r, sc_info::sh, and sc_info::st.

Referenced by als_intr().

Here is the caller graph for this function:

◆ als_capture_start()

◆ als_capture_stop()

static int als_capture_stop ( struct sc_chinfo ch)
static

Definition at line 479 of file als4000.c.

References ALS_FIFO1_CONTROL, ALS_FIFO1_STOP, als_mix_wr(), sc_info::ch, sc_chinfo::dma_active, and sc_chinfo::parent.

Referenced by als_pci_suspend(), and alsrchan_trigger().

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

◆ als_esp_reset()

static int als_esp_reset ( struct sc_info sc)
static

Definition at line 169 of file als4000.c.

References ALS_ESP_RD_DATA, ALS_ESP_RD_STATUS8, ALS_ESP_RST, sc_info::dev, sc_info::sh, and sc_info::st.

Referenced by als_init().

Here is the caller graph for this function:

◆ als_esp_wr()

static void als_esp_wr ( struct sc_info sc,
u_int8_t  data 
)
static

Definition at line 150 of file als4000.c.

References ALS_ESP_WR_DATA, ALS_ESP_WR_STATUS, data, sc_info::dev, sc_info::sh, and sc_info::st.

Referenced by als_capture_start(), als_playback_start(), als_playback_stop(), and als_set_speed().

Here is the caller graph for this function:

◆ als_gcr_rd()

static u_int32_t als_gcr_rd ( struct sc_info sc,
int  index 
)
static

Definition at line 110 of file als4000.c.

References ALS_GCR_DATA, ALS_GCR_INDEX, index, sc_info::sh, and sc_info::st.

Referenced by als_init(), and alschan_getptr().

Here is the caller graph for this function:

◆ als_gcr_wr()

static void als_gcr_wr ( struct sc_info sc,
int  index,
int  data 
)
static

Definition at line 117 of file als4000.c.

References ALS_GCR_DATA, ALS_GCR_INDEX, data, index, sc_info::sh, and sc_info::st.

Referenced by als_capture_start(), als_init(), als_playback_start(), and als_uninit().

Here is the caller graph for this function:

◆ als_get_fifo_format()

static u_int8_t als_get_fifo_format ( struct sc_info sc,
u_int32_t  format 
)
static

Definition at line 434 of file als4000.c.

References ALS_FIFO1_8BIT, ALS_FIFO1_SIGNED, ALS_FIFO1_STEREO, sc_info::dev, format, and SND_FORMAT.

Referenced by als_capture_start().

Here is the caller graph for this function:

◆ als_get_playback_command()

static const struct playback_command * als_get_playback_command ( u_int32_t  format)
static

Definition at line 331 of file als4000.c.

References DEB, format, n, playback_command::pcm_format, and playback_cmds.

Referenced by als_playback_start(), and als_playback_stop().

Here is the caller graph for this function:

◆ als_init()

static int als_init ( struct sc_info sc)
static

Definition at line 680 of file als4000.c.

References als_esp_reset(), ALS_GCR_DMA_EMULATION, ALS_GCR_MISC, als_gcr_rd(), als_gcr_wr(), als_mix_rd(), als_mix_wr(), ALS_SB16_CONFIG, ALS_SB16_DMA_SETUP, and DEB.

Referenced by als_pci_attach(), and als_pci_resume().

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

◆ als_intr()

static void als_intr ( void *  p)
static

◆ als_intr_rd()

static u_int8_t als_intr_rd ( struct sc_info sc)
static

Definition at line 124 of file als4000.c.

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

Referenced by als_intr().

Here is the caller graph for this function:

◆ als_intr_wr()

static void als_intr_wr ( struct sc_info sc,
u_int8_t  data 
)
static

Definition at line 130 of file als4000.c.

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

Referenced by als_intr().

Here is the caller graph for this function:

◆ als_mix_rd()

static u_int8_t als_mix_rd ( struct sc_info sc,
u_int8_t  index 
)
static

Definition at line 136 of file als4000.c.

References ALS_MIXER_DATA, ALS_MIXER_INDEX, index, sc_info::sh, and sc_info::st.

Referenced by als_init(), als_intr(), and alsmix_set().

Here is the caller graph for this function:

◆ als_mix_wr()

static void als_mix_wr ( struct sc_info sc,
u_int8_t  index,
u_int8_t  data 
)
static

Definition at line 143 of file als4000.c.

References ALS_MIXER_DATA, ALS_MIXER_INDEX, data, index, sc_info::sh, and sc_info::st.

Referenced by als_capture_start(), als_capture_stop(), als_init(), alsmix_set(), and alsmix_setrecsrc().

Here is the caller graph for this function:

◆ als_pci_attach()

static int als_pci_attach ( device_t  dev)
static

◆ als_pci_detach()

static int als_pci_detach ( device_t  dev)
static

Definition at line 864 of file als4000.c.

References als_resource_free(), als_uninit(), dev, free, pcm_getdevinfo(), pcm_unregister(), and r.

Here is the call graph for this function:

◆ als_pci_probe()

static int als_pci_probe ( device_t  dev)
static

Definition at line 726 of file als4000.c.

References ALS_PCI_ID0, and dev.

◆ als_pci_resume()

static int als_pci_resume ( device_t  dev)
static

◆ als_pci_suspend()

static int als_pci_suspend ( device_t  dev)
static

◆ als_playback_start()

◆ als_playback_stop()

static int als_playback_stop ( struct sc_chinfo ch)
static

Definition at line 378 of file als4000.c.

References als_esp_wr(), als_get_playback_command(), sc_info::ch, sc_chinfo::dma_active, playback_command::dma_stop, sc_chinfo::format, and sc_chinfo::parent.

Referenced by als_pci_suspend(), and alspchan_trigger().

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

◆ als_resource_free()

static void als_resource_free ( device_t  dev,
struct sc_info sc 
)
static

Definition at line 736 of file als4000.c.

References dev, sc_info::ih, sc_info::irq, sc_info::irqid, sc_info::lock, sc_info::parent_dmat, sc_info::reg, sc_info::regid, and snd_mtxfree().

Referenced by als_pci_attach(), als_pci_detach(), and als_resource_grab().

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

◆ als_resource_grab()

static int als_resource_grab ( device_t  dev,
struct sc_info sc 
)
static

Definition at line 761 of file als4000.c.

References ALS_DEFAULT_BUFSZ, als_intr(), als_resource_free(), sc_info::bufsz, dev, sc_info::ih, sc_info::irq, sc_info::irqid, sc_info::parent_dmat, PCIR_BAR, pcm_getbuffersize(), sc_info::reg, sc_info::regid, sc_info::sh, snd_setup_intr(), and sc_info::st.

Referenced by als_pci_attach().

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

◆ als_set_speed()

static void als_set_speed ( struct sc_chinfo ch)
static

Definition at line 297 of file als4000.c.

References ALS_ESP_SAMPLE_RATE, als_esp_wr(), sc_info::ch, DEB, sc_chinfo::dir, sc_chinfo::dma_active, sc_chinfo::parent, sc_info::pch, PCMDIR_PLAY, sc_info::rch, and sc_chinfo::speed.

Referenced by als_capture_start(), and als_playback_start().

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

◆ als_uninit()

static void als_uninit ( struct sc_info sc)
static

Definition at line 716 of file als4000.c.

References ALS_GCR_MISC, and als_gcr_wr().

Referenced by als_pci_detach(), and als_pci_suspend().

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

◆ alschan_getcaps()

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

Definition at line 291 of file als4000.c.

References als_caps.

◆ alschan_getptr()

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

Definition at line 277 of file als4000.c.

References als_gcr_rd(), sc_chinfo::buffer, sc_info::ch, data, sc_chinfo::gcr_fifo_status, sc_info::lock, sc_chinfo::parent, snd_mtxlock, snd_mtxunlock, and sndbuf_getsize().

Here is the call graph for this function:

◆ alschan_init()

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

◆ alschan_setblocksize()

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

Definition at line 264 of file als4000.c.

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

Here is the call graph for this function:

◆ alschan_setformat()

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

Definition at line 237 of file als4000.c.

References data, format, and sc_chinfo::format.

◆ alschan_setspeed()

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

◆ alsmix_init()

static int alsmix_init ( struct snd_mixer m)
static

Definition at line 554 of file als4000.c.

References amt, m, mix_setdevs(), and mix_setrecdevs().

Here is the call graph for this function:

◆ alsmix_set()

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

Definition at line 571 of file als4000.c.

References als_mix_rd(), als_mix_wr(), amt, sb16props::bits, dev, left, m, mask, mix_getdevinfo(), sb16props::oselect, r, right, and SB16_OMASK.

Here is the call graph for this function:

◆ alsmix_setrecsrc()

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

Definition at line 603 of file als4000.c.

References als_mix_wr(), amt, sb16props::iselect, m, mix_getdevinfo(), r, SB16_IMASK_L, SB16_IMASK_R, and src.

Here is the call graph for this function:

◆ alspchan_trigger()

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

◆ alsrchan_trigger()

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

Definition at line 493 of file als4000.c.

References als_capture_start(), als_capture_stop(), sc_info::ch, data, go, sc_info::lock, sc_chinfo::parent, PCMTRIG_ABORT, PCMTRIG_START, PCMTRIG_STOP, snd_mtxlock, and snd_mtxunlock.

Here is the call graph for this function:

◆ CHANNEL_DECLARE() [1/2]

CHANNEL_DECLARE ( alspchan  )

◆ CHANNEL_DECLARE() [2/2]

CHANNEL_DECLARE ( alsrchan  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( snd_als4000  ,
pci  ,
als_driver  ,
pcm_devclass  ,
,
 
)

◆ MIXER_DECLARE()

MIXER_DECLARE ( als_mixer  )

◆ MODULE_DEPEND()

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

◆ MODULE_VERSION()

MODULE_VERSION ( snd_als4000  ,
 
)

◆ SND_DECLARE_FILE()

SND_DECLARE_FILE ( "$FreeBSD$"  )

Variable Documentation

◆ als_caps

struct pcmchan_caps als_caps = { 4000, 44100, als_format, 0 }
static

Definition at line 104 of file als4000.c.

Referenced by alschan_getcaps().

◆ als_driver

driver_t als_driver
static
Initial value:
= {
"pcm",
}
static device_method_t als_methods[]
Definition: als4000.c:923
#define PCM_SOFTC_SIZE
Definition: sound.h:96

Definition at line 933 of file als4000.c.

◆ als_format

u_int32_t als_format[]
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 92 of file als4000.c.

◆ als_methods

device_method_t als_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, als_pci_probe),
DEVMETHOD(device_attach, als_pci_attach),
DEVMETHOD(device_detach, als_pci_detach),
DEVMETHOD(device_suspend, als_pci_suspend),
DEVMETHOD(device_resume, als_pci_resume),
{ 0, 0 }
}
static int als_pci_probe(device_t dev)
Definition: als4000.c:726
static int als_pci_resume(device_t dev)
Definition: als4000.c:894
static int als_pci_suspend(device_t dev)
Definition: als4000.c:881
static int als_pci_detach(device_t dev)
Definition: als4000.c:864
static int als_pci_attach(device_t dev)
Definition: als4000.c:807

Definition at line 923 of file als4000.c.

◆ als_mixer_methods

kobj_method_t als_mixer_methods[]
static
Initial value:
= {
KOBJMETHOD(mixer_init, alsmix_init),
KOBJMETHOD(mixer_set, alsmix_set),
}
static u_int32_t alsmix_setrecsrc(struct snd_mixer *m, u_int32_t src)
Definition: als4000.c:603
static int alsmix_init(struct snd_mixer *m)
Definition: als4000.c:554
static int alsmix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
Definition: als4000.c:571
#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

Definition at line 625 of file als4000.c.

◆ alspchan_methods

kobj_method_t alspchan_methods[]
static
Initial value:
= {
KOBJMETHOD(channel_init, alschan_init),
KOBJMETHOD(channel_setformat, alschan_setformat),
KOBJMETHOD(channel_setspeed, alschan_setspeed),
KOBJMETHOD(channel_setblocksize, alschan_setblocksize),
KOBJMETHOD(channel_trigger, alspchan_trigger),
KOBJMETHOD(channel_getptr, alschan_getptr),
KOBJMETHOD(channel_getcaps, alschan_getcaps),
}
static int alschan_setformat(kobj_t obj, void *data, u_int32_t format)
Definition: als4000.c:237
static u_int32_t alschan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
Definition: als4000.c:264
static u_int32_t alschan_getptr(kobj_t obj, void *data)
Definition: als4000.c:277
static u_int32_t alschan_setspeed(kobj_t obj, void *data, u_int32_t speed)
Definition: als4000.c:246
static int alspchan_trigger(kobj_t obj, void *data, int go)
Definition: als4000.c:394
static struct pcmchan_caps * alschan_getcaps(kobj_t obj, void *data)
Definition: als4000.c:291
static void * alschan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
Definition: als4000.c:207

Definition at line 418 of file als4000.c.

◆ alsrchan_methods

kobj_method_t alsrchan_methods[]
static
Initial value:
= {
KOBJMETHOD(channel_init, alschan_init),
KOBJMETHOD(channel_setformat, alschan_setformat),
KOBJMETHOD(channel_setspeed, alschan_setspeed),
KOBJMETHOD(channel_setblocksize, alschan_setblocksize),
KOBJMETHOD(channel_trigger, alsrchan_trigger),
KOBJMETHOD(channel_getptr, alschan_getptr),
KOBJMETHOD(channel_getcaps, alschan_getcaps),
}
static int alsrchan_trigger(kobj_t obj, void *data, int go)
Definition: als4000.c:493

Definition at line 512 of file als4000.c.

◆ amt

struct sb16props amt[SOUND_MIXER_NRDEVICES]
Initial value:
= {
[SOUND_MIXER_VOLUME] = { 0x30, 0x31, 5, 0x00, 0x00 },
[SOUND_MIXER_PCM] = { 0x32, 0x33, 5, 0x00, 0x00 },
[SOUND_MIXER_SYNTH] = { 0x34, 0x35, 5, 0x60, 0x40 },
[SOUND_MIXER_CD] = { 0x36, 0x37, 5, 0x06, 0x04 },
[SOUND_MIXER_LINE] = { 0x38, 0x39, 5, 0x18, 0x10 },
[SOUND_MIXER_MIC] = { 0x3a, 0x00, 5, 0x01, 0x01 },
[SOUND_MIXER_SPEAKER] = { 0x3b, 0x00, 2, 0x00, 0x00 },
[SOUND_MIXER_IGAIN] = { 0x3f, 0x40, 2, 0x00, 0x00 },
[SOUND_MIXER_OGAIN] = { 0x41, 0x42, 2, 0x00, 0x00 },
[SOUND_MIXER_TREBLE] = { 0x44, 0x45, 4, 0x00, 0x00 },
[SOUND_MIXER_BASS] = { 0x46, 0x47, 4, 0x00, 0x00 }
}

Referenced by alsmix_init(), alsmix_set(), alsmix_setrecsrc(), chn_dmaupdate(), chn_rdfeed(), and chn_wrfeed().

◆ playback_cmds

struct playback_command playback_cmds[]
Initial value:
= {
}
#define ALS_8BIT_CMD(x, y)
Definition: als4000.c:315
#define ALS_16BIT_CMD(x, y)
Definition: als4000.c:316
#define DSP_MODE_U8STEREO
Definition: sb.h:96
#define DSP_MODE_S16STEREO
Definition: sb.h:98
#define DSP_MODE_U8MONO
Definition: sb.h:95
#define DSP_MODE_S16MONO
Definition: sb.h:97

Referenced by als_get_playback_command().