Date: Thu, 27 Jun 2002 15:19:47 -0600 From: Scott Long <scott_long@btc.adaptec.com> To: freebsd-multimedia@freebsd.org, cg@freebsd.org, orion@freebsd.org Subject: ICH calibration under 5-CURRENT Message-ID: <20020627211947.GA18048@hollin.btc.adaptec.com>
next in thread | raw e-mail | index | archive | help
--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
All,
I noticed that with my ICH3/CS4205 sound setup, if I load the ich
driver at boot or compile it into the kernel, it incorrectly
sets the ac97 sample rate. However, if I load the driver *after*
boot, it's correct. This is due to ich_calibrate() running
before the system clock is itslef calibrated. I see that there are
a few hacks and sysctl's for dealing with this, but the attached
patch should settle this issue. It puts ich_calibrate() into a
config_intrhook, forcing it to run after the system clock is
calibrated. If there are no objections, I'd like to commit it
to 5-CURRENT. I haven't looked into 4-STABLE, so comments there
are welcome also.
Scott
--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ich.patch"
Index: ich.c
===================================================================
RCS file: /usr/ncvs/src/sys/dev/sound/pci/ich.c,v
retrieving revision 1.21
diff -u -r1.21 ich.c
--- ich.c 5 May 2002 15:37:09 -0000 1.21
+++ ich.c 27 Jun 2002 21:07:13 -0000
@@ -85,6 +85,7 @@
struct sc_chinfo ch[3];
int ac97rate;
struct ich_desc *dtbl;
+ struct intr_config_hook intrhook;
};
/* -------------------------------------------------------------------- */
@@ -455,13 +456,19 @@
/* Calibrate card (some boards are overclocked and need scaling) */
static
-unsigned int ich_calibrate(struct sc_info *sc)
+void ich_calibrate(void *arg)
{
- struct sc_chinfo *ch = &sc->ch[1];
+ struct sc_info *sc;
+ struct sc_chinfo *ch;
struct timeval t1, t2;
u_int8_t ociv, nciv;
u_int32_t wait_us, actual_48k_rate, bytes;
+ sc = (struct sc_info *)arg;
+ ch = &sc->ch[1];
+
+ config_intrhook_disestablish(&sc->intrhook);
+
/*
* Grab audio from input for fixed interval and compare how
* much we actually get with what we expect. Interval needs
@@ -516,7 +523,7 @@
if (nciv == ociv) {
device_printf(sc->dev, "ac97 link rate calibration timed out after %d us\n", wait_us);
- return 0;
+ return;
}
actual_48k_rate = (bytes * 250000) / wait_us;
@@ -534,7 +541,7 @@
printf("\n");
}
- return sc->ac97rate;
+ return;
}
/* -------------------------------------------------------------------- */
@@ -708,7 +715,13 @@
pcm_setstatus(dev, status);
ich_initsys(sc);
- ich_calibrate(sc);
+
+ sc->intrhook.ich_func = ich_calibrate;
+ sc->intrhook.ich_arg = sc;
+ if (config_intrhook_establish(&sc->intrhook) != 0) {
+ device_printf(dev, "Cannot establish calibration hook, will calibrate now\n");
+ ich_calibrate(sc);
+ }
return 0;
--h31gzZEtNLTqOjlF--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-multimedia" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020627211947.GA18048>
