Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoc: simple card: extend for MCLK support
@ 2015-06-05  8:19 Arnaud Pouliquen
  2015-06-05  8:19 ` [PATCH 1/2] ASoC: simple card: Add mclk-fs property in dai-link Arnaud Pouliquen
  2015-06-05  8:19 ` [PATCH 2/2] ASoC: simple card: set cpu-dai sysclk with mclk-fs Arnaud Pouliquen
  0 siblings, 2 replies; 6+ messages in thread
From: Arnaud Pouliquen @ 2015-06-05  8:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, arnaud.pouliquen, lgirdwood

Patches propose to extend the management of the mclk-fs ratio.
This extension allows to support following card constraints:
- mclk is generated by cpu_dai, depending on frame rate.
  cpu_dai needs to be informed on the ratio supported by codec.	
- Each codec needs a specific ratio. 
  In this case mclk-fs needs to be defined for the dai_link.

Arnaud Pouliquen (2):
  ASoC: simple card: Add mclk-fs property in dai-link
  ASoC: simple card: set cpu-dai sysclk with mclk-fs

 .../devicetree/bindings/sound/simple-card.txt      |  6 ++++-
 sound/soc/generic/simple-card.c                    | 27 +++++++++++++++++++---
 2 files changed, 29 insertions(+), 4 deletions(-)

-- 
1.9.1

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

* [PATCH 1/2] ASoC: simple card: Add mclk-fs property in dai-link
  2015-06-05  8:19 [PATCH 0/2] ASoc: simple card: extend for MCLK support Arnaud Pouliquen
@ 2015-06-05  8:19 ` Arnaud Pouliquen
  2015-06-12 11:36   ` Mark Brown
  2015-06-05  8:19 ` [PATCH 2/2] ASoC: simple card: set cpu-dai sysclk with mclk-fs Arnaud Pouliquen
  1 sibling, 1 reply; 6+ messages in thread
From: Arnaud Pouliquen @ 2015-06-05  8:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, arnaud.pouliquen, lgirdwood

Add mclk-fs ratio property per dai-link sub node. This will
allow to manage several codecs with different ratio.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 .../devicetree/bindings/sound/simple-card.txt          |  6 +++++-
 sound/soc/generic/simple-card.c                        | 18 +++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index 73bf314..cf3979e 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -16,7 +16,8 @@ Optional properties:
 					  connection's sink, the second being the connection's
 					  source.
 - simple-audio-card,mclk-fs             : Multiplication factor between stream rate and codec
-  					  mclk.
+					  mclk. When defined, mclk-fs property defined in
+					  dai-link sub nodes are ignored.
 - simple-audio-card,hp-det-gpio		: Reference to GPIO that signals when
 					  headphones are attached.
 - simple-audio-card,mic-det-gpio	: Reference to GPIO that signals when
@@ -55,6 +56,9 @@ Optional dai-link subnode properties:
 					  dai-link uses bit clock inversion.
 - frame-inversion			: bool property. Add this if the
 					  dai-link uses frame clock inversion.
+- mclk-fs             			: Multiplication factor between stream
+					  rate and codec mclk, applied only for
+					  the dai-link.
 
 For backward compatibility the frame-master and bitclock-master
 properties can be used as booleans in codec subnode to indicate if the
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index c87e585..d555493 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -26,6 +26,7 @@ struct simple_card_data {
 	struct simple_dai_props {
 		struct asoc_simple_dai cpu_dai;
 		struct asoc_simple_dai codec_dai;
+		unsigned int mclk_fs;
 	} *dai_props;
 	unsigned int mclk_fs;
 	int gpio_hp_det;
@@ -76,11 +77,18 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
-	unsigned int mclk;
+	struct simple_dai_props *dai_props =
+		&priv->dai_props[rtd - rtd->card->rtd];
+	unsigned int mclk, mclk_fs = 0;
 	int ret = 0;
 
-	if (priv->mclk_fs) {
-		mclk = params_rate(params) * priv->mclk_fs;
+	if (priv->mclk_fs)
+		mclk_fs = priv->mclk_fs;
+	else if (dai_props->mclk_fs)
+		mclk_fs = dai_props->mclk_fs;
+
+	if (mclk_fs) {
+		mclk = params_rate(params) * mclk_fs;
 		ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
 					     SND_SOC_CLOCK_IN);
 	}
@@ -313,6 +321,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
 	char prop[128];
 	char *prefix = "";
 	int ret, cpu_args;
+	u32 val;
 
 	/* For single DAI link & old style of DT node */
 	if (is_top_level_node)
@@ -338,6 +347,9 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
 	if (ret < 0)
 		goto dai_link_of_err;
 
+	if (!of_property_read_u32(node, "mclk-fs", &val))
+		dai_props->mclk_fs = val;
+
 	ret = asoc_simple_card_sub_parse_of(cpu, &dai_props->cpu_dai,
 					    &dai_link->cpu_of_node,
 					    &dai_link->cpu_dai_name,
-- 
1.9.1

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

* [PATCH 2/2] ASoC: simple card: set cpu-dai sysclk with mclk-fs
  2015-06-05  8:19 [PATCH 0/2] ASoc: simple card: extend for MCLK support Arnaud Pouliquen
  2015-06-05  8:19 ` [PATCH 1/2] ASoC: simple card: Add mclk-fs property in dai-link Arnaud Pouliquen
@ 2015-06-05  8:19 ` Arnaud Pouliquen
  2015-06-12 11:40   ` Mark Brown
  2015-07-07 13:58   ` Applied "ASoC: simple card: set cpu-dai sysclk with mclk-fs" to the asoc tree Mark Brown
  1 sibling, 2 replies; 6+ messages in thread
From: Arnaud Pouliquen @ 2015-06-05  8:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, arnaud.pouliquen, lgirdwood

Allows to request a specific mclk frequency per cpu_dai.
To support some codecs with mclk provided by the cpu_dai, the
mclk rate must be set depending on frame rate.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 sound/soc/generic/simple-card.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index d555493..3ff76d4 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -76,6 +76,7 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
 	struct simple_dai_props *dai_props =
 		&priv->dai_props[rtd - rtd->card->rtd];
@@ -91,8 +92,16 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
 		mclk = params_rate(params) * mclk_fs;
 		ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
 					     SND_SOC_CLOCK_IN);
+		if (ret && ret != -ENOTSUPP)
+			goto err;
+
+		ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk,
+					     SND_SOC_CLOCK_OUT);
+		if (ret && ret != -ENOTSUPP)
+			goto err;
 	}
 
+err:
 	return ret;
 }
 
-- 
1.9.1

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

* Re: [PATCH 1/2] ASoC: simple card: Add mclk-fs property in dai-link
  2015-06-05  8:19 ` [PATCH 1/2] ASoC: simple card: Add mclk-fs property in dai-link Arnaud Pouliquen
@ 2015-06-12 11:36   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2015-06-12 11:36 UTC (permalink / raw)
  To: Arnaud Pouliquen; +Cc: alsa-devel, lgirdwood


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

On Fri, Jun 05, 2015 at 10:19:05AM +0200, Arnaud Pouliquen wrote:
> Add mclk-fs ratio property per dai-link sub node. This will
> allow to manage several codecs with different ratio.

Applied, thanks.

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

* Re: [PATCH 2/2] ASoC: simple card: set cpu-dai sysclk with mclk-fs
  2015-06-05  8:19 ` [PATCH 2/2] ASoC: simple card: set cpu-dai sysclk with mclk-fs Arnaud Pouliquen
@ 2015-06-12 11:40   ` Mark Brown
  2015-07-07 13:58   ` Applied "ASoC: simple card: set cpu-dai sysclk with mclk-fs" to the asoc tree Mark Brown
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2015-06-12 11:40 UTC (permalink / raw)
  To: Arnaud Pouliquen; +Cc: alsa-devel, lgirdwood


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

On Fri, Jun 05, 2015 at 10:19:06AM +0200, Arnaud Pouliquen wrote:
> Allows to request a specific mclk frequency per cpu_dai.
> To support some codecs with mclk provided by the cpu_dai, the
> mclk rate must be set depending on frame rate.

I'm going to hold off on this one till after the merge window since we
are very near to that I worry that the behaviour change for CPU DAIs may
trigger problems, I'd appreciate test reports from other users.

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

* Applied "ASoC: simple card: set cpu-dai sysclk with mclk-fs" to the asoc tree
  2015-06-05  8:19 ` [PATCH 2/2] ASoC: simple card: set cpu-dai sysclk with mclk-fs Arnaud Pouliquen
  2015-06-12 11:40   ` Mark Brown
@ 2015-07-07 13:58   ` Mark Brown
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2015-07-07 13:58 UTC (permalink / raw)
  To: Arnaud Pouliquen, Mark Brown; +Cc: alsa-devel

The patch

   ASoC: simple card: set cpu-dai sysclk with mclk-fs

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 e22579713ae1384a3dff545369cebe42b01370fa Mon Sep 17 00:00:00 2001
From: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Date: Fri, 5 Jun 2015 10:19:06 +0200
Subject: [PATCH] ASoC: simple card: set cpu-dai sysclk with mclk-fs

Allows to request a specific mclk frequency per cpu_dai.
To support some codecs with mclk provided by the cpu_dai, the
mclk rate must be set depending on frame rate.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/generic/simple-card.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index d555493..3ff76d4 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -76,6 +76,7 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
 	struct simple_dai_props *dai_props =
 		&priv->dai_props[rtd - rtd->card->rtd];
@@ -91,8 +92,16 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
 		mclk = params_rate(params) * mclk_fs;
 		ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
 					     SND_SOC_CLOCK_IN);
+		if (ret && ret != -ENOTSUPP)
+			goto err;
+
+		ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk,
+					     SND_SOC_CLOCK_OUT);
+		if (ret && ret != -ENOTSUPP)
+			goto err;
 	}
 
+err:
 	return ret;
 }
 
-- 
2.1.4

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

end of thread, other threads:[~2015-07-07 13:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-05  8:19 [PATCH 0/2] ASoc: simple card: extend for MCLK support Arnaud Pouliquen
2015-06-05  8:19 ` [PATCH 1/2] ASoC: simple card: Add mclk-fs property in dai-link Arnaud Pouliquen
2015-06-12 11:36   ` Mark Brown
2015-06-05  8:19 ` [PATCH 2/2] ASoC: simple card: set cpu-dai sysclk with mclk-fs Arnaud Pouliquen
2015-06-12 11:40   ` Mark Brown
2015-07-07 13:58   ` Applied "ASoC: simple card: set cpu-dai sysclk with mclk-fs" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox