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

Go to the source code of this file.

Data Structures

struct  ac97mixtable_entry
 
struct  ac97_info
 
struct  ac97_vendorid
 
struct  ac97_codecid
 

Macros

#define AC97_MIXER_SIZE   SOUND_MIXER_NRDEVICES
 

Functions

 SND_DECLARE_FILE ("$FreeBSD$")
 
static MALLOC_DEFINE (M_AC97, "ac97", "ac97 codec")
 
u_int16_t ac97_rdcd (struct ac97_info *codec, int reg)
 
void ac97_wrcd (struct ac97_info *codec, int reg, u_int16_t val)
 
static void ac97_reset (struct ac97_info *codec)
 
int ac97_setrate (struct ac97_info *codec, int which, int rate)
 
int ac97_setextmode (struct ac97_info *codec, u_int16_t mode)
 
u_int16_t ac97_getextmode (struct ac97_info *codec)
 
u_int16_t ac97_getextcaps (struct ac97_info *codec)
 
u_int16_t ac97_getcaps (struct ac97_info *codec)
 
u_int32_t ac97_getsubvendor (struct ac97_info *codec)
 
static int ac97_setrecsrc (struct ac97_info *codec, int channel)
 
static int ac97_setmixer (struct ac97_info *codec, unsigned channel, unsigned left, unsigned right)
 
static void ac97_fix_auxout (struct ac97_info *codec)
 
static void ac97_fix_tone (struct ac97_info *codec)
 
static const char * ac97_hw_desc (u_int32_t id, const char *vname, const char *cname, char *buf)
 
static unsigned ac97_initmixer (struct ac97_info *codec)
 
static unsigned ac97_reinitmixer (struct ac97_info *codec)
 
struct ac97_infoac97_create (device_t dev, void *devinfo, kobj_class_t cls)
 
void ac97_destroy (struct ac97_info *codec)
 
void ac97_setflags (struct ac97_info *codec, u_int32_t val)
 
u_int32_t ac97_getflags (struct ac97_info *codec)
 
static int sysctl_hw_snd_ac97_eapd (SYSCTL_HANDLER_ARGS)
 
static void ac97_init_sysctl (struct ac97_info *codec)
 
static int ac97mix_init (struct snd_mixer *m)
 
static int ac97mix_uninit (struct snd_mixer *m)
 
static int ac97mix_reinit (struct snd_mixer *m)
 
