linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 00/14] ASoC: add OF graph base simple-card
@ 2016-11-28  2:42 Kuninori Morimoto
  2016-11-28  2:44 ` [PATCH v5 01/14] Documentation: of: add type property Kuninori Morimoto
                   ` (13 more replies)
  0 siblings, 14 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:42 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


Hi Rob, Mark

These are v5 of OF graph base simple-card patch-set.
I removed new "type" property on v4 patch-set, but I noticed that
it is necessary for ALSA SoC binding purpose. Thus, this v5 has
it again.

For example HDMI case, its DT will has video and sound ports.
This DT will be used from HDMI Video driver and HDMI sound driver.
HDMI video side can handle all somehow, because it is fully under its control.
HDMI sound side will just references it. But it can't know total
Video/Sound ports number which is necessary for ALSA SoC side.

For example, if HDMI video had 4 ports, sound had 2 ports,
this case, HDMI sound ports will be port@4, port@5.
Here, ALSA SoC side needs to know total 2 sound port,
and, it should be handled as 1st / 2nd port.
It is impossible without "type" property.

 1) -  7) : OF graph new feature
 8) - 14) : OF graph base simple-card

Kuninori Morimoto (14):
   1) Documentation: of: add type property
   2) of_graph: add of_graph_get_remote_endpoint()
   3) of_graph: add of_graph_port_type_is()
   4) of_graph: add of_graph_get_port_parent()
   5) of_graph: add of_graph_get_top_port()
   6) of_graph: add for_each_of_port() / for_each_of_endpoint_in_port()
   7) of_graph: add of_graph_get_endpoint_count()
   8) ASoC: simple-card-utils: adjust for graph on asoc_simple_card_parse_card_name
   9) ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai()
  10) ASoC: simple-card-utils: add asoc_simple_card_try_to_probe_graph_card()
  11) ASoC: add simple-graph-card document
  12) ASoC: add simple-graph-card support
  13) ASoC: add simple-graph-scu-card document
  14) ASoC: add simple-graph-scu-card support

 Documentation/devicetree/bindings/graph.txt        |  21 +
 .../bindings/sound/simple-graph-card.txt           |  67 +++
 .../bindings/sound/simple-graph-scu-card.txt       |  69 +++
 drivers/of/base.c                                  | 166 +++++++-
 include/linux/of_graph.h                           |  67 +++
 include/sound/simple_card_utils.h                  |  13 +
 sound/soc/generic/Kconfig                          |  15 +
 sound/soc/generic/Makefile                         |   4 +
 sound/soc/generic/simple-card-utils.c              |  98 ++++-
 sound/soc/generic/simple-card.c                    |   2 +-
 sound/soc/generic/simple-graph-card.c              | 461 +++++++++++++++++++++
 sound/soc/generic/simple-graph-scu-card.c          | 441 ++++++++++++++++++++
 sound/soc/generic/simple-scu-card.c                |   2 +-
 13 files changed, 1413 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/simple-graph-card.txt
 create mode 100644 Documentation/devicetree/bindings/sound/simple-graph-scu-card.txt
 create mode 100644 sound/soc/generic/simple-graph-card.c
 create mode 100644 sound/soc/generic/simple-graph-scu-card.c

-- 
1.9.1

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

* [PATCH v5 01/14] Documentation: of: add type property
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
@ 2016-11-28  2:44 ` Kuninori Morimoto
  2016-12-01 16:26   ` Rob Herring
  2016-11-28  2:45 ` [PATCH v5 02/14] of_graph: add of_graph_get_remote_endpoint() Kuninori Morimoto
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:44 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

OF graph indicates each devices connection. But it doesn't support type
of each port. For example HDMI case, it has video port and sound port
in one device node.
In this case, current driver can't handle each port correctly.
This patch enables to use type property on OF graph.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 Documentation/devicetree/bindings/graph.txt | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/graph.txt b/Documentation/devicetree/bindings/graph.txt
index fcb1c6a..fe6c8ce 100644
--- a/Documentation/devicetree/bindings/graph.txt
+++ b/Documentation/devicetree/bindings/graph.txt
@@ -110,6 +110,27 @@ device-2 {
         };
 };
 
+port / endpoint type
+--------------------
+
+Each port can have its type if needed.
+For example HDMI case, it has video port and sound port.
+Below example indicates that port@0 is HDMI-video port,
+and port@1 is HDMI-sound port.
+
+HDMI {
+	port@0 {
+		type = "video";
+		endpoint {
+		};
+	};
+	port@1 {
+		type = "sound";
+		endpoint {
+		};
+	};
+};
+
 
 Required properties
 -------------------
-- 
1.9.1

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

* [PATCH v5 02/14] of_graph: add of_graph_get_remote_endpoint()
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
  2016-11-28  2:44 ` [PATCH v5 01/14] Documentation: of: add type property Kuninori Morimoto
@ 2016-11-28  2:45 ` Kuninori Morimoto
  2016-11-28  2:45 ` [PATCH v5 03/14] of_graph: add of_graph_port_type_is() Kuninori Morimoto
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:45 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

It should use same method to get same result.
To getting remote-endpoint node,
let's use of_graph_get_remote_endpoint()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/of/base.c        | 18 ++++++++++++++++--
 include/linux/of_graph.h |  8 ++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index a0bccb5..fed109d 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2423,6 +2423,20 @@ struct device_node *of_graph_get_endpoint_by_regs(
 EXPORT_SYMBOL(of_graph_get_endpoint_by_regs);
 
 /**
+ * of_graph_get_remote_endpoint() - get remote endpoint node
+ * @node: pointer to a local endpoint device_node
+ *
+ * Return: Remote endpoint node associated with remote endpoint node linked
+ *	   to @node. Use of_node_put() on it when done.
+ */
+struct device_node *of_graph_get_remote_endpoint(const struct device_node *node)
+{
+	/* Get remote endpoint node. */
+	return of_parse_phandle(node, "remote-endpoint", 0);
+}
+EXPORT_SYMBOL(of_graph_get_remote_endpoint);
+
+/**
  * of_graph_get_remote_port_parent() - get remote port's parent node
  * @node: pointer to a local endpoint device_node
  *
@@ -2436,7 +2450,7 @@ struct device_node *of_graph_get_remote_port_parent(
 	unsigned int depth;
 
 	/* Get remote endpoint node. */
-	np = of_parse_phandle(node, "remote-endpoint", 0);
+	np = of_graph_get_remote_endpoint(node);
 
 	/* Walk 3 levels up only if there is 'ports' node. */
 	for (depth = 3; depth && np; depth--) {
@@ -2460,7 +2474,7 @@ struct device_node *of_graph_get_remote_port(const struct device_node *node)
 	struct device_node *np;
 
 	/* Get remote endpoint node. */
-	np = of_parse_phandle(node, "remote-endpoint", 0);
+	np = of_graph_get_remote_endpoint(node);
 	if (!np)
 		return NULL;
 	return of_get_next_parent(np);
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index bb3a5a2..d9d6d9c 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -48,6 +48,8 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 					struct device_node *previous);
 struct device_node *of_graph_get_endpoint_by_regs(
 		const struct device_node *parent, int port_reg, int reg);
+struct device_node *of_graph_get_remote_endpoint(
+					const struct device_node *node);
 struct device_node *of_graph_get_remote_port_parent(
 					const struct device_node *node);
 struct device_node *of_graph_get_remote_port(const struct device_node *node);
@@ -78,6 +80,12 @@ static inline struct device_node *of_graph_get_endpoint_by_regs(
 	return NULL;
 }
 
+static inline struct device_node *of_graph_get_remote_endpoint(
+					const struct device_node *node)
+{
+	return NULL;
+}
+
 static inline struct device_node *of_graph_get_remote_port_parent(
 					const struct device_node *node)
 {
-- 
1.9.1

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

* [PATCH v5 03/14] of_graph: add of_graph_port_type_is()
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
  2016-11-28  2:44 ` [PATCH v5 01/14] Documentation: of: add type property Kuninori Morimoto
  2016-11-28  2:45 ` [PATCH v5 02/14] of_graph: add of_graph_get_remote_endpoint() Kuninori Morimoto
@ 2016-11-28  2:45 ` Kuninori Morimoto
  2016-11-28  2:45 ` [PATCH v5 04/14] of_graph: add of_graph_get_port_parent() Kuninori Morimoto
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:45 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

OF graph indicates each devices connection. But it doesn't support type
of each port. For example HDMI case, it has video port and sound port
in one device node.
In this case, current driver can't handle each port correctly.

This patch adds of_graph_port_type_is() for it,
and adds of_graph_port_type_is_sound macro

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/of/base.c        | 14 ++++++++++++++
 include/linux/of_graph.h |  8 ++++++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index fed109d..d6237ba 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2480,3 +2480,17 @@ struct device_node *of_graph_get_remote_port(const struct device_node *node)
 	return of_get_next_parent(np);
 }
 EXPORT_SYMBOL(of_graph_get_remote_port);
+
+bool of_graph_port_type_is(struct device_node *port, char *type)
+{
+	const char *prop = NULL;
+
+	of_property_read_string(port, "type", &prop);
+
+	if (prop &&
+	    strcmp(prop, type) == 0)
+		return true;
+
+	return false;
+}
+EXPORT_SYMBOL(of_graph_port_type_is);
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index d9d6d9c..0a06441 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -40,9 +40,12 @@ struct of_endpoint {
 	for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \
 	     child = of_graph_get_next_endpoint(parent, child))
 
+#define of_graph_port_type_is_sound(n)		of_graph_port_type_is(n, "sound")
+
 #ifdef CONFIG_OF
 int of_graph_parse_endpoint(const struct device_node *node,
 				struct of_endpoint *endpoint);
+bool of_graph_port_type_is(struct device_node *port, char *type);
 struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 					struct device_node *previous);
@@ -61,6 +64,11 @@ static inline int of_graph_parse_endpoint(const struct device_node *node,
 	return -ENOSYS;
 }
 
+static bool of_graph_port_type_is(struct device_node *port, char *type)
+{
+	return false;
+}
+
 static inline struct device_node *of_graph_get_port_by_id(
 					struct device_node *node, u32 id)
 {
-- 
1.9.1

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

* [PATCH v5 04/14] of_graph: add of_graph_get_port_parent()
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2016-11-28  2:45 ` [PATCH v5 03/14] of_graph: add of_graph_port_type_is() Kuninori Morimoto
@ 2016-11-28  2:45 ` Kuninori Morimoto
  2016-11-28  2:46 ` [PATCH v5 05/14] of_graph: add of_graph_get_top_port() Kuninori Morimoto
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:45 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Linux kernel already has of_graph_get_remote_port_parent(),
but, sometimes we want to get own port parent.
This patch adds of_graph_get_port_parent()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/of/base.c        | 30 ++++++++++++++++++++++--------
 include/linux/of_graph.h |  7 +++++++
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index d6237ba..f94884d 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2437,6 +2437,27 @@ struct device_node *of_graph_get_remote_endpoint(const struct device_node *node)
 EXPORT_SYMBOL(of_graph_get_remote_endpoint);
 
 /**
+ * of_graph_get_port_parent() - get port's parent node
+ * @node: pointer to a local endpoint device_node
+ *
+ * Return: device node associated with endpoint node linked
+ *	   to @node. Use of_node_put() on it when done.
+ */
+struct device_node *of_graph_get_port_parent(struct device_node *node)
+{
+	unsigned int depth;
+
+	/* Walk 3 levels up only if there is 'ports' node. */
+	for (depth = 3; depth && node; depth--) {
+		node = of_get_next_parent(node);
+		if (depth == 2 && of_node_cmp(node->name, "ports"))
+			break;
+	}
+	return node;
+}
+EXPORT_SYMBOL(of_graph_get_port_parent);
+
+/**
  * of_graph_get_remote_port_parent() - get remote port's parent node
  * @node: pointer to a local endpoint device_node
  *
@@ -2447,18 +2468,11 @@ struct device_node *of_graph_get_remote_port_parent(
 			       const struct device_node *node)
 {
 	struct device_node *np;
-	unsigned int depth;
 
 	/* Get remote endpoint node. */
 	np = of_graph_get_remote_endpoint(node);
 
-	/* Walk 3 levels up only if there is 'ports' node. */
-	for (depth = 3; depth && np; depth--) {
-		np = of_get_next_parent(np);
-		if (depth == 2 && of_node_cmp(np->name, "ports"))
-			break;
-	}
-	return np;
+	return of_graph_get_port_parent(np);
 }
 EXPORT_SYMBOL(of_graph_get_remote_port_parent);
 
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 0a06441..0f362ed 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -53,6 +53,7 @@ struct device_node *of_graph_get_endpoint_by_regs(
 		const struct device_node *parent, int port_reg, int reg);
 struct device_node *of_graph_get_remote_endpoint(
 					const struct device_node *node);
+struct device_node *of_graph_get_port_parent(struct device_node *node);
 struct device_node *of_graph_get_remote_port_parent(
 					const struct device_node *node);
 struct device_node *of_graph_get_remote_port(const struct device_node *node);
@@ -94,6 +95,12 @@ static inline struct device_node *of_graph_get_remote_endpoint(
 	return NULL;
 }
 
+static inline struct device_node *of_graph_get_port_parent(
+	struct device_node *node)
+{
+	return NULL;
+}
+
 static inline struct device_node *of_graph_get_remote_port_parent(
 					const struct device_node *node)
 {
-- 
1.9.1

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

* [PATCH v5 05/14] of_graph: add of_graph_get_top_port()
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2016-11-28  2:45 ` [PATCH v5 04/14] of_graph: add of_graph_get_port_parent() Kuninori Morimoto
@ 2016-11-28  2:46 ` Kuninori Morimoto
  2016-11-28  2:46 ` [PATCH v5 06/14] of_graph: add for_each_of_port() / for_each_of_endpoint_in_port() Kuninori Morimoto
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:46 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

driver want to get top level of port[s] node. This patch adds
of_graph_get_top_port() for this purpose

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/of/base.c        | 24 ++++++++++++++++++++++++
 include/linux/of_graph.h |  7 +++++++
 2 files changed, 31 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index f94884d..8c5080b 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2328,6 +2328,30 @@ struct device_node *of_graph_get_port_by_id(struct device_node *parent, u32 id)
 EXPORT_SYMBOL(of_graph_get_port_by_id);
 
 /**
+ * of_graph_get_top_port() - get the top port node
+ * @dev: pointer to the device
+ *
+ * Return: A 'port' node pointer with refcount incremented. The caller
+ * has to use of_node_put() on it when done.
+ */
+struct device_node *of_graph_get_top_port(struct device *dev)
+{
+	struct device_node *np = dev->of_node;
+	struct device_node *node;
+
+	node = of_get_child_by_name(np, "ports");
+	if (node)
+		return node;
+
+	node = of_get_child_by_name(np, "port");
+	if (node)
+		return node;
+
+	return NULL;
+}
+EXPORT_SYMBOL(of_graph_get_top_port);
+
+/**
  * of_graph_get_next_endpoint() - get next endpoint node
  * @parent: pointer to the parent device node
  * @prev: previous endpoint node, or NULL to get first
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 0f362ed..699835a 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -14,6 +14,7 @@
 #ifndef __LINUX_OF_GRAPH_H
 #define __LINUX_OF_GRAPH_H
 
+#include <linux/device.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 
@@ -47,6 +48,7 @@ int of_graph_parse_endpoint(const struct device_node *node,
 				struct of_endpoint *endpoint);
 bool of_graph_port_type_is(struct device_node *port, char *type);
 struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
+struct device_node *of_graph_get_top_port(struct device *dev);
 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 					struct device_node *previous);
 struct device_node *of_graph_get_endpoint_by_regs(
@@ -76,6 +78,11 @@ static inline struct device_node *of_graph_get_port_by_id(
 	return NULL;
 }
 
+static inline struct device_node *of_graph_get_top_port(struct device *dev)
+{
+	return NULL;
+}
+
 static inline struct device_node *of_graph_get_next_endpoint(
 					const struct device_node *parent,
 					struct device_node *previous)
-- 
1.9.1

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

* [PATCH v5 06/14] of_graph: add for_each_of_port() / for_each_of_endpoint_in_port()
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2016-11-28  2:46 ` [PATCH v5 05/14] of_graph: add of_graph_get_top_port() Kuninori Morimoto
@ 2016-11-28  2:46 ` Kuninori Morimoto
  2016-11-28  2:46 ` [PATCH v5 07/14] of_graph: add of_graph_get_endpoint_count() Kuninori Morimoto
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:46 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

OF graph is used mainly from V4L2, but ALSA needs to use it. It already
has for_each_endpoint_of_node() which is for-loop for each endpoint.
But, ALSA needs for-loop for each port[s], and for-loop for each
endpoint of inside port[s]. This patch adds for_each_of_port()
and for_each_of_endpoint_in_port() for this purpose.

And it also adds for_each_of_endpoint() which is similar to
for_each_endpoint_of_node(). The difference is it can catch port
handle during for-loop.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/of/base.c        | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/of_graph.h | 29 ++++++++++++++++++++++
 2 files changed, 93 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 8c5080b..705ea15 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2352,6 +2352,70 @@ struct device_node *of_graph_get_top_port(struct device *dev)
 EXPORT_SYMBOL(of_graph_get_top_port);
 
 /**
+ * of_graph_get_next_port() - get next port node
+ * @parent: pointer to the parent device node
+ * @prev: previous endpoint node, or NULL to get first
+ *
+ * Return: An 'endpoint' node pointer with refcount incremented. Refcount
+ * of the passed @prev node is decremented.
+ */
+struct device_node *of_graph_get_next_port(const struct device_node *parent,
+					   struct device_node *prev)
+{
+	struct device_node *port;
+	struct device_node *node;
+
+	if (!parent)
+		return NULL;
+
+	node = of_get_child_by_name(parent, "ports");
+	if (node)
+		parent = node;
+
+	/*
+	 * Start by locating the port node. If no previous endpoint is specified
+	 * search for the first port node, otherwise get the previous endpoint
+	 * parent port node.
+	 */
+	if (!prev) {
+		port = of_get_child_by_name(parent, "port");
+		if (!port)
+			pr_err("%s(): no port node found in %s\n",
+			       __func__, parent->full_name);
+	} else {
+		do {
+			port = of_get_next_child(parent, prev);
+			if (!port)
+				break;
+		} while (of_node_cmp(port->name, "port"));
+	}
+
+	of_node_put(node);
+
+	return port;
+}
+EXPORT_SYMBOL(of_graph_get_next_port);
+
+/**
+ * of_graph_get_next_endpoint_in_port() - get next endpoint node in port
+ * @parent: pointer to the parent device node
+ * @prev: previous endpoint node, or NULL to get first
+ *
+ * Return: An 'endpoint' node pointer with refcount incremented. Refcount
+ * of the passed @prev node is decremented.
+ */
+struct device_node *of_graph_get_next_endpoint_in_port(
+			const struct device_node *port,
+			struct device_node *prev)
+{
+	if (!port)
+		return NULL;
+
+	return of_get_next_child(port, prev);
+}
+EXPORT_SYMBOL(of_graph_get_next_endpoint_in_port);
+
+/**
  * of_graph_get_next_endpoint() - get next endpoint node
  * @parent: pointer to the parent device node
  * @prev: previous endpoint node, or NULL to get first
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 699835a..7f735f8 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -30,6 +30,16 @@ struct of_endpoint {
 	const struct device_node *local_node;
 };
 
+#define for_each_of_port(parent, port) \
+	for (port = of_graph_get_next_port(parent, NULL); port != NULL; \
+	     port = of_graph_get_next_port(parent, port))
+#define for_each_of_endpoint_in_port(port, ep) \
+	for (ep = of_graph_get_next_endpoint_in_port(port, NULL); ep != NULL; \
+	     ep = of_graph_get_next_endpoint_in_port(port, ep))
+#define for_each_of_endpoint(parent, port, ep) \
+	for_each_of_port(parent, port) \
+		for_each_of_endpoint_in_port(port, ep)
+
 /**
  * for_each_endpoint_of_node - iterate over every endpoint in a device node
  * @parent: parent device node containing ports and endpoints
@@ -49,6 +59,11 @@ int of_graph_parse_endpoint(const struct device_node *node,
 bool of_graph_port_type_is(struct device_node *port, char *type);
 struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
 struct device_node *of_graph_get_top_port(struct device *dev);
+struct device_node *of_graph_get_next_port(const struct device_node *parent,
+					struct device_node *prev);
+struct device_node *of_graph_get_next_endpoint_in_port(
+	const struct device_node *port,
+	struct device_node *prev);
 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 					struct device_node *previous);
 struct device_node *of_graph_get_endpoint_by_regs(
@@ -83,6 +98,20 @@ static inline struct device_node *of_graph_get_top_port(struct device *dev)
 	return NULL;
 }
 
+static inline struct device_node *of_graph_get_next_port(
+					const struct device_node *parent,
+					struct device_node *prev)
+{
+	return NULL;
+}
+
+static inline struct device_node *of_graph_get_next_endpoint_in_port(
+					const struct device_node *port,
+					struct device_node *prev)
+{
+	return NULL;
+}
+
 static inline struct device_node *of_graph_get_next_endpoint(
 					const struct device_node *parent,
 					struct device_node *previous)
-- 
1.9.1

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

* [PATCH v5 07/14] of_graph: add of_graph_get_endpoint_count()
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2016-11-28  2:46 ` [PATCH v5 06/14] of_graph: add for_each_of_port() / for_each_of_endpoint_in_port() Kuninori Morimoto
@ 2016-11-28  2:46 ` Kuninori Morimoto
  2016-11-28  2:46 ` [PATCH v5 08/14] ASoC: simple-card-utils: adjust for graph on asoc_simple_card_parse_card_name Kuninori Morimoto
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:46 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

OF graph want to count its endpoint number, same as
of_get_child_count(). This patch adds of_graph_get_endpoint_count()
which can check specific type. It will count all endpoint if type
was NULL.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/of/base.c        | 16 ++++++++++++++++
 include/linux/of_graph.h |  8 ++++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 705ea15..76d2819 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2596,3 +2596,19 @@ bool of_graph_port_type_is(struct device_node *port, char *type)
 	return false;
 }
 EXPORT_SYMBOL(of_graph_port_type_is);
+
+int of_graph_get_endpoint_count(const struct device_node *np, char *type)
+{
+	struct device_node *port, *endpoint;
+	int num = 0;
+
+	for_each_of_endpoint(np, port, endpoint) {
+		if (!type)
+			num++;
+		else
+			num += of_graph_port_type_is(port, type);
+	}
+
+	return num;
+}
+EXPORT_SYMBOL(of_graph_get_endpoint_count);
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 7f735f8..826752f 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -52,11 +52,13 @@ struct of_endpoint {
 	     child = of_graph_get_next_endpoint(parent, child))
 
 #define of_graph_port_type_is_sound(n)		of_graph_port_type_is(n, "sound")
+#define of_graph_get_sound_endpoint_count(n)	of_graph_get_endpoint_count(n, "sound")
 
 #ifdef CONFIG_OF
 int of_graph_parse_endpoint(const struct device_node *node,
 				struct of_endpoint *endpoint);
 bool of_graph_port_type_is(struct device_node *port, char *type);
+int of_graph_get_endpoint_count(const struct device_node *np, char *type);
 struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
 struct device_node *of_graph_get_top_port(struct device *dev);
 struct device_node *of_graph_get_next_port(const struct device_node *parent,
@@ -87,6 +89,12 @@ static bool of_graph_port_type_is(struct device_node *port, char *type)
 	return false;
 }
 
+static inline int of_graph_get_endpoint_count(const struct device_node *np,
+					      char *type)
+{
+	return 0;
+}
+
 static inline struct device_node *of_graph_get_port_by_id(
 					struct device_node *node, u32 id)
 {
-- 
1.9.1

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

* [PATCH v5 08/14] ASoC: simple-card-utils: adjust for graph on asoc_simple_card_parse_card_name
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
                   ` (6 preceding siblings ...)
  2016-11-28  2:46 ` [PATCH v5 07/14] of_graph: add of_graph_get_endpoint_count() Kuninori Morimoto
@ 2016-11-28  2:46 ` Kuninori Morimoto
  2016-11-28  2:47 ` [PATCH v5 09/14] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai() Kuninori Morimoto
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:46 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

It is assuming that the card related information is located on
"card" node, but graph case doesn't have it.
This patch adds node parameter to adjust for graph support

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/simple_card_utils.h     | 1 +
 sound/soc/generic/simple-card-utils.c | 3 ++-
 sound/soc/generic/simple-card.c       | 2 +-
 sound/soc/generic/simple-scu-card.c   | 2 +-
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index fd641255..09750ac 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -32,6 +32,7 @@ int asoc_simple_card_set_dailink_name(struct device *dev,
 				      struct snd_soc_dai_link *dai_link,
 				      const char *fmt, ...);
 int asoc_simple_card_parse_card_name(struct snd_soc_card *card,
+				     struct device_node *node,
 				     char *prefix);
 
 #define asoc_simple_card_parse_clk_cpu(node, dai_link, simple_dai)		\
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 1cb3930..003331e 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -79,6 +79,7 @@ int asoc_simple_card_set_dailink_name(struct device *dev,
 EXPORT_SYMBOL_GPL(asoc_simple_card_set_dailink_name);
 
 int asoc_simple_card_parse_card_name(struct snd_soc_card *card,
+				     struct device_node *node,
 				     char *prefix)
 {
 	char prop[128];
@@ -87,7 +88,7 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card,
 	snprintf(prop, sizeof(prop), "%sname", prefix);
 
 	/* Parse the card name from DT */
-	ret = snd_soc_of_parse_card_name(card, prop);
+	ret = snd_soc_of_parse_card_name_from_node(card, node, prop);
 	if (ret < 0)
 		return ret;
 
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index f608f8d2..342ff53 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -401,7 +401,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 			goto card_parse_end;
 	}
 
-	ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX);
+	ret = asoc_simple_card_parse_card_name(&priv->snd_card, NULL, PREFIX);
 	if (ret < 0)
 		goto card_parse_end;
 
diff --git a/sound/soc/generic/simple-scu-card.c b/sound/soc/generic/simple-scu-card.c
index b9973a5..129dd8f 100644
--- a/sound/soc/generic/simple-scu-card.c
+++ b/sound/soc/generic/simple-scu-card.c
@@ -272,7 +272,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	if (ret < 0)
 		return ret;
 
-	ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX);
+	ret = asoc_simple_card_parse_card_name(&priv->snd_card, NULL, PREFIX);
 	if (ret < 0)
 		return ret;
 
-- 
1.9.1

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

* [PATCH v5 09/14] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai()
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
                   ` (7 preceding siblings ...)
  2016-11-28  2:46 ` [PATCH v5 08/14] ASoC: simple-card-utils: adjust for graph on asoc_simple_card_parse_card_name Kuninori Morimoto
@ 2016-11-28  2:47 ` Kuninori Morimoto
  2016-11-28  3:41   ` kbuild test robot
  2016-11-28  2:47 ` [PATCH v5 10/14] ASoC: simple-card-utils: add asoc_simple_card_try_to_probe_graph_card() Kuninori Morimoto
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:47 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

simple-card already has asoc_simple_card_parse_dai(),
but graph base parsing needs graph specific version of it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/simple_card_utils.h     | 10 +++++++
 sound/soc/generic/simple-card-utils.c | 53 +++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 09750ac..c223f79 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -60,6 +60,16 @@ int asoc_simple_card_parse_dai(struct device_node *node,
 				  const char *cells_name,
 				  int *is_single_links);
 
+#define asoc_simple_card_parse_graph_cpu(ep, dai_link)			\
+	asoc_simple_card_parse_graph_dai(ep, &dai_link->cpu_of_node,	\
+					 &dai_link->cpu_dai_name)
+#define asoc_simple_card_parse_graph_codec(ep, dai_link)		\
+	asoc_simple_card_parse_graph_dai(ep, &dai_link->codec_of_node,	\
+					 &dai_link->codec_dai_name)
+int asoc_simple_card_parse_graph_dai(struct device_node *ep,
+				     struct device_node **endpoint_np,
+				     const char **dai_name);
+
 int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
 			      struct asoc_simple_dai *simple_dai);
 
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 003331e..527944d 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -10,6 +10,7 @@
 #include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 #include <sound/simple_card_utils.h>
 
 int asoc_simple_card_parse_daifmt(struct device *dev,
@@ -165,6 +166,58 @@ int asoc_simple_card_parse_dai(struct device_node *node,
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dai);
 
+int asoc_simple_card_parse_graph_dai(struct device_node *ep,
+				     struct device_node **dai_of_node,
+				     const char **dai_name)
+{
+	struct device_node *node, *port, *endpoint;
+	int i, id;
+
+	if (!ep)
+		return 0;
+
+	/*
+	 * of_graph_get_port_parent() will call
+	 * of_node_put(). So, call of_node_get() here
+	 */
+	of_node_get(ep);
+	node = of_graph_get_port_parent(ep);
+
+	i = 0;
+	id = -1;
+	for_each_of_port(node, port) {
+		if (!of_graph_port_type_is_sound(port))
+			continue;
+
+		for_each_of_endpoint_in_port(port, endpoint) {
+			if (endpoint == ep)
+				id = i;
+			i++;
+		}
+	}
+	if (id < 0)
+		return -ENODEV;
+
+	/* Get dai->name */
+	if (dai_name) {
+		struct of_phandle_args args;
+		int ret;
+
+		args.np		= node;
+		args.args[0]	= id;
+		args.args_count	= (i > 1);
+
+		ret = snd_soc_get_dai_name(&args, dai_name);
+		if (ret < 0)
+			return ret;
+	}
+
+	*dai_of_node = node;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_card_parse_graph_dai);
+
 int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
 			      struct asoc_simple_dai *simple_dai)
 {
-- 
1.9.1

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

* [PATCH v5 10/14] ASoC: simple-card-utils: add asoc_simple_card_try_to_probe_graph_card()
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
                   ` (8 preceding siblings ...)
  2016-11-28  2:47 ` [PATCH v5 09/14] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai() Kuninori Morimoto
@ 2016-11-28  2:47 ` Kuninori Morimoto
  2016-11-28  2:47 ` [PATCH v5 11/14] ASoC: add simple-graph-card document Kuninori Morimoto
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:47 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

If CPU/Platform side driver probes successfully, and if it is supporting
both previous normal sound card style and graph style DT, it can call
asoc_simple_card_try_to_probe_graph_card().
It checks graph style DT, and do nothing if it was non graph style DT,
or register new simple-graph-card driver if graph style DT.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/simple_card_utils.h     |  2 ++
 sound/soc/generic/simple-card-utils.c | 42 +++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index c223f79..276e8e4 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -79,4 +79,6 @@ void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link,
 
 int asoc_simple_card_clean_reference(struct snd_soc_card *card);
 
+void asoc_simple_card_try_to_probe_graph_card(struct device *dev);
+
 #endif /* __SIMPLE_CARD_CORE_H */
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 527944d..fdf7d5e 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 #include <linux/clk.h>
+#include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_graph.h>
@@ -292,6 +293,47 @@ int asoc_simple_card_clean_reference(struct snd_soc_card *card)
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_clean_reference);
 
+void asoc_simple_card_try_to_probe_graph_card(struct device *dev)
+{
+	struct platform_device_info pdevinfo;
+	struct device_node *node;
+	const char *compatible;
+	int ret;
+
+	node = of_graph_get_top_port(dev);
+	if (!node)
+		/*
+		 * It doesn't have graph base sound DT.
+		 * Do nothing here, It assumes that system has
+		 * normal sound card.
+		 */
+		return;
+
+	ret = of_property_read_string(node, "compatible", &compatible);
+	if (ret < 0)
+		goto probe_err;
+
+	/*
+	 * FIXME
+	 *
+	 * It should use of_platform_xxx() instead of
+	 * platform_device_register_full() ? but there is no solution.
+	 * see also
+	 * linux/sound/soc/generic/simple-graph-card.c :: asoc_simple_card_probe
+	 */
+
+	memset(&pdevinfo, 0, sizeof(pdevinfo));
+	pdevinfo.parent		= dev;
+	pdevinfo.id		= PLATFORM_DEVID_AUTO;
+	pdevinfo.name		= compatible;
+	pdevinfo.dma_mask	= DMA_BIT_MASK(32);
+	platform_device_register_full(&pdevinfo);
+
+probe_err:
+	of_node_put(node);
+}
+EXPORT_SYMBOL_GPL(asoc_simple_card_try_to_probe_graph_card);
+
 /* Module information */
 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
 MODULE_DESCRIPTION("ALSA SoC Simple Card Utils");
-- 
1.9.1

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

* [PATCH v5 11/14] ASoC: add simple-graph-card document
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
                   ` (9 preceding siblings ...)
  2016-11-28  2:47 ` [PATCH v5 10/14] ASoC: simple-card-utils: add asoc_simple_card_try_to_probe_graph_card() Kuninori Morimoto
@ 2016-11-28  2:47 ` Kuninori Morimoto
  2016-12-02 13:50   ` Rob Herring
  2016-11-28  2:48 ` [PATCH v5 12/14] ASoC: add simple-graph-card support Kuninori Morimoto
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:47 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 .../bindings/sound/simple-graph-card.txt           | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/simple-graph-card.txt

diff --git a/Documentation/devicetree/bindings/sound/simple-graph-card.txt b/Documentation/devicetree/bindings/sound/simple-graph-card.txt
new file mode 100644
index 0000000..3d4c5a8
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/simple-graph-card.txt
@@ -0,0 +1,67 @@
+Simple-Graph-Card:
+
+Simple-Graph-Card specifies audio DAI connections of SoC <-> codec.
+It is based on common bindings for device graphs.
+see ${LINUX}/Documentation/devicetree/bindings/graph.txt
+
+Basically, Simple-Graph-Card property is same as Simple-Card.
+see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.txt
+
+Below are same as Simple-Card.
+
+- simple-audio-card,name
+- simple-audio-card,widgets
+- simple-audio-card,routing
+- simple-audio-card,mclk-fs
+- simple-audio-card,hp-det-gpio
+- simple-audio-card,mic-det-gpio
+- simple-audio-card,format
+- simple-audio-card,frame-master
+- simple-audio-card,bitclock-master
+- simple-audio-card,bitclock-inversion
+- simple-audio-card,frame-inversion
+- simple-audio-card,mclk-fs
+- simple-audio-card,dai-tdm-slot-num
+- simple-audio-card,dai-tdm-slot-width
+- clocks / system-clock-frequency
+
+In Simple-Graph-Card, above properties need in CPU side port on DT.
+And it needs to have "compatible" property too.
+In addition, CPU side driver needs to call asoc_simple_card_try_to_probe_graph_card().
+It will probe specified Card driver if it could find "compatible" property on port.
+Otherwise, it will do nothing.
+
+Required properties:
+
+- compatible				: "asoc-simple-graph-card";
+- type					: "sound";
+
+Example
+
+ak4643: codec@12 {
+	compatible = "asahi-kasei,ak4643";
+	...
+	port {
+		type = "sound";
+		ak4643_port: endpoint {
+			remote-endpoint = <&rcar_ak4643_port>;
+			...
+		};
+	};
+};
+
+rcar_sound {
+	...
+	port {
+		compatible = "asoc-simple-graph-card";
+
+		simple-audio-card,format = "left_j";
+		simple-audio-card,bitclock-master = <&ak4643_port>;
+		simple-audio-card,frame-master = <&ak4643_port>;
+		type = "sound";
+		rcar_ak4643_port: endpoint {
+			remote-endpoint = <&ak4643_port>;
+			...
+		};
+	};
+};
-- 
1.9.1

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

* [PATCH v5 12/14] ASoC: add simple-graph-card support
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
                   ` (10 preceding siblings ...)
  2016-11-28  2:47 ` [PATCH v5 11/14] ASoC: add simple-graph-card document Kuninori Morimoto
@ 2016-11-28  2:48 ` Kuninori Morimoto
  2016-11-28  4:19   ` kbuild test robot
  2016-11-28  2:48 ` [PATCH v5 13/14] ASoC: add simple-graph-scu-card document Kuninori Morimoto
  2016-11-28  2:48 ` [PATCH v5 14/14] ASoC: add simple-graph-scu-card support Kuninori Morimoto
  13 siblings, 1 reply; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:48 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

graph base DT binding are used on V4L2, and ALSA SoC is using different
style of DT. In case of simple case, ALSA SoC supports simple-card
driver.
In the future, V4L2 / ALSA will support HDMI, and then, DT bindings
between V4L2 / ALSA should be merged somehow.
This patch adds graph base DT binding with simple-card style

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/Kconfig             |   7 +
 sound/soc/generic/Makefile            |   2 +
 sound/soc/generic/simple-graph-card.c | 461 ++++++++++++++++++++++++++++++++++
 3 files changed, 470 insertions(+)
 create mode 100644 sound/soc/generic/simple-graph-card.c

diff --git a/sound/soc/generic/Kconfig b/sound/soc/generic/Kconfig
index d023959..efefabd 100644
--- a/sound/soc/generic/Kconfig
+++ b/sound/soc/generic/Kconfig
@@ -14,3 +14,10 @@ config SND_SIMPLE_SCU_CARD
 	help
 	  This option enables generic simple SCU sound card support.
 	  It supports DPCM of multi CPU single Codec system.
+
+config SND_SIMPLE_GRAPH_CARD
+	tristate "ASoC Simple Graph sound card support"
+	depends on OF
+	select SND_SIMPLE_CARD_UTILS
+	help
+	  This option enables generic simple Graph sound card support
diff --git a/sound/soc/generic/Makefile b/sound/soc/generic/Makefile
index ee750f3..94eb6f1 100644
--- a/sound/soc/generic/Makefile
+++ b/sound/soc/generic/Makefile
@@ -1,7 +1,9 @@
 snd-soc-simple-card-utils-objs	:= simple-card-utils.o
 snd-soc-simple-card-objs	:= simple-card.o
 snd-soc-simple-scu-card-objs	:= simple-scu-card.o
+snd-soc-simple-graph-card-objs	:= simple-graph-card.o
 
 obj-$(CONFIG_SND_SIMPLE_CARD_UTILS)	+= snd-soc-simple-card-utils.o
 obj-$(CONFIG_SND_SIMPLE_CARD)		+= snd-soc-simple-card.o
 obj-$(CONFIG_SND_SIMPLE_SCU_CARD)	+= snd-soc-simple-scu-card.o
