Skip to content

Commit 802ee8a

Browse files
LuoXiaoTanrkhuangtao
authored andcommitted
ASoC: rt5651: add alc5651 ASRC switch for HDMIIn
Change-Id: I447228656d5ee56b2c4b04c515ad71f34e107ba0 Signed-off-by: LuoXiaoTan <lxt@rock-chips.com>
1 parent 0d8e573 commit 802ee8a

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

sound/soc/codecs/rt5651.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,39 @@ static bool rt5651_readable_register(struct device *dev, unsigned int reg)
286286
}
287287
}
288288

289+
static int rt5651_asrc_get(struct snd_kcontrol *kcontrol,
290+
struct snd_ctl_elem_value *ucontrol)
291+
{
292+
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
293+
struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec);
294+
295+
ucontrol->value.integer.value[0] = rt5651->asrc_en;
296+
297+
return 0;
298+
}
299+
300+
static int rt5651_asrc_put(struct snd_kcontrol *kcontrol,
301+
struct snd_ctl_elem_value *ucontrol)
302+
{
303+
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
304+
struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec);
305+
306+
rt5651->asrc_en = ucontrol->value.integer.value[0];
307+
if (rt5651->asrc_en) {
308+
snd_soc_write(codec, 0x80, 0x4000);
309+
snd_soc_write(codec, 0x81, 0x0302);
310+
snd_soc_write(codec, 0x82, 0x0800);
311+
snd_soc_write(codec, 0x73, 0x1004);
312+
snd_soc_write(codec, 0x83, 0x1000);
313+
snd_soc_write(codec, 0x84, 0x7000);
314+
snd_soc_update_bits(codec, 0x64, 0x0200, 0x0200);
315+
} else {
316+
snd_soc_write(codec, 0x83, 0x0);
317+
snd_soc_write(codec, 0x84, 0x0);
318+
}
319+
return 0;
320+
}
321+
289322
static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
290323
static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
291324
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,
313346
static SOC_ENUM_SINGLE_DECL(rt5651_if2_adc_enum, RT5651_DIG_INF_DATA,
314347
RT5651_IF2_ADC_SEL_SFT, rt5651_data_select);
315348

349+
static const char * const rt5651_asrc_mode[] = {"Disable", "Enable"};
350+
351+
static const SOC_ENUM_SINGLE_DECL(rt5651_asrc_enum, 0, 0,
352+
rt5651_asrc_mode);
353+
316354
static const struct snd_kcontrol_new rt5651_snd_controls[] = {
317355
/* Headphone Output Volume */
318356
SOC_DOUBLE_TLV("HP Playback Volume", RT5651_HP_VOL,
@@ -353,6 +391,9 @@ static const struct snd_kcontrol_new rt5651_snd_controls[] = {
353391
RT5651_ADC_L_BST_SFT, RT5651_ADC_R_BST_SFT,
354392
3, 0, adc_bst_tlv),
355393

394+
/* RT5651 ASRC Switch */
395+
SOC_ENUM_EXT("RT5651 ASRC Switch", rt5651_asrc_enum,
396+
rt5651_asrc_get, rt5651_asrc_put),
356397
/* ASRC */
357398
SOC_SINGLE("IF1 ASRC Switch", RT5651_PLL_MODE_1,
358399
RT5651_STO1_T_SFT, 1, 0),

sound/soc/codecs/rt5651.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,7 @@ struct rt5651_priv {
20742074
int pll_out;
20752075

20762076
int dmic_en;
2077+
int asrc_en;
20772078
bool hp_mute;
20782079
struct clk *mclk;
20792080
};

0 commit comments

Comments
 (0)