Skip to contentSkip to conversation

ASoC: rt1011: add i2s reference control for rt1011

PATCH In review Jack Yu 3 participants 8 messages Sep 6, 2021 – Sep 13, 2021

Subsystems (3)
lore
Share & tools
lore

Jack Yu

author
#0 lore raw

PATCH 1/1 ASoC: rt1011: add i2s reference control for rt1011

Add i2s reference control for rt1011 amp.

---
 sound/soc/codecs/rt1011.c | 54 +++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt1011.h |  7 +++++
 2 files changed, 61 insertions(+)
sound/soc/codecs/rt1011.c +54 -0
index faff2b558687..508597866dff 100644
@@ -1311,6 +1311,57 @@ static int rt1011_r0_load_info(struct snd_kcontrol *kcontrol,
 	.put = rt1011_r0_load_mode_put \
 }
 
+static const char * const rt1011_i2s_ref[] = {
+	"None", "Left Channel", "Right Channel"
+};
+
+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);
+	int i2s_ref_ch = ucontrol->value.integer.value[0];
+
+	switch (i2s_ref_ch) {
+	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");
+	}
+
+	rt1011->i2s_ref = ucontrol->value.integer.value[0];
+
+	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.integer.value[0] = rt1011->i2s_ref;
+
+	return 0;
+}
+
 static const struct snd_kcontrol_new rt1011_snd_controls[] = {
 	/* I2S Data In Selection */
 	SOC_ENUM("DIN Source", rt1011_din_source_enum),
@@ -1349,6 +1400,9 @@ static const struct snd_kcontrol_new rt1011_snd_controls[] = {
 	/* R0 temperature */
 	SOC_SINGLE("R0 Temperature", RT1011_STP_INITIAL_RESISTANCE_TEMP,
 		2, 255, 0),
+	/* I2S Reference */
+	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,
sound/soc/codecs/rt1011.h +7 -0
index 68fadc15fa8c..afb2fad94216 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;
+	unsigned int i2s_ref;
 };
 
 #endif		/* end of _RT1011_H_ */
Signature · 1 line
2.31.1
#1 lore raw

sound/soc/codecs/rt1011.h enum { · line 661

Quoted 13 lines · Jack Yu

Add i2s reference control for rt1011 amp.

sound/soc/codecs/rt1011.h +8 -0
+static const char * const rt1011_i2s_ref[] = {
+	"None", "Left Channel", "Right Channel"
+};
 
+enum {
+	RT1011_I2S_REF_NONE,
+	RT1011_I2S_REF_LEFT_CH,
+	RT1011_I2S_REF_RIGHT_CH,
+};

is it possible to get Left-Right-mix (mixed on rt1011) and Left-Right (two channels, with the application selecting what they want)?

author
#2 lore raw
Quoted 22 lines

-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: Tuesday, September 7, 2021 10:54 PM
To: Jack Yu <[email protected]>; [email protected]; [email protected]
Cc: Oder Chiou <[email protected]>; [email protected]; [email protected]; [email protected] [陳建宏] <[email protected]>; Derek [方德義] <[email protected]>; Shuming [范書銘] <[email protected]>; Flove(HsinFu) <[email protected]>
Subject: Re: [PATCH] ASoC: rt1011: add i2s reference control for rt1011

Quoted 7 lines · Jack Yu

Add i2s reference control for rt1011 amp.

sound/soc/codecs/rt1011.c +3 -0
+static const char * const rt1011_i2s_ref[] = {
+	"None", "Left Channel", "Right Channel"
+};
Quoted 8 lines

sound/soc/codecs/rt1011.h enum { · line 661

Quoted 5 lines
sound/soc/codecs/rt1011.h +5 -0
+enum {
+	RT1011_I2S_REF_NONE,
+	RT1011_I2S_REF_LEFT_CH,
+	RT1011_I2S_REF_RIGHT_CH,
+};

is it possible to get Left-Right-mix (mixed on rt1011) and Left-Right (two channels, with the application selecting what they want)?

It's a mono amp, so there's no Left-Right-mix setting.
And for the choice of Left-Right channel, it's already available with this patch.

Quoted 2 lines

------Please consider the environment before printing this e-mail.

#3 lore raw
Quoted 31 lines · Jack Yu
Quoted 22 lines

-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: Tuesday, September 7, 2021 10:54 PM
To: Jack Yu <[email protected]>; [email protected]; [email protected]
Cc: Oder Chiou <[email protected]>; [email protected]; [email protected]; [email protected] [陳建宏] <[email protected]>; Derek [方德義] <[email protected]>; Shuming [范書銘] <[email protected]>; Flove(HsinFu) <[email protected]>
Subject: Re: [PATCH] ASoC: rt1011: add i2s reference control for rt1011

Quoted 7 lines · Jack Yu

Add i2s reference control for rt1011 amp.

sound/soc/codecs/rt1011.c +3 -0
+static const char * const rt1011_i2s_ref[] = {
+	"None", "Left Channel", "Right Channel"
+};
Quoted 8 lines

sound/soc/codecs/rt1011.h enum { · line 661

Quoted 5 lines
sound/soc/codecs/rt1011.h +5 -0
+enum {
+	RT1011_I2S_REF_NONE,
+	RT1011_I2S_REF_LEFT_CH,
+	RT1011_I2S_REF_RIGHT_CH,
+};

is it possible to get Left-Right-mix (mixed on rt1011) and Left-Right (two channels, with the application selecting what they want)?

Quoted 2 lines

It's a mono amp, so there's no Left-Right-mix setting.
And for the choice of Left-Right channel, it's already available with this patch.

So it's just to place a mono reference in either left or right channel of the I2S link? Why not dual-mono as well then?

author
#4 lore raw
Quoted 46 lines

-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: Wednesday, September 8, 2021 11:23 PM
To: Jack Yu <[email protected]>; [email protected]; [email protected]
Cc: Oder Chiou <[email protected]>; [email protected]; [email protected]; [email protected] [陳建宏] <[email protected]>; Derek [方德義] <[email protected]>; Shuming [范書銘] <[email protected]>; Flove(HsinFu) <[email protected]>
Subject: Re: [PATCH] ASoC: rt1011: add i2s reference control for rt1011

Quoted 32 lines · Jack Yu
Quoted 31 lines

-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: Tuesday, September 7, 2021 10:54 PM
To: Jack Yu <[email protected]>; [email protected]; [email protected]
Cc: Oder Chiou <[email protected]>; [email protected]; [email protected]; [email protected] [陳建宏] <[email protected]>; Derek [方德義] <[email protected]>; Shuming [范書銘] <[email protected]>; Flove(HsinFu) <[email protected]>
Subject: Re: [PATCH] ASoC: rt1011: add i2s reference control for rt1011

sound/soc/codecs/rt1011.h enum { · line 661

Quoted 13 lines · Jack Yu

Add i2s reference control for rt1011 amp.

sound/soc/codecs/rt1011.h +8 -0
+static const char * const rt1011_i2s_ref[] = {
+	"None", "Left Channel", "Right Channel"
+};
 
+enum {
+	RT1011_I2S_REF_NONE,
+	RT1011_I2S_REF_LEFT_CH,
+	RT1011_I2S_REF_RIGHT_CH,
+};

is it possible to get Left-Right-mix (mixed on rt1011) and Left-Right (two channels, with the application selecting what they want)?

Quoted 6 lines
Quoted 2 lines

It's a mono amp, so there's no Left-Right-mix setting.
And for the choice of Left-Right channel, it's already available with this

patch.

So it's just to place a mono reference in either left or right channel of the I2S link? Why not dual-mono as well then?

The patch is a specific control for two amps to send AEC data on single I2S data input pin by standard I2S protocol. If there are two I2S input from SoC, we can add dual-mono mode for it, but so far there is no requirement regarding to this mode.

Quoted 1 line

------Please consider the environment before printing this e-mail.

#5 lore raw
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines

sound/soc/codecs/rt1011.h enum { · line 661

Quoted 12 lines
sound/soc/codecs/rt1011.h +8 -0
+static const char * const rt1011_i2s_ref[] = {
+	"None", "Left Channel", "Right Channel"
+};
 
+enum {
+	RT1011_I2S_REF_NONE,
+	RT1011_I2S_REF_LEFT_CH,
+	RT1011_I2S_REF_RIGHT_CH,
+};

is it possible to get Left-Right-mix (mixed on rt1011) and Left-Right (two channels, with the application selecting what they want)?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

It's a mono amp, so there's no Left-Right-mix setting.
And for the choice of Left-Right channel, it's already available with this

patch.

So it's just to place a mono reference in either left or right channel of the I2S link? Why not dual-mono as well then?

The patch is a specific control for two amps to send AEC data on single I2S data input pin by standard I2S protocol.

That's really useful information and worthy of a comment.

What you are doing here is similar to selecting the slot for each amp with set_tdm_slot(), but leaving the choice to userspace, isn't it?

Quoted 1 line

If there are two I2S input from SoC, we can add dual-mono mode for it, but so far there is no requirement regarding to this mode.

ok.

author
#6 lore raw
Quoted 34 lines

-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: Thursday, September 9, 2021 11:26 AM
To: Jack Yu <[email protected]>; [email protected]; [email protected]
Cc: Oder Chiou <[email protected]>; [email protected]; [email protected]; [email protected] [陳建宏] <[email protected]>; Derek [方德義] <[email protected]>; Shuming [范書銘] <[email protected]>; Flove(HsinFu) <[email protected]>
Subject: Re: [PATCH] ASoC: rt1011: add i2s reference control for rt1011

Quoted 21 lines
Quoted 20 lines
Quoted 13 lines
Quoted 4 lines
Quoted 3 lines
sound/soc/codecs/rt1011.c +3 -0
+static const char * const rt1011_i2s_ref[] = {
+	"None", "Left Channel", "Right Channel"
+};
Quoted 8 lines

sound/soc/codecs/rt1011.h enum { · line 661

Quoted 5 lines
sound/soc/codecs/rt1011.h +5 -0
+enum {
+	RT1011_I2S_REF_NONE,
+	RT1011_I2S_REF_LEFT_CH,
+	RT1011_I2S_REF_RIGHT_CH,
+};

is it possible to get Left-Right-mix (mixed on rt1011) and Left-Right (two channels, with the application selecting what they want)?

Quoted 3 lines

It's a mono amp, so there's no Left-Right-mix setting. And for the choice of Left-Right channel, it's already available with this

patch.

So it's just to place a mono reference in either left or right channel of the I2S link? Why not dual-mono as well then?

Quoted 8 lines
Quoted 1 line

The patch is a specific control for two amps to send AEC data on single I2S

data input pin by standard I2S protocol.

That's really useful information and worthy of a comment.

What you are doing here is similar to selecting the slot for each amp with set_tdm_slot(), but leaving the choice to userspace, isn't it?

Yes.

Quoted 6 lines
Quoted 1 line

If there are two I2S input from SoC, we can add dual-mono mode for it, but

so far there is no requirement regarding to this mode.

ok.

------Please consider the environment before printing this e-mail.

maintainer
#7 lore raw
In reply to Jack Yu
Quoted 3 lines · Jack Yu

Add i2s reference control for rt1011 amp.

Applied to

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

Thanks!

[1/1] ASoC: rt1011: add i2s reference control for rt1011

      commit: 87f40af26c26233b060767f3e7cff5e54647cf2b

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