diff mbox

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

Message ID 1487296533-20893-1-git-send-email-KCHSU0@nuvoton.com (mailing list archive)
State New, archived
Headers show

Commit Message

AS50 KCHSU0 Feb. 17, 2017, 1:55 a.m. UTC
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(-)

-- 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.

Comments

Mark Brown Feb. 17, 2017, 10:40 a.m. UTC | #1
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...
Mark Brown Feb. 17, 2017, 10:43 a.m. UTC | #2
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?
AS50 KCHSU0 Feb. 20, 2017, 2:32 a.m. UTC | #3
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.
Mark Brown Feb. 20, 2017, 6:26 p.m. UTC | #4
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.
AS50 KCHSU0 Feb. 21, 2017, 2:17 a.m. UTC | #5
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.
diff mbox

Patch

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;