From patchwork Wed May 25 13:27:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gardiner X-Patchwork-Id: 816152 Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4PDShW9030847 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 May 2011 13:29:04 GMT Received: from dlep36.itg.ti.com ([157.170.170.91]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id p4PDRW25018718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 25 May 2011 08:27:32 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.7) with ESMTP id p4PDRVBD005379; Wed, 25 May 2011 08:27:32 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 2C19C80627; Wed, 25 May 2011 08:27:31 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 7013C80626 for ; Wed, 25 May 2011 08:27:29 -0500 (CDT) Received: from neches.ext.ti.com (neches.ext.ti.com [192.91.81.29]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id p4PDRPlN012182 for ; Wed, 25 May 2011 08:27:25 -0500 (CDT) Received: from psmtp.com (na3sys009amx202.postini.com [74.125.149.42]) by neches.ext.ti.com (8.13.7/8.13.7) with SMTP id p4PDRP58023721 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 25 May 2011 08:27:25 -0500 Received: from na3sys009aog104.obsmtp.com ([209.85.218.53]) (using TLSv1) by na3sys009amx202.postini.com ([74.125.148.10]) with SMTP; Wed, 25 May 2011 13:27:25 GMT Received: from mail-yi0-f53.google.com ([209.85.218.53]) (using TLSv1) by na3sys009aob104.postini.com ([74.125.148.12]) with SMTP ID DSNKTd0DvK4d9wu11WTWz/tbgDOaIrIogc/d@postini.com; Wed, 25 May 2011 06:27:25 PDT Received: by mail-yi0-f53.google.com with SMTP id 25so3682741yia.26 for ; Wed, 25 May 2011 06:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nanometrics.ca; s=google; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=iRClZqK0Es5gDOPF1zOCVJ75/UkQbkl8MhfhB6QsLqs=; b=Q2hPvkyZIOayg4nPOW4I9BNcUS+R4+FJF1jij2mhVDZeqQU96gG3WNtwAKV6/d5tPQ Mi0vOHMzMQUteZT3CpccBOSHG34QsDIUMwU0fn49Pv8ca72D/oAdOHKejgRkRMW2xZ9Y DM1JV8BHJClv6SwvY/uMiPBzs7pO8L9jl0gkc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=nanometrics.ca; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=JYfmZzQug/0k1eVfyMtGB+raHVtgW/nhWFPTv78kuZhUEYCfsqpPHlfF+IwGxb25uw 3LE2sYEkLrSd35EctoXNsc+Au7bvpFFVyHBZNVixZN4Oy/LiOtEi8xLFrjLg58mF5aps zqzji6MI3v93LCnR0TaWFs9oqL1k3hn7TADSA= Received: by 10.236.139.166 with SMTP id c26mr6850987yhj.225.1306330044673; Wed, 25 May 2011 06:27:24 -0700 (PDT) Received: from localhost.localdomain ([206.191.47.130]) by mx.google.com with ESMTPS id v70sm780096yhm.3.2011.05.25.06.27.23 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2011 06:27:24 -0700 (PDT) From: Ben Gardiner To: Liam Girdwood , Mark Brown , Sekhar Nori , alsa-devel@alsa-project.org, davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH] ASoC: davinci-pcm: comments for the conversion to BATCH mode Date: Wed, 25 May 2011 09:27:22 -0400 Message-Id: <1306330042-16714-1-git-send-email-bengardiner@nanometrics.ca> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <4DDCD16C.1080702@ti.com> References: <4DDCD16C.1080702@ti.com> X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:99.90000/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.0750) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: Steven Faludi X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 25 May 2011 13:29:05 +0000 (UTC) In the previous commit 'ASoC: davinci-pcm: convert to BATCH mode', the phase offset of 2 was mentioned in the commit message but not well commented in the source. Add descriptive comments of the phase offset with and without ping-pong buffers enabled. Signed-off-by: Ben Gardiner --- sound/soc/davinci/davinci-pcm.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c index fa8fc61..c9e0320 100644 --- a/sound/soc/davinci/davinci-pcm.c +++ b/sound/soc/davinci/davinci-pcm.c @@ -605,6 +605,18 @@ static int davinci_pcm_prepare(struct snd_pcm_substream *substream) print_buf_info(prtd->asp_link[0], "asp_link[0]"); print_buf_info(prtd->asp_link[1], "asp_link[1]"); + /* + * There is a phase offset of 2 periods between the position + * used by dma setup and the position reported in the pointer + * function. + * + * The phase offset, when not using ping-pong buffers, is due to + * the two consecutive calls to davinci_pcm_enqueue_dma() below. + * + * Whereas here, with ping-pong buffers, the phase is due to + * there being an entire buffer transfer complete before the + * first dma completion event triggers davinci_pcm_dma_irq(). + */ davinci_pcm_period_elapsed(substream); davinci_pcm_period_elapsed(substream); @@ -631,6 +643,13 @@ davinci_pcm_pointer(struct snd_pcm_substream *substream) int asp_count; unsigned int period_size = snd_pcm_lib_period_bytes(substream); + /* + * There is a phase offset of 2 periods between the position used by dma + * setup and the position reported in the pointer function. Either +2 in + * the dma setup or -2 here in the pointer function (with wrapping, + * both) accounts for this offset -- choose the latter since it makes + * the first-time setup clearer. + */ spin_lock(&prtd->lock); asp_count = prtd->period - 2; spin_unlock(&prtd->lock);