summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.cirrus.com>2017-09-04 11:41:53 -0400
committerMark Brown <broonie@kernel.org>2017-09-20 12:34:35 -0400
commit85e7dd3f871b988702973c80d9ef128e10dd3dad (patch)
tree4a7a73ae4ce07686c0e19a1dc976e4fe8bb32c14
parent601516a6f8cf9118a7c65ec38aa53896efc446bb (diff)
ASoC: arizona: Add support for setting the output volume limits
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>
-rw-r--r--include/linux/mfd/arizona/pdata.h3
-rw-r--r--sound/soc/codecs/arizona.c25
-rw-r--r--sound/soc/codecs/arizona.h1
-rw-r--r--sound/soc/codecs/cs47l24.c3
-rw-r--r--sound/soc/codecs/wm5102.c3
-rw-r--r--sound/soc/codecs/wm5110.c3
-rw-r--r--sound/soc/codecs/wm8997.c3
7 files changed, 41 insertions, 0 deletions
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index bfeecf179895..f72dc53848d7 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -174,6 +174,9 @@ struct arizona_pdata {
174 /** Mode for outputs */ 174 /** Mode for outputs */
175 int out_mono[ARIZONA_MAX_OUTPUT]; 175 int out_mono[ARIZONA_MAX_OUTPUT];
176 176
177 /** Limit output volumes */
178 unsigned int out_vol_limit[2 * ARIZONA_MAX_OUTPUT];
179
177 /** PDM speaker mute setting */ 180 /** PDM speaker mute setting */
178 unsigned int spk_mute[ARIZONA_MAX_PDM_SPK]; 181 unsigned int spk_mute[ARIZONA_MAX_PDM_SPK];
179 182
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index e6967385dccb..b3375e19598a 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -372,6 +372,22 @@ int arizona_init_common(struct arizona *arizona)
372} 372}
373EXPORT_SYMBOL_GPL(arizona_init_common); 373EXPORT_SYMBOL_GPL(arizona_init_common);
374 374
375int arizona_init_vol_limit(struct arizona *arizona)
376{
377 int i;
378
379 for (i = 0; i < ARRAY_SIZE(arizona->pdata.out_vol_limit); ++i) {
380 if (arizona->pdata.out_vol_limit[i])
381 regmap_update_bits(arizona->regmap,
382 ARIZONA_DAC_VOLUME_LIMIT_1L + i * 4,
383 ARIZONA_OUT1L_VOL_LIM_MASK,
384 arizona->pdata.out_vol_limit[i]);
385 }
386
387 return 0;
388}
389EXPORT_SYMBOL_GPL(arizona_init_vol_limit);
390
375const char * const arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS] = { 391const char * const arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS] = {
376 "None", 392 "None",
377 "Tone Generator 1", 393 "Tone Generator 1",
@@ -2810,6 +2826,15 @@ int arizona_of_get_audio_pdata(struct arizona *arizona)
2810 count++; 2826 count++;
2811 } 2827 }
2812 2828
2829 count = 0;
2830 of_property_for_each_u32(np, "wlf,out-volume-limit", prop, cur, val) {
2831 if (count == ARRAY_SIZE(pdata->out_vol_limit))
2832 break;
2833
2834 pdata->out_vol_limit[count] = val;
2835 count++;
2836 }
2837
2813 ret = of_property_read_u32_array(np, "wlf,spk-fmt", 2838 ret = of_property_read_u32_array(np, "wlf,spk-fmt",
2814 pdm_val, ARRAY_SIZE(pdm_val)); 2839 pdm_val, ARRAY_SIZE(pdm_val));
2815 2840
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index 2d198fb2ce97..dfdf6d8c9687 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -315,6 +315,7 @@ int arizona_init_gpio(struct snd_soc_codec *codec);
315int arizona_init_mono(struct snd_soc_codec *codec); 315int arizona_init_mono(struct snd_soc_codec *codec);
316 316
317int arizona_init_common(struct arizona *arizona); 317int arizona_init_common(struct arizona *arizona);
318int arizona_init_vol_limit(struct arizona *arizona);
318 319
319int arizona_init_spk_irqs(struct arizona *arizona); 320int arizona_init_spk_irqs(struct arizona *arizona);
320int arizona_free_spk_irqs(struct arizona *arizona); 321int arizona_free_spk_irqs(struct arizona *arizona);
diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c
index 0fe7d7a87ff3..94c0209977d0 100644
--- a/sound/soc/codecs/cs47l24.c
+++ b/sound/soc/codecs/cs47l24.c
@@ -1297,6 +1297,9 @@ static int cs47l24_probe(struct platform_device *pdev)
1297 1297
1298 arizona_init_common(arizona); 1298 arizona_init_common(arizona);
1299 1299
1300 ret = arizona_init_vol_limit(arizona);
1301 if (ret < 0)
1302 goto err_dsp_irq;
1300 ret = arizona_init_spk_irqs(arizona); 1303 ret = arizona_init_spk_irqs(arizona);
1301 if (ret < 0) 1304 if (ret < 0)
1302 goto err_dsp_irq; 1305 goto err_dsp_irq;
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index 5a917dd73f32..4f0481d3c7a7 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -2107,6 +2107,9 @@ static int wm5102_probe(struct platform_device *pdev)
2107 2107
2108 arizona_init_common(arizona); 2108 arizona_init_common(arizona);
2109 2109
2110 ret = arizona_init_vol_limit(arizona);
2111 if (ret < 0)
2112 goto err_dsp_irq;
2110 ret = arizona_init_spk_irqs(arizona); 2113 ret = arizona_init_spk_irqs(arizona);
2111 if (ret < 0) 2114 if (ret < 0)
2112 goto err_dsp_irq; 2115 goto err_dsp_irq;
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index ba1e90ca8be4..6ed1e1f9ce51 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -2463,6 +2463,9 @@ static int wm5110_probe(struct platform_device *pdev)
2463 2463
2464 arizona_init_common(arizona); 2464 arizona_init_common(arizona);
2465 2465
2466 ret = arizona_init_vol_limit(arizona);
2467 if (ret < 0)
2468 goto err_dsp_irq;
2466 ret = arizona_init_spk_irqs(arizona); 2469 ret = arizona_init_spk_irqs(arizona);
2467 if (ret < 0) 2470 if (ret < 0)
2468 goto err_dsp_irq; 2471 goto err_dsp_irq;
diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c
index c5aef9ecdecc..77f512767273 100644
--- a/sound/soc/codecs/wm8997.c
+++ b/sound/soc/codecs/wm8997.c
@@ -1176,6 +1176,9 @@ static int wm8997_probe(struct platform_device *pdev)
1176 1176
1177 arizona_init_common(arizona); 1177 arizona_init_common(arizona);
1178 1178
1179 ret = arizona_init_vol_limit(arizona);
1180 if (ret < 0)
1181 return ret;
1179 ret = arizona_init_spk_irqs(arizona); 1182 ret = arizona_init_spk_irqs(arizona);
1180 if (ret < 0) 1183 if (ret < 0)
1181 return ret; 1184 return ret;