From patchwork Tue Oct 27 04:48:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 105302 Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1564792lbq; Mon, 26 Oct 2015 21:51:10 -0700 (PDT) X-Received: by 10.180.21.142 with SMTP id v14mr23259317wie.86.1445921470640; Mon, 26 Oct 2015 21:51:10 -0700 (PDT) Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id oo7si47748506wjc.42.2015.10.26.21.51.10; Mon, 26 Oct 2015 21:51:10 -0700 (PDT) Received-SPF: neutral (google.com: 77.48.224.243 is neither permitted nor denied by best guess record for domain of alsa-devel-bounces@alsa-project.org) client-ip=77.48.224.243; Authentication-Results: mx.google.com; spf=neutral (google.com: 77.48.224.243 is neither permitted nor denied by best guess record for domain of alsa-devel-bounces@alsa-project.org) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D2B80265AC1; Tue, 27 Oct 2015 05:51:09 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.2.4 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2B5A5265463; Tue, 27 Oct 2015 05:48:46 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 206C5265338; Tue, 27 Oct 2015 05:48:42 +0100 (CET) Received: from mezzanine.sirena.org.uk (mezzanine.sirena.org.uk [106.187.55.193]) by alsa0.perex.cz (Postfix) with ESMTP id E4D802651E4 for ; Tue, 27 Oct 2015 05:48:35 +0100 (CET) Received: from [58.123.138.250] (helo=finisterre) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1ZqwBV-0005Nk-K4; Tue, 27 Oct 2015 04:48:34 +0000 Received: from broonie by finisterre with local (Exim 4.86) (envelope-from ) id 1ZqwBO-0004oA-7Q; Tue, 27 Oct 2015 13:48:26 +0900 From: Mark Brown To: Kuninori Morimoto , Mark Brown In-Reply-To: <87io5u3u0w.wl%kuninori.morimoto.gx@renesas.com> Message-Id: Date: Tue, 27 Oct 2015 13:48:26 +0900 X-SA-Exim-Connect-IP: 58.123.138.250 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] Applied "ASoC: rsnd: use mod base common method on DMA phase1" to the asoc tree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: rsnd: use mod base common method on DMA phase1 has been applied to the asoc tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 0de0c7f8c52aee6f8b7577b1b0e215dd808cbce2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 26 Oct 2015 08:42:25 +0000 Subject: [PATCH] ASoC: rsnd: use mod base common method on DMA phase1 Renesas sound needs many devices (SSI/SSIU/SRC/CTU/MIX/DVC/CMD/AudioDMAC/AudioDMACpp). SSI/SRC/CTU/MIX/DVC are implemented as module. SSI parent, SSIU are implemented as part of SSI CMD is implemented as part of CTU/MIX/DVC AudioDMAC/AudioDMACpp are implemented as part of SSI/SRC It is nice sense that these all devices are implemented as mod. DMA will be implemented as module. Then rsnd_dma will be mod base. This patch makes rsnd_dma mod base, but still not yet completely finished. This mod is not yet installed to system at this point. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/dma.c | 61 ++++++++++++++++++++++++++++++++---------------- sound/soc/sh/rcar/rsnd.h | 14 +++++------ sound/soc/sh/rcar/src.c | 2 +- sound/soc/sh/rcar/ssi.c | 6 ++--- 4 files changed, 52 insertions(+), 31 deletions(-) -- 2.6.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c index 697f882..45d30b8 100644 --- a/sound/soc/sh/rcar/dma.c +++ b/sound/soc/sh/rcar/dma.c @@ -34,7 +34,8 @@ struct rsnd_dmapp { struct rsnd_dma { struct rsnd_dma_ops *ops; - struct rsnd_mod *mod; + struct rsnd_mod mod; + struct rsnd_mod *user_mod; dma_addr_t src_addr; dma_addr_t dst_addr; union { @@ -45,6 +46,7 @@ struct rsnd_dma { struct rsnd_dma_ctrl { void __iomem *base; + int dmaen_num; int dmapp_num; }; @@ -56,9 +58,9 @@ struct rsnd_dma_ops { }; #define rsnd_priv_to_dmac(p) ((struct rsnd_dma_ctrl *)(p)->dma) +#define rsnd_mod_to_dma(_mod) container_of((_mod), struct rsnd_dma, mod) #define rsnd_dma_to_dmaen(dma) (&(dma)->dma.en) #define rsnd_dma_to_dmapp(dma) (&(dma)->dma.pp) -#define rsnd_dma_to_mod(_dma) ((dma)->mod) /* * Audio DMAC @@ -109,8 +111,8 @@ static void rsnd_dmaen_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma) static void rsnd_dmaen_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma) { struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma); - struct rsnd_mod *mod = rsnd_dma_to_mod(dma); - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); + struct rsnd_mod *user_mod = dma->user_mod; + struct rsnd_priv *priv = rsnd_io_to_priv(io); struct snd_pcm_substream *substream = io->substream; struct device *dev = rsnd_priv_to_dev(priv); struct dma_async_tx_descriptor *desc; @@ -129,7 +131,7 @@ static void rsnd_dmaen_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma) } desc->callback = rsnd_dmaen_complete; - desc->callback_param = mod; + desc->callback_param = user_mod; if (dmaengine_submit(desc) < 0) { dev_err(dev, "dmaengine_submit() fail\n"); @@ -180,6 +182,7 @@ static int rsnd_dmaen_attach(struct rsnd_dai_stream *io, { struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma); 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); struct dma_slave_config cfg = {}; int is_play = rsnd_io_is_play(io); @@ -221,10 +224,12 @@ static int rsnd_dmaen_attach(struct rsnd_dai_stream *io, if (ret < 0) goto rsnd_dma_attach_err; + dmac->dmaen_num++; + return 0; rsnd_dma_attach_err: - rsnd_dma_quit(io, dma); + rsnd_dma_quit(io, rsnd_mod_get(dma)); rsnd_dma_channel_err: /* @@ -328,7 +333,7 @@ static u32 rsnd_dmapp_get_chcr(struct rsnd_dai_stream *io, (0x10 * rsnd_dma_to_dmapp(dma)->dmapp_id)) static void rsnd_dmapp_write(struct rsnd_dma *dma, u32 data, u32 reg) { - struct rsnd_mod *mod = rsnd_dma_to_mod(dma); + struct rsnd_mod *mod = rsnd_mod_get(dma); struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv); struct device *dev = rsnd_priv_to_dev(priv); @@ -340,7 +345,7 @@ static void rsnd_dmapp_write(struct rsnd_dma *dma, u32 data, u32 reg) static u32 rsnd_dmapp_read(struct rsnd_dma *dma, u32 reg) { - struct rsnd_mod *mod = rsnd_dma_to_mod(dma); + struct rsnd_mod *mod = rsnd_mod_get(dma); struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv); @@ -517,13 +522,12 @@ static dma_addr_t rsnd_dma_addr(struct rsnd_dai_stream *io, } #define MOD_MAX (RSND_MOD_MAX + 1) /* +Memory */ -static void rsnd_dma_of_path(struct rsnd_dma *dma, +static void rsnd_dma_of_path(struct rsnd_mod *this, struct rsnd_dai_stream *io, int is_play, struct rsnd_mod **mod_from, struct rsnd_mod **mod_to) { - struct rsnd_mod *this = rsnd_dma_to_mod(dma); struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io); struct rsnd_mod *src = rsnd_io_to_mod_src(io); struct rsnd_mod *ctu = rsnd_io_to_mod_ctu(io); @@ -605,19 +609,23 @@ static void rsnd_dma_of_path(struct rsnd_dma *dma, } } -void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma) +void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_mod *mod) { + struct rsnd_dma *dma = rsnd_mod_to_dma(mod); + dma->ops->stop(io, dma); } -void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma) +void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_mod *mod) { + struct rsnd_dma *dma = rsnd_mod_to_dma(mod); + dma->ops->start(io, dma); } -void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma) +void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_mod *mod) { - struct rsnd_mod *mod = rsnd_dma_to_mod(dma); + struct rsnd_dma *dma = rsnd_mod_to_dma(mod); struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv); @@ -627,9 +635,13 @@ void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma) dma->ops->quit(io, dma); } -struct rsnd_dma *rsnd_dma_attach(struct rsnd_dai_stream *io, +static struct rsnd_mod_ops rsnd_dma_ops = { +}; + +struct rsnd_mod *rsnd_dma_attach(struct rsnd_dai_stream *io, struct rsnd_mod *mod, int id) { + struct rsnd_mod *dma_mod; struct rsnd_mod *mod_from = NULL; struct rsnd_mod *mod_to = NULL; struct rsnd_priv *priv = rsnd_io_to_priv(io); @@ -639,7 +651,7 @@ struct rsnd_dma *rsnd_dma_attach(struct rsnd_dai_stream *io, int (*attach)(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id, struct rsnd_mod *mod_from, struct rsnd_mod *mod_to); int is_play = rsnd_io_is_play(io); - int ret; + int ret, dma_id; /* * DMA failed. try to PIO mode @@ -654,10 +666,9 @@ struct rsnd_dma *rsnd_dma_attach(struct rsnd_dai_stream *io, if (!dma) return ERR_PTR(-ENOMEM); - dma->mod = mod; - - rsnd_dma_of_path(dma, io, is_play, &mod_from, &mod_to); + rsnd_dma_of_path(mod, io, is_play, &mod_from, &mod_to); + dma->user_mod = mod; dma->src_addr = rsnd_dma_addr(io, mod_from, is_play, 1); dma->dst_addr = rsnd_dma_addr(io, mod_to, is_play, 0); @@ -665,27 +676,37 @@ struct rsnd_dma *rsnd_dma_attach(struct rsnd_dai_stream *io, if (mod_from && mod_to) { dma->ops = &rsnd_dmapp_ops; attach = rsnd_dmapp_attach; + dma_id = dmac->dmapp_num; } else { dma->ops = &rsnd_dmaen_ops; attach = rsnd_dmaen_attach; + dma_id = dmac->dmaen_num; } /* for Gen1, overwrite */ if (rsnd_is_gen1(priv)) { dma->ops = &rsnd_dmaen_ops; attach = rsnd_dmaen_attach; + dma_id = dmac->dmaen_num; } + dma_mod = rsnd_mod_get(dma); + dev_dbg(dev, "%s %s[%d] -> %s[%d]\n", dma->ops->name, rsnd_mod_name(mod_from), rsnd_mod_id(mod_from), rsnd_mod_name(mod_to), rsnd_mod_id(mod_to)); + ret = rsnd_mod_init(priv, dma_mod, + &rsnd_dma_ops, NULL, 0, dma_id); + if (ret < 0) + return ERR_PTR(ret); + ret = attach(io, dma, id, mod_from, mod_to); if (ret < 0) return ERR_PTR(ret); - return dma; + return rsnd_mod_get(dma); } int rsnd_dma_probe(struct platform_device *pdev, diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 774cb24..6a0bd3e 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -193,13 +193,11 @@ void rsnd_path_parse(struct rsnd_priv *priv, /* * R-Car DMA */ -struct rsnd_dma; - -void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma); -void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma); -struct rsnd_dma *rsnd_dma_attach(struct rsnd_dai_stream *io, +void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_mod *mod); +void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_mod *mod); +struct rsnd_mod *rsnd_dma_attach(struct rsnd_dai_stream *io, struct rsnd_mod *mod, int id); -void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma); +void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_mod *mod); int rsnd_dma_probe(struct platform_device *pdev, const struct rsnd_of_data *of_data, struct rsnd_priv *priv); @@ -210,7 +208,9 @@ struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, * R-Car sound mod */ enum rsnd_mod_type { - RSND_MOD_DVC = 0, + RSND_MOD_AUDMAPP, + RSND_MOD_AUDMA, + RSND_MOD_DVC, RSND_MOD_MIX, RSND_MOD_CTU, RSND_MOD_SRC, diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 0d96ce5..517a1e1 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -22,7 +22,7 @@ struct rsnd_src { struct rsnd_src_platform_info *info; /* rcar_snd.h */ struct rsnd_mod mod; - struct rsnd_dma *dma; + struct rsnd_mod *dma; struct rsnd_kctrl_cfg_s sen; /* sync convert enable */ struct rsnd_kctrl_cfg_s sync; /* sync convert */ u32 convert_rate; /* sampling rate convert */ diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index ad5539d..66f9f2a 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -63,7 +63,7 @@ struct rsnd_ssi { struct rsnd_ssi_platform_info *info; /* rcar_snd.h */ struct rsnd_ssi *parent; struct rsnd_mod mod; - struct rsnd_dma *dma; + struct rsnd_mod *dma; u32 cr_own; u32 cr_clk; @@ -630,7 +630,7 @@ static int rsnd_ssi_dma_start(struct rsnd_mod *mod, struct rsnd_priv *priv) { struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); - struct rsnd_dma *dma = rsnd_ssi_to_dma(ssi); + struct rsnd_mod *dma = rsnd_ssi_to_dma(ssi); rsnd_dma_start(io, dma); @@ -644,7 +644,7 @@ static int rsnd_ssi_dma_stop(struct rsnd_mod *mod, struct rsnd_priv *priv) { struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); - struct rsnd_dma *dma = rsnd_ssi_to_dma(ssi); + struct rsnd_mod *dma = rsnd_ssi_to_dma(ssi); rsnd_ssi_stop(mod, io, priv);