Skip to contentSkip to conversation

ASoC: qcom: sc8280xp: Limit speaker digital volumes

PATCH In review Johan Hovold 5 participants 8 messages Dec 11, 2023 – Dec 13, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ASoC: qcom: sc8280xp: Limit speaker digital volumes

This is a backport of the following series:

	https://lore.kernel.org/lkml/[email protected]/

which did not build on 6.6 due a rename of the asoc_rtd_to_cpu() interface.

Johan

Srinivas Kandagatla (2):
ASoC: ops: add correct range check for limiting volume
ASoC: qcom: sc8280xp: Limit speaker digital volumes

 sound/soc/qcom/sc8280xp.c | 17 +++++++++++++++++
 sound/soc/soc-ops.c       |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/2 ASoC: ops: add correct range check for limiting volume

From: Srinivas Kandagatla <[email protected]>

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.

---
 sound/soc/soc-ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-ops.c +1 -1
index 55b009d3c681..2d25748ca706 100644
@@ -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;
 		}
Signature · 1 line
2.41.0
#2 lore raw

PATCH 2/2 ASoC: qcom: sc8280xp: Limit speaker digital volumes

In reply to Johan Hovold

From: Srinivas Kandagatla <[email protected]>

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.

---
 sound/soc/qcom/sc8280xp.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
sound/soc/qcom/sc8280xp.c +17 -0
index 14d9fea33d16..c61cad0180c8 100644
@@ -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);
 }
Signature · 1 line
2.41.0
#3 lore raw
FYI: kernel test robot notices the stable kernel rule is not satisfied.

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH 2/2] ASoC: qcom: sc8280xp: Limit speaker digital volumes

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw
Quoted 11 lines · kernel test robot

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH 2/2] ASoC: qcom: sc8280xp: Limit speaker digital volumes

Please fix your robot. This is a series of stable kernel backports so the above warning makes no sense.

Johan

#5 lore raw
Quoted 11 lines · Johan Hovold
Quoted 10 lines · kernel test robot

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH 2/2] ASoC: qcom: sc8280xp: Limit speaker digital volumes

                   ^
Quoted 4 lines
Quoted 1 line

Please fix your robot. This is a series of stable kernel backports so the above warning makes no sense.

Sorry for this wrong report. We introduced b4 tool into the robot recently to help simplify patch processing, but seems that b4 automatically removed the "stable-6.6" prefix in the patch subject when grabbing the mail thread, and triggered this wrong report. We've fixed this issue for the bot just now.

$ b4 am https://lore.kernel.org/all/[email protected]/
Cover: ./20231211_johan_linaro_asoc_qcom_sc8280xp_limit_speaker_digital_volumes.cover
 Link: https://lore.kernel.org/r/[email protected]
 Base: not specified
       git am ./20231211_johan_linaro_asoc_qcom_sc8280xp_limit_speaker_digital_volumes.mbx
$ grep -h ^Subject *johan_linaro*
Subject: [PATCH 0/2] ASoC: qcom: sc8280xp: Limit speaker digital volumes
Subject: [PATCH 1/2] ASoC: ops: add correct range check for limiting volume
Subject: [PATCH 2/2] ASoC: qcom: sc8280xp: Limit speaker digital volumes

Best Regards,
Yujie

#6 lore raw
Quoted 16 lines · Yujie Liu
Quoted 11 lines · Johan Hovold
Quoted 10 lines · kernel test robot

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH 2/2] ASoC: qcom: sc8280xp: Limit speaker digital volumes

                   ^
Quoted 2 lines
Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Please fix your robot. This is a series of stable kernel backports so the above warning makes no sense.

Sorry for this wrong report. We introduced b4 tool into the robot recently to help simplify patch processing, but seems that b4 automatically removed the "stable-6.6" prefix in the patch subject when grabbing the mail thread, and triggered this wrong report. We've fixed this issue for the bot just now.

Perfect, thanks!

Johan

#7 lore raw
In reply to Johan Hovold
Quoted 10 lines · Johan Hovold

This is a backport of the following series:

	https://lore.kernel.org/lkml/[email protected]/

which did not build on 6.6 due a rename of the asoc_rtd_to_cpu() interface.

Johan

Quoted 12 lines

Srinivas Kandagatla (2):
ASoC: ops: add correct range check for limiting volume
ASoC: qcom: sc8280xp: Limit speaker digital volumes

 sound/soc/qcom/sc8280xp.c | 17 +++++++++++++++++
 sound/soc/soc-ops.c       |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
Signature · 1 line
2.41.0

Now queued up, thanks.

greg k-h