From 6621b0f118d500092f5f3d72ddddb22aeeb3c3a0 Mon Sep 17 00:00:00 2001 From: Alex Tran Date: Sun, 28 Sep 2025 17:46:25 -0700 Subject: [PATCH] ASoC: codecs: rt5670: use SOC_VALUE_ENUM_SINGLE_DECL for DAC2 L/R MX-1B DAC2 L/R source selection fields (MX-1B [6:4] and [2:0]) contain non contiguous values due to reserved bits documented in datasheet (page 66): Switch from SOC_ENUM_SINGLE_DECL to SOC_VALUE_ENUM_SINGLE_DECL to handle discrete values. Signed-off-by: Alex Tran Link: https://patch.msgid.link/20250929004625.1310721-1-alex.t.tran@gmail.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt5670.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index efd26082f19ab..4c75a3e71859b 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -1153,25 +1153,29 @@ static SOC_ENUM_SINGLE_DECL(rt5670_dac1r_enum, RT5670_AD_DA_MIXER, static const struct snd_kcontrol_new rt5670_dac1r_mux = SOC_DAPM_ENUM("DAC1 R source", rt5670_dac1r_enum); -/*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */ -/* TODO Use SOC_VALUE_ENUM_SINGLE_DECL */ -static const char * const rt5670_dac12_src[] = { - "IF1 DAC", "IF2 DAC", "IF3 DAC", "TxDC DAC", - "Bass", "VAD_ADC", "IF4 DAC" -}; +/* DAC2 L source*/ /* MX-1B [6:4] */ +static const char *const rt5670_dac12_src[] = { + "IF1 DAC", "IF2 DAC", "TxDC DAC", "VAD_ADC" +}; /* VAD_ADC or TxDP_ADC_R */ + +static const unsigned int rt5670_dac12_values[] = { 0, 1, 3, 5 }; -static SOC_ENUM_SINGLE_DECL(rt5670_dac2l_enum, RT5670_DAC_CTRL, - RT5670_DAC2_L_SEL_SFT, rt5670_dac12_src); +static SOC_VALUE_ENUM_SINGLE_DECL(rt5670_dac2l_enum, RT5670_DAC_CTRL, + RT5670_DAC2_L_SEL_SFT, RT5670_DAC2_L_SEL_MASK, + rt5670_dac12_src, rt5670_dac12_values); static const struct snd_kcontrol_new rt5670_dac_l2_mux = SOC_DAPM_ENUM("DAC2 L source", rt5670_dac2l_enum); -static const char * const rt5670_dacr2_src[] = { - "IF1 DAC", "IF2 DAC", "IF3 DAC", "TxDC DAC", "TxDP ADC", "IF4 DAC" -}; +/*DAC2 R source*/ /* MX-1B [2:0] */ +static const char *const rt5670_dacr2_src[] = { "IF1 DAC", "IF2 DAC", + "TxDC DAC", "TxDP ADC" }; + +static const unsigned int rt5670_dacr2_values[] = { 0, 1, 3, 4 }; -static SOC_ENUM_SINGLE_DECL(rt5670_dac2r_enum, RT5670_DAC_CTRL, - RT5670_DAC2_R_SEL_SFT, rt5670_dacr2_src); +static SOC_VALUE_ENUM_SINGLE_DECL(rt5670_dac2r_enum, RT5670_DAC_CTRL, + RT5670_DAC2_R_SEL_SFT, RT5670_DAC2_R_SEL_MASK, + rt5670_dacr2_src, rt5670_dacr2_values); static const struct snd_kcontrol_new rt5670_dac_r2_mux = SOC_DAPM_ENUM("DAC2 R source", rt5670_dac2r_enum); -- 2.47.3