From patchwork Wed Jul 8 10:10:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 6743821 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 94D63C05AC for ; Wed, 8 Jul 2015 10:12:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1ECB206E5 for ; Wed, 8 Jul 2015 10:12:25 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 3F0F32065B for ; Wed, 8 Jul 2015 10:12:23 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 73CBF260617; Wed, 8 Jul 2015 12:12:20 +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.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 79630260632; Wed, 8 Jul 2015 12:11:08 +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 DDECD26068D; Wed, 8 Jul 2015 12:11:06 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id 1FF042605A1 for ; Wed, 8 Jul 2015 12:10:56 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 08 Jul 2015 03:10:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,431,1432623600"; d="scan'208";a="602243124" Received: from andersea-mobl1.ger.corp.intel.com (HELO pbossart-mobl2.ger.corp.intel.com) ([10.252.7.213]) by orsmga003.jf.intel.com with ESMTP; 08 Jul 2015 03:10:52 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Date: Wed, 8 Jul 2015 05:10:34 -0500 Message-Id: <1436350236-17509-3-git-send-email-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436350236-17509-1-git-send-email-pierre-louis.bossart@linux.intel.com> References: <1436350236-17509-1-git-send-email-pierre-louis.bossart@linux.intel.com> Cc: Pierre-Louis Bossart Subject: [alsa-devel] [RFC PATCH 2/4] ALSA: core: add .notify callback for pcm ops 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP When appl_ptr is updated let low-level driver know. This is only enabled when the NO_REWIND hardware flag is used, so that the low-level driver/hardware to opportunistically pre-fetch data. FIXME: should we rely on .ack for this? Signed-off-by: Pierre-Louis Bossart --- include/sound/pcm.h | 2 ++ sound/core/pcm_native.c | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 25310b7..d5eff03 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -87,6 +87,8 @@ struct snd_pcm_ops { unsigned long offset); int (*mmap)(struct snd_pcm_substream *substream, struct vm_area_struct *vma); int (*ack)(struct snd_pcm_substream *substream); + int (*notify)(struct snd_pcm_substream *substream); + /* FIXME: what's the difference between ack and notify ? */ }; /* diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index a70e52d..dd519b8 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2565,6 +2565,10 @@ static snd_pcm_sframes_t snd_pcm_playback_forward(struct snd_pcm_substream *subs appl_ptr -= runtime->boundary; runtime->control->appl_ptr = appl_ptr; ret = frames; + + if (runtime->no_rewinds && substream->ops->notify) + substream->ops->notify(substream); + __end: snd_pcm_stream_unlock_irq(substream); return ret; @@ -2614,6 +2618,10 @@ static snd_pcm_sframes_t snd_pcm_capture_forward(struct snd_pcm_substream *subst appl_ptr -= runtime->boundary; runtime->control->appl_ptr = appl_ptr; ret = frames; + + if (runtime->no_rewinds && substream->ops->notify) + substream->ops->notify(substream); + __end: snd_pcm_stream_unlock_irq(substream); return ret; @@ -2713,8 +2721,16 @@ static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, return err; } snd_pcm_stream_lock_irq(substream); - if (!(sync_ptr.flags & SNDRV_PCM_SYNC_PTR_APPL)) + if (!(sync_ptr.flags & SNDRV_PCM_SYNC_PTR_APPL)) { + /* FIXME: this code is used by mmap_commit, should it handle boundary + * wrap-around as done for read/write in pcm_lib.c + */ + control->appl_ptr = sync_ptr.c.control.appl_ptr; + /* if supported, let low-level driver know about appl_ptr change */ + if (runtime->no_rewinds && substream->ops->notify) + substream->ops->notify(substream); + } else sync_ptr.c.control.appl_ptr = control->appl_ptr; if (!(sync_ptr.flags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN))