1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

move a private struct definition from ac97.h to ac97.c

add proper handling of cards which take eapd=1 to mean 'produce sound'
instead of 'external amplifier power down'
This commit is contained in:
Cameron Grant 2001-06-23 17:32:40 +00:00
parent c73d99b567
commit 79bb7d52b3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=78668
2 changed files with 32 additions and 13 deletions
sys/dev/sound/pcm

View File

@ -33,6 +33,17 @@
MALLOC_DEFINE(M_AC97, "ac97", "ac97 codec");
struct ac97mixtable_entry {
int reg:8;
unsigned bits:4;
unsigned ofs:4;
unsigned stereo:1;
unsigned mute:1;
unsigned recidx:4;
unsigned mask:1;
unsigned enable:1;
};
#define AC97_NAMELEN 16
struct ac97_info {
kobj_t methods;
@ -41,6 +52,7 @@ struct ac97_info {
char *id;
char rev;
unsigned count, caps, se, extcaps, extid, extstat, noext:1;
u_int32_t flags;
struct ac97mixtable_entry mix[32];
char name[AC97_NAMELEN];
void *lock;
@ -350,10 +362,10 @@ ac97_initmixer(struct ac97_info *codec)
return ENODEV;
}
wrcd(codec, AC97_REG_POWER, 0x8000);
wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
wrcd(codec, AC97_REG_RESET, 0);
DELAY(100000);
wrcd(codec, AC97_REG_POWER, 0x8000);
wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
i = rdcd(codec, AC97_REG_RESET);
codec->caps = i & 0x03ff;
@ -445,9 +457,10 @@ ac97_reinitmixer(struct ac97_info *codec)
return ENODEV;
}
wrcd(codec, AC97_REG_POWER, 0);
wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
wrcd(codec, AC97_REG_RESET, 0);
DELAY(100000);
wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
i = rdcd(codec, AC97_REG_RESET);
if (!codec->noext) {
@ -484,6 +497,7 @@ ac97_create(device_t dev, void *devinfo, kobj_class_t cls)
codec->dev = dev;
codec->devinfo = devinfo;
codec->flags = 0;
return codec;
}
@ -497,6 +511,18 @@ ac97_destroy(struct ac97_info *codec)
free(codec, M_AC97);
}
void
ac97_setflags(struct ac97_info *codec, u_int32_t val)
{
codec->flags = val;
}
u_int32_t
ac97_getflags(struct ac97_info *codec)
{
return codec->flags;
}
/* -------------------------------------------------------------------- */
static int

View File

@ -63,16 +63,7 @@
#define AC97_REG_ID1 0x7c
#define AC97_REG_ID2 0x7e
struct ac97mixtable_entry {
int reg:8;
unsigned bits:4;
unsigned ofs:4;
unsigned stereo:1;
unsigned mute:1;
unsigned recidx:4;
unsigned mask:1;
unsigned enable:1;
};
#define AC97_F_EAPD_INV 0x00000001
#define AC97_DECLARE(name) static DEFINE_CLASS(name, name ## _methods, sizeof(struct kobj))
#define AC97_CREATE(dev, devinfo, cls) ac97_create(dev, devinfo, &cls ## _class)
@ -85,6 +76,8 @@ extern kobj_class_t ac97_getmixerclass(void);
struct ac97_info *ac97_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);
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);