From: Liam Girdwood Date: Wed, 11 Jan 2012 12:43:24 +0000 (+0000) Subject: ASoC: twl6040 - Add method to query optimum PDM_DL1 gain X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e48b46ba169181dc88ea48e31dcb4afcf8778397;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 --- 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 #include #include +#include #include #include @@ -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); diff --git a/sound/soc/codecs/twl6040.h b/sound/soc/codecs/twl6040.h index a83277bdb851..ef273f1fac2f 100644 --- a/sound/soc/codecs/twl6040.h +++ b/sound/soc/codecs/twl6040.h @@ -34,6 +34,7 @@ enum twl6040_trim { #define TWL6040_HSF_TRIM_LEFT(x) (x & 0x0f) #define TWL6040_HSF_TRIM_RIGHT(x) ((x >> 4) & 0x0f) +int twl6040_get_dl1_gain(struct snd_soc_codec *codec); void twl6040_hs_jack_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, int report); int twl6040_get_clk_id(struct snd_soc_codec *codec);