diff options
author | orion <orion@FreeBSD.org> | 2003-03-05 05:56:18 +0000 |
---|---|---|
committer | orion <orion@FreeBSD.org> | 2003-03-05 05:56:18 +0000 |
commit | d315a35ab1e589b864a47a2e3073b3ff6dba91e7 (patch) | |
tree | 0d29cebbe57ab91dcbd2d66bad0ea64c1d540f29 /sys/dev/sound | |
parent | d4ee62b07a76bf06911d862a0e2084a2309efa36 (diff) | |
download | FreeBSD-src-d315a35ab1e589b864a47a2e3073b3ff6dba91e7.zip FreeBSD-src-d315a35ab1e589b864a47a2e3073b3ff6dba91e7.tar.gz |
Attempt a hard reset if AC97 codec is not ready on attach.
Halt attach if mixer_init fails.
Prompted by: points raised by Hugo Valentim <hvalentim@gmx.net>.
Diffstat (limited to 'sys/dev/sound')
-rw-r--r-- | sys/dev/sound/pci/via82c686.c | 19 | ||||
-rw-r--r-- | sys/dev/sound/pci/via82c686.h | 28 |
2 files changed, 27 insertions, 20 deletions
diff --git a/sys/dev/sound/pci/via82c686.c b/sys/dev/sound/pci/via82c686.c index 1e0440f..b76987f 100644 --- a/sys/dev/sound/pci/via82c686.c +++ b/sys/dev/sound/pci/via82c686.c @@ -475,8 +475,20 @@ via_attach(device_t dev) pci_write_config(dev, PCIR_COMMAND, data, 2); data = pci_read_config(dev, PCIR_COMMAND, 2); - pci_write_config(dev, VIA_PCICONF_MISC, - VIA_PCICONF_ACLINKENAB | VIA_PCICONF_ACSGD | VIA_PCICONF_ACNOTRST | VIA_PCICONF_ACVSR, 1); + /* Wake up and reset AC97 if necessary */ + if (!(pci_read_config(dev, VIA_AC97STATUS, 1) & VIA_AC97STATUS_RDY)) { + pci_write_config(dev, VIA_ACLINKCTRL, VIA_ACLINK_EN | VIA_ACLINK_NRST | VIA_ACLINK_SYNC, 1); + DELAY(1000); + pci_write_config(dev, VIA_ACLINKCTRL, 0, 1); + DELAY(1000); + pci_write_config(dev, VIA_ACLINKCTRL, VIA_ACLINK_DESIRED, 1); + DELAY(1000); + } + + if (pci_read_config(dev, VIA_ACLINKCTRL, 1) != VIA_ACLINK_DESIRED) { + pci_write_config(dev, VIA_ACLINKCTRL, VIA_ACLINK_DESIRED, 1); + DELAY(1000); + } via->regid = PCIR_MAPS; via->reg = bus_alloc_resource(dev, SYS_RES_IOPORT, &via->regid, 0, ~0, 1, RF_ACTIVE); @@ -503,7 +515,8 @@ via_attach(device_t dev) if (!via->codec) goto bad; - mixer_init(dev, ac97_getmixerclass(), via->codec); + if (mixer_init(dev, ac97_getmixerclass(), via->codec)) + goto bad; via->codec_caps = ac97_getextcaps(via->codec); ac97_setextmode(via->codec, diff --git a/sys/dev/sound/pci/via82c686.h b/sys/dev/sound/pci/via82c686.h index a1fcf4b..501da33 100644 --- a/sys/dev/sound/pci/via82c686.h +++ b/sys/dev/sound/pci/via82c686.h @@ -49,14 +49,17 @@ * ftp://ftp.alsa-project.org/pub/manuals/ad/AD1881_0.pdf (example AC'97 codec) */ -#define VIA_PCICONF_MISC 0x41 -#define VIA_PCICONF_ACLINKENAB 0x80 /* ac link enab */ -#define VIA_PCICONF_ACNOTRST 0x40 /* ~(ac reset) */ -#define VIA_PCICONF_ACSYNC 0x20 /* ac sync */ -#define VIA_PCICONF_ACVSR 0x08 /* var. samp. rate */ -#define VIA_PCICONF_ACSGD 0x04 /* SGD enab */ -#define VIA_PCICONF_ACFM 0x02 /* FM enab */ -#define VIA_PCICONF_ACSB 0x01 /* SB enab */ +#define VIA_AC97STATUS 0x40 +#define VIA_AC97STATUS_RDY 0x01 +#define VIA_ACLINKCTRL 0x41 +#define VIA_ACLINK_EN 0x80 /* ac link enab */ +#define VIA_ACLINK_NRST 0x40 /* ~(ac reset) */ +#define VIA_ACLINK_SYNC 0x20 /* ac sync */ +#define VIA_ACLINK_VSR 0x08 /* var. samp. rate */ +#define VIA_ACLINK_SGD 0x04 /* SGD enab */ +#define VIA_ACLINK_FM 0x02 /* FM enab */ +#define VIA_ACLINK_SB 0x01 /* SB enab */ +#define VIA_ACLINK_DESIRED (VIA_ACLINK_EN|VIA_ACLINK_NRST|VIA_ACLINK_VSR|VIA_ACLINK_SGD) #define VIA_PCICONF_FUNC_EN 0x42 #define VIA_PLAY_STAT 0x00 @@ -84,13 +87,4 @@ #define VIA_CODEC_PRIVALID 0x02000000 #define VIA_CODEC_INDEX(x) ((x)<<16) -#define AC97_REG_EXT_AUDIO_ID 0x28 -#define AC97_CODEC_DOES_VRA 0x0001 -#define AC97_CODEC_DOES_MICVRA 0x0008 -#define AC97_REG_EXT_AUDIO_STAT 0x2A -#define AC97_ENAB_VRA 0x0001 -#define AC97_ENAB_MICVRA 0x0008 -#define AC97_REG_EXT_DAC_RATE 0x2C -#define AC97_REG_EXT_ADC_RATE 0x32 - #endif /* _VIA_H */ |