static int ac97mix_set (struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
 
static u_int32_t ac97mix_setrecsrc (struct snd_mixer *m, u_int32_t src)
 
 MIXER_DECLARE (ac97mixer)
 
kobj_class_t ac97_getmixerclass (void)
 

Variables

static const struct ac97mixtable_entry ac97mixtable_default [AC97_MIXER_SIZE]
 
static const struct ac97_vendorid ac97vendorid []
 
static struct ac97_codecid ac97codecid []
 
static char * ac97enhancement []
 
static char * ac97feature []
 
static char * ac97extfeature []
 
static kobj_method_t ac97mixer_methods []
 

Macro Definition Documentation

◆ AC97_MIXER_SIZE

#define AC97_MIXER_SIZE   SOUND_MIXER_NRDEVICES

Definition at line 57 of file ac97.c.

Function Documentation

◆ ac97_create()

struct ac97_info * ac97_create ( device_t  dev,
void *  devinfo,
kobj_class_t  cls 
)

◆ ac97_destroy()

void ac97_destroy ( struct ac97_info codec)

◆ ac97_fix_auxout()

static void ac97_fix_auxout ( struct ac97_info codec)
static

Definition at line 518 of file ac97.c.

References AC97_EXTCAP_SDAC, AC97_MIX_AUXOUT, AC97_MIXEXT_SURROUND, ac97_rdcd(), ac97_info::extcaps, ac97_info::mix, and ac97mixtable_entry::reg.

Referenced by ac97_initmixer().

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

◆ ac97_fix_tone()

static void ac97_fix_tone ( struct ac97_info codec)
static

Definition at line 553 of file ac97.c.

References AC97_CAP_TONE, ac97_info::caps, ac97_info::id, ac97_info::mix, and ac97_info::se.

Referenced by ac97_initmixer().

Here is the caller graph for this function:

◆ ac97_getcaps()

u_int16_t ac97_getcaps ( struct ac97_info codec)

Definition at line 411 of file ac97.c.

References ac97_info::caps.

Referenced by emu_pci_attach(), and ich_pci_attach().

Here is the caller graph for this function:

◆ ac97_getextcaps()

u_int16_t ac97_getextcaps ( struct ac97_info codec)

Definition at line 405 of file ac97.c.

References ac97_info::extcaps.

Referenced by ich_pci_attach(), and via_attach().

Here is the caller graph for this function:

◆ ac97_getextmode()

u_int16_t ac97_getextmode ( struct ac97_info codec)

Definition at line 399 of file ac97.c.

References ac97_info::extstat.

Referenced by via_attach().

Here is the caller graph for this function:

◆ ac97_getflags()

u_int32_t ac97_getflags ( struct ac97_info codec)

Definition at line 876 of file ac97.c.

References ac97_info::flags.

Referenced by atiixp_chip_post_init(), and ich_pci_attach().

Here is the caller graph for this function:

◆ ac97_getmixerclass()

kobj_class_t ac97_getmixerclass ( void  )

◆ ac97_getsubvendor()

u_int32_t ac97_getsubvendor ( struct ac97_info codec)

Definition at line 417 of file ac97.c.

References ac97_info::subvendor.

Referenced by ad1981b_patch(), ad198x_patch(), alc655_patch(), and cmi9739_patch().

Here is the caller graph for this function:

◆ ac97_hw_desc()

static const char * ac97_hw_desc ( u_int32_t  id,
const char *  vname,
const char *  cname,
char *  buf 
)
static

Definition at line 582 of file ac97.c.

References buf.

Referenced by ac97_initmixer().

Here is the caller graph for this function:

◆ ac97_init_sysctl()

static void ac97_init_sysctl ( struct ac97_info codec)
static

Definition at line 912 of file ac97.c.

References ac97_rdcd(), AC97_REG_POWER, ac97_wrcd(), ac97_info::dev, ac97_info::lock, snd_mtxlock, snd_mtxunlock, sysctl_hw_snd_ac97_eapd(), and val.

Referenced by ac97mix_init().

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

◆ ac97_initmixer()

◆ ac97_rdcd()

u_int16_t ac97_rdcd ( struct ac97_info codec,
int  reg 
)

◆ ac97_reinitmixer()

static unsigned ac97_reinitmixer ( struct ac97_info codec)
static

Definition at line 803 of file ac97.c.

References AC97_EXTCAPS, AC97_F_EAPD_INV, ac97_rdcd(), AC97_REG_POWER, AC97_REGEXT_STAT, ac97_reset(), ac97_wrcd(), ac97_info::count, ac97_info::dev, ac97_info::devinfo, ac97_info::extstat, ac97_info::flags, ac97_info::lock, ac97_info::methods, ac97_info::noext, snd_mtxlock, and snd_mtxunlock.

Referenced by ac97mix_reinit().

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

◆ ac97_reset()

static void ac97_reset ( struct ac97_info codec)
static

Definition at line 338 of file ac97.c.

References AC97_POWER_STATUS, ac97_rdcd(), AC97_REG_POWER, AC97_REG_RESET, ac97_wrcd(), and ac97_info::dev.

Referenced by ac97_initmixer(), and ac97_reinitmixer().

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

◆ ac97_setextmode()

int ac97_setextmode ( struct ac97_info codec,
u_int16_t  mode 
)

Definition at line 383 of file ac97.c.

References AC97_EXTCAPS, ac97_rdcd(), AC97_REGEXT_STAT, ac97_wrcd(), ac97_info::dev, ac97_info::extcaps, ac97_info::extstat, ac97_info::lock, snd_mtxlock, and snd_mtxunlock.

Referenced by ich_pci_attach(), ich_pci_resume(), and via_attach().

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

◆ ac97_setflags()

void ac97_setflags ( struct ac97_info codec,
u_int32_t  val 
)

Definition at line 870 of file ac97.c.

References ac97_info::flags, and val.

Referenced by atiixp_chip_post_init(), ich_pci_attach(), and pcmcsa_attach().

Here is the caller graph for this function:

◆ ac97_setmixer()

static int ac97_setmixer ( struct ac97_info codec,
unsigned  channel,
unsigned  left,
unsigned  right 
)
static

◆ ac97_setrate()

int ac97_setrate ( struct ac97_info codec,
int  which,
int  rate 
)

◆ ac97_setrecsrc()

static int ac97_setrecsrc ( struct ac97_info codec,
int  channel 
)
static

Definition at line 423 of file ac97.c.

References AC97_REG_RECSEL, ac97_wrcd(), channel, ac97_info::lock, ac97_info::mix, ac97mixtable_entry::recidx, snd_mtxlock, snd_mtxunlock, and val.

Referenced by ac97mix_setrecsrc().

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

◆ ac97_wrcd()

void ac97_wrcd ( struct ac97_info codec,
int  reg,
u_int16_t  val 
)

◆ ac97mix_init()

◆ ac97mix_reinit()

static int ac97mix_reinit ( struct snd_mixer m)
static

Definition at line 1051 of file ac97.c.

References ac97_reinitmixer(), m, and mix_getdevinfo().

Here is the call graph for this function:

◆ ac97mix_set()

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

Definition at line 1061 of file ac97.c.

References AC97_MIXER_SIZE, ac97_setmixer(), dev, left, m, mix_getdevinfo(), and right.

Here is the call graph for this function:

◆ ac97mix_setrecsrc()

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

Definition at line 1071 of file ac97.c.

References AC97_MIXER_SIZE, ac97_setrecsrc(), m, mix_getdevinfo(), and src.

Here is the call graph for this function:

◆ ac97mix_uninit()

static int ac97mix_uninit ( struct snd_mixer m)
static

Definition at line 1036 of file ac97.c.

References ac97_destroy(), m, and mix_getdevinfo().

Here is the call graph for this function:

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_AC97  ,
"ac97"  ,
"ac97 codec"   
)
static

◆ MIXER_DECLARE()

MIXER_DECLARE ( ac97mixer  )

◆ SND_DECLARE_FILE()

SND_DECLARE_FILE ( "$FreeBSD$"  )

◆ sysctl_hw_snd_ac97_eapd()

static int sysctl_hw_snd_ac97_eapd ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 884 of file ac97.c.

References AC97_F_EAPD_INV, ac97_rdcd(), AC97_REG_POWER, ac97_wrcd(), ac97_info::flags, ac97_info::id, ac97_info::lock, req, snd_mtxlock, snd_mtxunlock, and val.

Referenced by ac97_init_sysctl().

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

Variable Documentation

◆ ac97codecid

struct ac97_codecid ac97codecid[]
static

Definition at line 138 of file ac97.c.

Referenced by ac97_initmixer().

◆ ac97enhancement

char* ac97enhancement[]
static

Definition at line 245 of file ac97.c.

Referenced by ac97_initmixer().

◆ ac97extfeature

char* ac97extfeature[]
static
Initial value:
= {
"variable rate PCM",
"double rate PCM",
"reserved 1",
"variable rate mic",
"reserved 2",
"reserved 3",
"center DAC",
"surround DAC",
"LFE DAC",
"AMAP",
"reserved 4",
"reserved 5",
"reserved 6",
"reserved 7",
}

Definition at line 293 of file ac97.c.

Referenced by ac97_initmixer().

◆ ac97feature

char* ac97feature[]
static
Initial value:
= {
"mic channel",
"reserved",
"tone",
"simulated stereo",
"headphone",
"bass boost",
"18 bit DAC",
"20 bit DAC",
"18 bit ADC",
"20 bit ADC"
}

Definition at line 280 of file ac97.c.

Referenced by ac97_initmixer().

◆ ac97mixer_methods

kobj_method_t ac97mixer_methods[]
static
Initial value:
= {
KOBJMETHOD(mixer_init, ac97mix_init),
KOBJMETHOD(mixer_set, ac97mix_set),
}
static int ac97mix_init(struct snd_mixer *m)
Definition: ac97.c:935
static int ac97mix_uninit(struct snd_mixer *m)
Definition: ac97.c:1036
static int ac97mix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
Definition: ac97.c:1061
static u_int32_t ac97mix_setrecsrc(struct snd_mixer *m, u_int32_t src)
Definition: ac97.c:1071
static int ac97mix_reinit(struct snd_mixer *m)
Definition: ac97.c:1051
#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
int mixer_uninit(device_t dev)
Definition: mixer.c:805
int mixer_reinit(device_t dev)
Definition: mixer.c:860

Definition at line 1084 of file ac97.c.

◆ ac97mixtable_default

