2024-01-16 09:40:11

by Johan Hovold

[permalink] [raw]
Subject: [PATCH 1/7] ASoC: qcom: sc8280xp: limit speaker volumes

The current UCM configuration sets the speaker PA volume to 15 dB when
enabling the speakers but this does not prevent the user from increasing
the volume further.

Limit the PA volume to 15 dB in the machine driver to reduce the risk of
speaker damage until we have active speaker protection in place.

Note that this will probably need to be generalised using
machine-specific limits, but a common limit should do for now.

Cc: [email protected] # 6.5
Signed-off-by: Johan Hovold <[email protected]>
---
sound/soc/qcom/sc8280xp.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/soc/qcom/sc8280xp.c b/sound/soc/qcom/sc8280xp.c
index ed4bb551bfbb..aa43903421f5 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 0 dB on Digital Volume and 15 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, "SpkrLeft PA Volume", 12);
+ snd_soc_limit_volume(card, "SpkrRight PA Volume", 12);
break;
default:
break;
--
2.41.0



2024-01-16 11:12:20

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH 1/7] ASoC: qcom: sc8280xp: limit speaker volumes



On 16/01/2024 09:38, Johan Hovold wrote:
> The current UCM configuration sets the speaker PA volume to 15 dB when
> enabling the speakers but this does not prevent the user from increasing
> the volume further.
>
> Limit the PA volume to 15 dB in the machine driver to reduce the risk of
> speaker damage until we have active speaker protection in place.
>
> Note that this will probably need to be generalised using
> machine-specific limits, but a common limit should do for now.
>
> Cc: [email protected] # 6.5
> Signed-off-by: Johan Hovold <[email protected]>

LGTM, We can get rid of this limit once we have Speaker protection inplace.


Reviewed-by: Srinivas Kandagatla <[email protected]>

--srini

> ---
> sound/soc/qcom/sc8280xp.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/qcom/sc8280xp.c b/sound/soc/qcom/sc8280xp.c
> index ed4bb551bfbb..aa43903421f5 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 0 dB on Digital Volume and 15 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, "SpkrLeft PA Volume", 12);
> + snd_soc_limit_volume(card, "SpkrRight PA Volume", 12);
> break;
> default:
> break;

2024-01-16 15:10:27

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 1/7] ASoC: qcom: sc8280xp: limit speaker volumes

On Tue, Jan 16, 2024 at 11:11:47AM +0000, Srinivas Kandagatla wrote:
> On 16/01/2024 09:38, Johan Hovold wrote:
> > The current UCM configuration sets the speaker PA volume to 15 dB when
> > enabling the speakers but this does not prevent the user from increasing
> > the volume further.
> >
> > Limit the PA volume to 15 dB in the machine driver to reduce the risk of
> > speaker damage until we have active speaker protection in place.

> LGTM, We can get rid of this limit once we have Speaker protection inplace.

There should be a userspace component for speaker protection so you'll
need to limit things when that's not running.


Attachments:
(No filename) (649.00 B)
signature.asc (499.00 B)
Download all attachments