Skip to contentSkip to conversation

ASoC: rt1318: Add RT1318 audio amplifier driver

PATCH Superseded Jack Yu 3 participants 5 messages Jun 5, 2024 – Jun 20, 2024

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jack Yu

author
#0 lore raw

PATCH v2 1/1 ASoC: rt1318: Add RT1318 audio amplifier driver

This is the initial i2s-based amplifier driver for rt1318.

---
 include/sound/rt1318.h    |   16 +
 sound/soc/codecs/Kconfig  |    5 +
 sound/soc/codecs/Makefile |    2 +
 sound/soc/codecs/rt1318.c | 1347 +++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt1318.h |  342 ++++++++++
 5 files changed, 1712 insertions(+)
 create mode 100644 include/sound/rt1318.h
 create mode 100644 sound/soc/codecs/rt1318.c
 create mode 100644 sound/soc/codecs/rt1318.h
include/sound/rt1318.h new file +16 -0
new file mode 100644
index 000000000000..fe6bff06036c
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * linux/sound/rt1318.h -- Platform data for RT1318
+ *
+ * Copyright 2024 Realtek Semiconductor Corp.
+ */
+
+#ifndef __LINUX_SND_RT1318_H
+#define __LINUX_SND_RT1318_H
+
+struct rt1318_platform_data {
+	unsigned int init_r0_l;
+	unsigned int init_r0_r;
+};
+
+#endif
sound/soc/codecs/Kconfig +5 -0
index 4afc43d3f71f..d846bfbeeb79 100644
@@ -221,6 +221,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_RT722_SDCA_SDW
 	imply SND_SOC_RT1308_SDW
 	imply SND_SOC_RT1316_SDW
+	imply SND_SOC_RT1318
 	imply SND_SOC_RT1318_SDW
 	imply SND_SOC_RT9120
 	imply SND_SOC_RTQ9128
@@ -1570,6 +1571,10 @@ config SND_SOC_RT1316_SDW
 	depends on SOUNDWIRE
 	select REGMAP_SOUNDWIRE
 
+config SND_SOC_RT1318
+	tristate
+	depends on I2C
+
 config SND_SOC_RT1318_SDW
 	tristate "Realtek RT1318 Codec - SDW"
 	depends on SOUNDWIRE
sound/soc/codecs/Makefile +2 -0
index b4df22186e25..c5efae0aac72 100644
@@ -221,6 +221,7 @@ snd-soc-rt1305-y := rt1305.o
 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-y := rt1318.o
 snd-soc-rt1318-sdw-y := rt1318-sdw.o
 snd-soc-rt274-y := rt274.o
 snd-soc-rt286-y := rt286.o
@@ -613,6 +614,7 @@ obj-$(CONFIG_SND_SOC_RT1305)	+= snd-soc-rt1305.o
 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)	+= snd-soc-rt1318.o
 obj-$(CONFIG_SND_SOC_RT1318_SDW)	+= snd-soc-rt1318-sdw.o
 obj-$(CONFIG_SND_SOC_RT274)	+= snd-soc-rt274.o
 obj-$(CONFIG_SND_SOC_RT286)	+= snd-soc-rt286.o
sound/soc/codecs/rt1318.c new file +1347 -0

1,347 lines not on this page · raw message

sound/soc/codecs/rt1318.h new file +342 -0

342 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw

sound/soc/codecs/rt1318.c line 110

Quoted 5 lines
sound/soc/codecs/rt1318.c new file +3 -0
+static struct reg_sequence init_list[] = {
+	{ 0x41001888, 0x00},
+	{ 0x0000C121, 0x0B},

+ { 0x0000C121, 0x0B, 100},

in the v1, this register needed a 100us delay, is this no longer required?

author
#2 lore raw
Quoted 4 lines

External mail.

Quoted 8 lines

sound/soc/codecs/rt1318.c line 110

Quoted 3 lines
sound/soc/codecs/rt1318.c new file +3 -0
+static struct reg_sequence init_list[] = {
+     { 0x41001888, 0x00},
+     { 0x0000C121, 0x0B},

+ { 0x0000C121, 0x0B, 100},

in the v1, this register needed a 100us delay, is this no longer required?

Yes, I did test yesterday and this delay could be ignored.

maintainer
#3 lore raw
In reply to Jack Yu
Quoted 1 line · Jack Yu

This is the initial i2s-based amplifier driver for rt1318.

This breaks an x86 allmodconfig build:

/build/stage/linux/sound/soc/codecs/rt1318.c:785:5: error: no previous prototype
for ‘rt1318_pll_calc’ [-Werror=missing-prototypes]
785 | int rt1318_pll_calc(const unsigned int freq_in,

      |     ^~~~~~~~~~~~~~~
/build/stage/linux/sound/soc/codecs/rt1318.c:1340:10: error: ‘struct i2c_driver’
 has no member named ‘probe_new’
 1340 |         .probe_new = rt1318_i2c_probe,
      |          ^~~~~~~~~

/build/stage/linux/sound/soc/codecs/rt1318.c:1340:22: error: initialization of ‘ const struct i2c_device_id *’ from incompatible pointer type ‘int (*)(struct i2c _client *)’ [-Werror=incompatible-pointer-types]
1340 | .probe_new = rt1318_i2c_probe,

      |                      ^~~~~~~~~~~~~~~~

/build/stage/linux/sound/soc/codecs/rt1318.c:1340:22: note: (near initialization for ‘rt1318_i2c_driver.id_table’)
cc1: all warnings being treated as errors

Quoted 5 lines
sound/soc/codecs/rt1318.c new file +5 -0
+	if (lrclk == RT1318_LRCLK_48000 || lrclk == RT1318_LRCLK_44100 ||
+		lrclk == RT1318_LRCLK_16000)
+		regmap_update_bits(rt1318->regmap, RT1318_SRC_TCON,
+				RT1318_SRCIN_F12288_MASK | RT1318_SRCIN_DACLK_MASK,
+				RT1318_SRCIN_TCON4 | RT1318_DACLK_TCON4);

sound/soc/codecs/rt1318.c line 594

Quoted 10 lines
sound/soc/codecs/rt1318.c new file +10 -0
+	else if (lrclk == RT1318_LRCLK_96000)
+		regmap_update_bits(rt1318->regmap, RT1318_SRC_TCON,
+				RT1318_SRCIN_F12288_MASK | RT1318_SRCIN_DACLK_MASK,
+				RT1318_SRCIN_TCON4 | RT1318_DACLK_TCON2);
+	else if (lrclk == RT1318_LRCLK_192000)
+		regmap_update_bits(rt1318->regmap, RT1318_SRC_TCON,
+				RT1318_SRCIN_F12288_MASK | RT1318_SRCIN_DACLK_MASK,
+				RT1318_SRCIN_TCON4 | RT1318_DACLK_TCON1);
+	else
+		return -EINVAL;

This would be more clearly written as a switch statement.

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

This is the initial i2s-based amplifier driver for rt1318.

Applied to

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

Thanks!

[1/1] ASoC: rt1318: Add RT1318 audio amplifier driver

      commit: fe1ff61487ace69cd4e680e36169c90667eb9624

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