Skip to contentSkip to conversation

ASoC: rt1011: revert 'I2S Reference' to SOC_ENUM_EXT

PATCH In review Jack Yu 3 participants 6 messages Nov 11, 2021 – Dec 1, 2021

Subsystems (3)
lore
Share & tools
lore

Jack Yu

author
#0 lore raw

PATCH 1/1 ASoC: rt1011: revert 'I2S Reference' to SOC_ENUM_EXT

Revert 'I2S Reference' to SOC_ENUM_EXT because the settings are specific for some platforms, the default setting for 'I2S Reference' does nothing, only some SoC platform need to configure it.
Previous 'I2S Reference' in SOC_ENUM format only toggles one bit of RT1011_TDM1_SET_1 register, which isn't enough for specific platform.

---
 sound/soc/codecs/rt1011.c | 55 ++++++++++++++++++++++++++++++++++-----
 sound/soc/codecs/rt1011.h |  7 +++++
 2 files changed, 56 insertions(+), 6 deletions(-)
sound/soc/codecs/rt1011.c +49 -6
index 297af7ff824c..b62301a6281f 100644
@@ -1311,13 +1311,54 @@ static int rt1011_r0_load_info(struct snd_kcontrol *kcontrol,
 	.put = rt1011_r0_load_mode_put \
 }
 
-static const char * const rt1011_i2s_ref_texts[] = {
-	"Left Channel", "Right Channel"
+static const char * const rt1011_i2s_ref[] = {
+	"None", "Left Channel", "Right Channel"
 };
 
-static SOC_ENUM_SINGLE_DECL(rt1011_i2s_ref_enum,
-			    RT1011_TDM1_SET_1, 7,
-			    rt1011_i2s_ref_texts);
+static SOC_ENUM_SINGLE_DECL(rt1011_i2s_ref_enum, 0, 0,
+	rt1011_i2s_ref);
+
+static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct rt1011_priv *rt1011 =
+		snd_soc_component_get_drvdata(component);
+
+	rt1011->i2s_ref = ucontrol->value.enumerated.item[0];
+	switch (rt1011->i2s_ref) {
+	case RT1011_I2S_REF_LEFT_CH:
+		regmap_write(rt1011->regmap, RT1011_TDM_TOTAL_SET, 0x0240);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_2, 0x8);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_1, 0x1022);
+		regmap_write(rt1011->regmap, RT1011_ADCDAT_OUT_SOURCE, 0x4);
+		break;
+	case RT1011_I2S_REF_RIGHT_CH:
+		regmap_write(rt1011->regmap, RT1011_TDM_TOTAL_SET, 0x0240);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_2, 0x8);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_1, 0x10a2);
+		regmap_write(rt1011->regmap, RT1011_ADCDAT_OUT_SOURCE, 0x4);
+		break;
+	default:
+		dev_info(component->dev, "I2S Reference: Do nothing\n");
+	}
+
+	return 0;
+}
+
+static int rt1011_i2s_ref_get(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct rt1011_priv *rt1011 =
+		snd_soc_component_get_drvdata(component);
+
+	ucontrol->value.enumerated.item[0] = rt1011->i2s_ref;
+
+	return 0;
+}
 
 static const struct snd_kcontrol_new rt1011_snd_controls[] = {
 	/* I2S Data In Selection */
@@ -1358,7 +1399,8 @@ static const struct snd_kcontrol_new rt1011_snd_controls[] = {
 	SOC_SINGLE("R0 Temperature", RT1011_STP_INITIAL_RESISTANCE_TEMP,
 		2, 255, 0),
 	/* I2S Reference */
-	SOC_ENUM("I2S Reference", rt1011_i2s_ref_enum),
+	SOC_ENUM_EXT("I2S Reference", rt1011_i2s_ref_enum,
+		rt1011_i2s_ref_get, rt1011_i2s_ref_put),
 };
 
 static int rt1011_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
@@ -2017,6 +2059,7 @@ static int rt1011_probe(struct snd_soc_component *component)
 
 	schedule_work(&rt1011->cali_work);
 
+	rt1011->i2s_ref = 0;
 	rt1011->bq_drc_params = devm_kcalloc(component->dev,
 		RT1011_ADVMODE_NUM, sizeof(struct rt1011_bq_drc_params *),
 		GFP_KERNEL);
sound/soc/codecs/rt1011.h +7 -0
index 68fadc15fa8c..4d6e7492d99c 100644
@@ -654,6 +654,12 @@ enum {
 	RT1011_AIFS
 };
 
+enum {
+	RT1011_I2S_REF_NONE,
+	RT1011_I2S_REF_LEFT_CH,
+	RT1011_I2S_REF_RIGHT_CH,
+};
+
 /* BiQual & DRC related settings */
 #define RT1011_BQ_DRC_NUM 128
 struct rt1011_bq_drc_params {
@@ -692,6 +698,7 @@ struct rt1011_priv {
 	unsigned int r0_reg, cali_done;
 	unsigned int r0_calib, temperature_calib;
 	int recv_spk_mode;
+	int i2s_ref;
 };
 
 #endif		/* end of _RT1011_H_ */
Signature · 1 line
2.33.0
maintainer
#1 lore raw
Quoted 8 lines · Jack Yu

Revert 'I2S Reference' to SOC_ENUM_EXT because the settings are specific for some platforms, the default setting for 'I2S Reference' does nothing, only some SoC platform need to configure it.
Previous 'I2S Reference' in SOC_ENUM format only toggles one bit of RT1011_TDM1_SET_1 register, which isn't enough for specific platform.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-linus

Thanks!

[1/1] ASoC: rt1011: revert 'I2S Reference' to SOC_ENUM_EXT

      commit: a382285b6feda8db56955e5897453405c198048d

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

#2 lore raw
In reply to Jack Yu

Hi Jack,

Quoted 5 lines · Jack Yu

Revert 'I2S Reference' to SOC_ENUM_EXT because the settings are specific for some platforms, the default setting for 'I2S Reference' does nothing, only some SoC platform need to configure it.
Previous 'I2S Reference' in SOC_ENUM format only toggles one bit of RT1011_TDM1_SET_1 register, which isn't enough for specific platform.

This patch again breaks audio but in a less obvious way.
If a user _ever_ touches the "I2S Reference" then audio playback will never going to work again as instead of changing the i2s reference the code clears all settings done by set_tdm_slot, dai_fmt to something which is some product specific setting.
One would think that a reboot helps, but on boot we tend to restore the saved amixer settings -> audio playback is broken.
So, before reboot one has to set the reference to None and reboot and hope that on boot the NOP (None) is going to be set which means that the custom enum code would not overwrite the configuration of the codec.

There is a single bit in RT1011_TDM1_SET_1 (bit 7) which selects the I2S reference and the reset value is Left (0).

With this custom enum put code you effectively reconfigure the code to be unusable on most likely in all systems except the one which needs these settings...

Quoted 115 lines
---
 sound/soc/codecs/rt1011.c | 55 ++++++++++++++++++++++++++++++++++-----
 sound/soc/codecs/rt1011.h |  7 +++++
 2 files changed, 56 insertions(+), 6 deletions(-)
sound/soc/codecs/rt1011.c +49 -6
index 297af7ff824c..b62301a6281f 100644
@@ -1311,13 +1311,54 @@ static int rt1011_r0_load_info(struct snd_kcontrol *kcontrol,
 	.put = rt1011_r0_load_mode_put \
 }
 
-static const char * const rt1011_i2s_ref_texts[] = {
-	"Left Channel", "Right Channel"
+static const char * const rt1011_i2s_ref[] = {
+	"None", "Left Channel", "Right Channel"
 };
 
-static SOC_ENUM_SINGLE_DECL(rt1011_i2s_ref_enum,
-			    RT1011_TDM1_SET_1, 7,
-			    rt1011_i2s_ref_texts);
+static SOC_ENUM_SINGLE_DECL(rt1011_i2s_ref_enum, 0, 0,
+	rt1011_i2s_ref);
+
+static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct rt1011_priv *rt1011 =
+		snd_soc_component_get_drvdata(component);
+
+	rt1011->i2s_ref = ucontrol->value.enumerated.item[0];
+	switch (rt1011->i2s_ref) {
+	case RT1011_I2S_REF_LEFT_CH:
+		regmap_write(rt1011->regmap, RT1011_TDM_TOTAL_SET, 0x0240);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_2, 0x8);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_1, 0x1022);
+		regmap_write(rt1011->regmap, RT1011_ADCDAT_OUT_SOURCE, 0x4);
+		break;
+	case RT1011_I2S_REF_RIGHT_CH:
+		regmap_write(rt1011->regmap, RT1011_TDM_TOTAL_SET, 0x0240);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_2, 0x8);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_1, 0x10a2);
+		regmap_write(rt1011->regmap, RT1011_ADCDAT_OUT_SOURCE, 0x4);
+		break;
+	default:
+		dev_info(component->dev, "I2S Reference: Do nothing\n");
+	}
+
+	return 0;
+}
+
+static int rt1011_i2s_ref_get(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct rt1011_priv *rt1011 =
+		snd_soc_component_get_drvdata(component);
+
+	ucontrol->value.enumerated.item[0] = rt1011->i2s_ref;
+
+	return 0;
+}
 
 static const struct snd_kcontrol_new rt1011_snd_controls[] = {
 	/* I2S Data In Selection */
@@ -1358,7 +1399,8 @@ static const struct snd_kcontrol_new rt1011_snd_controls[] = {
 	SOC_SINGLE("R0 Temperature", RT1011_STP_INITIAL_RESISTANCE_TEMP,
 		2, 255, 0),
 	/* I2S Reference */
-	SOC_ENUM("I2S Reference", rt1011_i2s_ref_enum),
+	SOC_ENUM_EXT("I2S Reference", rt1011_i2s_ref_enum,
+		rt1011_i2s_ref_get, rt1011_i2s_ref_put),
 };
 
 static int rt1011_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
@@ -2017,6 +2059,7 @@ static int rt1011_probe(struct snd_soc_component *component)
 
 	schedule_work(&rt1011->cali_work);
 
+	rt1011->i2s_ref = 0;
 	rt1011->bq_drc_params = devm_kcalloc(component->dev,
 		RT1011_ADVMODE_NUM, sizeof(struct rt1011_bq_drc_params *),
 		GFP_KERNEL);
sound/soc/codecs/rt1011.h +7 -0
index 68fadc15fa8c..4d6e7492d99c 100644
@@ -654,6 +654,12 @@ enum {
 	RT1011_AIFS
 };
 
+enum {
+	RT1011_I2S_REF_NONE,
+	RT1011_I2S_REF_LEFT_CH,
+	RT1011_I2S_REF_RIGHT_CH,
+};
+
 /* BiQual & DRC related settings */
 #define RT1011_BQ_DRC_NUM 128
 struct rt1011_bq_drc_params {
@@ -692,6 +698,7 @@ struct rt1011_priv {
 	unsigned int r0_reg, cali_done;
 	unsigned int r0_calib, temperature_calib;
 	int recv_spk_mode;
+	int i2s_ref;
 };
 
 #endif		/* end of _RT1011_H_ */
Signature · 1 line
Péter
author
#3 lore raw

Hi Peter,

Quoted 18 lines · Jack Yu
Quoted 5 lines

Revert 'I2S Reference' to SOC_ENUM_EXT because the settings are specific for some platforms, the default setting for 'I2S Reference' does nothing, only some SoC platform need to configure it. Previous 'I2S Reference' in SOC_ENUM format only toggles one bit of RT1011_TDM1_SET_1 register, which isn't enough for specific platform.

This patch again breaks audio but in a less obvious way.
If a user _ever_ touches the "I2S Reference" then audio playback will never going to work again as instead of changing the i2s reference the code clears all settings done by set_tdm_slot, dai_fmt to something which is some product specific setting.
One would think that a reboot helps, but on boot we tend to restore the saved amixer settings -> audio playback is broken.
So, before reboot one has to set the reference to None and reboot and hope that on boot the NOP (None) is going to be set which means that the custom enum code would not overwrite the configuration of the codec.

Quoted 7 lines

There is a single bit in RT1011_TDM1_SET_1 (bit 7) which selects the I2S reference and the reset value is Left (0).

With this custom enum put code you effectively reconfigure the code to be unusable on most likely in all systems except the one which needs these settings...

This patch is specific for device which uses I2S format and need the reference data, if the device uses TDM format, it doesn't need to call "I2S Reference ".

If device runs TDM mode, machine driver sets TDM slot and DAI format, but no need to call " I2S reference ".
If device runs I2S mode, machine driver sets I2S DAI format, and ucm sets "I2S reference" (it's optional, only if device needs reference signal )

Quoted 123 lines

sound/soc/codecs/rt1011.c static int rt1011_r0_load_info(struct

Quoted 13 lines
---
 sound/soc/codecs/rt1011.c | 55
++++++++++++++++++++++++++++++++++-----
 sound/soc/codecs/rt1011.h |  7 +++++
 2 files changed, 56 insertions(+), 6 deletions(-)
sound/soc/codecs/rt1011.c +0 -0
index 297af7ff824c..b62301a6281f 100644
@@ -1311,13 +1311,54 @@ static int rt1011_r0_load_info(struct

snd_kcontrol *kcontrol,

Quoted 19 lines
sound/soc/codecs/rt1011.c +9 -5
 	.put = rt1011_r0_load_mode_put \
 }
 
-static const char * const rt1011_i2s_ref_texts[] = {
-	"Left Channel", "Right Channel"
+static const char * const rt1011_i2s_ref[] = {
+	"None", "Left Channel", "Right Channel"
 };
 
-static SOC_ENUM_SINGLE_DECL(rt1011_i2s_ref_enum,
-			    RT1011_TDM1_SET_1, 7,
-			    rt1011_i2s_ref_texts);
+static SOC_ENUM_SINGLE_DECL(rt1011_i2s_ref_enum, 0, 0,
+	rt1011_i2s_ref);
+
+static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol) {
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);

sound/soc/codecs/rt1011.c static int rt1011_r0_load_info(struct snd_kcontrol *kcontrol,

Quoted 10 lines
sound/soc/codecs/rt1011.c +10 -0
+	struct rt1011_priv *rt1011 =
+		snd_soc_component_get_drvdata(component);
+
+	rt1011->i2s_ref = ucontrol->value.enumerated.item[0];
+	switch (rt1011->i2s_ref) {
+	case RT1011_I2S_REF_LEFT_CH:
+		regmap_write(rt1011->regmap, RT1011_TDM_TOTAL_SET, 0x0240);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_2, 0x8);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_1, 0x1022);
+		regmap_write(rt1011->regmap, RT1011_ADCDAT_OUT_SOURCE,

0x4);

sound/soc/codecs/rt1011.c static int rt1011_r0_load_info(struct snd_kcontrol *kcontrol,

Quoted 6 lines
sound/soc/codecs/rt1011.c +6 -0
+		break;
+	case RT1011_I2S_REF_RIGHT_CH:
+		regmap_write(rt1011->regmap, RT1011_TDM_TOTAL_SET, 0x0240);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_2, 0x8);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_1, 0x10a2);
+		regmap_write(rt1011->regmap, RT1011_ADCDAT_OUT_SOURCE,

0x4);

sound/soc/codecs/rt1011.c static const struct snd_kcontrol_new

Quoted 23 lines
sound/soc/codecs/rt1011.c +19 -0
+		break;
+	default:
+		dev_info(component->dev, "I2S Reference: Do nothing\n");
+	}
+
+	return 0;
+}
+
+static int rt1011_i2s_ref_get(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol) {
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct rt1011_priv *rt1011 =
+		snd_soc_component_get_drvdata(component);
+
+	ucontrol->value.enumerated.item[0] = rt1011->i2s_ref;
+
+	return 0;
+}
 
 static const struct snd_kcontrol_new rt1011_snd_controls[] = {
 	/* I2S Data In Selection */
@@ -1358,7 +1399,8 @@ static const struct snd_kcontrol_new

rt1011_snd_controls[] = {

Quoted 37 lines
sound/soc/codecs/rt1011.c +2 -1
 	SOC_SINGLE("R0 Temperature", RT1011_STP_INITIAL_RESISTANCE_TEMP,
 		2, 255, 0),
 	/* I2S Reference */
-	SOC_ENUM("I2S Reference", rt1011_i2s_ref_enum),
+	SOC_ENUM_EXT("I2S Reference", rt1011_i2s_ref_enum,
+		rt1011_i2s_ref_get, rt1011_i2s_ref_put),
 };
 
 static int rt1011_is_sys_clk_from_pll(struct snd_soc_dapm_widget

*source, @@ -2017,6 +2059,7 @@ static int rt1011_probe(struct snd_soc_component *component)

sound/soc/codecs/rt1011.c +1 -0
 	schedule_work(&rt1011->cali_work);
 
+	rt1011->i2s_ref = 0;
 	rt1011->bq_drc_params = devm_kcalloc(component->dev,
 		RT1011_ADVMODE_NUM, sizeof(struct rt1011_bq_drc_params *),
 		GFP_KERNEL);
sound/soc/codecs/rt1011.h +6 -0
index 68fadc15fa8c..4d6e7492d99c 100644
@@ -654,6 +654,12 @@ enum {
 	RT1011_AIFS
 };
 
+enum {
+	RT1011_I2S_REF_NONE,
+	RT1011_I2S_REF_LEFT_CH,
+	RT1011_I2S_REF_RIGHT_CH,
+};
+
 /* BiQual & DRC related settings */
 #define RT1011_BQ_DRC_NUM 128
 struct rt1011_bq_drc_params {

sound/soc/codecs/rt1011.h struct rt1011_priv { · line 704

Quoted 7 lines
sound/soc/codecs/rt1011.h +1 -0
@@ -692,6 +698,7 @@ struct rt1011_priv {
 	unsigned int r0_reg, cali_done;
 	unsigned int r0_calib, temperature_calib;
 	int recv_spk_mode;
+	int i2s_ref;
 };
 
 #endif		/* end of _RT1011_H_ */

--
Péter
------Please consider the environment before printing this e-mail.

#4 lore raw

Hi jack,

Quoted 27 lines · Jack Yu

Hi Peter,

Quoted 18 lines · Jack Yu
Quoted 5 lines

Revert 'I2S Reference' to SOC_ENUM_EXT because the settings are specific for some platforms, the default setting for 'I2S Reference' does nothing, only some SoC platform need to configure it. Previous 'I2S Reference' in SOC_ENUM format only toggles one bit of RT1011_TDM1_SET_1 register, which isn't enough for specific platform.

This patch again breaks audio but in a less obvious way.
If a user _ever_ touches the "I2S Reference" then audio playback will never going to work again as instead of changing the i2s reference the code clears all settings done by set_tdm_slot, dai_fmt to something which is some product specific setting.
One would think that a reboot helps, but on boot we tend to restore the saved amixer settings -> audio playback is broken.
So, before reboot one has to set the reference to None and reboot and hope that on boot the NOP (None) is going to be set which means that the custom enum code would not overwrite the configuration of the codec.

Quoted 7 lines

There is a single bit in RT1011_TDM1_SET_1 (bit 7) which selects the I2S reference and the reset value is Left (0).

With this custom enum put code you effectively reconfigure the code to be unusable on most likely in all systems except the one which needs these settings...

Quoted 5 lines

This patch is specific for device which uses I2S format and need the reference data, if the device uses TDM format, it doesn't need to call "I2S Reference ".

If device runs TDM mode, machine driver sets TDM slot and DAI format, but no need to call " I2S reference ".
If device runs I2S mode, machine driver sets I2S DAI format, and ucm sets "I2S reference" (it's optional, only if device needs reference signal )

But then this should not be called as 'I2S Reference' 'I2S Reference' is _one_ bit.
This is something like drop dai_fmt and all configuration and set ADCDAT1/2 pin to output
set I2S, 24 bit for rx/tx
set undocumented BIT12 in RT1011_TDM1_SET_1
set 'TDM1 DOUT Source' to ALC

What happens if one starts 16bit audio playback after triggering this macro? It is going to change some of the settings and things might brake here and there?

What I'm saying is that the implementation is misleading and it is covertly reconfigures the codec to some static config

Quoted 124 lines
Quoted 124 lines

sound/soc/codecs/rt1011.c static int rt1011_r0_load_info(struct

Quoted 14 lines
---
 sound/soc/codecs/rt1011.c | 55
++++++++++++++++++++++++++++++++++-----
 sound/soc/codecs/rt1011.h |  7 +++++
 2 files changed, 56 insertions(+), 6 deletions(-)
sound/soc/codecs/rt1011.c +0 -0
index 297af7ff824c..b62301a6281f 100644
@@ -1311,13 +1311,54 @@ static int rt1011_r0_load_info(struct

snd_kcontrol *kcontrol,

Quoted 19 lines
sound/soc/codecs/rt1011.c +9 -5
 	.put = rt1011_r0_load_mode_put \
 }
 
-static const char * const rt1011_i2s_ref_texts[] = {
-	"Left Channel", "Right Channel"
+static const char * const rt1011_i2s_ref[] = {
+	"None", "Left Channel", "Right Channel"
 };
 
-static SOC_ENUM_SINGLE_DECL(rt1011_i2s_ref_enum,
-			    RT1011_TDM1_SET_1, 7,
-			    rt1011_i2s_ref_texts);
+static SOC_ENUM_SINGLE_DECL(rt1011_i2s_ref_enum, 0, 0,
+	rt1011_i2s_ref);
+
+static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol) {
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);

sound/soc/codecs/rt1011.c static int rt1011_r0_load_info(struct snd_kcontrol *kcontrol,

Quoted 10 lines
sound/soc/codecs/rt1011.c +10 -0
+	struct rt1011_priv *rt1011 =
+		snd_soc_component_get_drvdata(component);
+
+	rt1011->i2s_ref = ucontrol->value.enumerated.item[0];
+	switch (rt1011->i2s_ref) {
+	case RT1011_I2S_REF_LEFT_CH:
+		regmap_write(rt1011->regmap, RT1011_TDM_TOTAL_SET, 0x0240);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_2, 0x8);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_1, 0x1022);
+		regmap_write(rt1011->regmap, RT1011_ADCDAT_OUT_SOURCE,

0x4);

sound/soc/codecs/rt1011.c static int rt1011_r0_load_info(struct snd_kcontrol *kcontrol,

Quoted 6 lines
sound/soc/codecs/rt1011.c +6 -0
+		break;
+	case RT1011_I2S_REF_RIGHT_CH:
+		regmap_write(rt1011->regmap, RT1011_TDM_TOTAL_SET, 0x0240);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_2, 0x8);
+		regmap_write(rt1011->regmap, RT1011_TDM1_SET_1, 0x10a2);
+		regmap_write(rt1011->regmap, RT1011_ADCDAT_OUT_SOURCE,

0x4);

sound/soc/codecs/rt1011.c static const struct snd_kcontrol_new

Quoted 23 lines
sound/soc/codecs/rt1011.c +19 -0
+		break;
+	default:
+		dev_info(component->dev, "I2S Reference: Do nothing\n");
+	}
+
+	return 0;
+}
+
+static int rt1011_i2s_ref_get(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol) {
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct rt1011_priv *rt1011 =
+		snd_soc_component_get_drvdata(component);
+
+	ucontrol->value.enumerated.item[0] = rt1011->i2s_ref;
+
+	return 0;
+}
 
 static const struct snd_kcontrol_new rt1011_snd_controls[] = {
 	/* I2S Data In Selection */
@@ -1358,7 +1399,8 @@ static const struct snd_kcontrol_new

rt1011_snd_controls[] = {

Quoted 37 lines
sound/soc/codecs/rt1011.c +2 -1
 	SOC_SINGLE("R0 Temperature", RT1011_STP_INITIAL_RESISTANCE_TEMP,
 		2, 255, 0),
 	/* I2S Reference */
-	SOC_ENUM("I2S Reference", rt1011_i2s_ref_enum),
+	SOC_ENUM_EXT("I2S Reference", rt1011_i2s_ref_enum,
+		rt1011_i2s_ref_get, rt1011_i2s_ref_put),
 };
 
 static int rt1011_is_sys_clk_from_pll(struct snd_soc_dapm_widget

*source, @@ -2017,6 +2059,7 @@ static int rt1011_probe(struct snd_soc_component *component)

sound/soc/codecs/rt1011.c +1 -0
 	schedule_work(&rt1011->cali_work);
 
+	rt1011->i2s_ref = 0;
 	rt1011->bq_drc_params = devm_kcalloc(component->dev,
 		RT1011_ADVMODE_NUM, sizeof(struct rt1011_bq_drc_params *),
 		GFP_KERNEL);
sound/soc/codecs/rt1011.h +6 -0
index 68fadc15fa8c..4d6e7492d99c 100644
@@ -654,6 +654,12 @@ enum {
 	RT1011_AIFS
 };
 
+enum {
+	RT1011_I2S_REF_NONE,
+	RT1011_I2S_REF_LEFT_CH,
+	RT1011_I2S_REF_RIGHT_CH,
+};
+
 /* BiQual & DRC related settings */
 #define RT1011_BQ_DRC_NUM 128
 struct rt1011_bq_drc_params {

sound/soc/codecs/rt1011.h struct rt1011_priv { · line 704

Quoted 7 lines
sound/soc/codecs/rt1011.h +1 -0
@@ -692,6 +698,7 @@ struct rt1011_priv {
 	unsigned int r0_reg, cali_done;
 	unsigned int r0_calib, temperature_calib;
 	int recv_spk_mode;
+	int i2s_ref;
 };
 
 #endif		/* end of _RT1011_H_ */

--
Péter
------Please consider the environment before printing this e-mail.

Signature · 1 line
Péter
maintainer
#5 lore raw
Quoted 5 lines · Péter Ujfalusi

This is something like drop dai_fmt and all configuration and set ADCDAT1/2 pin to output
set I2S, 24 bit for rx/tx
set undocumented BIT12 in RT1011_TDM1_SET_1
set 'TDM1 DOUT Source' to ALC

I'd expect that last one in particular to be a DAPM route.