1 From a740e59bf8099d1f5b5b29be3e9993fbd51e729a Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Fri, 6 Jul 2018 17:43:03 +0100
4 Subject: [PATCH 388/454] Revert "bcm2835-camera: Fix timestamp calculation
7 This reverts commit 90ac037dbeecbb514b677e43b53bc5b1a452ea22.
8 This has been fixed in an alternate format upstream, so adopt that.
10 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
12 .../bcm2835-camera/bcm2835-camera.c | 41 ++++++++++++++-----
13 .../bcm2835-camera/bcm2835-camera.h | 2 +-
14 2 files changed, 32 insertions(+), 11 deletions(-)
16 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
17 +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
18 @@ -374,17 +374,37 @@ static void buffer_cb(struct vchiq_mmal_
19 buf->vb.vb2_buf.timestamp);
22 + struct timeval timestamp;
23 s64 runtime_us = pts -
24 dev->capture.vc_start_timestamp;
25 - buf->vb.vb2_buf.timestamp = (runtime_us * NSEC_PER_USEC) +
26 - dev->capture.kernel_start_timestamp;
31 + div_u64_rem(runtime_us, USEC_PER_SEC, &rem);
33 + dev->capture.kernel_start_ts.tv_sec + div;
35 + dev->capture.kernel_start_ts.tv_usec + rem;
37 + if (timestamp.tv_usec >=
40 + timestamp.tv_usec -=
43 v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
44 - "Buffer time set as converted timestamp - %llu "
45 - "= (pts [%lld usec] - vc start time [%llu usec]) "
46 - "+ kernel start time [%llu nsec]\n",
47 - buf->vb.vb2_buf.timestamp,
48 - pts, dev->capture.vc_start_timestamp,
49 - dev->capture.kernel_start_timestamp);
50 + "Convert start time %d.%06d and %llu "
51 + "with offset %llu to %d.%06d\n",
52 + (int)dev->capture.kernel_start_ts.
54 + (int)dev->capture.kernel_start_ts.
56 + dev->capture.vc_start_timestamp, pts,
57 + (int)timestamp.tv_sec,
58 + (int)timestamp.tv_usec);
59 + buf->vb.vb2_buf.timestamp = timestamp.tv_sec * 1000000000ULL +
60 + timestamp.tv_usec * 1000ULL;
62 if (dev->capture.last_timestamp) {
63 buf->vb.vb2_buf.timestamp = dev->capture.last_timestamp;
64 @@ -394,7 +414,8 @@ static void buffer_cb(struct vchiq_mmal_
67 buf->vb.vb2_buf.timestamp =
68 - dev->capture.kernel_start_timestamp;
69 + dev->capture.kernel_start_ts.tv_sec * 1000000000ULL +
70 + dev->capture.kernel_start_ts.tv_usec * 1000ULL;
71 v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
72 "Buffer time set as start timestamp - %lld",
73 buf->vb.vb2_buf.timestamp);
74 @@ -575,7 +596,7 @@ static int start_streaming(struct vb2_qu
76 dev->capture.last_timestamp = 0;
78 - dev->capture.kernel_start_timestamp = ktime_get_ns();
79 + v4l2_get_timestamp(&dev->capture.kernel_start_ts);
81 /* enable the camera port */
82 dev->capture.port->cb_ctx = dev;
83 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h
84 +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h
85 @@ -92,7 +92,7 @@ struct bm2835_mmal_dev {
86 /* VC start timestamp for streaming */
87 s64 vc_start_timestamp;
88 /* Kernel start timestamp for streaming */
89 - u64 kernel_start_timestamp;
90 + struct timeval kernel_start_ts;
91 /* Timestamp of last frame */