[media] v4l: Tell user space we're using monotonic timestamps
authorSakari Ailus <sakari.ailus@iki.fi>
Mon, 22 Oct 2012 20:10:16 +0000 (17:10 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 21 Dec 2012 13:20:51 +0000 (11:20 -0200)
Set buffer timestamp flags for videobuf, videobuf2 and drivers that use
neither.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/pci/meye/meye.c
drivers/media/pci/zoran/zoran_driver.c
drivers/media/platform/omap3isp/ispqueue.c
drivers/media/platform/vino.c
drivers/media/usb/cpia2/cpia2_v4l.c
drivers/media/usb/sn9c102/sn9c102_core.c
drivers/media/usb/stkwebcam/stk-webcam.c
drivers/media/usb/usbvision/usbvision-video.c
drivers/media/v4l2-core/videobuf-core.c
drivers/media/v4l2-core/videobuf2-core.c

index 288adea55e3321ec060db3edf786808e6538ddf2..ac7ab6edb06d078f7aca6abbfdfc8230f593d711 100644 (file)
@@ -1426,7 +1426,7 @@ static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
                return -EINVAL;
 
        buf->bytesused = meye.grab_buffer[index].size;
-       buf->flags = V4L2_BUF_FLAG_MAPPED;
+       buf->flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
        if (meye.grab_buffer[index].state == MEYE_BUF_USING)
                buf->flags |= V4L2_BUF_FLAG_QUEUED;
@@ -1499,7 +1499,7 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
 
        buf->index = reqnr;
        buf->bytesused = meye.grab_buffer[reqnr].size;
-       buf->flags = V4L2_BUF_FLAG_MAPPED;
+       buf->flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        buf->field = V4L2_FIELD_NONE;
        buf->timestamp = meye.grab_buffer[reqnr].timestamp;
        buf->sequence = meye.grab_buffer[reqnr].sequence;
index 53f12c7466b0b971218c2c1c6d769fa0d3f32461..33521a4f23a7186653b20a9e2c13a31bbdb0ada2 100644 (file)
@@ -1334,7 +1334,7 @@ static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
        struct zoran *zr = fh->zr;
        unsigned long flags;
 
-       buf->flags = V4L2_BUF_FLAG_MAPPED;
+       buf->flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
        switch (fh->map_mode) {
        case ZORAN_MAP_MODE_RAW:
index 15bf3eab2224ab3d835380c4a55b1e83e1269636..6599963cdd9ba25ccfcff1f326321542300f254a 100644 (file)
@@ -674,6 +674,7 @@ static int isp_video_queue_alloc(struct isp_video_queue *queue,
                buf->vbuf.index = i;
                buf->vbuf.length = size;
                buf->vbuf.type = queue->type;
+               buf->vbuf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
                buf->vbuf.field = V4L2_FIELD_NONE;
                buf->vbuf.memory = memory;
 
index 28350e78b5645353b4aec52503d9711ac8503e34..eb5d6f955709fbdbad6130f4b36cb74c59737608 100644 (file)
@@ -3410,6 +3410,9 @@ static void vino_v4l2_get_buffer_status(struct vino_channel_settings *vcs,
        if (fb->map_count > 0)
                b->flags |= V4L2_BUF_FLAG_MAPPED;
 
+       b->flags &= ~V4L2_BUF_FLAG_TIMESTAMP_MASK;
+       b->flags |= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+
        b->index = fb->id;
        b->memory = (vcs->fb_queue.type == VINO_MEMORY_MMAP) ?
                V4L2_MEMORY_MMAP : V4L2_MEMORY_USERPTR;
index aeb9d227572583e077a134e6133d9766793cc215..d5d42b6e94be128d49ec8a4dd2a0d8c452c42f48 100644 (file)
@@ -825,6 +825,8 @@ static int cpia2_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
        else
                buf->flags = 0;
 
+       buf->flags |= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+
        switch (cam->buffers[buf->index].status) {
        case FRAME_EMPTY:
        case FRAME_ERROR:
@@ -943,7 +945,8 @@ static int cpia2_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
 
        buf->index = frame;
        buf->bytesused = cam->buffers[buf->index].length;
-       buf->flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE;
+       buf->flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE
+               | V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        buf->field = V4L2_FIELD_NONE;
        buf->timestamp = cam->buffers[buf->index].timestamp;
        buf->sequence = cam->buffers[buf->index].seq;
index 8dbf0c721c4aed65a158794238f9feddfee833e5..6bda81aebf87fca620abb1ae16bdad7af2fe83ed 100644 (file)
@@ -173,7 +173,7 @@ sn9c102_request_buffers(struct sn9c102_device* cam, u32 count,
                cam->frame[i].buf.sequence = 0;
                cam->frame[i].buf.field = V4L2_FIELD_NONE;
                cam->frame[i].buf.memory = V4L2_MEMORY_MMAP;
-               cam->frame[i].buf.flags = 0;
+               cam->frame[i].buf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        }
 
        return cam->nbuffers;
index bf56904decb421f161745a5611e84d819c4890ff..52296f7ec9666f412cd020becc6b8da7cf220c38 100644 (file)
@@ -466,6 +466,7 @@ static int stk_setup_siobuf(struct stk_camera *dev, int index)
        buf->dev = dev;
        buf->v4lbuf.index = index;
        buf->v4lbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+       buf->v4lbuf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        buf->v4lbuf.field = V4L2_FIELD_NONE;
        buf->v4lbuf.memory = V4L2_MEMORY_MMAP;
        buf->v4lbuf.m.offset = 2*index*buf->v4lbuf.length;
index 5c36a57e6590d6c731341663296faad17607a7ef..c6bc8ce673759a719dedce2e98fc546aa8629e76 100644 (file)
@@ -761,7 +761,7 @@ static int vidioc_querybuf(struct file *file,
        if (vb->index >= usbvision->num_frames)
                return -EINVAL;
        /* Updating the corresponding frame state */
-       vb->flags = 0;
+       vb->flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        frame = &usbvision->frame[vb->index];
        if (frame->grabstate >= frame_state_ready)
                vb->flags |= V4L2_BUF_FLAG_QUEUED;
@@ -843,7 +843,8 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *vb)
        vb->memory = V4L2_MEMORY_MMAP;
        vb->flags = V4L2_BUF_FLAG_MAPPED |
                V4L2_BUF_FLAG_QUEUED |
-               V4L2_BUF_FLAG_DONE;
+               V4L2_BUF_FLAG_DONE |
+               V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        vb->index = f->index;
        vb->sequence = f->sequence;
        vb->timestamp = f->timestamp;
index 5449e8aa984a7b9ba18d1f02679a68d976411f9c..fb5ee5dd8fe933cbdd371aeecf41a3047d2e0e39 100644 (file)
@@ -340,7 +340,7 @@ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
                break;
        }
 
-       b->flags    = 0;
+       b->flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        if (vb->map)
                b->flags |= V4L2_BUF_FLAG_MAPPED;
 
index 9f81be23a81f06a1d527ac792071e1b7a6154979..85e3c221dadc2783175e34f0d34a06ad81ddbbbd 100644 (file)
@@ -40,9 +40,10 @@ module_param(debug, int, 0644);
 #define call_qop(q, op, args...)                                       \
        (((q)->ops->op) ? ((q)->ops->op(args)) : 0)
 
-#define V4L2_BUFFER_STATE_FLAGS        (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \
+#define V4L2_BUFFER_MASK_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \
                                 V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_ERROR | \
-                                V4L2_BUF_FLAG_PREPARED)
+                                V4L2_BUF_FLAG_PREPARED | \
+                                V4L2_BUF_FLAG_TIMESTAMP_MASK)
 
 /**
  * __vb2_buf_mem_alloc() - allocate video memory for the given buffer
@@ -401,7 +402,8 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
        /*
         * Clear any buffer state related flags.
         */
-       b->flags &= ~V4L2_BUFFER_STATE_FLAGS;
+       b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
+       b->flags |= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
        switch (vb->state) {
        case VB2_BUF_STATE_QUEUED:
@@ -939,7 +941,7 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
 
        vb->v4l2_buf.field = b->field;
        vb->v4l2_buf.timestamp = b->timestamp;
-       vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS;
+       vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS;
 }
 
 /**