From patchwork Mon Jun 23 00:58:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 4397191 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0C6C7BEEAA for ; Mon, 23 Jun 2014 01:01:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EECC62024F for ; Mon, 23 Jun 2014 01:01:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7B790201F7 for ; Mon, 23 Jun 2014 01:01:50 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8EB3926552D; Mon, 23 Jun 2014 03:01:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 81E60265533; Mon, 23 Jun 2014 03:00:12 +0200 (CEST) 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 DF6CA265533; Mon, 23 Jun 2014 03:00:10 +0200 (CEST) Received: from mail-pd0-f172.google.com (mail-pd0-f172.google.com [209.85.192.172]) by alsa0.perex.cz (Postfix) with ESMTP id E76332654FE for ; Mon, 23 Jun 2014 02:58:27 +0200 (CEST) Received: by mail-pd0-f172.google.com with SMTP id w10so4998279pde.17 for ; Sun, 22 Jun 2014 17:58:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:sender:message-id:to:cc:in-reply-to:references:from:subject :user-agent:mime-version:content-type; bh=al3XxVudSdTnJ67UGXhBw0IOeZj3jbpDJY5QSI7G0GI=; b=e5sSFS2/9Xc873MoFJcs182zcvhfUoPYpzP5bbDscCY6k3PTzAWQ12bb34jz6s9BAB 9Ret3tJon7pNOxXqbgS52J9yrxoDuPQqPYPSluYNIeA7Uy7YwAfGWDimPkYg0MVx9PQX kmAaf14REJg5rMb6jp8MI63UNYYCCocsJgTC80g0jh4EZVyDa0C4usMRB4uAckVXMUgh Uwq7fSNKFWwnv307Ra+jhIiNGvEvwUcrq1+gkDGI4G4ldHy67ctHmf9aPx6gWEztIbBU 7JbM3uvQUztSpUJ7e8TmYnVAyk4khBi/6zFubj5SxLHeUhYYUGNSIr6HCniBme/6q7JX OYIA== X-Received: by 10.68.196.202 with SMTP id io10mr23958805pbc.149.1403485106966; Sun, 22 Jun 2014 17:58:26 -0700 (PDT) Received: from remon.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id ir10sm23903689pbc.59.2014.06.22.17.58.25 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 22 Jun 2014 17:58:26 -0700 (PDT) Date: Sun, 22 Jun 2014 17:58:26 -0700 (PDT) Message-ID: <87tx7csaq0.wl%kuninori.morimoto.gx@renesas.com> To: Mark Brown In-Reply-To: <8761jstphc.wl%kuninori.morimoto.gx@gmail.com> References: <87d2e6zjhf.wl%kuninori.morimoto.gx@gmail.com> <8761jstphc.wl%kuninori.morimoto.gx@gmail.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: linux-sh@vger.kernel.org, Linux-ALSA , Simon , Kuninori Morimoto , Liam Girdwood Subject: [alsa-devel] [PATCH 08/10 v2] ASoC: rsnd: DMA cleanup for flexible SSI/SRC selection 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto Current R-Car sound SSI/SRC/DVC selection has feature limit. (It is assuming that SSI/SRC are using same index number) So that enabling SSI/SRC flexible selection, this patch modifies DMA settings. Signed-off-by: Kuninori Morimoto --- v1 -> v2 - based on latest mark/topic/rcar sound/soc/sh/rcar/core.c | 45 +++++++++++++++++++---------- sound/soc/sh/rcar/gen.c | 71 ++++++++++++++++++++-------------------------- sound/soc/sh/rcar/rsnd.h | 7 ++--- 3 files changed, 64 insertions(+), 59 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 5149fe2d..4435a31e 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -239,8 +239,21 @@ static int _rsnd_dma_of_name(char *dma_name, struct rsnd_mod *mod) } -static void rsnd_dma_of_name(struct rsnd_dma *dma, - int is_play, char *dma_name) +static void rsnd_dma_of_name(struct rsnd_mod *mod_from, + struct rsnd_mod *mod_to, + char *dma_name) +{ + int index = 0; + + index = _rsnd_dma_of_name(dma_name + index, mod_from); + *(dma_name + index++) = '_'; + index = _rsnd_dma_of_name(dma_name + index, mod_to); +} + +static void rsnd_dma_of_path(struct rsnd_dma *dma, + int is_play, + struct rsnd_mod **mod_from, + struct rsnd_mod **mod_to) { struct rsnd_mod *this = rsnd_dma_to_mod(dma); struct rsnd_dai_stream *io = rsnd_mod_to_io(this); @@ -248,7 +261,6 @@ static void rsnd_dma_of_name(struct rsnd_dma *dma, 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; @@ -285,17 +297,12 @@ static void rsnd_dma_of_name(struct rsnd_dma *dma, } if (is_play) { - src_mod = mod[index - 1]; - dst_mod = mod[index]; + *mod_from = mod[index - 1]; + *mod_to = mod[index]; } else { - src_mod = mod[index]; - dst_mod = mod[index - 1]; + *mod_from = mod[index]; + *mod_to = 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, @@ -303,6 +310,8 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, { struct device *dev = rsnd_priv_to_dev(priv); struct dma_slave_config cfg; + struct rsnd_mod *mod_from; + struct rsnd_mod *mod_to; char dma_name[DMA_NAME_SIZE]; dma_cap_mask_t mask; int ret; @@ -315,10 +324,16 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); - rsnd_dma_of_name(dma, is_play, dma_name); - rsnd_gen_dma_addr(priv, dma, &cfg, is_play, id); + rsnd_dma_of_path(dma, is_play, &mod_from, &mod_to); + rsnd_dma_of_name(mod_from, mod_to, dma_name); + + cfg.slave_id = id; + cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; + cfg.src_addr = rsnd_gen_dma_addr(priv, mod_from, is_play, 1); + cfg.dst_addr = rsnd_gen_dma_addr(priv, mod_to, is_play, 0); - dev_dbg(dev, "dma name : %s\n", dma_name); + dev_dbg(dev, "dma : %s %pad -> %pad\n", + dma_name, &cfg.src_addr, &cfg.dst_addr); dma->chan = dma_request_slave_channel_compat(mask, shdma_chan_filter, (void *)id, dev, diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index 46677af..73ce4c9 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c @@ -168,7 +168,7 @@ static int rsnd_gen_regmap_init(struct rsnd_priv *priv, * SSI : 0xec541000 / 0xec241008 / 0xec24100c * SSIU: 0xec541000 / 0xec100000 / 0xec100000 / 0xec400000 / 0xec400000 * SCU : 0xec500000 / 0xec000000 / 0xec004000 / 0xec300000 / 0xec304000 - * CMD : 0xec500000 / 0xec008000 0xec308000 + * CMD : 0xec500000 / / 0xec008000 0xec308000 */ #define RDMA_SSI_I_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0x8) #define RDMA_SSI_O_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0xc) @@ -188,14 +188,13 @@ static int rsnd_gen_regmap_init(struct rsnd_priv *priv, #define RDMA_CMD_O_N(addr, i) (addr ##_reg - 0x004f8000 + (0x400 * i)) #define RDMA_CMD_O_P(addr, i) (addr ##_reg - 0x001f8000 + (0x400 * i)) -static void rsnd_gen2_dma_addr(struct rsnd_priv *priv, - struct rsnd_dma *dma, - struct dma_slave_config *cfg, - int is_play, int slave_id) +static dma_addr_t +rsnd_gen2_dma_addr(struct rsnd_priv *priv, + struct rsnd_mod *mod, + int is_play, int is_from) { struct platform_device *pdev = rsnd_priv_to_pdev(priv); struct device *dev = rsnd_priv_to_dev(priv); - struct rsnd_mod *mod = rsnd_dma_to_mod(dma); struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); dma_addr_t ssi_reg = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SSI)->start; @@ -206,76 +205,68 @@ static void rsnd_gen2_dma_addr(struct rsnd_priv *priv, int use_dvc = !!rsnd_io_to_mod_dvc(io); int id = rsnd_mod_id(mod); struct dma_addr { - dma_addr_t src_addr; - dma_addr_t dst_addr; + dma_addr_t out_addr; + dma_addr_t in_addr; } dma_addrs[3][2][3] = { /* SRC */ {{{ 0, 0 }, /* Capture */ - { RDMA_SRC_O_N(src, id), 0 }, - { RDMA_CMD_O_N(src, id), 0 } }, + { RDMA_SRC_O_N(src, id), RDMA_SRC_I_P(src, id) }, + { RDMA_CMD_O_N(src, id), RDMA_SRC_I_P(src, id) } }, /* Playback */ {{ 0, 0, }, - { 0, RDMA_SRC_I_N(src, id) }, - { 0, RDMA_SRC_I_N(src, id) } } + { RDMA_SRC_O_P(src, id), RDMA_SRC_I_N(src, id) }, + { RDMA_CMD_O_P(src, id), RDMA_SRC_I_N(src, id) } } }, /* SSI */ /* Capture */ {{{ RDMA_SSI_O_N(ssi, id), 0 }, - { 0, 0 }, - { 0, 0 } }, + { RDMA_SSIU_O_P(ssi, id), 0 }, + { RDMA_SSIU_O_P(ssi, id), 0 } }, /* Playback */ {{ 0, RDMA_SSI_I_N(ssi, id) }, - { 0, 0 }, - { 0, 0 } } + { 0, RDMA_SSIU_I_P(ssi, id) }, + { 0, RDMA_SSIU_I_P(ssi, id) } } }, /* SSIU */ /* Capture */ {{{ RDMA_SSIU_O_N(ssi, id), 0 }, - { RDMA_SSIU_O_P(ssi, id), RDMA_SRC_I_P(src, id) }, - { RDMA_SSIU_O_P(ssi, id), RDMA_SRC_I_P(src, id) } }, + { RDMA_SSIU_O_P(ssi, id), 0 }, + { RDMA_SSIU_O_P(ssi, id), 0 } }, /* Playback */ {{ 0, RDMA_SSIU_I_N(ssi, id) }, - { RDMA_SRC_O_P(src, id), RDMA_SSIU_I_P(ssi, id) }, - { RDMA_CMD_O_P(src, id), RDMA_SSIU_I_P(ssi, id) } } }, + { 0, RDMA_SSIU_I_P(ssi, id) }, + { 0, RDMA_SSIU_I_P(ssi, id) } } }, }; /* it shouldn't happen */ - if (use_dvc & !use_src) { + if (use_dvc & !use_src) dev_err(dev, "DVC is selected without SRC\n"); - return; - } /* use SSIU or SSI ? */ if (is_ssi && (0 == strcmp(rsnd_mod_dma_name(mod), "ssiu"))) is_ssi++; - cfg->src_addr = dma_addrs[is_ssi][is_play][use_src + use_dvc].src_addr; - cfg->dst_addr = dma_addrs[is_ssi][is_play][use_src + use_dvc].dst_addr; - - dev_dbg(dev, "dma%d addr - src : %x / dst : %x\n", - id, cfg->src_addr, cfg->dst_addr); + return (is_from) ? + dma_addrs[is_ssi][is_play][use_src + use_dvc].out_addr : + dma_addrs[is_ssi][is_play][use_src + use_dvc].in_addr; } -void rsnd_gen_dma_addr(struct rsnd_priv *priv, - struct rsnd_dma *dma, - struct dma_slave_config *cfg, - int is_play, int slave_id) +dma_addr_t rsnd_gen_dma_addr(struct rsnd_priv *priv, + struct rsnd_mod *mod, + int is_play, int is_from) { - cfg->slave_id = slave_id; - cfg->src_addr = 0; - cfg->dst_addr = 0; - cfg->direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; - /* * gen1 uses default DMA addr */ if (rsnd_is_gen1(priv)) - return; + return 0; - rsnd_gen2_dma_addr(priv, dma, cfg, is_play, slave_id); -} + if (!mod) + return 0; + return rsnd_gen2_dma_addr(priv, mod, is_play, is_from); +} /* * Gen2 diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 60b5e92..425b22e 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -279,10 +279,9 @@ int rsnd_gen_probe(struct platform_device *pdev, void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg); -void rsnd_gen_dma_addr(struct rsnd_priv *priv, - struct rsnd_dma *dma, - struct dma_slave_config *cfg, - int is_play, int slave_id); +dma_addr_t rsnd_gen_dma_addr(struct rsnd_priv *priv, + struct rsnd_mod *mod, + int is_play, int is_from); #define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1) #define rsnd_is_gen2(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2)