]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
ALSA: Provide a CLOCK_MONOTONIC_RAW timestamp type
authorMark Brown <broonie@linaro.org>
Tue, 8 Jul 2014 14:51:49 +0000 (16:51 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 10 Jul 2014 14:58:13 +0000 (16:58 +0200)
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 <daniel.thompson@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/pcm.h
include/uapi/sound/asound.h

index d854fb31c000756e46bc9c677e6a9979232b8453..6f3e10ca0e323f8ca8422e1a75824bce89d61a62 100644 (file)
@@ -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;
+       }
 }
 
 /*
index 224948342f141c81ce5751e40adf1cf66b956376..cbf7dc850a4640da4430dbfd5032cb188caf8d3e 100644 (file)
@@ -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 */