+obj-$(CONFIG_SND_SIMPLE_GRAPH_CARD)	+= snd-soc-simple-graph-card.o
diff --git a/sound/soc/generic/simple-graph-card.c b/sound/soc/generic/simple-graph-card.c
new file mode 100644
index 0000000..fd7cddb
--- /dev/null
+++ b/sound/soc/generic/simple-graph-card.c
@@ -0,0 +1,461 @@
+/*
+ * ASoC simple graph sound card support
+ *
+ * Copyright (C) 2016 Renesas Solutions Corp.
+ * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ *
+ * based on ${LINUX}/sound/soc/generic/simple-card.c
+ *
+ * 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.
+ */
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/gpio.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+#include <linux/of_graph.h>
+#include <linux/platform_device.h>
+#include <linux/string.h>
+#include <sound/jack.h>
+#include <sound/simple_card_utils.h>
+
+struct asoc_simple_jack {
+	struct snd_soc_jack jack;
+	struct snd_soc_jack_pin pin;
+	struct snd_soc_jack_gpio gpio;
+};
+
+struct simple_card_data {
+	struct snd_soc_card snd_card;
+	struct simple_dai_props {
+		struct asoc_simple_dai cpu_dai;
+		struct asoc_simple_dai codec_dai;
+		unsigned int mclk_fs;
+	} *dai_props;
+	struct asoc_simple_jack hp_jack;
+	struct asoc_simple_jack mic_jack;
+	struct snd_soc_dai_link *dai_link;
+	unsigned int mclk_fs;
+};
+
+#define simple_priv_to_dev(priv) ((priv)->snd_card.dev)
+#define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + (i))
+#define simple_priv_to_props(priv, i) ((priv)->dai_props + (i))
+
+#define PREFIX	"simple-audio-card,"
+
+#define asoc_simple_card_init_hp(card, node, sjack, prefix)	\
+	asoc_simple_card_init_jack(card, node, sjack, 1, prefix)
+#define asoc_simple_card_init_mic(card, node, sjack, prefix)	\
+	asoc_simple_card_init_jack(card, node, sjack, 0, prefix)
+static int asoc_simple_card_init_jack(struct snd_soc_card *card,
+				      struct device_node *node,
+				      struct asoc_simple_jack *sjack,
+				      int is_hp, char *prefix)
+{
+	enum of_gpio_flags flags;
+	char prop[128];
+	char *pin_name;
+	char *gpio_name;
+	int mask;
+	int det;
+
+	sjack->gpio.gpio = -ENOENT;
+
+	if (is_hp) {
+		snprintf(prop, sizeof(prop), "%shp-det-gpio", prefix);
+		pin_name	= "Headphones";
+		gpio_name	= "Headphone detection";
+		mask		= SND_JACK_HEADPHONE;
+	} else {
+		snprintf(prop, sizeof(prop), "%smic-det-gpio", prefix);
+		pin_name	= "Mic Jack";
+		gpio_name	= "Mic detection";
+		mask		= SND_JACK_MICROPHONE;
+	}
+
+	det = of_get_named_gpio_flags(node, prop, 0, &flags);
+	if (det == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+
+	if (gpio_is_valid(det)) {
+		sjack->pin.pin		= pin_name;
+		sjack->pin.mask		= mask;
+
+		sjack->gpio.name	= gpio_name;
+		sjack->gpio.report	= mask;
+		sjack->gpio.gpio	= det;
+		sjack->gpio.invert	= !!(flags & OF_GPIO_ACTIVE_LOW);
+		sjack->gpio.debounce_time = 150;
+
+		snd_soc_card_jack_new(card, pin_name, mask,
+				      &sjack->jack,
+				      &sjack->pin, 1);
+
+		snd_soc_jack_add_gpios(&sjack->jack, 1,
+				       &sjack->gpio);
+	}
+
+	return 0;
+}
+
+static void asoc_simple_card_remove_jack(struct asoc_simple_jack *sjack)
+{
+	if (gpio_is_valid(sjack->gpio.gpio))
+		snd_soc_jack_free_gpios(&sjack->jack, 1, &sjack->gpio);
+}
+
+static int asoc_simple_card_startup(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
+	struct simple_dai_props *dai_props =
+		simple_priv_to_props(priv, rtd->num);
+	int ret;
+
+	ret = clk_prepare_enable(dai_props->cpu_dai.clk);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(dai_props->codec_dai.clk);
+	if (ret)
+		clk_disable_unprepare(dai_props->cpu_dai.clk);
+
+	return ret;
+}
+
+static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
+	struct simple_dai_props *dai_props =
+		simple_priv_to_props(priv, rtd->num);
+
+	clk_disable_unprepare(dai_props->cpu_dai.clk);
+
+	clk_disable_unprepare(dai_props->codec_dai.clk);
+}
+
+static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
+				      struct snd_pcm_hw_params *params)
+{
+	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 =
+		simple_priv_to_props(priv, rtd->num);
+	unsigned int mclk, mclk_fs = 0;
+	int ret = 0;
+
+	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);
+		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;
+	}
+	return 0;
+err:
+	return ret;
+}
+
+static struct snd_soc_ops asoc_simple_card_ops = {
+	.startup = asoc_simple_card_startup,
+	.shutdown = asoc_simple_card_shutdown,
+	.hw_params = asoc_simple_card_hw_params,
+};
+
+static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
+	struct device *dev = simple_priv_to_dev(priv);
+	struct device *cpu_dev = dev->parent;
+	struct snd_soc_dai *codec = rtd->codec_dai;
+	struct snd_soc_dai *cpu = rtd->cpu_dai;
+	struct snd_soc_card *card = rtd->card;
+	struct simple_dai_props *dai_props =
+		simple_priv_to_props(priv, rtd->num);
+	struct device_node *cpu_port = of_graph_get_top_port(cpu_dev);
+	int ret;
+
+	ret = asoc_simple_card_init_dai(codec, &dai_props->codec_dai);
+	if (ret < 0)
+		return ret;
+
+	ret = asoc_simple_card_init_dai(cpu, &dai_props->cpu_dai);
+	if (ret < 0)
+		return ret;
+
+	ret = asoc_simple_card_init_hp(card, cpu_port, &priv->hp_jack, PREFIX);
+	if (ret < 0)
+		return ret;
+
+	ret = asoc_simple_card_init_mic(card, cpu_port, &priv->hp_jack, PREFIX);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+static int asoc_simple_card_dai_link_of(struct device_node *cpu_ep,
+					struct simple_card_data *priv,
+					int idx)
+{
+	struct device *dev = simple_priv_to_dev(priv);
+	struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx);
+	struct simple_dai_props *dai_props = simple_priv_to_props(priv, idx);
+	struct asoc_simple_dai *cpu_dai = &dai_props->cpu_dai;
+	struct asoc_simple_dai *codec_dai = &dai_props->codec_dai;
+	struct device_node *cpu_port;
+	struct device_node *cpu_remote_ep;
+	struct device_node *codec_ep;
+	int ret;
+
+	codec_ep	= of_graph_get_remote_endpoint(cpu_ep);
+	cpu_remote_ep	= of_graph_get_remote_endpoint(codec_ep);
+
+	if (cpu_ep != cpu_remote_ep) {
+		dev_err(dev, "endpoint parse error\n");
+		ret = -EINVAL;
+		goto dai_link_of_err;
+	}
+
+	cpu_port	= cpu_ep->parent;
+
+	ret = asoc_simple_card_parse_daifmt(dev, cpu_port, codec_ep,
+					    PREFIX, &dai_link->dai_fmt);
+	if (ret < 0)
+		goto dai_link_of_err;
+
+	of_property_read_u32(cpu_port, "mclk-fs", &dai_props->mclk_fs);
+
+	ret = asoc_simple_card_parse_graph_cpu(cpu_ep, dai_link);
+	if (ret < 0)
+		goto dai_link_of_err;
+
+	ret = asoc_simple_card_parse_graph_codec(codec_ep, dai_link);
+	if (ret < 0)
+		goto dai_link_of_err;
+
+	ret = snd_soc_of_parse_tdm_slot(cpu_ep,
+					&cpu_dai->tx_slot_mask,
+					&cpu_dai->rx_slot_mask,
+					&cpu_dai->slots,
+					&cpu_dai->slot_width);
+	if (ret < 0)
+		goto dai_link_of_err;
+
+	ret = snd_soc_of_parse_tdm_slot(codec_ep,
+					&codec_dai->tx_slot_mask,
+					&codec_dai->rx_slot_mask,
+					&codec_dai->slots,
+					&codec_dai->slot_width);
+	if (ret < 0)
+		goto dai_link_of_err;
+
+	ret = asoc_simple_card_parse_clk_cpu(cpu_ep, dai_link, cpu_dai);
+	if (ret < 0)
+		goto dai_link_of_err;
+
+	ret = asoc_simple_card_parse_clk_codec(codec_ep, dai_link, codec_dai);
+	if (ret < 0)
+		goto dai_link_of_err;
+
+	ret = asoc_simple_card_canonicalize_dailink(dai_link);
+	if (ret < 0)
+		goto dai_link_of_err;
+
+	ret = asoc_simple_card_set_dailink_name(dev, dai_link,
+						"%s-%s",
+						dai_link->cpu_dai_name,
+						dai_link->codec_dai_name);
+	if (ret < 0)
+		goto dai_link_of_err;
+
+	dai_link->ops = &asoc_simple_card_ops;
+	dai_link->init = asoc_simple_card_dai_init;
+
+	dev_dbg(dev, "\tname : %s\n", dai_link->stream_name);
+	dev_dbg(dev, "\tformat : %04x\n", dai_link->dai_fmt);
+	dev_dbg(dev, "\tcpu : %s / %d\n",
+		dai_link->cpu_dai_name,
+		dai_props->cpu_dai.sysclk);
+	dev_dbg(dev, "\tcodec : %s / %d\n",
+		dai_link->codec_dai_name,
+		dai_props->codec_dai.sysclk);
+
+	asoc_simple_card_canonicalize_cpu(dai_link,
+					  priv->snd_card.num_links == 1);
+
+dai_link_of_err:
+	of_node_put(codec_ep);
+	of_node_put(cpu_remote_ep);
+
+	return ret;
+}
+
+static int asoc_simple_card_parse_of(struct device_node *node,
+				     struct simple_card_data *priv)
+{
+	struct device *dev = simple_priv_to_dev(priv);
+	struct device *cpu_dev = dev->parent;
+	struct device_node *top_port = of_graph_get_top_port(cpu_dev);
+	struct snd_soc_card *card = &priv->snd_card;
+	struct device_node *port, *ep;
+	int i = 0, ret;
+
+	if (!node)
+		return -EINVAL;
+
+	for_each_of_port(node, port) {
+		if (!of_graph_port_type_is_sound(port))
+			continue;
+
+		/* The off-codec widgets */
+		if (of_property_read_bool(port, PREFIX "widgets")) {
+			ret = snd_soc_of_parse_audio_simple_widgets_from_node(
+				&priv->snd_card,
+				port, PREFIX "widgets");
+			if (ret)
+				return ret;
+		}
+
+		/* DAPM routes */
+		if (of_property_read_bool(port, PREFIX "routing")) {
+			ret = snd_soc_of_parse_audio_routing_from_node(
+				&priv->snd_card,
+				port, PREFIX "routing");
+			if (ret)
+				return ret;
+		}
+
+		/* Factor to mclk, used in hw_params() */
+		of_property_read_u32(port, PREFIX "mclk-fs", &priv->mclk_fs);
+
+		for_each_of_endpoint_in_port(port, ep) {
+			ret = asoc_simple_card_dai_link_of(ep, priv, i);
+			if (ret < 0) {
+				of_node_put(ep);
+				return ret;
+			}
+			i++;
+		}
+	}
+
+	ret = asoc_simple_card_parse_card_name(card, top_port, PREFIX);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static int asoc_simple_card_probe(struct platform_device *pdev)
+{
+	struct simple_card_data *priv;
+	struct snd_soc_dai_link *dai_link;
+	struct simple_dai_props *dai_props;
+	struct device *dev = &pdev->dev;
+	struct device *cpu_dev = pdev->dev.parent;
+	struct device_node *cpu_node = cpu_dev->of_node;
+	int num, ret;
+
+	/* Allocate the private data and the DAI link array */
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	num = of_graph_get_sound_endpoint_count(cpu_node);
+
+	dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
+	dai_link  = devm_kzalloc(dev, sizeof(*dai_link)  * num, GFP_KERNEL);
+	if (!dai_props || !dai_link)
+		return -ENOMEM;
+
+	priv->dai_props			= dai_props;
+	priv->dai_link			= dai_link;
+
+	/* Init snd_soc_card */
+	priv->snd_card.owner		= THIS_MODULE;
+	priv->snd_card.dev		= dev;
+	priv->snd_card.dai_link		= priv->dai_link;
+	priv->snd_card.num_links	= num;
+
+	ret = asoc_simple_card_parse_of(cpu_node, priv);
+	if (ret < 0) {
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "parse error %d\n", ret);
+		goto err;
+	}
+
+	/*
+	 * FIXME
+	 *
+	 * This driver is assuming that it will be called from
+	 * asoc_simple_card_try_to_probe_graph_card() which
+	 * is using platform_device_register_full().
+	 * This means it is not came from DT. But this driver itself
+	 * will be used as part of ALSA SoC (= sound card).
+	 * Because of these background, it might fail in
+	 * snd_pcm_lib_malloc_pages() on .hw_params.
+	 * Because, noone cares its dma_ops, and result of get_dma_ops()
+	 * is based on its architecture.
+	 * So, it should call arch_setup_dma_ops() from somewhere,
+	 * otherwise, for example, ARM is no problem, but ARM64 will be fail.
+	 * But, of_platform_device_xxx() are not good solution today.
+	 * This driver calls it by itself here. Please fixme
+	 * see also
+	 * linux/sound/soc/generic/simple-card-utils.c ::
+	 *	asoc_simple_card_try_to_probe_graph_card()
+	 */
+	of_dma_configure(dev, dev->of_node);
+
+	snd_soc_card_set_drvdata(&priv->snd_card, priv);
+
+	ret = devm_snd_soc_register_card(dev, &priv->snd_card);
+	if (ret >= 0)
+		return ret;
+err:
+	asoc_simple_card_clean_reference(&priv->snd_card);
+
+	return ret;
+}
+
+static int asoc_simple_card_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct simple_card_data *priv = snd_soc_card_get_drvdata(card);
+
+	asoc_simple_card_remove_jack(&priv->hp_jack);
+	asoc_simple_card_remove_jack(&priv->mic_jack);
+
+	return asoc_simple_card_clean_reference(&priv->snd_card);
+}
+
+static struct platform_driver asoc_simple_card = {
+	.driver = {
+		.name = "asoc-simple-graph-card",
+	},
+	.probe = asoc_simple_card_probe,
+	.remove = asoc_simple_card_remove,
+};
+module_platform_driver(asoc_simple_card);
+
+MODULE_ALIAS("platform:asoc-simple-graph-card");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("ASoC Simple Graph Sound Card");
+MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
-- 
1.9.1

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

* [PATCH v5 13/14] ASoC: add simple-graph-scu-card document
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
                   ` (11 preceding siblings ...)
  2016-11-28  2:48 ` [PATCH v5 12/14] ASoC: add simple-graph-card support Kuninori Morimoto
@ 2016-11-28  2:48 ` Kuninori Morimoto
  2016-12-05 22:40   ` Rob Herring
  2016-11-28  2:48 ` [PATCH v5 14/14] ASoC: add simple-graph-scu-card support Kuninori Morimoto
  13 siblings, 1 reply; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:48 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 .../bindings/sound/simple-graph-scu-card.txt       | 69 ++++++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/simple-graph-scu-card.txt

diff --git a/Documentation/devicetree/bindings/sound/simple-graph-scu-card.txt b/Documentation/devicetree/bindings/sound/simple-graph-scu-card.txt
new file mode 100644
index 0000000..b0e46ba
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/simple-graph-scu-card.txt
@@ -0,0 +1,69 @@
+Simple-Graph-SCU-Card:
+
+Simple-Graph-SCU-Card specifies audio DAI connections of SoC <-> codec.
+It is based on common bindings for device graphs.
+see ${LINUX}/Documentation/devicetree/bindings/graph.txt
+
+Basically, Simple-Graph-SCU-Card property is same as Simple-Card / Simple-Graph-Card.
+see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.txt
+    ${LINUX}/Documentation/devicetree/bindings/sound/simple-graph-card.txt
+
+Main difference between Simple-Graph-Card and Simple-Graph-SCU-Card is that
+Simple-Graph-SCU-Card can use multi CPU.
+
+Required properties:
+
+- compatible				: "asoc-simple-graph-scu-card";
+- type					: "sound";
+- simple-audio-card,routing		: see simple-card.txt
+
+Example
+
+ak4643: codec@12 {
+	compatible = "asahi-kasei,ak4643";
+	...
+	port {
+		type = "sound";
+		ak4643_fe: endpoint@0 {
+			remote-endpoint = <&rsnd_fe>;
+			...
+		};
+		ak4643_be: endpoint@1 {
+			remote-endpoint = <&rsnd_be>;
+			...
+		};
+	};
+};
+
+rcar_sound {
+	...
+	ports {
+		compatible = "asoc-simple-graph-scu-card";
+
+		simple-audio-card,name = "graph-sound";
+		simple-audio-card,format = "left_j";
+		simple-audio-card,bitclock-master = <&rsnd_fe>;
+		simple-audio-card,frame-master = <&rsnd_fe>;
+		simple-audio-card,convert-rate = <48000>;
+		simple-audio-card,convert-channels = <2>;
+		simple-audio-card,prefix = "ak4642";
+		simple-audio-card,routing =
+				"ak4642 Playback", "DAI0 Playback",
+				"ak4642 Playback", "DAI1 Playback";
+
+		port@0 {
+			type = "sound";
+			rsnd_fe: endpoint@0 {
+				remote-endpoint = <&ak4643_fe>;
+				...
+			};
+		};
+		port@1 {
+			type = "sound";
+			rsnd_be: endpoint@1 {
+				remote-endpoint = <&ak4643_be>;
+				...
+			};
+		};
+	};
+};
-- 
1.9.1

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

* [PATCH v5 14/14] ASoC: add simple-graph-scu-card support
  2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
                   ` (12 preceding siblings ...)
  2016-11-28  2:48 ` [PATCH v5 13/14] ASoC: add simple-graph-scu-card document Kuninori Morimoto
@ 2016-11-28  2:48 ` Kuninori Morimoto
  2016-11-28  4:36   ` kbuild test robot
  13 siblings, 1 reply; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  2:48 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

graph base DT binding are used on V4L2, and ALSA SoC is using different
style of DT. In case of simple case, ALSA SoC supports simple-card
driver.
In the future, V4L2 / ALSA will support HDMI, and then, DT bindings
between V4L2 / ALSA should be merged somehow.
Sometimes, we would like to use DPCM base simple-card on graph base DT.
This patch adds graph base DT binding of simple-scu-card

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/Kconfig                 |   8 +
 sound/soc/generic/Makefile                |   2 +
 sound/soc/generic/simple-graph-scu-card.c | 441 ++++++++++++++++++++++++++++++
 3 files changed, 451 insertions(+)
 create mode 100644 sound/soc/generic/simple-graph-scu-card.c

diff --git a/sound/soc/generic/Kconfig b/sound/soc/generic/Kconfig
index efefabd..fc11828 100644
--- a/sound/soc/generic/Kconfig
+++ b/sound/soc/generic/Kconfig
@@ -21,3 +21,11 @@ config SND_SIMPLE_GRAPH_CARD
 	select SND_SIMPLE_CARD_UTILS
 	help
 	  This option enables generic simple Graph sound card support
+
+config SND_SIMPLE_GRAPH_SCU_CARD
+	tristate "ASoC Simple Graph SCU sound card support"
+	depends on OF
+	select SND_SIMPLE_CARD_UTILS
+	help
+	  This option enables generic simple Graph SCU sound card support.
+	  It supports DPCM of multi CPU single Codec ststem.
diff --git a/sound/soc/generic/Makefile b/sound/soc/generic/Makefile
index 94eb6f1..fd75b55 100644
--- a/sound/soc/generic/Makefile
+++ b/sound/soc/generic/Makefile
@@ -2,8 +2,10 @@ snd-soc-simple-card-utils-objs	:= simple-card-utils.o
 snd-soc-simple-card-objs	:= simple-card.o
 snd-soc-simple-scu-card-objs	:= simple-scu-card.o
 snd-soc-simple-graph-card-objs	:= simple-graph-card.o
+snd-soc-simple-graph-scu-card-objs	:= simple-graph-scu-card.o
 
 obj-$(CONFIG_SND_SIMPLE_CARD_UTILS)	+= snd-soc-simple-card-utils.o
 obj-$(CONFIG_SND_SIMPLE_CARD)		+= snd-soc-simple-card.o
 obj-$(CONFIG_SND_SIMPLE_SCU_CARD)	+= snd-soc-simple-scu-card.o
 obj-$(CONFIG_SND_SIMPLE_GRAPH_CARD)	+= snd-soc-simple-graph-card.o
+obj-$(CONFIG_SND_SIMPLE_GRAPH_SCU_CARD)	+= snd-soc-simple-graph-scu-card.o
diff --git a/sound/soc/generic/simple-graph-scu-card.c b/sound/soc/generic/simple-graph-scu-card.c
new file mode 100644
index 0000000..f910665
--- /dev/null
+++ b/sound/soc/generic/simple-graph-scu-card.c
@@ -0,0 +1,441 @@
+/*
+ * ASoC simple graph SCU sound card support
+ *
+ * Copyright (C) 2016 Renesas Solutions Corp.
+ * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ *
+ * based on
+ *	${LINUX}/sound/soc/generic/simple-graph-card.c
+ *	${LINUX}/sound/soc/generic/simple-scu-card.c
+ *
+ * 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.
+ */
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/gpio.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+#include <linux/of_graph.h>
+#include <linux/platform_device.h>
+#include <linux/string.h>
+#include <sound/jack.h>
+#include <sound/simple_card_utils.h>
+
+struct simple_card_data {
+	struct snd_soc_card snd_card;
+	struct snd_soc_codec_conf codec_conf;
+	struct asoc_simple_dai *dai_props;
+	struct snd_soc_dai_link *dai_link;
+	u32 convert_rate;
+	u32 convert_channels;
+};
+
+#define simple_priv_to_dev(priv) ((priv)->snd_card.dev)
+#define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + (i))
+#define simple_priv_to_props(priv, i) ((priv)->dai_props + (i))
+
+#define PREFIX	"simple-audio-card,"
+
+static int asoc_simple_card_startup(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
+	struct asoc_simple_dai *dai_props =
+		simple_priv_to_props(priv, rtd->num);
+
+	return clk_prepare_enable(dai_props->clk);
+}
+
+static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
+	struct asoc_simple_dai *dai_props =
+		simple_priv_to_props(priv, rtd->num);
+
+	clk_disable_unprepare(dai_props->clk);
+}
+
+static struct snd_soc_ops asoc_simple_card_ops = {
+	.startup = asoc_simple_card_startup,
+	.shutdown = asoc_simple_card_shutdown,
+};
+
+static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
+	struct snd_soc_dai *dai;
+	struct snd_soc_dai_link *dai_link;
+	struct asoc_simple_dai *dai_props;
+	int num = rtd->num;
+
+	dai_link	= simple_priv_to_link(priv, num);
+	dai_props	= simple_priv_to_props(priv, num);
+	dai		= dai_link->dynamic ?
+				rtd->cpu_dai :
+				rtd->codec_dai;
+
+	return asoc_simple_card_init_dai(dai, dai_props);
+}
+
+static int asoc_simple_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+					       struct snd_pcm_hw_params *params)
+{
+	struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
+	struct snd_interval *rate = hw_param_interval(params,
+						      SNDRV_PCM_HW_PARAM_RATE);
+	struct snd_interval *channels = hw_param_interval(params,
+							  SNDRV_PCM_HW_PARAM_CHANNELS);
+
+	if (priv->convert_rate)
+		rate->min =
+		rate->max = priv->convert_rate;
+
+	if (priv->convert_channels)
+		channels->min =
+		channels->max = priv->convert_channels;
+
+	return 0;
+}
+
+static int asoc_simple_card_dai_link_of(struct device_node *port,
+					struct device_node *ep,
+					struct simple_card_data *priv,
+					unsigned int daifmt,
+					int idx, int is_fe)
+{
+	struct device *dev = simple_priv_to_dev(priv);
+	struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx);
+	struct asoc_simple_dai *dai_props = simple_priv_to_props(priv, idx);
+	int ret;
+
+	if (is_fe) {
+		/* BE is dummy */
+		dai_link->codec_of_node		= NULL;
+		dai_link->codec_dai_name	= "snd-soc-dummy-dai";
+		dai_link->codec_name		= "snd-soc-dummy";
+
+		/* FE settings */
+		dai_link->dynamic		= 1;
+		dai_link->dpcm_merged_format	= 1;
+
+		ret = asoc_simple_card_parse_graph_cpu(ep, dai_link);
+		if (ret)
+			return ret;
+
+		ret = asoc_simple_card_parse_clk_cpu(ep, dai_link, dai_props);
+		if (ret < 0)
+			return ret;
+
+		ret = asoc_simple_card_set_dailink_name(dev, dai_link,
+							"fe.%s",
+							dai_link->cpu_dai_name);
+		if (ret < 0)
+			return ret;
+
+		/* snd_card.num_links includes Codec */
+		asoc_simple_card_canonicalize_cpu(dai_link,
+					(priv->snd_card.num_links - 1) == 1);
+	} else {
+		/* FE is dummy */
+		dai_link->cpu_of_node		= NULL;
+		dai_link->cpu_dai_name		= "snd-soc-dummy-dai";
+		dai_link->cpu_name		= "snd-soc-dummy";
+
+		/* BE settings */
+		dai_link->no_pcm		= 1;
+		dai_link->be_hw_params_fixup	= asoc_simple_card_be_hw_params_fixup;
+
+		ret = asoc_simple_card_parse_graph_codec(ep, dai_link);
+		if (ret < 0)
+			return ret;
+
+		ret = asoc_simple_card_parse_clk_codec(ep, dai_link, dai_props);
+		if (ret < 0)
+			return ret;
+
+		ret = asoc_simple_card_set_dailink_name(dev, dai_link,
+							"be.%s",
+							dai_link->codec_dai_name);
+		if (ret < 0)
+			return ret;
+
+		snd_soc_of_parse_audio_prefix_from_node(&priv->snd_card,
+							port->parent,
+							&priv->codec_conf,
+							dai_link->codec_of_node,
+							PREFIX "prefix");
+	}
+
+	ret = snd_soc_of_parse_tdm_slot(ep,
+					&dai_props->tx_slot_mask,
+					&dai_props->rx_slot_mask,
+					&dai_props->slots,
+					&dai_props->slot_width);
+	if (ret)
+		return ret;
+
+	ret = asoc_simple_card_canonicalize_dailink(dai_link);
+	if (ret < 0)
+		return ret;
+
+	dai_link->dai_fmt		= daifmt;
+	dai_link->dpcm_playback		= 1;
+	dai_link->dpcm_capture		= 1;
+	dai_link->ops			= &asoc_simple_card_ops;
+	dai_link->init			= asoc_simple_card_dai_init;
+
+	dev_dbg(dev, "\t%s / %04x / %d\n",
+		dai_link->name,
+		dai_link->dai_fmt,
+		dai_props->sysclk);
+
+	return 0;
+}
+
+static int asoc_simple_card_parse_of(struct device_node *node,
+				     struct simple_card_data *priv)
+{
+	struct device *dev = simple_priv_to_dev(priv);
+	struct device *cpu_dev = dev->parent;
+	struct device_node *ports = of_graph_get_top_port(cpu_dev);
+	struct snd_soc_card *card = &priv->snd_card;
+	struct device_node *port, *cpu_ep, *r_cpu_ep, *codec_ep;
+	unsigned int daifmt = 0;
+	int i, ret, done;
+
+	if (!node)
+		return -EINVAL;
+
+	ret = snd_soc_of_parse_audio_routing_from_node(&priv->snd_card,
+						       ports, PREFIX "routing");
+	if (ret)
+		return ret;
+
+	/* sampling rate convert */
+	of_property_read_u32(ports, PREFIX "convert-rate",
+			     &priv->convert_rate);
+
+	/* channels transfer */
+	of_property_read_u32(ports, PREFIX "convert-channels",
+			     &priv->convert_channels);
+
+	/*
+	 * it supports multi CPU, single CODEC only here.
+	 */
+
+	/* find 1st codec */
+	done = 0;
+	for_each_of_port(node, port) {
+		/* keep for_each for of_node_get/of_node_put */
+		if (done)
+			continue;
+
+		if (!of_graph_port_type_is_sound(port))
+			continue;
+
+		for_each_of_endpoint_in_port(port, cpu_ep) {
+			/* keep for_each for of_node_get/of_node_put */
+			if (done)
+				continue;
+
+			codec_ep = of_graph_get_remote_endpoint(cpu_ep);
+			r_cpu_ep = of_graph_get_remote_endpoint(codec_ep);
+			of_node_put(codec_ep);
+			of_node_put(r_cpu_ep);
+			if (cpu_ep != r_cpu_ep) {
+				ret = -EINVAL;
+				goto parse_of_err;
+			}
+
+			ret = asoc_simple_card_parse_daifmt(dev,
+							    ports, codec_ep,
+							    PREFIX, &daifmt);
+			if (ret < 0)
+				goto parse_of_err;
+
+			done = 1;
+		}
+	}
+
+	/* Front-End (= CPU) */
+	i = 0;
+	for_each_of_port(node, port) {
+		if (!of_graph_port_type_is_sound(port))
+			continue;
+
+		for_each_of_endpoint_in_port(port, cpu_ep) {
+			ret = asoc_simple_card_dai_link_of(
+				port, cpu_ep, priv, daifmt, i, 1);
+			if (ret < 0)
+				goto parse_of_err;
+			i++;
+		}
+	}
+
+	/* Back-End (= Codec) */
+	done = 0;
+	for_each_of_port(node, port) {
+		if (!of_graph_port_type_is_sound(port))
+			continue;
+
+		/* keep for_each for of_node_get/of_node_put */
+		if (done)
+			continue;
+
+		for_each_of_endpoint_in_port(port, cpu_ep) {
+			/* keep for_each for of_node_get/of_node_put */
+			if (done)
+				continue;
+
+			codec_ep = of_graph_get_remote_endpoint(cpu_ep);
+			r_cpu_ep = of_graph_get_remote_endpoint(codec_ep);
+			of_node_put(codec_ep);
+			of_node_put(r_cpu_ep);
+			if (cpu_ep != r_cpu_ep) {
+				ret = -EINVAL;
+				goto parse_of_err;
+			}
+
+			ret = asoc_simple_card_dai_link_of(
+				port, codec_ep, priv, daifmt, i, 0);
+			if (ret < 0)
+				goto parse_of_err;
+			i++;
+
+			done = 1;
+		}
+	}
+
+	ret = asoc_simple_card_parse_card_name(card, ports, PREFIX);
+	if (ret)
+		return ret;
+
+	dev_dbg(dev, "New card: %s\n",
+		priv->snd_card.name ? priv->snd_card.name : "");
+	dev_dbg(dev, "convert_rate     %d\n", priv->convert_rate);
+	dev_dbg(dev, "convert_channels %d\n", priv->convert_channels);
+
+	return 0;
+parse_of_err:
+	of_node_put(port);
+	of_node_put(cpu_ep);
+
+	return ret;
+}
+
+static int asoc_get_sound_port_count(struct device_node *cpu_node)
+{
+	int num;
+
+	/*
+	 * it supports multi CPU, single CODEC only here.
+	 */
+
+	/* CPU */
+	num = of_graph_get_sound_endpoint_count(cpu_node);
+
+	/* Codec */
+	num++;
+
+	return num;
+}
+
+static int asoc_simple_card_probe(struct platform_device *pdev)
+{
+	struct simple_card_data *priv;
+	struct snd_soc_dai_link *dai_link;
+	struct asoc_simple_dai *dai_props;
+	struct device *dev = &pdev->dev;
+	struct device *cpu_dev = pdev->dev.parent;
+	struct device_node *cpu_node = cpu_dev->of_node;
+	int num, ret;
+
+	/* Allocate the private data and the DAI link array */
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	num = asoc_get_sound_port_count(cpu_node);
+
+	dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
+	dai_link  = devm_kzalloc(dev, sizeof(*dai_link)  * num, GFP_KERNEL);
+	if (!dai_props || !dai_link)
+		return -ENOMEM;
+
+	priv->dai_props			= dai_props;
+	priv->dai_link			= dai_link;
+
+	/* Init snd_soc_card */
+	priv->snd_card.owner		= THIS_MODULE;
+	priv->snd_card.dev		= dev;
+	priv->snd_card.dai_link		= priv->dai_link;
+	priv->snd_card.num_links	= num;
+	priv->snd_card.codec_conf	= &priv->codec_conf;
+	priv->snd_card.num_configs	= 1;
+
+	ret = asoc_simple_card_parse_of(cpu_node, priv);
+	if (ret < 0) {
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "parse error %d\n", ret);
+		goto err;
+	}
+
+	/*
+	 * FIXME
+	 *
+	 * This driver is assuming that it will be called from
+	 * asoc_simple_card_try_to_probe_graph_card() which
+	 * is using platform_device_register_full().
+	 * This means it is not came from DT. But this driver itself
+	 * will be used as part of ALSA SoC (= sound card).
+	 * Because of these background, it might fail in
+	 * snd_pcm_lib_malloc_pages() on .hw_params.
+	 * Because, noone cares its dma_ops, and result of get_dma_ops()
+	 * is based on its architecture.
+	 * So, it should call arch_setup_dma_ops() from somewhere,
+	 * otherwise, for example, ARM is no problem, but ARM64 will be fail.
+	 * But, of_platform_device_xxx() are not good solution today.
+	 * This driver calls it by itself here. Please fixme
+	 * see also
+	 * linux/sound/soc/generic/simple-card-utils.c ::
+	 *	asoc_simple_card_try_to_probe_graph_card()
+	 */
+	of_dma_configure(dev, dev->of_node);
+
+	snd_soc_card_set_drvdata(&priv->snd_card, priv);
+
+	ret = devm_snd_soc_register_card(dev, &priv->snd_card);
+	if (ret >= 0)
+		return ret;
+err:
+	asoc_simple_card_clean_reference(&priv->snd_card);
+
+	return ret;
+}
+
+static int asoc_simple_card_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct simple_card_data *priv = snd_soc_card_get_drvdata(card);
+
+	return asoc_simple_card_clean_reference(&priv->snd_card);
+}
+
+static struct platform_driver asoc_simple_card = {
+	.driver = {
+		.name = "asoc-simple-graph-scu-card",
+	},
+	.probe = asoc_simple_card_probe,
+	.remove = asoc_simple_card_remove,
+};
+module_platform_driver(asoc_simple_card);
+
+MODULE_ALIAS("platform:asoc-simple-graph-scu-card");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("ASoC Simple Graph SCU Sound Card");
+MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
-- 
1.9.1

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

* Re: [PATCH v5 09/14] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai()
  2016-11-28  2:47 ` [PATCH v5 09/14] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai() Kuninori Morimoto
@ 2016-11-28  3:41   ` kbuild test robot
  2016-11-28  4:10     ` Kuninori Morimoto
  0 siblings, 1 reply; 31+ messages in thread
From: kbuild test robot @ 2016-11-28  3:41 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: kbuild-all, Rob Herring, Mark Brown, Linux-ALSA, Liam Girdwood,
	Simon, Laurent, Guennadi, Grant Likely, Frank Rowand, Linux-DT,
	Linux-Kernel

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

Hi Kuninori,

[auto build test ERROR on robh/for-next]
[also build test ERROR on v4.9-rc7]
[cannot apply to glikely/devicetree/next asoc/for-next next-20161125]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/ASoC-add-OF-graph-base-simple-card/20161128-111639
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: i386-randconfig-x002-201648 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   sound/soc/generic/simple-card-utils.c: In function 'asoc_simple_card_parse_card_name':
   sound/soc/generic/simple-card-utils.c:92:8: error: implicit declaration of function 'snd_soc_of_parse_card_name_from_node' [-Werror=implicit-function-declaration]
     ret = snd_soc_of_parse_card_name_from_node(card, node, prop);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   sound/soc/generic/simple-card-utils.c: In function 'asoc_simple_card_parse_graph_dai':
>> sound/soc/generic/simple-card-utils.c:210:9: error: implicit declaration of function 'snd_soc_get_dai_name' [-Werror=implicit-function-declaration]
      ret = snd_soc_get_dai_name(&args, dai_name);
            ^~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/snd_soc_get_dai_name +210 sound/soc/generic/simple-card-utils.c

    86		char prop[128];
    87		int ret;
    88	
    89		snprintf(prop, sizeof(prop), "%sname", prefix);
    90	
    91		/* Parse the card name from DT */
  > 92		ret = snd_soc_of_parse_card_name_from_node(card, node, prop);
    93		if (ret < 0)
    94			return ret;
    95	
    96		if (!card->name && card->dai_link)
    97			card->name = card->dai_link->name;
    98	
    99		return 0;
   100	}
   101	EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name);
   102	
   103	int asoc_simple_card_parse_clk(struct device_node *node,
   104				       struct device_node *dai_of_node,
   105				       struct asoc_simple_dai *simple_dai)
   106	{
   107		struct clk *clk;
   108		u32 val;
   109	
   110		/*
   111		 * Parse dai->sysclk come from "clocks = <&xxx>"
   112		 * (if system has common clock)
   113		 *  or "system-clock-frequency = <xxx>"
   114		 *  or device's module clock.
   115		 */
   116		clk = of_clk_get(node, 0);
   117		if (!IS_ERR(clk)) {
   118			simple_dai->sysclk = clk_get_rate(clk);
   119			simple_dai->clk = clk;
   120		} else if (!of_property_read_u32(node, "system-clock-frequency", &val)) {
   121			simple_dai->sysclk = val;
   122		} else {
   123			clk = of_clk_get(dai_of_node, 0);
   124			if (!IS_ERR(clk))
   125				simple_dai->sysclk = clk_get_rate(clk);
   126		}
   127	
   128		return 0;
   129	}
   130	EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk);
   131	
   132	int asoc_simple_card_parse_dai(struct device_node *node,
   133					    struct device_node **dai_of_node,
   134					    const char **dai_name,
   135					    const char *list_name,
   136					    const char *cells_name,
   137					    int *is_single_link)
   138	{
   139		struct of_phandle_args args;
   140		int ret;
   141	
   142		if (!node)
   143			return 0;
   144	
   145		/*
   146		 * Get node via "sound-dai = <&phandle port>"
   147		 * it will be used as xxx_of_node on soc_bind_dai_link()
   148		 */
   149		ret = of_parse_phandle_with_args(node, list_name, cells_name, 0, &args);
   150		if (ret)
   151			return ret;
   152	
   153		/* Get dai->name */
   154		if (dai_name) {
   155			ret = snd_soc_of_get_dai_name(node, dai_name);
   156			if (ret < 0)
   157				return ret;
   158		}
   159	
   160		*dai_of_node = args.np;
   161	
   162		if (is_single_link)
   163			*is_single_link = !args.args_count;
   164	
   165		return 0;
   166	}
   167	EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dai);
   168	
   169	int asoc_simple_card_parse_graph_dai(struct device_node *ep,
   170					     struct device_node **dai_of_node,
   171					     const char **dai_name)
   172	{
   173		struct device_node *node, *port, *endpoint;
   174		int i, id;
   175	
   176		if (!ep)
   177			return 0;
   178	
   179		/*
   180		 * of_graph_get_port_parent() will call
   181		 * of_node_put(). So, call of_node_get() here
   182		 */
   183		of_node_get(ep);
   184		node = of_graph_get_port_parent(ep);
   185	
   186		i = 0;
   187		id = -1;
   188		for_each_of_port(node, port) {
   189			if (!of_graph_port_type_is_sound(port))
   190				continue;
   191	
   192			for_each_of_endpoint_in_port(port, endpoint) {
   193				if (endpoint == ep)
   194					id = i;
   195				i++;
   196			}
   197		}
   198		if (id < 0)
   199			return -ENODEV;
   200	
   201		/* Get dai->name */
   202		if (dai_name) {
   203			struct of_phandle_args args;
   204			int ret;
   205	
   206			args.np		= node;
   207			args.args[0]	= id;
   208			args.args_count	= (i > 1);
   209	
 > 210			ret = snd_soc_get_dai_name(&args, dai_name);
   211			if (ret < 0)
   212				return ret;
   213		}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32707 bytes --]

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

* Re: [PATCH v5 09/14] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai()
  2016-11-28  3:41   ` kbuild test robot
@ 2016-11-28  4:10     ` Kuninori Morimoto
  0 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-11-28  4:10 UTC (permalink / raw)
  To: kbuild test robot
  Cc: kbuild-all, Rob Herring, Mark Brown, Linux-ALSA, Liam Girdwood,
	Simon, Laurent, Guennadi, Grant Likely, Frank Rowand, Linux-DT,
	Linux-Kernel


Hi

> [auto build test ERROR on robh/for-next]
> [also build test ERROR on v4.9-rc7]
> [cannot apply to glikely/devicetree/next asoc/for-next next-20161125]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> 
> url:    https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/ASoC-add-OF-graph-base-simple-card/20161128-111639
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
> config: i386-randconfig-x002-201648 (attached as .config)
> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=i386 

I didn't indicate, but, this patch-set is based on Mark's this branch

	git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git :: topic/of-graph

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH v5 12/14] ASoC: add simple-graph-card support
  2016-11-28  2:48 ` [PATCH v5 12/14] ASoC: add simple-graph-card support Kuninori Morimoto
@ 2016-11-28  4:19   ` kbuild test robot
  0 siblings, 0 replies; 31+ messages in thread
From: kbuild test robot @ 2016-11-28  4:19 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: kbuild-all, Rob Herring, Mark Brown, Linux-ALSA, Liam Girdwood,
	Simon, Laurent, Guennadi, Grant Likely, Frank Rowand, Linux-DT,
	Linux-Kernel

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

Hi Kuninori,

