@@ -363,37 +363,17 @@ static void buffer_cb(struct vchiq_mmal_instance *instance,
363
363
buf -> vb .vb2_buf .timestamp );
364
364
365
365
} else if (pts != 0 ) {
366
- struct timeval timestamp ;
367
366
s64 runtime_us = pts -
368
367
dev -> capture .vc_start_timestamp ;
369
- u32 div = 0 ;
370
- u32 rem = 0 ;
371
-
372
- div =
373
- div_u64_rem (runtime_us , USEC_PER_SEC , & rem );
374
- timestamp .tv_sec =
375
- dev -> capture .kernel_start_ts .tv_sec + div ;
376
- timestamp .tv_usec =
377
- dev -> capture .kernel_start_ts .tv_usec + rem ;
378
-
379
- if (timestamp .tv_usec >=
380
- USEC_PER_SEC ) {
381
- timestamp .tv_sec ++ ;
382
- timestamp .tv_usec -=
383
- USEC_PER_SEC ;
384
- }
368
+ buf -> vb .vb2_buf .timestamp = (runtime_us * NSEC_PER_USEC ) +
369
+ dev -> capture .kernel_start_timestamp ;
385
370
v4l2_dbg (1 , bcm2835_v4l2_debug , & dev -> v4l2_dev ,
386
- "Convert start time %d.%06d and %llu "
387
- "with offset %llu to %d.%06d\n" ,
388
- (int )dev -> capture .kernel_start_ts .
389
- tv_sec ,
390
- (int )dev -> capture .kernel_start_ts .
391
- tv_usec ,
392
- dev -> capture .vc_start_timestamp , pts ,
393
- (int )timestamp .tv_sec ,
394
- (int )timestamp .tv_usec );
395
- buf -> vb .vb2_buf .timestamp = timestamp .tv_sec * 1000000000ULL +
396
- timestamp .tv_usec * 1000ULL ;
371
+ "Buffer time set as converted timestamp - %llu "
372
+ "= (pts [%lld usec] - vc start time [%llu usec]) "
373
+ "+ kernel start time [%llu nsec]\n" ,
374
+ buf -> vb .vb2_buf .timestamp ,
375
+ pts , dev -> capture .vc_start_timestamp ,
376
+ dev -> capture .kernel_start_timestamp );
397
377
} else {
398
378
if (dev -> capture .last_timestamp ) {
399
379
buf -> vb .vb2_buf .timestamp = dev -> capture .last_timestamp ;
@@ -403,8 +383,7 @@ static void buffer_cb(struct vchiq_mmal_instance *instance,
403
383
}
404
384
else {
405
385
buf -> vb .vb2_buf .timestamp =
406
- dev -> capture .kernel_start_ts .tv_sec * 1000000000ULL +
407
- dev -> capture .kernel_start_ts .tv_usec * 1000ULL ;
386
+ dev -> capture .kernel_start_timestamp ;
408
387
v4l2_dbg (1 , bcm2835_v4l2_debug , & dev -> v4l2_dev ,
409
388
"Buffer time set as start timestamp - %lld" ,
410
389
buf -> vb .vb2_buf .timestamp );
@@ -586,7 +565,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
586
565
587
566
dev -> capture .last_timestamp = 0 ;
588
567
589
- v4l2_get_timestamp ( & dev -> capture .kernel_start_ts );
568
+ dev -> capture .kernel_start_timestamp = ktime_get_ns ( );
590
569
591
570
/* enable the camera port */
592
571
dev -> capture .port -> cb_ctx = dev ;
0 commit comments