1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-17 15:27:36 +00:00

Add ac97_reset function that polls ready bits in power register. One

component in tweaks required for the ICH3 controller in the thinkpad
x22 reported by Colin Perkins on -multimedia.
This commit is contained in:
Orion Hodson 2002-04-26 15:27:56 +00:00
parent d40aecb39d
commit c6d4b83ad1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=95499
2 changed files with 22 additions and 7 deletions

View File

@ -200,6 +200,20 @@ wrcd(struct ac97_info *codec, int reg, u_int16_t val)
AC97_WRITE(codec->methods, codec->devinfo, reg, val);
}
static void
ac97_reset(struct ac97_info *codec)
{
u_int32_t i, ps;
wrcd(codec, AC97_REG_RESET, 0);
for (i = 0; i < 500; i++) {
ps = rdcd(codec, AC97_REG_POWER) & AC97_POWER_STATUS;
if (ps == AC97_POWER_STATUS)
return;
DELAY(1000);
}
device_printf(codec->dev, "AC97 reset timed out.");
}
int
ac97_setrate(struct ac97_info *codec, int which, int rate)
{
@ -372,8 +386,7 @@ ac97_initmixer(struct ac97_info *codec)
}
wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
wrcd(codec, AC97_REG_RESET, 0);
DELAY(100000);
ac97_reset(codec);
wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
i = rdcd(codec, AC97_REG_RESET);
@ -456,8 +469,6 @@ ac97_initmixer(struct ac97_info *codec)
static unsigned
ac97_reinitmixer(struct ac97_info *codec)
{
unsigned i;
snd_mtxlock(codec->lock);
codec->count = AC97_INIT(codec->methods, codec->devinfo);
if (codec->count == 0) {
@ -467,10 +478,8 @@ ac97_reinitmixer(struct ac97_info *codec)
}
wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
wrcd(codec, AC97_REG_RESET, 0);
DELAY(100000);
ac97_reset(codec);
wrcd(codec, AC97_REG_POWER, (codec->flags & AC97_F_EAPD_INV)? 0x8000 : 0x0000);
i = rdcd(codec, AC97_REG_RESET);
if (!codec->noext) {
wrcd(codec, AC97_REGEXT_STAT, codec->extstat);

View File

@ -56,6 +56,12 @@
#define AC97_REG_GEN 0x20
#define AC97_REG_3D 0x22
#define AC97_REG_POWER 0x26
#define AC97_POWER_ADC (1 << 0)
#define AC97_POWER_DAC (1 << 1)
#define AC97_POWER_ANL (1 << 2)
#define AC97_POWER_REF (1 << 3)
#define AC97_POWER_STATUS (AC97_POWER_ADC | AC97_POWER_DAC | \
AC97_POWER_REF | AC97_POWER_ANL )
#define AC97_REGEXT_ID 0x28
#define AC97_EXTCAP_VRA (1 << 0)
#define AC97_EXTCAP_DRA (1 << 1)