Message ID | 20230524074156.147387-2-cristian.ciocaltea@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2669354vqo; Wed, 24 May 2023 00:55:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WrXvzBAXLFVEVVk4VZVq/dPkl4R/BLw8MPaQOIpB2qYNOqOxE6TRGqtcZ7b3xPKNknHqp X-Received: by 2002:a05:6a00:22c1:b0:644:d775:60bb with SMTP id f1-20020a056a0022c100b00644d77560bbmr2353920pfj.20.1684914922826; Wed, 24 May 2023 00:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684914922; cv=none; d=google.com; s=arc-20160816; b=i7XLqfDcQ+Xc4Gb/HUBTH7J0OSeXQY+u5ngFwBP6t/poOgVkgDIfE/w4INsIFhEZeA jMlEtEWgqTyqYr81Q/lRtT19yhj4Kpa+NdM0BOH462qKbeRR+xLOjyw7RF9l1EyVkmqx 1CpdiuvPw0yFPFgvJc4wb8qCOoBRPVlHfuY+5FWMLHMDLV2Stx01SYGIMY4GuPnXDsPd Skh8/4+c+TV3RHIiaD4irSnax66971A9WZC6pLbdMpmDpurlmFHKQfe2CXT6MFxLIrKI xkMK1H17ewFRdjd45NRJDtugjk1AAXmREbOcyoS+s9wNZajyEZUe4pCWYhySCdfdrVxk JfLg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RgClWvfhJGPzqokulG9eB8JpQ13GW93oKJZu0l16QTs=; b=bBULRC4LYIFA7fQvBjHjXPQfuGDA1JqpZiyRYzApBizmqD63c9O5mGEfepdL+7B+xP XdzcY1XbtulTrTfriekSs+hO16wYB7iSPj0HB9H5Y4rnySBjB/PhXPlW0ThP3Iuae0QD NkLGiLqtZTJlbyBi1IexlQIm0qp6mCNZ0z+EXHE17unweEKxfJcDvayEoeu/2v5M8gQv g9d/F1vWbu7njN86DjBzTSligbJkC0ZuzfAaNya7wQGFVmv7gB/i5XbDC4lthitfq6QD bEmzLA4yJLKUfIb3PGa13q6oNY+gzVJ0/n4hQ3rvdoR9AEgtGUbxZmhxqKhkuPQkHWZh p7Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fQkj2bN3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l192-20020a6391c9000000b00534293eee51si7937179pge.775.2023.05.24.00.55.10; Wed, 24 May 2023 00:55:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fQkj2bN3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240032AbjEXHmL (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Wed, 24 May 2023 03:42:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240015AbjEXHmF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 24 May 2023 03:42:05 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B0B19D; Wed, 24 May 2023 00:42:04 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id CE0296606E73; Wed, 24 May 2023 08:42:02 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684914123; bh=faNfSMxsboihf/E9pG9NmNCYt8187yJ11iV3M4yxj3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fQkj2bN38h3Di9mMwX+6e0iyLG8XxNYkrqv0WHX9HQak78Jbs46ss/kXVOF+9PmPe wbZk4DhZLsc4N1KDwZ06dsBy9g8j9KOt30+0na6+YYpBT+IIlRvyw8qnM+8SA75bhm OCMw1nDs4pC6kblznJuR8I9UKR5pw0uP4HTIOrT57Ji/+U3wAKaR4LPj/BPAANgOKS liUyIiql8a0BddF0uis/FYqY+BskTnpfuP+MOU2cuILvFRwz7iag3XqEpvUIWlLJtW E7h+9yO0DphnPj+YrvWWTnV8lpK5B7WF10o1GPadhsn2CvWZhX8L39Xzk6DVTXU1DP b3CcBpr8VaWfg== From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> To: Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Heiko Stuebner <heiko@sntech.de>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, Zhu Ning <zhuning0077@gmail.com>, Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>, Charles Keepax <ckeepax@opensource.cirrus.com>, =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= <u.kleine-koenig@pengutronix.de>, David Yang <yangxiaohua@everest-semi.com>, Daniel Drake <drake@endlessm.com> Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, kernel@collabora.com Subject: [PATCH 1/3] ASoC: es8316: Increment max value for ALC Capture Target Volume control Date: Wed, 24 May 2023 10:41:54 +0300 Message-Id: <20230524074156.147387-2-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524074156.147387-1-cristian.ciocaltea@collabora.com> References: <20230524074156.147387-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766761349927911619?= X-GMAIL-MSGID: =?utf-8?q?1766761349927911619?= |
Series |
ES8316 audio codec fixes on Rock5B
|
|
Commit Message
Cristian Ciocaltea
May 24, 2023, 7:41 a.m. UTC
The following error occurs when trying to restore a previously saved
ALSA mixer state (tested on a Rock 5B board):
$ alsactl --no-ucm -f /tmp/asound.state store hw:Analog
$ alsactl --no-ucm -I -f /tmp/asound.state restore hw:Analog
alsactl: set_control:1475: Cannot write control '2:0:0:ALC Capture Target Volume:0' : Invalid argument
According to ES8316 datasheet, the register at address 0x2B, which is
related to the above mixer control, contains by default the value 0xB0.
Considering the corresponding ALC target bits are 7:4, the control is
initialized with 0xB, which is one step above the maximum value 0xA
allowed by the driver.
This means that either the hardware default is wrongly set to 0xB
instead of 0xA, or the specs are incorrect and instead of having the
range 0xA-0xF mapped to -1.5 dB, the single value 0xA should have been
mapped to -1.5 dB and the remaining range 0xB-0xF to 0 dB.
Increment the max value allowed for ALC Capture Target Volume control,
so that it matches the hardware default.
Fixes: b8b88b70875a ("ASoC: add es8316 codec driver")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
sound/soc/codecs/es8316.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Wed, May 24, 2023 at 10:41:54AM +0300, Cristian Ciocaltea wrote: > This means that either the hardware default is wrongly set to 0xB > instead of 0xA, or the specs are incorrect and instead of having the > range 0xA-0xF mapped to -1.5 dB, the single value 0xA should have been > mapped to -1.5 dB and the remaining range 0xB-0xF to 0 dB. > Increment the max value allowed for ALC Capture Target Volume control, > so that it matches the hardware default. > - SOC_SINGLE_TLV("ALC Capture Target Volume", ES8316_ADC_ALC3, 4, 10, 0, > + SOC_SINGLE_TLV("ALC Capture Target Volume", ES8316_ADC_ALC3, 4, 11, 0, > alc_target_tlv), The description above of what the control does doesn't seem to match what alc_target_tlv specifies - it is: static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(alc_target_tlv, -1650, 150, 0); which is saying that the value goes from -16.5dB up in steps of 1.5dB but your description above says that 0-10 map to -1.5dB and other values are 0dB. Presumably you can check the effects of changing the value? It seems plausible that what's written in the code might be accurate and the higher values might actually change the gain but it'd be better to check.
On 5/24/23 13:30, Mark Brown wrote: > On Wed, May 24, 2023 at 10:41:54AM +0300, Cristian Ciocaltea wrote: > >> This means that either the hardware default is wrongly set to 0xB >> instead of 0xA, or the specs are incorrect and instead of having the >> range 0xA-0xF mapped to -1.5 dB, the single value 0xA should have been >> mapped to -1.5 dB and the remaining range 0xB-0xF to 0 dB. > >> Increment the max value allowed for ALC Capture Target Volume control, >> so that it matches the hardware default. > >> - SOC_SINGLE_TLV("ALC Capture Target Volume", ES8316_ADC_ALC3, 4, 10, 0, >> + SOC_SINGLE_TLV("ALC Capture Target Volume", ES8316_ADC_ALC3, 4, 11, 0, >> alc_target_tlv), > > The description above of what the control does doesn't seem to match > what alc_target_tlv specifies - it is: > > static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(alc_target_tlv, -1650, 150, 0); > > which is saying that the value goes from -16.5dB up in steps of 1.5dB > but your description above says that 0-10 map to -1.5dB and other values > are 0dB. My description above mentioned only the 0xA-0xF (10-15) range, anything before that is fine and the implementation matches the specs: 0000 –> -16.5 dB 0001 –> -15.0 dB 0010 –> -13.5 dB ... 0111 –> -6.0 dB 1000 –> -4.5 dB 1001 –> -3.0 dB The inconsistency is here: 1010-1111 –> -1.5 dB Since the hardware default is 1011 (11) instead of 1010 (10), I assumed the specs could be wrong and probably should have provided the following mappings: 1010 -> -1.5 dB 1011-1111 -> 0 dB > Presumably you can check the effects of changing the value? It seems > plausible that what's written in the code might be accurate and the > higher values might actually change the gain but it'd be better to > check. I haven't noticed a (measurable) change in gain when switching between 10 and 11, but my testing equipment is also not that great. Will try to improve the tests accuracy. Thanks, Cristian
On Wed, May 24, 2023 at 04:49:37PM +0300, Cristian Ciocaltea wrote: > On 5/24/23 13:30, Mark Brown wrote: > > Presumably you can check the effects of changing the value? It seems > > plausible that what's written in the code might be accurate and the > > higher values might actually change the gain but it'd be better to > > check. > I haven't noticed a (measurable) change in gain when switching between > 10 and 11, but my testing equipment is also not that great. Will try to > improve the tests accuracy. I'd expect it should be really obvious with a scope if you've got one? Testing with something consistent like a sine wave (eg, from speaker-test) should also make a 1.5dB difference noticable enough to check if there's at least a volume change by ear even if you can't specifically quantify it.
On 5/24/23 16:59, Mark Brown wrote: > On Wed, May 24, 2023 at 04:49:37PM +0300, Cristian Ciocaltea wrote: >> On 5/24/23 13:30, Mark Brown wrote: > >>> Presumably you can check the effects of changing the value? It seems >>> plausible that what's written in the code might be accurate and the >>> higher values might actually change the gain but it'd be better to >>> check. > >> I haven't noticed a (measurable) change in gain when switching between >> 10 and 11, but my testing equipment is also not that great. Will try to >> improve the tests accuracy. > > I'd expect it should be really obvious with a scope if you've got one? > Testing with something consistent like a sine wave (eg, from > speaker-test) should also make a 1.5dB difference noticable enough to > check if there's at least a volume change by ear even if you can't > specifically quantify it. Luckily arecord & aplay provide VU meter support (via -V, --vumeter=TYPE'), so I could easily verify this without using any additional tools: Volume | VU meter ---------+---------- -6.0 dB | 30-31 % -4.5 dB | 35-36 % -3.0 dB | 42-43 % -1.5 dB | 50-51 % -0.0 dB | 50-51 % So it seems the specs are correct, and the problem is the hardware default. Is there a better approach to handle this than extending the volume range? Regards, Cristian
On Fri, May 26, 2023 at 09:11:49PM +0300, Cristian Ciocaltea wrote: > -1.5 dB | 50-51 % > -0.0 dB | 50-51 % > So it seems the specs are correct, and the problem is the hardware default. > Is there a better approach to handle this than extending the volume range? The other option would be to change the value in the register during probe to one that's in range, that wouldn't stop any existing saved settings from generating errors but would mean there wouldn't be any new ones. Either approach is probably fine.
On 5/30/23 14:36, Mark Brown wrote: > On Fri, May 26, 2023 at 09:11:49PM +0300, Cristian Ciocaltea wrote: > >> -1.5 dB | 50-51 % >> -0.0 dB | 50-51 % > >> So it seems the specs are correct, and the problem is the hardware default. > >> Is there a better approach to handle this than extending the volume range? > > The other option would be to change the value in the register during > probe to one that's in range, that wouldn't stop any existing saved > settings from generating errors but would mean there wouldn't be any new > ones. Either approach is probably fine. Thanks, I will prepare v2 and keep the current approach.
On Tue, May 30, 2023 at 03:52:52PM +0300, Cristian Ciocaltea wrote: > On 5/30/23 14:36, Mark Brown wrote: > > The other option would be to change the value in the register during > > probe to one that's in range, that wouldn't stop any existing saved > > settings from generating errors but would mean there wouldn't be any new > > ones. Either approach is probably fine. > Thanks, I will prepare v2 and keep the current approach. OK. Remember that the TLV will need to be updated to show the two values having identical effect.
diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c index 9e033fb320a0..773c94fd3547 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -115,7 +115,7 @@ static const struct snd_kcontrol_new es8316_snd_controls[] = { alc_max_gain_tlv), SOC_SINGLE_TLV("ALC Capture Min Volume", ES8316_ADC_ALC2, 0, 28, 0, alc_min_gain_tlv), - SOC_SINGLE_TLV("ALC Capture Target Volume", ES8316_ADC_ALC3, 4, 10, 0, + SOC_SINGLE_TLV("ALC Capture Target Volume", ES8316_ADC_ALC3, 4, 11, 0, alc_target_tlv), SOC_SINGLE("ALC Capture Hold Time", ES8316_ADC_ALC3, 0, 10, 0), SOC_SINGLE("ALC Capture Decay Time", ES8316_ADC_ALC4, 4, 10, 0),