All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
@ 2017-02-17  1:55 John Hsu
  2017-02-17 10:40 ` Mark Brown
  0 siblings, 1 reply; 14+ messages in thread
From: John Hsu @ 2017-02-17  1:55 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, anatol.pomozov, YHCHuang, WTLI, John Hsu, lgirdwood,
	benzh, CTLIN0, mhkuo, yong.zhi

configurable LRC and BCLK divide. The driver
will make configurations of LRC and BCLK automatically according to
BCLK and FS information in master mode.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
---
 sound/soc/codecs/nau8825.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index 4576f98..97fbeba 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -1231,7 +1231,7 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream,
 {
        struct snd_soc_codec *codec = dai->codec;
        struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec);
-       unsigned int val_len = 0, osr;
+       unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div;

        nau8825_sema_acquire(nau8825, 3 * HZ);

@@ -1261,6 +1261,24 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream,
                        osr_adc_sel[osr].clk_src << NAU8825_CLK_ADC_SRC_SFT);
        }

+       /* make BCLK and LRC divde configuration if the codec as master. */
+       regmap_read(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, &ctrl_val);
+       if (ctrl_val & NAU8825_I2S_MS_MASTER) {
+               /* get the bclk and fs ratio */
+               bclk_fs = snd_soc_params_to_bclk(params) / params_rate(params);
+               if (bclk_fs <= 32)
+                       bclk_div = 2;
+               else if (bclk_fs <= 64)
+                       bclk_div = 1;
+               else if (bclk_fs <= 128)
+                       bclk_div = 0;
+               else
+                       return -EINVAL;
+               regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
+                       NAU8825_I2S_LRC_DIV_MASK | NAU8825_I2S_BLK_DIV_MASK,
+                       ((bclk_div + 1) << NAU8825_I2S_LRC_DIV_SFT) | bclk_div);
+       }
+
        switch (params_width(params)) {
        case 16:
                val_len |= NAU8825_I2S_DL_16;
-- 2.6.4 .


===========================================================================================
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

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

* Re: [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
  2017-02-17  1:55 [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode John Hsu
@ 2017-02-17 10:40 ` Mark Brown
  2017-02-17 10:43   ` Mark Brown
  0 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2017-02-17 10:40 UTC (permalink / raw)
  To: John Hsu
  Cc: alsa-devel, anatol.pomozov, YHCHuang, WTLI, lgirdwood, benzh,
	CTLIN0, mhkuo, yong.zhi


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

On Fri, Feb 17, 2017 at 09:55:33AM +0800, John Hsu wrote:
> configurable LRC and BCLK divide. The driver
> will make configurations of LRC and BCLK automatically according to
> BCLK and FS information in master mode.

> -       unsigned int val_len = 0, osr;
> +       unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div;

This is still broken, the above has tabs replaced by spaces.  I think
I'll try to fix up by hand but it's going to be fiddly and that's a one
time thing...

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

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



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

* Re: [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
  2017-02-17 10:40 ` Mark Brown
@ 2017-02-17 10:43   ` Mark Brown
  2017-02-20  2:32     ` John Hsu
  0 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2017-02-17 10:43 UTC (permalink / raw)
  To: John Hsu
  Cc: alsa-devel, anatol.pomozov, YHCHuang, WTLI, lgirdwood, benzh,
	CTLIN0, mhkuo, yong.zhi


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

On Fri, Feb 17, 2017 at 10:40:47AM +0000, Mark Brown wrote:

> This is still broken, the above has tabs replaced by spaces.  I think
> I'll try to fix up by hand but it's going to be fiddly and that's a one
> time thing...

OK, that worked - it's definitely a tab/space problem.  Please
investigate this and try to get it fixed though, I'm not doing that for
every patch you send.  It may be something to do with what happens when
it leaves your company mail system and looks fine internally?

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

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



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

