Skip to contentSkip to conversation

ASoC: rt1320: Add RT1320 SDCA vendor-specific driver

PATCH Superseded [email protected] 2 participants 5 messages May 15, 2024 – May 20, 2024

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: rt1320: Add RT1320 SDCA vendor-specific driver

From: Shuming Fan <[email protected]>

This is the initial amplifier driver for rt1320.

---
 sound/soc/codecs/Kconfig      |    7 +
 sound/soc/codecs/Makefile     |    2 +
 sound/soc/codecs/rt1320-sdw.c | 2213 +++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt1320-sdw.h |   92 ++
 4 files changed, 2314 insertions(+)
 create mode 100644 sound/soc/codecs/rt1320-sdw.c
 create mode 100644 sound/soc/codecs/rt1320-sdw.h
sound/soc/codecs/Kconfig +7 -0
index 4afc43d3f71f..7502581d1631 100644
@@ -222,6 +222,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_RT1308_SDW
 	imply SND_SOC_RT1316_SDW
 	imply SND_SOC_RT1318_SDW
+	imply SND_SOC_RT1320_SDW
 	imply SND_SOC_RT9120
 	imply SND_SOC_RTQ9128
 	imply SND_SOC_SDW_MOCKUP
@@ -1575,6 +1576,12 @@ config SND_SOC_RT1318_SDW
 	depends on SOUNDWIRE
 	select REGMAP_SOUNDWIRE
 
+config SND_SOC_RT1320_SDW
+	tristate "Realtek RT1320 Codec - SDW"
+	depends on SOUNDWIRE
+	select REGMAP_SOUNDWIRE
+	select REGMAP_SOUNDWIRE_MBQ
+
 config SND_SOC_RT5514
 	tristate
 	depends on I2C
sound/soc/codecs/Makefile +2 -0
index b4df22186e25..f9eb7c073a00 100644
@@ -222,6 +222,7 @@ snd-soc-rt1308-y := rt1308.o
 snd-soc-rt1308-sdw-y := rt1308-sdw.o
 snd-soc-rt1316-sdw-y := rt1316-sdw.o
 snd-soc-rt1318-sdw-y := rt1318-sdw.o
+snd-soc-rt1320-sdw-y := rt1320-sdw.o
 snd-soc-rt274-y := rt274.o
 snd-soc-rt286-y := rt286.o
 snd-soc-rt298-y := rt298.o
@@ -614,6 +615,7 @@ obj-$(CONFIG_SND_SOC_RT1308)	+= snd-soc-rt1308.o
 obj-$(CONFIG_SND_SOC_RT1308_SDW)	+= snd-soc-rt1308-sdw.o
 obj-$(CONFIG_SND_SOC_RT1316_SDW)	+= snd-soc-rt1316-sdw.o
 obj-$(CONFIG_SND_SOC_RT1318_SDW)	+= snd-soc-rt1318-sdw.o
+obj-$(CONFIG_SND_SOC_RT1320_SDW)	+= snd-soc-rt1320-sdw.o
 obj-$(CONFIG_SND_SOC_RT274)	+= snd-soc-rt274.o
 obj-$(CONFIG_SND_SOC_RT286)	+= snd-soc-rt286.o
 obj-$(CONFIG_SND_SOC_RT298)	+= snd-soc-rt298.o
sound/soc/codecs/rt1320-sdw.c new file +2213 -0

2,213 lines not on this page · raw message

sound/soc/codecs/rt1320-sdw.h new file +92 -0

92 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines

+static const struct reg_sequence rt1320_blind_write[] = {

...

Quoted 3 lines
sound/soc/codecs/rt1320-sdw.c new file +3 -0
+};
+
+static const struct reg_sequence rt1320_patch_code_write[] = {

...

Quoted 1 line

+};

On GitHub we talked about using the SDCA Initialization table coming from ACPI, is this still something you're interested in?

Quoted 4 lines
sound/soc/codecs/rt1320-sdw.c new file +3 -0
+	if (rt1320->version_id < 0) {
+		regmap_read(rt1320->regmap, RT1320_DEV_VERSION_ID_1, &val);
+		rt1320->version_id = val;
 

sound/soc/codecs/rt1320-sdw.c line 1704

Quoted 10 lines
sound/soc/codecs/rt1320-sdw.c new file +10 -0
+		/*
+		 * We call the version b which has the new DSP ROM code against version a.
+		 * Therefore, we read the DSP address to check the ID.
+		 */
+		if (val == RT1320_VER_B_ID)
+			rt1320->version_id = RT1320_VB;
+		regmap_write(rt1320->regmap, SDW_SDCA_CTL(FUNC_NUM_AMP, RT1320_SDCA_ENT_PDE23,
+			RT1320_SDCA_CTL_REQ_POWER_STATE, 0), 3);
+	}
+	dev_dbg(dev, "%s version_id=%d\n", __func__, rt1320->version_id);

