media: videodev2.h: add v4l2_timeval_to_ns inline function
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 24 Oct 2018 10:50:34 +0000 (06:50 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 7 Jan 2019 18:18:54 +0000 (13:18 -0500)
commitc2eb8effb265ac5cdd960d8e61ecb931e9c767cd
treef7a56858a9aec44e3fde9e40d2194fea9151df05
parent0e9109ffded1cfa2aeb5617a9a683ca3467e6e99
media: videodev2.h: add v4l2_timeval_to_ns inline function

We want to be able to uniquely identify buffers for stateless
codecs. The internal timestamp (a u64) as stored internally in the
kernel is a suitable candidate for that, but in struct v4l2_buffer
it is represented as a struct timeval.

Add a v4l2_timeval_to_ns() function that converts the struct timeval
into a u64 in the same way that the kernel does. This makes it possible
to use this u64 elsewhere as a unique identifier of the buffer.

Since timestamps are also copied from the output buffer to the
corresponding capture buffer(s) by M2M devices, the u64 can be
used to refer to both output and capture buffers.

The plan is that in the future we redesign struct v4l2_buffer and use
u64 for the timestamp instead of a struct timeval (which has lots of
problems with 32 vs 64 bit and y2038 layout changes), and then there
is no more need to use this function.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
include/uapi/linux/videodev2.h