Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3294106pxf; Mon, 5 Apr 2021 08:18:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbLhf2Ney0/YDDuzGSINdn9UVzyfH3HR1K+Rzu3OG8TZ/+YXNJSbFMPKXrm9uMrqXH/wbV X-Received: by 2002:a05:6e02:b2c:: with SMTP id e12mr722730ilu.161.1617635926612; Mon, 05 Apr 2021 08:18:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617635926; cv=none; d=google.com; s=arc-20160816; b=ulIWTR1xamlohXNi+CHlbk60Rkpb8K34yVBI+APgG1n5ZK5iT6CUCg4NFIbhT3CWn2 vb+/3gx+CWXxgIcmRCnnhQhmIifRg7vmq/a7/nG61JD6+ATPiBEV5bZ49fYxT9PC6Pvo J4yt/zDlI0xg/Ij0vXGsV/3WqBeyLSP7PEpGVBuTLgeXY0KB5cSlquVdjMi2W4dZ3xc1 mlGp7B8finv6ajHPJe7DAaqt7NRRZnWk+aiIaj2EdeofDVOY2/ewN4LuKJ94kfUdm5hQ nlQYj48MLukhhssNG4MxOPoY1jZF4zxPkend/10BMpAUoYoimDuWrD2VvuR1Mf+Z0Rdy qflQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vytXqqUoPtWH8qa4C2l53xjL393ZH7xSqmJ1GkFwq4s=; b=hHZPiwCvXECFGfV1Jva2asQ24HUld9OBJOj0QMsr1blC8yDsIeiXYb1YnJBkb0ARFn 9RaPFLku4F9HqsjpJ85Ye1UXrooZA/4Q2hke/97zzuk/Guac47bYr/h+74eTo9DVXJOi IBF8w43XmlFZ6MjRSWrza9Hp3MQEdLomKds/bqq2mYwxEaR4bBbgIf/3YGlQ38dwoItV 9xRuFrKPbZDYPW+GeEEyxhmgNdA/wLPM7mT83ybTMaetzk5onHsCwOiBPdjy18AArGO/ 2VWWYbPL1y/STK9J68g+thqgf4snMKta18xMxSsb6XCec9ltyfo5K/3o9Rok12q6a0hx rAHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H2S5uzDO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p6si7552554ilo.32.2021.04.05.08.18.34; Mon, 05 Apr 2021 08:18:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H2S5uzDO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238332AbhDEJEr (ORCPT + 99 others); Mon, 5 Apr 2021 05:04:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:46916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237726AbhDEJDm (ORCPT ); Mon, 5 Apr 2021 05:03:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 41ADF61002; Mon, 5 Apr 2021 09:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617613416; bh=RSeMbxYPaVdFocIANy3gRLltk1Yz7P//s7KNHjJ4nEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H2S5uzDOHLSWJbkI7vT6nOgAWucjuMYKfXknmUJU4p6YX2oZKVFS2gdRotjyh08x1 MZgm71HPYx27STiLnKGYXA1Z+TAjBr7LSgXMouG6Z+O1niIKerFfYOp5oM6aHy4i/Q IOXradfcbPAahcF+5WnWmbJOcFiGqBuyPMiXnsPc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Mark Brown , Sasha Levin Subject: [PATCH 5.4 11/74] ASoC: rt5640: Fix dac- and adc- vol-tlv values being off by a factor of 10 Date: Mon, 5 Apr 2021 10:53:35 +0200 Message-Id: <20210405085025.097725123@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405085024.703004126@linuxfoundation.org> References: <20210405085024.703004126@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede [ Upstream commit cfa26ed1f9f885c2fd8f53ca492989d1e16d0199 ] The adc_vol_tlv volume-control has a range from -17.625 dB to +30 dB, not -176.25 dB to + 300 dB. This wrong scale is esp. a problem in userspace apps which translate the dB scale to a linear scale. With the logarithmic dB scale being of by a factor of 10 we loose all precision in the lower area of the range when apps translate things to a linear scale. E.g. the 0 dB default, which corresponds with a value of 47 of the 0 - 127 range for the control, would be shown as 0/100 in alsa-mixer. Since the centi-dB values used in the TLV struct cannot represent the 0.375 dB step size used by these controls, change the TLV definition for them to specify a min and max value instead of min + stepsize. Note this mirrors commit 3f31f7d9b540 ("ASoC: rt5670: Fix dac- and adc- vol-tlv values being off by a factor of 10") which made the exact same change to the rt5670 codec driver. Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210226143817.84287-2-hdegoede@redhat.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/rt5640.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 747ca248bf10..3bc63fbcb188 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -339,9 +339,9 @@ static bool rt5640_readable_register(struct device *dev, unsigned int reg) } static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0); -static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0); +static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0); static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); -static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0); +static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000); static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ -- 2.30.1