ASoC: qcom: sc8280xp: Limit speaker digital volumes
[platform/kernel/linux-starfive.git] / sound / soc / qcom / sc8280xp.c
index 14d9fea..c61cad0 100644 (file)
@@ -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);
 }