diff options
author | Liam Girdwood <lrg@ti.com> | 2012-01-11 16:43:24 +0400 |
---|---|---|
committer | Liam Girdwood <lrg@ti.com> | 2012-01-11 16:43:24 +0400 |
commit | e48b46ba169181dc88ea48e31dcb4afcf8778397 (patch) | |
tree | 48aea71559fec05f3cfab43602657aaa60cf8627 /sound/soc/codecs/twl6040.c | |
parent | f75a8ff67d161b5166a2c2360bb2ffaefd5eb853 (diff) | |
download | linux-e48b46ba169181dc88ea48e31dcb4afcf8778397.tar.xz |
ASoC: twl6040 - Add method to query optimum PDM_DL1 gain
The DL1 PDM interface adds a little gain depending on the output device.
Add a method to retrieve the gain value for machine driver usage.
Signed-off-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'sound/soc/codecs/twl6040.c')
-rw-r--r-- | sound/soc/codecs/twl6040.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 3376e6fad2a2..5b9c79b6f65e 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -33,6 +33,7 @@ #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> +#include <sound/soc-dapm.h> #include <sound/initval.h> #include <sound/tlv.h> @@ -1012,6 +1013,28 @@ static int twl6040_pll_put_enum(struct snd_kcontrol *kcontrol, return 0; } +int twl6040_get_dl1_gain(struct snd_soc_codec *codec) +{ + struct snd_soc_dapm_context *dapm = &codec->dapm; + + if (snd_soc_dapm_get_pin_status(dapm, "EP")) + return -1; /* -1dB */ + + if (snd_soc_dapm_get_pin_status(dapm, "HSOR") || + snd_soc_dapm_get_pin_status(dapm, "HSOL")) { + + u8 val = snd_soc_read(codec, TWL6040_REG_HSLCTL); + if (val & TWL6040_HSDACMODE) + /* HSDACL in LP mode */ + return -8; /* -8dB */ + else + /* HSDACL in HP mode */ + return -1; /* -1dB */ + } + return 0; /* 0dB */ +} +EXPORT_SYMBOL_GPL(twl6040_get_dl1_gain); + int twl6040_get_clk_id(struct snd_soc_codec *codec) { struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); |