Subject: kern/32569: auich driver initializes to wrong ac97 rate at boot
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <ggm@apnic.net>
List: netbsd-bugs
Date: 01/19/2006 03:30:00
>Number:         32569
>Category:       kern
>Synopsis:       auich device initializes ac97 to wrong rate at boot
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 19 03:30:00 +0000 2006
>Originator:     George Michaelson
>Release:        NetBSD 3.99.15
>Organization:
George Michaelson       |  APNIC                 
Email: ggm@apnic.net    |  PO Box 2131 Milton    
Phone: +61 7 3858 3150  |  QLD 4064 Australia    
  Fax: +61 7 3858 3199  |  http://www.apnic.net  
>Environment:
	
	
System: NetBSD garlic.apnic.net 3.99.15 NetBSD 3.99.15 (GGMSMALL) #1: Wed Jan 18 10:11:08 EST 2006 ggm@garlic.apnic.net:/data/Build/obj/usr/src/sys/arch/i386/compile/GGMSMALL i386
Architecture: i386
Machine: i386
>Description:
	On boot, auich driver attach probes the ac97 rate via some code
	imported from FreeBSD. its designed to set the rate to a normalized
	value, typically 48000hz or 44100 hz or the like.

	From time to time, on my IBM X31 laptop its being set to a very odd
	rate. This appears to be irreversable at runtime, there being no
	hook I can see which re-initializes the rate.

	I believe all the exposed controls via audioctl are adjusting downstream
	values which pass through the boot-set ac97 rate.

	Here  are two /var/log/messages logs of the auich initialization
	at boot time. The first is the wrong calibration, the second is
	a warm boot, which cleared it back to the right setting.

Jan 19 09:24:50 garlic /netbsd: auich0 at pci0 dev 31 function 5: i82801DB/DBM (ICH4/ICH4M) AC-97 Audio
Jan 19 09:24:50 garlic /netbsd: auich0: interrupting at irq 11
Jan 19 09:24:50 garlic /netbsd: auich0: ac97: Analog Devices AD1981B codec; headphone, 20 bit DAC, no 3D stereo
Jan 19 09:24:50 garlic /netbsd: auich0: ac97: ext id 601<AC97_22,AMAP,VRA>
Jan 19 09:24:50 garlic /netbsd: auich0: measured ac97 link rate at 76803 Hz, will use 77000 Hz
Jan 19 09:24:50 garlic /netbsd: audio0 at auich0: full duplex, mmap, independent

Jan 19 11:42:09 garlic /netbsd: auich0 at pci0 dev 31 function 5: i82801DB/DBM (ICH4/ICH4M) AC-97 Audio
Jan 19 11:42:09 garlic /netbsd: auich0: interrupting at irq 11
Jan 19 11:42:09 garlic /netbsd: auich0: ac97: Analog Devices AD1981B codec; headphone, 20 bit DAC, no 3D stereo
Jan 19 11:42:09 garlic /netbsd: auich0: ac97: ext id 601<AC97_22,AMAP,VRA>
Jan 19 11:42:09 garlic /netbsd: auich0: measured ac97 link rate at 48003 Hz, will use 48000 Hz
Jan 19 11:42:09 garlic /netbsd: audio0 at auich0: full duplex, mmap, independent

	
>How-To-Repeat:
	I don't know if this is host specific. Its an older (2yo) IBM laptop
	and it may represent fading of some part like a crystal sync for the
	audio chip/synth.

	the symptom is that audio output appears to be severely rate mangled
	(typically sounding like its 3-4x slowed down)

	
>Fix:
	I think the fix is going to require work on sys/dev/pci/auich.c
	in the auich_calibrate() routine. It has the comment:

	auich_calibrate() was from FreeBSD: ich.c,v 1.22 2002/06/27 
		22:36:01 scottl Exp    

	

>Unformatted: