From patchwork Fri Sep 14 12:05:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1458101 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E5D4FDF280 for ; Fri, 14 Sep 2012 12:10:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759509Ab2INMFk (ORCPT ); Fri, 14 Sep 2012 08:05:40 -0400 Received: from na3sys009aog121.obsmtp.com ([74.125.149.145]:34925 "EHLO na3sys009aog121.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759505Ab2INMFh (ORCPT ); Fri, 14 Sep 2012 08:05:37 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]) (using TLSv1) by na3sys009aob121.postini.com ([74.125.148.12]) with SMTP ID DSNKUFMdkBXIZluO7ifAqa/s3btmFdVoUwjx@postini.com; Fri, 14 Sep 2012 05:05:37 PDT Received: by obbuo13 with SMTP id uo13so6096970obb.19 for ; Fri, 14 Sep 2012 05:05:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=PGlim6WmhoN4cbYUF3bosCLAokjNNPNnSgbSRJaaEXk=; b=cB9PmmCbxvntKTm6+KFsKB7AesMswh4t/Y78QKMqaOqBpGjBQ7A6vI0SHbXUGKjfui yN4bcUrraN693osVRgHAuO8CsjzhypIJIFfNmpS5D+xoUhd8lP/pXJIsl2n6kh1v8RKk ABN/LCkrzzXbTm/x61m9W5vTeedmW6UfKq1LiikTIMcR8EoI8VJYvZNDGtNL2y3odHkJ ruocIPF4rQWatWKpEOaHvUuwRNOSkifgJAuDQEw+RwjXoW7F6ZhbWypUrrqb906vPCfG /tc1E4AeR/gC1IT9kbZy5jcSBJry8Tx2ALzKrxzijAzU+L3BJRxbbjGt6zyzaBLOberl c1NA== Received: by 10.60.172.49 with SMTP id az17mr2739755oec.44.1347624336196; Fri, 14 Sep 2012 05:05:36 -0700 (PDT) Received: from barack.emea.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id ac10sm1615600obc.7.2012.09.14.05.05.33 (version=SSLv3 cipher=OTHER); Fri, 14 Sep 2012 05:05:35 -0700 (PDT) From: Peter Ujfalusi To: Mark Brown , Liam Girdwood , Tony Lindgren , Russell King , Vinod Koul , Dan Williams , Jarkko Nikula Cc: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik , Ricardo Neri , Lars-Peter Clausen Subject: [PATCH v3 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode Date: Fri, 14 Sep 2012 15:05:45 +0300 Message-Id: <1347624358-25582-3-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1347624358-25582-1-git-send-email-peter.ujfalusi@ti.com> References: <1347624358-25582-1-git-send-email-peter.ujfalusi@ti.com> X-Gm-Message-State: ALoCoQkdaHQX31uRv0JctiCFu8yOwLxezCqGW3W+sCtJwncoI5sIX6b431jdv0DUuYmNL0qp1/gZ Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The audio stack used omap_stop_dma/omap_start_dma to pause/resume the DMA. This method has been used for years on OMAP based products. We only allow pause/resume when the DMA has been configured in cyclic mode which is used by the audio stack. Signed-off-by: Peter Ujfalusi CC: Russell King Acked-by: Vinod Koul --- drivers/dma/omap-dma.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c index b77a40d..71d7869 100644 --- a/drivers/dma/omap-dma.c +++ b/drivers/dma/omap-dma.c @@ -34,6 +34,7 @@ struct omap_chan { struct dma_slave_config cfg; unsigned dma_sig; bool cyclic; + bool paused; int dma_ch; struct omap_desc *desc; @@ -470,11 +471,14 @@ static int omap_dma_terminate_all(struct omap_chan *c) */ if (c->desc) { c->desc = NULL; - omap_stop_dma(c->dma_ch); + /* Avoid stopping the dma twice */ + if (!c->paused) + omap_stop_dma(c->dma_ch); } if (c->cyclic) { c->cyclic = false; + c->paused = false; omap_dma_unlink_lch(c->dma_ch, c->dma_ch); } @@ -487,14 +491,30 @@ static int omap_dma_terminate_all(struct omap_chan *c) static int omap_dma_pause(struct omap_chan *c) { - /* FIXME: not supported by platform private API */ - return -EINVAL; + /* Pause/Resume only allowed with cyclic mode */ + if (!c->cyclic) + return -EINVAL; + + if (!c->paused) { + omap_stop_dma(c->dma_ch); + c->paused = true; + } + + return 0; } static int omap_dma_resume(struct omap_chan *c) { - /* FIXME: not supported by platform private API */ - return -EINVAL; + /* Pause/Resume only allowed with cyclic mode */ + if (!c->cyclic) + return -EINVAL; + + if (c->paused) { + omap_start_dma(c->dma_ch); + c->paused = false; + } + + return 0; } static int omap_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,