[5/6] ASoC: rsnd: care DMA slave channel name for DT
diff mbox

Message ID 87iooxc8pg.wl%kuninori.morimoto.gx@renesas.com
State Accepted
Commit 199e7688bdf7d188d70c3432c96ec13d8a14b341
Headers show

Commit Message

Kuninori Morimoto May 23, 2014, 6:25 a.m. UTC
Renesas sound driver is supporting to use DMAEngine.
But, DMA slave channel name "tx", "rx" is not enough
in DT case.
Becuase, it has many ports and path combination.

This patch adds rsnd_dma_of_name() to find
DMA channel name, for example
memory to SSI0 is "mem_ssi0",
SSI0 to memory is "ssi0_mem",
SSI0 to SRC0   is "ssi0_src0",
SRC0 to SSI0   is "src0_ssi0",
SRC0 to DVC0   is "src0_dvc0"...

Renesas sound want to use PIO transfer mode for some reasons.
It will be PIO tranfer mode if device node doesn't have
DMA settings.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 .../devicetree/bindings/sound/renesas,rsnd.txt     |    1 +
 sound/soc/sh/rcar/core.c                           |   80 +++++++++++++++++++-
 sound/soc/sh/rcar/ssi.c                            |    6 ++
 3 files changed, 86 insertions(+), 1 deletion(-)

Comments

Ben Dooks June 2, 2014, 9:33 p.m. UTC | #1
On 23/05/14 07:25, Kuninori Morimoto wrote:
> Renesas sound driver is supporting to use DMAEngine.
> But, DMA slave channel name "tx", "rx" is not enough
> in DT case.
> Becuase, it has many ports and path combination.
> 
> This patch adds rsnd_dma_of_name() to find
> DMA channel name, for example
> memory to SSI0 is "mem_ssi0",
> SSI0 to memory is "ssi0_mem",
> SSI0 to SRC0   is "ssi0_src0",
> SRC0 to SSI0   is "src0_ssi0",
> SRC0 to DVC0   is "src0_dvc0"...

I commented on another patch where the ssiX nodes are not being
used, this would be so much nicer if we removed the ssiX from the
name and used the of-pointer for the ssiX node to lookup the DMA...

This is going to produce a hugh list of DMA entries that are going
to be difficult to manage.

> Renesas sound want to use PIO transfer mode for some reasons.
> It will be PIO tranfer mode if device node doesn't have
> DMA settings.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  .../devicetree/bindings/sound/renesas,rsnd.txt     |    1 +
>  sound/soc/sh/rcar/core.c                           |   80 +++++++++++++++++++-
>  sound/soc/sh/rcar/ssi.c                            |    6 ++
>  3 files changed, 86 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
> index a44e917..8346cab 100644
> --- a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
> +++ b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
> @@ -20,6 +20,7 @@ Required properties:
>  SSI subnode properties:
>  - interrupts			: Should contain SSI interrupt for PIO transfer
>  - shared-pin			: if shared clock pin
> +- pio-transfer			: use PIO transfer mode
>  
>  SRC subnode properties:
>  no properties at this poin

> diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
> index 2d94a62..e0a4ba7 100644
> --- a/sound/soc/sh/rcar/ssi.c
> +++ b/sound/soc/sh/rcar/ssi.c
> @@ -589,6 +589,12 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev,
>  		 * irq
>  		 */
>  		ssi_info->pio_irq = irq_of_parse_and_map(np, 0);
> +
> +		/*
> +		 * DMA
> +		 */
> +		ssi_info->dma_id = of_get_property(np, "pio-transfer", NULL) ?
> +			0 : 1;

How about checking for the dma node, and if no present?
Kuninori Morimoto June 3, 2014, 12:43 a.m. UTC | #2
Hi Ben

> > Renesas sound driver is supporting to use DMAEngine.
> > But, DMA slave channel name "tx", "rx" is not enough
> > in DT case.
> > Becuase, it has many ports and path combination.
> > 
> > This patch adds rsnd_dma_of_name() to find
> > DMA channel name, for example
> > memory to SSI0 is "mem_ssi0",
> > SSI0 to memory is "ssi0_mem",
> > SSI0 to SRC0   is "ssi0_src0",
> > SRC0 to SSI0   is "src0_ssi0",
> > SRC0 to DVC0   is "src0_dvc0"...
> 
> I commented on another patch where the ssiX nodes are not being
> used, this would be so much nicer if we removed the ssiX from the
> name and used the of-pointer for the ssiX node to lookup the DMA...
> 
> This is going to produce a hugh list of DMA entries that are going
> to be difficult to manage.

Thank you for your comment.
I understand your opinion.
But, I don't want to use such style for DMA IMO.

You know R-Car sound is very complex IP collection.
And user want to use it as several patterns.
If SSI nodes has its specific DMA setting,
this means SRC/DVC needs to have same style too.

The DMA entry for SSI/SRC/DVC depends on data path.
This means, user *must* understand which IP can use which DMA.
(You know, R-Car sound uses Audio DMAC/Audio DMAC peri peri,
 and the pattern/use case is very complex)
And, user must care his DAI too.
If user failed his settings (= DAI and DMA entry for SSI/SRC/DVC),
someone (maybe me) needs to explain how R-Car sound is complex.
Then ask his DAI settings, research DMA settings, and answer.
This will happen for all user/integrater.
But, I don't want it :P

     * all settings must be correct *
     * but, it is difficult for user/beginner *

     playback = <&ssi0 &src1 &dvc0>;

     &ssi0 { dmas = <xxx>, dma-names = xxx };
     &src1 { dmas = <xxx>, dma-names = xxx };
     &dvc0 { dmas = <xxx>, dma-names = xxx };

Indeed above case needs many DMA entries on SoC DTSI file,
but, DMA entry for SSI/SRC/DVC will be decided automatically.
This case, user cares DAI only, it is very easy IMO.

     * user care only his DAI setting *

     playback = <&ssi0 &src1 &dvc0>;
     
     * it is very easy to exchange DAI setting *

     playback = <&ssi0 &src3>;

Patch
diff mbox

diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
index a44e917..8346cab 100644
--- a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
+++ b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
@@ -20,6 +20,7 @@  Required properties:
 SSI subnode properties:
 - interrupts			: Should contain SSI interrupt for PIO transfer
 - shared-pin			: if shared clock pin
+- pio-transfer			: use PIO transfer mode
 
 SRC subnode properties:
 no properties at this point
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 073a293..cddb76d 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -256,11 +256,81 @@  int rsnd_dma_available(struct rsnd_dma *dma)
 	return !!dma->chan;
 }
 
+#define DMA_NAME_SIZE 16
+#define MOD_MAX 4 /* MEM/SSI/SRC/DVC */
+static int _rsnd_dma_of_name(char *dma_name, struct rsnd_mod *mod)
+{
+	if (mod)
+		return snprintf(dma_name, DMA_NAME_SIZE / 2, "%s%d",
+			 rsnd_mod_name(mod), rsnd_mod_id(mod));
+	else
+		return snprintf(dma_name, DMA_NAME_SIZE / 2, "mem");
+
+}
+
+static void rsnd_dma_of_name(struct rsnd_dma *dma,
+			     int is_play, char *dma_name)
+{
+	struct rsnd_mod *this = rsnd_dma_to_mod(dma);
+	struct rsnd_dai_stream *io = rsnd_mod_to_io(this);
+	struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io);
+	struct rsnd_mod *src = rsnd_io_to_mod_src(io);
+	struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io);
+	struct rsnd_mod *mod[MOD_MAX];
+	struct rsnd_mod *src_mod, *dst_mod;
+	int i, index;
+
+
+	for (i = 0; i < MOD_MAX; i++)
+		mod[i] = NULL;
+
+	/*
+	 * in play case...
+	 *
+	 * src -> dst
+	 *
+	 * mem -> SSI
+	 * mem -> SRC -> SSI
+	 * mem -> SRC -> DVC -> SSI
+	 */
+	mod[0] = NULL; /* for "mem" */
+	index = 1;
+	for (i = 1; i < MOD_MAX; i++) {
+		if (!src) {
+			mod[i] = ssi;
+			break;
+		} else if (!dvc) {
+			mod[i] = src;
+			src = NULL;
+		} else {
+			mod[i] = dvc;
+			dvc = NULL;
+		}
+
+		if (mod[i] == this)
+			index = i;
+	}
+
+	if (is_play) {
+		src_mod = mod[index - 1];
+		dst_mod = mod[index];
+	} else {
+		src_mod = mod[index];
+		dst_mod = mod[index + 1];
+	}
+
+	index = 0;
+	index = _rsnd_dma_of_name(dma_name + index, src_mod);
+	*(dma_name + index++) = '_';
+	index = _rsnd_dma_of_name(dma_name + index, dst_mod);
+}
+
 int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,
 		  int is_play, int id)
 {
 	struct device *dev = rsnd_priv_to_dev(priv);
 	struct dma_slave_config cfg;
+	char dma_name[DMA_NAME_SIZE];
 	dma_cap_mask_t mask;
 	int ret;
 
@@ -272,9 +342,17 @@  int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
 
+	if (dev->of_node)
+		rsnd_dma_of_name(dma, is_play, dma_name);
+	else
+		snprintf(dma_name, DMA_NAME_SIZE,
+			 is_play ? "tx" : "rx");
+
+	dev_dbg(dev, "dma name : %s\n", dma_name);
+
 	dma->chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
 						     (void *)id, dev,
-						     is_play ? "tx" : "rx");
+						     dma_name);
 	if (!dma->chan) {
 		dev_err(dev, "can't get dma channel\n");
 		return -EIO;
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 2d94a62..e0a4ba7 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -589,6 +589,12 @@  static void rsnd_of_parse_ssi(struct platform_device *pdev,
 		 * irq
 		 */
 		ssi_info->pio_irq = irq_of_parse_and_map(np, 0);
+
+		/*
+		 * DMA
+		 */
+		ssi_info->dma_id = of_get_property(np, "pio-transfer", NULL) ?
+			0 : 1;
 	}
 
 rsnd_of_parse_ssi_end: