From: LuoXiaoTan Date: Thu, 6 Apr 2017 09:29:32 +0000 (-0700) Subject: ASoC: rt5651: add alc5651 ASRC switch for HDMIIn X-Git-Tag: firefly_0821_release~23 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=firefly-linux-kernel-4.4.55.git;a=commitdiff_plain;h=802ee8a48927eef439af92973a0f17ed3590950d;ds=sidebyside ASoC: rt5651: add alc5651 ASRC switch for HDMIIn Change-Id: I447228656d5ee56b2c4b04c515ad71f34e107ba0 Signed-off-by: LuoXiaoTan --- diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index f092758985bf..7de785087958 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -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), diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 422b382c6d3b..abf4297e49f3 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2074,6 +2074,7 @@ struct rt5651_priv { int pll_out; int dmic_en; + int asrc_en; bool hp_mute; struct clk *mclk; };