Message ID | 20240119112420.7446-3-johan+linaro@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-31093-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp941371dyb; Fri, 19 Jan 2024 03:28:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGuM8wtnhXivZozO82LKxWFBwDoRFRNgtQHe8aFsHpt2Bie+yDP241MYbJ+/DVx8NyLmFGa X-Received: by 2002:aa7:ca4a:0:b0:559:ffd7:a19b with SMTP id j10-20020aa7ca4a000000b00559ffd7a19bmr1430008edt.30.1705663698042; Fri, 19 Jan 2024 03:28:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705663698; cv=pass; d=google.com; s=arc-20160816; b=FUwmnGDeUnGL7MPvok99dKBfWaxvjteILDYxRA/YceAs18SJAz7yTXrSTZwrvc6E/O wtgBDZnpq0zSi7wu3efJsxqpifOgP3g3L/+cXppH5yQnPDMDodyHgiAZcTqx8/iOaGrb kDUVE6Upr8UzVZYBB3WxpSQZThnR3y11jZJB2zOrc+RX1AjxcYxBVWlBY8m55uVwpvAy m8bw29WLlwwOHTbxFmwYJcT+VLF2fcxo0jzNh3szZxq/VcIDepXzvVrM07QzkfkbI+mF ZAkI7L0WYlMcWibJDXH6vcXITeQQyA4NqVFktVwBDtRWG83xo3dMSFqOq+4F10Zdn4Kl LTtg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=c+DpJ9SeHYaSGTLGq5MiWP+AM562CJX4gtOgV+LMQg0=; fh=KBIhiGdu1Ygtr3M+FTFcsBcOHAnQgw4Q3/a7frwkCBE=; b=0lNCymZpGPIT6o/cVKYvcj3W2TcNEUivO08GsEWq3Ay7jtdWJtnfNVZT4BCxvkPJtr nQ5L6anz1/CFpw6h7OGV7wfWMTWtwLCC6ljEGAMcJKxLux1paXYgcXl39ZBFqD+l5IIZ 8afF3fJaAUKebRuFUcobdDqswbyEwH71aYIgsbnDikxiDVtShbJMT3PNJhhIeq7y91/y Ctg0NWjbpADGxnnw5HDBLdpMbRDoqdUHBixE/K0ZoM2h6EH8peSCxLj7d0M6hxOyRLPI VJhGzI92hc7f1TIsVRaAinwwAgIEpPzQ0mUAY819m4iSBWIfF7u7xobf5AQ2oQ9UkFb3 QPew== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O3nxEPkA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-31093-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31093-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q32-20020a05640224a000b0055860ed12c4si8058612eda.612.2024.01.19.03.28.17 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 03:28:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31093-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O3nxEPkA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-31093-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31093-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A685E1F237BD for <ouuuleilei@gmail.com>; Fri, 19 Jan 2024 11:28:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76D2D4E1BC; Fri, 19 Jan 2024 11:26:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="O3nxEPkA" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3CCB4CDE3; Fri, 19 Jan 2024 11:26:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705663615; cv=none; b=TCv8J6qaiLCuvDyuD5rKbdYP5aAkzH5CY1SmFuES2fX/3Akw7NtEsXNAlGFCV/EpyDWbmC38xn8gx7AyOaD0ZWwyy2JS8Re8yhXL4wE8xxPZK56DFgQkWnUG4uSWWL7eBnoUTsT+4MBDjFof9KemzNpoAV60sEPBDuaiC2RMErE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705663615; c=relaxed/simple; bh=HuYa0Hs5Af/qVxD25qBo9TBTPaafJMPziE92BqysBBA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ChN4GSNM8P3eSqfFE9l7+zA8Nj0pIAahZol2XJkfR/VFazJKttYaTJ9lf+C+tdRvIX1QJshbhlKS+SrzrKIXRVlmXjy11ySRd9kX7ZCdbKb6+dChe9k1QJnCGZlKubK4J5eUMAXBU3KUHItjLTfzHaN8V8HlZB28HkxkUojNYjw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O3nxEPkA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28949C433B2; Fri, 19 Jan 2024 11:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705663615; bh=HuYa0Hs5Af/qVxD25qBo9TBTPaafJMPziE92BqysBBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3nxEPkA96L2O/NWjrzucPoxwhvHKV8dJJ77SyUattgWnQJGmC0BZiknQDuLdin16 KzErDIsOJoMpmCI3lijwVL7Z5dHTJ0VfyjQjAtw43CX99KQYMvPUbEnSZQGJRiqMph Jvi0C3orFIfEwnwF8lpyUVk6acPb5cgoqfA1vigp6dL8eyXLorQ07wpci4/DJqCG7w vOZHcaKJqymR/pCEVqA5i6iancpP6k7+id8e+i4CkvbHFRgn/ltm9c3nIo8yuPZ3Rp xfus0YgQjQfSKZ1KO5JP4S3hcUH7fAH4BtnfKjXc/jr8HrmJH17fAbRqjL7AQqUVg3 xxXOCKdrk3U7g== Received: from johan by xi.lan with local (Exim 4.96.2) (envelope-from <johan+linaro@kernel.org>) id 1rQn1b-0001xL-2w; Fri, 19 Jan 2024 12:27:03 +0100 From: Johan Hovold <johan+linaro@kernel.org> To: Mark Brown <broonie@kernel.org> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, Banajit Goswami <bgoswami@quicinc.com>, Liam Girdwood <lgirdwood@gmail.com>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold <johan+linaro@kernel.org>, stable@vger.kernel.org Subject: [PATCH v4 2/4] ASoC: qcom: sc8280xp: limit speaker volumes Date: Fri, 19 Jan 2024 12:24:18 +0100 Message-ID: <20240119112420.7446-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240119112420.7446-1-johan+linaro@kernel.org> References: <20240119112420.7446-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788518017796068412 X-GMAIL-MSGID: 1788518017796068412 |
Series | ASoC: qcom: volume fixes and codec cleanups | |
Commit Message
Johan Hovold
Jan. 19, 2024, 11:24 a.m. UTC
The UCM configuration for the Lenovo ThinkPad X13s has up until now
been setting the speaker PA volume to the minimum -3 dB when enabling
the speakers, but this does not prevent the user from increasing the
volume further.
Limit the digital gain and PA volumes to a combined -3 dB in the machine
driver to reduce the risk of speaker damage until we have active speaker
protection in place (or higher safe levels have been established).
Note that the PA volume limit cannot be set lower than 0 dB or
PulseAudio gets confused when the first 16 levels all map to -3 dB.
Also note that this will probably need to be generalised using
machine-specific limits, but a common limit should do for now.
Cc: stable@vger.kernel.org # 6.5
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
sound/soc/qcom/sc8280xp.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
Comments
On Fri, Jan 19, 2024 at 12:24:18PM +0100, Johan Hovold wrote: > The UCM configuration for the Lenovo ThinkPad X13s has up until now > been setting the speaker PA volume to the minimum -3 dB when enabling > the speakers, but this does not prevent the user from increasing the > volume further. > > Limit the digital gain and PA volumes to a combined -3 dB in the machine > driver to reduce the risk of speaker damage until we have active speaker > protection in place (or higher safe levels have been established). > > Note that the PA volume limit cannot be set lower than 0 dB or > PulseAudio gets confused when the first 16 levels all map to -3 dB. I tracked the down the root cause for this, which appears to be a bug (feature) in pulseaudio that causes it to reject the dB range if the maximum is negative: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/447 This happened to work with v3 which limited the PA volume to the single lowest setting, but would similarly break if anyone wants to set a -1.5 dB limit. Johan
On Fri, Jan 19, 2024 at 12:24:18PM +0100, Johan Hovold wrote: > The UCM configuration for the Lenovo ThinkPad X13s has up until now > been setting the speaker PA volume to the minimum -3 dB when enabling > the speakers, but this does not prevent the user from increasing the > volume further. This doesn't apply against current code, please check and resend.
On Mon, Jan 22, 2024 at 12:03:55AM +0000, Mark Brown wrote: > On Fri, Jan 19, 2024 at 12:24:18PM +0100, Johan Hovold wrote: > > The UCM configuration for the Lenovo ThinkPad X13s has up until now > > been setting the speaker PA volume to the minimum -3 dB when enabling > > the speakers, but this does not prevent the user from increasing the > > volume further. > > This doesn't apply against current code, please check and resend. These patches are based on Linus's tree after merging the sound updates and I just verified that they apply cleanly to 6.8-rc1. I couldn't find anything related in either linux-next or your ASoC tree that should interfere. Could you please try again or let me know which branch to rebase on? Johan
On Mon, Jan 22, 2024 at 08:41:59AM +0100, Johan Hovold wrote: > On Mon, Jan 22, 2024 at 12:03:55AM +0000, Mark Brown wrote: > > This doesn't apply against current code, please check and resend. > These patches are based on Linus's tree after merging the sound updates > and I just verified that they apply cleanly to 6.8-rc1. > I couldn't find anything related in either linux-next or your ASoC tree > that should interfere. > Could you please try again or let me know which branch to rebase on? I was applying it against v6.8-rc1.
On Mon, Jan 22, 2024 at 04:05:37PM +0000, Mark Brown wrote: > On Mon, Jan 22, 2024 at 08:41:59AM +0100, Johan Hovold wrote: > > On Mon, Jan 22, 2024 at 12:03:55AM +0000, Mark Brown wrote: > > > > This doesn't apply against current code, please check and resend. > > > These patches are based on Linus's tree after merging the sound updates > > and I just verified that they apply cleanly to 6.8-rc1. > > > I couldn't find anything related in either linux-next or your ASoC tree > > that should interfere. > > > Could you please try again or let me know which branch to rebase on? > > I was applying it against v6.8-rc1. That's what I assumed, but I still don't understand why it doesn't apply on your end: $ git checkout -b tmp v6.8-rc1 $ b4 am 20240119112420.7446-1-johan+linaro@kernel.org ... $ git am ./v4_20240119_johan_linaro_asoc_qcom_volume_fixes_and_codec_cleanups.mbx Applying: ASoC: codecs: wsa883x: fix PA volume control Applying: ASoC: qcom: sc8280xp: limit speaker volumes Applying: ASoC: codecs: lpass-wsa-macro: fix compander volume hack Applying: ASoC: codecs: wcd9335: drop unused gain hack remnant And if I generate patches from this branch, the diffs are identical to the v4 patches I sent. Could you please try again, and tell me which patch fails to apply and how it fails? Johan
On Mon, Jan 22, 2024 at 06:29:12PM +0100, Johan Hovold wrote: > Could you please try again, and tell me which patch fails to apply and > how it fails? It was the specific patch I replied to, just the standard "this patch doesn't apply" message.
On Mon, Jan 22, 2024 at 06:06:25PM +0000, Mark Brown wrote: > On Mon, Jan 22, 2024 at 06:29:12PM +0100, Johan Hovold wrote: > > > Could you please try again, and tell me which patch fails to apply and > > how it fails? > > It was the specific patch I replied to, just the standard "this patch > doesn't apply" message. Ok, thanks. No idea what goes wrong here. I just sent the regenerated patches as a v5. Johan
diff --git a/sound/soc/qcom/sc8280xp.c b/sound/soc/qcom/sc8280xp.c index ed4bb551bfbb..b7fd503a1666 100644 --- a/sound/soc/qcom/sc8280xp.c +++ b/sound/soc/qcom/sc8280xp.c @@ -32,12 +32,14 @@ static int sc8280xp_snd_init(struct snd_soc_pcm_runtime *rtd) case WSA_CODEC_DMA_RX_0: case WSA_CODEC_DMA_RX_1: /* - * set limit of 0dB on Digital Volume for Speakers, - * this can prevent damage of speakers to some extent without - * active speaker protection + * Set limit of -3 dB on Digital Volume and 0 dB on PA Volume + * to reduce the risk of speaker damage until we have active + * speaker protection in place. */ - snd_soc_limit_volume(card, "WSA_RX0 Digital Volume", 84); - snd_soc_limit_volume(card, "WSA_RX1 Digital Volume", 84); + snd_soc_limit_volume(card, "WSA_RX0 Digital Volume", 81); + snd_soc_limit_volume(card, "WSA_RX1 Digital Volume", 81); + snd_soc_limit_volume(card, "SpkrLeft PA Volume", 17); + snd_soc_limit_volume(card, "SpkrRight PA Volume", 17); break; default: break;