From patchwork Wed Mar 3 13:08:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 83327 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o23D8XUO018314 for ; Wed, 3 Mar 2010 13:08:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753933Ab0CCNIg (ORCPT ); Wed, 3 Mar 2010 08:08:36 -0500 Received: from smtp.nokia.com ([192.100.105.134]:32536 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753815Ab0CCNIf (ORCPT ); Wed, 3 Mar 2010 08:08:35 -0500 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o23D6Xd6031550; Wed, 3 Mar 2010 07:08:27 -0600 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 3 Mar 2010 15:08:15 +0200 Received: from mgw-sa01.ext.nokia.com ([147.243.1.47]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 3 Mar 2010 15:08:15 +0200 Received: from localhost.localdomain (cseresznye.nmp.nokia.com [172.22.211.20]) by mgw-sa01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o23D87sj031611; Wed, 3 Mar 2010 15:08:14 +0200 From: Peter Ujfalusi To: broonie@opensource.wolfsonmicro.com, tony@atomide.com Cc: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, lrg@slimlogic.co.uk, jhnikula@GMAIL.COM, ext-eero.nurkkala@nokia.com Subject: [PATCHv2 3/5] ASoC: core: Add delay operation to snd_soc_dai_ops Date: Wed, 3 Mar 2010 15:08:07 +0200 Message-Id: <1267621689-30337-5-git-send-email-peter.ujfalusi@nokia.com> X-Mailer: git-send-email 1.7.0 In-Reply-To: <1267621689-30337-1-git-send-email-peter.ujfalusi@nokia.com> References: <1267621689-30337-1-git-send-email-peter.ujfalusi@nokia.com> X-OriginalArrivalTime: 03 Mar 2010 13:08:15.0562 (UTC) FILETIME=[95FACAA0:01CABAD2] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 03 Mar 2010 13:08:37 +0000 (UTC) diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 061f16d..be9cd47 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -182,6 +182,12 @@ struct snd_soc_dai_ops { struct snd_soc_dai *); int (*trigger)(struct snd_pcm_substream *, int, struct snd_soc_dai *); + /* + * For hardware based FIFO caused delay reporting. + * Optional. + */ + snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *, + struct snd_soc_dai *); }; /* diff --git a/include/sound/soc.h b/include/sound/soc.h index 5d234a8..c010824 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -469,6 +469,13 @@ struct snd_soc_platform { struct snd_pcm *); void (*pcm_free)(struct snd_pcm *); + /* + * For platform caused delay reporting. + * Optional. + */ + snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *, + struct snd_soc_dai *); + /* platform stream ops */ struct snd_pcm_ops *pcm_ops; }; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index de5223d..e9c2dc1 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -799,6 +799,8 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) /* * soc level wrapper for pointer callback + * If cpu_dai, codec_dai, platform driver has the delay callback, than + * the runtime->delay will be updated accordingly. */ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) { @@ -806,11 +808,27 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) struct snd_soc_device *socdev = rtd->socdev; struct snd_soc_card *card = socdev->card; struct snd_soc_platform *platform = card->platform; + struct snd_soc_dai_link *machine = rtd->dai; + struct snd_soc_dai *cpu_dai = machine->cpu_dai; + struct snd_soc_dai *codec_dai = machine->codec_dai; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t offset = 0; + snd_pcm_sframes_t delay = 0; if (platform->pcm_ops->pointer) offset = platform->pcm_ops->pointer(substream); + if (cpu_dai->ops->delay) + delay += cpu_dai->ops->delay(substream, cpu_dai); + + if (codec_dai->ops->delay) + delay += codec_dai->ops->delay(substream, codec_dai); + + if (platform->delay) + delay += platform->delay(substream, codec_dai); + + runtime->delay = delay; + return offset; }