aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2015-09-17 17:19:37 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-10-01 07:29:23 -0400
commit5ba0e2c3ad4c049b19f6cad7ec62e59424a55183 (patch)
treeda731151900e30bac077a5ef1872b32a62d1a7e2
parent2ef3b6fe9e6d7b22ca9f81a58d5ff089f7b4ef91 (diff)
[media] use v4l2_get_timestamp where possible
This is a preparation for a change to the type of v4l2 timestamps. v4l2_get_timestamp() is a helper function that reads the monotonic time and stores it into a 'struct timeval'. Multiple drivers implement the same thing themselves for historic reasons. Changing them all to use v4l2_get_timestamp() is more consistent and reduces the amount of code duplication, and most importantly simplifies the following changes. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> [hans.verkuil@cisco.com: dropped the v4l2-dev.c patch that didn't belong here] Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c5
-rw-r--r--drivers/media/pci/cx18/cx18-mailbox.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.c7
-rw-r--r--drivers/media/platform/omap3isp/ispstat.c5
-rw-r--r--drivers/media/platform/omap3isp/ispstat.h2
-rw-r--r--drivers/media/platform/s3c-camif/camif-capture.c8
-rw-r--r--drivers/media/usb/gspca/gspca.c4
-rw-r--r--drivers/staging/media/omap4iss/iss_video.c5
8 files changed, 10 insertions, 28 deletions
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 3632958f2158..15a4ebc2844d 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -3625,13 +3625,10 @@ static void
3625bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup, 3625bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup,
3626 unsigned int state) 3626 unsigned int state)
3627{ 3627{
3628 struct timeval ts;
3629
3630 if (NULL == wakeup) 3628 if (NULL == wakeup)
3631 return; 3629 return;
3632 3630
3633 v4l2_get_timestamp(&ts); 3631 v4l2_get_timestamp(&wakeup->vb.ts);
3634 wakeup->vb.ts = ts;
3635 wakeup->vb.field_count = btv->field_count; 3632 wakeup->vb.field_count = btv->field_count;
3636 wakeup->vb.state = state; 3633 wakeup->vb.state = state;
3637 wake_up(&wakeup->vb.done); 3634 wake_up(&wakeup->vb.done);
diff --git a/drivers/media/pci/cx18/cx18-mailbox.c b/drivers/media/pci/cx18/cx18-mailbox.c
index eabf00c6351b..1f8aa9a749a1 100644
--- a/drivers/media/pci/cx18/cx18-mailbox.c
+++ b/drivers/media/pci/cx18/cx18-mailbox.c
@@ -202,7 +202,7 @@ static void cx18_mdl_send_to_videobuf(struct cx18_stream *s,
202 } 202 }
203 203
204 if (dispatch) { 204 if (dispatch) {
205 vb_buf->vb.ts = ktime_to_timeval(ktime_get()); 205 v4l2_get_timestamp(&vb_buf->vb.ts);
206 list_del(&vb_buf->vb.queue); 206 list_del(&vb_buf->vb.queue);
207 vb_buf->vb.state = VIDEOBUF_DONE; 207 vb_buf->vb.state = VIDEOBUF_DONE;
208 wake_up(&vb_buf->vb.done); 208 wake_up(&vb_buf->vb.done);
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index ca6261a86a5f..459bc65b545d 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -254,8 +254,6 @@ static irqreturn_t flite_irq_handler(int irq, void *priv)
254 struct fimc_lite *fimc = priv; 254 struct fimc_lite *fimc = priv;
255 struct flite_buffer *vbuf; 255 struct flite_buffer *vbuf;
256 unsigned long flags; 256 unsigned long flags;
257 struct timeval *tv;
258 struct timespec ts;
259 u32 intsrc; 257 u32 intsrc;
260 258
261 spin_lock_irqsave(&fimc->slock, flags); 259 spin_lock_irqsave(&fimc->slock, flags);
@@ -294,10 +292,7 @@ static irqreturn_t flite_irq_handler(int irq, void *priv)
294 test_bit(ST_FLITE_RUN, &fimc->state) && 292 test_bit(ST_FLITE_RUN, &fimc->state) &&
295 !list_empty(&fimc->active_buf_q)) { 293 !list_empty(&fimc->active_buf_q)) {
296 vbuf = fimc_lite_active_queue_pop(fimc); 294 vbuf = fimc_lite_active_queue_pop(fimc);
297 ktime_get_ts(&ts); 295 v4l2_get_timestamp(&vbuf->vb.v4l2_buf.timestamp);
298 tv = &vbuf->vb.v4l2_buf.timestamp;
299 tv->tv_sec = ts.tv_sec;
300 tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
301 vbuf->vb.v4l2_buf.sequence = fimc->frame_count++; 296 vbuf->vb.v4l2_buf.sequence = fimc->frame_count++;
302 flite_hw_mask_dma_buffer(fimc, vbuf->index); 297 flite_hw_mask_dma_buffer(fimc, vbuf->index);
303 vb2_buffer_done(&vbuf->vb, VB2_BUF_STATE_DONE); 298 vb2_buffer_done(&vbuf->vb, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/omap3isp/ispstat.c b/drivers/media/platform/omap3isp/ispstat.c
index 20434e83e801..94d4c295d3d0 100644
--- a/drivers/media/platform/omap3isp/ispstat.c
+++ b/drivers/media/platform/omap3isp/ispstat.c
@@ -235,7 +235,7 @@ static int isp_stat_buf_queue(struct ispstat *stat)
235 if (!stat->active_buf) 235 if (!stat->active_buf)
236 return STAT_NO_BUF; 236 return STAT_NO_BUF;
237 237
238 ktime_get_ts(&stat->active_buf->ts); 238 v4l2_get_timestamp(&stat->active_buf->ts);
239 239
240 stat->active_buf->buf_size = stat->buf_size; 240 stat->active_buf->buf_size = stat->buf_size;
241 if (isp_stat_buf_check_magic(stat, stat->active_buf)) { 241 if (isp_stat_buf_check_magic(stat, stat->active_buf)) {
@@ -496,8 +496,7 @@ int omap3isp_stat_request_statistics(struct ispstat *stat,
496 return PTR_ERR(buf); 496 return PTR_ERR(buf);
497 } 497 }
498 498
499 data->ts.tv_sec = buf->ts.tv_sec; 499 data->ts = buf->ts;
500 data->ts.tv_usec = buf->ts.tv_nsec / NSEC_PER_USEC;
501 data->config_counter = buf->config_counter; 500 data->config_counter = buf->config_counter;
502 data->frame_number = buf->frame_number; 501 data->frame_number = buf->frame_number;
503 data->buf_size = buf->buf_size; 502 data->buf_size = buf->buf_size;
diff --git a/drivers/media/platform/omap3isp/ispstat.h b/drivers/media/platform/omap3isp/ispstat.h
index b79380d83fcf..6d9b0244f320 100644
--- a/drivers/media/platform/omap3isp/ispstat.h
+++ b/drivers/media/platform/omap3isp/ispstat.h
@@ -39,7 +39,7 @@ struct ispstat_buffer {
39 struct sg_table sgt; 39 struct sg_table sgt;
40 void *virt_addr; 40 void *virt_addr;
41 dma_addr_t dma_addr; 41 dma_addr_t dma_addr;
42 struct timespec ts; 42 struct timeval ts;
43 u32 buf_size; 43 u32 buf_size;
44 u32 frame_number; 44 u32 frame_number;
45 u16 config_counter; 45 u16 config_counter;
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
index 76e6289a5612..edf70725ecf3 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -328,23 +328,17 @@ irqreturn_t s3c_camif_irq_handler(int irq, void *priv)
328 !list_empty(&vp->active_buf_q)) { 328 !list_empty(&vp->active_buf_q)) {
329 unsigned int index; 329 unsigned int index;
330 struct camif_buffer *vbuf; 330 struct camif_buffer *vbuf;
331 struct timeval *tv;
332 struct timespec ts;
333 /* 331 /*
334 * Get previous DMA write buffer index: 332 * Get previous DMA write buffer index:
335 * 0 => DMA buffer 0, 2; 333 * 0 => DMA buffer 0, 2;
336 * 1 => DMA buffer 1, 3. 334 * 1 => DMA buffer 1, 3.
337 */ 335 */
338 index = (CISTATUS_FRAMECNT(status) + 2) & 1; 336 index = (CISTATUS_FRAMECNT(status) + 2) & 1;
339
340 ktime_get_ts(&ts);
341 vbuf = camif_active_queue_peek(vp, index); 337 vbuf = camif_active_queue_peek(vp, index);
342 338
343 if (!WARN_ON(vbuf == NULL)) { 339 if (!WARN_ON(vbuf == NULL)) {
344 /* Dequeue a filled buffer */ 340 /* Dequeue a filled buffer */
345 tv = &vbuf->vb.v4l2_buf.timestamp; 341 v4l2_get_timestamp(&vbuf->vb.v4l2_buf.timestamp);
346 tv->tv_sec = ts.tv_sec;
347 tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
348 vbuf->vb.v4l2_buf.sequence = vp->frame_sequence++; 342 vbuf->vb.v4l2_buf.sequence = vp->frame_sequence++;
349 vb2_buffer_done(&vbuf->vb, VB2_BUF_STATE_DONE); 343 vb2_buffer_done(&vbuf->vb, VB2_BUF_STATE_DONE);
350 344
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index e54cee856a80..af5cd8213e8b 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -436,7 +436,7 @@ void gspca_frame_add(struct gspca_dev *gspca_dev,
436 } 436 }
437 j = gspca_dev->fr_queue[i]; 437 j = gspca_dev->fr_queue[i];
438 frame = &gspca_dev->frame[j]; 438 frame = &gspca_dev->frame[j];
439 frame->v4l2_buf.timestamp = ktime_to_timeval(ktime_get()); 439 v4l2_get_timestamp(&frame->v4l2_buf.timestamp);
440 frame->v4l2_buf.sequence = gspca_dev->sequence++; 440 frame->v4l2_buf.sequence = gspca_dev->sequence++;
441 gspca_dev->image = frame->data; 441 gspca_dev->image = frame->data;
442 gspca_dev->image_len = 0; 442 gspca_dev->image_len = 0;
@@ -1909,7 +1909,7 @@ static ssize_t dev_read(struct file *file, char __user *data,
1909 } 1909 }
1910 1910
1911 /* get a frame */ 1911 /* get a frame */
1912 timestamp = ktime_to_timeval(ktime_get()); 1912 v4l2_get_timestamp(&timestamp);
1913 timestamp.tv_sec--; 1913 timestamp.tv_sec--;
1914 n = 2; 1914 n = 2;
1915 for (;;) { 1915 for (;;) {
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index 40405d8710a6..485a90ce12df 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -420,7 +420,6 @@ struct iss_buffer *omap4iss_video_buffer_next(struct iss_video *video)
420 enum iss_pipeline_state state; 420 enum iss_pipeline_state state;
421 struct iss_buffer *buf; 421 struct iss_buffer *buf;
422 unsigned long flags; 422 unsigned long flags;
423 struct timespec ts;
424 423
425 spin_lock_irqsave(&video->qlock, flags); 424 spin_lock_irqsave(&video->qlock, flags);
426 if (WARN_ON(list_empty(&video->dmaqueue))) { 425 if (WARN_ON(list_empty(&video->dmaqueue))) {
@@ -433,9 +432,7 @@ struct iss_buffer *omap4iss_video_buffer_next(struct iss_video *video)
433 list_del(&buf->list); 432 list_del(&buf->list);
434 spin_unlock_irqrestore(&video->qlock, flags); 433 spin_unlock_irqrestore(&video->qlock, flags);
435 434
436 ktime_get_ts(&ts); 435 v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp);
437 buf->vb.v4l2_buf.timestamp.tv_sec = ts.tv_sec;
438 buf->vb.v4l2_buf.timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
439 436
440 /* Do frame number propagation only if this is the output video node. 437 /* Do frame number propagation only if this is the output video node.
441 * Frame number either comes from the CSI receivers or it gets 438 * Frame number either comes from the CSI receivers or it gets