* [PATCH] ASoC: imx-rpmsg: Add DSD format support with dynamic DAI format switching
@ 2026-03-26 5:56 Chancel Liu
2026-04-03 14:13 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Chancel Liu @ 2026-03-26 5:56 UTC (permalink / raw)
To: festevam, nicoleotsuka, lgirdwood, broonie, perex, tiwai,
Frank.Li, s.hauer, kernel, linux-sound, linuxppc-dev, imx,
linux-arm-kernel, linux-kernel
Add hw_params callback to dynamically switch DAI format between I2S
and PDM based on audio stream format. When DSD formats are detected,
the DAI format is switched to PDM mode.
Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
sound/soc/fsl/imx-rpmsg.c | 48 +++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index 76a8e68c1b62..40e0043cfe15 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -30,6 +30,53 @@ static const struct snd_soc_dapm_widget imx_rpmsg_dapm_widgets[] = {
SND_SOC_DAPM_MIC("Main MIC", NULL),
};
+static int imx_rpmsg_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
+ struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
+ struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
+ snd_pcm_format_t format = params_format(params);
+ struct device *dev = rtd->card->dev;
+ unsigned int fmt = rtd->dai_link->dai_fmt;
+ bool format_is_dsd = false;
+ int ret;
+
+ switch (format) {
+ case SNDRV_PCM_FORMAT_DSD_U8:
+ case SNDRV_PCM_FORMAT_DSD_U16_LE:
+ case SNDRV_PCM_FORMAT_DSD_U16_BE:
+ case SNDRV_PCM_FORMAT_DSD_U32_LE:
+ case SNDRV_PCM_FORMAT_DSD_U32_BE:
+ format_is_dsd = true;
+ break;
+ default:
+ format_is_dsd = false;
+ break;
+ }
+
+ if (format_is_dsd)
+ fmt = (rtd->dai_link->dai_fmt & ~SND_SOC_DAIFMT_FORMAT_MASK) |
+ SND_SOC_DAIFMT_PDM;
+
+ ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
+ if (ret && ret != -ENOTSUPP) {
+ dev_err(dev, "failed to set cpu dai fmt: %d\n", ret);
+ return ret;
+ }
+ ret = snd_soc_dai_set_fmt(codec_dai, fmt);
+ if (ret && ret != -ENOTSUPP) {
+ dev_err(dev, "failed to set codec dai fmt: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static const struct snd_soc_ops imx_rpmsg_ops = {
+ .hw_params = imx_rpmsg_hw_params,
+};
+
static int imx_rpmsg_late_probe(struct snd_soc_card *card)
{
struct imx_rpmsg *data = snd_soc_card_get_drvdata(card);
@@ -135,6 +182,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
data->dai.dai_fmt = SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBC_CFC;
+ data->dai.ops = &imx_rpmsg_ops;
/*
* i.MX rpmsg sound cards work on codec slave mode. MCLK will be
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: imx-rpmsg: Add DSD format support with dynamic DAI format switching
2026-03-26 5:56 [PATCH] ASoC: imx-rpmsg: Add DSD format support with dynamic DAI format switching Chancel Liu
@ 2026-04-03 14:13 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-04-03 14:13 UTC (permalink / raw)
To: festevam, nicoleotsuka, lgirdwood, perex, tiwai, Frank.Li,
s.hauer, kernel, linux-sound, linuxppc-dev, imx, linux-arm-kernel,
linux-kernel, Chancel Liu
On Thu, 26 Mar 2026 14:56:14 +0900, Chancel Liu wrote:
> ASoC: imx-rpmsg: Add DSD format support with dynamic DAI format switching
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.1
Thanks!
[1/1] ASoC: imx-rpmsg: Add DSD format support with dynamic DAI format switching
https://git.kernel.org/broonie/sound/c/ccd7e53b7d6f
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-03 16:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26 5:56 [PATCH] ASoC: imx-rpmsg: Add DSD format support with dynamic DAI format switching Chancel Liu
2026-04-03 14:13 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox