From patchwork Thu Jun 5 09:01:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 4304101 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 6957DBEEA7 for ; Thu, 5 Jun 2014 09:03:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 83D16201B4 for ; Thu, 5 Jun 2014 09:03:05 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 20D9520320 for ; Thu, 5 Jun 2014 09:03:04 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3518A265653; Thu, 5 Jun 2014 11:03:03 +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 7DD4A26548B; Thu, 5 Jun 2014 11:02: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 E591F26535E; Thu, 5 Jun 2014 11:02:10 +0200 (CEST) Received: from mail-pd0-f175.google.com (mail-pd0-f175.google.com [209.85.192.175]) by alsa0.perex.cz (Postfix) with ESMTP id B325026548B for ; Thu, 5 Jun 2014 11:01:32 +0200 (CEST) Received: by mail-pd0-f175.google.com with SMTP id z10so806573pdj.6 for ; Thu, 05 Jun 2014 02:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:sender:message-id:from:subject:user-agent:to:cc:in-reply-to :references:mime-version:content-type; bh=28cZHO2wlAlk1HCcro6pyYBJfAvtPMzrXveuwjcBo8w=; b=hIdIZFjOstJ+RNju4Vs9ARqsKdpIXQ9HN4HC5F8hzBRsuv6nrrezev5qnNcx98Q7LM 0BMDOz8CoC+RCJIElNNsPXbVlUuaxDwpSlB5Qvt8oK+I+PMw9+2mo5VxJsH5088eXA1d mmVkLyTOT5WzGr8nDApR0ueBXxVYy8JHlzNKE8lSYGrW5OIVvV1VbJCxn5+xq7Nnespt daORbO+JLspKtoaR7Z1DbiSK3nKJ69PcYS6RfeQuo3QCXM3novM23yzwMSQ46uxaehb0 M9YChdz9TcrUYgB/5/VCSQTzOa9Ws9IfTr7GPNt13BronGY0uYUvuxd1qOm1c2lacquI S7MQ== X-Received: by 10.69.31.107 with SMTP id kl11mr73344215pbd.142.1401958891626; Thu, 05 Jun 2014 02:01:31 -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 no9sm20112775pbc.83.2014.06.05.02.01.29 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Jun 2014 02:01:31 -0700 (PDT) Date: Thu, 05 Jun 2014 02:01:31 -0700 (PDT) Message-ID: <87ha3zivbr.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 To: Mark Brown In-Reply-To: <87mwdrivhe.wl%kuninori.morimoto.gx@gmail.com> References: <87mwdrivhe.wl%kuninori.morimoto.gx@gmail.com> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: Linux-ALSA , cm-hiep@jinso.co.jp, Liam Girdwood , bd-phuc@jinso.co.jp, nx-nui@jinso.co.jp, Simon , h-inayoshi@jinso.co.jp, m-miura@jinso.co.jp, Kuninori Morimoto , nv-dung@jinso.co.jp Subject: [alsa-devel] [PATCH 4/4] ASoC: rsnd: use dmaengine_prep_dma_cyclic() instead of original method 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 driver is using DMAEngine directly, but, ASoC is requesting to use common DMA transfer method, like snd_dmaengine_pcm_trigger() or dmaengine_pcm_ops. It is difficult to switch at this point, since Renesas driver is also supporting PIO transfer. This patch uses dmaengine_prep_dma_cyclic() instead of dmaengine_prep_slave_single(). It is used in requested method, and is good first step to switch over. Signed-off-by: Kuninori Morimoto --- sound/soc/sh/rcar/core.c | 76 +++++++++++----------------------------------- sound/soc/sh/rcar/rsnd.h | 4 --- 2 files changed, 18 insertions(+), 62 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 9188015..fc31771 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -153,26 +153,8 @@ void rsnd_mod_init(struct rsnd_priv *priv, /* * rsnd_dma functions */ -static void __rsnd_dma_start(struct rsnd_dma *dma); -static void rsnd_dma_continue(struct rsnd_dma *dma) -{ - /* push next A or B plane */ - dma->submit_loop = 1; - schedule_work(&dma->work); -} - -void rsnd_dma_start(struct rsnd_dma *dma) -{ - /* push both A and B plane*/ - dma->offset = 0; - dma->submit_loop = 2; - __rsnd_dma_start(dma); -} - void rsnd_dma_stop(struct rsnd_dma *dma) { - dma->submit_loop = 0; - cancel_work_sync(&dma->work); dmaengine_terminate_all(dma->chan); } @@ -180,11 +162,7 @@ static void rsnd_dma_complete(void *data) { struct rsnd_dma *dma = (struct rsnd_dma *)data; struct rsnd_mod *mod = rsnd_dma_to_mod(dma); - struct rsnd_priv *priv = rsnd_mod_to_priv(rsnd_dma_to_mod(dma)); struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); - unsigned long flags; - - rsnd_lock(priv, flags); /* * Renesas sound Gen1 needs 1 DMAC, @@ -197,57 +175,40 @@ static void rsnd_dma_complete(void *data) * rsnd_dai_pointer_update() will be called twice, * ant it will breaks io->byte_pos */ - if (dma->submit_loop) - rsnd_dma_continue(dma); - - rsnd_unlock(priv, flags); rsnd_dai_pointer_update(io, io->byte_per_period); } -static void __rsnd_dma_start(struct rsnd_dma *dma) +void rsnd_dma_start(struct rsnd_dma *dma) { struct rsnd_mod *mod = rsnd_dma_to_mod(dma); struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); - struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); + struct snd_pcm_substream *substream = io->substream; struct device *dev = rsnd_priv_to_dev(priv); struct dma_async_tx_descriptor *desc; - dma_addr_t buf; - size_t len = io->byte_per_period; - int i; - - for (i = 0; i < dma->submit_loop; i++) { - buf = runtime->dma_addr + - rsnd_dai_pointer_offset(io, dma->offset + len); - dma->offset = len; + desc = dmaengine_prep_dma_cyclic(dma->chan, + substream->runtime->dma_addr, + snd_pcm_lib_buffer_bytes(substream), + snd_pcm_lib_period_bytes(substream), + dma->dir, + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); - desc = dmaengine_prep_slave_single( - dma->chan, buf, len, dma->dir, - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); - if (!desc) { - dev_err(dev, "dmaengine_prep_slave_sg() fail\n"); - return; - } - - desc->callback = rsnd_dma_complete; - desc->callback_param = dma; + if (!desc) { + dev_err(dev, "dmaengine_prep_slave_sg() fail\n"); + return; + } - if (dmaengine_submit(desc) < 0) { - dev_err(dev, "dmaengine_submit() fail\n"); - return; - } + desc->callback = rsnd_dma_complete; + desc->callback_param = dma; - dma_async_issue_pending(dma->chan); + if (dmaengine_submit(desc) < 0) { + dev_err(dev, "dmaengine_submit() fail\n"); + return; } -} - -static void rsnd_dma_do_work(struct work_struct *work) -{ - struct rsnd_dma *dma = container_of(work, struct rsnd_dma, work); - __rsnd_dma_start(dma); + dma_async_issue_pending(dma->chan); } int rsnd_dma_available(struct rsnd_dma *dma) @@ -364,7 +325,6 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, goto rsnd_dma_init_err; dma->dir = is_play ? DMA_TO_DEVICE : DMA_FROM_DEVICE; - INIT_WORK(&dma->work, rsnd_dma_do_work); return 0; diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 39d98af..7323b46 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -156,12 +156,8 @@ u32 rsnd_get_adinr(struct rsnd_mod *mod); */ struct rsnd_dma { struct sh_dmae_slave slave; - struct work_struct work; struct dma_chan *chan; enum dma_data_direction dir; - - int submit_loop; - int offset; /* it cares A/B plane */ }; void rsnd_dma_start(struct rsnd_dma *dma);