NetBSD Problem Report #18901

Received: (qmail 21426 invoked by uid 605); 3 Nov 2002 11:36:14 -0000
Message-Id: <200211032035.gA3KZug04224@alice.>
Date: Mon, 4 Nov 2002 05:35:56 +0900 (JST)
From: sunakawa@hi-ho.ne.jp
Sender: gnats-bugs-owner@netbsd.org
Reply-To: sunakawa@hi-ho.ne.jp
To: gnats-bugs@gnats.netbsd.org
Subject: Audio gain control of LR channel is contrary.
X-Send-Pr-Version: 3.95

>Number:         18901
>Category:       kern
>Synopsis:       Audio gain control of LR channel is contrary.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kent
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 03 11:37:00 +0000 2002
>Closed-Date:    Fri Nov 08 05:31:35 +0000 2002
>Last-Modified:  Wed Dec 11 18:13:00 +0000 2002
>Originator:     Hirokatsu Sunakawa
>Release:        NetBSD 1.6
>Organization:
individual
>Environment:
System: NetBSD alice 1.6 NetBSD 1.6 (ALICE) #4: Sun Nov 3 00:01:29 JST 2002 root@alice:/home/src/sys/arch/i386/compile/ALICE i386
Architecture: i386
Machine: i386

auvia0 at pci0 dev 17 function 5: VIA VT82C686A AC'97 Audio (rev 0x40)
auvia0: interrupting at irq 5
auvia0: unknown (0x83847650) codec; headphone, 20 bit DAC, 18 bit ADC, SigmaTel 3D
audio0 at auvia0: full duplex, mmap, independent

>Description:
	Audio gain control of LR channel is contrary.
>How-To-Repeat:
	Please try to change gain of L and R channels to different value, using some mixer program.
>Fix:

	According to the AC'97 specification, L ch's bit position is 8 and R ch's bit position is 0.
	So, I think, the following description of ac97.c (/usr/src/sys/dev/ic/ac97.c) is wrong.

    762                 newval = ((l & mask) << si->ofs);                <-----
    763                 if (value->num_channels == 2) {
    764                         newval |= ((r & mask) << (si->ofs + 8)); <-----
    765                         mask |= (mask << 8);
    766                 }


	These shold be as follows.

    762                 newval = ((r & mask) << si->ofs);
    763                 if (value->num_channels == 2) {
    764                         newval |= ((l & mask) << (si->ofs + 8));
    765                         mask |= (mask << 8);
    766                 }



	And also, the following description of ac97.c is wrong.

    837                 if (value->num_channels == 1) {
    838                         l = r = (val >> si->ofs) & mask;
    839                 } else {
    840                         if (!(as->host_flags & AC97_HOST_SWAPPED_CHANNELS)) {
    841                                 l = (val >> si->ofs) & mask;              <----
    842                                 r = (val >> (si->ofs + 8)) & mask;        <----
    843                         } else {        /* host has reversed channels */
    844                                 r = (val >> si->ofs) & mask;		  <----
    845                                 l = (val >> (si->ofs + 8)) & mask;	  <----
    846                         }
    847                 }

	These shold be as follows.

    837                 if (value->num_channels == 1) {
    838                         l = r = (val >> si->ofs) & mask;
    839                 } else {
    840                         if (!(as->host_flags & AC97_HOST_SWAPPED_CHANNELS)) {
    841                                 r = (val >> si->ofs) & mask;
    842                                 l = (val >> (si->ofs + 8)) & mask;
    843                         } else {        /* host has reversed channels */
    844                                 l = (val >> si->ofs) & mask;
    845                                 r = (val >> (si->ofs + 8)) & mask;
    846                         }
    847                 }



	And also, according to the defines of Balance settings in audioio.h,
	the following description of audio.c (/usr/src/sys/dev/audio.c) is wrong.

   2397         if (balance == AUDIO_MID_BALANCE) {
   2398                 l = r = gain;
   2399         } else if (balance < AUDIO_MID_BALANCE) {
   2400                 r = gain;				     <----
   2401                 l = (balance * gain) / AUDIO_MID_BALANCE;    <----
   2402         } else {
   2403                 l = gain;				     <----
   2404                 r = ((AUDIO_RIGHT_BALANCE - balance) * gain) <----
   2405                     / AUDIO_MID_BALANCE;
   2406         }


	These shold be as follows.


   2397         if (balance == AUDIO_MID_BALANCE) {
   2398                 l = r = gain;
   2399         } else if (balance < AUDIO_MID_BALANCE) {
   2400           /* left > right */
   2401                 l = gain;
   2402                 r = (balance * gain) / AUDIO_MID_BALANCE;
   2403         } else {
   2404           /* left < right */
   2405                 r = gain;
   2406                 l = ((AUDIO_RIGHT_BALANCE - balance) * gain)
   2407                     / AUDIO_MID_BALANCE;
   2408         }



	That's all.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->kent 
Responsible-Changed-By: kent 
Responsible-Changed-When: Wed Nov 6 05:35:19 PST 2002 
Responsible-Changed-Why:  
I'm working on this. 

From: TAMURA Kent <kent@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/18901 CVS commit: syssrc/sys/dev/ic
Date: Wed,  6 Nov 2002 18:58:37 +0200 (EET)

 Module Name:	syssrc
 Committed By:	kent
 Date:		Wed Nov  6 16:58:37 UTC 2002

 Modified Files:
 	syssrc/sys/dev/ic: ac97.c

 Log Message:
 Fix LR contrary problem of mixer and record gain polarity
 problem.  The change is based on the patches in PR kern/12878 by
 Zdenek Salvet and PR kern/18901 by SUNAKAWA Hirokatsu.


 To generate a diff of this commit:
 cvs rdiff -r1.36 -r1.37 syssrc/sys/dev/ic/ac97.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: TAMURA Kent <kent@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/18901 CVS commit: syssrc/sys/dev
Date: Fri,  8 Nov 2002 07:02:08 +0200 (EET)

 Module Name:	syssrc
 Committed By:	kent
 Date:		Fri Nov  8 05:02:08 UTC 2002

 Modified Files:
 	syssrc/sys/dev: audio.c

 Log Message:
 Fix LR contrary problem of play.balance and record.balance.  The
 change is based on PR kern/18901 by SUNAKAWA Hirokatsu.


 To generate a diff of this commit:
 cvs rdiff -r1.167 -r1.168 syssrc/sys/dev/audio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed 
State-Changed-By: kent 
State-Changed-When: Thu Nov 7 21:26:29 PST 2002 
State-Changed-Why:  
The problems has been fixed in -current.  Thank you. 
I have some advice.  You should submit independent problems as 
separated PRs, and we are happy if you provide fixes in "diff 
-c" or "diff -u" form. 

From: Havard Eidnes <he@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/18901 CVS commit: [netbsd-1-6] syssrc/sys/dev/ic
Date: Wed, 11 Dec 2002 20:10:08 +0200 (EET)

 Module Name:	syssrc
 Committed By:	he
 Date:		Wed Dec 11 18:10:07 UTC 2002

 Modified Files:
 	syssrc/sys/dev/ic [netbsd-1-6]: ac97.c

 Log Message:
 Pull up revision 1.37 (via patch, requested by kent in ticket #980):
   Fix LR reversal problem of mixer and record gain
   polarity problem.  Based on PR#12878 and PR#18901.


 To generate a diff of this commit:
 cvs rdiff -r1.24 -r1.24.10.1 syssrc/sys/dev/ic/ac97.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Havard Eidnes <he@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/18901 CVS commit: [netbsd-1-6] syssrc/sys/dev
Date: Wed, 11 Dec 2002 20:12:06 +0200 (EET)

 Module Name:	syssrc
 Committed By:	he
 Date:		Wed Dec 11 18:12:05 UTC 2002

 Modified Files:
 	syssrc/sys/dev [netbsd-1-6]: audio.c

 Log Message:
 Pull up revision 1.168 (requested by kent in ticket #981):
   Fix LR reversal problem of play.balance vs. record.balance.
   Based on PR#18901.


 To generate a diff of this commit:
 cvs rdiff -r1.155.4.3 -r1.155.4.4 syssrc/sys/dev/audio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

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.