summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorXing Zheng <zhengxing@rock-chips.com>2019-01-30 10:36:49 +0800
committerTao Huang <huangtao@rock-chips.com>2019-02-01 11:51:16 +0800
commitfdff04d652f0df833b1487ef11ed95653b1868c6 (patch)
tree54eadd4b3f7261307432f84d58c17d59dab8b700 /sound
parentbfcfeef064d4ea829dad238a6d22a038d3a14bed (diff)
ASoC: rk3308_codec: Add controls for main MICBIAS switch
Change-Id: I8a2a113df7fd427634e1a1f81632725d7d4ecdc0 Signed-off-by: Xing Zheng <zhengxing@rock-chips.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/rk3308_codec.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/sound/soc/codecs/rk3308_codec.c b/sound/soc/codecs/rk3308_codec.c
index e0caf94ff451..e8e67bbf3320 100644
--- a/sound/soc/codecs/rk3308_codec.c
+++ b/sound/soc/codecs/rk3308_codec.c
@@ -245,6 +245,10 @@ static const DECLARE_TLV_DB_RANGE(rk3308_codec_adc_mic_gain_tlv_b,
static bool handle_loopback(struct rk3308_codec_priv *rk3308);
+static int rk3308_codec_micbias_enable(struct rk3308_codec_priv *rk3308,
+ int micbias);
+static int rk3308_codec_micbias_disable(struct rk3308_codec_priv *rk3308);
+
static int rk3308_codec_hpout_l_get_tlv(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
static int rk3308_codec_hpout_l_put_tlv(struct snd_kcontrol *kcontrol,
@@ -273,6 +277,10 @@ static int rk3308_codec_mic_gain_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
static int rk3308_codec_mic_gain_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
+static int rk3308_codec_main_micbias_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol);
+static int rk3308_codec_main_micbias_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol);
static const char *offon_text[2] = {
[0] = "Off",
@@ -284,6 +292,11 @@ static const char *mute_text[2] = {
[1] = "Mute",
};
+/* ADC MICBIAS1 and MICBIAS2 Main Switch */
+static const struct soc_enum rk3308_main_micbias_enum_array[] = {
+ SOC_ENUM_SINGLE(0, 0, ARRAY_SIZE(offon_text), offon_text),
+};
+
static const struct soc_enum rk3308_hpf_enum_array[] = {
SOC_ENUM_SINGLE(0, 0, ARRAY_SIZE(offon_text), offon_text),
SOC_ENUM_SINGLE(1, 0, ARRAY_SIZE(offon_text), offon_text),
@@ -681,6 +694,10 @@ static const struct snd_kcontrol_new rk3308_codec_dapm_controls[] = {
SOC_ENUM_EXT("AGC Group 3 Right Approximate Sample Rate", rk3308_agc_asr_enum_array[7],
rk3308_codec_agc_asr_get, rk3308_codec_agc_asr_put),
+ /* ADC Main MICBIAS Switch */
+ SOC_ENUM_EXT("ADC Main MICBIAS", rk3308_main_micbias_enum_array[0],
+ rk3308_codec_main_micbias_get, rk3308_codec_main_micbias_put),
+
/* ADC MICBIAS1 and MICBIAS2 Switch */
SOC_SINGLE("ADC MICBIAS1", RK3308_ADC_ANA_CON07(1),
RK3308_ADC_MIC_BIAS_BUF_SFT, 1, 0),
@@ -1025,6 +1042,35 @@ static int rk3308_codec_mic_mute_put(struct snd_kcontrol *kcontrol,
return 0;
}
+static int rk3308_codec_main_micbias_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+ struct rk3308_codec_priv *rk3308 = snd_soc_codec_get_drvdata(codec);
+
+ ucontrol->value.integer.value[0] = rk3308->enable_micbias;
+
+ return 0;
+}
+
+static int rk3308_codec_main_micbias_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+ struct rk3308_codec_priv *rk3308 = snd_soc_codec_get_drvdata(codec);
+ unsigned int on = ucontrol->value.integer.value[0];
+
+ if (on) {
+ if (!rk3308->enable_micbias)
+ rk3308_codec_micbias_enable(rk3308, RK3308_ADC_MICBIAS_VOLT_0_85);
+ } else {
+ if (rk3308->enable_micbias)
+ rk3308_codec_micbias_disable(rk3308);
+ }
+
+ return 0;
+}
+
static int rk3308_codec_mic_gain_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{