linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: imx-card: several improvement and fixes
@ 2022-01-04 10:40 Shengjiu Wang
  2022-01-04 10:40 ` [PATCH 1/3] ASoC: imx-card: Need special setting for ak4497 on i.MX8MQ Shengjiu Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Shengjiu Wang @ 2022-01-04 10:40 UTC (permalink / raw)
  To: timur, nicoleotsuka, Xiubo.Lee, festevam, broonie, perex, tiwai,
	alsa-devel
  Cc: linuxppc-dev, linux-kernel

Several improvement and fixes for AK codecs supported on i.MX platfroms

Shengjiu Wang (3):
  ASoC: imx-card: Need special setting for ak4497 on i.MX8MQ
  ASoC: imx-card: Fix mclk calculation issue for akcodec
  ASoC: imx-card: improve the sound quality for low rate

 sound/soc/fsl/imx-card.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] ASoC: imx-card: Need special setting for ak4497 on i.MX8MQ
  2022-01-04 10:40 [PATCH 0/3] ASoC: imx-card: several improvement and fixes Shengjiu Wang
@ 2022-01-04 10:40 ` Shengjiu Wang
  2022-01-04 18:06   ` Mark Brown
  2022-01-04 10:40 ` [PATCH 2/3] ASoC: imx-card: Fix mclk calculation issue for akcodec Shengjiu Wang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Shengjiu Wang @ 2022-01-04 10:40 UTC (permalink / raw)
  To: timur, nicoleotsuka, Xiubo.Lee, festevam, broonie, perex, tiwai,
	alsa-devel
  Cc: linuxppc-dev, linux-kernel

The SAI on i.MX8MQ don't support one2one ratio for mclk:bclk, so
the mclk frequency exceeds the supported range of codec for
the case that sample rate is larger than 705kHZ and format is
S32_LE. Update the supported width for such case.

Fixes: aa736700f42f ("ASoC: imx-card: Add imx-card machine driver")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 sound/soc/fsl/imx-card.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c
index e758c4f1b0bc..e0f3aa6d9501 100644
--- a/sound/soc/fsl/imx-card.c
+++ b/sound/soc/fsl/imx-card.c
@@ -553,8 +553,23 @@ static int imx_card_parse_of(struct imx_card_data *data)
 			link_data->cpu_sysclk_id = FSL_SAI_CLK_MAST1;
 
 			/* sai may support mclk/bclk = 1 */
-			if (of_find_property(np, "fsl,mclk-equal-bclk", NULL))
+			if (of_find_property(np, "fsl,mclk-equal-bclk", NULL)) {
 				link_data->one2one_ratio = true;
+			} else {
+				int i;
+
+				/*
+				 * i.MX8MQ don't support one2one ratio, then
+				 * with ak4497 only 16bit case is supported.
+				 */
+				for (i = 0; i < ARRAY_SIZE(ak4497_fs_mul); i++) {
+					if (ak4497_fs_mul[i].rmin == 705600 &&
+					    ak4497_fs_mul[i].rmax == 768000) {
+						ak4497_fs_mul[i].wmin = 32;
+						ak4497_fs_mul[i].wmax = 32;
+					}
+				}
+			}
 		}
 
 		link->cpus->of_node = args.np;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] ASoC: imx-card: Fix mclk calculation issue for akcodec
  2022-01-04 10:40 [PATCH 0/3] ASoC: imx-card: several improvement and fixes Shengjiu Wang
  2022-01-04 10:40 ` [PATCH 1/3] ASoC: imx-card: Need special setting for ak4497 on i.MX8MQ Shengjiu Wang
@ 2022-01-04 10:40 ` Shengjiu Wang
  2022-01-04 10:40 ` [PATCH 3/3] ASoC: imx-card: improve the sound quality for low rate Shengjiu Wang
  2022-01-06 20:28 ` [PATCH 0/3] ASoC: imx-card: several improvement and fixes Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Shengjiu Wang @ 2022-01-04 10:40 UTC (permalink / raw)
  To: timur, nicoleotsuka, Xiubo.Lee, festevam, broonie, perex, tiwai,
	alsa-devel
  Cc: linuxppc-dev, linux-kernel

Transfer the refined slots and slot_width to akcodec_get_mclk_rate()
for mclk calculation, otherwise the mclk frequency does not match
with the slots and slot_width for S16_LE format, because the default
slot_width is 32.

