diff options
author | Charles Keepax | 2015-06-25 09:35:12 +0100 |
---|---|---|
committer | Mark Brown | 2015-07-07 13:15:12 +0100 |
commit | 5f8e671a49e1d608fcf52c8944ea7818cd4c99a9 (patch) | |
tree | 8802ff671911422dd7866a21d5ebe56b900eac5d /sound/soc/codecs/arizona.c | |
parent | c05d9a8c7f55a901d9e8ec2a5f0730137bbfea4a (diff) |
ASoC: arizona: Implement stability check for LHPF coefficients
Specifying unstable coefficients for the low/high pass filters can have
a severe impact on the audio. This patchs adds a stability check on the
coefficients written to the low/high pass filter block to prevent this.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/arizona.c')
-rw-r--r-- | sound/soc/codecs/arizona.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index 39967863d2ec..a88202d768f4 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -2372,6 +2372,23 @@ out: } EXPORT_SYMBOL_GPL(arizona_eq_coeff_put); +int arizona_lhpf_coeff_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + __be16 *data = (__be16 *)ucontrol->value.bytes.data; + s16 val = be16_to_cpu(*data); + + if (abs(val) >= 4096) { + dev_err(arizona->dev, "Rejecting unstable LHPF coefficients\n"); + return -EINVAL; + } + + return snd_soc_bytes_put(kcontrol, ucontrol); +} +EXPORT_SYMBOL_GPL(arizona_lhpf_coeff_put); + MODULE_DESCRIPTION("ASoC Wolfson Arizona class device support"); MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); MODULE_LICENSE("GPL"); |