From fcd478479db7490599ef2d88d0096a66f77aeb1c Mon Sep 17 00:00:00 2001 From: John Hay Date: Sun, 14 Apr 2002 10:39:59 +0000 Subject: [PATCH] Fix the play / record rate setting so that it actually works. The extra microphone channel capability is part of the "normal" ac97 capabilities and not an extended ac97 capability. Now recording on codecs without a seperate mic channel works. MFC after: 1 week --- sys/dev/sound/pci/ich.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/dev/sound/pci/ich.c b/sys/dev/sound/pci/ich.c index c44e221e3bc8..c6392855dabe 100644 --- a/sys/dev/sound/pci/ich.c +++ b/sys/dev/sound/pci/ich.c @@ -298,7 +298,12 @@ ichchan_setspeed(kobj_t obj, void *data, u_int32_t speed) if (sc->ac97rate <= 32000 || sc->ac97rate >= 64000) sc->ac97rate = 48000; r = (speed * 48000) / sc->ac97rate; - ch->spd = (ac97_setrate(sc->codec, ch->spdreg, r) * sc->ac97rate) / 48000; + /* + * Cast the return value of ac97_setrate() to u_int so that + * the math don't overflow into the negative range. + */ + ch->spd = ((u_int)ac97_setrate(sc->codec, ch->spdreg, r) * + sc->ac97rate) / 48000; } else { ch->spd = 48000; } @@ -682,8 +687,8 @@ ich_pci_attach(device_t dev) extcaps = ac97_getextcaps(sc->codec); sc->hasvra = extcaps & AC97_EXTCAP_VRA; sc->hasvrm = extcaps & AC97_EXTCAP_VRM; - sc->hasmic = extcaps & AC97_CAP_MICCHANNEL; - ac97_setextmode(sc->codec, sc->hasvra | sc->hasvrm | sc->hasmic); + sc->hasmic = ac97_getcaps(sc->codec) & AC97_CAP_MICCHANNEL; + ac97_setextmode(sc->codec, sc->hasvra | sc->hasvrm); if (pcm_register(dev, sc, 1, sc->hasmic? 2 : 1)) goto bad;