All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean-Francois Moine <moinejf@free.fr>
To: Mark Brown <broonie@kernel.org>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Dave Airlie <airlied@gmail.com>,
	Andrew Jackson <Andrew.Jackson@arm.com>,
	Jyri Sarha <jsarha@ti.com>,
	alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH v10 3/9] ASoC: kirkwood: accept the DAI definitions from a graph of ports
Date: Mon, 19 Jan 2015 19:50:54 +0100	[thread overview]
Message-ID: <18425fc3a59ca2f1fed6cf056c3d2700adee7d4a.1421782532.git.moinejf@free.fr> (raw)
In-Reply-To: <cover.1421782532.git.moinejf@free.fr>

By default, both output ports 0 (I2S) and 1 (S/PDIF) are defined.
A graph of port permits to define only the really connected ports of
the board and to identify the remote ends.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 .../devicetree/bindings/sound/mvebu-audio.txt      | 30 ++++++++++++++++
 sound/soc/kirkwood/kirkwood-i2s.c                  | 41 ++++++++++++++++++----
 sound/soc/kirkwood/kirkwood.h                      |  3 +-
 3 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/mvebu-audio.txt b/Documentation/devicetree/bindings/sound/mvebu-audio.txt
index cb8c07c..ae81bf1 100644
--- a/Documentation/devicetree/bindings/sound/mvebu-audio.txt
+++ b/Documentation/devicetree/bindings/sound/mvebu-audio.txt
@@ -23,6 +23,19 @@ Required properties:
 	"internal" for the internal clock
 	"extclk" for the external clock
 
