From patchwork Wed Sep 11 06:08:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Padmavathi Venna X-Patchwork-Id: 2870911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2CDA49F485 for ; Wed, 11 Sep 2013 06:09:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD4FA2020E for ; Wed, 11 Sep 2013 06:09:33 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FB9E20209 for ; Wed, 11 Sep 2013 06:09:32 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJdc7-0000Os-75; Wed, 11 Sep 2013 06:09:19 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJdc3-0003cb-BE; Wed, 11 Sep 2013 06:09:15 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJdbp-0003Yy-Gj for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2013 06:09:04 +0000 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MSY00BKI6E8DHL0@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2013 15:08:38 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.123]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 64.AD.22755.6E800325; Wed, 11 Sep 2013 15:08:38 +0900 (KST) X-AuditID: cbfee68f-b7f656d0000058e3-0a-523008e609e5 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 53.B5.05832.6E800325; Wed, 11 Sep 2013 15:08:38 +0900 (KST) Received: from padma-linuxpc.sisodomain.com ([107.108.83.35]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MSY00EHK6E1FP70@mmp2.samsung.com>; Wed, 11 Sep 2013 15:08:38 +0900 (KST) From: Padmavathi Venna To: linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, padma.v@samsung.com, padma.kvr@gmail.com Subject: [PATCH 3/3] ASoC: Update pointer to account for pending dma transfers. Date: Wed, 11 Sep 2013 11:38:05 +0530 Message-id: <1378879685-5352-4-git-send-email-padma.v@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1378879685-5352-1-git-send-email-padma.v@samsung.com> References: <1378879685-5352-1-git-send-email-padma.v@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGIsWRmVeSWpSXmKPExsWyRsSkWvcZh0GQwcnfMhZ/Jx1jt5j68Amb xfwTt9gsehdcZbPY9Pgaq8WM8/uYLL5u2c1o0b5sDqvF75vf2SwurvjCZPGybz+LA7fH71+T GD1mN1xk8dg56y67x+I9L5k8Nq3qZPPYvKTeo2/LKkaPz5vkAjiiuGxSUnMyy1KL9O0SuDK+ zu5lLFgmUrF3yzH2BsarAl2MnBwSAiYSpw7OZ4GwxSQu3FvPBmILCSxllDj2rgim5vDKM0A1 XEDx6YwSd5p3Qzk9TBKPr+wBcjg42AR0JFrOuoA0iAiUS9x/+IAVpIZZYBKjxOVbC1lBaoQF /CUubUwEqWERUJV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wawkwivGbhAkxJuSWFmVWpQfX1Sak1p8iDEZ6KiJzFKiyfnA FJFXEm9obGJuamxqaWJhYmZJmrCSOO/BVutAIYH0xJLU7NTUgtQimC1MHJxSDYyT9c2SDxzl i6loC1id5yD6yrdctjHOX351dAPXxFchk+LPXVjKUH5Z+uXdM9mmy+r7FxslHf918MceLtdv y5kesAZku2RFS7S4pt7atLy8l6vnxjPNmtZ3jJNfRLvF3z8v+mXHn7ZlGxSuszq+n3PHUk1P pMPD7EjX9T+CG07+dD8zQcw74YkSS3FGoqEWc1FxIgCxQP+HBwMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130911_020902_576949_B7826725 X-CRM114-Status: GOOD ( 15.68 ) X-Spam-Score: -7.6 (-------) Cc: kgene.kim@samsung.com, arnd@arndb.de, sbkim73@samsung.com, vinod.koul@intel.com, broonie@kernel.org, dgreid@chromium.org, olofj@chromium.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dylan Reid Make dma_pointer check how much of the current dma transfer has completed. This improves the accuracy of the pointer operation, which previously was only updated once a period. Before this change calling snd_pcm_avail() right before a dma transfer completed would indicate that the entire transfer was still pending, now it will indicate the actual count of free frames. If the dma being used doesn't support the residue operation to query a pending transfer, then assume that no bytes have been transfered. This leads to the same behavior as before the change. Signed-off-by: Dylan Reid Reviewed-by: Olof Johansson Signed-off-by: Padmavathi Venna --- sound/soc/samsung/dma.c | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-) diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c index 21b7926..6b2e55d 100644 --- a/sound/soc/samsung/dma.c +++ b/sound/soc/samsung/dma.c @@ -271,13 +271,24 @@ dma_pointer(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct runtime_data *prtd = runtime->private_data; - unsigned long res; + unsigned long offset; + unsigned long xfd; /* Number of bytes transfered by current dma. */ + unsigned int ret = 0; pr_debug("Entered %s\n", __func__); - res = prtd->dma_pos - prtd->dma_start; + /* If we can inspect how much of the transfer is left, use that for a + * more accurate number. Otherwise, assume no bytes have been + * transfered. + */ + if (prtd->params->ops->residue) + ret = prtd->params->ops->residue(prtd->params->ch); + + spin_lock(&prtd->lock); + xfd = prtd->dma_period - ret; - pr_debug("Pointer offset: %lu\n", res); + offset = prtd->dma_pos + xfd - prtd->dma_start; + spin_unlock(&prtd->lock); /* we seem to be getting the odd error from the pcm library due * to out-of-bounds pointers. this is maybe due to the dma engine @@ -285,12 +296,12 @@ dma_pointer(struct snd_pcm_substream *substream) * called... (todo - fix ) */ - if (res >= snd_pcm_lib_buffer_bytes(substream)) { - if (res == snd_pcm_lib_buffer_bytes(substream)) - res = 0; - } + if (offset >= snd_pcm_lib_buffer_bytes(substream)) + offset = 0; + + pr_debug("Pointer offset: %lu\n", offset); - return bytes_to_frames(substream->runtime, res); + return bytes_to_frames(substream->runtime, offset); } static int dma_open(struct snd_pcm_substream *substream)