[auto build test ERROR on robh/for-next]
[also build test ERROR on v4.9-rc7]
[cannot apply to glikely/devicetree/next asoc/for-next next-20161125]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/ASoC-add-OF-graph-base-simple-card/20161128-111639
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   sound/soc/generic/simple-graph-card.c: In function 'asoc_simple_card_parse_of':
>> sound/soc/generic/simple-graph-card.c:331:10: error: implicit declaration of function 'snd_soc_of_parse_audio_simple_widgets_from_node' [-Werror=implicit-function-declaration]
       ret = snd_soc_of_parse_audio_simple_widgets_from_node(
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> sound/soc/generic/simple-graph-card.c:340:10: error: implicit declaration of function 'snd_soc_of_parse_audio_routing_from_node' [-Werror=implicit-function-declaration]
       ret = snd_soc_of_parse_audio_routing_from_node(
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/snd_soc_of_parse_audio_simple_widgets_from_node +331 sound/soc/generic/simple-graph-card.c

   325		for_each_of_port(node, port) {
   326			if (!of_graph_port_type_is_sound(port))
   327				continue;
   328	
   329			/* The off-codec widgets */
   330			if (of_property_read_bool(port, PREFIX "widgets")) {
 > 331				ret = snd_soc_of_parse_audio_simple_widgets_from_node(
   332					&priv->snd_card,
   333					port, PREFIX "widgets");
   334				if (ret)
   335					return ret;
   336			}
   337	
   338			/* DAPM routes */
   339			if (of_property_read_bool(port, PREFIX "routing")) {
 > 340				ret = snd_soc_of_parse_audio_routing_from_node(
   341					&priv->snd_card,
   342					port, PREFIX "routing");
   343				if (ret)

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 56831 bytes --]

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

* Re: [PATCH v5 14/14] ASoC: add simple-graph-scu-card support
  2016-11-28  2:48 ` [PATCH v5 14/14] ASoC: add simple-graph-scu-card support Kuninori Morimoto
@ 2016-11-28  4:36   ` kbuild test robot
  0 siblings, 0 replies; 31+ messages in thread
From: kbuild test robot @ 2016-11-28  4:36 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: kbuild-all, Rob Herring, Mark Brown, Linux-ALSA, Liam Girdwood,
	Simon, Laurent, Guennadi, Grant Likely, Frank Rowand, Linux-DT,
	Linux-Kernel

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

Hi Kuninori,

[auto build test ERROR on robh/for-next]
[also build test ERROR on v4.9-rc7]
[cannot apply to glikely/devicetree/next asoc/for-next next-20161125]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/ASoC-add-OF-graph-base-simple-card/20161128-111639
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   sound/soc/generic/simple-graph-scu-card.c: In function 'asoc_simple_card_dai_link_of':
>> sound/soc/generic/simple-graph-scu-card.c:167:3: error: implicit declaration of function 'snd_soc_of_parse_audio_prefix_from_node' [-Werror=implicit-function-declaration]
      snd_soc_of_parse_audio_prefix_from_node(&priv->snd_card,
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   sound/soc/generic/simple-graph-scu-card.c: In function 'asoc_simple_card_parse_of':
>> sound/soc/generic/simple-graph-scu-card.c:214:8: error: implicit declaration of function 'snd_soc_of_parse_audio_routing_from_node' [-Werror=implicit-function-declaration]
     ret = snd_soc_of_parse_audio_routing_from_node(&priv->snd_card,
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/snd_soc_of_parse_audio_prefix_from_node +167 sound/soc/generic/simple-graph-scu-card.c

   161			ret = asoc_simple_card_set_dailink_name(dev, dai_link,
   162								"be.%s",
   163								dai_link->codec_dai_name);
   164			if (ret < 0)
   165				return ret;
   166	
 > 167			snd_soc_of_parse_audio_prefix_from_node(&priv->snd_card,
   168								port->parent,
   169								&priv->codec_conf,
   170								dai_link->codec_of_node,
   171								PREFIX "prefix");
   172		}
   173	
   174		ret = snd_soc_of_parse_tdm_slot(ep,
   175						&dai_props->tx_slot_mask,
   176						&dai_props->rx_slot_mask,
   177						&dai_props->slots,
   178						&dai_props->slot_width);
   179		if (ret)
   180			return ret;
   181	
   182		ret = asoc_simple_card_canonicalize_dailink(dai_link);
   183		if (ret < 0)
   184			return ret;
   185	
   186		dai_link->dai_fmt		= daifmt;
   187		dai_link->dpcm_playback		= 1;
   188		dai_link->dpcm_capture		= 1;
   189		dai_link->ops			= &asoc_simple_card_ops;
   190		dai_link->init			= asoc_simple_card_dai_init;
   191	
   192		dev_dbg(dev, "\t%s / %04x / %d\n",
   193			dai_link->name,
   194			dai_link->dai_fmt,
   195			dai_props->sysclk);
   196	
   197		return 0;
   198	}
   199	
   200	static int asoc_simple_card_parse_of(struct device_node *node,
   201					     struct simple_card_data *priv)
   202	{
   203		struct device *dev = simple_priv_to_dev(priv);
   204		struct device *cpu_dev = dev->parent;
   205		struct device_node *ports = of_graph_get_top_port(cpu_dev);
   206		struct snd_soc_card *card = &priv->snd_card;
   207		struct device_node *port, *cpu_ep, *r_cpu_ep, *codec_ep;
   208		unsigned int daifmt = 0;
   209		int i, ret, done;
   210	
   211		if (!node)
   212			return -EINVAL;
   213	
 > 214		ret = snd_soc_of_parse_audio_routing_from_node(&priv->snd_card,
   215							       ports, PREFIX "routing");
   216		if (ret)
   217			return ret;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 56833 bytes --]

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

* Re: [PATCH v5 01/14] Documentation: of: add type property
  2016-11-28  2:44 ` [PATCH v5 01/14] Documentation: of: add type property Kuninori Morimoto
@ 2016-12-01 16:26   ` Rob Herring
  2016-12-08  1:57     ` Kuninori Morimoto
  0 siblings, 1 reply; 31+ messages in thread
From: Rob Herring @ 2016-12-01 16:26 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel

On Mon, Nov 28, 2016 at 02:44:46AM +0000, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> OF graph indicates each devices connection. But it doesn't support type
> of each port. For example HDMI case, it has video port and sound port
> in one device node.
> In this case, current driver can't handle each port correctly.
> This patch enables to use type property on OF graph.

I still don't think this is necessary. Simply define which port number 
is which for each HDMI chip.

If this is necessary, then the types, video and sound, are too generic.

> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  Documentation/devicetree/bindings/graph.txt | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)

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

* Re: [PATCH v5 11/14] ASoC: add simple-graph-card document
  2016-11-28  2:47 ` [PATCH v5 11/14] ASoC: add simple-graph-card document Kuninori Morimoto
@ 2016-12-02 13:50   ` Rob Herring
  2016-12-04 23:48     ` Kuninori Morimoto
  2016-12-05  2:21     ` Kuninori Morimoto
  0 siblings, 2 replies; 31+ messages in thread
From: Rob Herring @ 2016-12-02 13:50 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel

On Mon, Nov 28, 2016 at 02:47:57AM +0000, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  .../bindings/sound/simple-graph-card.txt           | 67 ++++++++++++++++++++++
>  1 file changed, 67 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/simple-graph-card.txt
> 
> diff --git a/Documentation/devicetree/bindings/sound/simple-graph-card.txt b/Documentation/devicetree/bindings/sound/simple-graph-card.txt
> new file mode 100644
> index 0000000..3d4c5a8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/simple-graph-card.txt
> @@ -0,0 +1,67 @@
> +Simple-Graph-Card:

There's nothing simple about this. graph-audio-card or audio-card-graph.

> +
> +Simple-Graph-Card specifies audio DAI connections of SoC <-> codec.
> +It is based on common bindings for device graphs.
> +see ${LINUX}/Documentation/devicetree/bindings/graph.txt
> +
> +Basically, Simple-Graph-Card property is same as Simple-Card.
> +see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.txt
> +
> +Below are same as Simple-Card.
> +
> +- simple-audio-card,name
> +- simple-audio-card,widgets
> +- simple-audio-card,routing
> +- simple-audio-card,mclk-fs
> +- simple-audio-card,hp-det-gpio
> +- simple-audio-card,mic-det-gpio
> +- simple-audio-card,format
> +- simple-audio-card,frame-master
> +- simple-audio-card,bitclock-master
> +- simple-audio-card,bitclock-inversion
> +- simple-audio-card,frame-inversion
> +- simple-audio-card,mclk-fs
> +- simple-audio-card,dai-tdm-slot-num
> +- simple-audio-card,dai-tdm-slot-width

The simple-audio-card prefix is pointless. It's fine to reuse, but don't 
add to it.

> +- clocks / system-clock-frequency
> +
> +In Simple-Graph-Card, above properties need in CPU side port on DT.
> +And it needs to have "compatible" property too.
> +In addition, CPU side driver needs to call asoc_simple_card_try_to_probe_graph_card().
> +It will probe specified Card driver if it could find "compatible" property on port.
> +Otherwise, it will do nothing.
> +
> +Required properties:
> +
> +- compatible				: "asoc-simple-graph-card";
> +- type					: "sound";
> +
> +Example
> +
> +ak4643: codec@12 {
> +	compatible = "asahi-kasei,ak4643";
> +	...
> +	port {
> +		type = "sound";
> +		ak4643_port: endpoint {
> +			remote-endpoint = <&rcar_ak4643_port>;
> +			...
> +		};
> +	};
> +};
> +
> +rcar_sound {
> +	...
> +	port {
> +		compatible = "asoc-simple-graph-card";

Do you have an example where you'd have multiple ports? If not, this 
should go up a level.

> +
> +		simple-audio-card,format = "left_j";
> +		simple-audio-card,bitclock-master = <&ak4643_port>;
> +		simple-audio-card,frame-master = <&ak4643_port>;

If you follow video-interfaces.txt, these should all go in the endpoint 
node.

> +		type = "sound";
> +		rcar_ak4643_port: endpoint {
> +			remote-endpoint = <&ak4643_port>;
> +			...
> +		};
> +	};
> +};
> -- 
> 1.9.1
> 

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

* Re: [PATCH v5 11/14] ASoC: add simple-graph-card document
  2016-12-02 13:50   ` Rob Herring
@ 2016-12-04 23:48     ` Kuninori Morimoto
  2016-12-05  2:38       ` Kuninori Morimoto
  2016-12-05 22:58       ` Rob Herring
  2016-12-05  2:21     ` Kuninori Morimoto
  1 sibling, 2 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-12-04 23:48 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Brown, Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


Hi Rob, Mark

> > +++ b/Documentation/devicetree/bindings/sound/simple-graph-card.txt
> > @@ -0,0 +1,67 @@
> > +Simple-Graph-Card:
> 
> There's nothing simple about this. graph-audio-card or audio-card-graph.

I have no objection about naming, but this is one of simple-xxx-card series.
And, this is very simple from ALSA SoC point of view...

> > +rcar_sound {
> > +	...
> > +	port {
> > +		compatible = "asoc-simple-graph-card";
> 
> Do you have an example where you'd have multiple ports? If not, this 
> should go up a level.

ALSA SoC needs 3 type of driver, CPU/Codec/Card. But HW is SoC <-> Codec.
Thus, "CPU" side DT needs to call "Card" portion, and ALSA SoC needs to
select Card type (graph-audio-card, graph-scu-card, etc, etc....).
Above it for it.

	SoC {
		compatible = "cpu_driver_compatible_name";
		...
		port {
			compatible = "card_driver_compatible_name";
			...
		};
	};

Here, SoC driver "cpu_driver_compatible_name" will handle CPU and its
each port settings. And it will probes "card_driver_compatible_name".
"card_driver_compatible_name" will connect CPU <-> Codec via ALSA SoC.

> > +		simple-audio-card,format = "left_j";
> > +		simple-audio-card,bitclock-master = <&ak4643_port>;
> > +		simple-audio-card,frame-master = <&ak4643_port>;
> 
> If you follow video-interfaces.txt, these should all go in the endpoint 
> node.

Hmm... this is not for endpoint, but for whole card.
Mark, of course this can goes to each endpoint, but it negates passed
ALSA SoC Card discussion/decision. What is your opinion ?

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

* Re: [PATCH v5 11/14] ASoC: add simple-graph-card document
  2016-12-02 13:50   ` Rob Herring
  2016-12-04 23:48     ` Kuninori Morimoto
@ 2016-12-05  2:21     ` Kuninori Morimoto
  1 sibling, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-12-05  2:21 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Brown, Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


Hi Rob again

> > +Below are same as Simple-Card.
> > +
> > +- simple-audio-card,name
> > +- simple-audio-card,widgets
> > +- simple-audio-card,routing
> > +- simple-audio-card,mclk-fs
> > +- simple-audio-card,hp-det-gpio
> > +- simple-audio-card,mic-det-gpio
> > +- simple-audio-card,format
> > +- simple-audio-card,frame-master
> > +- simple-audio-card,bitclock-master
> > +- simple-audio-card,bitclock-inversion
> > +- simple-audio-card,frame-inversion
> > +- simple-audio-card,mclk-fs
> > +- simple-audio-card,dai-tdm-slot-num
> > +- simple-audio-card,dai-tdm-slot-width
> 
> The simple-audio-card prefix is pointless. It's fine to reuse, but don't 
> add to it.

ALSA SoC sometimes want to switch Sound Card feature.
This is one of simple-xxx-card series, and each simple-xxx-card
series are similar but have difference from DT point of view.
Because of this, it is easy to switch to other feature
if these series are using same property.

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH v5 11/14] ASoC: add simple-graph-card document
  2016-12-04 23:48     ` Kuninori Morimoto
@ 2016-12-05  2:38       ` Kuninori Morimoto
  2016-12-05 22:58       ` Rob Herring
  1 sibling, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-12-05  2:38 UTC (permalink / raw)
  To: Rob Herring, Mark Brown, Linux-ALSA, Liam Girdwood, Simon,
	Laurent, Guennadi, Grant Likely, Frank Rowand, Linux-DT,
	Linux-Kernel


Hi Rob, Mark

> > > +		simple-audio-card,format = "left_j";
> > > +		simple-audio-card,bitclock-master = <&ak4643_port>;
> > > +		simple-audio-card,frame-master = <&ak4643_port>;
> > 
> > If you follow video-interfaces.txt, these should all go in the endpoint 
> > node.
> 
> Hmm... this is not for endpoint, but for whole card.
> Mark, of course this can goes to each endpoint, but it negates passed
> ALSA SoC Card discussion/decision. What is your opinion ?

I'm sorry, this was my fault.
I can move these to endpoint side.

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH v5 13/14] ASoC: add simple-graph-scu-card document
  2016-11-28  2:48 ` [PATCH v5 13/14] ASoC: add simple-graph-scu-card document Kuninori Morimoto
@ 2016-12-05 22:40   ` Rob Herring
  2016-12-06  6:33     ` Kuninori Morimoto
  0 siblings, 1 reply; 31+ messages in thread
From: Rob Herring @ 2016-12-05 22:40 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel

On Mon, Nov 28, 2016 at 02:48:37AM +0000, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  .../bindings/sound/simple-graph-scu-card.txt       | 69 ++++++++++++++++++++++
>  1 file changed, 69 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/simple-graph-scu-card.txt
> 
> diff --git a/Documentation/devicetree/bindings/sound/simple-graph-scu-card.txt b/Documentation/devicetree/bindings/sound/simple-graph-scu-card.txt
> new file mode 100644
> index 0000000..b0e46ba
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/simple-graph-scu-card.txt
> @@ -0,0 +1,69 @@
> +Simple-Graph-SCU-Card:
> +
> +Simple-Graph-SCU-Card specifies audio DAI connections of SoC <-> codec.
> +It is based on common bindings for device graphs.
> +see ${LINUX}/Documentation/devicetree/bindings/graph.txt
> +
> +Basically, Simple-Graph-SCU-Card property is same as Simple-Card / Simple-Graph-Card.
> +see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.txt
> +    ${LINUX}/Documentation/devicetree/bindings/sound/simple-graph-card.txt
> +
> +Main difference between Simple-Graph-Card and Simple-Graph-SCU-Card is that
> +Simple-Graph-SCU-Card can use multi CPU.

So it can have more that 1 port? At least for the bindings, I think you 
should combine these 2 bindings. Whether the driver should be combined 
is separate question. I imagine you have 2 compatible strings because 
you have 2 drivers, but that isn't really a reason to have 2.

I still have no idea what SCU is.

Rob

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

* Re: [PATCH v5 11/14] ASoC: add simple-graph-card document
  2016-12-04 23:48     ` Kuninori Morimoto
  2016-12-05  2:38       ` Kuninori Morimoto
@ 2016-12-05 22:58       ` Rob Herring
  2016-12-06  0:57         ` Kuninori Morimoto
  1 sibling, 1 reply; 31+ messages in thread
From: Rob Herring @ 2016-12-05 22:58 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel

On Sun, Dec 04, 2016 at 11:48:49PM +0000, Kuninori Morimoto wrote:
> 
> Hi Rob, Mark
> 
> > > +++ b/Documentation/devicetree/bindings/sound/simple-graph-card.txt
> > > @@ -0,0 +1,67 @@
> > > +Simple-Graph-Card:
> > 
> > There's nothing simple about this. graph-audio-card or audio-card-graph.
> 
> I have no objection about naming, but this is one of simple-xxx-card series.
> And, this is very simple from ALSA SoC point of view...
> 
> > > +rcar_sound {
> > > +	...
> > > +	port {
> > > +		compatible = "asoc-simple-graph-card";
> > 
> > Do you have an example where you'd have multiple ports? If not, this 
> > should go up a level.
> 
> ALSA SoC needs 3 type of driver, CPU/Codec/Card. But HW is SoC <-> Codec.
> Thus, "CPU" side DT needs to call "Card" portion, and ALSA SoC needs to
> select Card type (graph-audio-card, graph-scu-card, etc, etc....).
> Above it for it.
> 
> 	SoC {
> 		compatible = "cpu_driver_compatible_name";
> 		...
> 		port {
> 			compatible = "card_driver_compatible_name";
> 			...
> 		};
> 	};
> 
> Here, SoC driver "cpu_driver_compatible_name" will handle CPU and its
> each port settings. And it will probes "card_driver_compatible_name".
> "card_driver_compatible_name" will connect CPU <-> Codec via ALSA SoC.

Don't design bindings around what ASoC wants and don't explain it in 
terms of how ALSA works. Design bindings in a way that reflects the h/w.

This explanation seems completely wrong to me. It seems like you are 
abusing OF graph to just create 2 instances of a simple-card which would 
be working around some ASoC limitation.

I'd expect the top level node to be the card node that knows how to find 
all the components. The graph should reflect the data flow. For example, 
the data goes to audio DSP to I2S host to codec to amp. 

Rob

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

* Re: [PATCH v5 11/14] ASoC: add simple-graph-card document
  2016-12-05 22:58       ` Rob Herring
@ 2016-12-06  0:57         ` Kuninori Morimoto
  2016-12-06 15:03           ` Rob Herring
  0 siblings, 1 reply; 31+ messages in thread
From: Kuninori Morimoto @ 2016-12-06  0:57 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Brown, Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


Hi Rob

> I'd expect the top level node to be the card node that knows how to find 
> all the components. The graph should reflect the data flow. For example, 
> the data goes to audio DSP to I2S host to codec to amp. 

Do you mean, is this OK for OF graph ?
in driver point of view, "I2S" is sound card here.

I2S {
	port {
		i2s-dsp: endpoint {
			remote-endpoint = <&dsp>;
		}
		i2s-codec: endpoint {
			remote-endpoint = <&codec>;
		}
	}
}

DSP {
	port {
		dsp: endpoint {
			remote-endpoint = <&i2s-dsp>;
		}
	}
}

Codec {
	port {
		codec: endpoint {
			remote-endpoint = <&i2s-codec>;
		}
	}
}

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

* Re: [PATCH v5 13/14] ASoC: add simple-graph-scu-card document
  2016-12-05 22:40   ` Rob Herring
@ 2016-12-06  6:33     ` Kuninori Morimoto
  0 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-12-06  6:33 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Brown, Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


Hi Rob

> > +Simple-Graph-SCU-Card:
> > +
> > +Simple-Graph-SCU-Card specifies audio DAI connections of SoC <-> codec.
> > +It is based on common bindings for device graphs.
> > +see ${LINUX}/Documentation/devicetree/bindings/graph.txt
> > +
> > +Basically, Simple-Graph-SCU-Card property is same as Simple-Card / Simple-Graph-Card.
> > +see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.txt
> > +    ${LINUX}/Documentation/devicetree/bindings/sound/simple-graph-card.txt
> > +
> > +Main difference between Simple-Graph-Card and Simple-Graph-SCU-Card is that
> > +Simple-Graph-SCU-Card can use multi CPU.
> 
> So it can have more that 1 port? At least for the bindings, I think you 
> should combine these 2 bindings. Whether the driver should be combined 
> is separate question. I imagine you have 2 compatible strings because 
> you have 2 drivers, but that isn't really a reason to have 2.

The difference these 2 are, 1) compatible name 2) single port / multi port.
>From ALSA SoC point of view, they are using different feature,
but from DT point of view, they are almost same.
Combine these are OK, but my question is can we use different "compatible" ?
Or same "compatible" but switch single/multi somehow ?

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH v5 11/14] ASoC: add simple-graph-card document
  2016-12-06  0:57         ` Kuninori Morimoto
@ 2016-12-06 15:03           ` Rob Herring
  2016-12-07  0:10             ` Kuninori Morimoto
  0 siblings, 1 reply; 31+ messages in thread
From: Rob Herring @ 2016-12-06 15:03 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel

On Mon, Dec 5, 2016 at 6:57 PM, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
>
> Hi Rob
>
>> I'd expect the top level node to be the card node that knows how to find
>> all the components. The graph should reflect the data flow. For example,
>> the data goes to audio DSP to I2S host to codec to amp.
>
> Do you mean, is this OK for OF graph ?

Yes, something like this.

> in driver point of view, "I2S" is sound card here.

Well, that seems odd to me because I2S should just be the h/w block
that interfaces to I2S/SSI signals. I'd expect you still have a card
node that references these nodes. Maybe it just references the DSP and
then you walk the graph from there to find the I2S controller and
codec.

>
> I2S {
>         port {
>                 i2s-dsp: endpoint {
>                         remote-endpoint = <&dsp>;
>                 }
>                 i2s-codec: endpoint {
>                         remote-endpoint = <&codec>;
>                 }
>         }
> }
>
> DSP {
>         port {
>                 dsp: endpoint {
>                         remote-endpoint = <&i2s-dsp>;
>                 }
>         }
> }
>
> Codec {
>         port {
>                 codec: endpoint {
>                         remote-endpoint = <&i2s-codec>;
>                 }
>         }
> }

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

* Re: [PATCH v5 11/14] ASoC: add simple-graph-card document
  2016-12-06 15:03           ` Rob Herring
@ 2016-12-07  0:10             ` Kuninori Morimoto
  0 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-12-07  0:10 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Brown, Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


Hi Rob

> > Do you mean, is this OK for OF graph ?
> 
> Yes, something like this.

Wow!! Thanks !!
it makes new OF-graph easier !!

> > in driver point of view, "I2S" is sound card here.
> 
> Well, that seems odd to me because I2S should just be the h/w block
> that interfaces to I2S/SSI signals. I'd expect you still have a card
> node that references these nodes. Maybe it just references the DSP and
> then you walk the graph from there to find the I2S controller and
> codec.

If my understanding was correct, this is good ?

Card {
	ports {
		port@0 {
			card-dsp: endpoint {
				remote-endpoint = <&dsp>;
			};
		};
		port@1 {
			card-codec: endpoint {
				remote-endpoint = <&codec>;
			};
		}
	}
}

DSP {
	port {
		dsp: endpoint {
			remote-endpoint = <&card-dsp>;
		}
	}
}

Codec {
	port {
		codec: endpoint {
			remote-endpoint = <&card-codec>;
		}
	}
}

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

* Re: [PATCH v5 01/14] Documentation: of: add type property
  2016-12-01 16:26   ` Rob Herring
@ 2016-12-08  1:57     ` Kuninori Morimoto
  0 siblings, 0 replies; 31+ messages in thread
From: Kuninori Morimoto @ 2016-12-08  1:57 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Brown, Linux-ALSA, Liam Girdwood, Simon, Laurent, Guennadi,
	Grant Likely, Frank Rowand, Linux-DT, Linux-Kernel


Hi Rob

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > OF graph indicates each devices connection. But it doesn't support type
> > of each port. For example HDMI case, it has video port and sound port
> > in one device node.
> > In this case, current driver can't handle each port correctly.
> > This patch enables to use type property on OF graph.
> 
> I still don't think this is necessary. Simply define which port number 
> is which for each HDMI chip.
> 
> If this is necessary, then the types, video and sound, are too generic.

About this, if OF-graph can have "query" function to each port,
I can remove this "type" property from DT, and driver can answer
each port feature.
But is this OK approach ?

Best regards
---
Kuninori Morimoto

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

end of thread, other threads:[~2016-12-08  1:57 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-28  2:42 [PATCH v5 00/14] ASoC: add OF graph base simple-card Kuninori Morimoto
2016-11-28  2:44 ` [PATCH v5 01/14] Documentation: of: add type property Kuninori Morimoto
2016-12-01 16:26   ` Rob Herring
2016-12-08  1:57     ` Kuninori Morimoto
2016-11-28  2:45 ` [PATCH v5 02/14] of_graph: add of_graph_get_remote_endpoint() Kuninori Morimoto
2016-11-28  2:45 ` [PATCH v5 03/14] of_graph: add of_graph_port_type_is() Kuninori Morimoto
2016-11-28  2:45 ` [PATCH v5 04/14] of_graph: add of_graph_get_port_parent() Kuninori Morimoto
2016-11-28  2:46 ` [PATCH v5 05/14] of_graph: add of_graph_get_top_port() Kuninori Morimoto
2016-11-28  2:46 ` [PATCH v5 06/14] of_graph: add for_each_of_port() / for_each_of_endpoint_in_port() Kuninori Morimoto
2016-11-28  2:46 ` [PATCH v5 07/14] of_graph: add of_graph_get_endpoint_count() Kuninori Morimoto
2016-11-28  2:46 ` [PATCH v5 08/14] ASoC: simple-card-utils: adjust for graph on asoc_simple_card_parse_card_name Kuninori Morimoto
2016-11-28  2:47 ` [PATCH v5 09/14] ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai() Kuninori Morimoto
2016-11-28  3:41   ` kbuild test robot
2016-11-28  4:10     ` Kuninori Morimoto
2016-11-28  2:47 ` [PATCH v5 10/14] ASoC: simple-card-utils: add asoc_simple_card_try_to_probe_graph_card() Kuninori Morimoto
2016-11-28  2:47 ` [PATCH v5 11/14] ASoC: add simple-graph-card document Kuninori Morimoto
2016-12-02 13:50   ` Rob Herring
2016-12-04 23:48     ` Kuninori Morimoto
2016-12-05  2:38       ` Kuninori Morimoto
2016-12-05 22:58       ` Rob Herring
2016-12-06  0:57         ` Kuninori Morimoto
2016-12-06 15:03           ` Rob Herring
2016-12-07  0:10             ` Kuninori Morimoto
2016-12-05  2:21     ` Kuninori Morimoto
2016-11-28  2:48 ` [PATCH v5 12/14] ASoC: add simple-graph-card support Kuninori Morimoto
2016-11-28  4:19   ` kbuild test robot
2016-11-28  2:48 ` [PATCH v5 13/14] ASoC: add simple-graph-scu-card document Kuninori Morimoto
2016-12-05 22:40   ` Rob Herring
2016-12-06  6:33     ` Kuninori Morimoto
2016-11-28  2:48 ` [PATCH v5 14/14] ASoC: add simple-graph-scu-card support Kuninori Morimoto
2016-11-28  4:36   ` kbuild test robot

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).