+Optional nodes:
+
+- port: one or two ports.
+  Each port must contain the following property:
+
+  - port-type: must be "i2s" or "spdif"
+
+  and the following node:
+
+  - endpoint: reference of the remote endpoint - see [1]
+
+[1] Documentation/devicetree/bindings/graph.txt
+
 Example:
 
 i2s1: audio-controller@b4000 {
@@ -31,4 +44,21 @@ i2s1: audio-controller@b4000 {
 	interrupts = <21>, <22>;
 	clocks = <&gate_clk 13>;
 	clock-names = "internal";
+
+	port@0 {
+		port-type = "spdif";
+		audio1_spdif0: endpoint@0 {
+			remote-endpoint = <&spdif_out>;
+		};
+		audio1_spdif1: endpoint@1 {
+			remote-endpoint = <&tda998x_spdif>;
+		};
+	};
+	port@1 {
+		port-type = "i2s";
+		audio1_i2s: endpoint {
+			remote-endpoint = <&tda998x_i2s>;
+		};
+	};
+
 };
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 357f963..8e62bb8 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -466,13 +466,42 @@ static const struct snd_soc_component_driver kirkwood_i2s_component = {
 };
 
 /* create the DAIs */
-static int kirkwood_i2s_create_dais(struct kirkwood_dma_data *priv)
+static int kirkwood_i2s_create_dais(struct device_node *np,
+				struct kirkwood_dma_data *priv)
 {
-	int i, ndai, dai[2];
+	struct device_node *of_port;
+	const char *name;
+	int i, ret, ndai, dai[2];
 
-	ndai = 2;
-	dai[0] = 0;		/* i2s(0) - spdif(1) */
-	dai[1] = 1;
+	ndai = 0;
+	if (np) {
+		for_each_child_of_node(np, of_port) {
+			if (!of_port->name ||
+			     of_node_cmp(of_port->name, "port") != 0)
+				continue;
+			ret = of_property_read_string(of_port,
+						"port-type",
+						&name);
+			if (ret)
+				continue;
+			if (strcmp(name, "i2s") == 0) {
+				dai[ndai] = 0;
+			} else if (strcmp(name, "spdif") == 0) {
+				dai[ndai] = 1;
+			} else {
+				continue;
+			}
+			if (++ndai >= 2)
+				break;
+		}
+	}
+	if (ndai == 0) {		/* no DT or no port */
+		ndai = 2;
+		dai[0] = 0;		/* i2s(0) - spdif(1) */
+		dai[1] = 1;
+	} else {
+		priv->is_graph = 1;	/* graph of the ports */
+	}
 	for (i = 0; i < ndai; i++) {
 		memcpy(&priv->dais[i], &kirkwood_i2s_dai_i2s_ext,
 				sizeof(priv->dais[0]));
@@ -570,7 +599,7 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 		priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128;
 	}
 
-	ndais = kirkwood_i2s_create_dais(priv);
+	ndais = kirkwood_i2s_create_dais(np, priv);
 
 	err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component,
 					 priv->dais, ndais);
diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h
index a24d2c2..b4cbefe 100644
--- a/sound/soc/kirkwood/kirkwood.h
+++ b/sound/soc/kirkwood/kirkwood.h
@@ -141,7 +141,8 @@ struct kirkwood_dma_data {
 	struct snd_pcm_substream *substream_play;
 	struct snd_pcm_substream *substream_rec;
 	int irq;
-	int burst;
+	short burst;
+	short is_graph;
 };
 
 extern struct snd_soc_platform_driver kirkwood_soc_platform;
-- 
2.1.4


WARNING: multiple messages have this Message-ID (diff)
From: Jean-Francois Moine <moinejf@free.fr>
To: Mark Brown <broonie@kernel.org>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	Andrew Jackson <Andrew.Jackson@arm.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Jyri Sarha <jsarha@ti.com>
Subject: [PATCH v10 3/9] ASoC: kirkwood: accept the DAI definitions from a graph of ports
Date: Mon, 19 Jan 2015 19:50:54 +0100	[thread overview]
Message-ID: <18425fc3a59ca2f1fed6cf056c3d2700adee7d4a.1421782532.git.moinejf@free.fr> (raw)
In-Reply-To: <cover.1421782532.git.moinejf@free.fr>

By default, both output ports 0 (I2S) and 1 (S/PDIF) are defined.
A graph of port permits to define only the really connected ports of
the board and to identify the remote ends.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 .../devicetree/bindings/sound/mvebu-audio.txt      | 30 ++++++++++++++++
 sound/soc/kirkwood/kirkwood-i2s.c                  | 41 ++++++++++++++++++----
 sound/soc/kirkwood/kirkwood.h                      |  3 +-
 3 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/mvebu-audio.txt b/Documentation/devicetree/bindings/sound/mvebu-audio.txt
index cb8c07c..ae81bf1 100644
--- a/Documentation/devicetree/bindings/sound/mvebu-audio.txt
+++ b/Documentation/devicetree/bindings/sound/mvebu-audio.txt
@@ -23,6 +23,19 @@ Required properties:
 	"internal" for the internal clock
 	"extclk" for the external clock
 
+Optional nodes:
+
+- port: one or two ports.
+  Each port must contain the following property:
+
+  - port-type: must be "i2s" or "spdif"
+
+  and the following node:
+
+  - endpoint: reference of the remote endpoint - see [1]
+
+[1] Documentation/devicetree/bindings/graph.txt
+
 Example:
 
 i2s1: audio-controller@b4000 {
@@ -31,4 +44,21 @@ i2s1: audio-controller@b4000 {
 	interrupts = <21>, <22>;
 	clocks = <&gate_clk 13>;
 	clock-names = "internal";
+
+	port@0 {
+		port-type = "spdif";
+		audio1_spdif0: endpoint@0 {
+			remote-endpoint = <&spdif_out>;
+		};
+		audio1_spdif1: endpoint@1 {
+			remote-endpoint = <&tda998x_spdif>;
+		};
+	};
+	port@1 {
+		port-type = "i2s";
+		audio1_i2s: endpoint {
+			remote-endpoint = <&tda998x_i2s>;
+		};
+	};
+
 };
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 357f963..8e62bb8 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -466,13 +466,42 @@ static const struct snd_soc_component_driver kirkwood_i2s_component = {
 };
 
 /* create the DAIs */
-static int kirkwood_i2s_create_dais(struct kirkwood_dma_data *priv)
+static int kirkwood_i2s_create_dais(struct device_node *np,
+				struct kirkwood_dma_data *priv)
 {
-	int i, ndai, dai[2];
+	struct device_node *of_port;
+	const char *name;
+	int i, ret, ndai, dai[2];
 
-	ndai = 2;
-	dai[0] = 0;		/* i2s(0) - spdif(1) */
-	dai[1] = 1;
+	ndai = 0;
+	if (np) {
+		for_each_child_of_node(np, of_port) {
+			if (!of_port->name ||
+			     of_node_cmp(of_port->name, "port") != 0)
+				continue;
+			ret = of_property_read_string(of_port,
+						"port-type",
+						&name);
+			if (ret)
+				continue;
+			if (strcmp(name, "i2s") == 0) {
+				dai[ndai] = 0;
+			} else if (strcmp(name, "spdif") == 0) {
+				dai[ndai] = 1;
+			} else {
+				continue;
+			}
+			if (++ndai >= 2)
+				break;
+		}
+	}
+	if (ndai == 0) {		/* no DT or no port */
+		ndai = 2;
+		dai[0] = 0;		/* i2s(0) - spdif(1) */
+		dai[1] = 1;
+	} else {
+		priv->is_graph = 1;	/* graph of the ports */
+	}
 	for (i = 0; i < ndai; i++) {
 		memcpy(&priv->dais[i], &kirkwood_i2s_dai_i2s_ext,
 				sizeof(priv->dais[0]));
@@ -570,7 +599,7 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 		priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128;
 	}
 
-	ndais = kirkwood_i2s_create_dais(priv);
+	ndais = kirkwood_i2s_create_dais(np, priv);
 
 	err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component,
 					 priv->dais, ndais);
diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h
index a24d2c2..b4cbefe 100644
--- a/sound/soc/kirkwood/kirkwood.h
+++ b/sound/soc/kirkwood/kirkwood.h
@@ -141,7 +141,8 @@ struct kirkwood_dma_data {
 	struct snd_pcm_substream *substream_play;
 	struct snd_pcm_substream *substream_rec;
 	int irq;
-	int burst;
+	short burst;
+	short is_graph;
 };
 
 extern struct snd_soc_platform_driver kirkwood_soc_platform;
-- 
2.1.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-01-20 19:43 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-20 19:35 [PATCH v10 0/9] ASoC: tda998x: add a codec to the HDMI transmitter Jean-Francois Moine
2015-01-20 19:35 ` Jean-Francois Moine
2015-01-19 17:15 ` [PATCH v10 1/9] ASoC: kirkwood: dynamically build the DAI array Jean-Francois Moine
2015-01-19 17:15   ` Jean-Francois Moine
2015-01-19 17:38 ` [PATCH v10 2/9] ASoC: kirkwood: check the DAI type from the DAI name Jean-Francois Moine
2015-01-19 17:38   ` Jean-Francois Moine
2015-01-19 18:50 ` Jean-Francois Moine [this message]
2015-01-19 18:50   ` [PATCH v10 3/9] ASoC: kirkwood: accept the DAI definitions from a graph of ports Jean-Francois Moine
2015-01-20  9:27 ` [PATCH v10 4/9] drm/i2c: tda998x: Add support of a DT " Jean-Francois Moine
2015-01-20  9:27   ` Jean-Francois Moine
2015-01-20 11:16 ` [PATCH v10 5/9] drm/i2c: tda998x: Change drvdata for audio extension Jean-Francois Moine
2015-01-20 11:16   ` Jean-Francois Moine
2015-01-20 15:38 ` [PATCH v10 6/9] ASoC: tda998x: add a codec to the HDMI transmitter Jean-Francois Moine
2015-01-20 15:38   ` Jean-Francois Moine
2015-01-20 16:50 ` [PATCH v10 7/9] drm/i2c: tda998x: set cts_n according to the sample width Jean-Francois Moine
2015-01-20 16:50   ` Jean-Francois Moine
2015-01-20 18:47 ` [PATCH v10 8/9] ASoC: core: export snd_soc_get_dai_name Jean-Francois Moine
2015-01-20 18:47   ` Jean-Francois Moine
2015-01-20 19:16 ` [PATCH v10 9/9] ASoC: add generic dt-card support Jean-Francois Moine
2015-01-20 19:16   ` Jean-Francois Moine
2015-01-21 13:50   ` Mark Brown
2015-01-21 13:50     ` Mark Brown
2015-04-27 11:33 ` [PATCH v10 0/9] ASoC: tda998x: add a codec to the HDMI transmitter Jyri Sarha
2015-04-27 11:33   ` Jyri Sarha
2015-04-27 18:25   ` Jean-Francois Moine
2015-04-27 18:25     ` Jean-Francois Moine
2015-04-28  7:10     ` Jean-Francois Moine
2015-04-28  7:10       ` Jean-Francois Moine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18425fc3a59ca2f1fed6cf056c3d2700adee7d4a.1421782532.git.moinejf@free.fr \
    --to=moinejf@free.fr \
    --cc=Andrew.Jackson@arm.com \
    --cc=airlied@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jsarha@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.