* Re: [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
  2017-02-17 10:43   ` Mark Brown
@ 2017-02-20  2:32     ` John Hsu
  2017-02-20 18:26       ` Mark Brown
  0 siblings, 1 reply; 14+ messages in thread
From: John Hsu @ 2017-02-20  2:32 UTC (permalink / raw)
  To: Mark Brown; +Cc: AP MS30 Linux ALSA

Hi,
On 2/17/2017 6:43 PM, Mark Brown wrote:
> On Fri, Feb 17, 2017 at 10:40:47AM +0000, Mark Brown wrote:
>
>> This is still broken, the above has tabs replaced by spaces.  I think
>> I'll try to fix up by hand but it's going to be fiddly and that's a one
>> time thing...
>
> OK, that worked - it's definitely a tab/space problem.  Please
> investigate this and try to get it fixed though, I'm not doing that for
> every patch you send.  It may be something to do with what happens when
> it leaves your company mail system and looks fine internally?

Thank you very much for help. I'll investigate what's the problem.
May I ask you more information? I need to know how to produce
the tab/space conversion issue. Do you save the patch mail
to text file with patch sub file name? Then type the "git am <"
command to apply the patch. I can't reproduce the issue in my
ubuntu linux with the patch mail sent by me.


===========================================================================================
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

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

* Re: [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
  2017-02-20  2:32     ` John Hsu
@ 2017-02-20 18:26       ` Mark Brown
  2017-02-21  2:17         ` John Hsu
  0 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2017-02-20 18:26 UTC (permalink / raw)
  To: John Hsu; +Cc: AP MS30 Linux ALSA


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

On Mon, Feb 20, 2017 at 10:32:18AM +0800, John Hsu wrote:

> Thank you very much for help. I'll investigate what's the problem.
> May I ask you more information? I need to know how to produce
> the tab/space conversion issue. Do you save the patch mail
> to text file with patch sub file name? Then type the "git am <"
> command to apply the patch. I can't reproduce the issue in my
> ubuntu linux with the patch mail sent by me.

I save to a mailbox then use git am --signoff on the mailbox.  I can see
the problem in my mail client directly as well, for example by editing
or replying to your e-mail.  Perhaps check a copy that's been through
the mailing list or sent to an external account rather than just one
sent locally?  It might be getting changed when it goes to a different
mail server.

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

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



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

* Re: [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
  2017-02-20 18:26       ` Mark Brown
@ 2017-02-21  2:17         ` John Hsu
  0 siblings, 0 replies; 14+ messages in thread
From: John Hsu @ 2017-02-21  2:17 UTC (permalink / raw)
  To: Mark Brown; +Cc: AP MS30 Linux ALSA

Hi,
On 2/21/2017 2:26 AM, Mark Brown wrote:
> On Mon, Feb 20, 2017 at 10:32:18AM +0800, John Hsu wrote:
>
>> Thank you very much for help. I'll investigate what's the problem.
>> May I ask you more information? I need to know how to produce
>> the tab/space conversion issue. Do you save the patch mail
>> to text file with patch sub file name? Then type the "git am <"
>> command to apply the patch. I can't reproduce the issue in my
>> ubuntu linux with the patch mail sent by me.
>
> I save to a mailbox then use git am --signoff on the mailbox.  I can see
> the problem in my mail client directly as well, for example by editing
> or replying to your e-mail.  Perhaps check a copy that's been through
> the mailing list or sent to an external account rather than just one
> sent locally?  It might be getting changed when it goes to a different
> mail server.

I get it. Thank you very much for the information.


===========================================================================================
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

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

* Re: [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
  2017-02-16  2:08   ` John Hsu
@ 2017-02-16 12:13     ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2017-02-16 12:13 UTC (permalink / raw)
  To: John Hsu
  Cc: AP MS30 Linux ALSA, anatol.pomozov, AC30 YHChuang, AC30 WTLi,
	lgirdwood, benzh, AC30 CTLin0, MS40 MHKuo, yong.zhi


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

On Thu, Feb 16, 2017 at 10:08:38AM +0800, John Hsu wrote:
> On 2/14/2017 7:09 PM, Mark Brown wrote:

> > This patch *still* does not apply.  Please, try sending to yourself and
> > applying with git am before you resend to me.  Check that the patch is
> > not being corrupted when you send it (things like space/tab conversion
> > for example).

> I have resent the patch to myself. And copy the mail content to a new
> patch. Then try the command as follows, and it seems work fine.
> git am --signoff < ASoC-nau8825-auto-BCLK-and-LRC-divide.patch

I looked again, you've got at least space/tab conversion problems in
there in the copy that ended up in my mailbox.  Perhaps there was some
temporary problem in the mail system your company uses, can you try
resending to me and see if it's sorted?

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

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



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

* Re: [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
  2017-02-14 11:09 ` Mark Brown
@ 2017-02-16  2:08   ` John Hsu
  2017-02-16 12:13     ` Mark Brown
  0 siblings, 1 reply; 14+ messages in thread
From: John Hsu @ 2017-02-16  2:08 UTC (permalink / raw)
  To: Mark Brown
  Cc: AP MS30 Linux ALSA, anatol.pomozov, AC30 YHChuang, AC30 WTLi,
	lgirdwood, benzh, AC30 CTLin0, MS40 MHKuo, yong.zhi

Hi,
On 2/14/2017 7:09 PM, Mark Brown wrote:
> On Tue, Feb 14, 2017 at 01:44:33PM +0800, John Hsu wrote:
>> Provide the automatic configurable LRC and BCLK divide. The driver
>> will make configurations of LRC and BCLK automatically according to
>> BCLK and FS information in master mode.
>
> This patch *still* does not apply.  Please, try sending to yourself and
> applying with git am before you resend to me.  Check that the patch is
> not being corrupted when you send it (things like space/tab conversion
> for example).

I have resent the patch to myself. And copy the mail content to a new
patch. Then try the command as follows, and it seems work fine.
git am --signoff < ASoC-nau8825-auto-BCLK-and-LRC-divide.patch

Here are the git logs in my site.

commit ce7f61934872c0bc701d93de2db39260b44a8ebd
Author: John Hsu <KCHSU0@nuvoton.com>
Date:   Wed Feb 15 17:13:43 2017 +0800

     ASoC: nau8825: automatic BCLK and LRC divde in master mode

     Provide the automatic configurable LRC and BCLK divide. The driver
     will make configurations of LRC and BCLK automatically according to
     BCLK and FS information in master mode.

     Signed-off-by: John Hsu <KCHSU0@nuvoton.com>

commit 71d7b89701f4e2bee4710bd229e254156006f69b
Merge: 92dfbd1 af4b654 66ead50
Author: Mark Brown <broonie@kernel.org>
Date:   Thu Feb 9 23:48:22 2017 +0000

     Merge remote-tracking branches 'asoc/topic/wm8753' and
'asoc/topic/zte' into asoc-next

commit 92dfbd159676290c359f94ff0e5637eb00d4b170




===========================================================================================
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

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

* Re: [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
  2017-02-14  5:44 John Hsu
@ 2017-02-14 11:09 ` Mark Brown
  2017-02-16  2:08   ` John Hsu
  0 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2017-02-14 11:09 UTC (permalink / raw)
  To: John Hsu
  Cc: alsa-devel, anatol.pomozov, YHCHuang, WTLI, lgirdwood, benzh,
	CTLIN0, mhkuo, yong.zhi


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

On Tue, Feb 14, 2017 at 01:44:33PM +0800, John Hsu wrote:
> Provide the automatic configurable LRC and BCLK divide. The driver
> will make configurations of LRC and BCLK automatically according to
> BCLK and FS information in master mode.

This patch *still* does not apply.  Please, try sending to yourself and
applying with git am before you resend to me.  Check that the patch is
not being corrupted when you send it (things like space/tab conversion
for example).

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

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



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

* [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
@ 2017-02-14  5:44 John Hsu
  2017-02-14 11:09 ` Mark Brown
  0 siblings, 1 reply; 14+ messages in thread
From: John Hsu @ 2017-02-14  5:44 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, anatol.pomozov, YHCHuang, WTLI, John Hsu, lgirdwood,
	benzh, CTLIN0, mhkuo, yong.zhi

Provide the automatic configurable LRC and BCLK divide. The driver
will make configurations of LRC and BCLK automatically according to
BCLK and FS information in master mode.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
---
 sound/soc/codecs/nau8825.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index 4576f98..97fbeba 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -1231,7 +1231,7 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream,
 {
        struct snd_soc_codec *codec = dai->codec;
        struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec);
-       unsigned int val_len = 0, osr;
+       unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div;

        nau8825_sema_acquire(nau8825, 3 * HZ);

@@ -1261,6 +1261,24 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream,
                        osr_adc_sel[osr].clk_src << NAU8825_CLK_ADC_SRC_SFT);
        }

+       /* make BCLK and LRC divde configuration if the codec as master. */
+       regmap_read(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, &ctrl_val);
+       if (ctrl_val & NAU8825_I2S_MS_MASTER) {
+               /* get the bclk and fs ratio */
+               bclk_fs = snd_soc_params_to_bclk(params) / params_rate(params);
+               if (bclk_fs <= 32)
+                       bclk_div = 2;
+               else if (bclk_fs <= 64)
+                       bclk_div = 1;
+               else if (bclk_fs <= 128)
+                       bclk_div = 0;
+               else
+                       return -EINVAL;
+               regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
+                       NAU8825_I2S_LRC_DIV_MASK | NAU8825_I2S_BLK_DIV_MASK,
+                       ((bclk_div + 1) << NAU8825_I2S_LRC_DIV_SFT) | bclk_div);
+       }
+
        switch (params_width(params)) {
        case 16:
                val_len |= NAU8825_I2S_DL_16;
--
2.6.4



===========================================================================================
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

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

* Re: [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
  2017-02-10  1:11   ` John Hsu
@ 2017-02-10 12:05     ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2017-02-10 12:05 UTC (permalink / raw)
  To: John Hsu
  Cc: AP MS30 Linux ALSA, anatol.pomozov, AC30 YHChuang, AC30 WTLi,
	lgirdwood, benzh, mac.chiang, AC30 CTLin0, MS40 MHKuo, yong.zhi


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

On Fri, Feb 10, 2017 at 09:11:56AM +0800, John Hsu wrote:

> There are three branches about nau8825 driver as follows.
> origin/fix/nau8825
> origin/for-next
> origin/topic/nau8825
> Which branch do I make patch based on? Thank you.

Whatever it needs to be based on, or Linus' tree if nothing else.  The
topic/nau8825 branch is currently empty and I don't have a fix/nau8825
branch right now...  if there are things in my for-next that's usually
fine but it doesn't apply there either.

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

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



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

* Re: [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
  2017-02-09 16:45 ` Mark Brown
@ 2017-02-10  1:11   ` John Hsu
  2017-02-10 12:05     ` Mark Brown
  0 siblings, 1 reply; 14+ messages in thread
From: John Hsu @ 2017-02-10  1:11 UTC (permalink / raw)
  To: Mark Brown
  Cc: AP MS30 Linux ALSA, anatol.pomozov, AC30 YHChuang, AC30 WTLi,
	lgirdwood, benzh, mac.chiang, AC30 CTLin0, MS40 MHKuo, yong.zhi

Hi,
On 2/10/2017 12:45 AM, Mark Brown wrote:
> On Thu, Feb 09, 2017 at 03:30:11PM +0800, John Hsu wrote:
>> Provide the automatic configurable LRC and BCLK divide. The driver
>> will make configurations of LRC and BCLK automatically according to
>> BCLK and FS information in master mode.
>
> This doesn't apply against current code, please check and resend.

There are three branches about nau8825 driver as follows.
origin/fix/nau8825
origin/for-next
origin/topic/nau8825
Which branch do I make patch based on? Thank you.


===========================================================================================
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

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

* Re: [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
  2017-02-09  7:30 John Hsu
@ 2017-02-09 16:45 ` Mark Brown
  2017-02-10  1:11   ` John Hsu
  0 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2017-02-09 16:45 UTC (permalink / raw)
  To: John Hsu
  Cc: alsa-devel, anatol.pomozov, YHCHuang, WTLI, lgirdwood, benzh,
	mac.chiang, CTLIN0, mhkuo, yong.zhi


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

On Thu, Feb 09, 2017 at 03:30:11PM +0800, John Hsu wrote:
> Provide the automatic configurable LRC and BCLK divide. The driver
> will make configurations of LRC and BCLK automatically according to
> BCLK and FS information in master mode.

This doesn't apply against current code, please check and resend.

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

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



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

* [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode
@ 2017-02-09  7:30 John Hsu
  2017-02-09 16:45 ` Mark Brown
  0 siblings, 1 reply; 14+ messages in thread
From: John Hsu @ 2017-02-09  7:30 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, anatol.pomozov, YHCHuang, WTLI, John Hsu, lgirdwood,
	benzh, mac.chiang, CTLIN0, mhkuo, yong.zhi

Provide the automatic configurable LRC and BCLK divide. The driver
will make configurations of LRC and BCLK automatically according to
BCLK and FS information in master mode.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
---
 sound/soc/codecs/nau8825.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index 4576f98..97fbeba 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -1231,7 +1231,7 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream,
 {
        struct snd_soc_codec *codec = dai->codec;
        struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec);
-       unsigned int val_len = 0, osr;
+       unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div;

        nau8825_sema_acquire(nau8825, 3 * HZ);

@@ -1261,6 +1261,24 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream,
                        osr_adc_sel[osr].clk_src << NAU8825_CLK_ADC_SRC_SFT);
        }

+       /* make BCLK and LRC divde configuration if the codec as master. */
+       regmap_read(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, &ctrl_val);
+       if (ctrl_val & NAU8825_I2S_MS_MASTER) {
+               /* get the bclk and fs ratio */
+               bclk_fs = snd_soc_params_to_bclk(params) / params_rate(params);
+               if (bclk_fs <= 32)
+                       bclk_div = 2;
+               else if (bclk_fs <= 64)
+                       bclk_div = 1;
+               else if (bclk_fs <= 128)
+                       bclk_div = 0;
+               else
+                       return -EINVAL;
+               regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
+                       NAU8825_I2S_LRC_DIV_MASK | NAU8825_I2S_BLK_DIV_MASK,
+                       ((bclk_div + 1) << NAU8825_I2S_LRC_DIV_SFT) | bclk_div);
+       }
+
        switch (params_width(params)) {
        case 16:
                val_len |= NAU8825_I2S_DL_16;
--
2.6.4



===========================================================================================
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

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

end of thread, other threads:[~2017-02-21  2:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-17  1:55 [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode John Hsu
2017-02-17 10:40 ` Mark Brown
2017-02-17 10:43   ` Mark Brown
2017-02-20  2:32     ` John Hsu
2017-02-20 18:26       ` Mark Brown
2017-02-21  2:17         ` John Hsu
  -- strict thread matches above, loose matches on Subject: below --
2017-02-14  5:44 John Hsu
2017-02-14 11:09 ` Mark Brown
2017-02-16  2:08   ` John Hsu
2017-02-16 12:13     ` Mark Brown
2017-02-09  7:30 John Hsu
2017-02-09 16:45 ` Mark Brown
2017-02-10  1:11   ` John Hsu
2017-02-10 12:05     ` Mark Brown

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.