Fixes: aa736700f42f ("ASoC: imx-card: Add imx-card machine driver")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 sound/soc/fsl/imx-card.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c
index e0f3aa6d9501..f9196fb7e833 100644
--- a/sound/soc/fsl/imx-card.c
+++ b/sound/soc/fsl/imx-card.c
@@ -247,13 +247,14 @@ static bool codec_is_akcodec(unsigned int type)
 }
 
 static unsigned long akcodec_get_mclk_rate(struct snd_pcm_substream *substream,
-					   struct snd_pcm_hw_params *params)
+					   struct snd_pcm_hw_params *params,
+					   int slots, int slot_width)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct imx_card_data *data = snd_soc_card_get_drvdata(rtd->card);
 	const struct imx_card_plat_data *plat_data = data->plat_data;
 	struct dai_link_data *link_data = &data->link_data[rtd->num];
-	unsigned int width = link_data->slots * link_data->slot_width;
+	unsigned int width = slots * slot_width;
 	unsigned int rate = params_rate(params);
 	int i;
 
@@ -349,7 +350,7 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream,
 
 	/* Set MCLK freq */
 	if (codec_is_akcodec(plat_data->type))
-		mclk_freq = akcodec_get_mclk_rate(substream, params);
+		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) */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] ASoC: imx-card: improve the sound quality for low rate
  2022-01-04 10:40 [PATCH 0/3] ASoC: imx-card: several improvement and fixes Shengjiu Wang
  2022-01-04 10:40 ` [PATCH 1/3] ASoC: imx-card: Need special setting for ak4497 on i.MX8MQ Shengjiu Wang
  2022-01-04 10:40 ` [PATCH 2/3] ASoC: imx-card: Fix mclk calculation issue for akcodec Shengjiu Wang
@ 2022-01-04 10:40 ` Shengjiu Wang
  2022-01-06 20:28 ` [PATCH 0/3] ASoC: imx-card: several improvement and fixes Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Shengjiu Wang @ 2022-01-04 10:40 UTC (permalink / raw)
  To: timur, nicoleotsuka, Xiubo.Lee, festevam, broonie, perex, tiwai,
	alsa-devel
  Cc: linuxppc-dev, linux-kernel

According to RM, on auto mode:
For codec AK4458 and AK4497, the lowest ratio of MLCK/FS is 256
if sample rate is 8kHz-48kHz,
For codec AK5558, the lowest ratio of MLCK/FS is 512 if sample
rate is 8kHz-48kHz.

With these setting the sound quality for 8kHz-48kHz can be improved.

