Skip to contentSkip to conversation

ASoC: fsl: Use dynamic slot width for ESAI.

PATCH Applied Nicolin Chen 2 participants 10 messages Oct 24, 2014 – Nov 25, 2014

Subsystems (3)
lore
Share & tools
lore

Nicolin Chen

author reviewer
#0 lore raw

cover ASoC: fsl: Use dynamic slot width for ESAI.

This series of patches add the support of dynamic slot width for ESAI driver. To do this, the PATCH-1 removes the fixed width. In order not to break those platforms that use fixed width, there comes the PATCH-2 to apply an override of slot_width.

@Shengjiu,
Will you be available to test this series on Sabre Auto for both Master and Slave cases? I'd like to wait for your Test-by. Thanks.

Nicolin Chen (2):
ASoC: fsl_esai: Use dynamic slot width as default
ASoC: fsl-asoc-card: Add slot_width setting for cpu-dai

 sound/soc/fsl/fsl-asoc-card.c | 12 ++++++++++++
 sound/soc/fsl/fsl_esai.c      | 12 +++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)
Signature · 1 line
1.9.1
author reviewer
#1 lore raw

PATCH 1/1 ASoC: fsl-asoc-card: Don't bypass settings if cpu-dai is Master

When cpu-dai is the DAI Master (CBM_CFx), it may need some configurations, set_sysclk() call for eample, for cpu-dai side in the hw_params(), even if the set_bias_level() has already taken care of the codec-dai side.

So this patch just simply adds an additional condition.

---
 sound/soc/fsl/fsl-asoc-card.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
sound/soc/fsl/fsl-asoc-card.c +6 -1
index 007c772..14572e6 100644
@@ -125,7 +125,12 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
 	priv->sample_rate = params_rate(params);
 	priv->sample_format = params_format(params);
 
-	if (priv->card.set_bias_level)
+	/*
+	 * If codec-dai is DAI Master and all configurations are already in the
+	 * set_bias_level(), bypass the remaining settings in hw_params().
+	 * Note: (dai_fmt & CBM_CFM) includes CBM_CFM and CBM_CFS.
+	 */
+	if (priv->card.set_bias_level && priv->dai_fmt & SND_SOC_DAIFMT_CBM_CFM)
 		return 0;
 
 	/* Specific configurations of DAIs starts from here */
Signature · 1 line
1.9.1
author reviewer
#5 lore raw

PATCH 1/2 ASoC: fsl_esai: Use dynamic slot width as default

In reply to Nicolin Chen

The driver previously used 32-bit fixed slot width as default. In result, ESAI might use 32-bit length to capture 16-bit width audio slot from CODEC side when ESAI is running as DAI slave.

So this patch just removes the default slot_width so as to use dynamic slot width. If there comes a specific situation that needs a fixed width, the machine driver shall set slot_width via set_tdm_slot() so as to let the ESAI driver replace the dynamic width policy with the fixed value.

---
 sound/soc/fsl/fsl_esai.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/fsl/fsl_esai.c +7 -5
index a645e29..ca319d5 100644
@@ -513,10 +513,15 @@ static int fsl_esai_hw_params(struct snd_pcm_substream *substream,
 	u32 width = snd_pcm_format_width(params_format(params));
 	u32 channels = params_channels(params);
 	u32 pins = DIV_ROUND_UP(channels, esai_priv->slots);
+	u32 slot_width = width;
 	u32 bclk, mask, val;
 	int ret;
 
-	bclk = params_rate(params) * esai_priv->slot_width * esai_priv->slots;
+	/* Override slot_width if being specifially set */
+	if (esai_priv->slot_width)
+		slot_width = esai_priv->slot_width;
+
+	bclk = params_rate(params) * slot_width * esai_priv->slots;
 
 	ret = fsl_esai_set_bclk(dai, tx, bclk);
 	if (ret)
@@ -538,7 +543,7 @@ static int fsl_esai_hw_params(struct snd_pcm_substream *substream,
 	regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx), mask, val);
 
 	mask = ESAI_xCR_xSWS_MASK | (tx ? ESAI_xCR_PADC : 0);
-	val = ESAI_xCR_xSWS(esai_priv->slot_width, width) | (tx ? ESAI_xCR_PADC : 0);
+	val = ESAI_xCR_xSWS(slot_width, width) | (tx ? ESAI_xCR_PADC : 0);
 
 	regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), mask, val);
 
@@ -780,9 +785,6 @@ static int fsl_esai_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	/* Set a default slot size */
-	esai_priv->slot_width = 32;
-
 	/* Set a default slot number */
 	esai_priv->slots = 2;
 
Signature · 1 line
1.9.1
author reviewer
#6 lore raw

PATCH 2/2 ASoC: fsl-asoc-card: Add slot_width setting for cpu-dai

In reply to Nicolin Chen

ESAI may need to use fixed slot width to comply with external CODEC. So this set_tdm_slot() call will allow the ESAI driver to override its default dynamic slot width policy.

---
 sound/soc/fsl/fsl-asoc-card.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
sound/soc/fsl/fsl-asoc-card.c +12 -0
index 14572e6..3f6959c 100644
@@ -51,6 +51,7 @@ struct codec_priv {
  * @sysclk_freq[2]: SYSCLK rates for set_sysclk()
  * @sysclk_dir[2]: SYSCLK directions for set_sysclk()
  * @sysclk_id[2]: SYSCLK ids for set_sysclk()
+ * @slot_width: Slot width of each frame
  *
  * Note: [1] for tx and [0] for rx
  */
@@ -58,6 +59,7 @@ struct cpu_priv {
 	unsigned long sysclk_freq[2];
 	u32 sysclk_dir[2];
 	u32 sysclk_id[2];
+	u32 slot_width;
 };
 
 /**
@@ -142,6 +144,15 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
 		return ret;
 	}
 
+	if (cpu_priv->slot_width) {
+		ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2,
+					       cpu_priv->slot_width);
+		if (ret) {
+			dev_err(dev, "failed to set TDM slot for cpu dai\n");
+			return ret;
+		}
+	}
+
 	return 0;
 }
 
@@ -453,6 +464,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
 		priv->cpu_priv.sysclk_freq[RX] = priv->codec_priv.mclk_freq;
 		priv->cpu_priv.sysclk_dir[TX] = SND_SOC_CLOCK_OUT;
 		priv->cpu_priv.sysclk_dir[RX] = SND_SOC_CLOCK_OUT;
+		priv->cpu_priv.slot_width = 32;
 		priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
 	} else if (of_device_is_compatible(np, "fsl,imx-audio-sgtl5000")) {
 		priv->codec_priv.mclk_id = SGTL5000_SYSCLK;
Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [PATCH] ASoC: fsl-asoc-card: Don't bypass settings if cpu-dai is Master

In reply to Nicolin Chen
Quoted 5 lines · Nicolin Chen

When cpu-dai is the DAI Master (CBM_CFx), it may need some configurations, set_sysclk() call for eample, for cpu-dai side in the hw_params(), even if the set_bias_level() has already taken care of the codec-dai side.

So this patch just simply adds an additional condition.

This was threaded with another patch series - did you intend to submit this or did it get sent by accident?

author reviewer
#3 lore raw

Re: [PATCH] ASoC: fsl-asoc-card: Don't bypass settings if cpu-dai is Master

Quoted 9 lines · Mark Brown
Quoted 5 lines · Nicolin Chen

When cpu-dai is the DAI Master (CBM_CFx), it may need some configurations, set_sysclk() call for eample, for cpu-dai side in the hw_params(), even if the set_bias_level() has already taken care of the codec-dai side.

So this patch just simply adds an additional condition.

This was threaded with another patch series - did you intend to submit this or did it get sent by accident?

I created this one without "--thread" (separately from that series) but accidentally sent the patch along with the series in one git-send-mail command. So I think I don't need to resend it since it's already there.

Please regard this one as one single patch.

Thank you.
Nicolin

maintainer Applied
#4 lore raw

Re: [PATCH] ASoC: fsl-asoc-card: Don't bypass settings if cpu-dai is Master

In reply to Nicolin Chen
Quoted 3 lines · Nicolin Chen

When cpu-dai is the DAI Master (CBM_CFx), it may need some configurations, set_sysclk() call for eample, for cpu-dai side in the hw_params(), even if the set_bias_level() has already taken care of the codec-dai side.

Applied, thanks.

maintainer
#7 lore raw
In reply to Nicolin Chen
Quoted 3 lines · Nicolin Chen

@Shengjiu,
Will you be available to test this series on Sabre Auto for both Master and Slave cases? I'd like to wait for your Test-by. Thanks.

Any ETA on the testing?

author reviewer
#8 lore raw
Quoted 7 lines · Mark Brown
Quoted 3 lines · Nicolin Chen

@Shengjiu,
Will you be available to test this series on Sabre Auto for both Master and Slave cases? I'd like to wait for your Test-by. Thanks.

Any ETA on the testing?

Please hold one more week. I'll also try to contact him personally.

Thank you.
Nicolin

maintainer Applied
#9 lore raw
In reply to Nicolin Chen
Quoted 4 lines · Nicolin Chen

This series of patches add the support of dynamic slot width for ESAI driver. To do this, the PATCH-1 removes the fixed width. In order not to break those platforms that use fixed width, there comes the PATCH-2 to apply an override of slot_width.

Applied both, thanks.