All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: linux-media@vger.kernel.org
Cc: hverkuil@xs4all.nl
Subject: [RFC 2/4] v4l: Helper function for obtaining timestamps
Date: Wed, 24 Oct 2012 21:16:21 +0300	[thread overview]
Message-ID: <1351102583-682-2-git-send-email-sakari.ailus@iki.fi> (raw)
In-Reply-To: <20121024181602.GD23933@valkosipuli.retiisi.org.uk>

v4l2_get_timestamp() produces a monotonic timestamp but unlike
ktime_get_ts(), it uses struct timeval instead of struct timespec, saving
the drivers the conversion job when getting timestamps for v4l2_buffer's
timestamp field.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 drivers/media/v4l2-core/v4l2-common.c |   10 ++++++++++
 include/media/v4l2-common.h           |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index f995dd3..cbace52 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -979,3 +979,13 @@ const struct v4l2_frmsize_discrete *v4l2_find_nearest_format(
 	return best;
 }
 EXPORT_SYMBOL_GPL(v4l2_find_nearest_format);
+
+void v4l2_get_timestamp(struct timeval *tv)
+{
+	struct timespec ts;
+
+	ktime_get_ts(&ts);
+	tv->tv_sec = ts.tv_sec;
+	tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
+}
+EXPORT_SYMBOL_GPL(v4l2_get_timestamp);
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 1a0b2db..ec7c9c0 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -225,4 +225,6 @@ bool v4l2_detect_gtf(unsigned frame_height, unsigned hfreq, unsigned vsync,
 
 struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait);
 
+void v4l2_get_timestamp(struct timeval *tv);
+
 #endif /* V4L2_COMMON_H_ */
-- 
1.7.2.5


  parent reply	other threads:[~2012-10-24 18:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24 18:16 [RFC 0/4] Monotonic timestamps Sakari Ailus
2012-10-24 18:16 ` [RFC 1/4] v4l: Define video buffer flags for timestamp types Sakari Ailus
2012-11-04 12:05   ` Laurent Pinchart
2012-10-24 18:16 ` Sakari Ailus [this message]
2012-10-24 18:16 ` [RFC 3/4] v4l: Convert drivers to use monotonic timestamps Sakari Ailus
2012-10-24 18:16 ` [RFC 4/4] v4l: Tell user space we're using " Sakari Ailus
2012-11-04 12:07   ` Laurent Pinchart
2012-11-05 14:04     ` Sakari Ailus
2012-11-08 12:18       ` Laurent Pinchart
2012-11-08 22:33         ` Sakari Ailus
2012-11-12 12:17           ` Laurent Pinchart
2012-11-12 15:20             ` Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351102583-682-2-git-send-email-sakari.ailus@iki.fi \
    --to=sakari.ailus@iki.fi \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.