]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
ASoC: arizona: Add support for setting the output volume limits
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Mon, 4 Sep 2017 15:41:53 +0000 (16:41 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 20 Sep 2017 16:34:35 +0000 (17:34 +0100)
The output volume limits allow signals to be limited to specific levels
appropriate for the hardware attached. As this is a property of the
hardware itself these will be configured through device tree.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/linux/mfd/arizona/pdata.h
sound/soc/codecs/arizona.c
sound/soc/codecs/arizona.h
sound/soc/codecs/cs47l24.c
sound/soc/codecs/wm5102.c
sound/soc/codecs/wm5110.c
sound/soc/codecs/wm8997.c

index bfeecf179895b09edfb2ed5489e6293ca5a100d7..f72dc53848d705b3d09d57d9df466fb796e51669 100644 (file)
@@ -174,6 +174,9 @@ struct arizona_pdata {
        /** Mode for outputs */
        int out_mono[ARIZONA_MAX_OUTPUT];
 
+       /** Limit output volumes */
+       unsigned int out_vol_limit[2 * ARIZONA_MAX_OUTPUT];
+
        /** PDM speaker mute setting */
        unsigned int spk_mute[ARIZONA_MAX_PDM_SPK];
 
index e6967385dccb8264be7968a4dbe10f49f90a3587..b3375e19598a8372dbedbb4e012cb343d5c0fbdb 100644 (file)
@@ -372,6 +372,22 @@ int arizona_init_common(struct arizona *arizona)
 }
 EXPORT_SYMBOL_GPL(arizona_init_common);
 
+int arizona_init_vol_limit(struct arizona *arizona)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(arizona->pdata.out_vol_limit); ++i) {
+               if (arizona->pdata.out_vol_limit[i])
+                       regmap_update_bits(arizona->regmap,
+                                          ARIZONA_DAC_VOLUME_LIMIT_1L + i * 4,
+                                          ARIZONA_OUT1L_VOL_LIM_MASK,
+                                          arizona->pdata.out_vol_limit[i]);
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(arizona_init_vol_limit);
+
 const char * const arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS] = {
        "None",
        "Tone Generator 1",
@@ -2810,6 +2826,15 @@ int arizona_of_get_audio_pdata(struct arizona *arizona)
                count++;
        }
 
+       count = 0;
+       of_property_for_each_u32(np, "wlf,out-volume-limit", prop, cur, val) {
+               if (count == ARRAY_SIZE(pdata->out_vol_limit))
+                       break;
+
+               pdata->out_vol_limit[count] = val;
+               count++;
+       }
+
        ret = of_property_read_u32_array(np, "wlf,spk-fmt",
                                         pdm_val, ARRAY_SIZE(pdm_val));
 
index 2d198fb2ce97d3865a0c5bcb79f0cc69ef0f5cca..dfdf6d8c9687f72d4bfc0ff77d9c0b132687e56d 100644 (file)
@@ -315,6 +315,7 @@ int arizona_init_gpio(struct snd_soc_codec *codec);
 int arizona_init_mono(struct snd_soc_codec *codec);
 
 int arizona_init_common(struct arizona *arizona);
+int arizona_init_vol_limit(struct arizona *arizona);
 
 int arizona_init_spk_irqs(struct arizona *arizona);
 int arizona_free_spk_irqs(struct arizona *arizona);
index 0fe7d7a87ff33c550f6593919e74afdf299b2449..94c0209977d0bfd2a9a63bc0a4858d26a5a5a3a5 100644 (file)
@@ -1297,6 +1297,9 @@ static int cs47l24_probe(struct platform_device *pdev)
 
        arizona_init_common(arizona);
 
+       ret = arizona_init_vol_limit(arizona);
+       if (ret < 0)
+               goto err_dsp_irq;
        ret = arizona_init_spk_irqs(arizona);
        if (ret < 0)
                goto err_dsp_irq;
index 5a917dd73f3298dfefe838d83f1c110cc917855b..4f0481d3c7a7117894c209d217d403e1946d5393 100644 (file)
@@ -2107,6 +2107,9 @@ static int wm5102_probe(struct platform_device *pdev)
 
        arizona_init_common(arizona);
 
+       ret = arizona_init_vol_limit(arizona);
+       if (ret < 0)
+               goto err_dsp_irq;
        ret = arizona_init_spk_irqs(arizona);
        if (ret < 0)
                goto err_dsp_irq;
index ba1e90ca8be4696dfe4f8e74361b623d138ebbda..6ed1e1f9ce516cb4867f51a0edb1e83e5ddf34a7 100644 (file)
@@ -2463,6 +2463,9 @@ static int wm5110_probe(struct platform_device *pdev)
 
        arizona_init_common(arizona);
 
+       ret = arizona_init_vol_limit(arizona);
+       if (ret < 0)
+               goto err_dsp_irq;
        ret = arizona_init_spk_irqs(arizona);
        if (ret < 0)
                goto err_dsp_irq;
index c5aef9ecdecc4fa430384142417912fb14a1e31b..77f512767273f4e0813f77bdce632e46b1fd83fb 100644 (file)
@@ -1176,6 +1176,9 @@ static int wm8997_probe(struct platform_device *pdev)
 
        arizona_init_common(arizona);
 
+       ret = arizona_init_vol_limit(arizona);
+       if (ret < 0)
+               return ret;
        ret = arizona_init_spk_irqs(arizona);
        if (ret < 0)
                return ret;