Commit 85e7dd3f authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

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: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 601516a6
...@@ -174,6 +174,9 @@ struct arizona_pdata { ...@@ -174,6 +174,9 @@ struct arizona_pdata {
/** Mode for outputs */ /** Mode for outputs */
int out_mono[ARIZONA_MAX_OUTPUT]; int out_mono[ARIZONA_MAX_OUTPUT];
/** Limit output volumes */
unsigned int out_vol_limit[2 * ARIZONA_MAX_OUTPUT];
/** PDM speaker mute setting */ /** PDM speaker mute setting */
unsigned int spk_mute[ARIZONA_MAX_PDM_SPK]; unsigned int spk_mute[ARIZONA_MAX_PDM_SPK];
......
...@@ -372,6 +372,22 @@ int arizona_init_common(struct arizona *arizona) ...@@ -372,6 +372,22 @@ int arizona_init_common(struct arizona *arizona)
} }
EXPORT_SYMBOL_GPL(arizona_init_common); 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] = { const char * const arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS] = {
"None", "None",
"Tone Generator 1", "Tone Generator 1",
...@@ -2810,6 +2826,15 @@ int arizona_of_get_audio_pdata(struct arizona *arizona) ...@@ -2810,6 +2826,15 @@ int arizona_of_get_audio_pdata(struct arizona *arizona)
count++; 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", ret = of_property_read_u32_array(np, "wlf,spk-fmt",
pdm_val, ARRAY_SIZE(pdm_val)); pdm_val, ARRAY_SIZE(pdm_val));
......
...@@ -315,6 +315,7 @@ int arizona_init_gpio(struct snd_soc_codec *codec); ...@@ -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_mono(struct snd_soc_codec *codec);
int arizona_init_common(struct arizona *arizona); 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_init_spk_irqs(struct arizona *arizona);
int arizona_free_spk_irqs(struct arizona *arizona); int arizona_free_spk_irqs(struct arizona *arizona);
......
...@@ -1297,6 +1297,9 @@ static int cs47l24_probe(struct platform_device *pdev) ...@@ -1297,6 +1297,9 @@ static int cs47l24_probe(struct platform_device *pdev)
arizona_init_common(arizona); arizona_init_common(arizona);
ret = arizona_init_vol_limit(arizona);
if (ret < 0)
goto err_dsp_irq;
ret = arizona_init_spk_irqs(arizona); ret = arizona_init_spk_irqs(arizona);
if (ret < 0) if (ret < 0)
goto err_dsp_irq; goto err_dsp_irq;
......
...@@ -2107,6 +2107,9 @@ static int wm5102_probe(struct platform_device *pdev) ...@@ -2107,6 +2107,9 @@ static int wm5102_probe(struct platform_device *pdev)
arizona_init_common(arizona); arizona_init_common(arizona);
ret = arizona_init_vol_limit(arizona);
if (ret < 0)
goto err_dsp_irq;
ret = arizona_init_spk_irqs(arizona); ret = arizona_init_spk_irqs(arizona);
if (ret < 0) if (ret < 0)
goto err_dsp_irq; goto err_dsp_irq;
......
...@@ -2463,6 +2463,9 @@ static int wm5110_probe(struct platform_device *pdev) ...@@ -2463,6 +2463,9 @@ static int wm5110_probe(struct platform_device *pdev)
arizona_init_common(arizona); arizona_init_common(arizona);
ret = arizona_init_vol_limit(arizona);
if (ret < 0)
goto err_dsp_irq;
ret = arizona_init_spk_irqs(arizona); ret = arizona_init_spk_irqs(arizona);
if (ret < 0) if (ret < 0)
goto err_dsp_irq; goto err_dsp_irq;
......
...@@ -1176,6 +1176,9 @@ static int wm8997_probe(struct platform_device *pdev) ...@@ -1176,6 +1176,9 @@ static int wm8997_probe(struct platform_device *pdev)
arizona_init_common(arizona); arizona_init_common(arizona);
ret = arizona_init_vol_limit(arizona);
if (ret < 0)
return ret;
ret = arizona_init_spk_irqs(arizona); ret = arizona_init_spk_irqs(arizona);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment