Skip to contentSkip to conversation

DPCM with simple-card support for Kirkwood

RFC New Andrew Lunn 2 participants 14 messages Aug 6, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover DPCM with simple-card support for Kirkwood

Hi Russell

30 June you posted your code to implement DPCM for kirkwood-i2s, making it possible to use both I2S and SPDIF at the same time.

It has taken me a while, but i now have this patch on 3.16-rc6, and i've extended simple-card to support DPCM. I've tested it on a kirkwood based HP T5325, which only makes use of the I2S backend.

Please could you take a look and see if this helps to unblock getting your Cubox support into mainline.

The code is also here

https://github.com/lunn/linux.git v3.16-rc6-rmk-dpcm

Thanks
Andrew

Andrew Lunn (7):
ASoC: simple-card: Make mclk setting a dai link property
ARM: Kirkwood: Update sound DT node to reflect DPCM support
ASoC: dt: Parse DPCM properties
ASoC: simple-card: Don't set DAI format for dynamic DAIs
ASoC: dt: Allow the platform name to be set for a DAI
ASoC: simple-card: Allow use of snd-soc-dummy as codec
ARM: Kirkwood: Describe DPCM audio support in DT

Russell King (1):
ASoC: kirkwood: add DPCM support

 .../devicetree/bindings/sound/simple-card.txt      |  11 +-
 arch/arm/boot/dts/kirkwood-openrd-client.dts       |  39 +++-
 arch/arm/boot/dts/kirkwood-t5325.dts               |  37 +++-
 arch/arm/boot/dts/kirkwood.dtsi                    |   2 +-
 include/sound/soc.h                                |   8 +
 sound/soc/generic/simple-card.c                    | 140 +++++++-----
 sound/soc/kirkwood/kirkwood-i2s.c                  | 244 ++++++++++++++-------
 sound/soc/kirkwood/kirkwood.h                      |  20 ++
 sound/soc/soc-core.c                               |  29 +++
 9 files changed, 380 insertions(+), 150 deletions(-)
Signature · 1 line
2.0.1
#1 lore raw

RFC 1/8 ASoC: kirkwood: add DPCM support

From: Russell King <[email protected]>

Add DPCM support to kirkwood-i2s to support the I2S and SPDIF streams. This consists of:
- a single front end DAI called "kirkwood-fe" with "dma-tx" and "dma-rx" streams.
- one backend DAI called "kirkwood-i2s" for I2S with streams named "i2s-tx" and "i2s-rx"
- one backend DAI called "kirkwood-spdif" for SPDIF with a single stream named "spdif-tx".

DAPM widgets are used to connect the backend i2s-tx/spdif-tx streams to the dma-tx frontend stream, and similarly for the capture side. SPDIF capture is not supported by this patch.

We avoid the requirement that streams must not be started independently by keeping a separate mask of which streams are enabled - and this mask is only used in the playback trigger when we start playback.

---
 arch/arm/boot/dts/kirkwood-t5325.dts |   4 +-
 sound/soc/kirkwood/kirkwood-i2s.c    | 244 +++++++++++++++++++++++------------
 sound/soc/kirkwood/kirkwood.h        |  20 +++
 3 files changed, 187 insertions(+), 81 deletions(-)
arch/arm/boot/dts/kirkwood-t5325.dts +3 -1
index 610ec0f95858..cc6cd0bdcfac 100644
@@ -196,7 +196,9 @@
 			"Speaker", "SPKOUT",
 			"Speaker", "SPKOUTN",
 			"MIC1", "Mic Jack",
-			"MIC2", "Mic Jack";
+			"MIC2", "Mic Jack",
+			"i2s-tx", "dma-tx",
+			"dma-rx", "i2s-rx";
 		simple-audio-card,widgets =
 			"Headphone", "Headphone Jack",
 			"Speaker", "Speaker",
sound/soc/kirkwood/kirkwood-i2s.c +164 -80

347 lines not on this page · raw message

sound/soc/kirkwood/kirkwood.h +20 -0
index 90e32a781424..5a5a48944976 100644
@@ -131,12 +131,19 @@
 #define KIRKWOOD_SND_MAX_BUFFER_BYTES		(KIRKWOOD_SND_MAX_PERIOD_BYTES \
 						 * KIRKWOOD_SND_MAX_PERIODS)
 
+#define KIRKWOOD_NUM_DAIS 3
+
 struct kirkwood_dma_data {
 	void __iomem *io;
 	struct clk *clk;
 	struct clk *extclk;
+	unsigned have_spdif;
+	uint32_t ctl_play_mask;
 	uint32_t ctl_play;
+	uint32_t ctl_rec_mask;
 	uint32_t ctl_rec;
+	struct snd_soc_dai *active_dai;
+	struct snd_soc_dai_driver dai_driver[KIRKWOOD_NUM_DAIS];
 	struct snd_pcm_substream *substream_play;
 	struct snd_pcm_substream *substream_rec;
 	int irq;
@@ -145,4 +152,17 @@ struct kirkwood_dma_data {
 
 extern struct snd_soc_platform_driver kirkwood_soc_platform;
 
+#define KIRKWOOD_FE_DAI_LINK(id, play, capt) {	\
+	.name = "Kirkwood-FE",			\
+	.stream_name = "FE PCM Playback",	\
+	.cpu_name = "mvebu-audio" id,		\
+	.cpu_dai_name = "kirkwood-fe",		\
+	.codec_name = "snd-soc-dummy",		\
+	.codec_dai_name = "snd-soc-dummy-dai",	\
+	.platform_name = "mvebu-audio" id,	\
+	.dynamic = 1,				\
+	.dpcm_capture = capt,			\
+	.dpcm_playback = play,			\
+}
+
 #endif
Signature · 1 line
2.0.1
#2 lore raw

RFC 2/8 ASoC: simple-card: Make mclk setting a dai link property

In reply to Andrew Lunn

The mclk factor between between stream rate and codec clk was wrongly made a property of the whole card, when in fact it is a property of a dai link. Correct this.

---

The only users of this property are kirkwood devices, which are updated in a later patch. There is an ABI break anyway, in order to make use of DPCM, which is the right way to handle the kirkwood hardware, rather than what we currently have.

---
 Documentation/devicetree/bindings/sound/simple-card.txt |  4 ++--
 sound/soc/generic/simple-card.c                         | 16 +++++++++-------
 2 files changed, 11 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/sound/simple-card.txt +2 -2
index c2e9841dfce4..8b9f902cdfc7 100644
@@ -15,8 +15,6 @@ Optional properties:
 					  Each entry is a pair of strings, the first being the
 					  connection's sink, the second being the connection's
 					  source.
-- simple-audio-card,mclk-fs             : Multiplication factor between stream rate and codec
-  					  mclk.
 
 Optional subnodes:
 
@@ -51,6 +49,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.
+- mclk-fs                               : Multiplication factor between stream
+                                          rate and codec mclk.
 
 For backward compatibility the frame-master and bitclock-master
 properties can be used as booleans in codec subnode to indicate if the
sound/soc/generic/simple-card.c +9 -7
index 03a7fdcdf114..63f3d16d43ba 100644
@@ -23,8 +23,8 @@ struct simple_card_data {
 	struct simple_dai_props {
 		struct asoc_simple_dai cpu_dai;
 		struct asoc_simple_dai codec_dai;
+		unsigned int mclk_fs;
 	} *dai_props;
-	unsigned int mclk_fs;
 	struct snd_soc_dai_link dai_link[];	/* dynamically allocated */
 };
 
@@ -34,11 +34,13 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
+	int num = rtd - rtd->card->rtd;
+	struct simple_dai_props *dai_props = &priv->dai_props[num];
 	unsigned int mclk;
 	int ret = 0;
 
-	if (priv->mclk_fs) {
-		mclk = params_rate(params) * priv->mclk_fs;
+	if (dai_props->mclk_fs) {
+		mclk = params_rate(params) * dai_props->mclk_fs;
 		ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
 					     SND_SOC_CLOCK_IN);
 	}
@@ -186,6 +188,10 @@ static int simple_card_dai_link_of(struct device_node *node,
 					 &bitclkmaster, &framemaster);
 	daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
 
+	/* Factor to mclk, used in hw_params() */
+	of_property_read_u32(node, "mclk-fs",
+			     &dai_props->mclk_fs);
+
 	snprintf(prop, sizeof(prop), "%scpu", prefix);
 	np = of_get_child_by_name(node, prop);
 	if (!np) {
@@ -324,10 +330,6 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 			return ret;
 	}
 
-	/* Factor to mclk, used in hw_params() */
-	of_property_read_u32(node, "simple-audio-card,mclk-fs",
-			     &priv->mclk_fs);
-
 	dev_dbg(dev, "New simple-card: %s\n", priv->snd_card.name ?
 		priv->snd_card.name : "");
 
Signature · 1 line
2.0.1
#3 lore raw

RFC 3/8 ARM: Kirkwood: Update sound DT node to reflect DPCM support

In reply to Andrew Lunn

Now that kirkwood-i2s supports multiple DAIs, we need to specify which DAI is to be used in phandle. So increase the #sound-dai-cells to one.

---
 arch/arm/boot/dts/kirkwood.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/kirkwood.dtsi +1 -1
index afc640cd80c5..69b4cee1f4d3 100644
@@ -372,7 +372,7 @@
 
 		audio0: audio-controller at a0000 {
 			compatible = "marvell,kirkwood-audio";
-			#sound-dai-cells = <0>;
+			#sound-dai-cells = <1>;
 			reg = <0xa0000 0x2210>;
 			interrupts = <24>;
 			clocks = <&gate_clk 9>;
Signature · 1 line
2.0.1
#4 lore raw

RFC 4/8 ASoC: dt: Parse DPCM properties

In reply to Andrew Lunn

In order to describe DPCM links in DT, we need some additional properties. Is the DAI dynamic, i.e. a front end? Should no PCM be created for the DAI? Can it be used for DPCM playback and capture? Add parsing of these properties to the core and make use of them in simple card.

---
 .../devicetree/bindings/sound/simple-card.txt      |  4 ++++
 include/sound/soc.h                                |  6 ++++++
 sound/soc/generic/simple-card.c                    |  4 ++++
 sound/soc/soc-core.c                               | 22 ++++++++++++++++++++++
 4 files changed, 36 insertions(+)
Documentation/devicetree/bindings/sound/simple-card.txt +4 -0
index 8b9f902cdfc7..cba8b8406bb0 100644
@@ -51,6 +51,10 @@ Optional dai-link subnode properties:
 					  dai-link uses frame clock inversion.
 - mclk-fs                               : Multiplication factor between stream
                                           rate and codec mclk.
+- dynamic				: This DAI link can route to other DAI links at runtime
+- no_pcm				: Do not create a PCM for this DAI link
+- dpcm_capture				: DPCM capture supported for this DAI link
+- dpcm_playback				: DPCM playback supported for this DAI link
 
 For backward compatibility the frame-master and bitclock-master
 properties can be used as booleans in codec subnode to indicate if the
include/sound/soc.h +6 -0
index ed9e2d7e5fdc..060e2f955292 100644
@@ -1374,6 +1374,12 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
 				     struct device_node **framemaster);
+void snd_soc_of_parse_dpcm(struct device_node *np,
+			   struct snd_soc_dai_link *dai_link);
+void snd_soc_of_parse_dynamic(struct device_node *np,
+			      struct snd_soc_dai_link *dai_link);
+void snd_soc_of_parse_no_pcm(struct device_node *np,
+			     struct snd_soc_dai_link *dai_link);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
 			    const char **dai_name);
 
sound/soc/generic/simple-card.c +4 -0
index 63f3d16d43ba..735a54099b8d 100644
@@ -188,6 +188,10 @@ static int simple_card_dai_link_of(struct device_node *node,
 					 &bitclkmaster, &framemaster);
 	daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
 
+	snd_soc_of_parse_dpcm(node, dai_link);
+	snd_soc_of_parse_dynamic(node, dai_link);
+	snd_soc_of_parse_no_pcm(node, dai_link);
+
 	/* Factor to mclk, used in hw_params() */
 	of_property_read_u32(node, "mclk-fs",
 			     &dai_props->mclk_fs);
sound/soc/soc-core.c +22 -0
index 91120b8e283e..8aa3a21d37af 100644
@@ -4745,6 +4745,28 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
 
+void snd_soc_of_parse_dpcm(struct device_node *np,
+			   struct snd_soc_dai_link *dai_link)
+{
+	dai_link->dpcm_playback = of_property_read_bool(np, "dpcm_playback");
+	dai_link->dpcm_capture = of_property_read_bool(np, "dpcm_capture");
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_parse_dpcm);
+
+void snd_soc_of_parse_dynamic(struct device_node *np,
+			      struct snd_soc_dai_link *dai_link)
+{
+	dai_link->dynamic = of_property_read_bool(np, "dynamic");
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_parse_dynamic);
+
+void snd_soc_of_parse_no_pcm(struct device_node *np,
+			     struct snd_soc_dai_link *dai_link)
+{
+	dai_link->no_pcm = of_property_read_bool(np, "no_pcm");
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_parse_no_pcm);
+
 int snd_soc_of_get_dai_name(struct device_node *of_node,
 			    const char **dai_name)
 {
Signature · 1 line
2.0.1
#5 lore raw

RFC 5/8 ASoC: simple-card: Don't set DAI format for dynamic DAIs

In reply to Andrew Lunn

Dynamic DAIs, i.e. frontend's should not have a fmt. Skip setting it when the dynamic property has been found in DT.

---
 sound/soc/generic/simple-card.c | 88 +++++++++++++++++++++++++----------------
 1 file changed, 55 insertions(+), 33 deletions(-)
sound/soc/generic/simple-card.c +55 -33
index 735a54099b8d..c3235923b12f 100644
@@ -166,6 +166,52 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
 	return 0;
 }
 
+static void simple_card_cpu_dia_fmt(int daifmt,
+				    struct simple_dai_props *dai_props,
+				    struct device_node *np,
+				    struct device_node *bitclkmaster,
+				    struct device_node *framemaster)
+{
+	dai_props->cpu_dai.fmt = daifmt;
+	switch (((np == bitclkmaster) << 4) | (np == framemaster)) {
+	case 0x11:
+		dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBS_CFS;
+		break;
+	case 0x10:
+		dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBS_CFM;
+		break;
+	case 0x01:
+		dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBM_CFS;
+		break;
+	default:
+		dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBM_CFM;
+		break;
+	}
+}
+
+static void simple_card_codec_dia_fmt(int daifmt,
+				      struct simple_dai_props *dai_props,
+				      struct device_node *np,
+				      struct device_node *bitclkmaster,
+				      struct device_node *framemaster)
+{
+	dai_props->codec_dai.fmt = daifmt;
+	switch (((np == bitclkmaster) << 4) | (np == framemaster)) {
+	case 0x11:
+		dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBM_CFM;
+		break;
+	case 0x10:
+		dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBM_CFS;
+		break;
+	case 0x01:
+		dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBS_CFM;
+		break;
+	default:
+		dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBS_CFS;
+		break;
+	}
+}
+
 static int simple_card_dai_link_of(struct device_node *node,
 				   struct device *dev,
 				   struct snd_soc_dai_link *dai_link,
@@ -210,21 +256,9 @@ static int simple_card_dai_link_of(struct device_node *node,
 	if (ret < 0)
 		goto dai_link_of_err;
 
-	dai_props->cpu_dai.fmt = daifmt;
-	switch (((np == bitclkmaster) << 4) | (np == framemaster)) {
-	case 0x11:
-		dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBS_CFS;
-		break;
-	case 0x10:
-		dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBS_CFM;
-		break;
-	case 0x01:
-		dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBM_CFS;
-		break;
-	default:
-		dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBM_CFM;
-		break;
-	}
+	if (!dai_link->dynamic)
+		simple_card_cpu_dia_fmt(daifmt, dai_props, np,
+					bitclkmaster, framemaster);
 
 	of_node_put(np);
 	snprintf(prop, sizeof(prop), "%scodec", prefix);
@@ -242,30 +276,18 @@ static int simple_card_dai_link_of(struct device_node *node,
 		goto dai_link_of_err;
 
 	if (strlen(prefix) && !bitclkmaster && !framemaster) {
-		/* No dai-link level and master setting was not found from
-		   sound node level, revert back to legacy DT parsing and
-		   take the settings from codec node. */
+		/* No dai-link level and master setting was not found
+		   from sound node level, revert back to legacy DT
+		   parsing and take the settings from codec node. */
 		dev_dbg(dev, "%s: Revert to legacy daifmt parsing\n",
 			__func__);
 		dai_props->cpu_dai.fmt = dai_props->codec_dai.fmt =
 			snd_soc_of_parse_daifmt(np, NULL, NULL, NULL) |
 			(daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK);
 	} else {
-		dai_props->codec_dai.fmt = daifmt;
-		switch (((np == bitclkmaster) << 4) | (np == framemaster)) {
-		case 0x11:
-			dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBM_CFM;
-			break;
-		case 0x10:
-			dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBM_CFS;
-			break;
-		case 0x01:
-			dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBS_CFM;
-			break;
-		default:
-			dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBS_CFS;
-			break;
-		}
+		if (!dai_link->dynamic)
+			simple_card_codec_dia_fmt(daifmt, dai_props, np,
+						bitclkmaster, framemaster);
 	}
 
 	if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) {
Signature · 1 line
2.0.1
#6 lore raw

RFC 6/8 ASoC: dt: Allow the platform name to be set for a DAI

In reply to Andrew Lunn

In order to use DPCM, we need to be able to set the platform name per DAI. In particular, we need to use the "snd-soc-dummy" platform for DPCM backends.

---
 include/sound/soc.h             | 2 ++
 sound/soc/generic/simple-card.c | 5 +++--
 sound/soc/soc-core.c            | 7 +++++++
 3 files changed, 12 insertions(+), 2 deletions(-)
include/sound/soc.h +2 -0
index 060e2f955292..3e4fd6eb5f32 100644
@@ -1380,6 +1380,8 @@ void snd_soc_of_parse_dynamic(struct device_node *np,
 			      struct snd_soc_dai_link *dai_link);
 void snd_soc_of_parse_no_pcm(struct device_node *np,
 			     struct snd_soc_dai_link *dai_link);
+void snd_soc_of_parse_platform_name(struct device_node *np,
+				    struct snd_soc_dai_link *dai_link);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
 			    const char **dai_name);
 
sound/soc/generic/simple-card.c +3 -2
index c3235923b12f..a99aad16d8f9 100644
@@ -237,6 +237,7 @@ static int simple_card_dai_link_of(struct device_node *node,
 	snd_soc_of_parse_dpcm(node, dai_link);
 	snd_soc_of_parse_dynamic(node, dai_link);
 	snd_soc_of_parse_no_pcm(node, dai_link);
+	snd_soc_of_parse_platform_name(node, dai_link);
 
 	/* Factor to mclk, used in hw_params() */
 	of_property_read_u32(node, "mclk-fs",
@@ -295,8 +296,8 @@ static int simple_card_dai_link_of(struct device_node *node,
 		goto dai_link_of_err;
 	}
 
-	/* simple-card assumes platform == cpu */
-	dai_link->platform_of_node = dai_link->cpu_of_node;
+	if (!dai_link->platform_name)
+		dai_link->platform_of_node = dai_link->cpu_of_node;
 
 	/* Link name is created from CPU/CODEC dai name */
 	name = devm_kzalloc(dev,
sound/soc/soc-core.c +7 -0
index 8aa3a21d37af..667129078e44 100644
@@ -4767,6 +4767,13 @@ void snd_soc_of_parse_no_pcm(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_no_pcm);
 
+void snd_soc_of_parse_platform_name(struct device_node *np,
+				    struct snd_soc_dai_link *dai_link)
+{
+	of_property_read_string(np, "platform_name", &dai_link->platform_name);
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_parse_platform_name);
+
 int snd_soc_of_get_dai_name(struct device_node *of_node,
 			    const char **dai_name)
 {
Signature · 1 line
2.0.1
#7 lore raw

RFC 7/8 ASoC: simple-card: Allow use of snd-soc-dummy as codec

In reply to Andrew Lunn

The DPCM front end does not have a codec attached. So use the Boolean property 'snd-soc-dummy' to indicate that snd-soc-dummy should be used, instead of a phandle to a real codec.

---
 .../devicetree/bindings/sound/simple-card.txt      |  3 +++
 sound/soc/generic/simple-card.c                    | 27 ++++++++++++++--------
 2 files changed, 21 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/sound/simple-card.txt +3 -0
index cba8b8406bb0..79ba1138dfa8 100644
@@ -65,7 +65,10 @@ properties should also be placed in the codec node if needed.
 
 Required CPU/CODEC subnodes properties:
 
+Either:
 - sound-dai				: phandle and port of CPU/CODEC
+Or:
+- snd-soc-dummy				: Boolean that dummy should be used
 
 Optional CPU/CODEC subnodes properties:
 
sound/soc/generic/simple-card.c +18 -9
index a99aad16d8f9..e7fccd0940bb 100644
@@ -114,6 +114,7 @@ static int
 asoc_simple_card_sub_parse_of(struct device_node *np,
 			      struct asoc_simple_dai *dai,
 			      const struct device_node **p_node,
+			      const char **dai_name,
 			      const char **name)
 {
 	struct device_node *node;
@@ -125,14 +126,20 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
 	 * it will be used as xxx_of_node on soc_bind_dai_link()
 	 */
 	node = of_parse_phandle(np, "sound-dai", 0);
-	if (!node)
-		return -ENODEV;
-	*p_node = node;
+	if (!node) {
+		if (!of_property_read_bool(np, "snd-soc-dummy"))
+			return -ENODEV;
+		*name = "snd-soc-dummy";
+		*dai_name = "snd-soc-dummy-dai";
+		p_node = NULL;
+	} else {
+		*p_node = node;
 
-	/* get dai->name */
-	ret = snd_soc_of_get_dai_name(np, name);
-	if (ret < 0)
-		return ret;
+		/* get dai->name */
+		ret = snd_soc_of_get_dai_name(np, dai_name);
+		if (ret < 0)
+			return ret;
+	}
 
 	/* parse TDM slot */
 	ret = snd_soc_of_parse_tdm_slot(np, &dai->slots, &dai->slot_width);
@@ -253,7 +260,8 @@ static int simple_card_dai_link_of(struct device_node *node,
 
 	ret = asoc_simple_card_sub_parse_of(np, &dai_props->cpu_dai,
 					    &dai_link->cpu_of_node,
-					    &dai_link->cpu_dai_name);
+					    &dai_link->cpu_dai_name,
+					    &dai_link->cpu_name);
 	if (ret < 0)
 		goto dai_link_of_err;
 
@@ -272,7 +280,8 @@ static int simple_card_dai_link_of(struct device_node *node,
 
 	ret = asoc_simple_card_sub_parse_of(np, &dai_props->codec_dai,
 					    &dai_link->codec_of_node,
-					    &dai_link->codec_dai_name);
+					    &dai_link->codec_dai_name,
+					    &dai_link->codec_name);
 	if (ret < 0)
 		goto dai_link_of_err;
 
Signature · 1 line
2.0.1
#8 lore raw

RFC 8/8 ARM: Kirkwood: Describe DPCM audio support in DT

In reply to Andrew Lunn

Describe the DAI backend and the I2S front end of the audio hardware for both HP T5325 and Marvell OpenRD Client.

---
 arch/arm/boot/dts/kirkwood-openrd-client.dts | 39 +++++++++++++++++++++++-----
 arch/arm/boot/dts/kirkwood-t5325.dts         | 33 +++++++++++++++++------
 2 files changed, 57 insertions(+), 15 deletions(-)
arch/arm/boot/dts/kirkwood-openrd-client.dts +32 -7
index 887b9c1fee43..2cb216512ff2 100644
@@ -29,19 +29,44 @@
 				reg = <0x4a>;
 			};
 		};
+
+		audio: audio-controller at a0000 {
+			status = "okay";
+		};
+
 	};
 
 	sound {
 		compatible = "simple-audio-card";
-		simple-audio-card,format = "i2s";
-		simple-audio-card,mclk-fs = <256>;
+		simple-audio-card,name = "openrd-client-audio";
+		simple-audio-card,routing =
+			"i2s-tx", "dma-tx",
+			"dma-rx", "i2s-rx";
 
-		simple-audio-card,cpu {
-			sound-dai = <&audio0>;
+		simple-audio-card,dai-link at 0 { /* Front end */
+			dynamic;
+			dpcm_playback;
+			dpcm_capture;
+			cpu {
+				sound-dai = <&audio 0>;
+			};
+			codec {
+				snd-soc-dummy;
+			};
 		};
-
-		simple-audio-card,codec {
-			sound-dai = <&cs42l51>;
+		simple-audio-card,dia-link at 1 { /* I2S Backend */
+			format = "i2s";
+			dpcm_playback;
+			dpcm_capture;
+			no_pcm;
+			mclk-fs = <256>;
+			platform_name = "snd-soc-dummy";
+			cpu {
+				sound-dai = <&audio 1>;
+			};
+			codec {
+				sound-dai = <&cs42l51>;
+			};
 		};
 	};
 };
arch/arm/boot/dts/kirkwood-t5325.dts +25 -8
index cc6cd0bdcfac..f9466a2858c9 100644
@@ -189,7 +189,7 @@
 
 	sound {
 		compatible = "simple-audio-card";
-		simple-audio-card,format = "i2s";
+		simple-audio-card,name = "t5325";
 		simple-audio-card,routing =
 			"Headphone Jack", "HPL",
 			"Headphone Jack", "HPR",
@@ -204,15 +204,32 @@
 			"Speaker", "Speaker",
 			"Microphone", "Mic Jack";
 
-		simple-audio-card,mclk-fs = <256>;
-
-		simple-audio-card,cpu {
-			sound-dai = <&audio>;
+		simple-audio-card,dai-link at 0 { /* Front end */
+			dynamic;
+			dpcm_playback;
+			dpcm_capture;
+			cpu {
+				sound-dai = <&audio 0>;
+			};
+			codec {
+				snd-soc-dummy;
+			};
 		};
-
-		simple-audio-card,codec {
-			sound-dai = <&alc5621>;
+		simple-audio-card,dia-link at 1 { /* I2S Backend */
+			format = "i2s";
+			dpcm_playback;
+			dpcm_capture;
+			no_pcm;
+			mclk-fs = <256>;
+			platform_name = "snd-soc-dummy";
+			cpu {
+				sound-dai = <&audio 1>;
+			};
+			codec {
+				sound-dai = <&alc5621>;
+			};
 		};
+
 	};
 };
 
Signature · 1 line
2.0.1
#9 lore raw

cover DPCM with simple-card support for Kirkwood

In reply to Andrew Lunn
Quoted 9 lines · On Wed, 6 Aug 2014 03:18:24 +0200 Andrew Lunn <[email protected]> wrote:

30 June you posted your code to implement DPCM for kirkwood-i2s, making it possible to use both I2S and SPDIF at the same time.

It has taken me a while, but i now have this patch on 3.16-rc6, and i've extended simple-card to support DPCM. I've tested it on a kirkwood based HP T5325, which only makes use of the I2S backend.

Please could you take a look and see if this helps to unblock getting your Cubox support into mainline.

Andrew,

I had quite the same code as yours end 2013, and, if I did not miss something:

- you cannot put Linux specific stuff in the DT:
http://mailman.alsa-project.org/pipermail/alsa-devel/2013-December/070595.html
http://mailman.alsa-project.org/pipermail/alsa-devel/2014-January/070622.html

- the DPCM code does not handle the formats and rates of the back-ends:
http://mailman.alsa-project.org/pipermail/alsa-devel/2013-December/070585.html

Some more information may be found at:
http://mailman.alsa-project.org/pipermail/alsa-devel/2014-January/070798.html

Signature · 2 lines
Ken ar c'henta?	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
#10 lore raw

cover DPCM with simple-card support for Kirkwood

Quoted 10 lines · Jean-Francois Moine
Quoted 7 lines · On Wed, 6 Aug 2014 03:18:24 +0200 Andrew Lunn <[email protected]> wrote:

30 June you posted your code to implement DPCM for kirkwood-i2s, making it possible to use both I2S and SPDIF at the same time.

It has taken me a while, but i now have this patch on 3.16-rc6, and i've extended simple-card to support DPCM. I've tested it on a kirkwood based HP T5325, which only makes use of the I2S backend.

Quoted 7 lines
Quoted 2 lines

Please could you take a look and see if this helps to unblock getting your Cubox support into mainline.

Andrew,

I had quite the same code as yours end 2013, and, if I did not miss something:

Hi Jean

At the moment, i'm not so interested in details, but more about, is this the right direction to allow Russell to progress. Once i know that, we can work on details.

Quoted 3 lines

- you cannot put Linux specific stuff in the DT:
http://mailman.alsa-project.org/pipermail/alsa-devel/2013-December/070595.html
http://mailman.alsa-project.org/pipermail/alsa-devel/2014-January/070622.html

The binding is not nice, and i know that. I want to simplify it. I need to look at other DPCM users and see what is possible. It might be i can just have two booleans: dpcm_frontend and dpcm_backend, and derive everything else from these. As of 3.16, there only appears to be one other dpcm user, intel haswell. There is a lot in common with kirkwood, needing to use the snd-soc-dummy, dummy platform, setting no_pcm, etc. So for simple-card, i can probably just assume these can be implied from flags like dpcm_frontend and dpcm_backend? It looks like you had the same idea at the end of 2013.

Quoted 5 lines

- the DPCM code does not handle the formats and rates of the back-ends:
http://mailman.alsa-project.org/pipermail/alsa-devel/2013-December/070585.html

Some more information may be found at:
http://mailman.alsa-project.org/pipermail/alsa-devel/2014-January/070798.html

I've not run into these problems, but i have not tested too much. Once we have the general direction decided, we should try to work on this together to fix it.

Andrew

#11 lore raw

cover DPCM with simple-card support for Kirkwood

Quoted 3 lines · On Wed, 6 Aug 2014 16:30:26 +0200 Andrew Lunn <[email protected]> wrote:

At the moment, i'm not so interested in details, but more about, is this the right direction to allow Russell to progress. Once i know that, we can work on details.

These are not details. Putting DPCM in the Cubox is easy (I may send you my work which seems simpler), but there is no way to make it work correctly, and that's why I forgot about it.

The recent multi-CODEC seems more promising. I will have a look at it as soon as I will be less busy.

Signature · 2 lines
Ken ar c'henta?	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
#12 lore raw

cover DPCM with simple-card support for Kirkwood

Quoted 10 lines · Jean-Francois Moine
Quoted 3 lines · On Wed, 6 Aug 2014 16:30:26 +0200 Andrew Lunn <[email protected]> wrote:

At the moment, i'm not so interested in details, but more about, is this the right direction to allow Russell to progress. Once i know that, we can work on details.

These are not details. Putting DPCM in the Cubox is easy (I may send you my work which seems simpler), but there is no way to make it work correctly, and that's why I forgot about it.

Does it not work correctly because of a property of the hardware, or because of bugs in the DPCM implementation? From what you pointed out in the mailing lists, it seems like bugs.

Thanks
Andrew

#13 lore raw

cover DPCM with simple-card support for Kirkwood

Quoted 3 lines · On Wed, 6 Aug 2014 19:53:13 +0200 Andrew Lunn <[email protected]> wrote:

Does it not work correctly because of a property of the hardware, or because of bugs in the DPCM implementation? From what you pointed out in the mailing lists, it seems like bugs.

As I explained, DPCM shunts the routing. The constraints are not handled, so, the formats and rates are always those of the front-end. And this is normal, because DPCM is done for devices with a firmware which adapts the back-ends to the chosen front-end format and rate.

Signature · 2 lines
Ken ar c'henta?	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/