[alsa-devel] [PATCH 0/2] 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(-)
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.
Signed-off-by: Nicolin Chen nicoleotsuka@gmail.com --- sound/soc/fsl/fsl-asoc-card.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 007c772..14572e6 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -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 */
On Fri, Oct 24, 2014 at 04:48:11PM -0700, Nicolin Chen wrote:
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?
On Mon, Oct 27, 2014 at 05:30:31PM +0000, Mark Brown wrote:
On Fri, Oct 24, 2014 at 04:48:11PM -0700, Nicolin Chen wrote:
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
On Fri, Oct 24, 2014 at 04:48:11PM -0700, Nicolin Chen wrote:
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.
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.
Signed-off-by: Nicolin Chen nicoleotsuka@gmail.com --- sound/soc/fsl/fsl_esai.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index a645e29..ca319d5 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -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;
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.
Signed-off-by: Nicolin Chen nicoleotsuka@gmail.com --- sound/soc/fsl/fsl-asoc-card.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 14572e6..3f6959c 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -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;
On Fri, Oct 24, 2014 at 04:48:10PM -0700, Nicolin Chen wrote:
@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?
On Fri, Oct 31, 2014 at 06:12:24PM +0000, Mark Brown wrote:
On Fri, Oct 24, 2014 at 04:48:10PM -0700, Nicolin Chen wrote:
@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
On Fri, Oct 24, 2014 at 04:48:10PM -0700, Nicolin Chen wrote:
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.
participants (2)
-
Mark Brown
-
Nicolin Chen