summaryrefslogtreecommitdiff
path: root/sys/dev/sound/pci/ich.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/sound/pci/ich.c')
-rw-r--r--sys/dev/sound/pci/ich.c11
1 files 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;