linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: fsl-asoc-card: add support for generic codecs
@ 2020-07-02 14:11 Arnaud Ferraris
  2020-07-02 14:11 ` [PATCH 1/2] dt-bindings: sound: fsl-asoc-card: add new compatible for I2S slave Arnaud Ferraris
  2020-07-02 14:11 ` [PATCH 2/2] ASoC: fsl-asoc-card: add support for generic I2S slave use-case Arnaud Ferraris
  0 siblings, 2 replies; 7+ messages in thread
From: Arnaud Ferraris @ 2020-07-02 14:11 UTC (permalink / raw)
  Cc: kernel, Liam Girdwood, Mark Brown, Rob Herring, Timur Tabi,
	Nicolin Chen, Xiubo Li, Fabio Estevam, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, devicetree, linux-kernel, linuxppc-dev

fsl-asoc-card currently only works with AC97 or a selection of codecs,
although the hardware is capable of more.

Supporting generic codecs when acting as I2S slave (codec is master)
would be useful, especially when using Bluetooth audio, as these are
generally simple I2S devices not controlled by the sound subsystem.

This will allow using simple/dummy codecs along with ASRC.

Arnaud Ferraris (2):
  dt-bindings: sound: fsl-asoc-card: add new compatible for I2S slave
  ASoC: fsl-asoc-card: add support for generic I2S slave use-case

 Documentation/devicetree/bindings/sound/fsl-asoc-card.txt | 23 ++++++++++++++++++++++-
 sound/soc/fsl/fsl-asoc-card.c                             | 46 +++++++++++++++++++++++++++++++++++-----------
 2 files changed, 57 insertions(+), 12 deletions(-)

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

* [PATCH 1/2] dt-bindings: sound: fsl-asoc-card: add new compatible for I2S slave
  2020-07-02 14:11 [PATCH 0/2] ASoC: fsl-asoc-card: add support for generic codecs Arnaud Ferraris
@ 2020-07-02 14:11 ` Arnaud Ferraris
  2020-07-02 14:31   ` Mark Brown
  2020-07-02 14:11 ` [PATCH 2/2] ASoC: fsl-asoc-card: add support for generic I2S slave use-case Arnaud Ferraris
  1 sibling, 1 reply; 7+ messages in thread
From: Arnaud Ferraris @ 2020-07-02 14:11 UTC (permalink / raw)
  Cc: kernel, Liam Girdwood, Mark Brown, Rob Herring, Timur Tabi,
	Nicolin Chen, Xiubo Li, Fabio Estevam, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, devicetree, linux-kernel, linuxppc-dev

fsl-asoc-card currently doesn't support generic codecs with the SoC
acting as I2S slave.

This commit adds a new `fsl,imx-audio-i2s-slave` for this use-case, as
well as the following mandatory properties:
- `audio-codec-dai-name` for specifying the codec DAI to be used
- `audio-slot-width`

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
---
 .../bindings/sound/fsl-asoc-card.txt          | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
index 133d7e14a4d0..694a138df462 100644
--- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
+++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
@@ -22,6 +22,8 @@ Note: The card is initially designed for those sound cards who use AC'97, I2S
 The compatible list for this generic sound card currently:
  "fsl,imx-audio-ac97"
 
+ "fsl,imx-audio-i2s-slave"
+
  "fsl,imx-audio-cs42888"
 
  "fsl,imx-audio-cs427x"
@@ -75,7 +77,13 @@ Optional unless SSI is selected as a CPU DAI:
 
   - mux-ext-port	: The external port of the i.MX audio muxer
 
-Example:
+Optional unless compatible is "fsl,imx-audio-i2s-slave":
+
+  - audio-codec-dai-name: The name of the DAI provided by the codec
+
+  - audio-slot-width	: The audio sample format
+
+Examples:
 sound-cs42888 {
 	compatible = "fsl,imx-audio-cs42888";
 	model = "cs42888-audio";
@@ -96,3 +104,16 @@ sound-cs42888 {
 		"AIN2L", "Line In Jack",
 		"AIN2R", "Line In Jack";
 };
+
+sound-bluetooth {
+	compatible = "fsl,imx-audio-i2s-slave";
+	audio-cpu = <&ssi1>;
+	audio-codec = <&codec_bluetooth>;
+	audio-codec-dai-name = "bt-sco-pcm-wb";
+	audio-slot-width = <16>;
+	audio-routing =
+		"RX", "Mic Jack",
+		"Headphone Jack", "TX";
+	mux-int-port = <1>;
+	mux-ext-port = <4>;
+};
-- 
2.27.0


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

* [PATCH 2/2] ASoC: fsl-asoc-card: add support for generic I2S slave use-case
  2020-07-02 14:11 [PATCH 0/2] ASoC: fsl-asoc-card: add support for generic codecs Arnaud Ferraris
  2020-07-02 14:11 ` [PATCH 1/2] dt-bindings: sound: fsl-asoc-card: add new compatible for I2S slave Arnaud Ferraris
@ 2020-07-02 14:11 ` Arnaud Ferraris
  1 sibling, 0 replies; 7+ messages in thread
From: Arnaud Ferraris @ 2020-07-02 14:11 UTC (permalink / raw)
  Cc: kernel, Liam Girdwood, Mark Brown, Rob Herring, Timur Tabi,
	Nicolin Chen, Xiubo Li, Fabio Estevam, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, devicetree, linux-kernel, linuxppc-dev

This commit implements support for generic codecs with the SoC acting as
I2S slave, by implementing the new `fsl,imx-audio-i2s-slave` compatible
and related properties.

This is particularly useful when using a Bluetooth controller acting as
I2S master, but other simple or dummy codecs might benefit from it too.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
---
 sound/soc/fsl/fsl-asoc-card.c | 46 ++++++++++++++++++++++++++---------
 1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 57ea1b072326..6076b963c873 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -166,12 +166,15 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
 		return 0;
 
 	/* Specific configurations of DAIs starts from here */
-	ret = snd_soc_dai_set_sysclk(asoc_rtd_to_cpu(rtd, 0), cpu_priv->sysclk_id[tx],
-				     cpu_priv->sysclk_freq[tx],
-				     cpu_priv->sysclk_dir[tx]);
-	if (ret && ret != -ENOTSUPP) {
-		dev_err(dev, "failed to set sysclk for cpu dai\n");
-		return ret;
+	if (cpu_priv->sysclk_freq[tx] > 0) {
+		ret = snd_soc_dai_set_sysclk(asoc_rtd_to_cpu(rtd, 0),
+					     cpu_priv->sysclk_id[tx],
+					     cpu_priv->sysclk_freq[tx],
+					     cpu_priv->sysclk_dir[tx]);
+		if (ret && ret != -ENOTSUPP) {
+			dev_err(dev, "failed to set sysclk for cpu dai\n");
+			return ret;
+		}
 	}
 
 	if (cpu_priv->slot_width) {
@@ -475,11 +478,14 @@ static int fsl_asoc_card_late_probe(struct snd_soc_card *card)
 		return 0;
 	}
 
-	ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->mclk_id,
-				     codec_priv->mclk_freq, SND_SOC_CLOCK_IN);
-	if (ret && ret != -ENOTSUPP) {
-		dev_err(dev, "failed to set sysclk in %s\n", __func__);
-		return ret;
+	if (codec_priv->mclk_freq > 0) {
+		ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->mclk_id,
+					     codec_priv->mclk_freq,
+					     SND_SOC_CLOCK_IN);
+		if (ret && ret != -ENOTSUPP) {
+			dev_err(dev, "failed to set sysclk in %s\n", __func__);
+			return ret;
+		}
 	}
 
 	return 0;
@@ -620,6 +626,23 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
 		priv->cpu_priv.slot_width = 32;
 		priv->card.dapm_routes = audio_map_tx;
 		priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_tx);
+	} else if (of_device_is_compatible(np, "fsl,imx-audio-i2s-slave")) {
+		ret = of_property_read_string(np, "audio-codec-dai-name",
+					      &codec_dai_name);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to get codec DAI name\n");
+			ret = -EINVAL;
+			goto asrc_fail;
+		}
+		ret = of_property_read_u32(np, "audio-slot-width",
+					   &priv->cpu_priv.slot_width);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to get slot width\n");
+			ret = -EINVAL;
+			goto asrc_fail;
+		}
+		priv->card.set_bias_level = NULL;
+		priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
 	} else {
 		dev_err(&pdev->dev, "unknown Device Tree compatible\n");
 		ret = -EINVAL;
@@ -763,6 +786,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
 
 static const struct of_device_id fsl_asoc_card_dt_ids[] = {
 	{ .compatible = "fsl,imx-audio-ac97", },
+	{ .compatible = "fsl,imx-audio-i2s-slave", },
 	{ .compatible = "fsl,imx-audio-cs42888", },
 	{ .compatible = "fsl,imx-audio-cs427x", },
 	{ .compatible = "fsl,imx-audio-sgtl5000", },
-- 
2.27.0


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

* Re: [PATCH 1/2] dt-bindings: sound: fsl-asoc-card: add new compatible for I2S slave
  2020-07-02 14:11 ` [PATCH 1/2] dt-bindings: sound: fsl-asoc-card: add new compatible for I2S slave Arnaud Ferraris
@ 2020-07-02 14:31   ` Mark Brown
  2020-07-02 15:28     ` Arnaud Ferraris
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2020-07-02 14:31 UTC (permalink / raw)
  To: Arnaud Ferraris
  Cc: kernel, Liam Girdwood, Rob Herring, Timur Tabi, Nicolin Chen,
	Xiubo Li, Fabio Estevam, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, devicetree, linux-kernel, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 436 bytes --]

On Thu, Jul 02, 2020 at 04:11:14PM +0200, Arnaud Ferraris wrote:
> fsl-asoc-card currently doesn't support generic codecs with the SoC
> acting as I2S slave.
> 
> This commit adds a new `fsl,imx-audio-i2s-slave` for this use-case, as
> well as the following mandatory properties:

Why require that the CODEC be clock master here - why not make this
configurable, reusing the properties from the generic and audio graph
cards?

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

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

* Re: [PATCH 1/2] dt-bindings: sound: fsl-asoc-card: add new compatible for I2S slave
  2020-07-02 14:31   ` Mark Brown
@ 2020-07-02 15:28     ` Arnaud Ferraris
  2020-07-02 15:42       ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Arnaud Ferraris @ 2020-07-02 15:28 UTC (permalink / raw)
  To: Mark Brown
  Cc: kernel, Liam Girdwood, Rob Herring, Timur Tabi, Nicolin Chen,
	Xiubo Li, Fabio Estevam, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, devicetree, linux-kernel, linuxppc-dev

Hi Mark,

Le 02/07/2020 à 16:31, Mark Brown a écrit :
> On Thu, Jul 02, 2020 at 04:11:14PM +0200, Arnaud Ferraris wrote:
>> fsl-asoc-card currently doesn't support generic codecs with the SoC
>> acting as I2S slave.
>>
>> This commit adds a new `fsl,imx-audio-i2s-slave` for this use-case, as
>> well as the following mandatory properties:
> 
> Why require that the CODEC be clock master here - why not make this
> configurable, reusing the properties from the generic and audio graph
> cards?

This is partly because I'm not sure how to do it (yet), but mostly
because I don't have the hardware to test this (the 2 CODECs present on
my only i.MX6 board are both clock master)

Regards,
Arnaud

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

* Re: [PATCH 1/2] dt-bindings: sound: fsl-asoc-card: add new compatible for I2S slave
  2020-07-02 15:28     ` Arnaud Ferraris
@ 2020-07-02 15:42       ` Mark Brown
  2020-07-03  9:23         ` Arnaud Ferraris
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2020-07-02 15:42 UTC (permalink / raw)
  To: Arnaud Ferraris
  Cc: kernel, Liam Girdwood, Rob Herring, Timur Tabi, Nicolin Chen,
	Xiubo Li, Fabio Estevam, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, devicetree, linux-kernel, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 756 bytes --]

On Thu, Jul 02, 2020 at 05:28:03PM +0200, Arnaud Ferraris wrote:
> Le 02/07/2020 à 16:31, Mark Brown a écrit :

> > Why require that the CODEC be clock master here - why not make this
> > configurable, reusing the properties from the generic and audio graph
> > cards?

> This is partly because I'm not sure how to do it (yet), but mostly
> because I don't have the hardware to test this (the 2 CODECs present on
> my only i.MX6 board are both clock master)

Take a look at what the generic cards are doing, it's a library function 
asoc_simple_parse_daifmt().  It's not the end of the world if you can't
test it properly - if it turns out it's buggy somehow someone can always
fix the code later but an ABI is an ABI so we can't change it.

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

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

* Re: [PATCH 1/2] dt-bindings: sound: fsl-asoc-card: add new compatible for I2S slave
  2020-07-02 15:42       ` Mark Brown
@ 2020-07-03  9:23         ` Arnaud Ferraris
  0 siblings, 0 replies; 7+ messages in thread
From: Arnaud Ferraris @ 2020-07-03  9:23 UTC (permalink / raw)
  To: Mark Brown
  Cc: devicetree, alsa-devel, linuxppc-dev, Timur Tabi, Xiubo Li,
	linux-kernel, Takashi Iwai, Liam Girdwood, Nicolin Chen,
	Rob Herring, kernel, Fabio Estevam



Le 02/07/2020 à 17:42, Mark Brown a écrit :
> On Thu, Jul 02, 2020 at 05:28:03PM +0200, Arnaud Ferraris wrote:
>> Le 02/07/2020 à 16:31, Mark Brown a écrit :
> 
>>> Why require that the CODEC be clock master here - why not make this
>>> configurable, reusing the properties from the generic and audio graph
>>> cards?
> 
>> This is partly because I'm not sure how to do it (yet), but mostly
>> because I don't have the hardware to test this (the 2 CODECs present on
>> my only i.MX6 board are both clock master)
> 
> Take a look at what the generic cards are doing, it's a library function 
> asoc_simple_parse_daifmt().  It's not the end of the world if you can't
> test it properly - if it turns out it's buggy somehow someone can always
> fix the code later but an ABI is an ABI so we can't change it.
> 

Thanks for the hints, I'll look into it.

Regards,
Arnaud

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

end of thread, other threads:[~2020-07-03  9:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02 14:11 [PATCH 0/2] ASoC: fsl-asoc-card: add support for generic codecs Arnaud Ferraris
2020-07-02 14:11 ` [PATCH 1/2] dt-bindings: sound: fsl-asoc-card: add new compatible for I2S slave Arnaud Ferraris
2020-07-02 14:31   ` Mark Brown
2020-07-02 15:28     ` Arnaud Ferraris
2020-07-02 15:42       ` Mark Brown
2020-07-03  9:23         ` Arnaud Ferraris
2020-07-02 14:11 ` [PATCH 2/2] ASoC: fsl-asoc-card: add support for generic I2S slave use-case Arnaud Ferraris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).