Maybe I missed it but I didn't see anything that tests the version_id and does something different between VER_A and VER_B. Can you add a comment on why it's important to track the version?

Also if there's a DSP, is there a need for the FDL capability to download firmware, or is the speaker protection configured only via tables?

#2 lore raw
Quoted 10 lines
Quoted 1 line

+static const struct reg_sequence rt1320_blind_write[] = {

...

Quoted 3 lines
sound/soc/codecs/rt1320-sdw.c new file +3 -0
+};
+
+static const struct reg_sequence rt1320_patch_code_write[] = {

...

Quoted 1 line

+};

On GitHub we talked about using the SDCA Initialization table coming from ACPI, is this still something you're interested in?

If the SDCA function is ready, the codec driver could call the API to do the blind writes.

Quoted 7 lines

Maybe I missed it but I didn't see anything that tests the version_id and does something different between VER_A and VER_B. Can you add a comment on why it's important to track the version?

Also if there's a DSP, is there a need for the FDL capability to download firmware, or is the speaker protection configured only via tables?

OK, will add a comment for the version_id.
Currently, the blind writes enables the basic function, not the advanced mode (speaker protection). However, VER_B has the capability to enable the speaker protection.
The codec driver could use the version_id if the customer wants to enable the speaker protection. Regarding DSP firmware, the ROM code stores the DSP FW inside the chip.
The speaker protection needs other parameters to set.

#3 lore raw
Quoted 6 lines · Shuming [范書銘]
Quoted 6 lines
Quoted 1 line

+static const struct reg_sequence rt1320_blind_write[] = {

...

Quoted 3 lines
sound/soc/codecs/rt1320-sdw.c new file +3 -0
+};
+
+static const struct reg_sequence rt1320_patch_code_write[] = {

...

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

+};

On GitHub we talked about using the SDCA Initialization table coming from ACPI, is this still something you're interested in?

If the SDCA function is ready, the codec driver could call the API to do the blind writes.

The code I have is about ready, it just needs to be cleaned-up and submitted.

But just to be clear, the codec driver would use the API to retrieve an array of (address, value) pair. It would be up to the codec driver to do the writes and/or patch their regmap.

Quoted 7 lines
Quoted 6 lines

Maybe I missed it but I didn't see anything that tests the version_id and does something different between VER_A and VER_B. Can you add a comment on why it's important to track the version?

Also if there's a DSP, is there a need for the FDL capability to download firmware, or is the speaker protection configured only via tables?

Quoted 6 lines

OK, will add a comment for the version_id.
Currently, the blind writes enables the basic function, not the advanced mode (speaker protection). However, VER_B has the capability to enable the speaker protection.
The codec driver could use the version_id if the customer wants to enable the speaker protection. Regarding DSP firmware, the ROM code stores the DSP FW inside the chip.
The speaker protection needs other parameters to set.

If there is a speaker protection running on the codec DSP, shouldn't there be a source port to pass an echo reference back to the host?

#4 lore raw
Quoted 11 lines
Quoted 4 lines
Quoted 2 lines

On GitHub we talked about using the SDCA Initialization table coming from ACPI, is this still something you're interested in?

If the SDCA function is ready, the codec driver could call the API to do the

blind writes.

The code I have is about ready, it just needs to be cleaned-up and submitted.

But just to be clear, the codec driver would use the API to retrieve an array of (address, value) pair. It would be up to the codec driver to do the writes and/or patch their regmap.

Understood.
However, the customer requested Realtek to send the primary version to upstream first. We could modify the codec driver after the patches of the SDCA function are submitted.

Quoted 11 lines
Quoted 2 lines

OK, will add a comment for the version_id.
Currently, the blind writes enables the basic function, not the advanced

mode (speaker protection).

Quoted 2 lines

However, VER_B has the capability to enable the speaker protection. The codec driver could use the version_id if the customer wants to enable

the speaker protection.

Quoted 2 lines

Regarding DSP firmware, the ROM code stores the DSP FW inside the chip. The speaker protection needs other parameters to set.

If there is a speaker protection running on the codec DSP, shouldn't there be a source port to pass an echo reference back to the host?

I could create the capture DAI for AEC feedback.