Subject: Re: AC97 auich and i82801BA - some progress
To: Mark Davies <mark@mcs.vuw.ac.nz>
From: TAMURA Kent <kent@netbsd.org>
List: port-i386
Date: 03/18/2002 16:15:51
In message "Re: AC97 auich and i82801BA - some progress"
    on 02/03/18, Mark Davies <mark@mcs.vuw.ac.nz> writes:
> _However_ (you knew that was coming didn't you)  when I play a 44.1kHz MP3 
> (with noatun, or xmms, or mpg123 or via nasd) or a 22.05kHz mono file it still 
> plays fast.

I have the same problem with IBM NetVista A40p:
	auich0 at pci0 dev 31 function 5: i82801BA (ICH2) AC-97 Audio
	auich0: interrupting at irq 9
	auich0: ADS96 codec; headphone, Analog Devices Phat Stereo
	audio0 at auich0: full duplex, mmap, independent

However, with your patch for auich_reset_codec() and the
following patch, it plays correctly.  Of course, the following
patch is not a correct fix.  The auich driver needs to measure
actual clock.

--- auich.c.orig	Mon Mar 18 16:11:58 2002
+++ auich.c	Mon Mar 18 15:54:08 2002
@@ -676,18 +676,19 @@
		if (sc->sc_fixed_rate) {
			p->hw_sample_rate = sc->sc_fixed_rate;
		} else {
+#define ICH_ACTUAL_CLOCK	410
			if (mode == AUMODE_PLAY) {
				auich_write_codec(sc, AC97_REG_PCM_FRONT_DAC_RATE,
-				    p->sample_rate);
+				    p->sample_rate * ICH_ACTUAL_CLOCK / 480);
				auich_read_codec(sc, AC97_REG_PCM_FRONT_DAC_RATE,
				    &rate);
			} else {
				auich_write_codec(sc, AC97_REG_PCM_LR_ADC_RATE,
-				    p->sample_rate);
+				    p->sample_rate * ICH_ACTUAL_CLOCK / 480);
				auich_read_codec(sc, AC97_REG_PCM_LR_ADC_RATE,
				    &rate);
			}
-			p->hw_sample_rate = rate;
+			p->hw_sample_rate = rate * 480 / ICH_ACTUAL_CLOCK;
		}

		auich_write_codec(sc, AC97_REG_POWER, val);

-- 
TAMURA Kent <kent2002@hauN.org> <kent@netbsd.org>