Fixes: aa736700f42f ("ASoC: imx-card: Add imx-card machine driver")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 sound/soc/fsl/imx-card.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c
index f9196fb7e833..6f8efd838fcc 100644
--- a/sound/soc/fsl/imx-card.c
+++ b/sound/soc/fsl/imx-card.c
@@ -120,7 +120,7 @@ struct imx_card_data {
 
 static struct imx_akcodec_fs_mul ak4458_fs_mul[] = {
 	/* Normal, < 32kHz */
-	{ .rmin = 8000,   .rmax = 24000,  .wmin = 1024, .wmax = 1024, },
+	{ .rmin = 8000,   .rmax = 24000,  .wmin = 256,  .wmax = 1024, },
 	/* Normal, 32kHz */
 	{ .rmin = 32000,  .rmax = 32000,  .wmin = 256,  .wmax = 1024, },
 	/* Normal */
@@ -151,8 +151,8 @@ static struct imx_akcodec_fs_mul ak4497_fs_mul[] = {
 	 * Table 7      - mapping multiplier and speed mode
 	 * Tables 8 & 9 - mapping speed mode and LRCK fs
 	 */
-	{ .rmin = 8000,   .rmax = 32000,  .wmin = 1024, .wmax = 1024, }, /* Normal, <= 32kHz */
-	{ .rmin = 44100,  .rmax = 48000,  .wmin = 512,  .wmax = 512, }, /* Normal */
+	{ .rmin = 8000,   .rmax = 32000,  .wmin = 256,  .wmax = 1024, }, /* Normal, <= 32kHz */
+	{ .rmin = 44100,  .rmax = 48000,  .wmin = 256,  .wmax = 512, }, /* Normal */
 	{ .rmin = 88200,  .rmax = 96000,  .wmin = 256,  .wmax = 256, }, /* Double */
 	{ .rmin = 176400, .rmax = 192000, .wmin = 128,  .wmax = 128, }, /* Quad */
 	{ .rmin = 352800, .rmax = 384000, .wmin = 128,  .wmax = 128, }, /* Oct */
@@ -164,7 +164,7 @@ static struct imx_akcodec_fs_mul ak4497_fs_mul[] = {
  * (Table 4 from datasheet)
  */
 static struct imx_akcodec_fs_mul ak5558_fs_mul[] = {
-	{ .rmin = 8000,   .rmax = 32000,  .wmin = 1024, .wmax = 1024, },
+	{ .rmin = 8000,   .rmax = 32000,  .wmin = 512,  .wmax = 1024, },
 	{ .rmin = 44100,  .rmax = 48000,  .wmin = 512,  .wmax = 512, },
 	{ .rmin = 88200,  .rmax = 96000,  .wmin = 256,  .wmax = 256, },
 	{ .rmin = 176400, .rmax = 192000, .wmin = 128,  .wmax = 128, },
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] ASoC: imx-card: Need special setting for ak4497 on i.MX8MQ
  2022-01-04 10:40 ` [PATCH 1/3] ASoC: imx-card: Need special setting for ak4497 on i.MX8MQ Shengjiu Wang
@ 2022-01-04 18:06   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2022-01-04 18:06 UTC (permalink / raw)
  To: Shengjiu Wang
  Cc: alsa-devel, timur, Xiubo.Lee, linuxppc-dev, tiwai, perex,
	nicoleotsuka, festevam, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 568 bytes --]

On Tue, Jan 04, 2022 at 06:40:33PM +0800, Shengjiu Wang wrote:

>  			/* sai may support mclk/bclk = 1 */
> -			if (of_find_property(np, "fsl,mclk-equal-bclk", NULL))
> +			if (of_find_property(np, "fsl,mclk-equal-bclk", NULL)) {
>  				link_data->one2one_ratio = true;
> +			} else {
> +				int i;
> +
> +				/*
> +				 * i.MX8MQ don't support one2one ratio, then
> +				 * with ak4497 only 16bit case is supported.
> +				 */
> +				for (i = 0; i < ARRAY_SIZE(ak4497_fs_mul); i++) {

Shouldn't this be keyed off checking that we are actually running with
an ak4497?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] ASoC: imx-card: several improvement and fixes
  2022-01-04 10:40 [PATCH 0/3] ASoC: imx-card: several improvement and fixes Shengjiu Wang
                   ` (2 preceding siblings ...)
  2022-01-04 10:40 ` [PATCH 3/3] ASoC: imx-card: improve the sound quality for low rate Shengjiu Wang
@ 2022-01-06 20:28 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2022-01-06 20:28 UTC (permalink / raw)
  To: perex, tiwai, Xiubo.Lee, alsa-devel, festevam, nicoleotsuka,
	timur, Shengjiu Wang
  Cc: linuxppc-dev, linux-kernel

On Tue, 4 Jan 2022 18:40:32 +0800, Shengjiu Wang wrote:
> Several improvement and fixes for AK codecs supported on i.MX platfroms
> 
> Shengjiu Wang (3):
>   ASoC: imx-card: Need special setting for ak4497 on i.MX8MQ
>   ASoC: imx-card: Fix mclk calculation issue for akcodec
>   ASoC: imx-card: improve the sound quality for low rate
> 
> [...]

Applied to

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

Thanks!

[1/3] ASoC: imx-card: Need special setting for ak4497 on i.MX8MQ
      commit: 3349b3d0c63b8b6fcca58156d72407f0b2e101ac
[2/3] ASoC: imx-card: Fix mclk calculation issue for akcodec
      commit: f331ae5fa59fbfb748317b290648fc3f1a50d932
[3/3] ASoC: imx-card: improve the sound quality for low rate
      commit: 3969341813eb56d2dfc39bb64229359a6ae3c195

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] 6+ messages in thread

end of thread, other threads:[~2022-01-06 20:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-04 10:40 [PATCH 0/3] ASoC: imx-card: several improvement and fixes Shengjiu Wang
2022-01-04 10:40 ` [PATCH 1/3] ASoC: imx-card: Need special setting for ak4497 on i.MX8MQ Shengjiu Wang
2022-01-04 18:06   ` Mark Brown
2022-01-04 10:40 ` [PATCH 2/3] ASoC: imx-card: Fix mclk calculation issue for akcodec Shengjiu Wang
2022-01-04 10:40 ` [PATCH 3/3] ASoC: imx-card: improve the sound quality for low rate Shengjiu Wang
2022-01-06 20:28 ` [PATCH 0/3] ASoC: imx-card: several improvement and fixes Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).