Lines Matching refs:b
56 static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __verify_planes_array() argument
58 if (!V4L2_TYPE_IS_MULTIPLANAR(b->type)) in __verify_planes_array()
62 if (b->m.planes == NULL) { in __verify_planes_array()
67 if (b->length < vb->num_planes || b->length > VB2_MAX_PLANES) { in __verify_planes_array()
69 vb->num_planes, b->length); in __verify_planes_array()
85 static int __verify_length(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __verify_length() argument
91 if (!V4L2_TYPE_IS_OUTPUT(b->type)) in __verify_length()
94 if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { in __verify_length()
96 length = (b->memory == VB2_MEMORY_USERPTR || in __verify_length()
97 b->memory == VB2_MEMORY_DMABUF) in __verify_length()
98 ? b->m.planes[plane].length in __verify_length()
100 bytesused = b->m.planes[plane].bytesused in __verify_length()
101 ? b->m.planes[plane].bytesused : length; in __verify_length()
103 if (b->m.planes[plane].bytesused > length) in __verify_length()
106 if (b->m.planes[plane].data_offset > 0 && in __verify_length()
107 b->m.planes[plane].data_offset >= bytesused) in __verify_length()
111 length = (b->memory == VB2_MEMORY_USERPTR) in __verify_length()
112 ? b->length : vb->planes[0].length; in __verify_length()
114 if (b->bytesused > length) in __verify_length()
123 const struct v4l2_buffer *b = pb; in __copy_timestamp() local
133 vb->timestamp = timeval_to_ns(&b->timestamp); in __copy_timestamp()
134 vbuf->flags |= b->flags & V4L2_BUF_FLAG_TIMECODE; in __copy_timestamp()
135 if (b->flags & V4L2_BUF_FLAG_TIMECODE) in __copy_timestamp()
136 vbuf->timecode = b->timecode; in __copy_timestamp()
156 static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b, in vb2_queue_or_prepare_buf() argument
159 if (b->type != q->type) { in vb2_queue_or_prepare_buf()
164 if (b->index >= q->num_buffers) { in vb2_queue_or_prepare_buf()
169 if (q->bufs[b->index] == NULL) { in vb2_queue_or_prepare_buf()
175 if (b->memory != q->memory) { in vb2_queue_or_prepare_buf()
180 return __verify_planes_array(q->bufs[b->index], b); in vb2_queue_or_prepare_buf()
189 struct v4l2_buffer *b = pb; in __fill_v4l2_buffer() local
195 b->index = vb->index; in __fill_v4l2_buffer()
196 b->type = vb->type; in __fill_v4l2_buffer()
197 b->memory = vb->memory; in __fill_v4l2_buffer()
198 b->bytesused = 0; in __fill_v4l2_buffer()
200 b->flags = vbuf->flags; in __fill_v4l2_buffer()
201 b->field = vbuf->field; in __fill_v4l2_buffer()
202 b->timestamp = ns_to_timeval(vb->timestamp); in __fill_v4l2_buffer()
203 b->timecode = vbuf->timecode; in __fill_v4l2_buffer()
204 b->sequence = vbuf->sequence; in __fill_v4l2_buffer()
205 b->reserved2 = 0; in __fill_v4l2_buffer()
206 b->reserved = 0; in __fill_v4l2_buffer()
213 b->length = vb->num_planes; in __fill_v4l2_buffer()
215 struct v4l2_plane *pdst = &b->m.planes[plane]; in __fill_v4l2_buffer()
234 b->length = vb->planes[0].length; in __fill_v4l2_buffer()
235 b->bytesused = vb->planes[0].bytesused; in __fill_v4l2_buffer()
237 b->m.offset = vb->planes[0].m.offset; in __fill_v4l2_buffer()
239 b->m.userptr = vb->planes[0].m.userptr; in __fill_v4l2_buffer()
241 b->m.fd = vb->planes[0].m.fd; in __fill_v4l2_buffer()
247 b->flags &= ~V4L2_BUFFER_MASK_FLAGS; in __fill_v4l2_buffer()
248 b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK; in __fill_v4l2_buffer()
254 b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; in __fill_v4l2_buffer()
255 b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; in __fill_v4l2_buffer()
261 b->flags |= V4L2_BUF_FLAG_QUEUED; in __fill_v4l2_buffer()
264 b->flags |= V4L2_BUF_FLAG_ERROR; in __fill_v4l2_buffer()
267 b->flags |= V4L2_BUF_FLAG_DONE; in __fill_v4l2_buffer()
270 b->flags |= V4L2_BUF_FLAG_PREPARED; in __fill_v4l2_buffer()
280 b->flags |= V4L2_BUF_FLAG_MAPPED; in __fill_v4l2_buffer()
283 b->flags & V4L2_BUF_FLAG_DONE && in __fill_v4l2_buffer()
284 b->flags & V4L2_BUF_FLAG_LAST) in __fill_v4l2_buffer()
297 const struct v4l2_buffer *b = pb; in __fill_vb2_buffer() local
302 ret = __verify_length(vb, b); in __fill_vb2_buffer()
307 if (b->field == V4L2_FIELD_ALTERNATE && q->is_output) { in __fill_vb2_buffer()
323 if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { in __fill_vb2_buffer()
324 if (b->memory == VB2_MEMORY_USERPTR) { in __fill_vb2_buffer()
327 b->m.planes[plane].m.userptr; in __fill_vb2_buffer()
329 b->m.planes[plane].length; in __fill_vb2_buffer()
332 if (b->memory == VB2_MEMORY_DMABUF) { in __fill_vb2_buffer()
335 b->m.planes[plane].m.fd; in __fill_vb2_buffer()
337 b->m.planes[plane].length; in __fill_vb2_buffer()
342 if (V4L2_TYPE_IS_OUTPUT(b->type)) { in __fill_vb2_buffer()
361 struct v4l2_plane *psrc = &b->m.planes[plane]; in __fill_vb2_buffer()
389 if (b->memory == VB2_MEMORY_USERPTR) { in __fill_vb2_buffer()
390 planes[0].m.userptr = b->m.userptr; in __fill_vb2_buffer()
391 planes[0].length = b->length; in __fill_vb2_buffer()
394 if (b->memory == VB2_MEMORY_DMABUF) { in __fill_vb2_buffer()
395 planes[0].m.fd = b->m.fd; in __fill_vb2_buffer()
396 planes[0].length = b->length; in __fill_vb2_buffer()
399 if (V4L2_TYPE_IS_OUTPUT(b->type)) { in __fill_vb2_buffer()
400 if (b->bytesused == 0) in __fill_vb2_buffer()
404 planes[0].bytesused = b->bytesused; in __fill_vb2_buffer()
406 planes[0].bytesused = b->bytesused ? in __fill_vb2_buffer()
407 b->bytesused : planes[0].length; in __fill_vb2_buffer()
414 vbuf->flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS; in __fill_vb2_buffer()
415 if (!vb->vb2_queue->copy_timestamp || !V4L2_TYPE_IS_OUTPUT(b->type)) { in __fill_vb2_buffer()
424 if (V4L2_TYPE_IS_OUTPUT(b->type)) { in __fill_vb2_buffer()
432 vbuf->field = b->field; in __fill_vb2_buffer()
463 int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) in vb2_querybuf() argument
468 if (b->type != q->type) { in vb2_querybuf()
473 if (b->index >= q->num_buffers) { in vb2_querybuf()
477 vb = q->bufs[b->index]; in vb2_querybuf()
478 ret = __verify_planes_array(vb, b); in vb2_querybuf()
480 vb2_core_querybuf(q, b->index, b); in vb2_querybuf()
493 int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b) in vb2_prepare_buf() argument
502 ret = vb2_queue_or_prepare_buf(q, b, "prepare_buf"); in vb2_prepare_buf()
504 return ret ? ret : vb2_core_prepare_buf(q, b->index, b); in vb2_prepare_buf()
562 int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) in vb2_qbuf() argument
571 ret = vb2_queue_or_prepare_buf(q, b, "qbuf"); in vb2_qbuf()
572 return ret ? ret : vb2_core_qbuf(q, b->index, b); in vb2_qbuf()
576 int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking) in vb2_dqbuf() argument
585 if (b->type != q->type) { in vb2_dqbuf()
590 ret = vb2_core_dqbuf(q, NULL, b, nonblocking); in vb2_dqbuf()
596 b->flags &= ~V4L2_BUF_FLAG_DONE; in vb2_dqbuf()