NetBSD Problem Report #17604

From boundary="----_=_NextPart_001_01C22BC4.FD1E4900"
Received: (qmail 23697 invoked by uid 605); 15 Jul 2002 13:57:07 -0000
Message-Id: <200207141714.g6EHE5R00302@chewie>
Date: Sun, 14 Jul 2002 19:14:05 +0200
From: <cube@cubidou.net>
Sender: gnats-bugs-owner@netbsd.org
Reply-To: <cube@cubidou.net>
To: <gnats-bugs@gnats.netbsd.org>
Subject: auich(4) does not set all parameters correctly

>Number:         17604
>Category:       kern
>Synopsis:       auich(4) does not set all parameters correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 15 13:58:01 +0000 2002
>Closed-Date:    Sat Oct 26 17:59:37 +0000 2002
>Last-Modified:  Sat Oct 26 17:59:37 +0000 2002
>Originator:     Quentin Garnier
>Release:        NetBSD 1.6A - auich.c 1.17 2002/04/11
>Organization:
=09
>Environment:
=09
=09
System: NetBSD chewie 1.6A NetBSD 1.6A (CHEWIE-$Revision: 1.6 $) #9: Sun
Jul 14 18:21:40 CEST 2002
cube@chewie:/home/cube/sys/src/NetBSD/src/sys/arch/i386/compile/CHEWIE
i386
Architecture: i386
Machine: i386
>Description:
=09
The auich(4) drivers does not set the parameters sent with AUDIO_SETINFO
correctly, which leads to a difference between the internal driver state
and
what the user can obtain with AUDIO_GETINFO.

More precisely, it involves the way p->[hw_]channels and
p->[hw_]sample_rate
are set : the hw_ variants are set instead of the others. If for some
reason
the driver does not set the values it was given by the user, it changes
the
hw_ variants, but not the other, although AUDIO_GETINFO rely on the
latter.

audio(4) contains a test to check if the driver set p->sample_rate and
p->channels to the values given, and then change the hw_ variants
accordingly.
Manipulating the hw_ variants in auich_set_params is thus useless.

The following pico-patch will make auich(4) behave the way it should.

>How-To-Repeat:
=09
On my hardware, auich(4) detects a fixed-rate codec, making the problem
very easy to reproduce : call AUDIO_SETINFO with sample_rate set to a
dumb value. The driver corrects it to the one and only it can use
(48000).
But then a call to AUDIO_GETINFO will retrieve the dumb value.

>Fix:
=09
--- auich.c.orig	Sun Jul 14 18:19:28 2002
+++ auich.c	Sun Jul 14 19:11:41 2002
@@ -642,7 +642,7 @@
 		p->hw_encoding =3D AUDIO_ENCODING_SLINEAR_LE;
 		p->hw_precision =3D 16;
 		if (p->channels < 2)
