linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <jiada_wang@mentor.com>
To: <lgirdwood@gmail.com>, <broonie@kernel.org>, <perex@perex.cz>,
	<tiwai@suse.com>, <kuninori.morimoto.gx@renesas.com>
Cc: <alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>,
	<jiada_wang@mentor.com>
Subject: [PATCH linux-next v2 9/9] ASoC: rsnd: add busif property to dai stream
Date: Wed, 3 Oct 2018 18:01:36 +0900	[thread overview]
Message-ID: <20181003090136.4556-1-jiada_wang@mentor.com> (raw)

From: Jiada Wang <jiada_wang@mentor.com>

in GEN3 SSI may use different BUSIF for data transfer,
this patch adds busif property to each dai stream,
to indicate the BUSIF used by playback/capture stream.

Also adds rsnd_ssi_select_busif() to automatically select
BUSIF (currently only BUSIF0 is selected)

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
 sound/soc/sh/rcar/core.c |  3 +++
 sound/soc/sh/rcar/dma.c  | 31 +++++++++++++++++++++++++++++++
 sound/soc/sh/rcar/rsnd.h |  3 +++
 sound/soc/sh/rcar/ssi.c  | 30 +++++++++++++++++++++++++++++-
 4 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 40d7dc4f7839..5e3e6e65bcdf 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1158,6 +1158,9 @@ static int rsnd_hw_params(struct snd_pcm_substream *substream,
 	struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
 	struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
 	int ret;
+	int chan = rsnd_runtime_channel_for_ssi_with_params(io, hw_params);
+
+	rsnd_ssi_select_busif(io, chan);
 
 	ret = rsnd_dai_call(hw_params, io, substream, hw_params);
 	if (ret)
diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c
index 6d1947515dc8..bf87939f79bb 100644
--- a/sound/soc/sh/rcar/dma.c
+++ b/sound/soc/sh/rcar/dma.c
@@ -792,6 +792,37 @@ int rsnd_dma_attach(struct rsnd_dai_stream *io, struct rsnd_mod *mod,
 	return rsnd_dai_connect(*dma_mod, io, (*dma_mod)->type);
 }
 
+void rsnd_dma_addr_update(struct rsnd_dai_stream *io)
+{
+	struct rsnd_mod *ssi_mod = rsnd_io_to_mod_ssi(io);
+	struct rsnd_mod *mod_from = NULL;
+	struct rsnd_mod *mod_to = NULL;
+	struct rsnd_priv *priv = rsnd_io_to_priv(io);
+	struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
+	struct device *dev = rsnd_priv_to_dev(priv);
+	int is_play = rsnd_io_is_play(io);
+	struct rsnd_dma *dma = rsnd_mod_to_dma(io->dma);
+
+	if (!dmac)
+		return;
+
+	rsnd_dma_of_path(ssi_mod, io, is_play, &mod_from, &mod_to);
+
+	dma->src_addr = rsnd_dma_addr(io, mod_from, is_play, 1);
+	dma->dst_addr = rsnd_dma_addr(io, mod_to,   is_play, 0);
+
+	if (mod_from && mod_to) {
+		struct rsnd_dmapp *dmapp = rsnd_dma_to_dmapp(dma);
+
+		dmapp->chcr = rsnd_dmapp_get_chcr(io, mod_from, mod_to) |
+						  PDMACHCR_DE;
+	}
+
+	dev_dbg(dev, "%s[%d] %pad -> %pad\n",
+		rsnd_mod_name(ssi_mod), rsnd_mod_id(ssi_mod),
+		&dma->src_addr, &dma->dst_addr);
+}
+
 int rsnd_dma_probe(struct rsnd_priv *priv)
 {
 	struct platform_device *pdev = rsnd_priv_to_pdev(priv);
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index 4464d1d0a042..7ce10267c87b 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -227,12 +227,14 @@ void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg,
 u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io);
 u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io);
 u32 rsnd_get_busif_shift(struct rsnd_dai_stream *io, struct rsnd_mod *mod);
+void rsnd_ssi_select_busif(struct rsnd_dai_stream *io, int chan);
 
 /*
  *	R-Car DMA
  */
 int rsnd_dma_attach(struct rsnd_dai_stream *io,
 		    struct rsnd_mod *mod, struct rsnd_mod **dma_mod);
+void rsnd_dma_addr_update(struct rsnd_dai_stream *io);
 int rsnd_dma_probe(struct rsnd_priv *priv);
 struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node,
 					  struct rsnd_mod *mod, char *name);
@@ -457,6 +459,7 @@ struct rsnd_dai_stream {
 	struct rsnd_dai *rdai;
 	struct device *dmac_dev; /* for IPMMU */
 	u32 parent_ssi_status;
+	u32 busif;
 };
 #define rsnd_io_to_mod(io, i)	((i) < RSND_MOD_MAX ? (io)->mod[(i)] : NULL)
 #define rsnd_io_to_mod_ssi(io)	rsnd_io_to_mod((io), RSND_MOD_SSI)
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 992aeac09e76..d515ee192276 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -154,7 +154,35 @@ int rsnd_ssi_use_busif(struct rsnd_dai_stream *io)
 
 int rsnd_ssi_get_busif(struct rsnd_dai_stream *io)
 {
-	return 0; /* BUSIF0 only for now */
+	struct rsnd_priv *priv = rsnd_io_to_priv(io);
+
+	if (!rsnd_is_gen3(priv))
+		return 0;
+
+	if (!rsnd_ssi_use_busif(io))
+		return 0;
+
+	return io->busif;
+}
+
+void rsnd_ssi_select_busif(struct rsnd_dai_stream *io, int chan)
+{
+	struct rsnd_priv *priv = rsnd_io_to_priv(io);
+	u32 busif = 0; /* BUSIF0 only for now */
+
+	if (!rsnd_is_gen3(priv))
+		return;
+
+	if (!rsnd_ssi_use_busif(io))
+		return;
+
+	/* FIXME: calcuate BUSIF based on SSI mode in future */
+	if (io->busif == busif)
+		return;
+
+	io->busif = busif;
+
+	rsnd_dma_addr_update(io);
 }
 
 static void rsnd_ssi_status_clear(struct rsnd_mod *mod)
-- 
2.17.0


             reply	other threads:[~2018-10-03  9:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-03  9:01 jiada_wang [this message]
2018-10-04  1:41 ` [alsa-devel] [PATCH linux-next v2 9/9] ASoC: rsnd: add busif property to dai stream Kuninori Morimoto
2018-10-04  2:43   ` Jiada Wang
2018-10-04  3:43     ` Kuninori Morimoto
2018-10-04  7:00       ` Jiada Wang
2018-10-09  0:44         ` Kuninori Morimoto
2018-10-09  7:09           ` Jiada Wang
2018-10-09  7:47             ` Kuninori Morimoto
2018-10-09 10:40               ` Jiada Wang
2018-10-10  0:16                 ` Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181003090136.4556-1-jiada_wang@mentor.com \
    --to=jiada_wang@mentor.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).