All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/8] DPCM with simple-card support for Kirkwood
@ 2014-08-06  1:18 Andrew Lunn
  2014-08-06  1:18 ` [RFC 1/8] ASoC: kirkwood: add DPCM support Andrew Lunn
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Andrew Lunn @ 2014-08-06  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

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

-- 
2.0.1

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

* [RFC 1/8] ASoC: kirkwood: add DPCM support
  2014-08-06  1:18 [RFC 0/8] DPCM with simple-card support for Kirkwood Andrew Lunn
@ 2014-08-06  1:18 ` Andrew Lunn
  2014-08-06  1:18 ` [RFC 2/8] ASoC: simple-card: Make mclk setting a dai link property Andrew Lunn
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2014-08-06  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

From: Russell King <rmk+kernel@arm.linux.org.uk>

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.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 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(-)

diff --git a/arch/arm/boot/dts/kirkwood-t5325.dts b/arch/arm/boot/dts/kirkwood-t5325.dts
index 610ec0f95858..cc6cd0bdcfac 100644
--- a/arch/arm/boot/dts/kirkwood-t5325.dts
+++ b/arch/arm/boot/dts/kirkwood-t5325.dts
@@ -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",
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 0704cd6d2314..7e075d4da8c4 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -37,6 +37,18 @@
 	(SNDRV_PCM_FMTBIT_S16_LE | \
 	 SNDRV_PCM_FMTBIT_S24_LE)
 
+/* Workaround ASoC not respecting backend restrictions */
+#define KIRKWOOD_FE_FORMATS (KIRKWOOD_I2S_FORMATS & KIRKWOOD_SPDIF_FORMATS)
+
+enum {
+	KW_DAI_FE,
+	KW_DAI_BE_I2S,
+	KW_DAI_BE_SPDIF,
+
+	KW_DAI_BE_SPDIF_PLAYBACK = BIT(0),
+	KW_DAI_BE_SPDIF_CAPTURE = BIT(1),
+};
+
 static int kirkwood_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
 		unsigned int fmt)
 {
@@ -261,13 +273,12 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
+		if (priv->ctl_play_mask == ~KIRKWOOD_PLAYCTL_ENABLE_MASK)
+			return -EINVAL;
+
 		/* configure */
-		ctl = priv->ctl_play;
-		if (dai->id == 0)
-			ctl &= ~KIRKWOOD_PLAYCTL_SPDIF_EN;	/* i2s */
-		else
-			ctl &= ~KIRKWOOD_PLAYCTL_I2S_EN;	/* spdif */
-		ctl = kirkwood_i2s_play_mute(ctl);
+		ctl = kirkwood_i2s_play_mute(priv->ctl_play &
+					     priv->ctl_play_mask);
 		value = ctl & ~KIRKWOOD_PLAYCTL_ENABLE_MASK;
 		writel(value, priv->io + KIRKWOOD_PLAYCTL);
 
@@ -329,13 +340,11 @@ static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream,
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
-		/* configure */
-		ctl = priv->ctl_rec;
-		if (dai->id == 0)
-			ctl &= ~KIRKWOOD_RECCTL_SPDIF_EN;	/* i2s */
-		else
-			ctl &= ~KIRKWOOD_RECCTL_I2S_EN;		/* spdif */
+		if (priv->ctl_rec_mask == ~KIRKWOOD_RECCTL_ENABLE_MASK)
+			return -EINVAL;
 
+		/* configure */
+		ctl = priv->ctl_rec & priv->ctl_rec_mask;
 		value = ctl & ~KIRKWOOD_RECCTL_ENABLE_MASK;
 		writel(value, priv->io + KIRKWOOD_RECCTL);
 
@@ -396,8 +405,9 @@ static int kirkwood_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
 	return 0;
 }
 
-static int kirkwood_i2s_init(struct kirkwood_dma_data *priv)
+static int kirkwood_fe_probe(struct snd_soc_dai *dai)
 {
+	struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
 	unsigned long value;
 	unsigned int reg_data;
 
@@ -431,97 +441,134 @@ static int kirkwood_i2s_init(struct kirkwood_dma_data *priv)
 
 }
 
-static const struct snd_soc_dai_ops kirkwood_i2s_dai_ops = {
+static const struct snd_soc_dai_ops kirkwood_dai_fe_ops = {
 	.startup	= kirkwood_i2s_startup,
 	.trigger	= kirkwood_i2s_trigger,
 	.hw_params      = kirkwood_i2s_hw_params,
 	.set_fmt        = kirkwood_i2s_set_fmt,
 };
 
-static struct snd_soc_dai_driver kirkwood_i2s_dai[2] = {
-    {
-	.name = "i2s",
-	.id = 0,
-	.playback = {
-		.channels_min = 1,
-		.channels_max = 2,
-		.rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_96000,
-		.formats = KIRKWOOD_I2S_FORMATS,
-	},
-	.capture = {
-		.channels_min = 1,
-		.channels_max = 2,
-		.rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
-				SNDRV_PCM_RATE_96000,
-		.formats = KIRKWOOD_I2S_FORMATS,
-	},
-	.ops = &kirkwood_i2s_dai_ops,
-    },
-    {
-	.name = "spdif",
-	.id = 1,
+static int kirkwood_i2s_be_startup(struct snd_pcm_substream *substream,
+	struct snd_soc_dai *dai)
+{
+	struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
+
+	switch (dai->id) {
+	case KW_DAI_BE_I2S:
+		priv->ctl_play_mask |= KIRKWOOD_PLAYCTL_I2S_EN;
+		priv->ctl_rec_mask |= KIRKWOOD_RECCTL_I2S_EN;
+		break;
+
+	case KW_DAI_BE_SPDIF:
+		priv->ctl_play_mask |= KIRKWOOD_PLAYCTL_SPDIF_EN;
+		priv->ctl_rec_mask |= KIRKWOOD_RECCTL_SPDIF_EN;
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void kirkwood_i2s_be_shutdown(struct snd_pcm_substream *substream,
+	struct snd_soc_dai *dai)
+{
+	struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
+
+	switch (dai->id) {
+	case KW_DAI_BE_I2S:
+		priv->ctl_play_mask &= ~KIRKWOOD_PLAYCTL_I2S_EN;
+		priv->ctl_rec_mask &= ~KIRKWOOD_RECCTL_I2S_EN;
+		break;
+
+	case KW_DAI_BE_SPDIF:
+		priv->ctl_play_mask &= ~KIRKWOOD_PLAYCTL_SPDIF_EN;
+		priv->ctl_rec_mask &= ~KIRKWOOD_RECCTL_SPDIF_EN;
+		break;
+	}
+}
+
+static const struct snd_soc_dai_ops kirkwood_i2s_be_dai_ops = {
+	.startup	= kirkwood_i2s_be_startup,
+	.shutdown	= kirkwood_i2s_be_shutdown,
+};
+
+
+static const struct snd_soc_dai_driver kirkwood_dai_fe = {
+	.name = "kirkwood-fe",
+	.id = KW_DAI_FE,
+	.probe = kirkwood_fe_probe,
 	.playback = {
+		.stream_name = "dma-tx",
 		.channels_min = 1,
 		.channels_max = 2,
 		.rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
 				SNDRV_PCM_RATE_96000,
-		.formats = KIRKWOOD_SPDIF_FORMATS,
+		.formats = KIRKWOOD_FE_FORMATS,
 	},
 	.capture = {
+		.stream_name = "dma-rx",
 		.channels_min = 1,
 		.channels_max = 2,
 		.rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
 				SNDRV_PCM_RATE_96000,
-		.formats = KIRKWOOD_SPDIF_FORMATS,
+		.formats = KIRKWOOD_FE_FORMATS,
 	},
-	.ops = &kirkwood_i2s_dai_ops,
-    },
+	.ops = &kirkwood_dai_fe_ops,
 };
 
-static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = {
-    {
-	.name = "i2s",
-	.id = 0,
+static const struct snd_soc_dai_driver kirkwood_dai_fe_extclk = {
+	.name = "kirkwood-fe",
+	.id = KW_DAI_FE,
+	.probe = kirkwood_fe_probe,
 	.playback = {
+		.stream_name = "dma-tx",
 		.channels_min = 1,
 		.channels_max = 2,
-		.rates = SNDRV_PCM_RATE_CONTINUOUS,
-		.rate_min = 5512,
-		.rate_max = 192000,
-		.formats = KIRKWOOD_I2S_FORMATS,
+		.rates = SNDRV_PCM_RATE_8000_192000 |
+			 SNDRV_PCM_RATE_CONTINUOUS |
+			 SNDRV_PCM_RATE_KNOT,
+		.formats = KIRKWOOD_FE_FORMATS,
 	},
 	.capture = {
+		.stream_name = "dma-rx",
 		.channels_min = 1,
 		.channels_max = 2,
-		.rates = SNDRV_PCM_RATE_CONTINUOUS,
-		.rate_min = 5512,
-		.rate_max = 192000,
-		.formats = KIRKWOOD_I2S_FORMATS,
-	},
-	.ops = &kirkwood_i2s_dai_ops,
-    },
-    {
-	.name = "spdif",
-	.id = 1,
-	.playback = {
-		.channels_min = 1,
-		.channels_max = 2,
-		.rates = SNDRV_PCM_RATE_CONTINUOUS,
-		.rate_min = 5512,
-		.rate_max = 192000,
-		.formats = KIRKWOOD_SPDIF_FORMATS,
+		.rates = SNDRV_PCM_RATE_8000_192000 |
+			 SNDRV_PCM_RATE_CONTINUOUS |
+			 SNDRV_PCM_RATE_KNOT,
+		.formats = KIRKWOOD_FE_FORMATS,
 	},
-	.capture = {
-		.channels_min = 1,
-		.channels_max = 2,
-		.rates = SNDRV_PCM_RATE_CONTINUOUS,
-		.rate_min = 5512,
-		.rate_max = 192000,
-		.formats = KIRKWOOD_SPDIF_FORMATS,
+	.ops = &kirkwood_dai_fe_ops,
+};
+
+static const struct snd_soc_dai_driver kirkwood_dai_be[] = {
+	{
+		.name = "kirkwood-i2s",
+		.id = KW_DAI_BE_I2S,
+		.ops = &kirkwood_i2s_be_dai_ops,
+		.playback = {
+			.stream_name = "i2s-tx",
+			.formats = KIRKWOOD_I2S_FORMATS,
+		},
+		.capture = {
+			.stream_name = "i2s-rx",
+			.formats = KIRKWOOD_I2S_FORMATS,
+		},
+	}, {
+		.name = "kirkwood-spdif",
+		.id = KW_DAI_BE_SPDIF,
+		.ops = &kirkwood_i2s_be_dai_ops,
+		.playback = {
+			.stream_name = "spdif-tx",
+			.formats = KIRKWOOD_SPDIF_FORMATS,
+		},
+		.capture = {
+			.stream_name = "spdif-rx",
+			.formats = KIRKWOOD_SPDIF_FORMATS,
+		},
 	},
-	.ops = &kirkwood_i2s_dai_ops,
-    },
 };
 
 static const struct snd_soc_component_driver kirkwood_i2s_component = {
@@ -531,10 +578,12 @@ static const struct snd_soc_component_driver kirkwood_i2s_component = {
 static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 {
 	struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data;
-	struct snd_soc_dai_driver *soc_dai = kirkwood_i2s_dai;
+	const struct snd_soc_dai_driver *soc_dai = &kirkwood_dai_fe;
+	struct snd_soc_dai_driver *dai;
 	struct kirkwood_dma_data *priv;
 	struct resource *mem;
 	struct device_node *np = pdev->dev.of_node;
+	unsigned i;
 	int err;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -555,6 +604,13 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
+	/*
+	 * We currently have no way to determine whether SPDIF playback
+	 * or capture is currently supported; take the middle ground
+	 * for the time being until DT/platform data passes this detail.
+	 */
+	priv->have_spdif = KW_DAI_BE_SPDIF_PLAYBACK;
+
 	if (np) {
 		priv->burst = 128;		/* might be 32 or 128 */
 	} else if (data) {
@@ -585,13 +641,15 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 		} else {
 			dev_info(&pdev->dev, "found external clock\n");
 			clk_prepare_enable(priv->extclk);
-			soc_dai = kirkwood_i2s_dai_extclk;
+			soc_dai = &kirkwood_dai_fe_extclk;
 		}
 	}
 
 	/* Some sensible defaults - this reflects the powerup values */
 	priv->ctl_play = KIRKWOOD_PLAYCTL_SIZE_24;
 	priv->ctl_rec = KIRKWOOD_RECCTL_SIZE_24;
+	priv->ctl_play_mask = ~KIRKWOOD_PLAYCTL_ENABLE_MASK;
+	priv->ctl_rec_mask = ~KIRKWOOD_RECCTL_ENABLE_MASK;
 
 	/* Select the burst size */
 	if (priv->burst == 32) {
@@ -602,8 +660,35 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 		priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128;
 	}
 
+	dai = priv->dai_driver;
+	memcpy(dai, soc_dai, sizeof(*dai));
+
+	/* Copy the frontend channels and rates to the backends */
+	for (i = 1; i < ARRAY_SIZE(priv->dai_driver); i++) {
+		memcpy(&dai[i], &kirkwood_dai_be[i - 1], sizeof(*dai));
+		dai[i].playback.channels_min = dai[0].playback.channels_min;
+		dai[i].playback.channels_max = dai[0].playback.channels_max;
+		dai[i].playback.rates        = dai[0].playback.rates;
+		dai[i].playback.rate_min     = dai[0].playback.rate_min;
+		dai[i].playback.rate_max     = dai[0].playback.rate_max;
+		dai[i].capture.channels_min  = dai[0].capture.channels_min;
+		dai[i].capture.channels_max  = dai[0].capture.channels_max;
+		dai[i].capture.rates         = dai[0].capture.rates;
+		dai[i].capture.rate_min      = dai[0].capture.rate_min;
+		dai[i].capture.rate_max      = dai[0].capture.rate_max;
+	}
+
+	/*
+	 * Kill the SPDIF stream information according to
+	 * the capabilities we have on this device.
+	 */
+	if (!(priv->have_spdif & KW_DAI_BE_SPDIF_PLAYBACK))
+		memset(&dai[2].playback, 0, sizeof(dai[2].playback));
+	if (!(priv->have_spdif & KW_DAI_BE_SPDIF_CAPTURE))
+		memset(&dai[2].capture, 0, sizeof(dai[2].capture));
+
 	err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component,
-					 soc_dai, 2);
+					 dai, 2 + !!priv->have_spdif);
 	if (err) {
 		dev_err(&pdev->dev, "snd_soc_register_component failed\n");
 		goto err_component;
@@ -615,9 +700,8 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 		goto err_platform;
 	}
 
-	kirkwood_i2s_init(priv);
-
 	return 0;
+
  err_platform:
 	snd_soc_unregister_component(&pdev->dev);
  err_component:
diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h
index 90e32a781424..5a5a48944976 100644
--- a/sound/soc/kirkwood/kirkwood.h
+++ b/sound/soc/kirkwood/kirkwood.h
@@ -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
-- 
2.0.1

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

* [RFC 2/8] ASoC: simple-card: Make mclk setting a dai link property
  2014-08-06  1:18 [RFC 0/8] DPCM with simple-card support for Kirkwood Andrew Lunn
  2014-08-06  1:18 ` [RFC 1/8] ASoC: kirkwood: add DPCM support Andrew Lunn