const struct ac97mixtable_entry ac97mixtable_default[AC97_MIXER_SIZE]
static
Initial value:
= {
[SOUND_MIXER_VOLUME] = { AC97_MIX_MASTER, 5, 0, 1, 1, 6, 0, 1 },
[SOUND_MIXER_OGAIN] = { AC97_MIX_AUXOUT, 5, 0, 1, 1, 0, 0, 0 },
[SOUND_MIXER_PHONEOUT] = { AC97_MIX_MONO, 5, 0, 0, 1, 7, 0, 0 },
[SOUND_MIXER_BASS] = { AC97_MIX_TONE, 4, 8, 0, 0, 0, 1, 0 },
[SOUND_MIXER_TREBLE] = { AC97_MIX_TONE, 4, 0, 0, 0, 0, 1, 0 },
[SOUND_MIXER_PCM] = { AC97_MIX_PCM, 5, 0, 1, 1, 0, 0, 1 },
[SOUND_MIXER_SPEAKER] = { AC97_MIX_BEEP, 4, 1, 0, 1, 0, 0, 0 },
[SOUND_MIXER_LINE] = { AC97_MIX_LINE, 5, 0, 1, 1, 5, 0, 1 },
[SOUND_MIXER_PHONEIN] = { AC97_MIX_PHONE, 5, 0, 0, 1, 8, 0, 0 },
[SOUND_MIXER_MIC] = { AC97_MIX_MIC, 5, 0, 0, 1, 1, 1, 1 },
[SOUND_MIXER_IGAIN] = { -AC97_MIX_MIC, 1, 6, 0, 0, 0, 1, 1 },
[SOUND_MIXER_CD] = { AC97_MIX_CD, 5, 0, 1, 1, 2, 0, 1 },
[SOUND_MIXER_LINE1] = { AC97_MIX_AUX, 5, 0, 1, 1, 4, 0, 0 },
[SOUND_MIXER_VIDEO] = { AC97_MIX_VIDEO, 5, 0, 1, 1, 3, 0, 0 },
[SOUND_MIXER_RECLEV] = { -AC97_MIX_RGAIN, 4, 0, 1, 1, 0, 0, 1 }
}
#define AC97_MIX_CD
Definition: ac97.h:51
#define AC97_MIX_AUX
Definition: ac97.h:53
#define AC97_MIX_MASTER
Definition: ac97.h:43
#define AC97_MIX_TONE
Definition: ac97.h:46
#define AC97_MIX_MONO
Definition: ac97.h:45
#define AC97_MIX_PCM
Definition: ac97.h:54
#define AC97_MIX_VIDEO
Definition: ac97.h:52
#define AC97_MIX_AUXOUT
Definition: ac97.h:44
#define AC97_MIX_PHONE
Definition: ac97.h:48
#define AC97_MIX_RGAIN
Definition: ac97.h:56
#define AC97_MIX_BEEP
Definition: ac97.h:47
#define AC97_MIX_MIC
Definition: ac97.h:49
#define AC97_MIX_LINE
Definition: ac97.h:50

Definition at line 85 of file ac97.c.

Referenced by ac97_initmixer().

◆ ac97vendorid

const struct ac97_vendorid ac97vendorid[]
static
Initial value:
= {
{ 0x41445300, "Analog Devices" },
{ 0x414b4d00, "Asahi Kasei" },
{ 0x414c4300, "Realtek" },
{ 0x414c4700, "Avance Logic" },
{ 0x43525900, "Cirrus Logic" },
{ 0x434d4900, "C-Media Electronics" },
{ 0x43585400, "Conexant" },
{ 0x44543000, "Diamond Technology" },
{ 0x454d4300, "eMicro" },
{ 0x45838300, "ESS Technology" },
{ 0x48525300, "Intersil" },
{ 0x49434500, "ICEnsemble" },
{ 0x49544500, "ITE, Inc." },
{ 0x4e534300, "National Semiconductor" },
{ 0x50534300, "Philips Semiconductor" },
{ 0x83847600, "SigmaTel" },
{ 0x53494c00, "Silicon Laboratories" },
{ 0x54524100, "TriTech" },
{ 0x54584e00, "Texas Instruments" },
{ 0x56494100, "VIA Technologies" },
{ 0x57454300, "Winbond" },
{ 0x574d4c00, "Wolfson" },
{ 0x594d4800, "Yamaha" },
{ 0x01408300, "Creative" },
{ 0x00000000, NULL }
}

Definition at line 105 of file ac97.c.

Referenced by ac97_initmixer().