From patchwork Fri Apr 20 11:04:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 154017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3C73CB7019 for ; Fri, 20 Apr 2012 21:02:40 +1000 (EST) Received: from localhost ([::1]:35068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SLBbq-0001ZR-3x for incoming@patchwork.ozlabs.org; Fri, 20 Apr 2012 07:02:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SLBb8-0007y4-U4 for qemu-devel@nongnu.org; Fri, 20 Apr 2012 07:02:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SLBb1-0005Ej-J8 for qemu-devel@nongnu.org; Fri, 20 Apr 2012 07:01:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19884) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SLBb1-0005ER-Bx for qemu-devel@nongnu.org; Fri, 20 Apr 2012 07:01:47 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3KB1jFC008682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 20 Apr 2012 07:01:46 -0400 Received: from shalem.localdomain.com (vpn1-5-206.ams2.redhat.com [10.36.5.206]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3KB1elt031729; Fri, 20 Apr 2012 07:01:45 -0400 From: Hans de Goede To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2012 13:04:01 +0200 Message-Id: <1334919842-14610-4-git-send-email-hdegoede@redhat.com> In-Reply-To: <1334919842-14610-1-git-send-email-hdegoede@redhat.com> References: <1334919842-14610-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Hans de Goede Subject: [Qemu-devel] [PATCH 4/5] hw/ac97: Mask out unused bits of volume controls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The Linux ac97 drivers does a number of register read/write tests to see how much resolution a volume control actually has. This patch takes this into account by masking out any bits written to a volume control reg which should not be there according to the spec. After this the Linux ac97 driver correctly uses a range of 0 - 0x1f for the PCM out volume, as stated in the spec, and we can fix the FIXME in update_combined_volume_out(). This patch was also tested with a Windows XP guest without any issues. Signed-off-by: Hans de Goede --- hw/ac97.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/hw/ac97.c b/hw/ac97.c index 524dd7f..a245c97 100644 --- a/hw/ac97.c +++ b/hw/ac97.c @@ -455,8 +455,7 @@ static void update_combined_volume_out (AC97LinkState *s) get_volume (mixer_load (s, AC97_Master_Volume_Mute), 0x3f, 1, &mute, &lvol, &rvol); - /* FIXME: should be 1f according to spec */ - get_volume (mixer_load (s, AC97_PCM_Out_Volume_Mute), 0x3f, 1, + get_volume (mixer_load (s, AC97_PCM_Out_Volume_Mute), 0x1f, 1, &pmute, &plvol, &prvol); mute = mute | pmute; @@ -479,11 +478,22 @@ static void update_volume_in (AC97LinkState *s) static void set_volume (AC97LinkState *s, int index, uint32_t val) { - mixer_store (s, index, val); - if (index == AC97_Master_Volume_Mute || index == AC97_PCM_Out_Volume_Mute) { + switch (index) { + case AC97_Master_Volume_Mute: + val &= 0xbf3f; + mixer_store (s, index, val); update_combined_volume_out (s); - } else if (index == AC97_Record_Gain_Mute) { + break; + case AC97_PCM_Out_Volume_Mute: + val &= 0x9f1f; + mixer_store (s, index, val); + update_combined_volume_out (s); + break; + case AC97_Record_Gain_Mute: + val &= 0x8f0f; + mixer_store (s, index, val); update_volume_in (s); + break; } }