All of lore.kernel.org
 help / color / mirror / Atom feed
* [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
* [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
* [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-14  5:44 [PATCH] ASoC: nau8825: automatic BCLK and LRC divde in master mode John Hsu
2017-02-14 11:09 ` Mark Brown
2017-02-16  2:08   ` John Hsu
2017-02-16 12:13     ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2017-02-17  1:55 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
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.