]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: imx-card: Fix DSD/PDM mclk frequency
authorShengjiu Wang <shengjiu.wang@nxp.com>
Wed, 6 Jul 2022 09:42:55 +0000 (17:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:05 +0000 (14:24 +0200)
[ Upstream commit 95c3c4178c711ce30890417bb91a6136a92f561a ]

The DSD/PDM rate not only DSD64/128/256/512, which are the
multiple rate of 44.1kHz,  but also support the multiple
rate of 8kHz, so can't force all mclk frequency to be
22579200Hz, need to assign the frequency according to
rate.

Fixes: 53eb042a8665 ("ASoC: imx-card: Add imx-card machine driver")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1657100575-8261-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/fsl/imx-card.c

index 55bc1bb0dbbd388ca6c1a5f699112b1f7cb1284e..b28b30c69a3f1e271e27f869355bd15ae9072d9b 100644 (file)
@@ -17,6 +17,9 @@
 
 #include "fsl_sai.h"
 
+#define IMX_CARD_MCLK_22P5792MHZ  22579200
+#define IMX_CARD_MCLK_24P576MHZ   24576000
+
 enum codec_type {
        CODEC_DUMMY = 0,
        CODEC_AK5558 = 1,
@@ -353,9 +356,14 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream,
                mclk_freq = akcodec_get_mclk_rate(substream, params, slots, slot_width);
        else
                mclk_freq = params_rate(params) * slots * slot_width;
-       /* Use the maximum freq from DSD512 (512*44100 = 22579200) */
-       if (format_is_dsd(params))
-               mclk_freq = 22579200;
+
+       if (format_is_dsd(params)) {
+               /* Use the maximum freq from DSD512 (512*44100 = 22579200) */
+               if (!(params_rate(params) % 11025))
+                       mclk_freq = IMX_CARD_MCLK_22P5792MHZ;
+               else
+                       mclk_freq = IMX_CARD_MCLK_24P576MHZ;
+       }
 
        ret = snd_soc_dai_set_sysclk(cpu_dai, link_data->cpu_sysclk_id, mclk_freq,
                                     SND_SOC_CLOCK_OUT);