All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: generic: add simple card with devicetree support
@ 2013-07-20 17:25 Jean-Francois Moine
  2013-07-20 20:23   ` Daniel Mack
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Jean-Francois Moine @ 2013-07-20 17:25 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Grant Likely, Rob Herring, Rob Landley, linux-kernel, alsa-devel

This generic simple card driver uses DT values to instanciate an audio
system in which the real work is done by the subdrivers (audio
controller, audio codec and pcm/dma controller).

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 Documentation/devicetree/bindings/sound/simple-dt-card.txt |  18 ++++
 sound/soc/generic/Kconfig                                 |   7 ++
 sound/soc/generic/Makefile                                |   2 +
 sound/soc/generic/simple-dt-card.c                        | 137 ++++++++++++++++++++++++
 4 files changed, 163 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/simple-dt-card.txt b/Documentation/devicetree/bindings/sound/simple-dt-card.txt
new file mode 100644
index 0000000..45f41cc
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/simple-dt-card.txt
@@ -0,0 +1,18 @@
+Device-Tree bindings for simple DT audio card
+
+Required properties:
+  - compatible: should be "linux,simple-dt-audio".
+  - audio-controller: phandle of the audio controller
+  - audio-codec: phandle of the audio codec
+  - platform-pcm-dma: phandle of the PCM/DMA controller
+  - codec-dai-name: name of the codec dai
+
+Example node:
+
+	sound {
+		compatible = "linux,simple-dt-audio";
+		audio-controller = <&i2s1>;
+		audio-codec = <&spdif>;
+		platform-pcm-dma = <&pcm>;
+		codec-dai-name = "dit-hifi";
+	};
diff --git a/sound/soc/generic/Kconfig b/sound/soc/generic/Kconfig
index 610f612..e593224 100644
--- a/sound/soc/generic/Kconfig
+++ b/sound/soc/generic/Kconfig
@@ -2,3 +2,10 @@ config SND_SIMPLE_CARD
 	tristate "ASoC Simple sound card support"
 	help
 	  This option enables generic simple sound card support
+
+config SND_SIMPLE_DT_CARD
+	tristate "ASoC Simple sound card support (Flattened Device Tree)"
+	depends on OF
+	help
+	  This option enables generic simple sound card support
+	  using flattened device tree.
diff --git a/sound/soc/generic/Makefile b/sound/soc/generic/Makefile
index 9c3b246..65ddd3e 100644
--- a/sound/soc/generic/Makefile
+++ b/sound/soc/generic/Makefile
@@ -1,3 +1,5 @@
 snd-soc-simple-card-objs	:= simple-card.o
+snd-soc-simple-dt-card-objs	:= simple-dt-card.o
 
 obj-$(CONFIG_SND_SIMPLE_CARD)	+= snd-soc-simple-card.o
+obj-$(CONFIG_SND_SIMPLE_DT_CARD) += snd-soc-simple-dt-card.o
diff --git a/sound/soc/generic/simple-dt-card.c b/sound/soc/generic/simple-dt-card.c
new file mode 100644
index 0000000..d373d68
--- /dev/null
+++ b/sound/soc/generic/simple-dt-card.c
@@ -0,0 +1,137 @@
+/*
+ * Simple DT defined sound card support
+ *
+ * Copyright (C) 2013 Jean-Francois Moine <moinejf@free.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <sound/soc.h>
+#include <linux/of.h>
+
+static int simple_dt_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct snd_soc_dai_link *link;
+
+	snd_soc_unregister_card(card);
+	link = card->dai_link;
+	if (link) {
+		of_node_put((struct device_node *) link->platform_of_node);
+		of_node_put((struct device_node *) link->codec_of_node);
+		of_node_put((struct device_node *) link->cpu_of_node);
+		kfree(link);
+	}
+	kfree(card);
+	return 0;
+}
+
+static int simple_dt_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct snd_soc_card *card;
+	struct snd_soc_dai_link *link;
+	int ret;
+
+	if (!np) {
+		dev_err(dev, "no device-tree\n");
+		return -ENXIO;
+	}
+
+	card = kzalloc(sizeof *card, GFP_KERNEL);
+	if (!card) {
+		dev_err(dev, "unable to allocate soc card\n");
+		return -ENOMEM;
+	}
+	card->name = "Simple DT audio card";
+	card->owner = THIS_MODULE;
+	card->dev = dev;
+	platform_set_drvdata(pdev, card);
+
+	link = kzalloc(sizeof *link, GFP_KERNEL);
+	if (!link) {
+		dev_err(dev, "unable to allocate soc link\n");
+		ret = -ENOMEM;
+		goto err;
+	}
+	card->dai_link = link;
+	card->num_links = 1;
+
+	link->name = "Simple audio";
+	link->stream_name = "Playback";
+
+	link->cpu_of_node = of_parse_phandle(np, "audio-controller", 0);
+	if (!link->cpu_of_node) {
+		dev_err(dev, "no 'audio-controller' in DT\n");
+		ret = -EINVAL;
+		goto err;
+	}
+
+	link->codec_of_node = of_parse_phandle(np, "audio-codec", 0);
+	if (!link->codec_of_node) {
+		dev_err(dev, "no 'audio-codec' in DT\n");
+		ret = -EINVAL;
+		goto err;
+	}
+
+	link->platform_of_node = of_parse_phandle(np, "platform-pcm-dma", 0);
+	if (!link->platform_of_node) {
+		dev_err(dev, "no 'platform-pcm-dma' in DT\n");
+		ret = -EINVAL;
+		goto err;
+	}
+
+	ret = of_property_read_string(np, "codec-dai-name",
+					 &link->codec_dai_name);
+	if (ret) {
+		dev_err(dev, "no 'codec-dai-name' in DT\n");
+		ret = -EINVAL;
+		goto err;
+	}
+
+	ret = snd_soc_register_card(card);
+	if (ret) {
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "register card err %d\n", ret);
+		goto err;
+	}
+	return 0;
+
+err:
+	simple_dt_remove(pdev);
+	return ret;
+}
+
+static struct of_device_id simple_dt_of_match[] = {
+	{ .compatible = "linux,simple-dt-audio" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, simple_dt_of_match);
+
+static struct platform_driver simple_dt_driver = {
+	.driver		= {
+		.name	= "simple-dt-audio",
+		.owner	= THIS_MODULE,
+		.of_match_table = simple_dt_of_match,
+	},
+	.probe		= simple_dt_probe,
+	.remove		= simple_dt_remove,
+};
+module_platform_driver(simple_dt_driver);
+
+MODULE_AUTHOR("Jean-Francois Moine <moinejf@free.fr>");
+MODULE_DESCRIPTION("ALSA SoC simple DT driver");
+MODULE_LICENSE("GPL");


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

* Re: [PATCH] ASoC: generic: add simple card with devicetree support
  2013-07-20 17:25 [PATCH] ASoC: generic: add simple card with devicetree support Jean-Francois Moine
@ 2013-07-20 20:23   ` Daniel Mack
  2013-07-21  3:14   ` Stephen Warren
  2013-07-21 23:32   ` Mark Brown
  2 siblings, 0 replies; 12+ messages in thread
From: Daniel Mack @ 2013-07-20 20:23 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Grant Likely, Rob Herring, Rob Landley, linux-kernel, alsa-devel,
	Kuninori Morimoto

Hi,

On 20.07.2013 19:25, Jean-Francois Moine wrote:
> This generic simple card driver uses DT values to instanciate an audio
> system in which the real work is done by the subdrivers (audio
> controller, audio codec and pcm/dma controller).
> 
> Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
> ---

> diff --git a/sound/soc/generic/simple-dt-card.c b/sound/soc/generic/simple-dt-card.c
> new file mode 100644

There is a simple-card driver in the tree already, and there were
several attempts to add DT bindings for it in the past - have you seen
that? Search for "ASoC: add simple-card DT support" in the archives ...


Daniel


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

* Re: [PATCH] ASoC: generic: add simple card with devicetree support
@ 2013-07-20 20:23   ` Daniel Mack
  0 siblings, 0 replies; 12+ messages in thread
From: Daniel Mack @ 2013-07-20 20:23 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: alsa-devel, Kuninori Morimoto, Takashi Iwai, linux-kernel,
	Liam Girdwood, Rob Herring, Mark Brown, Rob Landley,
	Grant Likely

Hi,

On 20.07.2013 19:25, Jean-Francois Moine wrote:
> This generic simple card driver uses DT values to instanciate an audio
> system in which the real work is done by the subdrivers (audio
> controller, audio codec and pcm/dma controller).
> 
> Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
> ---

> diff --git a/sound/soc/generic/simple-dt-card.c b/sound/soc/generic/simple-dt-card.c
> new file mode 100644

There is a simple-card driver in the tree already, and there were
several attempts to add DT bindings for it in the past - have you seen
that? Search for "ASoC: add simple-card DT support" in the archives ...


Daniel

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

* Re: [PATCH] ASoC: generic: add simple card with devicetree support
  2013-07-20 17:25 [PATCH] ASoC: generic: add simple card with devicetree support Jean-Francois Moine
@ 2013-07-21  3:14   ` Stephen Warren
  2013-07-21  3:14   ` Stephen Warren
  2013-07-21 23:32   ` Mark Brown
  2 siblings, 0 replies; 12+ messages in thread
From: Stephen Warren @ 2013-07-21  3:14 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Grant Likely, Rob Herring, Rob Landley, linux-kernel, alsa-devel

On 07/20/2013 11:25 AM, Jean-Francois Moine wrote:
> This generic simple card driver uses DT values to instanciate an audio
> system in which the real work is done by the subdrivers (audio
> controller, audio codec and pcm/dma controller).

New DT bindings should be sent to devicetree@vger.kernel.org for review.
Note that's a branch new list (it moved from a different server), so it
might be best to wait a few days for people to subscribe before sending
mail to it.

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

* Re: [PATCH] ASoC: generic: add simple card with devicetree support
@ 2013-07-21  3:14   ` Stephen Warren
  0 siblings, 0 replies; 12+ messages in thread
From: Stephen Warren @ 2013-07-21  3:14 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: alsa-devel, Takashi Iwai, linux-kernel, Liam Girdwood,
	Rob Herring, Mark Brown, Rob Landley, Grant Likely

On 07/20/2013 11:25 AM, Jean-Francois Moine wrote:
> This generic simple card driver uses DT values to instanciate an audio
> system in which the real work is done by the subdrivers (audio
> controller, audio codec and pcm/dma controller).

New DT bindings should be sent to devicetree@vger.kernel.org for review.
Note that's a branch new list (it moved from a different server), so it
might be best to wait a few days for people to subscribe before sending
mail to it.

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

* Re: [PATCH] ASoC: generic: add simple card with devicetree support
  2013-07-20 20:23   ` Daniel Mack
  (?)
@ 2013-07-21 11:24   ` Jean-Francois Moine
  2013-07-21 11:30       ` Daniel Mack
  -1 siblings, 1 reply; 12+ messages in thread
From: Jean-Francois Moine @ 2013-07-21 11:24 UTC (permalink / raw)
  To: Daniel Mack
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Grant Likely, Rob Herring, Rob Landley, linux-kernel, alsa-devel,
	Kuninori Morimoto

On Sat, 20 Jul 2013 22:23:36 +0200
Daniel Mack <zonque@gmail.com> wrote:

> There is a simple-card driver in the tree already, and there were
> several attempts to add DT bindings for it in the past - have you seen
> that? Search for "ASoC: add simple-card DT support" in the archives ...

Hi Daniel,

Thanks, that is what I was searching.

I will wait for Kuninori.

-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

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

* Re: [PATCH] ASoC: generic: add simple card with devicetree support
  2013-07-21 11:24   ` Jean-Francois Moine
@ 2013-07-21 11:30       ` Daniel Mack
  0 siblings, 0 replies; 12+ messages in thread
