Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1728603 > unrolled thread

[PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot number

Started byNicolin Chen <nicoleotsuka@gmail.com>
First post2017-09-08 07:30 +0200
Last post2017-09-08 10:50 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot number Nicolin Chen <nicoleotsuka@gmail.com> - 2017-09-08 07:30 +0200
    Re: [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot  number Nicolin Chen <nicoleotsuka@gmail.com> - 2017-09-08 07:50 +0200
      Re: [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot  number Arnaud Mouiche <arnaud.mouiche@invoxia.com> - 2017-09-08 08:20 +0200
      Re: [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot  number Łukasz Majewski <lukma@denx.de> - 2017-09-08 10:50 +0200

#1728603 — [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot number

FromNicolin Chen <nicoleotsuka@gmail.com>
Date2017-09-08 07:30 +0200
Subject[PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot number
Message-ID<unk1z-2p0-3@gated-at.bofh.it>
The set_sysclk() now is used to override the output bit clock rate.
But this is not a common way to implement a set_dai_sysclk(). And
this creates a problem when a general machine driver (simple-card
for example) tries to do set_dai_sysclk() by passing an input clock
rate for the baud clock instead of setting the bit clock rate as
fsl_ssi driver expected.

So this patch solves this problem by firstly removing set_sysclk()
since the hw_params() can calculate the bit clock rate. Secondly,
in order not to break those TDM use cases which previously might
have been using set_sysclk() to override the bit clock rate, this
patch changes the driver to override it based on the slot number.

The patch also removes an obsolete comment of the dir parameter.

Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
---
 sound/soc/fsl/fsl_ssi.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 64598d1..3657c88 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -197,12 +197,12 @@ struct fsl_ssi_soc_data {
  * @use_dma: DMA is used or FIQ with stream filter
  * @use_dual_fifo: DMA with support for both FIFOs used
  * @fifo_deph: Depth of the SSI FIFOs
+ * @slots: number of slots
  * @rxtx_reg_val: Specific register settings for receive/transmit configuration
  *
  * @clk: SSI clock
  * @baudclk: SSI baud clock for master mode
  * @baudclk_streams: Active streams that are using baudclk
- * @bitclk_freq: bitclock frequency set by .set_dai_sysclk
  *
  * @dma_params_tx: DMA transmit parameters
  * @dma_params_rx: DMA receive parameters
@@ -233,12 +233,12 @@ struct fsl_ssi_private {
 	bool use_dual_fifo;
 	bool has_ipg_clk_name;
 	unsigned int fifo_depth;
+	unsigned int slots;
 	struct fsl_ssi_rxtx_reg_val rxtx_reg_val;
 
 	struct clk *clk;
 	struct clk *baudclk;
 	unsigned int baudclk_streams;
-	unsigned int bitclk_freq;
 
 	/* regcache for volatile regs */
 	u32 regcache_sfcsr;
@@ -700,8 +700,7 @@ static void fsl_ssi_shutdown(struct snd_pcm_substream *substream,
  * Note: This function can be only called when using SSI as DAI master
  *
  * Quick instruction for parameters:
- * freq: Output BCLK frequency = samplerate * 32 (fixed) * channels
- * dir: SND_SOC_CLOCK_OUT -> TxBCLK, SND_SOC_CLOCK_IN -> RxBCLK.
+ * freq: Output BCLK frequency = samplerate * 32 (fixed) * slots (or channels)
  */
 static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
 		struct snd_soc_dai *cpu_dai,
@@ -716,9 +715,9 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
 	unsigned int freq;
 	bool baudclk_is_used;
 
-	/* Prefer the explicitly set bitclock frequency */
-	if (ssi_private->bitclk_freq)
-		freq = ssi_private->bitclk_freq;
+	/* Generate bit clock based on the slot or channel number */
+	if (ssi_private->slots)
+		freq = ssi_private->slots * 32 * params_rate(hw_params);
 	else
 		freq = params_channels(hw_params) * 32 * params_rate(hw_params);
 
@@ -805,16 +804,6 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
 	return 0;
 }
 
-static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
-		int clk_id, unsigned int freq, int dir)
-{
-	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
-
-	ssi_private->bitclk_freq = freq;
-
-	return 0;
-}
-
 /**
  * fsl_ssi_hw_params - program the sample size
  *
@@ -1121,6 +1110,8 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
 
 	regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN, val);
 
+	ssi_private->slots = slots;
+
 	return 0;
 }
 
@@ -1191,7 +1182,6 @@ static const struct snd_soc_dai_ops fsl_ssi_dai_ops = {
 	.hw_params	= fsl_ssi_hw_params,
 	.hw_free	= fsl_ssi_hw_free,
 	.set_fmt	= fsl_ssi_set_dai_fmt,
-	.set_sysclk	= fsl_ssi_set_dai_sysclk,
 	.set_tdm_slot	= fsl_ssi_set_dai_tdm_slot,
 	.trigger	= fsl_ssi_trigger,
 };
-- 
2.7.4

[toc] | [next] | [standalone]


#1728606 — Re: [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot number

FromNicolin Chen <nicoleotsuka@gmail.com>
Date2017-09-08 07:50 +0200
SubjectRe: [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot number
Message-ID<unkkV-2ve-5@gated-at.bofh.it>
In reply to#1728603
On Thu, Sep 07, 2017 at 10:23:43PM -0700, Nicolin Chen wrote:
> The set_sysclk() now is used to override the output bit clock rate.
> But this is not a common way to implement a set_dai_sysclk(). And
> this creates a problem when a general machine driver (simple-card
> for example) tries to do set_dai_sysclk() by passing an input clock
> rate for the baud clock instead of setting the bit clock rate as
> fsl_ssi driver expected.
> 
> So this patch solves this problem by firstly removing set_sysclk()
> since the hw_params() can calculate the bit clock rate. Secondly,
> in order not to break those TDM use cases which previously might
> have been using set_sysclk() to override the bit clock rate, this
> patch changes the driver to override it based on the slot number.
> 
> The patch also removes an obsolete comment of the dir parameter.
> 
> Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>

Forgot to mention, I think that it's better to wait for a couple of
Tested-by from those who use the TDM mode of SSI before applying it.

Thanks
Nicolin

[toc] | [prev] | [next] | [standalone]


#1728624 — Re: [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot number

FromArnaud Mouiche <arnaud.mouiche@invoxia.com>
Date2017-09-08 08:20 +0200
SubjectRe: [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot number
Message-ID<unkNZ-2TR-9@gated-at.bofh.it>
In reply to#1728606
On 08/09/2017 07:42, Nicolin Chen wrote:
> On Thu, Sep 07, 2017 at 10:23:43PM -0700, Nicolin Chen wrote:
>> The set_sysclk() now is used to override the output bit clock rate.
>> But this is not a common way to implement a set_dai_sysclk(). And
>> this creates a problem when a general machine driver (simple-card
>> for example) tries to do set_dai_sysclk() by passing an input clock
>> rate for the baud clock instead of setting the bit clock rate as
>> fsl_ssi driver expected.
>>
>> So this patch solves this problem by firstly removing set_sysclk()
>> since the hw_params() can calculate the bit clock rate. Secondly,
>> in order not to break those TDM use cases which previously might
>> have been using set_sysclk() to override the bit clock rate, this
>> patch changes the driver to override it based on the slot number.
>>
>> The patch also removes an obsolete comment of the dir parameter.
>>
>> Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
> Forgot to mention, I think that it's better to wait for a couple of
> Tested-by from those who use the TDM mode of SSI before applying it.
I can check next monday or tuesday.
Arnaud
> Thanks
> Nicolin

[toc] | [prev] | [next] | [standalone]


#1728695 — Re: [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot number

FromŁukasz Majewski <lukma@denx.de>
Date2017-09-08 10:50 +0200
SubjectRe: [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot number
Message-ID<unn97-4mN-15@gated-at.bofh.it>
In reply to#1728606
Hi Nicolin,

> On Thu, Sep 07, 2017 at 10:23:43PM -0700, Nicolin Chen wrote:
>> The set_sysclk() now is used to override the output bit clock rate.
>> But this is not a common way to implement a set_dai_sysclk(). And
>> this creates a problem when a general machine driver (simple-card
>> for example) tries to do set_dai_sysclk() by passing an input clock
>> rate for the baud clock instead of setting the bit clock rate as
>> fsl_ssi driver expected.
>>
>> So this patch solves this problem by firstly removing set_sysclk()
>> since the hw_params() can calculate the bit clock rate. Secondly,
>> in order not to break those TDM use cases which previously might
>> have been using set_sysclk() to override the bit clock rate, this
>> patch changes the driver to override it based on the slot number.
>>
>> The patch also removes an obsolete comment of the dir parameter.
>>
>> Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
> 
> Forgot to mention, I think that it's better to wait for a couple of
> Tested-by from those who use the TDM mode of SSI before applying it.

Although, I'm not the PCM user, I've tested your patch and it works :-)

Tested-by: Łukasz Majewski <lukma@denx.de>

Test HW: imx6q + tfa9879 codec

> 
> Thanks
> Nicolin
> 


-- 
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web