From patchwork Thu Sep 13 13:37:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1452351 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 45CBA3FE79 for ; Thu, 13 Sep 2012 13:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752815Ab2IMNhs (ORCPT ); Thu, 13 Sep 2012 09:37:48 -0400 Received: from na3sys009aog113.obsmtp.com ([74.125.149.209]:49367 "EHLO na3sys009aog113.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751786Ab2IMNhp (ORCPT ); Thu, 13 Sep 2012 09:37:45 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]) (using TLSv1) by na3sys009aob113.postini.com ([74.125.148.12]) with SMTP ID DSNKUFHhp1CCVq6gju66JrCEkOMYN9ZKzGG+@postini.com; Thu, 13 Sep 2012 06:37:44 PDT Received: by obbuo13 with SMTP id uo13so4468498obb.19 for ; Thu, 13 Sep 2012 06:37:43 -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=IWFbuUhJpAp582Cgixizscec6Whxmjgr5B/2Fm15JCfZEXR587IvUy4MOQU83LpTe3 HxLnQJ/uIabZNrtt98hwZU8AXz8CWWW/mqSjXw94xEqVkuXSFuvj1Y/bmEKfjlqXKFFj UIXUWM0wuqxgJR6iFEpX75OCflmasa5OK8QtBGJm74bJrh5mPlRiiKg+EWHQ3wM3byQa 6/u0qJAXfhlHxGyH4+yjHY8wn12OLD0QLxWYVvHE8wmC6YoYQ8tL/VXtjNIicpSG33cK wUG6+ATCzO6yseMTjRYVKWTEVePLy6DQLGyKLSEohTObP8tlsIA+YS7an23UEH278hR8 lQGg== Received: by 10.182.202.1 with SMTP id ke1mr2252655obc.51.1347543463209; Thu, 13 Sep 2012 06:37:43 -0700 (PDT) Received: from barack.emea.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id n8sm19403567oec.5.2012.09.13.06.37.39 (version=SSLv3 cipher=OTHER); Thu, 13 Sep 2012 06:37:42 -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 v2 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode Date: Thu, 13 Sep 2012 16:37:52 +0300 Message-Id: <1347543485-339-3-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1347543485-339-1-git-send-email-peter.ujfalusi@ti.com> References: <1347543485-339-1-git-send-email-peter.ujfalusi@ti.com> X-Gm-Message-State: ALoCoQnA9G0V3IwrYSzoj4FsDHIU+YJIyd4LJVQUV5pnP09eX0B5vCPOkzHTY23jlHBkNi4pk4SN 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 --- 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,