Re: [PATCH v2 3/3] ASoC: rt766: add RT766/RT767 SDCA driver

Mark Brown <[email protected]> Thu, 30 Jul 2026 18:26:06 +0100
Newsgroups org.kernel.vger.linux-sound
Message-ID <[email protected]>
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.

> +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?

> +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):
> +	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?

> +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.

> +static int rt766_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
> +				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),
> +			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?


> +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.
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmpriS0ACgkQJNaLcl1U
h9AYEAf/aYWtxsHWtXtZRq88XnkfxadtKiW8HKpSxdi9WrzScrOiSktgLjTZycrQ
58GMwqwR2EVxh++h6qHvO4BYvbcc/HGknSuxLPXG9b/BGsSlD39EjIZbV3hiwGPp
dYJMaOK/mfELywR/74/nTrZzF3q3SJOUVdmWAwLmeRHn5urZUd3RBOh4uS/JV4Hc
jOBixeJtFYavAxQDC7KwEnRnABlJYGkI/MoBfgMosJNi+2mcptvtspaxMzotLSRL
l6PNPKMStNccvSm3Nq5UMfD3xD13M7gHmWcppS2Z0rw5Ads4TMErGqMI1Bo0hS+0
XIYyErIPJYig9OQ2yPVVcEC/VyBycg==
=bTLq
-----END PGP SIGNATURE-----