ASoC: rt5651: add alc5651 ASRC switch for HDMIIn
authorLuoXiaoTan <lxt@rock-chips.com>
Thu, 6 Apr 2017 09:29:32 +0000 (02:29 -0700)
committerHuang, Tao <huangtao@rock-chips.com>
Fri, 14 Apr 2017 09:09:46 +0000 (17:09 +0800)
Change-Id: I447228656d5ee56b2c4b04c515ad71f34e107ba0
Signed-off-by: LuoXiaoTan <lxt@rock-chips.com>
sound/soc/codecs/rt5651.c
sound/soc/codecs/rt5651.h

index f092758..7de7850 100644 (file)
@@ -286,6 +286,39 @@ static bool rt5651_readable_register(struct device *dev, unsigned int reg)
        }
 }
 
+static int rt5651_asrc_get(struct snd_kcontrol *kcontrol,
+                          struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+       struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec);
+
+       ucontrol->value.integer.value[0] = rt5651->asrc_en;
+
+       return 0;
+}
+
+static int rt5651_asrc_put(struct snd_kcontrol *kcontrol,
+                          struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+       struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec);
+
+       rt5651->asrc_en = ucontrol->value.integer.value[0];
+       if (rt5651->asrc_en) {
+               snd_soc_write(codec, 0x80, 0x4000);
+               snd_soc_write(codec, 0x81, 0x0302);
+               snd_soc_write(codec, 0x82, 0x0800);
+               snd_soc_write(codec, 0x73, 0x1004);
+               snd_soc_write(codec, 0x83, 0x1000);
+               snd_soc_write(codec, 0x84, 0x7000);
+               snd_soc_update_bits(codec, 0x64, 0x0200, 0x0200);
+       } else {
+               snd_soc_write(codec, 0x83, 0x0);
+               snd_soc_write(codec, 0x84, 0x0);
+       }
+       return 0;
+}
+
 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
@@ -313,6 +346,11 @@ static SOC_ENUM_SINGLE_DECL(rt5651_if2_dac_enum, RT5651_DIG_INF_DATA,
 static SOC_ENUM_SINGLE_DECL(rt5651_if2_adc_enum, RT5651_DIG_INF_DATA,
                                RT5651_IF2_ADC_SEL_SFT, rt5651_data_select);
 
+static const char * const rt5651_asrc_mode[] = {"Disable", "Enable"};
+
+static const SOC_ENUM_SINGLE_DECL(rt5651_asrc_enum, 0, 0,
+               rt5651_asrc_mode);
+
 static const struct snd_kcontrol_new rt5651_snd_controls[] = {
        /* Headphone Output Volume */
        SOC_DOUBLE_TLV("HP Playback Volume", RT5651_HP_VOL,
@@ -353,6 +391,9 @@ static const struct snd_kcontrol_new rt5651_snd_controls[] = {
                        RT5651_ADC_L_BST_SFT, RT5651_ADC_R_BST_SFT,
                        3, 0, adc_bst_tlv),
 
+       /* RT5651 ASRC Switch */
+       SOC_ENUM_EXT("RT5651 ASRC Switch", rt5651_asrc_enum,
+                    rt5651_asrc_get, rt5651_asrc_put),
        /* ASRC */
        SOC_SINGLE("IF1 ASRC Switch", RT5651_PLL_MODE_1,
                RT5651_STO1_T_SFT, 1, 0),
index 422b382..abf4297 100644 (file)
@@ -2074,6 +2074,7 @@ struct rt5651_priv {
        int pll_out;
 
        int dmic_en;
+       int asrc_en;
        bool hp_mute;
        struct clk *mclk;
 };