aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJunghak Sung <jh1009.sung@samsung.com>2015-11-03 05:16:37 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-12-18 10:53:31 -0500
commitd6dd645eae76eeb42cb47d9da69cd3f56b3f2cb6 (patch)
tree7cd1f67b772a7829c832aca35a69454b162ab2d0 /drivers
parent9057bc2b35cfdb5b5fb7d93708f11de5dd9b6b2e (diff)
[media] media: videobuf2: Move timestamp to vb2_buffer
Move timestamp from struct vb2_v4l2_buffer to struct vb2_buffer for common use, and change its type to u64 in order to handling y2038 problem. This patch also includes all device drivers' changes related to this restructuring. Signed-off-by: Junghak Sung <jh1009.sung@samsung.com> Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com> Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com> Acked-by: Inki Dae <inki.dae@samsung.com> Signed-off-by: Hans Verkuil <hansverk@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/touchscreen/sur40.c2
-rw-r--r--drivers/media/dvb-frontends/rtl2832_sdr.c2
-rw-r--r--drivers/media/pci/cobalt/cobalt-irq.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-core.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-video.c2
-rw-r--r--drivers/media/pci/cx25821/cx25821-video.c2
-rw-r--r--drivers/media/pci/cx88/cx88-core.c2
-rw-r--r--drivers/media/pci/dt3155/dt3155.c2
-rw-r--r--drivers/media/pci/netup_unidvb/netup_unidvb_core.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-core.c2
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c2
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-v4l2.c2
-rw-r--r--drivers/media/pci/sta2x11/sta2x11_vip.c2
-rw-r--r--drivers/media/pci/tw68/tw68-video.c2
-rw-r--r--drivers/media/platform/am437x/am437x-vpfe.c2
-rw-r--r--drivers/media/platform/blackfin/bfin_capture.c2
-rw-r--r--drivers/media/platform/coda/coda-bit.c6
-rw-r--r--drivers/media/platform/coda/coda.h2
-rw-r--r--drivers/media/platform/davinci/vpbe_display.c2
-rw-r--r--drivers/media/platform/davinci/vpif_capture.c2
-rw-r--r--drivers/media/platform/davinci/vpif_display.c6
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-m2m.c4
-rw-r--r--drivers/media/platform/exynos4-is/fimc-capture.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-isp-video.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-m2m.c2
-rw-r--r--drivers/media/platform/m2m-deinterlace.c2
-rw-r--r--drivers/media/platform/marvell-ccic/mcam-core.c2
-rw-r--r--drivers/media/platform/mx2_emmaprp.c2
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.c2
-rw-r--r--drivers/media/platform/rcar_jpu.c2
-rw-r--r--drivers/media/platform/s3c-camif/camif-capture.c2
-rw-r--r--drivers/media/platform/s5p-g2d/g2d.c2
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-core.c4
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c4
-rw-r--r--drivers/media/platform/sh_veu.c2
-rw-r--r--drivers/media/platform/sh_vou.c2
-rw-r--r--drivers/media/platform/soc_camera/atmel-isi.c2
-rw-r--r--drivers/media/platform/soc_camera/mx2_camera.c2
-rw-r--r--drivers/media/platform/soc_camera/mx3_camera.c2
-rw-r--r--drivers/media/platform/soc_camera/rcar_vin.c2
-rw-r--r--drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c2
-rw-r--r--drivers/media/platform/sti/bdisp/bdisp-v4l2.c4
-rw-r--r--drivers/media/platform/ti-vpe/vpe.c2
-rw-r--r--drivers/media/platform/vim2m.c2
-rw-r--r--drivers/media/platform/vivid/vivid-core.h2
-rw-r--r--drivers/media/platform/vivid/vivid-ctrls.c14
-rw-r--r--drivers/media/platform/vivid/vivid-kthread-cap.c6
-rw-r--r--drivers/media/platform/vivid/vivid-kthread-out.c8
-rw-r--r--drivers/media/platform/vivid/vivid-sdr-cap.c4
-rw-r--r--drivers/media/platform/vivid/vivid-vbi-cap.c6
-rw-r--r--drivers/media/platform/vsp1/vsp1_video.c2
-rw-r--r--drivers/media/platform/xilinx/xilinx-dma.c2
-rw-r--r--drivers/media/usb/airspy/airspy.c2
-rw-r--r--drivers/media/usb/au0828/au0828-video.c2
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c2
-rw-r--r--drivers/media/usb/go7007/go7007-driver.c2
-rw-r--r--drivers/media/usb/hackrf/hackrf.c4
-rw-r--r--drivers/media/usb/pwc/pwc-if.c3
-rw-r--r--drivers/media/usb/s2255/s2255drv.c2
-rw-r--r--drivers/media/usb/stk1160/stk1160-video.c2
-rw-r--r--drivers/media/usb/usbtv/usbtv-video.c2
-rw-r--r--drivers/media/usb/uvc/uvc_video.c15
-rw-r--r--drivers/media/v4l2-core/videobuf2-v4l2.c7
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_video.c2
-rw-r--r--drivers/staging/media/omap4iss/iss_video.c2
-rw-r--r--drivers/usb/gadget/function/uvc_queue.c2
67 files changed, 99 insertions, 100 deletions
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index 3f3e2b12e5e7..b6c4d03de340 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -444,7 +444,7 @@ static void sur40_process_video(struct sur40_state *sur40)
444 goto err_poll; 444 goto err_poll;
445 445
446 /* mark as finished */ 446 /* mark as finished */
447 v4l2_get_timestamp(&new_buf->vb.timestamp); 447 new_buf->vb.vb2_buf.timestamp = ktime_get_ns();
448 new_buf->vb.sequence = sur40->sequence++; 448 new_buf->vb.sequence = sur40->sequence++;
449 new_buf->vb.field = V4L2_FIELD_NONE; 449 new_buf->vb.field = V4L2_FIELD_NONE;
450 vb2_buffer_done(&new_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 450 vb2_buffer_done(&new_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c
index 238191ddcf35..b860f02a4e55 100644
--- a/drivers/media/dvb-frontends/rtl2832_sdr.c
+++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
@@ -310,7 +310,7 @@ static void rtl2832_sdr_urb_complete(struct urb *urb)
310 len = rtl2832_sdr_convert_stream(dev, ptr, urb->transfer_buffer, 310 len = rtl2832_sdr_convert_stream(dev, ptr, urb->transfer_buffer,
311 urb->actual_length); 311 urb->actual_length);
312 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0, len); 312 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0, len);
313 v4l2_get_timestamp(&fbuf->vb.timestamp); 313 fbuf->vb.vb2_buf.timestamp = ktime_get_ns();
314 fbuf->vb.sequence = dev->sequence++; 314 fbuf->vb.sequence = dev->sequence++;
315 vb2_buffer_done(&fbuf->vb.vb2_buf, VB2_BUF_STATE_DONE); 315 vb2_buffer_done(&fbuf->vb.vb2_buf, VB2_BUF_STATE_DONE);
316 } 316 }
diff --git a/drivers/media/pci/cobalt/cobalt-irq.c b/drivers/media/pci/cobalt/cobalt-irq.c
index c30748e76164..b190d4f81c6e 100644
--- a/drivers/media/pci/cobalt/cobalt-irq.c
+++ b/drivers/media/pci/cobalt/cobalt-irq.c
@@ -134,7 +134,7 @@ done:
134 skip = true; 134 skip = true;
135 s->skip_first_frames--; 135 s->skip_first_frames--;
136 } 136 }
137 v4l2_get_timestamp(&cb->vb.timestamp); 137 cb->vb.vb2_buf.timestamp = ktime_get_ns();
138 /* TODO: the sequence number should be read from the FPGA so we 138 /* TODO: the sequence number should be read from the FPGA so we
139 also know about dropped frames. */ 139 also know about dropped frames. */
140 cb->vb.sequence = s->sequence++; 140 cb->vb.sequence = s->sequence++;
diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c
index 722781babccd..813c217b5e1a 100644
--- a/drivers/media/pci/cx23885/cx23885-core.c
+++ b/drivers/media/pci/cx23885/cx23885-core.c
@@ -427,7 +427,7 @@ static void cx23885_wakeup(struct cx23885_tsport *port,
427 buf = list_entry(q->active.next, 427 buf = list_entry(q->active.next,
428 struct cx23885_buffer, queue); 428 struct cx23885_buffer, queue);
429 429
430 v4l2_get_timestamp(&buf->vb.timestamp); 430 buf->vb.vb2_buf.timestamp = ktime_get_ns();
431 buf->vb.sequence = q->count++; 431 buf->vb.sequence = q->count++;
432 dprintk(1, "[%p/%d] wakeup reg=%d buf=%d\n", buf, 432 dprintk(1, "[%p/%d] wakeup reg=%d buf=%d\n", buf,
433 buf->vb.vb2_buf.index, 433 buf->vb.vb2_buf.index,
diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c
index 93a3720d9116..e1d7d0847167 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -105,7 +105,7 @@ void cx23885_video_wakeup(struct cx23885_dev *dev,
105 struct cx23885_buffer, queue); 105 struct cx23885_buffer, queue);
106 106
107 buf->vb.sequence = q->count++; 107 buf->vb.sequence = q->count++;
108 v4l2_get_timestamp(&buf->vb.timestamp); 108 buf->vb.vb2_buf.timestamp = ktime_get_ns();
109 dprintk(2, "[%p/%d] wakeup reg=%d buf=%d\n", buf, 109 dprintk(2, "[%p/%d] wakeup reg=%d buf=%d\n", buf,
110 buf->vb.vb2_buf.index, count, q->count); 110 buf->vb.vb2_buf.index, count, q->count);
111 list_del(&buf->queue); 111 list_del(&buf->queue);
diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c
index 644373dd2525..c48bba9daf1f 100644
--- a/drivers/media/pci/cx25821/cx25821-video.c
+++ b/drivers/media/pci/cx25821/cx25821-video.c
@@ -130,7 +130,7 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status)
130 buf = list_entry(dmaq->active.next, 130 buf = list_entry(dmaq->active.next,
131 struct cx25821_buffer, queue); 131 struct cx25821_buffer, queue);
132 132
133 v4l2_get_timestamp(&buf->vb.timestamp); 133 buf->vb.vb2_buf.timestamp = ktime_get_ns();
134 buf->vb.sequence = dmaq->count++; 134 buf->vb.sequence = dmaq->count++;
135 list_del(&buf->queue); 135 list_del(&buf->queue);
136 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 136 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/pci/cx88/cx88-core.c b/drivers/media/pci/cx88/cx88-core.c
index 9a43c7826b60..46fe8c1eb9d4 100644
--- a/drivers/media/pci/cx88/cx88-core.c
+++ b/drivers/media/pci/cx88/cx88-core.c
@@ -518,7 +518,7 @@ void cx88_wakeup(struct cx88_core *core,
518 518
519 buf = list_entry(q->active.next, 519 buf = list_entry(q->active.next,
520 struct cx88_buffer, list); 520 struct cx88_buffer, list);
521 v4l2_get_timestamp(&buf->vb.timestamp); 521 buf->vb.vb2_buf.timestamp = ktime_get_ns();
522 buf->vb.field = core->field; 522 buf->vb.field = core->field;
523 buf->vb.sequence = q->count++; 523 buf->vb.sequence = q->count++;
524 list_del(&buf->list); 524 list_del(&buf->list);
diff --git a/drivers/media/pci/dt3155/dt3155.c b/drivers/media/pci/dt3155/dt3155.c
index f09bd73bd16f..568c0c8fb2dc 100644
--- a/drivers/media/pci/dt3155/dt3155.c
+++ b/drivers/media/pci/dt3155/dt3155.c
@@ -270,7 +270,7 @@ static irqreturn_t dt3155_irq_handler_even(int irq, void *dev_id)
270 270
271 spin_lock(&ipd->lock); 271 spin_lock(&ipd->lock);
272 if (ipd->curr_buf && !list_empty(&ipd->dmaq)) { 272 if (ipd->curr_buf && !list_empty(&ipd->dmaq)) {
273 v4l2_get_timestamp(&ipd->curr_buf->timestamp); 273 ipd->curr_buf->vb2_buf.timestamp = ktime_get_ns();
274 ipd->curr_buf->sequence = ipd->sequence++; 274 ipd->curr_buf->sequence = ipd->sequence++;
275 ipd->curr_buf->field = V4L2_FIELD_NONE; 275 ipd->curr_buf->field = V4L2_FIELD_NONE;
276 vb2_buffer_done(&ipd->curr_buf->vb2_buf, VB2_BUF_STATE_DONE); 276 vb2_buffer_done(&ipd->curr_buf->vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
index 58a8e9db5748..81e1a5e26efb 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
@@ -579,7 +579,7 @@ static void netup_unidvb_dma_worker(struct work_struct *work)
579 dev_dbg(&ndev->pci_dev->dev, 579 dev_dbg(&ndev->pci_dev->dev,
580 "%s(): buffer %p done, size %d\n", 580 "%s(): buffer %p done, size %d\n",
581 __func__, buf, buf->size); 581 __func__, buf, buf->size);
582 v4l2_get_timestamp(&buf->vb.timestamp); 582 buf->vb.vb2_buf.timestamp = ktime_get_ns();
583 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->size); 583 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->size);
584 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 584 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
585 } 585 }
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index f720cea80e28..e227b02cc122 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -309,7 +309,7 @@ void saa7134_buffer_finish(struct saa7134_dev *dev,
309 core_dbg("buffer_finish %p\n", q->curr); 309 core_dbg("buffer_finish %p\n", q->curr);
310 310
311 /* finish current buffer */ 311 /* finish current buffer */
312 v4l2_get_timestamp(&q->curr->vb2.timestamp); 312 q->curr->vb2.vb2_buf.timestamp = ktime_get_ns();
313 q->curr->vb2.sequence = q->seq_nr++; 313 q->curr->vb2.sequence = q->seq_nr++;
314 vb2_buffer_done(&q->curr->vb2.vb2_buf, state); 314 vb2_buffer_done(&q->curr->vb2.vb2_buf, state);
315 q->curr = NULL; 315 q->curr = NULL;
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
index 5b7853b75d2a..67a14c41c227 100644
--- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
@@ -531,7 +531,7 @@ static int solo_enc_fillbuf(struct solo_enc_dev *solo_enc,
531 531
532 if (!ret) { 532 if (!ret) {
533 vbuf->sequence = solo_enc->sequence++; 533 vbuf->sequence = solo_enc->sequence++;
534 v4l2_get_timestamp(&vbuf->timestamp); 534 vb->timestamp = ktime_get_ns();
535 535
536 /* Check for motion flags */ 536 /* Check for motion flags */
537 if (solo_is_motion_on(solo_enc) && enc_buf->motion) { 537 if (solo_is_motion_on(solo_enc) && enc_buf->motion) {
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2.c b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
index 212d15efc26b..721ff5320de7 100644
--- a/drivers/media/pci/solo6x10/solo6x10-v4l2.c
+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
@@ -225,7 +225,7 @@ finish_buf:
225 vb2_set_plane_payload(vb, 0, 225 vb2_set_plane_payload(vb, 0,
226 solo_vlines(solo_dev) * solo_bytesperline(solo_dev)); 226 solo_vlines(solo_dev) * solo_bytesperline(solo_dev));
227 vbuf->sequence = solo_dev->sequence++; 227 vbuf->sequence = solo_dev->sequence++;
228 v4l2_get_timestamp(&vbuf->timestamp); 228 vb->timestamp = ktime_get_ns();
229 } 229 }
230 230
231 vb2_buffer_done(vb, error ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); 231 vb2_buffer_done(vb, error ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
index b8b06fb7bec2..753411cbbc9a 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -817,7 +817,7 @@ static irqreturn_t vip_irq(int irq, struct sta2x11_vip *vip)
817 /* Disable acquisition */ 817 /* Disable acquisition */
818 reg_write(vip, DVP_CTL, reg_read(vip, DVP_CTL) & ~DVP_CTL_ENA); 818 reg_write(vip, DVP_CTL, reg_read(vip, DVP_CTL) & ~DVP_CTL_ENA);
819 /* Remove the active buffer from the list */ 819 /* Remove the active buffer from the list */
820 v4l2_get_timestamp(&vip->active->vb.timestamp); 820 vip->active->vb.vb2_buf.timestamp = ktime_get_ns();
821 vip->active->vb.sequence = vip->sequence++; 821 vip->active->vb.sequence = vip->sequence++;
822 vb2_buffer_done(&vip->active->vb.vb2_buf, VB2_BUF_STATE_DONE); 822 vb2_buffer_done(&vip->active->vb.vb2_buf, VB2_BUF_STATE_DONE);
823 } 823 }
diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
index 2e71af15ddb0..07116a87a57b 100644
--- a/drivers/media/pci/tw68/tw68-video.c
+++ b/drivers/media/pci/tw68/tw68-video.c
@@ -1016,7 +1016,7 @@ void tw68_irq_video_done(struct tw68_dev *dev, unsigned long status)
1016 buf = list_entry(dev->active.next, struct tw68_buf, list); 1016 buf = list_entry(dev->active.next, struct tw68_buf, list);
1017 list_del(&buf->list); 1017 list_del(&buf->list);
1018 spin_unlock(&dev->slock); 1018 spin_unlock(&dev->slock);
1019 v4l2_get_timestamp(&buf->vb.timestamp); 1019 buf->vb.vb2_buf.timestamp = ktime_get_ns();
1020 buf->vb.field = dev->field; 1020 buf->vb.field = dev->field;
1021 buf->vb.sequence = dev->seqnr++; 1021 buf->vb.sequence = dev->seqnr++;
1022 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 1022 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
index e434c8ef5c5e..de32e3a3d4d1 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -1281,7 +1281,7 @@ static inline void vpfe_schedule_bottom_field(struct vpfe_device *vpfe)
1281 */ 1281 */
1282static inline void vpfe_process_buffer_complete(struct vpfe_device *vpfe) 1282static inline void vpfe_process_buffer_complete(struct vpfe_device *vpfe)
1283{ 1283{
1284 v4l2_get_timestamp(&vpfe->cur_frm->vb.timestamp); 1284 vpfe->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
1285 vpfe->cur_frm->vb.field = vpfe->fmt.fmt.pix.field; 1285 vpfe->cur_frm->vb.field = vpfe->fmt.fmt.pix.field;
1286 vpfe->cur_frm->vb.sequence = vpfe->sequence++; 1286 vpfe->cur_frm->vb.sequence = vpfe->sequence++;
1287 vb2_buffer_done(&vpfe->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE); 1287 vb2_buffer_done(&vpfe->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c
index 8ecc05a8e5ae..d0092dae7a57 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -404,7 +404,7 @@ static irqreturn_t bcap_isr(int irq, void *dev_id)
404 spin_lock(&bcap_dev->lock); 404 spin_lock(&bcap_dev->lock);
405 405
406 if (!list_empty(&bcap_dev->dma_queue)) { 406 if (!list_empty(&bcap_dev->dma_queue)) {
407 v4l2_get_timestamp(&vbuf->timestamp); 407 vb->timestamp = ktime_get_ns();
408 if (ppi->err) { 408 if (ppi->err) {
409 vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); 409 vb2_buffer_done(vb, VB2_BUF_STATE_ERROR);
410 ppi->err = false; 410 ppi->err = false;
diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index 654e964f84a2..21beb97974c2 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -279,7 +279,7 @@ void coda_fill_bitstream(struct coda_ctx *ctx, bool streaming)
279 if (meta) { 279 if (meta) {
280 meta->sequence = src_buf->sequence; 280 meta->sequence = src_buf->sequence;
281 meta->timecode = src_buf->timecode; 281 meta->timecode = src_buf->timecode;
282 meta->timestamp = src_buf->timestamp; 282 meta->timestamp = src_buf->vb2_buf.timestamp;
283 meta->start = start; 283 meta->start = start;
284 meta->end = ctx->bitstream_fifo.kfifo.in & 284 meta->end = ctx->bitstream_fifo.kfifo.in &
285 ctx->bitstream_fifo.kfifo.mask; 285 ctx->bitstream_fifo.kfifo.mask;
@@ -1364,7 +1364,7 @@ static void coda_finish_encode(struct coda_ctx *ctx)
1364 dst_buf->flags &= ~V4L2_BUF_FLAG_KEYFRAME; 1364 dst_buf->flags &= ~V4L2_BUF_FLAG_KEYFRAME;
1365 } 1365 }
1366 1366
1367 dst_buf->timestamp = src_buf->timestamp; 1367 dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
1368 dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 1368 dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1369 dst_buf->flags |= 1369 dst_buf->flags |=
1370 src_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 1370 src_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
@@ -2040,7 +2040,7 @@ static void coda_finish_decode(struct coda_ctx *ctx)
2040 dst_buf->flags |= ctx->frame_types[ctx->display_idx]; 2040 dst_buf->flags |= ctx->frame_types[ctx->display_idx];
2041 meta = &ctx->frame_metas[ctx->display_idx]; 2041 meta = &ctx->frame_metas[ctx->display_idx];
2042 dst_buf->timecode = meta->timecode; 2042 dst_buf->timecode = meta->timecode;
2043 dst_buf->timestamp = meta->timestamp; 2043 dst_buf->vb2_buf.timestamp = meta->timestamp;
2044 2044
2045 trace_coda_dec_rot_done(ctx, dst_buf, meta); 2045 trace_coda_dec_rot_done(ctx, dst_buf, meta);
2046 2046
diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h
index 96532b06bd9e..6cda81e4163a 100644
--- a/drivers/media/platform/coda/coda.h
+++ b/drivers/media/platform/coda/coda.h
@@ -138,7 +138,7 @@ struct coda_buffer_meta {
138 struct list_head list; 138 struct list_head list;
139 u32 sequence; 139 u32 sequence;
140 struct v4l2_timecode timecode; 140 struct v4l2_timecode timecode;
141 struct timeval timestamp; 141 u64 timestamp;
142 u32 start; 142 u32 start;
143 u32 end; 143 u32 end;
144}; 144};
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index 3fc21766d3a8..0abcdfe97a6c 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -74,7 +74,7 @@ static void vpbe_isr_even_field(struct vpbe_display *disp_obj,
74 if (layer->cur_frm == layer->next_frm) 74 if (layer->cur_frm == layer->next_frm)
75 return; 75 return;
76 76
77 v4l2_get_timestamp(&layer->cur_frm->vb.timestamp); 77 layer->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
78 vb2_buffer_done(&layer->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE); 78 vb2_buffer_done(&layer->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
79 /* Make cur_frm pointing to next_frm */ 79 /* Make cur_frm pointing to next_frm */
80 layer->cur_frm = layer->next_frm; 80 layer->cur_frm = layer->next_frm;
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index fad5b383706f..08f7028c7560 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -330,7 +330,7 @@ static struct vb2_ops video_qops = {
330 */ 330 */
331static void vpif_process_buffer_complete(struct common_obj *common) 331static void vpif_process_buffer_complete(struct common_obj *common)
332{ 332{
333 v4l2_get_timestamp(&common->cur_frm->vb.timestamp); 333 common->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
334 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE); 334 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
335 /* Make curFrm pointing to nextFrm */ 335 /* Make curFrm pointing to nextFrm */
336 common->cur_frm = common->next_frm; 336 common->cur_frm = common->next_frm;
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 534b50ace3a3..f40755cf1bf2 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -331,7 +331,7 @@ static void process_interlaced_mode(int fid, struct common_obj *common)
331 /* one frame is displayed If next frame is 331 /* one frame is displayed If next frame is
332 * available, release cur_frm and move on */ 332 * available, release cur_frm and move on */
333 /* Copy frame display time */ 333 /* Copy frame display time */
334 v4l2_get_timestamp(&common->cur_frm->vb.timestamp); 334 common->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
335 /* Change status of the cur_frm */ 335 /* Change status of the cur_frm */
336 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, 336 vb2_buffer_done(&common->cur_frm->vb.vb2_buf,
337 VB2_BUF_STATE_DONE); 337 VB2_BUF_STATE_DONE);
@@ -387,8 +387,8 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
387 if (!channel_first_int[i][channel_id]) { 387 if (!channel_first_int[i][channel_id]) {
388 /* Mark status of the cur_frm to 388 /* Mark status of the cur_frm to
389 * done and unlock semaphore on it */ 389 * done and unlock semaphore on it */
390 v4l2_get_timestamp( 390 common->cur_frm->vb.vb2_buf.timestamp =
391 &common->cur_frm->vb.timestamp); 391 ktime_get_ns();
392 vb2_buffer_done(&common->cur_frm->vb.vb2_buf, 392 vb2_buffer_done(&common->cur_frm->vb.vb2_buf,
393 VB2_BUF_STATE_DONE); 393 VB2_BUF_STATE_DONE);
394 /* Make cur_frm pointing to next_frm */ 394 /* Make cur_frm pointing to next_frm */
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index ea9230ef35e3..93782f15b825 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -86,7 +86,7 @@ void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
86 dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); 86 dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
87 87
88 if (src_vb && dst_vb) { 88 if (src_vb && dst_vb) {
89 dst_vb->timestamp = src_vb->timestamp; 89 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
90 dst_vb->timecode = src_vb->timecode; 90 dst_vb->timecode = src_vb->timecode;
91 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 91 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
92 dst_vb->flags |= 92 dst_vb->flags |=
@@ -125,7 +125,7 @@ static int gsc_get_bufs(struct gsc_ctx *ctx)
125 if (ret) 125 if (ret)
126 return ret; 126 return ret;
127 127
128 dst_vb->timestamp = src_vb->timestamp; 128 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
129 129
130 return 0; 130 return 0;
131} 131}
diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c
index beadccb8abd7..0d549a6c8a13 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -193,7 +193,7 @@ void fimc_capture_irq_handler(struct fimc_dev *fimc, int deq_buf)
193 test_bit(ST_CAPT_RUN, &fimc->state) && deq_buf) { 193 test_bit(ST_CAPT_RUN, &fimc->state) && deq_buf) {
194 v_buf = fimc_active_queue_pop(cap); 194 v_buf = fimc_active_queue_pop(cap);
195 195
196 v4l2_get_timestamp(&v_buf->vb.timestamp); 196 v_buf->vb.vb2_buf.timestamp = ktime_get_ns();
197 v_buf->vb.sequence = cap->frame_count++; 197 v_buf->vb.sequence = cap->frame_count++;
198 198
199 vb2_buffer_done(&v_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 199 vb2_buffer_done(&v_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c
index 273e7a5c7256..0dd22ec66694 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
@@ -251,7 +251,7 @@ void fimc_isp_video_irq_handler(struct fimc_is *is)
251 buf_index = (is->i2h_cmd.args[1] - 1) % video->buf_count; 251 buf_index = (is->i2h_cmd.args[1] - 1) % video->buf_count;
252 vbuf = &video->buffers[buf_index]->vb; 252 vbuf = &video->buffers[buf_index]->vb;
253 253
254 v4l2_get_timestamp(&vbuf->timestamp); 254 vbuf->vb2_buf.timestamp = ktime_get_ns();
255 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE); 255 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE);
256 256
257 video->buf_mask &= ~BIT(buf_index); 257 video->buf_mask &= ~BIT(buf_index);
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index 15d6fc983951..639ee710499e 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -292,7 +292,7 @@ static irqreturn_t flite_irq_handler(int irq, void *priv)
292 test_bit(ST_FLITE_RUN, &fimc->state) && 292 test_bit(ST_FLITE_RUN, &fimc->state) &&
293 !list_empty(&fimc->active_buf_q)) { 293 !list_empty(&fimc->active_buf_q)) {
294 vbuf = fimc_lite_active_queue_pop(fimc); 294 vbuf = fimc_lite_active_queue_pop(fimc);
295 v4l2_get_timestamp(&vbuf->vb.timestamp); 295 vbuf->vb.vb2_buf.timestamp = ktime_get_ns();
296 vbuf->vb.sequence = fimc->frame_count++; 296 vbuf->vb.sequence = fimc->frame_count++;
297 flite_hw_mask_dma_buffer(fimc, vbuf->index); 297 flite_hw_mask_dma_buffer(fimc, vbuf->index);
298 vb2_buffer_done(&vbuf->vb.vb2_buf, VB2_BUF_STATE_DONE); 298 vb2_buffer_done(&vbuf->vb.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c
index 4c04b5964624..5aa857c7b631 100644
--- a/drivers/media/platform/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
@@ -132,7 +132,7 @@ static void fimc_device_run(void *priv)
132 if (ret) 132 if (ret)
133 goto dma_unlock; 133 goto dma_unlock;
134 134
135 dst_vb->timestamp = src_vb->timestamp; 135 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
136 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 136 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
137 dst_vb->flags |= 137 dst_vb->flags |=
138 src_vb->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 138 src_vb->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index 652eebdbcd8e..7383818c2be6 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -207,7 +207,7 @@ static void dma_callback(void *data)
207 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx); 207 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
208 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx); 208 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
209 209
210 dst_vb->timestamp = src_vb->timestamp; 210 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
211 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 211 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
212 dst_vb->flags |= 212 dst_vb->flags |=
213 src_vb->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 213 src_vb->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 7080a88b6a95..9b878deb1437 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -226,7 +226,7 @@ static void mcam_buffer_done(struct mcam_camera *cam, int frame,
226 vbuf->vb2_buf.planes[0].bytesused = cam->pix_format.sizeimage; 226 vbuf->vb2_buf.planes[0].bytesused = cam->pix_format.sizeimage;
227 vbuf->sequence = cam->buf_seq[frame]; 227 vbuf->sequence = cam->buf_seq[frame];
228 vbuf->field = V4L2_FIELD_NONE; 228 vbuf->field = V4L2_FIELD_NONE;
229 v4l2_get_timestamp(&vbuf->timestamp); 229 vbuf->vb2_buf.timestamp = ktime_get_ns();
230 vb2_set_plane_payload(&vbuf->vb2_buf, 0, cam->pix_format.sizeimage); 230 vb2_set_plane_payload(&vbuf->vb2_buf, 0, cam->pix_format.sizeimage);
231 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE); 231 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE);
232} 232}
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index cb7d4b518318..3c4012d42d69 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -375,7 +375,7 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
375 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx); 375 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
376 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx); 376 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
377 377
378 dst_vb->timestamp = src_vb->timestamp; 378 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
379 dst_vb->flags &= 379 dst_vb->flags &=
380 ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 380 ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
381 dst_vb->flags |= 381 dst_vb->flags |=
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index 9cc4878f784f..ecadca3e945b 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -466,7 +466,7 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
466 list_del(&buf->irqlist); 466 list_del(&buf->irqlist);
467 spin_unlock_irqrestore(&video->irqlock, flags); 467 spin_unlock_irqrestore(&video->irqlock, flags);
468 468
469 v4l2_get_timestamp(&buf->vb.timestamp); 469 buf->vb.vb2_buf.timestamp = ktime_get_ns();
470 470
471 /* Do frame number propagation only if this is the output video node. 471 /* Do frame number propagation only if this is the output video node.
472 * Frame number either comes from the CSI receivers or it gets 472 * Frame number either comes from the CSI receivers or it gets
diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c
index 742f13ee67a9..485f5259acb0 100644
--- a/drivers/media/platform/rcar_jpu.c
+++ b/drivers/media/platform/rcar_jpu.c
@@ -1565,7 +1565,7 @@ static irqreturn_t jpu_irq_handler(int irq, void *dev_id)
1565 } 1565 }
1566 1566
1567 dst_buf->field = src_buf->field; 1567 dst_buf->field = src_buf->field;
1568 dst_buf->timestamp = src_buf->timestamp; 1568 dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
1569 if (src_buf->flags & V4L2_BUF_FLAG_TIMECODE) 1569 if (src_buf->flags & V4L2_BUF_FLAG_TIMECODE)
1570 dst_buf->timecode = src_buf->timecode; 1570 dst_buf->timecode = src_buf->timecode;
1571 dst_buf->flags = src_buf->flags & 1571 dst_buf->flags = src_buf->flags &
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
index 68e651295ded..ec3abbed87d9 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -338,7 +338,7 @@ irqreturn_t s3c_camif_irq_handler(int irq, void *priv)
338 338
339 if (!WARN_ON(vbuf == NULL)) { 339 if (!WARN_ON(vbuf == NULL)) {
340 /* Dequeue a filled buffer */ 340 /* Dequeue a filled buffer */
341 v4l2_get_timestamp(&vbuf->vb.timestamp); 341 vbuf->vb.vb2_buf.timestamp = ktime_get_ns();
342 vbuf->vb.sequence = vp->frame_sequence++; 342 vbuf->vb.sequence = vp->frame_sequence++;
343 vb2_buffer_done(&vbuf->vb.vb2_buf, VB2_BUF_STATE_DONE); 343 vb2_buffer_done(&vbuf->vb.vb2_buf, VB2_BUF_STATE_DONE);
344 344
diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
index 12b4415bc283..74bd46ca7942 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -552,7 +552,7 @@ static irqreturn_t g2d_isr(int irq, void *prv)
552 BUG_ON(dst == NULL); 552 BUG_ON(dst == NULL);
553 553
554 dst->timecode = src->timecode; 554 dst->timecode = src->timecode;
555 dst->timestamp = src->timestamp; 555 dst->vb2_buf.timestamp = src->vb2_buf.timestamp;
556 dst->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 556 dst->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
557 dst->flags |= 557 dst->flags |=
558 src->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 558 src->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 30440b0609af..c3b13a630edf 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -2620,7 +2620,7 @@ static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id)
2620 } 2620 }
2621 2621
2622 dst_buf->timecode = src_buf->timecode; 2622 dst_buf->timecode = src_buf->timecode;
2623 dst_buf->timestamp = src_buf->timestamp; 2623 dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
2624 dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 2624 dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
2625 dst_buf->flags |= 2625 dst_buf->flags |=
2626 src_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 2626 src_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
@@ -2751,7 +2751,7 @@ static irqreturn_t exynos3250_jpeg_irq(int irq, void *dev_id)
2751 dst_buf = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx); 2751 dst_buf = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);
2752 2752
2753 dst_buf->timecode = src_buf->timecode; 2753 dst_buf->timecode = src_buf->timecode;
2754 dst_buf->timestamp = src_buf->timestamp; 2754 dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
2755 2755
2756 v4l2_m2m_buf_done(src_buf, state); 2756 v4l2_m2m_buf_done(src_buf, state);
2757 if (curr_ctx->mode == S5P_JPEG_ENCODE) 2757 if (curr_ctx->mode == S5P_JPEG_ENCODE)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 3ffe2ecfd5ef..0effb2fa4ea1 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -233,8 +233,8 @@ static void s5p_mfc_handle_frame_copy_time(struct s5p_mfc_ctx *ctx)
233 == dec_y_addr) { 233 == dec_y_addr) {
234 dst_buf->b->timecode = 234 dst_buf->b->timecode =
235 src_buf->b->timecode; 235 src_buf->b->timecode;
236 dst_buf->b->timestamp = 236 dst_buf->b->vb2_buf.timestamp =
237 src_buf->b->timestamp; 237 src_buf->b->vb2_buf.timestamp;
238 dst_buf->b->flags &= 238 dst_buf->b->flags &=
239 ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 239 ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
240 dst_buf->b->flags |= 240 dst_buf->b->flags |=
diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c
index 82c39f305b54..82b5d69b87fa 100644
--- a/drivers/media/platform/sh_veu.c
+++ b/drivers/media/platform/sh_veu.c
@@ -1094,7 +1094,7 @@ static irqreturn_t sh_veu_isr(int irq, void *dev_id)
1094 if (!src || !dst) 1094 if (!src || !dst)
1095 return IRQ_NONE; 1095 return IRQ_NONE;
1096 1096
1097 dst->timestamp = src->timestamp; 1097 dst->vb2_buf.timestamp = src->vb2_buf.timestamp;
1098 dst->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 1098 dst->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1099 dst->flags |= 1099 dst->flags |=
1100 src->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 1100 src->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index fd0524ec1ccc..115740498274 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -1070,7 +1070,7 @@ static irqreturn_t sh_vou_isr(int irq, void *dev_id)
1070 1070
1071 list_del(&vb->list); 1071 list_del(&vb->list);
1072 1072
1073 v4l2_get_timestamp(&vb->vb.timestamp); 1073 vb->vb.vb2_buf.timestamp = ktime_get_ns();
1074 vb->vb.sequence = vou_dev->sequence++; 1074 vb->vb.sequence = vou_dev->sequence++;
1075 vb->vb.field = V4L2_FIELD_INTERLACED; 1075 vb->vb.field = V4L2_FIELD_INTERLACED;
1076 vb2_buffer_done(&vb->vb.vb2_buf, VB2_BUF_STATE_DONE); 1076 vb2_buffer_done(&vb->vb.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
index b78aa0250b2a..c398b285180c 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -214,7 +214,7 @@ static irqreturn_t atmel_isi_handle_streaming(struct atmel_isi *isi)
214 struct frame_buffer *buf = isi->active; 214 struct frame_buffer *buf = isi->active;
215 215
216 list_del_init(&buf->list); 216 list_del_init(&buf->list);
217 v4l2_get_timestamp(&vbuf->timestamp); 217 vbuf->vb2_buf.timestamp = ktime_get_ns();
218 vbuf->sequence = isi->sequence++; 218 vbuf->sequence = isi->sequence++;
219 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE); 219 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE);
220 } 220 }
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c
index 8889b299a742..48dd5b7851b5 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -1345,7 +1345,7 @@ static void mx27_camera_frame_done_emma(struct mx2_camera_dev *pcdev,
1345 vb2_get_plane_payload(vb, 0)); 1345 vb2_get_plane_payload(vb, 0));
1346 1346
1347 list_del_init(&buf->internal.queue); 1347 list_del_init(&buf->internal.queue);
1348 v4l2_get_timestamp(&vbuf->timestamp); 1348 vb->timestamp = ktime_get_ns();
1349 vbuf->sequence = pcdev->frame_count; 1349 vbuf->sequence = pcdev->frame_count;
1350 if (err) 1350 if (err)
1351 vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); 1351 vb2_buffer_done(vb, VB2_BUF_STATE_ERROR);
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c
index bbe01e86a0ca..169ed1150226 100644
--- a/drivers/media/platform/soc_camera/mx3_camera.c
+++ b/drivers/media/platform/soc_camera/mx3_camera.c
@@ -155,7 +155,7 @@ static void mx3_cam_dma_done(void *arg)
155 struct mx3_camera_buffer *buf = to_mx3_vb(vb); 155 struct mx3_camera_buffer *buf = to_mx3_vb(vb);
156 156
157 list_del_init(&buf->queue); 157 list_del_init(&buf->queue);
158 v4l2_get_timestamp(&vb->timestamp); 158 vb->vb2_buf.timestamp = ktime_get_ns();
159 vb->field = mx3_cam->field; 159 vb->field = mx3_cam->field;
160 vb->sequence = mx3_cam->sequence++; 160 vb->sequence = mx3_cam->sequence++;
161 vb2_buffer_done(&vb->vb2_buf, VB2_BUF_STATE_DONE); 161 vb2_buffer_done(&vb->vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index b0043cd209aa..b7fd695b9ed5 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -888,7 +888,7 @@ static irqreturn_t rcar_vin_irq(int irq, void *data)
888 888
889 priv->queue_buf[slot]->field = priv->field; 889 priv->queue_buf[slot]->field = priv->field;
890 priv->queue_buf[slot]->sequence = priv->sequence++; 890 priv->queue_buf[slot]->sequence = priv->sequence++;
891 v4l2_get_timestamp(&priv->queue_buf[slot]->timestamp); 891 priv->queue_buf[slot]->vb2_buf.timestamp = ktime_get_ns();
892 vb2_buffer_done(&priv->queue_buf[slot]->vb2_buf, 892 vb2_buffer_done(&priv->queue_buf[slot]->vb2_buf,
893 VB2_BUF_STATE_DONE); 893 VB2_BUF_STATE_DONE);
894 priv->queue_buf[slot] = NULL; 894 priv->queue_buf[slot] = NULL;
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index 4e9bc04b92cb..90c87f2b4ec0 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -510,7 +510,7 @@ static irqreturn_t sh_mobile_ceu_irq(int irq, void *data)
510 pcdev->active = NULL; 510 pcdev->active = NULL;
511 511
512 ret = sh_mobile_ceu_capture(pcdev); 512 ret = sh_mobile_ceu_capture(pcdev);
513 v4l2_get_timestamp(&vbuf->timestamp); 513 vbuf->vb2_buf.timestamp = ktime_get_ns();
514 if (!ret) { 514 if (!ret) {
515 vbuf->field = pcdev->field; 515 vbuf->field = pcdev->field;
516 vbuf->sequence = pcdev->sequence++; 516 vbuf->sequence = pcdev->sequence++;
diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
index 81871d6ae823..d12a419c044a 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
@@ -191,7 +191,7 @@ static void bdisp_job_finish(struct bdisp_ctx *ctx, int vb_state)
191 dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); 191 dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
192 192
193 if (src_vb && dst_vb) { 193 if (src_vb && dst_vb) {
194 dst_vb->timestamp = src_vb->timestamp; 194 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
195 dst_vb->timecode = src_vb->timecode; 195 dst_vb->timecode = src_vb->timecode;
196 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 196 dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
197 dst_vb->flags |= src_vb->flags & 197 dst_vb->flags |= src_vb->flags &
@@ -297,7 +297,7 @@ static int bdisp_get_bufs(struct bdisp_ctx *ctx)
297 if (ret) 297 if (ret)
298 return ret; 298 return ret;
299 299
300 dst_vb->timestamp = src_vb->timestamp; 300 dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
301 301
302 return 0; 302 return 0;
303} 303}
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index e8ed2652eb07..1fa00c2cf3d7 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -1288,7 +1288,7 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1288 d_vb = ctx->dst_vb; 1288 d_vb = ctx->dst_vb;
1289 1289
1290 d_vb->flags = s_vb->flags; 1290 d_vb->flags = s_vb->flags;
1291 d_vb->timestamp = s_vb->timestamp; 1291 d_vb->vb2_buf.timestamp = s_vb->vb2_buf.timestamp;
1292 1292
1293 if (s_vb->flags & V4L2_BUF_FLAG_TIMECODE) 1293 if (s_vb->flags & V4L2_BUF_FLAG_TIMECODE)
1294 d_vb->timecode = s_vb->timecode; 1294 d_vb->timecode = s_vb->timecode;
diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index 93e1d256b13a..418113c99801 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -235,7 +235,7 @@ static int device_process(struct vim2m_ctx *ctx,
235 out_vb->sequence = 235 out_vb->sequence =
236 get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE)->sequence++; 236 get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE)->sequence++;
237 in_vb->sequence = q_data->sequence++; 237 in_vb->sequence = q_data->sequence++;
238 out_vb->timestamp = in_vb->timestamp; 238 out_vb->vb2_buf.timestamp = in_vb->vb2_buf.timestamp;
239 239
240 if (in_vb->flags & V4L2_BUF_FLAG_TIMECODE) 240 if (in_vb->flags & V4L2_BUF_FLAG_TIMECODE)
241 out_vb->timecode = in_vb->timecode; 241 out_vb->timecode = in_vb->timecode;
diff --git a/drivers/media/platform/vivid/vivid-core.h b/drivers/media/platform/vivid/vivid-core.h
index 8c7a5ba87c90..751c1ba391e9 100644
--- a/drivers/media/platform/vivid/vivid-core.h
+++ b/drivers/media/platform/vivid/vivid-core.h
@@ -286,7 +286,7 @@ struct vivid_dev {
286 bool dqbuf_error; 286 bool dqbuf_error;
287 bool seq_wrap; 287 bool seq_wrap;
288 bool time_wrap; 288 bool time_wrap;
289 __kernel_time_t time_wrap_offset; 289 u64 time_wrap_offset;
290 unsigned perc_dropped_buffers; 290 unsigned perc_dropped_buffers;
291 enum vivid_signal_mode std_signal_mode; 291 enum vivid_signal_mode std_signal_mode;
292 unsigned query_std_last; 292 unsigned query_std_last;
diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c
index 4ab7c4b6aaca..b98089c95ef5 100644
--- a/drivers/media/platform/vivid/vivid-ctrls.c
+++ b/drivers/media/platform/vivid/vivid-ctrls.c
@@ -954,7 +954,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_has_scaler_out = {
954static int vivid_streaming_s_ctrl(struct v4l2_ctrl *ctrl) 954static int vivid_streaming_s_ctrl(struct v4l2_ctrl *ctrl)
955{ 955{
956 struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_streaming); 956 struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_streaming);
957 struct timeval tv; 957 u64 rem;
958 958
959 switch (ctrl->id) { 959 switch (ctrl->id) {
960 case VIVID_CID_DQBUF_ERROR: 960 case VIVID_CID_DQBUF_ERROR:
@@ -993,8 +993,16 @@ static int vivid_streaming_s_ctrl(struct v4l2_ctrl *ctrl)
993 dev->time_wrap_offset = 0; 993 dev->time_wrap_offset = 0;
994 break; 994 break;
995 } 995 }
996 v4l2_get_timestamp(&tv); 996 /*
997 dev->time_wrap_offset = -tv.tv_sec - 16; 997 * We want to set the time 16 seconds before the 32 bit tv_sec
998 * value of struct timeval would wrap around. So first we
999 * calculate ktime_get_ns() % ((1 << 32) * NSEC_PER_SEC), and
1000 * then we set the offset to ((1 << 32) - 16) * NSEC_PER_SEC).
1001 */
1002 div64_u64_rem(ktime_get_ns(),
1003 0x100000000ULL * NSEC_PER_SEC, &rem);
1004 dev->time_wrap_offset =
1005 (0x100000000ULL - 16) * NSEC_PER_SEC - rem;
998 break; 1006 break;
999 } 1007 }
1000 return 0; 1008 return 0;
diff --git a/drivers/media/platform/vivid/vivid-kthread-cap.c b/drivers/media/platform/vivid/vivid-kthread-cap.c
index 83cc6d3b4784..9034281944a4 100644
--- a/drivers/media/platform/vivid/vivid-kthread-cap.c
+++ b/drivers/media/platform/vivid/vivid-kthread-cap.c
@@ -441,7 +441,7 @@ static void vivid_fillbuff(struct vivid_dev *dev, struct vivid_buffer *buf)
441 * "Start of Exposure". 441 * "Start of Exposure".
442 */ 442 */
443 if (dev->tstamp_src_is_soe) 443 if (dev->tstamp_src_is_soe)
444 v4l2_get_timestamp(&buf->vb.timestamp); 444 buf->vb.vb2_buf.timestamp = ktime_get_ns();
445 if (dev->field_cap == V4L2_FIELD_ALTERNATE) { 445 if (dev->field_cap == V4L2_FIELD_ALTERNATE) {
446 /* 446 /*
447 * 60 Hz standards start with the bottom field, 50 Hz standards 447 * 60 Hz standards start with the bottom field, 50 Hz standards
@@ -558,8 +558,8 @@ static void vivid_fillbuff(struct vivid_dev *dev, struct vivid_buffer *buf)
558 * the timestamp now. 558 * the timestamp now.
559 */ 559 */
560 if (!dev->tstamp_src_is_soe) 560 if (!dev->tstamp_src_is_soe)
561 v4l2_get_timestamp(&buf->vb.timestamp); 561 buf->vb.vb2_buf.timestamp = ktime_get_ns();
562 buf->vb.timestamp.tv_sec += dev->time_wrap_offset; 562 buf->vb.vb2_buf.timestamp += dev->time_wrap_offset;
563} 563}
564 564
565/* 565/*
diff --git a/drivers/media/platform/vivid/vivid-kthread-out.c b/drivers/media/platform/vivid/vivid-kthread-out.c
index c2c46dcdbe95..98eed5889bc1 100644
--- a/drivers/media/platform/vivid/vivid-kthread-out.c
+++ b/drivers/media/platform/vivid/vivid-kthread-out.c
@@ -95,8 +95,8 @@ static void vivid_thread_vid_out_tick(struct vivid_dev *dev)
95 */ 95 */
96 vid_out_buf->vb.sequence /= 2; 96 vid_out_buf->vb.sequence /= 2;
97 } 97 }
98 v4l2_get_timestamp(&vid_out_buf->vb.timestamp); 98 vid_out_buf->vb.vb2_buf.timestamp =
99 vid_out_buf->vb.timestamp.tv_sec += dev->time_wrap_offset; 99 ktime_get_ns() + dev->time_wrap_offset;
100 vb2_buffer_done(&vid_out_buf->vb.vb2_buf, dev->dqbuf_error ? 100 vb2_buffer_done(&vid_out_buf->vb.vb2_buf, dev->dqbuf_error ?
101 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); 101 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
102 dprintk(dev, 2, "vid_out buffer %d done\n", 102 dprintk(dev, 2, "vid_out buffer %d done\n",
@@ -108,8 +108,8 @@ static void vivid_thread_vid_out_tick(struct vivid_dev *dev)
108 vivid_sliced_vbi_out_process(dev, vbi_out_buf); 108 vivid_sliced_vbi_out_process(dev, vbi_out_buf);
109 109
110 vbi_out_buf->vb.sequence = dev->vbi_out_seq_count; 110 vbi_out_buf->vb.sequence = dev->vbi_out_seq_count;
111 v4l2_get_timestamp(&vbi_out_buf->vb.timestamp); 111 vbi_out_buf->vb.vb2_buf.timestamp =
112 vbi_out_buf->vb.timestamp.tv_sec += dev->time_wrap_offset; 112 ktime_get_ns() + dev->time_wrap_offset;
113 vb2_buffer_done(&vbi_out_buf->vb.vb2_buf, dev->dqbuf_error ? 113 vb2_buffer_done(&vbi_out_buf->vb.vb2_buf, dev->dqbuf_error ?
114 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); 114 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
115 dprintk(dev, 2, "vbi_out buffer %d done\n", 115 dprintk(dev, 2, "vbi_out buffer %d done\n",
diff --git a/drivers/media/platform/vivid/vivid-sdr-cap.c b/drivers/media/platform/vivid/vivid-sdr-cap.c
index 6eeeff9d1ae2..3d1604cb982f 100644
--- a/drivers/media/platform/vivid/vivid-sdr-cap.c
+++ b/drivers/media/platform/vivid/vivid-sdr-cap.c
@@ -117,8 +117,8 @@ static void vivid_thread_sdr_cap_tick(struct vivid_dev *dev)
117 if (sdr_cap_buf) { 117 if (sdr_cap_buf) {
118 sdr_cap_buf->vb.sequence = dev->sdr_cap_seq_count; 118 sdr_cap_buf->vb.sequence = dev->sdr_cap_seq_count;
119 vivid_sdr_cap_process(dev, sdr_cap_buf); 119 vivid_sdr_cap_process(dev, sdr_cap_buf);
120 v4l2_get_timestamp(&sdr_cap_buf->vb.timestamp); 120 sdr_cap_buf->vb.vb2_buf.timestamp =
121 sdr_cap_buf->vb.timestamp.tv_sec += dev->time_wrap_offset; 121 ktime_get_ns() + dev->time_wrap_offset;
122 vb2_buffer_done(&sdr_cap_buf->vb.vb2_buf, dev->dqbuf_error ? 122 vb2_buffer_done(&sdr_cap_buf->vb.vb2_buf, dev->dqbuf_error ?
123 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); 123 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
124 dev->dqbuf_error = false; 124 dev->dqbuf_error = false;
diff --git a/drivers/media/platform/vivid/vivid-vbi-cap.c b/drivers/media/platform/vivid/vivid-vbi-cap.c
index d6d12e104aea..cda45a582bfe 100644
--- a/drivers/media/platform/vivid/vivid-vbi-cap.c
+++ b/drivers/media/platform/vivid/vivid-vbi-cap.c
@@ -108,8 +108,7 @@ void vivid_raw_vbi_cap_process(struct vivid_dev *dev, struct vivid_buffer *buf)
108 if (!VIVID_INVALID_SIGNAL(dev->std_signal_mode)) 108 if (!VIVID_INVALID_SIGNAL(dev->std_signal_mode))
109 vivid_vbi_gen_raw(&dev->vbi_gen, &vbi, vbuf); 109 vivid_vbi_gen_raw(&dev->vbi_gen, &vbi, vbuf);
110 110
111 v4l2_get_timestamp(&buf->vb.timestamp); 111 buf->vb.vb2_buf.timestamp = ktime_get_ns() + dev->time_wrap_offset;
112 buf->vb.timestamp.tv_sec += dev->time_wrap_offset;
113} 112}
114 113
115 114
@@ -133,8 +132,7 @@ void vivid_sliced_vbi_cap_process(struct vivid_dev *dev,
133 vbuf[i] = dev->vbi_gen.data[i]; 132 vbuf[i] = dev->vbi_gen.data[i];
134 } 133 }
135 134
136 v4l2_get_timestamp(&buf->vb.timestamp); 135 buf->vb.vb2_buf.timestamp = ktime_get_ns() + dev->time_wrap_offset;
137 buf->vb.timestamp.tv_sec += dev->time_wrap_offset;
138} 136}
139 137
140static int vbi_cap_queue_setup(struct vb2_queue *vq, 138static int vbi_cap_queue_setup(struct vb2_queue *vq,
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index 1eebf58bbecb..45eb65fa23db 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -582,7 +582,7 @@ vsp1_video_complete_buffer(struct vsp1_video *video)
582 spin_unlock_irqrestore(&video->irqlock, flags); 582 spin_unlock_irqrestore(&video->irqlock, flags);
583 583
584 done->buf.sequence = video->sequence++; 584 done->buf.sequence = video->sequence++;
585 v4l2_get_timestamp(&done->buf.timestamp); 585 done->buf.vb2_buf.timestamp = ktime_get_ns();
586 for (i = 0; i < done->buf.vb2_buf.num_planes; ++i) 586 for (i = 0; i < done->buf.vb2_buf.num_planes; ++i)
587 vb2_set_plane_payload(&done->buf.vb2_buf, i, done->length[i]); 587 vb2_set_plane_payload(&done->buf.vb2_buf, i, done->length[i]);
588 vb2_buffer_done(&done->buf.vb2_buf, VB2_BUF_STATE_DONE); 588 vb2_buffer_done(&done->buf.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index 8532cab2ec77..722758f33924 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -303,7 +303,7 @@ static void xvip_dma_complete(void *param)
303 303
304 buf->buf.field = V4L2_FIELD_NONE; 304 buf->buf.field = V4L2_FIELD_NONE;
305 buf->buf.sequence = dma->sequence++; 305 buf->buf.sequence = dma->sequence++;
306 v4l2_get_timestamp(&buf->buf.timestamp); 306 buf->buf.vb2_buf.timestamp = ktime_get_ns();
307 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma->format.sizeimage); 307 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma->format.sizeimage);
308 vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); 308 vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE);
309} 309}
diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c
index 518d511e49ee..b5595ca81189 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -316,7 +316,7 @@ static void airspy_urb_complete(struct urb *urb)
316 len = airspy_convert_stream(s, ptr, urb->transfer_buffer, 316 len = airspy_convert_stream(s, ptr, urb->transfer_buffer,
317 urb->actual_length); 317 urb->actual_length);
318 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0, len); 318 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0, len);
319 v4l2_get_timestamp(&fbuf->vb.timestamp); 319 fbuf->vb.vb2_buf.timestamp = ktime_get_ns();
320 fbuf->vb.sequence = s->sequence++; 320 fbuf->vb.sequence = s->sequence++;
321 vb2_buffer_done(&fbuf->vb.vb2_buf, VB2_BUF_STATE_DONE); 321 vb2_buffer_done(&fbuf->vb.vb2_buf, VB2_BUF_STATE_DONE);
322 } 322 }
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 427d58e6b85e..0a725a161dd6 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -314,7 +314,7 @@ static inline void buffer_filled(struct au0828_dev *dev,
314 vb->sequence = dev->vbi_frame_count++; 314 vb->sequence = dev->vbi_frame_count++;
315 315
316 vb->field = V4L2_FIELD_INTERLACED; 316 vb->field = V4L2_FIELD_INTERLACED;
317 v4l2_get_timestamp(&vb->timestamp); 317 vb->vb2_buf.timestamp = ktime_get_ns();
318 vb2_buffer_done(&vb->vb2_buf, VB2_BUF_STATE_DONE); 318 vb2_buffer_done(&vb->vb2_buf, VB2_BUF_STATE_DONE);
319} 319}
320 320
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 235a03885198..0e86ff423c49 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -438,7 +438,7 @@ static inline void finish_buffer(struct em28xx *dev,
438 buf->vb.field = V4L2_FIELD_NONE; 438 buf->vb.field = V4L2_FIELD_NONE;
439 else 439 else
440 buf->vb.field = V4L2_FIELD_INTERLACED; 440 buf->vb.field = V4L2_FIELD_INTERLACED;
441 v4l2_get_timestamp(&buf->vb.timestamp); 441 buf->vb.vb2_buf.timestamp = ktime_get_ns();
442 442
443 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 443 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
444} 444}
diff --git a/drivers/media/usb/go7007/go7007-driver.c b/drivers/media/usb/go7007/go7007-driver.c
index ae1cfa792c58..05b1126f263e 100644
--- a/drivers/media/usb/go7007/go7007-driver.c
+++ b/drivers/media/usb/go7007/go7007-driver.c
@@ -466,7 +466,7 @@ static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buf
466 else 466 else
467 go7007_set_motion_regions(go, vb, 0); 467 go7007_set_motion_regions(go, vb, 0);
468 468
469 v4l2_get_timestamp(&vb->vb.timestamp); 469 vb->vb.vb2_buf.timestamp = ktime_get_ns();
470 vb_tmp = vb; 470 vb_tmp = vb;
471 spin_lock(&go->spinlock); 471 spin_lock(&go->spinlock);
472 list_del(&vb->list); 472 list_del(&vb->list);
diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c
index d0c416ddd5e7..d7a3aa2029d2 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -517,7 +517,7 @@ static void hackrf_urb_complete_in(struct urb *urb)
517 urb->transfer_buffer, len); 517 urb->transfer_buffer, len);
518 vb2_set_plane_payload(&buffer->vb.vb2_buf, 0, len); 518 vb2_set_plane_payload(&buffer->vb.vb2_buf, 0, len);
519 buffer->vb.sequence = dev->sequence++; 519 buffer->vb.sequence = dev->sequence++;
520 v4l2_get_timestamp(&buffer->vb.timestamp); 520 buffer->vb.vb2_buf.timestamp = ktime_get_ns();
521 vb2_buffer_done(&buffer->vb.vb2_buf, VB2_BUF_STATE_DONE); 521 vb2_buffer_done(&buffer->vb.vb2_buf, VB2_BUF_STATE_DONE);
522exit_usb_submit_urb: 522exit_usb_submit_urb:
523 usb_submit_urb(urb, GFP_ATOMIC); 523 usb_submit_urb(urb, GFP_ATOMIC);
@@ -562,7 +562,7 @@ static void hackrf_urb_complete_out(struct urb *urb)
562 vb2_plane_vaddr(&buffer->vb.vb2_buf, 0), len); 562 vb2_plane_vaddr(&buffer->vb.vb2_buf, 0), len);
563 urb->actual_length = len; 563 urb->actual_length = len;
564 buffer->vb.sequence = dev->sequence++; 564 buffer->vb.sequence = dev->sequence++;
565 v4l2_get_timestamp(&buffer->vb.timestamp); 565 buffer->vb.vb2_buf.timestamp = ktime_get_ns();
566 vb2_buffer_done(&buffer->vb.vb2_buf, VB2_BUF_STATE_DONE); 566 vb2_buffer_done(&buffer->vb.vb2_buf, VB2_BUF_STATE_DONE);
567exit_usb_submit_urb: 567exit_usb_submit_urb:
568 usb_submit_urb(urb, GFP_ATOMIC); 568 usb_submit_urb(urb, GFP_ATOMIC);
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index e90e4946afaf..086cf1c7bd7d 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -316,8 +316,7 @@ static void pwc_isoc_handler(struct urb *urb)
316 struct pwc_frame_buf *fbuf = pdev->fill_buf; 316 struct pwc_frame_buf *fbuf = pdev->fill_buf;
317 317
318 if (pdev->vsync == 1) { 318 if (pdev->vsync == 1) {
319 v4l2_get_timestamp( 319 fbuf->vb.vb2_buf.timestamp = ktime_get_ns();
320 &fbuf->vb.timestamp);
321 pdev->vsync = 2; 320 pdev->vsync = 2;
322 } 321 }
323 322
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 82bdd42f76b5..9acdaa3716fb 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -574,7 +574,7 @@ static void s2255_got_frame(struct s2255_vc *vc, int jpgsize)
574 buf = list_entry(vc->buf_list.next, 574 buf = list_entry(vc->buf_list.next,
575 struct s2255_buffer, list); 575 struct s2255_buffer, list);
576 list_del(&buf->list); 576 list_del(&buf->list);
577 v4l2_get_timestamp(&buf->vb.timestamp); 577 buf->vb.vb2_buf.timestamp = ktime_get_ns();
578 buf->vb.field = vc->field; 578 buf->vb.field = vc->field;
579 buf->vb.sequence = vc->frame_count; 579 buf->vb.sequence = vc->frame_count;
580 spin_unlock_irqrestore(&vc->qlock, flags); 580 spin_unlock_irqrestore(&vc->qlock, flags);
diff --git a/drivers/media/usb/stk1160/stk1160-video.c b/drivers/media/usb/stk1160/stk1160-video.c
index 75654e676e80..46191d5262eb 100644
--- a/drivers/media/usb/stk1160/stk1160-video.c
+++ b/drivers/media/usb/stk1160/stk1160-video.c
@@ -99,7 +99,7 @@ void stk1160_buffer_done(struct stk1160 *dev)
99 buf->vb.sequence = dev->sequence++; 99 buf->vb.sequence = dev->sequence++;
100 buf->vb.field = V4L2_FIELD_INTERLACED; 100 buf->vb.field = V4L2_FIELD_INTERLACED;
101 buf->vb.vb2_buf.planes[0].bytesused = buf->bytesused; 101 buf->vb.vb2_buf.planes[0].bytesused = buf->bytesused;
102 v4l2_get_timestamp(&buf->vb.timestamp); 102 buf->vb.vb2_buf.timestamp = ktime_get_ns();
103 103
104 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->bytesused); 104 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->bytesused);
105 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); 105 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index 05cbd2f4b445..4ebb33943f9a 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -322,7 +322,7 @@ static void usbtv_image_chunk(struct usbtv *usbtv, __be32 *chunk)
322 322
323 buf->vb.field = V4L2_FIELD_INTERLACED; 323 buf->vb.field = V4L2_FIELD_INTERLACED;
324 buf->vb.sequence = usbtv->sequence++; 324 buf->vb.sequence = usbtv->sequence++;
325 v4l2_get_timestamp(&buf->vb.timestamp); 325 buf->vb.vb2_buf.timestamp = ktime_get_ns();
326 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size); 326 vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size);
327 vb2_buffer_done(&buf->vb.vb2_buf, state); 327 vb2_buffer_done(&buf->vb.vb2_buf, state);
328 list_del(&buf->list); 328 list_del(&buf->list);
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 2b276ab7764f..f126859ca848 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -694,19 +694,16 @@ void uvc_video_clock_update(struct uvc_streaming *stream,
694 ts.tv_nsec -= NSEC_PER_SEC; 694 ts.tv_nsec -= NSEC_PER_SEC;
695 } 695 }
696 696
697 uvc_trace(UVC_TRACE_CLOCK, "%s: SOF %u.%06llu y %llu ts %lu.%06lu " 697 uvc_trace(UVC_TRACE_CLOCK, "%s: SOF %u.%06llu y %llu ts %llu "
698 "buf ts %lu.%06lu (x1 %u/%u/%u x2 %u/%u/%u y1 %u y2 %u)\n", 698 "buf ts %llu (x1 %u/%u/%u x2 %u/%u/%u y1 %u y2 %u)\n",
699 stream->dev->name, 699 stream->dev->name,
700 sof >> 16, div_u64(((u64)sof & 0xffff) * 1000000LLU, 65536), 700 sof >> 16, div_u64(((u64)sof & 0xffff) * 1000000LLU, 65536),
701 y, ts.tv_sec, ts.tv_nsec / NSEC_PER_USEC, 701 y, timespec_to_ns(&ts), vbuf->vb2_buf.timestamp,
702 vbuf->timestamp.tv_sec,
703 (unsigned long)vbuf->timestamp.tv_usec,
704 x1, first->host_sof, first->dev_sof, 702 x1, first->host_sof, first->dev_sof,
705 x2, last->host_sof, last->dev_sof, y1, y2); 703 x2, last->host_sof, last->dev_sof, y1, y2);
706 704
707 /* Update the V4L2 buffer. */ 705 /* Update the V4L2 buffer. */
708 vbuf->timestamp.tv_sec = ts.tv_sec; 706 vbuf->vb2_buf.timestamp = timespec_to_ns(&ts);
709 vbuf->timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
710 707
711done: 708done:
712 spin_unlock_irqrestore(&stream->clock.lock, flags); 709 spin_unlock_irqrestore(&stream->clock.lock, flags);
@@ -1034,9 +1031,7 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,
1034 1031
1035 buf->buf.field = V4L2_FIELD_NONE; 1032 buf->buf.field = V4L2_FIELD_NONE;
1036 buf->buf.sequence = stream->sequence; 1033 buf->buf.sequence = stream->sequence;
1037 buf->buf.timestamp.tv_sec = ts.tv_sec; 1034 buf->buf.vb2_buf.timestamp = timespec_to_ns(&ts);
1038 buf->buf.timestamp.tv_usec =
1039 ts.tv_nsec / NSEC_PER_USEC;
1040 1035
1041 /* TODO: Handle PTS and SCR. */ 1036 /* TODO: Handle PTS and SCR. */
1042 buf->state = UVC_BUF_STATE_ACTIVE; 1037 buf->state = UVC_BUF_STATE_ACTIVE;
diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 1b5c695f6c59..bfd7e3474186 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -120,7 +120,7 @@ static int __set_timestamp(struct vb2_buffer *vb, const void *pb)
120 */ 120 */
121 if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) == 121 if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
122 V4L2_BUF_FLAG_TIMESTAMP_COPY) 122 V4L2_BUF_FLAG_TIMESTAMP_COPY)
123 vbuf->timestamp = b->timestamp; 123 vb->timestamp = timeval_to_ns(&b->timestamp);
124 vbuf->flags |= b->flags & V4L2_BUF_FLAG_TIMECODE; 124 vbuf->flags |= b->flags & V4L2_BUF_FLAG_TIMECODE;
125 if (b->flags & V4L2_BUF_FLAG_TIMECODE) 125 if (b->flags & V4L2_BUF_FLAG_TIMECODE)
126 vbuf->timecode = b->timecode; 126 vbuf->timecode = b->timecode;
@@ -191,7 +191,7 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb)
191 191
192 b->flags = vbuf->flags; 192 b->flags = vbuf->flags;
193 b->field = vbuf->field; 193 b->field = vbuf->field;
194 b->timestamp = vbuf->timestamp; 194 b->timestamp = ns_to_timeval(vb->timestamp);
195 b->timecode = vbuf->timecode; 195 b->timecode = vbuf->timecode;
196 b->sequence = vbuf->sequence; 196 b->sequence = vbuf->sequence;
197 b->reserved2 = 0; 197 b->reserved2 = 0;
@@ -308,8 +308,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
308 "for an output buffer\n"); 308 "for an output buffer\n");
309 return -EINVAL; 309 return -EINVAL;
310 } 310 }
311 vbuf->timestamp.tv_sec = 0; 311 vb->timestamp = 0;
312 vbuf->timestamp.tv_usec = 0;
313 vbuf->sequence = 0; 312 vbuf->sequence = 0;
314 313
315 if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { 314 if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 77b4fc6fd2ee..adb2bc8811ab 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -470,7 +470,7 @@ void vpfe_video_process_buffer_complete(struct vpfe_video_device *video)
470{ 470{
471 struct vpfe_pipeline *pipe = &video->pipe; 471 struct vpfe_pipeline *pipe = &video->pipe;
472 472
473 v4l2_get_timestamp(&video->cur_frm->vb.timestamp); 473 video->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
474 vb2_buffer_done(&video->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE); 474 vb2_buffer_done(&video->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
475 if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS) 475 if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS)
476 video->cur_frm = video->next_frm; 476 video->cur_frm = video->next_frm;
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index 17741e37a73c..e9aeca08986f 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -433,7 +433,7 @@ struct iss_buffer *omap4iss_video_buffer_next(struct iss_video *video)
433 list_del(&buf->list); 433 list_del(&buf->list);
434 spin_unlock_irqrestore(&video->qlock, flags); 434 spin_unlock_irqrestore(&video->qlock, flags);
435 435
436 v4l2_get_timestamp(&buf->vb.timestamp); 436 buf->vb.vb2_buf.timestamp = ktime_get_ns();
437 437
438 /* Do frame number propagation only if this is the output video node. 438 /* Do frame number propagation only if this is the output video node.
439 * Frame number either comes from the CSI receivers or it gets 439 * Frame number either comes from the CSI receivers or it gets
diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c
index f5921989873d..912694f3d54e 100644
--- a/drivers/usb/gadget/function/uvc_queue.c
+++ b/drivers/usb/gadget/function/uvc_queue.c
@@ -329,7 +329,7 @@ struct uvc_buffer *uvcg_queue_next_buffer(struct uvc_video_queue *queue,
329 329
330 buf->buf.field = V4L2_FIELD_NONE; 330 buf->buf.field = V4L2_FIELD_NONE;
331 buf->buf.sequence = queue->sequence++; 331 buf->buf.sequence = queue->sequence++;
332 v4l2_get_timestamp(&buf->buf.timestamp); 332 buf->buf.vb2_buf.timestamp = ktime_get_ns();
333 333
334 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, buf->bytesused); 334 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, buf->bytesused);
335 vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); 335 vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE);