]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: vb2: keep track of timestamp status
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 4 Feb 2019 10:11:33 +0000 (05:11 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 18 Feb 2019 19:44:20 +0000 (14:44 -0500)
If a stream is stopped, or if a USERPTR/DMABUF buffer is queued
backed by a different user address or dmabuf fd, then the timestamp
should be skipped by vb2_find_timestamp since the memory it refers
to is no longer valid.

So keep track of a 'copied_timestamp' state: it is set when the
timestamp is copied from an output to a capture buffer, and is
cleared when it is no longer valid.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/common/videobuf2/videobuf2-core.c
drivers/media/common/videobuf2/videobuf2-v4l2.c
drivers/media/v4l2-core/v4l2-mem2mem.c
include/media/videobuf2-core.h

index b4457edc3245bf5310840a9ed6297b1563681db0..275cddd8808cb7ce1fa11d2249a6ea07f5621bea 100644 (file)
@@ -1041,6 +1041,7 @@ static int __prepare_userptr(struct vb2_buffer *vb)
                if (vb->planes[plane].mem_priv) {
                        if (!reacquired) {
                                reacquired = true;
+                               vb->copied_timestamp = 0;
                                call_void_vb_qop(vb, buf_cleanup, vb);
                        }
                        call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv);
@@ -1165,6 +1166,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
 
                if (!reacquired) {
                        reacquired = true;
+                       vb->copied_timestamp = 0;
                        call_void_vb_qop(vb, buf_cleanup, vb);
                }
 
@@ -1942,6 +1944,7 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
                if (vb->request)
                        media_request_put(vb->request);
                vb->request = NULL;
+               vb->copied_timestamp = 0;
        }
 }
 
index 3aeaea3af42ac250dd6e789c53b31ec75bee1aca..55277370c3133655171bd78ce50b32216d1b4cb5 100644 (file)
@@ -604,7 +604,8 @@ int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp,
        unsigned int i;
 
        for (i = start_idx; i < q->num_buffers; i++)
-               if (q->bufs[i]->timestamp == timestamp)
+               if (q->bufs[i]->copied_timestamp &&
+                   q->bufs[i]->timestamp == timestamp)
                        return i;
        return -1;
 }
index 1494d0d5951a2a5b976f559467a76fd7718d9b0c..add228c98a9ac1e13e757141e436cce1219e2b2d 100644 (file)
@@ -992,6 +992,7 @@ void v4l2_m2m_buf_copy_metadata(const struct vb2_v4l2_buffer *out_vb,
        cap_vb->field = out_vb->field;
        cap_vb->flags &= ~mask;
        cap_vb->flags |= out_vb->flags & mask;
+       cap_vb->vb2_buf.copied_timestamp = 1;
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_buf_copy_metadata);
 
index 6d5490bb91d3af5c87c88863922e3fb3bc516a98..a844abcae71e8650d2e88e593e6394b3cd86afd8 100644 (file)
@@ -262,6 +262,8 @@ struct vb2_buffer {
         * prepared:            this buffer has been prepared, i.e. the
         *                      buf_prepare op was called. It is cleared again
         *                      after the 'buf_finish' op is called.
+        * copied_timestamp:    the timestamp of this capture buffer was copied
+        *                      from an output buffer.
         * queued_entry:        entry on the queued buffers list, which holds
         *                      all buffers queued from userspace
         * done_entry:          entry on the list that stores all buffers ready
@@ -271,6 +273,7 @@ struct vb2_buffer {
        enum vb2_buffer_state   state;
        unsigned int            synced:1;
        unsigned int            prepared:1;
+       unsigned int            copied_timestamp:1;
 
        struct vb2_plane        planes[VB2_MAX_PLANES];
        struct list_head        queued_entry;