-			p->hw_channels =3D 2;
+			p->channels =3D 2;
 		switch (p->encoding) {
 		case AUDIO_ENCODING_SLINEAR_BE:
 			if (p->precision =3D=3D 16) {
@@ -716,9 +716,9 @@
 		}
=20
 		if (sc->sc_fixed_rate)
-			p->hw_sample_rate =3D sc->sc_fixed_rate;
+			p->sample_rate =3D sc->sc_fixed_rate;
 		else
-			p->hw_sample_rate =3D auich_set_rate(sc, mode,
+			p->sample_rate =3D auich_set_rate(sc, mode,
=20
p->sample_rate);
 	}
=20

------_=_NextPart_001_01C22BC4.FD1E4900
Content-Type: text/html;
	charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.0.5770.91">
<TITLE>auich(4) does not set all parameters correctly</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>

<P><FONT SIZE=3D2>&gt;Submitter-Id:&nbsp; net</FONT>

<BR><FONT SIZE=3D2>&gt;Originator:&nbsp;&nbsp;&nbsp; Quentin =
Garnier</FONT>

<BR><FONT SIZE=3D2>&gt;Organization:</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20

<BR><FONT SIZE=3D2>&gt;Confidential:&nbsp; no</FONT>

<BR><FONT SIZE=3D2>&gt;Synopsis:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auich(4) =
does not set all parameters correctly</FONT>

<BR><FONT SIZE=3D2>&gt;Severity:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
non-critical</FONT>

<BR><FONT SIZE=3D2>&gt;Priority:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
low</FONT>

<BR><FONT SIZE=3D2>&gt;Category:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
kern</FONT>

<BR><FONT SIZE=3D2>&gt;Class: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
sw-bug</FONT>

<BR><FONT SIZE=3D2>&gt;Release:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
NetBSD 1.6A - auich.c 1.17 2002/04/11</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20

<BR><FONT SIZE=3D2>&gt;Environment:</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20

<BR><FONT SIZE=3D2>System: NetBSD chewie 1.6A NetBSD 1.6A =
(CHEWIE-$Revision: 1.6 $) #9: Sun Jul 14 18:21:40 CEST 2002 =
cube@chewie:/home/cube/sys/src/NetBSD/src/sys/arch/i386/compile/CHEWIE =
i386</FONT></P>

<P><FONT SIZE=3D2>Architecture: i386</FONT>

<BR><FONT SIZE=3D2>Machine: i386</FONT>

<BR><FONT SIZE=3D2>&gt;Description:</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20

<BR><FONT SIZE=3D2>The auich(4) drivers does not set the parameters sent =
with AUDIO_SETINFO</FONT>

<BR><FONT SIZE=3D2>correctly, which leads to a difference between the =
internal driver state and</FONT>

<BR><FONT SIZE=3D2>what the user can obtain with AUDIO_GETINFO.</FONT>
</P>

<P><FONT SIZE=3D2>More precisely, it involves the way =
p-&gt;[hw_]channels and p-&gt;[hw_]sample_rate</FONT>

<BR><FONT SIZE=3D2>are set : the hw_ variants are set instead of the =
others. If for some reason</FONT>

<BR><FONT SIZE=3D2>the driver does not set the values it was given by =
the user, it changes the</FONT>

<BR><FONT SIZE=3D2>hw_ variants, but not the other, although =
AUDIO_GETINFO rely on the latter.</FONT>
</P>

<P><FONT SIZE=3D2>audio(4) contains a test to check if the driver set =
p-&gt;sample_rate and</FONT>

<BR><FONT SIZE=3D2>p-&gt;channels to the values given, and then change =
the hw_ variants accordingly.</FONT>

<BR><FONT SIZE=3D2>Manipulating the hw_ variants in auich_set_params is =
thus useless.</FONT>
</P>

<P><FONT SIZE=3D2>The following pico-patch will make auich(4) behave the =
way it should.</FONT>
</P>

<P><FONT SIZE=3D2>&gt;How-To-Repeat:</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20

<BR><FONT SIZE=3D2>On my hardware, auich(4) detects a fixed-rate codec, =
making the problem</FONT>

<BR><FONT SIZE=3D2>very easy to reproduce : call AUDIO_SETINFO with =
sample_rate set to a</FONT>

<BR><FONT SIZE=3D2>dumb value. The driver corrects it to the one and =
only it can use (48000).</FONT>

<BR><FONT SIZE=3D2>But then a call to AUDIO_GETINFO will retrieve the =
dumb value.</FONT>
</P>

<P><FONT SIZE=3D2>&gt;Fix:</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20

<BR><FONT SIZE=3D2>--- =
auich.c.orig&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sun Jul 14 =
18:19:28 2002</FONT>

<BR><FONT SIZE=3D2>+++ auich.c&nbsp;&nbsp;&nbsp;&nbsp; Sun Jul 14 =
19:11:41 2002</FONT>

<BR><FONT SIZE=3D2>@@ -642,7 +642,7 @@</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p-&gt;hw_encoding =3D =
AUDIO_ENCODING_SLINEAR_LE;</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p-&gt;hw_precision =3D =
16;</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (p-&gt;channels &lt; =
2)</FONT>

<BR><FONT SIZE=3D2>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p-&gt;hw_channels =3D =
2;</FONT>

<BR><FONT SIZE=3D2>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p-&gt;channels =3D 2;</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch (p-&gt;encoding) =
{</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case =
AUDIO_ENCODING_SLINEAR_BE:</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (p-&gt;precision =3D=3D =
16) {</FONT>

<BR><FONT SIZE=3D2>@@ -716,9 +716,9 @@</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>

<BR><FONT SIZE=3D2>&nbsp;</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if =
(sc-&gt;sc_fixed_rate)</FONT>

<BR><FONT SIZE=3D2>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p-&gt;hw_sample_rate =3D =
sc-&gt;sc_fixed_rate;</FONT>

<BR><FONT SIZE=3D2>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p-&gt;sample_rate =3D =
sc-&gt;sc_fixed_rate;</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</FONT>

<BR><FONT SIZE=3D2>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p-&gt;hw_sample_rate =3D =
auich_set_rate(sc, mode,</FONT>

<BR><FONT SIZE=3D2>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p-&gt;sample_rate =3D =
auich_set_rate(sc, mode,</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; =
p-&gt;sample_rate);</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>

<BR><FONT SIZE=3D2>&nbsp;</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C22BC4.FD1E4900--

>Release-Note:
>Audit-Trail:

From: TAMURA Kent <kent@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: Re: kern/17604
Date: Fri, 26 Jul 2002 22:57:44 +0900 (JST)

 It is expected behavior.

 If you call AUDIO_SETINFO with non-48kHz sampling rate against a
 48kHz-fixed device, the auich(4) asks the audio(9) driver for
 sampling rate conversion (aurateconv.c) by setting hw_* values.
 =46rom the userland view, the device can play the non-48kHz
 sampling rate.  So AUDIO_GETINFO should return the non-48kHz
 sampling rate.

 --=20
 TAMURA Kent <kent2002@hauN.org> <kent@netbsd.org>
State-Changed-From-To: open->closed 
State-Changed-By: kent 
State-Changed-When: Sat Oct 26 10:57:54 PDT 2002 
State-Changed-Why:  
It is expected behavior. 
>Unformatted:
 This is a multi-part message in MIME format.

 ------_=_NextPart_001_01C22BC4.FD1E4900
 Content-Type: text/plain;
 	charset="US-ASCII"
 Content-Transfer-Encoding: quoted-printable


 =09
 =09

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.