@ 2014-08-06  1:18 ` Andrew Lunn
  2014-08-06  1:18 ` [RFC 3/8] ARM: Kirkwood: Update sound DT node to reflect DPCM support Andrew Lunn
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2014-08-06  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---

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

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index c2e9841dfce4..8b9f902cdfc7 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -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
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 03a7fdcdf114..63f3d16d43ba 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -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 : "");
 
-- 
2.0.1

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

* [RFC 3/8] ARM: Kirkwood: Update sound DT node to reflect DPCM support
  2014-08-06  1:18 [RFC 0/8] DPCM with simple-card support for Kirkwood Andrew Lunn
  2014-08-06  1:18 ` [RFC 1/8] ASoC: kirkwood: add DPCM support Andrew Lunn
  2014-08-06  1:18 ` [RFC 2/8] ASoC: simple-card: Make mclk setting a dai link property Andrew Lunn
@ 2014-08-06  1:18 ` Andrew Lunn
  2014-08-06  1:18 ` [RFC 4/8] ASoC: dt: Parse DPCM properties Andrew Lunn
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2014-08-06  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 arch/arm/boot/dts/kirkwood.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index afc640cd80c5..69b4cee1f4d3 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -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>;
-- 
2.0.1

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

* [RFC 4/8] ASoC: dt: Parse DPCM properties
  2014-08-06  1:18 [RFC 0/8] DPCM with simple-card support for Kirkwood Andrew Lunn
                   ` (2 preceding siblings ...)
  2014-08-06  1:18 ` [RFC 3/8] ARM: Kirkwood: Update sound DT node to reflect DPCM support Andrew Lunn
@ 2014-08-06  1:18 ` Andrew Lunn
  2014-08-06  1:18 ` [RFC 5/8] ASoC: simple-card: Don't set DAI format for dynamic DAIs Andrew Lunn
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2014-08-06  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 .../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(+)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index 8b9f902cdfc7..cba8b8406bb0 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -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
diff --git a/include/sound/soc.h b/include/sound/soc.h
index ed9e2d7e5fdc..060e2f955292 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -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);
 
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 63f3d16d43ba..735a54099b8d 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -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);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 91120b8e283e..8aa3a21d37af 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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)
 {
-- 
2.0.1

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

* [RFC 5/8] ASoC: simple-card: Don't set DAI format for dynamic DAIs
  2014-08-06  1:18 [RFC 0/8] DPCM with simple-card support for Kirkwood Andrew Lunn
                   ` (3 preceding siblings ...)
  2014-08-06  1:18 ` [RFC 4/8] ASoC: dt: Parse DPCM properties Andrew Lunn
@ 2014-08-06  1:18 ` Andrew Lunn
  2014-08-06  1:18 ` [RFC 6/8] ASoC: dt: Allow the platform name to be set for a DAI Andrew Lunn
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2014-08-06  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 sound/soc/generic/simple-card.c | 88 +++++++++++++++++++++++++----------------
 1 file changed, 55 insertions(+), 33 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 735a54099b8d..c3235923b12f 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -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) {
-- 
2.0.1

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

* [RFC 6/8] ASoC: dt: Allow the platform name to be set for a DAI
  2014-08-06  1:18 [RFC 0/8] DPCM with simple-card support for Kirkwood Andrew Lunn
                   ` (4 preceding siblings ...)
  2014-08-06  1:18 ` [RFC 5/8] ASoC: simple-card: Don't set DAI format for dynamic DAIs Andrew Lunn
@ 2014-08-06  1:18 ` Andrew Lunn
  2014-08-06  1:18 ` [RFC 7/8] ASoC: simple-card: Allow use of snd-soc-dummy as codec Andrew Lunn
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2014-08-06  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 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(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 060e2f955292..3e4fd6eb5f32 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -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);
 
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index c3235923b12f..a99aad16d8f9 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -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,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 8aa3a21d37af..667129078e44 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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)
 {
-- 
2.0.1

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

* [RFC 7/8] ASoC: simple-card: Allow use of snd-soc-dummy as codec
  2014-08-06  1:18 [RFC 0/8] DPCM with simple-card support for Kirkwood Andrew Lunn
                   ` (5 preceding siblings ...)
  2014-08-06  1:18 ` [RFC 6/8] ASoC: dt: Allow the platform name to be set for a DAI Andrew Lunn
@ 2014-08-06  1:18 ` Andrew Lunn
  2014-08-06  1:18 ` [RFC 8/8] ARM: Kirkwood: Describe DPCM audio support in DT Andrew Lunn
  2014-08-06  8:33 ` [RFC 0/8] DPCM with simple-card support for Kirkwood Jean-Francois Moine
  8 siblings, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2014-08-06  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 .../devicetree/bindings/sound/simple-card.txt      |  3 +++
 sound/soc/generic/simple-card.c                    | 27 ++++++++++++++--------
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index cba8b8406bb0..79ba1138dfa8 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -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:
 
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index a99aad16d8f9..e7fccd0940bb 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -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;
 
-- 
2.0.1

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

* [RFC 8/8] ARM: Kirkwood: Describe DPCM audio support in DT
  2014-08-06  1:18 [RFC 0/8] DPCM with simple-card support for Kirkwood Andrew Lunn
                   ` (6 preceding siblings ...)
  2014-08-06  1:18 ` [RFC 7/8] ASoC: simple-card: Allow use of snd-soc-dummy as codec Andrew Lunn
@ 2014-08-06  1:18 ` Andrew Lunn
  2014-08-06  8:33 ` [RFC 0/8] DPCM with simple-card support for Kirkwood Jean-Francois Moine
  8 siblings, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2014-08-06  1:18 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 arch/arm/boot/dts/kirkwood-openrd-client.dts | 39 +++++++++++++++++++++++-----
 arch/arm/boot/dts/kirkwood-t5325.dts         | 33 +++++++++++++++++------
 2 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/arch/arm/boot/dts/kirkwood-openrd-client.dts b/arch/arm/boot/dts/kirkwood-openrd-client.dts
index 887b9c1fee43..2cb216512ff2 100644
--- a/arch/arm/boot/dts/kirkwood-openrd-client.dts
+++ b/arch/arm/boot/dts/kirkwood-openrd-client.dts
@@ -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>;
+			};
 		};
 	};
 };
diff --git a/arch/arm/boot/dts/kirkwood-t5325.dts b/arch/arm/boot/dts/kirkwood-t5325.dts
index cc6cd0bdcfac..f9466a2858c9 100644
--- a/arch/arm/boot/dts/kirkwood-t5325.dts
+++ b/arch/arm/boot/dts/kirkwood-t5325.dts
@@ -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>;
+			};
 		};
+
 	};
 };
 
-- 
2.0.1

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

* [RFC 0/8] DPCM with simple-card support for Kirkwood
  2014-08-06  1:18 [RFC 0/8] DPCM with simple-card support for Kirkwood Andrew Lunn
                   ` (7 preceding siblings ...)
  2014-08-06  1:18 ` [RFC 8/8] ARM: Kirkwood: Describe DPCM audio support in DT Andrew Lunn
@ 2014-08-06  8:33 ` Jean-Francois Moine
  2014-08-06 14:30   ` Andrew Lunn
  8 siblings, 1 reply; 14+ messages in thread
From: Jean-Francois Moine @ 2014-08-06  8:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed,  6 Aug 2014 03:18:24 +0200
Andrew Lunn <andrew@lunn.ch> 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

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

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

* [RFC 0/8] DPCM with simple-card support for Kirkwood
  2014-08-06  8:33 ` [RFC 0/8] DPCM with simple-card support for Kirkwood Jean-Francois Moine
@ 2014-08-06 14:30   ` Andrew Lunn
  2014-08-06 17:43     ` Jean-Francois Moine
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Lunn @ 2014-08-06 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 06, 2014 at 10:33:56AM +0200, Jean-Francois Moine wrote:
> On Wed,  6 Aug 2014 03:18:24 +0200
> Andrew Lunn <andrew@lunn.ch> 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:

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

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

* [RFC 0/8] DPCM with simple-card support for Kirkwood
  2014-08-06 14:30   ` Andrew Lunn
@ 2014-08-06 17:43     ` Jean-Francois Moine
  2014-08-06 17:53       ` Andrew Lunn
  0 siblings, 1 reply; 14+ messages in thread
From: Jean-Francois Moine @ 2014-08-06 17:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 6 Aug 2014 16:30:26 +0200
Andrew Lunn <andrew@lunn.ch> 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.

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

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

* [RFC 0/8] DPCM with simple-card support for Kirkwood
  2014-08-06 17:43     ` Jean-Francois Moine
@ 2014-08-06 17:53       ` Andrew Lunn
  2014-08-06 18:29         ` Jean-Francois Moine
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Lunn @ 2014-08-06 17:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 06, 2014 at 07:43:04PM +0200, Jean-Francois Moine wrote:
> On Wed, 6 Aug 2014 16:30:26 +0200
> Andrew Lunn <andrew@lunn.ch> 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

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

* [RFC 0/8] DPCM with simple-card support for Kirkwood
  2014-08-06 17:53       ` Andrew Lunn
@ 2014-08-06 18:29         ` Jean-Francois Moine
  0 siblings, 0 replies; 14+ messages in thread
From: Jean-Francois Moine @ 2014-08-06 18:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 6 Aug 2014 19:53:13 +0200
Andrew Lunn <andrew@lunn.ch> 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.

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

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

end of thread, other threads:[~2014-08-06 18:29 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-06  1:18 [RFC 0/8] DPCM with simple-card support for Kirkwood Andrew Lunn
2014-08-06  1:18 ` [RFC 1/8] ASoC: kirkwood: add DPCM support Andrew Lunn
2014-08-06  1:18 ` [RFC 2/8] ASoC: simple-card: Make mclk setting a dai link property Andrew Lunn
2014-08-06  1:18 ` [RFC 3/8] ARM: Kirkwood: Update sound DT node to reflect DPCM support Andrew Lunn
2014-08-06  1:18 ` [RFC 4/8] ASoC: dt: Parse DPCM properties Andrew Lunn
2014-08-06  1:18 ` [RFC 5/8] ASoC: simple-card: Don't set DAI format for dynamic DAIs Andrew Lunn
2014-08-06  1:18 ` [RFC 6/8] ASoC: dt: Allow the platform name to be set for a DAI Andrew Lunn
2014-08-06  1:18 ` [RFC 7/8] ASoC: simple-card: Allow use of snd-soc-dummy as codec Andrew Lunn
2014-08-06  1:18 ` [RFC 8/8] ARM: Kirkwood: Describe DPCM audio support in DT Andrew Lunn
2014-08-06  8:33 ` [RFC 0/8] DPCM with simple-card support for Kirkwood Jean-Francois Moine
2014-08-06 14:30   ` Andrew Lunn
2014-08-06 17:43     ` Jean-Francois Moine
2014-08-06 17:53       ` Andrew Lunn
2014-08-06 18:29         ` Jean-Francois Moine

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.