summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2004-07-21 04:05:34 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2004-07-21 04:05:34 +0000
commit58d8db023c37627e4c29984bfa0fe8aca45e466f (patch)
treeb0537a1eb9e47c8d00febb29d3ce37c21d26d560 /sys
parent76a180d49b88a54f0255698a87f5ee6c16626f32 (diff)
calibrate after opening. helps if cpu speed is changing and microtime can't
be trusted. ok deraadt, several testers. solves pr3814. while here, art says use microuptime.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/auich.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/dev/pci/auich.c b/sys/dev/pci/auich.c
index 57fe69f7342..43ccdf3b760 100644
--- a/sys/dev/pci/auich.c
+++ b/sys/dev/pci/auich.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auich.c,v 1.40 2004/07/08 00:34:47 deraadt Exp $ */
+/* $OpenBSD: auich.c,v 1.41 2004/07/21 04:05:33 tedu Exp $ */
/*
* Copyright (c) 2000,2001 Michael Shalayeff
@@ -441,7 +441,7 @@ auich_attach(parent, self, aux)
sc->suspend = PWR_RESUME;
sc->powerhook = powerhook_establish(auich_powerhook, sc);
- sc->sc_ac97rate = auich_calibrate(sc);
+ sc->sc_ac97rate = -1;
}
int
@@ -540,6 +540,10 @@ auich_open(v, flags)
void *v;
int flags;
{
+ struct auich_softc *sc = v;
+
+ if (sc->sc_ac97rate == -1)
+ sc->sc_ac97rate = auich_calibrate(sc);
return 0;
}
@@ -1367,19 +1371,19 @@ auich_calibrate(struct auich_softc *sc)
(0 - 1) & AUICH_LVI_MASK);
/* start */
- microtime(&t1);
+ microuptime(&t1);
bus_space_write_1(sc->iot, sc->aud_ioh, AUICH_PCMI + AUICH_CTRL,
AUICH_RPBM);
/* wait */
while (nciv == ociv) {
- microtime(&t2);
+ microuptime(&t2);
if (t2.tv_sec - t1.tv_sec > 1)
break;
nciv = bus_space_read_1(sc->iot, sc->aud_ioh,
AUICH_PCMI + AUICH_CIV);
}
- microtime(&t2);
+ microuptime(&t2);
/* reset */
bus_space_write_1(sc->iot, sc->aud_ioh, AUICH_PCMI + AUICH_CTRL, AUICH_RR);