From patchwork Mon Dec 11 13:26:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13487211 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 CC7513E474; Mon, 11 Dec 2023 13:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JdrWVEgw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5879BC433CA; Mon, 11 Dec 2023 13:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702301145; bh=CR4WEiVLSbI2eaXlZ+1qwly9qiLQTKtm9P5IJp8GAYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JdrWVEgwfxDc3wu20xBwcrinYaKy9S/4VKOe2QcSwApLUdLd98hme+dafUfnIfslC VFr1/X/On6ADNdadg3HQG8Ax2xuuvxNT/v+BxdjKJ3PpC5icWCBW6pi1Ikt0N1xasX QfFluSUWQuyWw8FnN3K2H8hR/KQcbswmsVnSuHwMMDzeSF4zQew0e/Xt3fVj/KSI21 y5y2UN6d8W4EpJM1HsnUl9J/6mppJ62SjUYm+zftSjaCYoilQBDmmSx3TiToYW2520 Ok1fnf7nOvLnsPhR0dT4Z7hMU7KgPWAavD97ZovBr6TYAGYJqrkFTSM2gkq5RVTGR3 zIpKvPf2igNsg== Received: from johan by xi.lan with local (Exim 4.96.2) (envelope-from ) id 1rCgIq-0007Fh-0m; Mon, 11 Dec 2023 14:26:32 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: Sasha Levin , stable@vger.kernel.org, broonie@kernel.org, alsa-devel@alsa-project.org, perex@perex.cz, tiwai@suse.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, johan+linaro@kernel.org, srinivas.kandagatla@linaro.org Subject: [PATCH stable-6.6 1/2] ASoC: ops: add correct range check for limiting volume Date: Mon, 11 Dec 2023 14:26:07 +0100 Message-ID: <20231211132608.27861-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211132608.27861-1-johan+linaro@kernel.org> References: <20231211132608.27861-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Srinivas Kandagatla commit fb9ad24485087e0f00d84bee7a5914640b2b9024 upstream. Volume can have ranges that start with negative values, ex: -84dB to +40dB. Apply correct range check in snd_soc_limit_volume before setting the platform_max. Without this patch, for example setting a 0dB limit on a volume range of -84dB to +40dB would fail. Signed-off-by: Srinivas Kandagatla Tested-by: Johan Hovold Reviewed-by: Johan Hovold Link: https://lore.kernel.org/r/20231204124736.132185-2-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown Signed-off-by: Johan Hovold --- sound/soc/soc-ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index 55b009d3c681..2d25748ca706 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -661,7 +661,7 @@ int snd_soc_limit_volume(struct snd_soc_card *card, kctl = snd_soc_card_get_kcontrol(card, name); if (kctl) { struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value; - if (max <= mc->max) { + if (max <= mc->max - mc->min) { mc->platform_max = max; ret = 0; } From patchwork Mon Dec 11 13:26:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13487210 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 C011A3E472; Mon, 11 Dec 2023 13:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cS/iWytV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53085C433C7; Mon, 11 Dec 2023 13:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702301145; bh=/z+1W086U9uqPBNKB8aX+O++X4c1G0rkhD8UdWMNhzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cS/iWytVlYQM0gozRB+Upq9CcIRrAvHsRFH6RQAkA1LWOcZagdgs3QQjBjKh2pVvG ZFWp+/Z3CseCAgK6+JwoLQpZpkj8yhwlr0hISQFT4+CvkKkYX7VZZuoLBnJTKe5++f Gsty+T7k9GY3hBQYrmPQUkNNCVbun56KPl7tMCQcMoKyIq7eg1aj+o11ffMLX3x7CT Qa3ZO0/Ce82thdg6p9AwPChR7f+GWLnKW1/ImDclts5x8ABjzTr4pICELFPQAH+5hN 1w5BBDgSEwzP5ZtaGCJeM8iwGrNBi5Om+KLerFSJYLnfA8TnXkf6+OVc1+L/C3Bx/r h6ARAZJ3U+NZA== Received: from johan by xi.lan with local (Exim 4.96.2) (envelope-from ) id 1rCgIq-0007Fj-10; Mon, 11 Dec 2023 14:26:32 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: Sasha Levin , stable@vger.kernel.org, broonie@kernel.org, alsa-devel@alsa-project.org, perex@perex.cz, tiwai@suse.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, johan+linaro@kernel.org, srinivas.kandagatla@linaro.org Subject: [PATCH stable-6.6 2/2] ASoC: qcom: sc8280xp: Limit speaker digital volumes Date: Mon, 11 Dec 2023 14:26:08 +0100 Message-ID: <20231211132608.27861-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211132608.27861-1-johan+linaro@kernel.org> References: <20231211132608.27861-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Srinivas Kandagatla commit 716d4e5373e9d1ae993485ab2e3b893bf7104fb1 upstream. Limit the speaker digital gains to 0dB so that the users will not damage them. Currently there is a limit in UCM, but this does not stop the user form changing the digital gains from command line. So limit this in driver which makes the speakers more safer without active speaker protection in place. Signed-off-by: Srinivas Kandagatla Reviewed-by: Johan Hovold Tested-by: Johan Hovold Link: https://lore.kernel.org/r/20231204124736.132185-3-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown [ johan: backport to 6.6; rename snd_soc_rtd_to_cpu() ] Signed-off-by: Johan Hovold --- sound/soc/qcom/sc8280xp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sound/soc/qcom/sc8280xp.c b/sound/soc/qcom/sc8280xp.c index 14d9fea33d16..c61cad0180c8 100644 --- a/sound/soc/qcom/sc8280xp.c +++ b/sound/soc/qcom/sc8280xp.c @@ -27,6 +27,23 @@ struct sc8280xp_snd_data { static int sc8280xp_snd_init(struct snd_soc_pcm_runtime *rtd) { struct sc8280xp_snd_data *data = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); + struct snd_soc_card *card = rtd->card; + + switch (cpu_dai->id) { + 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 + */ + snd_soc_limit_volume(card, "WSA_RX0 Digital Volume", 84); + snd_soc_limit_volume(card, "WSA_RX1 Digital Volume", 84); + break; + default: + break; + } return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); }