@@ -107,7 +107,7 @@ static int __verify_length(struct vb2_buffer *vb, const struct v4l2_buffer *b)
107107 return 0 ;
108108}
109109
110- static int __set_timestamp (struct vb2_buffer * vb , const void * pb )
110+ static int __copy_timestamp (struct vb2_buffer * vb , const void * pb )
111111{
112112 const struct v4l2_buffer * b = pb ;
113113 struct vb2_v4l2_buffer * vbuf = to_vb2_v4l2_buffer (vb );
@@ -118,8 +118,7 @@ static int __set_timestamp(struct vb2_buffer *vb, const void *pb)
118118 * For output buffers copy the timestamp if needed,
119119 * and the timecode field and flag if needed.
120120 */
121- if ((q -> timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK ) ==
122- V4L2_BUF_FLAG_TIMESTAMP_COPY )
121+ if (q -> copy_timestamp )
123122 vb -> timestamp = timeval_to_ns (& b -> timestamp );
124123 vbuf -> flags |= b -> flags & V4L2_BUF_FLAG_TIMECODE ;
125124 if (b -> flags & V4L2_BUF_FLAG_TIMECODE )
@@ -238,8 +237,7 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb)
238237 */
239238 b -> flags &= ~V4L2_BUFFER_MASK_FLAGS ;
240239 b -> flags |= q -> timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK ;
241- if ((q -> timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK ) !=
242- V4L2_BUF_FLAG_TIMESTAMP_COPY ) {
240+ if (!q -> copy_timestamp ) {
243241 /*
244242 * For non-COPY timestamps, drop timestamp source bits
245243 * and obtain the timestamp source from the queue.
@@ -403,8 +401,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
403401
404402 /* Zero flags that the vb2 core handles */
405403 vbuf -> flags = b -> flags & ~V4L2_BUFFER_MASK_FLAGS ;
406- if ((vb -> vb2_queue -> timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK ) !=
407- V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT (b -> type )) {
404+ if (!vb -> vb2_queue -> copy_timestamp || !V4L2_TYPE_IS_OUTPUT (b -> type )) {
408405 /*
409406 * Non-COPY timestamps and non-OUTPUT queues will get
410407 * their timestamp and timestamp source flags from the
@@ -433,7 +430,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
433430static const struct vb2_buf_ops v4l2_buf_ops = {
434431 .fill_user_buffer = __fill_v4l2_buffer ,
435432 .fill_vb2_buffer = __fill_vb2_buffer ,
436- .set_timestamp = __set_timestamp ,
433+ .copy_timestamp = __copy_timestamp ,
437434};
438435
439436/**
@@ -760,6 +757,8 @@ int vb2_queue_init(struct vb2_queue *q)
760757 q -> buf_ops = & v4l2_buf_ops ;
761758 q -> is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR (q -> type );
762759 q -> is_output = V4L2_TYPE_IS_OUTPUT (q -> type );
760+ q -> copy_timestamp = (q -> timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK )
761+ == V4L2_BUF_FLAG_TIMESTAMP_COPY ;
763762
764763 return vb2_core_queue_init (q );
765764}
@@ -1114,12 +1113,10 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
11141113 bool is_multiplanar = q -> is_multiplanar ;
11151114 /*
11161115 * When using write() to write data to an output video node the vb2 core
1117- * should set timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody
1116+ * should copy timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody
11181117 * else is able to provide this information with the write() operation.
11191118 */
1120- bool set_timestamp = !read &&
1121- (q -> timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK ) ==
1122- V4L2_BUF_FLAG_TIMESTAMP_COPY ;
1119+ bool copy_timestamp = !read && q -> copy_timestamp ;
11231120 int ret , index ;
11241121
11251122 dprintk (3 , "mode %s, offset %ld, count %zd, %sblocking\n" ,
@@ -1236,7 +1233,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
12361233 fileio -> b .m .planes = & fileio -> p ;
12371234 fileio -> b .length = 1 ;
12381235 }
1239- if (set_timestamp )
1236+ if (copy_timestamp )
12401237 v4l2_get_timestamp (& fileio -> b .timestamp );
12411238 ret = vb2_internal_qbuf (q , & fileio -> b );
12421239 dprintk (5 , "vb2_dbuf result: %d\n" , ret );
@@ -1301,16 +1298,14 @@ static int vb2_thread(void *data)
13011298 struct vb2_queue * q = data ;
13021299 struct vb2_threadio_data * threadio = q -> threadio ;
13031300 struct vb2_fileio_data * fileio = q -> fileio ;
1304- bool set_timestamp = false;
1301+ bool copy_timestamp = false;
13051302 int prequeue = 0 ;
13061303 int index = 0 ;
13071304 int ret = 0 ;
13081305
13091306 if (q -> is_output ) {
13101307 prequeue = q -> num_buffers ;
1311- set_timestamp =
1312- (q -> timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK ) ==
1313- V4L2_BUF_FLAG_TIMESTAMP_COPY ;
1308+ copy_timestamp = q -> copy_timestamp ;
13141309 }
13151310
13161311 set_freezable ();
@@ -1343,7 +1338,7 @@ static int vb2_thread(void *data)
13431338 if (threadio -> fnc (vb , threadio -> priv ))
13441339 break ;
13451340 call_void_qop (q , wait_finish , q );
1346- if (set_timestamp )
1341+ if (copy_timestamp )
13471342 v4l2_get_timestamp (& fileio -> b .timestamp );
13481343 if (!threadio -> stop )
13491344 ret = vb2_internal_qbuf (q , & fileio -> b );
0 commit comments