From: Daniel Mack @ 2013-07-21 11:30 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Grant Likely, Rob Herring, Rob Landley, linux-kernel, alsa-devel,
	Kuninori Morimoto

On 21.07.2013 13:24, Jean-Francois Moine wrote:
> On Sat, 20 Jul 2013 22:23:36 +0200
> Daniel Mack <zonque@gmail.com> wrote:
> 
>> There is a simple-card driver in the tree already, and there were
>> several attempts to add DT bindings for it in the past - have you seen
>> that? Search for "ASoC: add simple-card DT support" in the archives ...
> 
> Hi Daniel,
> 
> Thanks, that is what I was searching.
> 
> I will wait for Kuninori.

Well, Kuninori recently stated he's currently too busy to continue.
Given his permission, it might be an option to pick up where he left off
and finish the open topics. Depends on how urgent your need is I guess.


Thanks,
Daniel


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

* Re: [PATCH] ASoC: generic: add simple card with devicetree support
@ 2013-07-21 11:30       ` Daniel Mack
  0 siblings, 0 replies; 12+ messages in thread
From: Daniel Mack @ 2013-07-21 11:30 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: alsa-devel, Kuninori Morimoto, Takashi Iwai, linux-kernel,
	Liam Girdwood, Rob Herring, Mark Brown, Rob Landley,
	Grant Likely

On 21.07.2013 13:24, Jean-Francois Moine wrote:
> On Sat, 20 Jul 2013 22:23:36 +0200
> Daniel Mack <zonque@gmail.com> wrote:
> 
>> There is a simple-card driver in the tree already, and there were
>> several attempts to add DT bindings for it in the past - have you seen
>> that? Search for "ASoC: add simple-card DT support" in the archives ...
> 
> Hi Daniel,
> 
> Thanks, that is what I was searching.
> 
> I will wait for Kuninori.

Well, Kuninori recently stated he's currently too busy to continue.
Given his permission, it might be an option to pick up where he left off
and finish the open topics. Depends on how urgent your need is I guess.


Thanks,
Daniel

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

* Re: [PATCH] ASoC: generic: add simple card with devicetree support
  2013-07-20 17:25 [PATCH] ASoC: generic: add simple card with devicetree support Jean-Francois Moine
@ 2013-07-21 23:32   ` Mark Brown
  2013-07-21  3:14   ` Stephen Warren
  2013-07-21 23:32   ` Mark Brown
  2 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2013-07-21 23:32 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Grant Likely,
	Rob Herring, Rob Landley, linux-kernel, alsa-devel

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

On Sat, Jul 20, 2013 at 07:25:54PM +0200, Jean-Francois Moine wrote:

>  Documentation/devicetree/bindings/sound/simple-dt-card.txt |  18 ++++
>  sound/soc/generic/Kconfig                                 |   7 ++
>  sound/soc/generic/Makefile                                |   2 +
>  sound/soc/generic/simple-dt-card.c                        | 137 ++++++++++++++++++++++++
>  4 files changed, 163 insertions(+)

The obvious question here is why is this a separate driver to the
existing simple card driver rather than DT bindings for that?  I don't
see that mentioned here.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] ASoC: generic: add simple card with devicetree support
@ 2013-07-21 23:32   ` Mark Brown
  0 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2013-07-21 23:32 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: alsa-devel, Takashi Iwai, linux-kernel, Liam Girdwood,
	Rob Herring, Rob Landley, Grant Likely


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

On Sat, Jul 20, 2013 at 07:25:54PM +0200, Jean-Francois Moine wrote:

>  Documentation/devicetree/bindings/sound/simple-dt-card.txt |  18 ++++
>  sound/soc/generic/Kconfig                                 |   7 ++
>  sound/soc/generic/Makefile                                |   2 +
>  sound/soc/generic/simple-dt-card.c                        | 137 ++++++++++++++++++++++++
>  4 files changed, 163 insertions(+)

The obvious question here is why is this a separate driver to the
existing simple card driver rather than DT bindings for that?  I don't
see that mentioned here.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH] ASoC: generic: add simple card with devicetree support
  2013-07-21 11:30       ` Daniel Mack
@ 2013-07-22  0:46         ` Kuninori Morimoto
  -1 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2013-07-22  0:46 UTC (permalink / raw)
  To: Daniel Mack
  Cc: Jean-Francois Moine, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Grant Likely, Rob Herring, Rob Landley,
	linux-kernel, alsa-devel


Hi

> > On Sat, 20 Jul 2013 22:23:36 +0200
> > Daniel Mack <zonque@gmail.com> wrote:
> > 
> >> There is a simple-card driver in the tree already, and there were
> >> several attempts to add DT bindings for it in the past - have you seen
> >> that? Search for "ASoC: add simple-card DT support" in the archives ...
> > 
> > Hi Daniel,
> > 
> > Thanks, that is what I was searching.
> > 
> > I will wait for Kuninori.
> 
> Well, Kuninori recently stated he's currently too busy to continue.
> Given his permission, it might be an option to pick up where he left off
> and finish the open topics. Depends on how urgent your need is I guess.

I'm sorry, but I'm busy now. and I'm happy if someone try to support simple-card DT.

In my understanding, latest plan (agreement with ALSA ML ?) of simple-card DT support are...

   1) current snd_soc_register_codec() will replaced to use snd_soc_register_component().
   2) snd_soc_register_component() will have name <-> id exchange function for DT suport.
   3) simple-card supports DT by using above name <-> id exchange

Most biggest and difficult is 1) I think.
It needs more discussion how to do 1) ?

But someone (I forgot who is) is already trying to implement it ?
I'm not sure...

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH] ASoC: generic: add simple card with devicetree support
@ 2013-07-22  0:46         ` Kuninori Morimoto
  0 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2013-07-22  0:46 UTC (permalink / raw)
  To: Daniel Mack
  Cc: Jean-Francois Moine, alsa-devel, Takashi Iwai, linux-kernel,
	Liam Girdwood, Rob Herring, Mark Brown, Rob Landley,
	Grant Likely


Hi

> > On Sat, 20 Jul 2013 22:23:36 +0200
> > Daniel Mack <zonque@gmail.com> wrote:
> > 
> >> There is a simple-card driver in the tree already, and there were
> >> several attempts to add DT bindings for it in the past - have you seen
> >> that? Search for "ASoC: add simple-card DT support" in the archives ...
> > 
> > Hi Daniel,
> > 
> > Thanks, that is what I was searching.
> > 
> > I will wait for Kuninori.
> 
> Well, Kuninori recently stated he's currently too busy to continue.
> Given his permission, it might be an option to pick up where he left off
> and finish the open topics. Depends on how urgent your need is I guess.

I'm sorry, but I'm busy now. and I'm happy if someone try to support simple-card DT.

In my understanding, latest plan (agreement with ALSA ML ?) of simple-card DT support are...

   1) current snd_soc_register_codec() will replaced to use snd_soc_register_component().
   2) snd_soc_register_component() will have name <-> id exchange function for DT suport.
   3) simple-card supports DT by using above name <-> id exchange

Most biggest and difficult is 1) I think.
It needs more discussion how to do 1) ?

But someone (I forgot who is) is already trying to implement it ?
I'm not sure...

Best regards
---
Kuninori Morimoto

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

end of thread, other threads:[~2013-07-22  0:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-20 17:25 [PATCH] ASoC: generic: add simple card with devicetree support Jean-Francois Moine
2013-07-20 20:23 ` Daniel Mack
2013-07-20 20:23   ` Daniel Mack
2013-07-21 11:24   ` Jean-Francois Moine
2013-07-21 11:30     ` Daniel Mack
2013-07-21 11:30       ` Daniel Mack
2013-07-22  0:46       ` Kuninori Morimoto
2013-07-22  0:46         ` Kuninori Morimoto
2013-07-21  3:14 ` Stephen Warren
2013-07-21  3:14   ` Stephen Warren
2013-07-21 23:32 ` Mark Brown
2013-07-21 23:32   ` 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.