All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: sgtl5000: Allow the codec to work in slave mode
@ 2014-09-18 23:17 Fabio Estevam
  2014-09-23  1:54 ` Mark Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2014-09-18 23:17 UTC (permalink / raw)
  To: broonie
  Cc: nicoleotsuka, jean-michel.hautbois, alsa-devel, Fabio Estevam, shawn.guo

From: Fabio Estevam <fabio.estevam@freescale.com>

When configuring sgtl5000 to work in slave mode the following error is seen:

root@freescale /$ aplay dtmf_mono_16b_48000.wav 
[   11.406460] random: nonblocking pool is initialized
[   11.600461] sgtl5000 1-000a: PLL not supported in slave mode
[   11.609052] sgtl5000 1-000a: ASoC: can't set sgtl5000 hw params: -22
ALSA lib pcm_direct.c:980:(snd1_pcm_direct_initialize_slave) unable to install hw params
ALSA lib pcm_dmix.c:1030:(snd_pcm_dmix_open) unable to initialize slave
aplay: main:660: audio open error: Invalid argument

Do not error out when sgtl5000_set_clock() reaches the default path for slave 
mode.

While at it, fix a typo in the comment.

Tested on a imx53-qsb configured as ssi in master and sgtl5000 as slave.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 sound/soc/codecs/sgtl5000.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index a604a22..b641ed1 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -619,14 +619,10 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate)
 			SGTL5000_MCLK_FREQ_SHIFT;
 		break;
 	default:
-		/* if mclk not satisify the divider, use pll */
+		/* if mclk not satisfy the divider, use pll */
 		if (sgtl5000->master) {
 			clk_ctl |= SGTL5000_MCLK_FREQ_PLL <<
 				SGTL5000_MCLK_FREQ_SHIFT;
-		} else {
-			dev_err(codec->dev,
-				"PLL not supported in slave mode\n");
-			return -EINVAL;
 		}
 	}
 
-- 
1.9.1

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

* Re: [PATCH] ASoC: sgtl5000: Allow the codec to work in slave mode
  2014-09-18 23:17 [PATCH] ASoC: sgtl5000: Allow the codec to work in slave mode Fabio Estevam
@ 2014-09-23  1:54 ` Mark Brown
  2014-09-29 13:17   ` Fabio Estevam
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2014-09-23  1:54 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: nicoleotsuka, jean-michel.hautbois, alsa-devel, Fabio Estevam, shawn.guo


[-- Attachment #1.1: Type: text/plain, Size: 871 bytes --]

On Thu, Sep 18, 2014 at 08:17:25PM -0300, Fabio Estevam wrote:

>  	default:
> -		/* if mclk not satisify the divider, use pll */
> +		/* if mclk not satisfy the divider, use pll */
>  		if (sgtl5000->master) {
>  			clk_ctl |= SGTL5000_MCLK_FREQ_PLL <<
>  				SGTL5000_MCLK_FREQ_SHIFT;
> -		} else {
> -			dev_err(codec->dev,
> -				"PLL not supported in slave mode\n");
> -			return -EINVAL;
>  		}
>  	}

Are you sure that the configuration that results is valid?  Typically
the requirements for MCLK to other clock ratios are very similar for
master and slave modes, it's just that it tends to be a lot more obvious
when things go wrong in master mode since directly visible clocks tend
to go wrong as opposed to performance problems.  Are the dividers that
we can't get configuration for purely for generating BCLK/LRCLK in
master mode or are they for other things?

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH] ASoC: sgtl5000: Allow the codec to work in slave mode
  2014-09-23  1:54 ` Mark Brown
@ 2014-09-29 13:17   ` Fabio Estevam
  2014-09-30 19:29     ` Mark Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2014-09-29 13:17 UTC (permalink / raw)
  To: Mark Brown
  Cc: Nicolin Chen, Jean-Michel Hautbois, alsa-devel, Fabio Estevam, Shawn Guo

Hi Mark,

On Mon, Sep 22, 2014 at 10:54 PM, Mark Brown <broonie@kernel.org> wrote:
> On Thu, Sep 18, 2014 at 08:17:25PM -0300, Fabio Estevam wrote:
>
>>       default:
>> -             /* if mclk not satisify the divider, use pll */
>> +             /* if mclk not satisfy the divider, use pll */
>>               if (sgtl5000->master) {
>>                       clk_ctl |= SGTL5000_MCLK_FREQ_PLL <<
>>                               SGTL5000_MCLK_FREQ_SHIFT;
>> -             } else {
>> -                     dev_err(codec->dev,
>> -                             "PLL not supported in slave mode\n");
>> -                     return -EINVAL;
>>               }
>>       }
>
> Are you sure that the configuration that results is valid?  Typically
> the requirements for MCLK to other clock ratios are very similar for
> master and slave modes, it's just that it tends to be a lot more obvious
> when things go wrong in master mode since directly visible clocks tend
> to go wrong as opposed to performance problems.  Are the dividers that
> we can't get configuration for purely for generating BCLK/LRCLK in
> master mode or are they for other things?

Tested sgtl5000 slave mode with different sampling rates and it plays well.

Any particular register I should monitor?

Sorry, but I guess I did not understand your last question.

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

* Re: [PATCH] ASoC: sgtl5000: Allow the codec to work in slave mode
  2014-09-29 13:17   ` Fabio Estevam
@ 2014-09-30 19:29     ` Mark Brown
  2014-09-30 19:38       ` Michael Trimarchi
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2014-09-30 19:29 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Nicolin Chen, Jean-Michel Hautbois, alsa-devel, Fabio Estevam, Shawn Guo


[-- Attachment #1.1: Type: text/plain, Size: 1028 bytes --]

On Mon, Sep 29, 2014 at 10:17:57AM -0300, Fabio Estevam wrote:
> On Mon, Sep 22, 2014 at 10:54 PM, Mark Brown <broonie@kernel.org> wrote:

> > Are you sure that the configuration that results is valid?  Typically
> > the requirements for MCLK to other clock ratios are very similar for
> > master and slave modes, it's just that it tends to be a lot more obvious
> > when things go wrong in master mode since directly visible clocks tend
> > to go wrong as opposed to performance problems.  Are the dividers that
> > we can't get configuration for purely for generating BCLK/LRCLK in
> > master mode or are they for other things?

> Tested sgtl5000 slave mode with different sampling rates and it plays well.

> Any particular register I should monitor?

Did you just listen or did you measure the performance?

> Sorry, but I guess I did not understand your last question.

I'm really not sure how to simplify it...  clearly we're skipping some
configuration here, what does it do - is it purely for generating BCLK
and LRCLK?

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH] ASoC: sgtl5000: Allow the codec to work in slave mode
  2014-09-30 19:29     ` Mark Brown
@ 2014-09-30 19:38       ` Michael Trimarchi
  2014-10-01 18:27         ` Mark Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Trimarchi @ 2014-09-30 19:38 UTC (permalink / raw)
  To: Mark Brown
  Cc: Fabio Estevam, alsa-devel, Nicolin Chen, Jean-Michel Hautbois,
	Fabio Estevam, Shawn Guo

Hi Mark

On Tue, Sep 30, 2014 at 9:29 PM, Mark Brown <broonie@kernel.org> wrote:
> On Mon, Sep 29, 2014 at 10:17:57AM -0300, Fabio Estevam wrote:
>> On Mon, Sep 22, 2014 at 10:54 PM, Mark Brown <broonie@kernel.org> wrote:
>
>> > Are you sure that the configuration that results is valid?  Typically
>> > the requirements for MCLK to other clock ratios are very similar for
>> > master and slave modes, it's just that it tends to be a lot more obvious
>> > when things go wrong in master mode since directly visible clocks tend
>> > to go wrong as opposed to performance problems.  Are the dividers that
>> > we can't get configuration for purely for generating BCLK/LRCLK in
>> > master mode or are they for other things?
>
>> Tested sgtl5000 slave mode with different sampling rates and it plays well.
>
>> Any particular register I should monitor?
>
> Did you just listen or did you measure the performance?
>
>> Sorry, but I guess I did not understand your last question.
>
> I'm really not sure how to simplify it...  clearly we're skipping some
> configuration here, what does it do - is it purely for generating BCLK
> and LRCLK?

Are you talking about clock_in and sigma-delta? So no  the bclk and lrclk but
the clkin of the codec.

Michael

>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>



-- 
| Michael Nazzareno Trimarchi                     Amarula Solutions BV |
| COO  -  Founder                                      Cruquiuskade 47 |
| +31(0)851119172                                 Amsterdam 1018 AM NL |
|                  [`as] http://www.amarulasolutions.com               |

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

* Re: [PATCH] ASoC: sgtl5000: Allow the codec to work in slave mode
  2014-09-30 19:38       ` Michael Trimarchi
@ 2014-10-01 18:27         ` Mark Brown
  2014-10-01 18:44           ` Fabio Estevam
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2014-10-01 18:27 UTC (permalink / raw)
  To: Michael Trimarchi
  Cc: Fabio Estevam, alsa-devel, Nicolin Chen, Jean-Michel Hautbois,
	Fabio Estevam, Shawn Guo


[-- Attachment #1.1: Type: text/plain, Size: 941 bytes --]

On Tue, Sep 30, 2014 at 09:38:21PM +0200, Michael Trimarchi wrote:
> On Tue, Sep 30, 2014 at 9:29 PM, Mark Brown <broonie@kernel.org> wrote:

> >> Any particular register I should monitor?

> > Did you just listen or did you measure the performance?

> >> Sorry, but I guess I did not understand your last question.

> > I'm really not sure how to simplify it...  clearly we're skipping some
> > configuration here, what does it do - is it purely for generating BCLK
> > and LRCLK?

> Are you talking about clock_in and sigma-delta? So no  the bclk and lrclk but
> the clkin of the codec.

I'm sorry but I can't parse what you're saying terribly clearly - please
bear in mind that I don't know anything about this device, that's one of
the reasons I'm having to ask questions here.  If the configuration that
is being skipped is not about generating BCLK and LRCLK then it seems
like it's going to be wanted in slave mode as well as master.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH] ASoC: sgtl5000: Allow the codec to work in slave mode
  2014-10-01 18:27         ` Mark Brown
@ 2014-10-01 18:44           ` Fabio Estevam
  2014-10-02 17:58             ` Mark Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2014-10-01 18:44 UTC (permalink / raw)
  To: Mark Brown
  Cc: Fabio Estevam, alsa-devel, Nicolin Chen, Jean-Michel Hautbois,
	Michael Trimarchi, Shawn Guo

Hi Mark,

On Wed, Oct 1, 2014 at 3:27 PM, Mark Brown <broonie@kernel.org> wrote:
> On Tue, Sep 30, 2014 at 09:38:21PM +0200, Michael Trimarchi wrote:
>> On Tue, Sep 30, 2014 at 9:29 PM, Mark Brown <broonie@kernel.org> wrote:
>
>> >> Any particular register I should monitor?
>
>> > Did you just listen or did you measure the performance?
>
>> >> Sorry, but I guess I did not understand your last question.
>
>> > I'm really not sure how to simplify it...  clearly we're skipping some
>> > configuration here, what does it do - is it purely for generating BCLK
>> > and LRCLK?
>
>> Are you talking about clock_in and sigma-delta? So no  the bclk and lrclk but
>> the clkin of the codec.
>
> I'm sorry but I can't parse what you're saying terribly clearly - please
> bear in mind that I don't know anything about this device, that's one of
> the reasons I'm having to ask questions here.  If the configuration that
> is being skipped is not about generating BCLK and LRCLK then it seems
> like it's going to be wanted in slave mode as well as master.

This patch does not skip any configuration. It just remove the error
case for sgtl5000 in slave mode.

Not sure why the error case was there in the first place, as I think
sgtl5000 slave mode has never been tested before.

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

* Re: [PATCH] ASoC: sgtl5000: Allow the codec to work in slave mode
  2014-10-01 18:44           ` Fabio Estevam
@ 2014-10-02 17:58             ` Mark Brown
  2014-10-02 18:54               ` Fabio Estevam
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2014-10-02 17:58 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Fabio Estevam, alsa-devel, Nicolin Chen, Jean-Michel Hautbois,
	Michael Trimarchi, Shawn Guo


[-- Attachment #1.1: Type: text/plain, Size: 1032 bytes --]

On Wed, Oct 01, 2014 at 03:44:59PM -0300, Fabio Estevam wrote:
> On Wed, Oct 1, 2014 at 3:27 PM, Mark Brown <broonie@kernel.org> wrote:

> > I'm sorry but I can't parse what you're saying terribly clearly - please
> > bear in mind that I don't know anything about this device, that's one of
> > the reasons I'm having to ask questions here.  If the configuration that
> > is being skipped is not about generating BCLK and LRCLK then it seems
> > like it's going to be wanted in slave mode as well as master.

> This patch does not skip any configuration. It just remove the error
> case for sgtl5000 in slave mode.

> Not sure why the error case was there in the first place, as I think
> sgtl5000 slave mode has never been tested before.

The comment says "if mclk not satisfy the divider, use pll" and then
does in fact skip configuring the PLL (or at least a register change
which looks like it does that).  Looking at the code it seems like
there's a requirement for MCLK to be one of the standard multiples of
the sample rate.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH] ASoC: sgtl5000: Allow the codec to work in slave mode
  2014-10-02 17:58             ` Mark Brown
@ 2014-10-02 18:54               ` Fabio Estevam
  0 siblings, 0 replies; 9+ messages in thread
From: Fabio Estevam @ 2014-10-02 18:54 UTC (permalink / raw)
  To: Mark Brown
  Cc: Fabio Estevam, alsa-devel, Nicolin Chen, Jean-Michel Hautbois,
	Michael Trimarchi, Shawn Guo

On Thu, Oct 2, 2014 at 2:58 PM, Mark Brown <broonie@kernel.org> wrote:

> The comment says "if mclk not satisfy the divider, use pll" and then
> does in fact skip configuring the PLL (or at least a register change
> which looks like it does that).  Looking at the code it seems like
> there's a requirement for MCLK to be one of the standard multiples of
> the sample rate.

Ok, got it now.

For sgtl5000 to operate in slave mode it can only work in "Synchronous
SYS_MCLK input" mode.

In this mode only the following rates can be supported: 256*Fs, 384*Fs, 512*Fs.

On the board I was testing this I was getting a ratio of 233, so the
original code returned -EINVAL.

So the current behaviour looks correct.

We could improve the 'PLL not supported in slave mode' error message
though putting the actual ratio we got.

Will send a patch for this shortly.

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

end of thread, other threads:[~2014-10-02 18:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-18 23:17 [PATCH] ASoC: sgtl5000: Allow the codec to work in slave mode Fabio Estevam
2014-09-23  1:54 ` Mark Brown
2014-09-29 13:17   ` Fabio Estevam
2014-09-30 19:29     ` Mark Brown
2014-09-30 19:38       ` Michael Trimarchi
2014-10-01 18:27         ` Mark Brown
2014-10-01 18:44           ` Fabio Estevam
2014-10-02 17:58             ` Mark Brown
2014-10-02 18:54               ` Fabio Estevam

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.