diff mbox

[5/8] ASoC: simple-card: add DPCM support when DT case

Message ID 878umjiqjm.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kuninori Morimoto Aug. 20, 2014, 7:11 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch adds DPCM support on simple-card when DT case

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 .../devicetree/bindings/sound/simple-card.txt      |   35 ++++++++++++++++++++
 sound/soc/generic/simple-card.c                    |   33 ++++++++++++++++--
 2 files changed, 65 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index c2e9841..60ce432 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -51,6 +51,8 @@  Optional dai-link subnode properties:
 					  dai-link uses bit clock inversion.
 - frame-inversion			: bool property. Add this if the
 					  dai-link uses frame clock inversion.
+- remote				: DPCM phandle to backend DAI entry.
+					  and this DAI will be frontend entry.
 
 For backward compatibility the frame-master and bitclock-master
 properties can be used as booleans in codec subnode to indicate if the
@@ -149,3 +151,36 @@  sound {
 		};
 	};
 };
+
+Example 3 - DPCM:
+
+sound {
+	compatible = "simple-audio-card";
+
+	/* Front End <-> Back End route */
+	simple-audio-card,routing =
+		"yyy Playback", "xxx Playback",
+		"xxx Capture",  "yyy Capture";
+
+	simple-audio-card,dai-link@0 {		/* Front End */
+		...
+		remote = <&backend>;
+
+		cpu {
+			sound-dai = <xxx>;
+		};
+		codec {
+			sound-dai = <xxx>;
+		};
+	};
+
+	backend: simple-audio-card,dai-link@1 {	/* Back End */
+		...
+		cpu {
+			sound-dai = <yyy>;
+		};
+		codec {
+			sound-dai = <yyy>;
+		};
+	};
+};
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 60d277a..9481e70 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -163,7 +163,8 @@  asoc_simple_card_sub_parse_of(struct device_node *np,
 	return 0;
 }
 
-static int asoc_simple_card_dai_link_of(struct device_node *node,
+static int asoc_simple_card_dai_link_of(struct device_node *parent_node,
+					struct device_node *node,
 					struct device *dev,
 					struct snd_soc_dai_link *dai_link,
 					struct simple_dai_props *dai_props,
@@ -276,6 +277,32 @@  static int asoc_simple_card_dai_link_of(struct device_node *node,
 	dai_link->ops = &asoc_simple_card_ops;
 	dai_link->init = asoc_simple_card_dai_init;
 
+	/* For DPCM */
+	if (parent_node) {
+		struct device_node *e;
+		struct device_node *h;
+
+		for_each_child_of_node(parent_node, e) {
+			h = of_parse_phandle(e, "remote", 0);
+			if (!h)
+				continue;
+
+			/* Front End */
+			if (e == node) {
+				dai_link->dynamic	= 1;
+				dai_link->dpcm_playback	= 1; /* FIXME */
+				dai_link->dpcm_capture	= 1; /* FIXME */
+			}
+
+			/* Back End */
+			if (h == node) {
+				dai_link->no_pcm	= 1;
+				dai_link->dpcm_playback	= 1; /* FIXME */
+				dai_link->dpcm_capture	= 1; /* FIXME */
+			}
+		}
+	}
+
 	dev_dbg(dev, "\tname : %s\n", dai_link->stream_name);
 	dev_dbg(dev, "\tcpu : %s / %04x / %d\n",
 		dai_link->cpu_dai_name,
@@ -350,7 +377,7 @@  static int asoc_simple_card_parse_of(struct device_node *node,
 
 		for_each_child_of_node(node, np) {
 			dev_dbg(dev, "\tlink %d:\n", i);
-			ret = asoc_simple_card_dai_link_of(np, dev,
+			ret = asoc_simple_card_dai_link_of(node, np, dev,
 							   dai_link + i,
 							   dai_props + i,
 							   false);
@@ -361,7 +388,7 @@  static int asoc_simple_card_parse_of(struct device_node *node,
 			i++;
 		}
 	} else {
-		ret = asoc_simple_card_dai_link_of(node, dev,
+		ret = asoc_simple_card_dai_link_of(NULL, node, dev,
 						   dai_link, dai_props, true);
 		if (ret < 0)
 			return ret;