Subject: kern/15606: auich fails setting rate on YMF743 (non-VRA)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <zinnia@jan.ne.jp>
List: netbsd-bugs
Date: 02/13/2002 19:10:30
>Number:         15606
>Category:       kern
>Synopsis:       auich fails setting rate on YMF743 (non-VRA)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 13 19:10:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Tsuyoshi Iguchi
>Release:        NetBSD 1.5ZA(i386)
>Organization:
>Environment:
NetBSD iguchi.comnetbank.co.jp 1.5ZA NetBSD 1.5ZA (TI-Z.freesia) #8: Thu Feb 14 10:44:35 JST 2002     zinnia@iguchi.comnetbank.co.jp:/home/build/src/sys/arch/i386/compile/TI-Z.freesia i386
>Description:
auich.c revision 1.9 has support for variable rate.
On the other hand, on my laptop (Panasonic CF-B5R / YMF743, 
doesn't have variable rate support), AC97_REG_PCM_FRONT_DAC_RATE always 
returns 0(not 48000) and application fails initializing audio device.

zinnia@freesia:~[3]% audioctl -w play=48000,2,16,slinear_le
play: -> 0,2,16,slinear_le
play.rate: -> 0
play.channels: -> 2
play.precision: -> 16
play.encoding: -> slinear_le


>How-To-Repeat:
audioctl -w play=48000,2,16,slinear_le  
with YMF743 or ALC100(AvanceLogic) or so...


>Fix:
Following patch seems good for my platform,

--- auich.c.1.9	Wed Feb 13 18:42:48 2002
+++ auich.c	Thu Feb 14 10:03:11 2002
@@ -665,10 +665,14 @@
 		auich_read_codec(sc, AC97_REG_POWER, &val);
 		auich_write_codec(sc, AC97_REG_POWER, val | inout);
 
-		auich_write_codec(sc, AC97_REG_PCM_FRONT_DAC_RATE,
-		    sc->sc_fixed_rate ? sc->sc_fixed_rate : p->sample_rate);
-		auich_read_codec(sc, AC97_REG_PCM_FRONT_DAC_RATE, &rate);
-		p->sample_rate = rate;
+		if (sc->sc_fixed_rate) {
+			p->sample_rate = sc->sc_fixed_rate;
+		} else {
+			auich_write_codec(sc, AC97_REG_PCM_FRONT_DAC_RATE,
+				p->sample_rate);
+			auich_read_codec(sc, AC97_REG_PCM_FRONT_DAC_RATE, &rate);
+			p->sample_rate = rate;
+                }
 
 		auich_write_codec(sc, AC97_REG_POWER, val);
 	}

or simpler (but little rough) one

--- auich.c.1.8 Wed Feb 13 18:42:48 2002
+++ auich.c     Thu Feb 14 10:40:42 2002
@@ -668,7 +668,7 @@
                auich_write_codec(sc, AC97_REG_PCM_FRONT_DAC_RATE,
                    sc->sc_fixed_rate ? sc->sc_fixed_rate : p->sample_rate);
                auich_read_codec(sc, AC97_REG_PCM_FRONT_DAC_RATE, &rate);
-               p->sample_rate = rate;
+               p->sample_rate = rate ? rate : sc->sc_fixed_rate;

                auich_write_codec(sc, AC97_REG_POWER, val);
        }
 

zinnia@freesia:~[1]% audioctl -w play=48000,2,16,slinear_le
play: -> 48000,2,16,slinear_le
play.rate: -> 48000
play.channels: -> 2
play.precision: -> 16
play.encoding: -> slinear_le

>Release-Note:
>Audit-Trail:
>Unformatted: