From patchwork Thu Jul 10 13:04:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 33424 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5301021140 for ; Thu, 10 Jul 2014 13:04:45 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kq14sf59560607pab.0 for ; Thu, 10 Jul 2014 06:04:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=DUPApru4imNFz1QULQD+f76/A2P3jIqskHlzDpVILsM=; b=Jrk9wm4fnDvu/8/+b9ovRsepNL0bwC2DNMczuUESyk8e2MgD6vaaZsOIp9SR74uSO0 SRAVDKDtYySMdVc987QJJ1wdu3iqpLsyS2IVJy6VYyjBEXjQFX8EE6PTaAag+twQ+Ekj YxxUCAvQ1LCPdYHPoDy1UDkjIJVF8gaARDhEfAWCteqYtALEYAHAXMyLDFjyOy4im/cb uzzle+Tkcr7io2y6jFJf42fcbB2xSCw80cszhWCmJEASQ9gywrdyTj/YoRT0FajHceTU nnUpN7FAolyiNq7oeIOjfZRhtCmb8C142UrPET2ZemOgsMo+u6BGrp5TVviEJviQvvUK eEng== X-Gm-Message-State: ALoCoQl5PBpIbQtJttbDhx8GoEbF7hOtj2U6bZp7HHeia2ExIBGZZ1Qape8hGvnfCsh2EGzB3GMM X-Received: by 10.66.66.163 with SMTP id g3mr23328571pat.3.1404997484496; Thu, 10 Jul 2014 06:04:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.51 with SMTP id s48ls53902qgs.64.gmail; Thu, 10 Jul 2014 06:04:44 -0700 (PDT) X-Received: by 10.58.208.170 with SMTP id mf10mr45068184vec.22.1404997484384; Thu, 10 Jul 2014 06:04:44 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id o6si22889743vcn.83.2014.07.10.06.04.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Jul 2014 06:04:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ij19so10395721vcb.37 for ; Thu, 10 Jul 2014 06:04:44 -0700 (PDT) X-Received: by 10.220.68.140 with SMTP id v12mr44864377vci.13.1404997484154; Thu, 10 Jul 2014 06:04:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp131031vcb; Thu, 10 Jul 2014 06:04:43 -0700 (PDT) X-Received: by 10.194.104.200 with SMTP id gg8mr56556455wjb.93.1404997482785; Thu, 10 Jul 2014 06:04:42 -0700 (PDT) Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id u4si62080405wjy.175.2014.07.10.06.04.42 for ; Thu, 10 Jul 2014 06:04:42 -0700 (PDT) Received-SPF: none (google.com: alsa-devel-bounces@alsa-project.org does not designate permitted sender hosts) client-ip=77.48.224.243; Received: by alsa0.perex.cz (Postfix, from userid 1000) id 322C32619F2; Thu, 10 Jul 2014 15:04:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.2.4 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id DA1CE2607C8; Thu, 10 Jul 2014 15:04:32 +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 C12232615F7; Thu, 10 Jul 2014 15:04:30 +0200 (CEST) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id A1A0126072A for ; Thu, 10 Jul 2014 15:04:22 +0200 (CEST) Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6F5BFAD58; Thu, 10 Jul 2014 13:04:22 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Thu, 10 Jul 2014 15:04:17 +0200 Message-Id: <1404997458-15377-3-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1404997458-15377-1-git-send-email-tiwai@suse.de> References: <1404997458-15377-1-git-send-email-tiwai@suse.de> Cc: Daniel Thompson , Mark Brown , Clemens Ladisch Subject: [alsa-devel] [PATCH 2/3] ALSA: Provide a CLOCK_MONOTONIC_RAW timestamp type X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tiwai@suse.de X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Mark Brown For applications which need to synchronise with external timebases such as broadcast TV applications the kernel monotonic time is not optimal as it includes adjustments from NTP and so may still include discontinuities due to that. A raw monotonic time which does not include any adjustments is available in the kernel from getrawmonotonic() so provide userspace with a new timestamp type SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW which provides timestamps based on this as an option. [dropped tstamp_type assignment code, as it's no longer needed -- tiwai] Reported-by: Daniel Thompson Signed-off-by: Mark Brown Signed-off-by: Takashi Iwai --- include/sound/pcm.h | 11 +++++++++-- include/uapi/sound/asound.h | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index d854fb31c000..6f3e10ca0e32 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -931,10 +931,17 @@ void snd_pcm_timer_done(struct snd_pcm_substream *substream); static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime, struct timespec *tv) { - if (runtime->tstamp_type == SNDRV_PCM_TSTAMP_TYPE_MONOTONIC) + switch (runtime->tstamp_type) { + case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC: ktime_get_ts(tv); - else + break; + case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW: + getrawmonotonic(tv); + break; + default: getnstimeofday(tv); + break; + } } /* diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index 224948342f14..cbf7dc850a46 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -462,7 +462,8 @@ struct snd_xfern { enum { SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0, /* gettimeofday equivalent */ SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, /* posix_clock_monotonic equivalent */ - SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, + SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW, /* monotonic_raw (no NTP) */ + SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW, }; /* channel positions */