From owner-freebsd-bugs@FreeBSD.ORG Wed Aug 10 03:30:13 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E3B9F16A41F for ; Wed, 10 Aug 2005 03:30:12 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3303145BB3 for ; Wed, 10 Aug 2005 03:30:12 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j7A3UCpQ039347 for ; Wed, 10 Aug 2005 03:30:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j7A3UChB039339; Wed, 10 Aug 2005 03:30:12 GMT (envelope-from gnats) Resent-Date: Wed, 10 Aug 2005 03:30:12 GMT Resent-Message-Id: <200508100330.j7A3UChB039339@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, michaels@sdf.lonestar.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 182C116A41F for ; Wed, 10 Aug 2005 03:28:15 +0000 (GMT) (envelope-from michaels@sdf.lonestar.org) Received: from sdf.lonestar.org (mx.freeshell.ORG [192.94.73.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id BEB7645BAD for ; Wed, 10 Aug 2005 03:28:14 +0000 (GMT) (envelope-from michaels@sdf.lonestar.org) Received: from sdf.lonestar.org (IDENT:michaels@otaku.freeshell.org [192.94.73.2]) by sdf.lonestar.org (8.13.1/8.12.10) with ESMTP id j7A3RFJ6025690; Wed, 10 Aug 2005 03:27:15 GMT Received: (from michaels@localhost) by sdf.lonestar.org (8.13.1/8.12.8/Submit) id j7A3RFkj010203; Wed, 10 Aug 2005 03:27:15 GMT Message-Id: <20050810032715.GA10051@SDF.LONESTAR.ORG> Date: Wed, 10 Aug 2005 03:27:15 +0000 From: michaels@sdf.lonestar.org To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: michaels.maillist@gmail.com Subject: kern/84728: [sound] [patch] ac97 broken mixing capabilities checking X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2005 03:30:13 -0000 >Number: 84728 >Category: kern >Synopsis: [sound] [patch] ac97 broken mixing capabilities checking >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Aug 10 03:30:11 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Michael Seyfert >Release: FreeBSD 7.0-CURRENT i386 >Organization: >Environment: System: FreeBSD icemach.my.domain 7.0-CURRENT i386 >Description: new sys/dev/sound/pcm/ac97.c introduces some problems with mixer capabilities checking. It does not properly set the "width of control field" for cards with a non-default width. As such the volume control is misaligned ( I can only change the volume from 50% to 100% on my audigy card.) Also, there's an if statement and for loops that logically don't do anything at all, which has me wondering about the quality of this code. I think the author (Ariff Abdullah ) should redo it. >How-To-Repeat: Audigy 2 card... >Fix: Here's a patch to revert this code to the previous version. --- sys/dev/sound/pcm/ac97.c Sun Jul 31 08:28:31 2005 +++ /home/michael/work/ac97.c Tue Aug 9 19:12:01 2005 @@ -611,39 +611,15 @@ for (i = 0; i < 32; i++) { k = codec->noext? codec->mix[i].enable : 1; if (k && (codec->mix[i].reg > 0)) { - j = old = ac97_rdcd(codec, codec->mix[i].reg); - if (!(j & 0x8000)) { - ac97_wrcd(codec, codec->mix[i].reg, j | 0x8000); - j = ac97_rdcd(codec, codec->mix[i].reg); - } - if ((j & 0x8000)) { - j = ((1 << 6) - 1) << codec->mix[i].ofs; - if (codec->mix[i].mute) - j |= 0x8000; - ac97_wrcd(codec, codec->mix[i].reg, j); - j = ac97_rdcd(codec, codec->mix[i].reg) & j; - j >>= codec->mix[i].ofs; - if (codec->mix[i].reg == AC97_MIX_TONE && - ((j & 0x0001) == 0x0000)) - j >>= 1; - for (k = 0; j != 0; k++) - j >>= 1; - for (j = 0; k != 0; j++) - k >>= 1; - if (j != 0) { - codec->mix[i].enable = 1; -#if 0 - codec->mix[i].bits = j; -#endif - } else - codec->mix[i].enable = 0; - } else - codec->mix[i].enable = 0; + old = ac97_rdcd(codec, codec->mix[i].reg); + ac97_wrcd(codec, codec->mix[i].reg, 0x3f); + j = ac97_rdcd(codec, codec->mix[i].reg); ac97_wrcd(codec, codec->mix[i].reg, old); + codec->mix[i].enable = (j != 0 && j != old)? 1 : 0; + for (k = 1; j & (1 << k); k++); + codec->mix[i].bits = j? k - codec->mix[i].ofs : 0; } -#if 0 - printf("mixch %d, en=%d, b=%d\n", i, codec->mix[i].enable, codec->mix[i].bits); -#endif + /* printf("mixch %d, en=%d, b=%d\n", i, codec->mix[i].enable, codec->mix[i].bits); */ } device_printf(codec->dev, "<%s>\n", >Release-Note: >Audit-Trail: >Unformatted: