Commit 15a40b27 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: videobuf: use u64 for the timestamp internally

Just like vb2 does, use u64 internally to store the timestamps
of the buffers. Only convert to timeval when interfacing with
userspace.
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 63635b54
...@@ -105,7 +105,7 @@ void saa7146_buffer_finish(struct saa7146_dev *dev, ...@@ -105,7 +105,7 @@ void saa7146_buffer_finish(struct saa7146_dev *dev,
} }
q->curr->vb.state = state; q->curr->vb.state = state;
v4l2_get_timestamp(&q->curr->vb.ts); q->curr->vb.ts = ktime_get_ns();
wake_up(&q->curr->vb.done); wake_up(&q->curr->vb.done);
q->curr = NULL; q->curr = NULL;
......
...@@ -3600,9 +3600,7 @@ static void ...@@ -3600,9 +3600,7 @@ static void
bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup, bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup,
struct bttv_buffer_set *curr, unsigned int state) struct bttv_buffer_set *curr, unsigned int state)
{ {
struct timeval ts; u64 ts = ktime_get_ns();
v4l2_get_timestamp(&ts);
if (wakeup->top == wakeup->bottom) { if (wakeup->top == wakeup->bottom) {
if (NULL != wakeup->top && curr->top != wakeup->top) { if (NULL != wakeup->top && curr->top != wakeup->top) {
...@@ -3643,7 +3641,7 @@ bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup, ...@@ -3643,7 +3641,7 @@ bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup,
if (NULL == wakeup) if (NULL == wakeup)
return; return;
v4l2_get_timestamp(&wakeup->vb.ts); wakeup->vb.ts = ktime_get_ns();
wakeup->vb.field_count = btv->field_count; wakeup->vb.field_count = btv->field_count;
wakeup->vb.state = state; wakeup->vb.state = state;
wake_up(&wakeup->vb.done); wake_up(&wakeup->vb.done);
...@@ -3713,7 +3711,7 @@ bttv_irq_wakeup_top(struct bttv *btv) ...@@ -3713,7 +3711,7 @@ bttv_irq_wakeup_top(struct bttv *btv)
btv->curr.top = NULL; btv->curr.top = NULL;
bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0); bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0);
v4l2_get_timestamp(&wakeup->vb.ts); wakeup->vb.ts = ktime_get_ns();
wakeup->vb.field_count = btv->field_count; wakeup->vb.field_count = btv->field_count;
wakeup->vb.state = VIDEOBUF_DONE; wakeup->vb.state = VIDEOBUF_DONE;
wake_up(&wakeup->vb.done); wake_up(&wakeup->vb.done);
......
...@@ -197,7 +197,7 @@ static void cx18_mdl_send_to_videobuf(struct cx18_stream *s, ...@@ -197,7 +197,7 @@ static void cx18_mdl_send_to_videobuf(struct cx18_stream *s,
} }
if (dispatch) { if (dispatch) {
v4l2_get_timestamp(&vb_buf->vb.ts); vb_buf->vb.ts = ktime_get_ns();
list_del(&vb_buf->vb.queue); list_del(&vb_buf->vb.queue);
vb_buf->vb.state = VIDEOBUF_DONE; vb_buf->vb.state = VIDEOBUF_DONE;
wake_up(&vb_buf->vb.done); wake_up(&vb_buf->vb.done);
......
...@@ -518,7 +518,7 @@ static void vpfe_schedule_bottom_field(struct vpfe_device *vpfe_dev) ...@@ -518,7 +518,7 @@ static void vpfe_schedule_bottom_field(struct vpfe_device *vpfe_dev)
static void vpfe_process_buffer_complete(struct vpfe_device *vpfe_dev) static void vpfe_process_buffer_complete(struct vpfe_device *vpfe_dev)
{ {
v4l2_get_timestamp(&vpfe_dev->cur_frm->ts); vpfe_dev->cur_frm->ts = ktime_get_ns();
vpfe_dev->cur_frm->state = VIDEOBUF_DONE; vpfe_dev->cur_frm->state = VIDEOBUF_DONE;
vpfe_dev->cur_frm->size = vpfe_dev->fmt.fmt.pix.sizeimage; vpfe_dev->cur_frm->size = vpfe_dev->fmt.fmt.pix.sizeimage;
wake_up_interruptible(&vpfe_dev->cur_frm->done); wake_up_interruptible(&vpfe_dev->cur_frm->done);
......
...@@ -1090,7 +1090,7 @@ static void viu_capture_intr(struct viu_dev *dev, u32 status) ...@@ -1090,7 +1090,7 @@ static void viu_capture_intr(struct viu_dev *dev, u32 status)
if (waitqueue_active(&buf->vb.done)) { if (waitqueue_active(&buf->vb.done)) {
list_del(&buf->vb.queue); list_del(&buf->vb.queue);
v4l2_get_timestamp(&buf->vb.ts); buf->vb.ts = ktime_get_ns();
buf->vb.state = VIDEOBUF_DONE; buf->vb.state = VIDEOBUF_DONE;
buf->vb.field_count++; buf->vb.field_count++;
wake_up(&buf->vb.done); wake_up(&buf->vb.done);
......
...@@ -513,7 +513,7 @@ static int omapvid_apply_changes(struct omap_vout_device *vout) ...@@ -513,7 +513,7 @@ static int omapvid_apply_changes(struct omap_vout_device *vout)
} }
static int omapvid_handle_interlace_display(struct omap_vout_device *vout, static int omapvid_handle_interlace_display(struct omap_vout_device *vout,
unsigned int irqstatus, struct timeval timevalue) unsigned int irqstatus, u64 ts)
{ {
u32 fid; u32 fid;
...@@ -537,7 +537,7 @@ static int omapvid_handle_interlace_display(struct omap_vout_device *vout, ...@@ -537,7 +537,7 @@ static int omapvid_handle_interlace_display(struct omap_vout_device *vout,
if (vout->cur_frm == vout->next_frm) if (vout->cur_frm == vout->next_frm)
goto err; goto err;
vout->cur_frm->ts = timevalue; vout->cur_frm->ts = ts;
vout->cur_frm->state = VIDEOBUF_DONE; vout->cur_frm->state = VIDEOBUF_DONE;
wake_up_interruptible(&vout->cur_frm->done); wake_up_interruptible(&vout->cur_frm->done);
vout->cur_frm = vout->next_frm; vout->cur_frm = vout->next_frm;
...@@ -557,7 +557,7 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus) ...@@ -557,7 +557,7 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus)
int ret, fid, mgr_id; int ret, fid, mgr_id;
u32 addr, irq; u32 addr, irq;
struct omap_overlay *ovl; struct omap_overlay *ovl;
struct timeval timevalue; u64 ts;
struct omapvideo_info *ovid; struct omapvideo_info *ovid;
struct omap_dss_device *cur_display; struct omap_dss_device *cur_display;
struct omap_vout_device *vout = (struct omap_vout_device *)arg; struct omap_vout_device *vout = (struct omap_vout_device *)arg;
...@@ -577,7 +577,7 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus) ...@@ -577,7 +577,7 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus)
return; return;
spin_lock(&vout->vbq_lock); spin_lock(&vout->vbq_lock);
v4l2_get_timestamp(&timevalue); ts = ktime_get_ns();
switch (cur_display->type) { switch (cur_display->type) {
case OMAP_DISPLAY_TYPE_DSI: case OMAP_DISPLAY_TYPE_DSI:
...@@ -595,7 +595,7 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus) ...@@ -595,7 +595,7 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus)
break; break;
case OMAP_DISPLAY_TYPE_VENC: case OMAP_DISPLAY_TYPE_VENC:
fid = omapvid_handle_interlace_display(vout, irqstatus, fid = omapvid_handle_interlace_display(vout, irqstatus,
timevalue); ts);
if (!fid) if (!fid)
goto vout_isr_err; goto vout_isr_err;
break; break;
...@@ -608,7 +608,7 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus) ...@@ -608,7 +608,7 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus)
} }
if (!vout->first_int && (vout->cur_frm != vout->next_frm)) { if (!vout->first_int && (vout->cur_frm != vout->next_frm)) {
vout->cur_frm->ts = timevalue; vout->cur_frm->ts = ts;
vout->cur_frm->state = VIDEOBUF_DONE; vout->cur_frm->state = VIDEOBUF_DONE;
wake_up_interruptible(&vout->cur_frm->done); wake_up_interruptible(&vout->cur_frm->done);
vout->cur_frm = vout->next_frm; vout->cur_frm = vout->next_frm;
......
...@@ -1316,7 +1316,7 @@ static void buffer_copy(struct cx231xx *dev, char *data, int len, struct urb *ur ...@@ -1316,7 +1316,7 @@ static void buffer_copy(struct cx231xx *dev, char *data, int len, struct urb *ur
buf->vb.state = VIDEOBUF_DONE; buf->vb.state = VIDEOBUF_DONE;
buf->vb.field_count++; buf->vb.field_count++;
v4l2_get_timestamp(&buf->vb.ts); buf->vb.ts = ktime_get_ns();
list_del(&buf->vb.queue); list_del(&buf->vb.queue);
wake_up(&buf->vb.done); wake_up(&buf->vb.done);
dma_q->mpeg_buffer_completed = 0; dma_q->mpeg_buffer_completed = 0;
...@@ -1347,7 +1347,7 @@ static void buffer_filled(char *data, int len, struct urb *urb, ...@@ -1347,7 +1347,7 @@ static void buffer_filled(char *data, int len, struct urb *urb,
memcpy(vbuf, data, len); memcpy(vbuf, data, len);
buf->vb.state = VIDEOBUF_DONE; buf->vb.state = VIDEOBUF_DONE;
buf->vb.field_count++; buf->vb.field_count++;
v4l2_get_timestamp(&buf->vb.ts); buf->vb.ts = ktime_get_ns();
list_del(&buf->vb.queue); list_del(&buf->vb.queue);
wake_up(&buf->vb.done); wake_up(&buf->vb.done);
} }
......
...@@ -528,7 +528,7 @@ static inline void vbi_buffer_filled(struct cx231xx *dev, ...@@ -528,7 +528,7 @@ static inline void vbi_buffer_filled(struct cx231xx *dev,
buf->vb.state = VIDEOBUF_DONE; buf->vb.state = VIDEOBUF_DONE;
buf->vb.field_count++; buf->vb.field_count++;
v4l2_get_timestamp(&buf->vb.ts); buf->vb.ts = ktime_get_ns();
dev->vbi_mode.bulk_ctl.buf = NULL; dev->vbi_mode.bulk_ctl.buf = NULL;
......
...@@ -182,7 +182,7 @@ static inline void buffer_filled(struct cx231xx *dev, ...@@ -182,7 +182,7 @@ static inline void buffer_filled(struct cx231xx *dev,
cx231xx_isocdbg("[%p/%d] wakeup\n", buf, buf->vb.i); cx231xx_isocdbg("[%p/%d] wakeup\n", buf, buf->vb.i);
buf->vb.state = VIDEOBUF_DONE; buf->vb.state = VIDEOBUF_DONE;
buf->vb.field_count++; buf->vb.field_count++;
v4l2_get_timestamp(&buf->vb.ts); buf->vb.ts = ktime_get_ns();
if (dev->USE_ISO) if (dev->USE_ISO)
dev->video_mode.isoc_ctl.buf = NULL; dev->video_mode.isoc_ctl.buf = NULL;
......
...@@ -106,7 +106,7 @@ static inline void buffer_filled(struct tm6000_core *dev, ...@@ -106,7 +106,7 @@ static inline void buffer_filled(struct tm6000_core *dev,
dprintk(dev, V4L2_DEBUG_ISOC, "[%p/%d] wakeup\n", buf, buf->vb.i); dprintk(dev, V4L2_DEBUG_ISOC, "[%p/%d] wakeup\n", buf, buf->vb.i);
buf->vb.state = VIDEOBUF_DONE; buf->vb.state = VIDEOBUF_DONE;
buf->vb.field_count++; buf->vb.field_count++;
v4l2_get_timestamp(&buf->vb.ts); buf->vb.ts = ktime_get_ns();
list_del(&buf->vb.queue); list_del(&buf->vb.queue);
wake_up(&buf->vb.done); wake_up(&buf->vb.done);
......
...@@ -521,7 +521,7 @@ static void zr364xx_fillbuff(struct zr364xx_camera *cam, ...@@ -521,7 +521,7 @@ static void zr364xx_fillbuff(struct zr364xx_camera *cam,
/* tell v4l buffer was filled */ /* tell v4l buffer was filled */
buf->vb.field_count = cam->frame_count * 2; buf->vb.field_count = cam->frame_count * 2;
v4l2_get_timestamp(&buf->vb.ts); buf->vb.ts = ktime_get_ns();
buf->vb.state = VIDEOBUF_DONE; buf->vb.state = VIDEOBUF_DONE;
} }
...@@ -549,7 +549,7 @@ static int zr364xx_got_frame(struct zr364xx_camera *cam, int jpgsize) ...@@ -549,7 +549,7 @@ static int zr364xx_got_frame(struct zr364xx_camera *cam, int jpgsize)
goto unlock; goto unlock;
} }
list_del(&buf->vb.queue); list_del(&buf->vb.queue);
v4l2_get_timestamp(&buf->vb.ts); buf->vb.ts = ktime_get_ns();
DBG("[%p/%d] wakeup\n", buf, buf->vb.i); DBG("[%p/%d] wakeup\n", buf, buf->vb.i);
zr364xx_fillbuff(cam, buf, jpgsize); zr364xx_fillbuff(cam, buf, jpgsize);
wake_up(&buf->vb.done); wake_up(&buf->vb.done);
......
...@@ -367,7 +367,7 @@ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, ...@@ -367,7 +367,7 @@ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
} }
b->field = vb->field; b->field = vb->field;
b->timestamp = vb->ts; b->timestamp = ns_to_timeval(vb->ts);
b->bytesused = vb->size; b->bytesused = vb->size;
b->sequence = vb->field_count >> 1; b->sequence = vb->field_count >> 1;
} }
...@@ -581,7 +581,7 @@ int videobuf_qbuf(struct videobuf_queue *q, struct v4l2_buffer *b) ...@@ -581,7 +581,7 @@ int videobuf_qbuf(struct videobuf_queue *q, struct v4l2_buffer *b)
|| q->type == V4L2_BUF_TYPE_SDR_OUTPUT) { || q->type == V4L2_BUF_TYPE_SDR_OUTPUT) {
buf->size = b->bytesused; buf->size = b->bytesused;
buf->field = b->field; buf->field = b->field;
buf->ts = b->timestamp; buf->ts = v4l2_timeval_to_ns(&b->timestamp);
} }
break; break;
case V4L2_MEMORY_USERPTR: case V4L2_MEMORY_USERPTR:
......
...@@ -80,7 +80,7 @@ struct videobuf_buffer { ...@@ -80,7 +80,7 @@ struct videobuf_buffer {
struct list_head queue; struct list_head queue;
wait_queue_head_t done; wait_queue_head_t done;
unsigned int field_count; unsigned int field_count;
struct timeval ts; u64 ts;
/* Memory type */ /* Memory type */
enum v4l2_memory memory; enum v4l2_memory memory;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment