ASoC: rt766: add RT766/RT767 SDCA driver
Subsystems (3)
PATCH v2 3/3 ASoC: rt766: add RT766/RT767 SDCA driver
From: Shuming Fan <[email protected]>
This patch adds the initial SDCA multi-function codec driver for the RT766 and RT767.
--- sound/soc/codecs/Kconfig | 8 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt766-sdca-sdw.c | 341 ++++++++ sound/soc/codecs/rt766-sdca-sdw.h | 61 ++ sound/soc/codecs/rt766-sdca.c | 1339 +++++++++++++++++++++++++++++ sound/soc/codecs/rt766-sdca.h | 138 +++ 6 files changed, 1889 insertions(+) create mode 100644 sound/soc/codecs/rt766-sdca-sdw.c create mode 100644 sound/soc/codecs/rt766-sdca-sdw.h create mode 100644 sound/soc/codecs/rt766-sdca.c create mode 100644 sound/soc/codecs/rt766-sdca.h
sound/soc/codecs/Kconfig +8 -0
@@ -238,6 +238,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_RT715_SDCA_SDW imply SND_SOC_RT721_SDCA_SDW imply SND_SOC_RT722_SDCA_SDW + imply SND_SOC_RT766_SDCA_SDW imply SND_SOC_RT1308_SDW imply SND_SOC_RT1316_SDW imply SND_SOC_RT1318
@@ -1983,6 +1984,13 @@ config SND_SOC_RT715_SDCA_SDW select REGMAP_SOUNDWIRE select REGMAP_SOUNDWIRE_MBQ +config SND_SOC_RT766_SDCA_SDW + tristate "Realtek RT766 SDCA Codec - SDW" + depends on SOUNDWIRE + depends on SND_SOC_SDCA + select REGMAP_SOUNDWIRE + select REGMAP_SOUNDWIRE_MBQ + config SND_SOC_RT9120 tristate "Richtek RT9120 Stereo Class-D Amplifier" depends on I2C
sound/soc/codecs/Makefile +2 -0
@@ -285,6 +285,7 @@ snd-soc-rt715-y := rt715.o rt715-sdw.o snd-soc-rt715-sdca-y := rt715-sdca.o rt715-sdca-sdw.o snd-soc-rt721-sdca-y := rt721-sdca.o rt721-sdca-sdw.o snd-soc-rt722-sdca-y := rt722-sdca.o rt722-sdca-sdw.o +snd-soc-rt766-sdca-y := rt766-sdca.o rt766-sdca-sdw.o snd-soc-rt9120-y := rt9120.o snd-soc-rt9123-y := rt9123.o snd-soc-rt9123p-y := rt9123p.o
@@ -726,6 +727,7 @@ obj-$(CONFIG_SND_SOC_RT715) += snd-soc-rt715.o obj-$(CONFIG_SND_SOC_RT715_SDCA_SDW) += snd-soc-rt715-sdca.o obj-$(CONFIG_SND_SOC_RT721_SDCA_SDW) += snd-soc-rt721-sdca.o obj-$(CONFIG_SND_SOC_RT722_SDCA_SDW) += snd-soc-rt722-sdca.o +obj-$(CONFIG_SND_SOC_RT766_SDCA_SDW) += snd-soc-rt766-sdca.o obj-$(CONFIG_SND_SOC_RT9120) += snd-soc-rt9120.o obj-$(CONFIG_SND_SOC_RT9123) += snd-soc-rt9123.o obj-$(CONFIG_SND_SOC_RT9123P) += snd-soc-rt9123p.o
sound/soc/codecs/rt766-sdca-sdw.c new file +341 -0
341 lines not on this page · raw message
sound/soc/codecs/rt766-sdca-sdw.h new file +61 -0
61 lines not on this page · raw message
sound/soc/codecs/rt766-sdca.c new file +1339 -0
1,339 lines not on this page · raw message
sound/soc/codecs/rt766-sdca.h new file +138 -0
138 lines not on this page · raw message
Signature · 1 line
2.54.0
Quoted 5 lines · On 7/29/26 05:22, [email protected] wrote:
From: Shuming Fan <[email protected]>
This patch adds the initial SDCA multi-function codec driver for the RT766 and RT767.
Signed-off-by Shuming Fan <[email protected]>
Quoted 12 lines
--- sound/soc/codecs/Kconfig | 8 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt766-sdca-sdw.c | 341 ++++++++ sound/soc/codecs/rt766-sdca-sdw.h | 61 ++ sound/soc/codecs/rt766-sdca.c | 1339 +++++++++++++++++++++++++++++ sound/soc/codecs/rt766-sdca.h | 138 +++ 6 files changed, 1889 insertions(+) create mode 100644 sound/soc/codecs/rt766-sdca-sdw.c create mode 100644 sound/soc/codecs/rt766-sdca-sdw.h create mode 100644 sound/soc/codecs/rt766-sdca.c create mode 100644 sound/soc/codecs/rt766-sdca.h
LGTM
Mark Brown
maintainersound/soc/codecs/Kconfig config SND_SOC_RT715_SDCA_SDW · line 1993
Quoted 11 lines · On Wed, Jul 29, 2026 at 11:22:46AM +0800, [email protected] wrote:
From: Shuming Fan <[email protected]>
This patch adds the initial SDCA multi-function codec driver for the RT766 and RT767.
sound/soc/codecs/Kconfig +7
-0+config SND_SOC_RT766_SDCA_SDW + tristate "Realtek RT766 SDCA Codec - SDW" + depends on SOUNDWIRE + depends on SND_SOC_SDCA + select REGMAP_SOUNDWIRE + select REGMAP_SOUNDWIRE_MBQ +
Does this need SND_SOC_SDCA_IRQ and SND_SOC_SDCA_HID?
Quoted 4 lines
sound/soc/codecs/rt766-sdca-sdw.c new file +4
-0+static int rt766_sdca_mbq_size (struct device *dev,unsigned int reg) +{ +switch (reg) { +case RT766_VOLUME_REG (UAJ ,USER_FU41 ,1 ):
sound/soc/codecs/rt766-sdca-sdw.c line 131
Quoted 10 lines
sound/soc/codecs/rt766-sdca-sdw.c new file +10
-0+case RT766_VOLUME_REG (UAJ ,USER_FU41 ,2 ): +case RT766_VOLUME_REG (UAJ ,USER_FU36 ,1 ): +case RT766_VOLUME_REG (UAJ ,USER_FU36 ,2 ): +case RT766_VOLUME_REG (MIC ,USER_FU113 ,1 ): +case RT766_VOLUME_REG (MIC ,USER_FU113 ,2 ): +case RT766_VOLUME_REG (MIC ,USER_FU113 ,3 ): +case RT766_VOLUME_REG (MIC ,USER_FU113 ,4 ): +case RT766_VOLUME_REG (AMP ,USER_FU21 ,1 ): +case RT766_VOLUME_REG (AMP ,USER_FU21 ,2 ): +return 2 ;
Are the FU33 gain registers also 2 bytes?
sound/soc/codecs/rt766-sdca-sdw.c line 233
Quoted 8 lines
sound/soc/codecs/rt766-sdca-sdw.c new file +8
-0+static void rt766_sdca_sdw_remove (struct sdw_slave *slave) +{ +struct rt766_sdca_priv *rt766 =dev_get_drvdata (&slave->dev); + +pm_runtime_disable (&slave->dev); + +mutex_destroy (&rt766->disable_irq_lock); +}
The mutex is used by the interrupt code, probably better to allocate it using devm so it's ordered with everything else during teardown.
Quoted 6 lines
sound/soc/codecs/rt766-sdca.c new file +5
-0+static int rt766_sdca_pcm_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params, +struct snd_soc_dai *dai) +{ +
sound/soc/codecs/rt766-sdca.c line 1003
Quoted 10 lines
sound/soc/codecs/rt766-sdca.c new file +10
-0+/* set sampling frequency */ +switch (dai->id) { +case RT766_AIF1 : +regmap_write (rt766->regmap, +RT766_SDCA_CTL (UAJ ,CS41 ,SDCA_CTL_CS_SAMPLERATEINDEX ), + sampling_rate); +regmap_write (rt766->regmap, +RT766_SDCA_CTL (UAJ ,CS36 ,SDCA_CTL_CS_SAMPLERATEINDEX ), + sampling_rate); +break ;
Are these separate playback/capture clocks? If so should we only be programming the one that's active, or if they have to be in sync should the DAI be flagged as needing symmetric rates?
sound/soc/codecs/rt766-sdca.c line 1193
Quoted 10 lines
sound/soc/codecs/rt766-sdca.c new file +9
-0+int rt766_sdca_init (struct device *dev,struct regmap *regmap,struct sdw_slave *slave) +{ + rates =rt766_find_dt_rates (dev, func_data_ptr,"IT 41" ); +if (rates) + rt766_sdca_dai[RT766_DAI_UAJ ].playback.rates = rates; + + rates =rt766_find_dt_rates (dev, func_data_ptr,"OT 36" ); +if (rates) + rt766_sdca_dai[RT766_DAI_UAJ ].capture.rates = rates;
This should modify a local copy rather than the global in case there's multiple devices with different configs.
Quoted 9 lines
sound/soc/codecs/Kconfig config SND_SOC_RT715_SDCA_SDW · line 1993
Quoted 7 lines
sound/soc/codecs/Kconfig +7
-0+config SND_SOC_RT766_SDCA_SDW + tristate "Realtek RT766 SDCA Codec - SDW" + depends on SOUNDWIRE + depends on SND_SOC_SDCA + select REGMAP_SOUNDWIRE + select REGMAP_SOUNDWIRE_MBQ +Does this need
SND_SOC_SDCA_IRQandSND_SOC_SDCA_HID?
Yes, will select this two configs.
Quoted 8 lines
Quoted 8 lines
sound/soc/codecs/rt766-sdca-sdw.c new file +8
-0+static int rt766_sdca_mbq_size (struct device *dev,unsigned int reg) +{ +switch (reg) { +case RT766_VOLUME_REG (UAJ ,USER_FU41 ,1 ): +case RT766_VOLUME_REG (UAJ ,USER_FU41 ,2 ): +case RT766_VOLUME_REG (UAJ ,USER_FU36 ,1 ): +case RT766_VOLUME_REG (UAJ ,USER_FU36 ,2 ): +case RT766_VOLUME_REG (MIC ,USER_FU113 ,1 ):
Quoted 8 lines
sound/soc/codecs/rt766-sdca-sdw.c line 131
Quoted 6 lines
sound/soc/codecs/rt766-sdca-sdw.c new file +6
-0+case RT766_VOLUME_REG (MIC ,USER_FU113 ,2 ): +case RT766_VOLUME_REG (MIC ,USER_FU113 ,3 ): +case RT766_VOLUME_REG (MIC ,USER_FU113 ,4 ): +case RT766_VOLUME_REG (AMP ,USER_FU21 ,1 ): +case RT766_VOLUME_REG (AMP ,USER_FU21 ,2 ): +return 2 ;Are the FU33 gain registers also 2 bytes?
Yes, will add FU33 gain registers here.
Quoted 10 lines
sound/soc/codecs/rt766-sdca-sdw.c line 233
Quoted 7 lines
sound/soc/codecs/rt766-sdca-sdw.c new file +7
-0+static void rt766_sdca_sdw_remove (struct sdw_slave *slave) { +struct rt766_sdca_priv *rt766 =dev_get_drvdata (&slave->dev); + +pm_runtime_disable (&slave->dev); + +mutex_destroy (&rt766->disable_irq_lock); +}The mutex is used by the interrupt code, probably better to allocate it using devm so it's ordered with everything else during teardown.
will fix. Thanks.
Quoted 17 lines
Quoted 1 line
+static int rt766_sdca_pcm_hw_params(struct
snd_pcm_substream*substream,
sound/soc/codecs/rt766-sdca.c
Quoted 10 lines
sound/soc/codecs/rt766-sdca.c new file +9
-0+ struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + +/* set sampling frequency */ +switch (dai->id) { +case RT766_AIF1 : + regmap_write(rt766->regmap, + RT766_SDCA_CTL(UAJ, CS41,
SDCA_CTL_CS_SAMPLERATEINDEX),sound/soc/codecs/rt766-sdca.c
Quoted 3 lines
sound/soc/codecs/rt766-sdca.c new file +3
-0+ sampling_rate); + regmap_write(rt766->regmap, + RT766_SDCA_CTL(UAJ, CS36,
SDCA_CTL_CS_SAMPLERATEINDEX),
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ sampling_rate); + break;Are these separate playback/capture clocks? If so should we only be programming the one that's active, or if they have to be in sync should the DAI be flagged as needing symmetric rates?
Will add symmetric_rate = 1 for this DAI.
Quoted 13 lines
sound/soc/codecs/rt766-sdca.c line 1193
Quoted 10 lines
sound/soc/codecs/rt766-sdca.c new file +9
-0+int rt766_sdca_init (struct device *dev,struct regmap *regmap,struct +sdw_slave *slave) { + rates =rt766_find_dt_rates (dev, func_data_ptr,"IT 41" ); +if (rates) + rt766_sdca_dai[RT766_DAI_UAJ ].playback.rates = rates; + + rates =rt766_find_dt_rates (dev, func_data_ptr,"OT 36" ); +if (rates) + rt766_sdca_dai[RT766_DAI_UAJ ].capture.rates = rates;This should modify a local copy rather than the global in case there's multiple devices with different configs.
Will fix.