From c3d18e41b138044c44916ade07f7d4d1e34cb90f Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 10 Jan 2013 13:45:49 +0100 Subject: [PATCH] v4l2-ctl: show used timestamp type. Implement support for the new timestamp type encoded in the buffer flags. Signed-off-by: Hans Verkuil --- utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp index 3b55227..5a080e3 100644 --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp @@ -89,6 +89,21 @@ static const flag_def flags_def[] = { { 0, NULL } }; +static std::string timestamp_type2s(__u32 flags) +{ + char buf[20]; + + switch (flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) { + case V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN: + return "Unknown"; + case V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC: + return "Monotonic"; + default: + sprintf(buf, "Type %d", (flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) >> 13); + return std::string(buf); + } +} + static const flag_def tc_flags_def[] = { { V4L2_TC_FLAG_DROPFRAME, "dropframe" }, { V4L2_TC_FLAG_COLORFRAME, "colorframe" }, @@ -107,7 +122,8 @@ static void print_buffer(struct v4l2_buffer &buf) printf("\tSequence : %u\n", buf.sequence); printf("\tLength : %u\n", buf.length); printf("\tBytesused: %u\n", buf.bytesused); - printf("\tTimestamp: %lu.%06lus\n", buf.timestamp.tv_sec, buf.timestamp.tv_usec); + printf("\tTimestamp: %lu.%06lus (%s)\n", buf.timestamp.tv_sec, buf.timestamp.tv_usec, + timestamp_type2s(buf.flags).c_str()); if (buf.flags & V4L2_BUF_FLAG_TIMECODE) { static const int fps_types[] = { 0, 24, 25, 30, 50, 60 }; int fps = buf.timecode.type; -- 2.7.4