Skip to content

Commit 0a10d15

Browse files
committed
ASoC: qcom: Limit Digital gains on speaker
Merge series from [email protected]: 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. Apart from this there is also a range check fix in snd_soc_limit_volume to allow setting this limit correctly. Tested on Lenovo X13s.
2 parents 29046a7 + 716d4e5 commit 0a10d15

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

sound/soc/qcom/sc8280xp.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ struct sc8280xp_snd_data {
2727
static int sc8280xp_snd_init(struct snd_soc_pcm_runtime *rtd)
2828
{
2929
struct sc8280xp_snd_data *data = snd_soc_card_get_drvdata(rtd->card);
30+
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
31+
struct snd_soc_card *card = rtd->card;
32+
33+
switch (cpu_dai->id) {
34+
case WSA_CODEC_DMA_RX_0:
35+
case WSA_CODEC_DMA_RX_1:
36+
/*
37+
* set limit of 0dB on Digital Volume for Speakers,
38+
* this can prevent damage of speakers to some extent without
39+
* active speaker protection
40+
*/
41+
snd_soc_limit_volume(card, "WSA_RX0 Digital Volume", 84);
42+
snd_soc_limit_volume(card, "WSA_RX1 Digital Volume", 84);
43+
break;
44+
default:
45+
break;
46+
}
3047

3148
return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup);
3249
}

sound/soc/soc-ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ int snd_soc_limit_volume(struct snd_soc_card *card,
661661
kctl = snd_soc_card_get_kcontrol(card, name);
662662
if (kctl) {
663663
struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;
664-
if (max <= mc->max) {
664+
if (max <= mc->max - mc->min) {
665665
mc->platform_max = max;
666666
ret = 0;
667667
}

0 commit comments

Comments
 (0)