1 From ab4be0bc5cce7c699d654d7f88a3c1bec57b5570 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Fri, 10 May 2019 14:11:58 +0100
4 Subject: [PATCH 513/773] staging: bcm2835-codec: Convert V4L2 nsec timestamps
7 V4L2 uses nsecs, whilst MMAL uses usecs, but the code wasn't converting
8 between them. This upsets video encode rate control.
10 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
12 .../vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c | 9 +++++++--
13 1 file changed, 7 insertions(+), 2 deletions(-)
15 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
16 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
17 @@ -823,7 +823,8 @@ static void op_buffer_cb(struct vchiq_mm
18 vb2->flags |= V4L2_BUF_FLAG_LAST;
21 - vb2->vb2_buf.timestamp = mmal_buf->pts;
22 + /* vb2 timestamps in nsecs, mmal in usecs */
23 + vb2->vb2_buf.timestamp = mmal_buf->pts * 1000;
25 vb2_set_plane_payload(&vb2->vb2_buf, 0, mmal_buf->length);
26 if (mmal_buf->mmal_flags & MMAL_BUFFER_HEADER_FLAG_KEYFRAME)
27 @@ -847,6 +848,7 @@ static void op_buffer_cb(struct vchiq_mm
28 static void vb2_to_mmal_buffer(struct m2m_mmal_buffer *buf,
29 struct vb2_v4l2_buffer *vb2)
32 buf->mmal.mmal_flags = 0;
33 if (vb2->flags & V4L2_BUF_FLAG_KEYFRAME)
34 buf->mmal.mmal_flags |= MMAL_BUFFER_HEADER_FLAG_KEYFRAME;
35 @@ -869,7 +871,10 @@ static void vb2_to_mmal_buffer(struct m2
36 if (!buf->mmal.length || vb2->flags & V4L2_BUF_FLAG_LAST)
37 buf->mmal.mmal_flags |= MMAL_BUFFER_HEADER_FLAG_EOS;
39 - buf->mmal.pts = vb2->vb2_buf.timestamp;
40 + /* vb2 timestamps in nsecs, mmal in usecs */
41 + pts = vb2->vb2_buf.timestamp;
43 + buf->mmal.pts = pts;
44 buf->mmal.dts = MMAL_TIME_UNKNOWN;