All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: nau8825: correct the function name of register
@ 2016-12-20  8:47 John Hsu
  2016-12-20  8:47 ` [PATCH 2/2] ASoC: nau8825: provide clock divide for codec mater mode John Hsu
  2016-12-31 19:18 ` Applied "ASoC: nau8825: correct the function name of register" to the asoc tree Mark Brown
  0 siblings, 2 replies; 7+ messages in thread
From: John Hsu @ 2016-12-20  8:47 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, anatol.pomozov, YHCHuang, WTLI, John Hsu, lgirdwood,
	benzh, CTLIN0, mhkuo, yong.zhi

Change to correct name of the register function.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
---
 sound/soc/codecs/nau8825.c | 6 +++---
 sound/soc/codecs/nau8825.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index e4fb017..9c98d35 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -561,9 +561,9 @@ static void nau8825_xtalk_prepare(struct nau8825 *nau8825)
 	nau8825_xtalk_backup(nau8825);
 	/* Config IIS as master to output signal by codec */
 	regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
-		NAU8825_I2S_MS_MASK | NAU8825_I2S_DRV_MASK |
+		NAU8825_I2S_MS_MASK | NAU8825_I2S_LRC_DIV_MASK |
 		NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_MASTER |
-		(0x2 << NAU8825_I2S_DRV_SFT) | 0x1);
+		(0x2 << NAU8825_I2S_LRC_DIV_SFT) | 0x1);
 	/* Ramp up headphone volume to 0dB to get better performance and
 	 * avoid pop noise in headphone.
 	 */
@@ -657,7 +657,7 @@ static void nau8825_xtalk_clean(struct nau8825 *nau8825)
 		NAU8825_IRQ_RMS_EN, NAU8825_IRQ_RMS_EN);
 	/* Recover default value for IIS */
 	regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
-		NAU8825_I2S_MS_MASK | NAU8825_I2S_DRV_MASK |
+		NAU8825_I2S_MS_MASK | NAU8825_I2S_LRC_DIV_MASK |
 		NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_SLAVE);
 	/* Restore value of specific register for cross talk */
 	nau8825_xtalk_restore(nau8825);
diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h
index 5732ce1..4b390c4 100644
--- a/sound/soc/codecs/nau8825.h
+++ b/sound/soc/codecs/nau8825.h
@@ -248,8 +248,8 @@
 
 /* I2S_PCM_CTRL2 (0x1d) */
 #define NAU8825_I2S_TRISTATE	(1 << 15) /* 0 - normal mode, 1 - Hi-Z output */
-#define NAU8825_I2S_DRV_SFT	12
-#define NAU8825_I2S_DRV_MASK	(0x3 << NAU8825_I2S_DRV_SFT)
+#define NAU8825_I2S_LRC_DIV_SFT	12
+#define NAU8825_I2S_LRC_DIV_MASK	(0x3 << NAU8825_I2S_LRC_DIV_SFT)
 #define NAU8825_I2S_MS_SFT	3
 #define NAU8825_I2S_MS_MASK	(1 << NAU8825_I2S_MS_SFT)
 #define NAU8825_I2S_MS_MASTER	(1 << NAU8825_I2S_MS_SFT)
-- 
2.6.4

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

* [PATCH 2/2] ASoC: nau8825: provide clock divide for codec mater mode
  2016-12-20  8:47 [PATCH 1/2] ASoC: nau8825: correct the function name of register John Hsu
@ 2016-12-20  8:47 ` John Hsu
  2016-12-31 18:57   ` Mark Brown
  2016-12-31 19:18 ` Applied "ASoC: nau8825: correct the function name of register" to the asoc tree Mark Brown
  1 sibling, 1 reply; 7+ messages in thread
From: John Hsu @ 2016-12-20  8:47 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, anatol.pomozov, YHCHuang, WTLI, John Hsu, lgirdwood,
	benzh, CTLIN0, mhkuo, yong.zhi

Provide the LRC and BCLK divide. The clock divide needs configuration
properly when codec in master mode.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
---
 sound/soc/codecs/nau8825.c | 26 ++++++++++++++++++++++++++
 sound/soc/codecs/nau8825.h |  6 ++++++
 2 files changed, 32 insertions(+)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index 9c98d35..3c7a801 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -1421,9 +1421,35 @@ static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 	return 0;
 }
 
+static int nau8825_set_clkdiv(struct snd_soc_dai *codec_dai,
+	int div_id, int div)
+{
+	struct snd_soc_codec *codec = codec_dai->codec;
+	struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec);
+
+	switch (div_id) {
+	case NAU8825_BCLKDIV:
+		regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
+			NAU8825_I2S_BLK_DIV_MASK, div);
+		break;
+
+	case NAU8825_FSDIV:
+		regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
+			NAU8825_I2S_LRC_DIV_MASK,
+			div << NAU8825_I2S_LRC_DIV_SFT);
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static const struct snd_soc_dai_ops nau8825_dai_ops = {
 	.hw_params	= nau8825_hw_params,
 	.set_fmt	= nau8825_set_dai_fmt,
+	.set_clkdiv	= nau8825_set_clkdiv,
 };
 
 #define NAU8825_RATES	SNDRV_PCM_RATE_8000_192000
diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h
index 4b390c4..58b8554 100644
--- a/sound/soc/codecs/nau8825.h
+++ b/sound/soc/codecs/nau8825.h
@@ -425,6 +425,12 @@
 #define NAU8825_CHANRGE_PUMP_EN	(1 << 5)
 
 
+/* Programmable divide */
+enum {
+	NAU8825_BCLKDIV,
+	NAU8825_FSDIV,
+};
+
 /* System Clock Source */
 enum {
 	NAU8825_CLK_DIS = 0,
-- 
2.6.4

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

* Re: [PATCH 2/2] ASoC: nau8825: provide clock divide for codec mater mode
  2016-12-20  8:47 ` [PATCH 2/2] ASoC: nau8825: provide clock divide for codec mater mode John Hsu
@ 2016-12-31 18:57   ` Mark Brown
  2017-01-03  3:04     ` John Hsu
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2016-12-31 18:57 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: 480 bytes --]

On Tue, Dec 20, 2016 at 04:47:07PM +0800, John Hsu wrote:
> Provide the LRC and BCLK divide. The clock divide needs configuration
> properly when codec in master mode.

Why is the driver not able to configure these automatically, most
devices manage to do that OK?  Typically systems are fine with the
obvious divisions down from the root clock, the driver should at least
offer that as a default rather than requiring all machine drivers to
duplicate the divisor selection code.

[-- 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] 7+ messages in thread

* Applied "ASoC: nau8825: correct the function name of register" to the asoc tree
  2016-12-20  8:47 [PATCH 1/2] ASoC: nau8825: correct the function name of register John Hsu
  2016-12-20  8:47 ` [PATCH 2/2] ASoC: nau8825: provide clock divide for codec mater mode John Hsu
@ 2016-12-31 19:18 ` Mark Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Brown @ 2016-12-31 19:18 UTC (permalink / raw)
  To: John Hsu
  Cc: alsa-devel, anatol.pomozov, benzh, WTLI, lgirdwood, YHCHuang,
	broonie, CTLIN0, yong.zhi, mhkuo

The patch

   ASoC: nau8825: correct the function name of register

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From a33b56a6a824fa5cd89c74f85cbeb9af1dcef87e Mon Sep 17 00:00:00 2001
From: John Hsu <KCHSU0@nuvoton.com>
Date: Tue, 20 Dec 2016 16:47:06 +0800
Subject: [PATCH] ASoC: nau8825: correct the function name of register

Change to correct name of the register function.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/nau8825.c | 6 +++---
 sound/soc/codecs/nau8825.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index efe3a44658d5..abf77dd422f4 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -561,9 +561,9 @@ static void nau8825_xtalk_prepare(struct nau8825 *nau8825)
 	nau8825_xtalk_backup(nau8825);
 	/* Config IIS as master to output signal by codec */
 	regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
-		NAU8825_I2S_MS_MASK | NAU8825_I2S_DRV_MASK |
+		NAU8825_I2S_MS_MASK | NAU8825_I2S_LRC_DIV_MASK |
 		NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_MASTER |
-		(0x2 << NAU8825_I2S_DRV_SFT) | 0x1);
+		(0x2 << NAU8825_I2S_LRC_DIV_SFT) | 0x1);
 	/* Ramp up headphone volume to 0dB to get better performance and
 	 * avoid pop noise in headphone.
 	 */
@@ -657,7 +657,7 @@ static void nau8825_xtalk_clean(struct nau8825 *nau8825)
 		NAU8825_IRQ_RMS_EN, NAU8825_IRQ_RMS_EN);
 	/* Recover default value for IIS */
 	regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2,
-		NAU8825_I2S_MS_MASK | NAU8825_I2S_DRV_MASK |
+		NAU8825_I2S_MS_MASK | NAU8825_I2S_LRC_DIV_MASK |
 		NAU8825_I2S_BLK_DIV_MASK, NAU8825_I2S_MS_SLAVE);
 	/* Restore value of specific register for cross talk */
 	nau8825_xtalk_restore(nau8825);
diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h
index 5d1704e73241..b6b21b312854 100644
--- a/sound/soc/codecs/nau8825.h
+++ b/sound/soc/codecs/nau8825.h
@@ -247,8 +247,8 @@
 
 /* I2S_PCM_CTRL2 (0x1d) */
 #define NAU8825_I2S_TRISTATE	(1 << 15) /* 0 - normal mode, 1 - Hi-Z output */
-#define NAU8825_I2S_DRV_SFT	12
-#define NAU8825_I2S_DRV_MASK	(0x3 << NAU8825_I2S_DRV_SFT)
+#define NAU8825_I2S_LRC_DIV_SFT	12
+#define NAU8825_I2S_LRC_DIV_MASK	(0x3 << NAU8825_I2S_LRC_DIV_SFT)
 #define NAU8825_I2S_MS_SFT	3
 #define NAU8825_I2S_MS_MASK	(1 << NAU8825_I2S_MS_SFT)
 #define NAU8825_I2S_MS_MASTER	(1 << NAU8825_I2S_MS_SFT)
-- 
2.11.0

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

* Re: [PATCH 2/2] ASoC: nau8825: provide clock divide for codec mater mode
  2016-12-31 18:57   ` Mark Brown
@ 2017-01-03  3:04     ` John Hsu
  2017-01-09 11:42       ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: John Hsu @ 2017-01-03  3:04 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

On 1/1/2017 2:57 AM, Mark Brown wrote:
> On Tue, Dec 20, 2016 at 04:47:07PM +0800, John Hsu wrote:
>
>> Provide the LRC and BCLK divide. The clock divide needs configuration
>> properly when codec in master mode.
>>
>
> Why is the driver not able to configure these automatically, most
> devices manage to do that OK?  Typically systems are fine with the
> obvious divisions down from the root clock, the driver should at least
> offer that as a default rather than requiring all machine drivers to
> duplicate the divisor selection code.
>

The system clock of codec is always 256FS. Therefore, the driver can
make it automatically. If the codec is as master, the driver needs to
divide the system clock to output the BCLK and FS. But there are too
many combinations between BCLK and FS. The BCLK maybe is 32FS, 64FS,
128FS, etc. The driver needs machine information to do the division.
Thus, I think the best way is to make decision by machine driver.



===========================================================================================
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] 7+ messages in thread

* Re: [PATCH 2/2] ASoC: nau8825: provide clock divide for codec mater mode
  2017-01-03  3:04     ` John Hsu
@ 2017-01-09 11:42       ` Mark Brown
  2017-01-23  8:39         ` John Hsu
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2017-01-09 11:42 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: 1129 bytes --]

On Tue, Jan 03, 2017 at 11:04:50AM +0800, John Hsu wrote:
> On 1/1/2017 2:57 AM, Mark Brown wrote:

> > Why is the driver not able to configure these automatically, most
> > devices manage to do that OK?  Typically systems are fine with the
> > obvious divisions down from the root clock, the driver should at least
> > offer that as a default rather than requiring all machine drivers to
> > duplicate the divisor selection code.

> The system clock of codec is always 256FS. Therefore, the driver can
> make it automatically. If the codec is as master, the driver needs to
> divide the system clock to output the BCLK and FS. But there are too
> many combinations between BCLK and FS. The BCLK maybe is 32FS, 64FS,
> 128FS, etc. The driver needs machine information to do the division.
> Thus, I think the best way is to make decision by machine driver.

This all sounds totally standard - other drivers manage to provide a
default easily enough here.  You can determine a default BCLK by looking
at the number of channels and number of bits per sample to work out how
many BCLKs are going to be needed to clock that data out.

[-- 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] 7+ messages in thread

* Re: [PATCH 2/2] ASoC: nau8825: provide clock divide for codec mater mode
  2017-01-09 11:42       ` Mark Brown
@ 2017-01-23  8:39         ` John Hsu
  0 siblings, 0 replies; 7+ messages in thread
From: John Hsu @ 2017-01-23  8:39 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 1/9/2017 7:42 PM, Mark Brown wrote:
> On Tue, Jan 03, 2017 at 11:04:50AM +0800, John Hsu wrote:
>
>> On 1/1/2017 2:57 AM, Mark Brown wrote:
>>
>
>
>>> Why is the driver not able to configure these automatically, most
>>> devices manage to do that OK?  Typically systems are fine with the
>>> obvious divisions down from the root clock, the driver should at least
>>> offer that as a default rather than requiring all machine drivers to
>>> duplicate the divisor selection code.
>>>
>
>
>> The system clock of codec is always 256FS. Therefore, the driver can
>> make it automatically. If the codec is as master, the driver needs to
>> divide the system clock to output the BCLK and FS. But there are too
>> many combinations between BCLK and FS. The BCLK maybe is 32FS, 64FS,
>> 128FS, etc. The driver needs machine information to do the division.
>> Thus, I think the best way is to make decision by machine driver.
>>
>
> This all sounds totally standard - other drivers manage to provide a
> default easily enough here.  You can determine a default BCLK by looking
> at the number of channels and number of bits per sample to work out how
> many BCLKs are going to be needed to clock that data out.
>

I see. The driver should be able to handle it. I'll make another
patch to support the clock divide automatically.



===========================================================================================
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] 7+ messages in thread

end of thread, other threads:[~2017-01-23  8:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-20  8:47 [PATCH 1/2] ASoC: nau8825: correct the function name of register John Hsu
2016-12-20  8:47 ` [PATCH 2/2] ASoC: nau8825: provide clock divide for codec mater mode John Hsu
2016-12-31 18:57   ` Mark Brown
2017-01-03  3:04     ` John Hsu
2017-01-09 11:42       ` Mark Brown
2017-01-23  8:39         ` John Hsu
2016-12-31 19:18 ` Applied "ASoC: nau8825: correct the function name of register" to the asoc tree 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.