diff mbox series

media: add V4L2_BUF_FLAG_TIMESTAMP_UTC and V4L2_BUF_FLAG_TIMESTAMP_TAI.

Message ID 1612172048-28830-1-git-send-email-phdm@macqel.be (mailing list archive)
State New, archived
Headers show
Series media: add V4L2_BUF_FLAG_TIMESTAMP_UTC and V4L2_BUF_FLAG_TIMESTAMP_TAI. | expand

Commit Message

Philippe De Muyter Feb. 1, 2021, 9:34 a.m. UTC
Since V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN and
V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC were added long ago, no other flag
was introduced to indicate precisely the reference clock used for
timestamps associated to v4l2 buffers.  Add here the ability for drivers
to use the realtime (= UTC) or TAI clock.

Signed-off-by: Philippe De Muyter <phdm@macqel.be>
---
 Documentation/userspace-api/media/v4l/buffer.rst | 14 ++++++++++++++
 include/trace/events/v4l2.h                      |  2 ++
 include/uapi/linux/videodev2.h                   |  2 ++
 3 files changed, 18 insertions(+)

Comments

Hans Verkuil Nov. 24, 2022, 11:56 a.m. UTC | #1
Hi Philippe,

I'm cleaning up old patches and I decided to mark this as Obsolete since
there has been no activity for a long time. If you still want to pursue this,
then post a v2.

In any case, this patch can only be accepted if there is also a driver in
the mainline kernel that uses it.

Regards,

	Hans

On 01/02/2021 10:34, Philippe De Muyter wrote:
> Since V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN and
> V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC were added long ago, no other flag
> was introduced to indicate precisely the reference clock used for
> timestamps associated to v4l2 buffers.  Add here the ability for drivers
> to use the realtime (= UTC) or TAI clock.
> 
> Signed-off-by: Philippe De Muyter <phdm@macqel.be>
> ---
>  Documentation/userspace-api/media/v4l/buffer.rst | 14 ++++++++++++++
>  include/trace/events/v4l2.h                      |  2 ++
>  include/uapi/linux/videodev2.h                   |  2 ++
>  3 files changed, 18 insertions(+)
> 
> diff --git a/Documentation/userspace-api/media/v4l/buffer.rst b/Documentation/userspace-api/media/v4l/buffer.rst
> index 1b0fdc1..44cb59b 100644
> --- a/Documentation/userspace-api/media/v4l/buffer.rst
> +++ b/Documentation/userspace-api/media/v4l/buffer.rst
> @@ -637,6 +637,20 @@ Buffer Flags
>        - The buffer timestamp has been taken from the ``CLOCK_MONOTONIC``
>  	clock. To access the same clock outside V4L2, use
>  	:c:func:`clock_gettime`.
> +    * .. _`V4L2-BUF-FLAG-TIMESTAMP-UTC`:
> +
> +      - ``V4L2_BUF_FLAG_TIMESTAMP_UTC``
> +      - 0x00008000
> +      - The buffer timestamp has been taken from the ``CLOCK_REALTIME``
> +	clock. To access the same clock outside V4L2, use
> +	:c:func:`clock_gettime`.
> +    * .. _`V4L2-BUF-FLAG-TIMESTAMP-TAI`:
> +
> +      - ``V4L2_BUF_FLAG_TIMESTAMP_TAI``
> +      - 0x0000a000
> +      - The buffer timestamp has been taken from the ``CLOCK_TAI``
> +	clock. To access the same clock outside V4L2, use
> +	:c:func:`clock_gettime`.
>      * .. _`V4L2-BUF-FLAG-TIMESTAMP-COPY`:
>  
>        - ``V4L2_BUF_FLAG_TIMESTAMP_COPY``
> diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
> index 248bc09..ce93c88 100644
> --- a/include/trace/events/v4l2.h
> +++ b/include/trace/events/v4l2.h
> @@ -88,6 +88,8 @@
>  		{ V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN,   "TIMESTAMP_UNKNOWN" },   \
>  		{ V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC, "TIMESTAMP_MONOTONIC" }, \
>  		{ V4L2_BUF_FLAG_TIMESTAMP_COPY,	     "TIMESTAMP_COPY" },      \
> +		{ V4L2_BUF_FLAG_TIMESTAMP_UTC,	     "TIMESTAMP_UTC" },       \
> +		{ V4L2_BUF_FLAG_TIMESTAMP_TAI,	     "TIMESTAMP_TAI" },       \
>  		{ V4L2_BUF_FLAG_LAST,                "LAST" })
>  
>  #define show_timecode_flags(flags)					  \
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> index 79dbde3..87502ab 100644
> --- a/include/uapi/linux/videodev2.h
> +++ b/include/uapi/linux/videodev2.h
> @@ -1101,6 +1101,8 @@ static inline __u64 v4l2_timeval_to_ns(const struct timeval *tv)
>  #define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN		0x00000000
>  #define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC	0x00002000
>  #define V4L2_BUF_FLAG_TIMESTAMP_COPY		0x00004000
> +#define V4L2_BUF_FLAG_TIMESTAMP_UTC		0x00008000
> +#define V4L2_BUF_FLAG_TIMESTAMP_TAI		0x0000a000
>  /* Timestamp sources. */
>  #define V4L2_BUF_FLAG_TSTAMP_SRC_MASK		0x00070000
>  #define V4L2_BUF_FLAG_TSTAMP_SRC_EOF		0x00000000
diff mbox series

Patch

diff --git a/Documentation/userspace-api/media/v4l/buffer.rst b/Documentation/userspace-api/media/v4l/buffer.rst
index 1b0fdc1..44cb59b 100644
--- a/Documentation/userspace-api/media/v4l/buffer.rst
+++ b/Documentation/userspace-api/media/v4l/buffer.rst
@@ -637,6 +637,20 @@  Buffer Flags
       - The buffer timestamp has been taken from the ``CLOCK_MONOTONIC``
 	clock. To access the same clock outside V4L2, use
 	:c:func:`clock_gettime`.
+    * .. _`V4L2-BUF-FLAG-TIMESTAMP-UTC`:
+
+      - ``V4L2_BUF_FLAG_TIMESTAMP_UTC``
+      - 0x00008000
+      - The buffer timestamp has been taken from the ``CLOCK_REALTIME``
+	clock. To access the same clock outside V4L2, use
+	:c:func:`clock_gettime`.
+    * .. _`V4L2-BUF-FLAG-TIMESTAMP-TAI`:
+
+      - ``V4L2_BUF_FLAG_TIMESTAMP_TAI``
+      - 0x0000a000
+      - The buffer timestamp has been taken from the ``CLOCK_TAI``
+	clock. To access the same clock outside V4L2, use
+	:c:func:`clock_gettime`.
     * .. _`V4L2-BUF-FLAG-TIMESTAMP-COPY`:
 
       - ``V4L2_BUF_FLAG_TIMESTAMP_COPY``
diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
index 248bc09..ce93c88 100644
--- a/include/trace/events/v4l2.h
+++ b/include/trace/events/v4l2.h
@@ -88,6 +88,8 @@ 
 		{ V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN,   "TIMESTAMP_UNKNOWN" },   \
 		{ V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC, "TIMESTAMP_MONOTONIC" }, \
 		{ V4L2_BUF_FLAG_TIMESTAMP_COPY,	     "TIMESTAMP_COPY" },      \
+		{ V4L2_BUF_FLAG_TIMESTAMP_UTC,	     "TIMESTAMP_UTC" },       \
+		{ V4L2_BUF_FLAG_TIMESTAMP_TAI,	     "TIMESTAMP_TAI" },       \
 		{ V4L2_BUF_FLAG_LAST,                "LAST" })
 
 #define show_timecode_flags(flags)					  \
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 79dbde3..87502ab 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1101,6 +1101,8 @@  static inline __u64 v4l2_timeval_to_ns(const struct timeval *tv)
 #define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN		0x00000000
 #define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC	0x00002000
 #define V4L2_BUF_FLAG_TIMESTAMP_COPY		0x00004000
+#define V4L2_BUF_FLAG_TIMESTAMP_UTC		0x00008000
+#define V4L2_BUF_FLAG_TIMESTAMP_TAI		0x0000a000
 /* Timestamp sources. */
 #define V4L2_BUF_FLAG_TSTAMP_SRC_MASK		0x00070000
 #define V4L2_BUF_FLAG_TSTAMP_SRC_EOF		0x00000000