Lines Matching refs:vb

52 #define log_memop(vb, op)						\  argument
54 (vb)->vb2_queue, (vb)->v4l2_buf.index, #op, \
55 (vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
57 #define call_memop(vb, op, args...) \ argument
59 struct vb2_queue *_q = (vb)->vb2_queue; \
62 log_memop(vb, op); \
65 (vb)->cnt_mem_ ## op++; \
69 #define call_ptr_memop(vb, op, args...) \ argument
71 struct vb2_queue *_q = (vb)->vb2_queue; \
74 log_memop(vb, op); \
77 (vb)->cnt_mem_ ## op++; \
81 #define call_void_memop(vb, op, args...) \ argument
83 struct vb2_queue *_q = (vb)->vb2_queue; \
85 log_memop(vb, op); \
88 (vb)->cnt_mem_ ## op++; \
114 #define log_vb_qop(vb, op, args...) \ argument
116 (vb)->vb2_queue, (vb)->v4l2_buf.index, #op, \
117 (vb)->vb2_queue->ops->op ? "" : " (nop)")
119 #define call_vb_qop(vb, op, args...) \ argument
123 log_vb_qop(vb, op); \
124 err = (vb)->vb2_queue->ops->op ? \
125 (vb)->vb2_queue->ops->op(args) : 0; \
127 (vb)->cnt_ ## op++; \
131 #define call_void_vb_qop(vb, op, args...) \ argument
133 log_vb_qop(vb, op); \
134 if ((vb)->vb2_queue->ops->op) \
135 (vb)->vb2_queue->ops->op(args); \
136 (vb)->cnt_ ## op++; \
141 #define call_memop(vb, op, args...) \ argument
142 ((vb)->vb2_queue->mem_ops->op ? \
143 (vb)->vb2_queue->mem_ops->op(args) : 0)
145 #define call_ptr_memop(vb, op, args...) \ argument
146 ((vb)->vb2_queue->mem_ops->op ? \
147 (vb)->vb2_queue->mem_ops->op(args) : NULL)
149 #define call_void_memop(vb, op, args...) \ argument
151 if ((vb)->vb2_queue->mem_ops->op) \
152 (vb)->vb2_queue->mem_ops->op(args); \
164 #define call_vb_qop(vb, op, args...) \ argument
165 ((vb)->vb2_queue->ops->op ? (vb)->vb2_queue->ops->op(args) : 0)
167 #define call_void_vb_qop(vb, op, args...) \ argument
169 if ((vb)->vb2_queue->ops->op) \
170 (vb)->vb2_queue->ops->op(args); \
189 static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) in __vb2_buf_mem_alloc() argument
191 struct vb2_queue *q = vb->vb2_queue; in __vb2_buf_mem_alloc()
201 for (plane = 0; plane < vb->num_planes; ++plane) { in __vb2_buf_mem_alloc()
204 mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane], in __vb2_buf_mem_alloc()
210 vb->planes[plane].mem_priv = mem_priv; in __vb2_buf_mem_alloc()
211 vb->v4l2_planes[plane].length = q->plane_sizes[plane]; in __vb2_buf_mem_alloc()
218 call_void_memop(vb, put, vb->planes[plane - 1].mem_priv); in __vb2_buf_mem_alloc()
219 vb->planes[plane - 1].mem_priv = NULL; in __vb2_buf_mem_alloc()
228 static void __vb2_buf_mem_free(struct vb2_buffer *vb) in __vb2_buf_mem_free() argument
232 for (plane = 0; plane < vb->num_planes; ++plane) { in __vb2_buf_mem_free()
233 call_void_memop(vb, put, vb->planes[plane].mem_priv); in __vb2_buf_mem_free()
234 vb->planes[plane].mem_priv = NULL; in __vb2_buf_mem_free()
236 vb->v4l2_buf.index); in __vb2_buf_mem_free()
244 static void __vb2_buf_userptr_put(struct vb2_buffer *vb) in __vb2_buf_userptr_put() argument
248 for (plane = 0; plane < vb->num_planes; ++plane) { in __vb2_buf_userptr_put()
249 if (vb->planes[plane].mem_priv) in __vb2_buf_userptr_put()
250 call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv); in __vb2_buf_userptr_put()
251 vb->planes[plane].mem_priv = NULL; in __vb2_buf_userptr_put()
259 static void __vb2_plane_dmabuf_put(struct vb2_buffer *vb, struct vb2_plane *p) in __vb2_plane_dmabuf_put() argument
265 call_void_memop(vb, unmap_dmabuf, p->mem_priv); in __vb2_plane_dmabuf_put()
267 call_void_memop(vb, detach_dmabuf, p->mem_priv); in __vb2_plane_dmabuf_put()
276 static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) in __vb2_buf_dmabuf_put() argument
280 for (plane = 0; plane < vb->num_planes; ++plane) in __vb2_buf_dmabuf_put()
281 __vb2_plane_dmabuf_put(vb, &vb->planes[plane]); in __vb2_buf_dmabuf_put()
291 struct vb2_buffer *vb; in __setup_lengths() local
294 vb = q->bufs[buffer]; in __setup_lengths()
295 if (!vb) in __setup_lengths()
298 for (plane = 0; plane < vb->num_planes; ++plane) in __setup_lengths()
299 vb->v4l2_planes[plane].length = q->plane_sizes[plane]; in __setup_lengths()
310 struct vb2_buffer *vb; in __setup_offsets() local
315 vb = q->bufs[q->num_buffers - 1]; in __setup_offsets()
316 p = &vb->v4l2_planes[vb->num_planes - 1]; in __setup_offsets()
323 vb = q->bufs[buffer]; in __setup_offsets()
324 if (!vb) in __setup_offsets()
327 for (plane = 0; plane < vb->num_planes; ++plane) { in __setup_offsets()
328 vb->v4l2_planes[plane].m.mem_offset = off; in __setup_offsets()
333 off += vb->v4l2_planes[plane].length; in __setup_offsets()
350 struct vb2_buffer *vb; in __vb2_queue_alloc() local
355 vb = kzalloc(q->buf_struct_size, GFP_KERNEL); in __vb2_queue_alloc()
356 if (!vb) { in __vb2_queue_alloc()
363 vb->v4l2_buf.length = num_planes; in __vb2_queue_alloc()
365 vb->state = VB2_BUF_STATE_DEQUEUED; in __vb2_queue_alloc()
366 vb->vb2_queue = q; in __vb2_queue_alloc()
367 vb->num_planes = num_planes; in __vb2_queue_alloc()
368 vb->v4l2_buf.index = q->num_buffers + buffer; in __vb2_queue_alloc()
369 vb->v4l2_buf.type = q->type; in __vb2_queue_alloc()
370 vb->v4l2_buf.memory = memory; in __vb2_queue_alloc()
374 ret = __vb2_buf_mem_alloc(vb); in __vb2_queue_alloc()
378 kfree(vb); in __vb2_queue_alloc()
386 ret = call_vb_qop(vb, buf_init, vb); in __vb2_queue_alloc()
389 " failed\n", buffer, vb); in __vb2_queue_alloc()
390 __vb2_buf_mem_free(vb); in __vb2_queue_alloc()
391 kfree(vb); in __vb2_queue_alloc()
396 q->bufs[q->num_buffers + buffer] = vb; in __vb2_queue_alloc()
415 struct vb2_buffer *vb; in __vb2_free_mem() local
419 vb = q->bufs[buffer]; in __vb2_free_mem()
420 if (!vb) in __vb2_free_mem()
425 __vb2_buf_mem_free(vb); in __vb2_free_mem()
427 __vb2_buf_dmabuf_put(vb); in __vb2_free_mem()
429 __vb2_buf_userptr_put(vb); in __vb2_free_mem()
463 struct vb2_buffer *vb = q->bufs[buffer]; in __vb2_queue_free() local
465 if (vb && vb->planes[0].mem_priv) in __vb2_queue_free()
466 call_void_vb_qop(vb, buf_cleanup, vb); in __vb2_queue_free()
498 struct vb2_buffer *vb = q->bufs[buffer]; in __vb2_queue_free() local
499 bool unbalanced = vb->cnt_mem_alloc != vb->cnt_mem_put || in __vb2_queue_free()
500 vb->cnt_mem_prepare != vb->cnt_mem_finish || in __vb2_queue_free()
501 vb->cnt_mem_get_userptr != vb->cnt_mem_put_userptr || in __vb2_queue_free()
502 vb->cnt_mem_attach_dmabuf != vb->cnt_mem_detach_dmabuf || in __vb2_queue_free()
503 vb->cnt_mem_map_dmabuf != vb->cnt_mem_unmap_dmabuf || in __vb2_queue_free()
504 vb->cnt_buf_queue != vb->cnt_buf_done || in __vb2_queue_free()
505 vb->cnt_buf_prepare != vb->cnt_buf_finish || in __vb2_queue_free()
506 vb->cnt_buf_init != vb->cnt_buf_cleanup; in __vb2_queue_free()
512 vb->cnt_buf_init, vb->cnt_buf_cleanup, in __vb2_queue_free()
513 vb->cnt_buf_prepare, vb->cnt_buf_finish); in __vb2_queue_free()
515 vb->cnt_buf_queue, vb->cnt_buf_done); in __vb2_queue_free()
517 vb->cnt_mem_alloc, vb->cnt_mem_put, in __vb2_queue_free()
518 vb->cnt_mem_prepare, vb->cnt_mem_finish, in __vb2_queue_free()
519 vb->cnt_mem_mmap); in __vb2_queue_free()
521 vb->cnt_mem_get_userptr, vb->cnt_mem_put_userptr); in __vb2_queue_free()
523 vb->cnt_mem_attach_dmabuf, vb->cnt_mem_detach_dmabuf, in __vb2_queue_free()
524 vb->cnt_mem_map_dmabuf, vb->cnt_mem_unmap_dmabuf); in __vb2_queue_free()
526 vb->cnt_mem_get_dmabuf, in __vb2_queue_free()
527 vb->cnt_mem_num_users, in __vb2_queue_free()
528 vb->cnt_mem_vaddr, in __vb2_queue_free()
529 vb->cnt_mem_cookie); in __vb2_queue_free()
553 static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __verify_planes_array() argument
565 if (b->length < vb->num_planes || b->length > VIDEO_MAX_PLANES) { in __verify_planes_array()
567 "expected %d, got %d\n", vb->num_planes, b->length); in __verify_planes_array()
578 static int __verify_length(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __verify_length() argument
588 for (plane = 0; plane < vb->num_planes; ++plane) { in __verify_length()
592 : vb->v4l2_planes[plane].length; in __verify_length()
605 ? b->length : vb->v4l2_planes[0].length; in __verify_length()
619 static bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb) in __buffer_in_use() argument
622 for (plane = 0; plane < vb->num_planes; ++plane) { in __buffer_in_use()
623 void *mem_priv = vb->planes[plane].mem_priv; in __buffer_in_use()
630 if (mem_priv && call_memop(vb, num_users, mem_priv) > 1) in __buffer_in_use()
654 static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b) in __fill_v4l2_buffer() argument
656 struct vb2_queue *q = vb->vb2_queue; in __fill_v4l2_buffer()
659 memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); in __fill_v4l2_buffer()
660 b->reserved2 = vb->v4l2_buf.reserved2; in __fill_v4l2_buffer()
661 b->reserved = vb->v4l2_buf.reserved; in __fill_v4l2_buffer()
668 b->length = vb->num_planes; in __fill_v4l2_buffer()
669 memcpy(b->m.planes, vb->v4l2_planes, in __fill_v4l2_buffer()
676 b->length = vb->v4l2_planes[0].length; in __fill_v4l2_buffer()
677 b->bytesused = vb->v4l2_planes[0].bytesused; in __fill_v4l2_buffer()
679 b->m.offset = vb->v4l2_planes[0].m.mem_offset; in __fill_v4l2_buffer()
681 b->m.userptr = vb->v4l2_planes[0].m.userptr; in __fill_v4l2_buffer()
683 b->m.fd = vb->v4l2_planes[0].m.fd; in __fill_v4l2_buffer()
701 switch (vb->state) { in __fill_v4l2_buffer()
721 if (__buffer_in_use(q, vb)) in __fill_v4l2_buffer()
740 struct vb2_buffer *vb; in vb2_querybuf() local
752 vb = q->bufs[b->index]; in vb2_querybuf()
753 ret = __verify_planes_array(vb, b); in vb2_querybuf()
755 __fill_v4l2_buffer(vb, b); in vb2_querybuf()
1123 void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no) in vb2_plane_vaddr() argument
1125 if (plane_no > vb->num_planes || !vb->planes[plane_no].mem_priv) in vb2_plane_vaddr()
1128 return call_ptr_memop(vb, vaddr, vb->planes[plane_no].mem_priv); in vb2_plane_vaddr()
1144 void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no) in vb2_plane_cookie() argument
1146 if (plane_no >= vb->num_planes || !vb->planes[plane_no].mem_priv) in vb2_plane_cookie()
1149 return call_ptr_memop(vb, cookie, vb->planes[plane_no].mem_priv); in vb2_plane_cookie()
1172 void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) in vb2_buffer_done() argument
1174 struct vb2_queue *q = vb->vb2_queue; in vb2_buffer_done()
1178 if (WARN_ON(vb->state != VB2_BUF_STATE_ACTIVE)) in vb2_buffer_done()
1191 vb->cnt_buf_done++; in vb2_buffer_done()
1194 vb->v4l2_buf.index, state); in vb2_buffer_done()
1197 for (plane = 0; plane < vb->num_planes; ++plane) in vb2_buffer_done()
1198 call_void_memop(vb, finish, vb->planes[plane].mem_priv); in vb2_buffer_done()
1202 vb->state = state; in vb2_buffer_done()
1204 list_add_tail(&vb->done_entry, &q->done_list); in vb2_buffer_done()
1230 struct vb2_buffer *vb; in vb2_discard_done() local
1234 list_for_each_entry(vb, &q->done_list, done_entry) in vb2_discard_done()
1235 vb->state = VB2_BUF_STATE_ERROR; in vb2_discard_done()
1240 static void vb2_warn_zero_bytesused(struct vb2_buffer *vb) in vb2_warn_zero_bytesused() argument
1251 if (vb->vb2_queue->allow_zero_bytesused) in vb2_warn_zero_bytesused()
1262 static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b, in __fill_vb2_buffer() argument
1269 for (plane = 0; plane < vb->num_planes; ++plane) { in __fill_vb2_buffer()
1277 for (plane = 0; plane < vb->num_planes; ++plane) { in __fill_vb2_buffer()
1303 for (plane = 0; plane < vb->num_planes; ++plane) { in __fill_vb2_buffer()
1308 vb2_warn_zero_bytesused(vb); in __fill_vb2_buffer()
1310 if (vb->vb2_queue->allow_zero_bytesused) in __fill_vb2_buffer()
1345 vb2_warn_zero_bytesused(vb); in __fill_vb2_buffer()
1347 if (vb->vb2_queue->allow_zero_bytesused) in __fill_vb2_buffer()
1358 vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS; in __fill_vb2_buffer()
1359 if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) != in __fill_vb2_buffer()
1366 vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; in __fill_vb2_buffer()
1376 vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TIMECODE; in __fill_vb2_buffer()
1377 vb->v4l2_buf.field = b->field; in __fill_vb2_buffer()
1380 vb->v4l2_buf.flags &= ~V4L2_BUFFER_OUT_FLAGS; in __fill_vb2_buffer()
1387 static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __qbuf_mmap() argument
1389 __fill_vb2_buffer(vb, b, vb->v4l2_planes); in __qbuf_mmap()
1390 return call_vb_qop(vb, buf_prepare, vb); in __qbuf_mmap()
1396 static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __qbuf_userptr() argument
1399 struct vb2_queue *q = vb->vb2_queue; in __qbuf_userptr()
1405 bool reacquired = vb->planes[0].mem_priv == NULL; in __qbuf_userptr()
1407 memset(planes, 0, sizeof(planes[0]) * vb->num_planes); in __qbuf_userptr()
1409 __fill_vb2_buffer(vb, b, planes); in __qbuf_userptr()
1411 for (plane = 0; plane < vb->num_planes; ++plane) { in __qbuf_userptr()
1413 if (vb->v4l2_planes[plane].m.userptr && in __qbuf_userptr()
1414 vb->v4l2_planes[plane].m.userptr == planes[plane].m.userptr in __qbuf_userptr()
1415 && vb->v4l2_planes[plane].length == planes[plane].length) in __qbuf_userptr()
1432 if (vb->planes[plane].mem_priv) { in __qbuf_userptr()
1435 call_void_vb_qop(vb, buf_cleanup, vb); in __qbuf_userptr()
1437 call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv); in __qbuf_userptr()
1440 vb->planes[plane].mem_priv = NULL; in __qbuf_userptr()
1441 memset(&vb->v4l2_planes[plane], 0, sizeof(struct v4l2_plane)); in __qbuf_userptr()
1444 mem_priv = call_ptr_memop(vb, get_userptr, q->alloc_ctx[plane], in __qbuf_userptr()
1453 vb->planes[plane].mem_priv = mem_priv; in __qbuf_userptr()
1460 for (plane = 0; plane < vb->num_planes; ++plane) in __qbuf_userptr()
1461 vb->v4l2_planes[plane] = planes[plane]; in __qbuf_userptr()
1469 ret = call_vb_qop(vb, buf_init, vb); in __qbuf_userptr()
1476 ret = call_vb_qop(vb, buf_prepare, vb); in __qbuf_userptr()
1479 call_void_vb_qop(vb, buf_cleanup, vb); in __qbuf_userptr()
1486 for (plane = 0; plane < vb->num_planes; ++plane) { in __qbuf_userptr()
1487 if (vb->planes[plane].mem_priv) in __qbuf_userptr()
1488 call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv); in __qbuf_userptr()
1489 vb->planes[plane].mem_priv = NULL; in __qbuf_userptr()
1490 vb->v4l2_planes[plane].m.userptr = 0; in __qbuf_userptr()
1491 vb->v4l2_planes[plane].length = 0; in __qbuf_userptr()
1500 static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __qbuf_dmabuf() argument
1503 struct vb2_queue *q = vb->vb2_queue; in __qbuf_dmabuf()
1509 bool reacquired = vb->planes[0].mem_priv == NULL; in __qbuf_dmabuf()
1511 memset(planes, 0, sizeof(planes[0]) * vb->num_planes); in __qbuf_dmabuf()
1513 __fill_vb2_buffer(vb, b, planes); in __qbuf_dmabuf()
1515 for (plane = 0; plane < vb->num_planes; ++plane) { in __qbuf_dmabuf()
1537 if (dbuf == vb->planes[plane].dbuf && in __qbuf_dmabuf()
1538 vb->v4l2_planes[plane].length == planes[plane].length) { in __qbuf_dmabuf()
1547 call_void_vb_qop(vb, buf_cleanup, vb); in __qbuf_dmabuf()
1551 __vb2_plane_dmabuf_put(vb, &vb->planes[plane]); in __qbuf_dmabuf()
1552 memset(&vb->v4l2_planes[plane], 0, sizeof(struct v4l2_plane)); in __qbuf_dmabuf()
1555 mem_priv = call_ptr_memop(vb, attach_dmabuf, q->alloc_ctx[plane], in __qbuf_dmabuf()
1564 vb->planes[plane].dbuf = dbuf; in __qbuf_dmabuf()
1565 vb->planes[plane].mem_priv = mem_priv; in __qbuf_dmabuf()
1572 for (plane = 0; plane < vb->num_planes; ++plane) { in __qbuf_dmabuf()
1573 ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv); in __qbuf_dmabuf()
1579 vb->planes[plane].dbuf_mapped = 1; in __qbuf_dmabuf()
1586 for (plane = 0; plane < vb->num_planes; ++plane) in __qbuf_dmabuf()
1587 vb->v4l2_planes[plane] = planes[plane]; in __qbuf_dmabuf()
1594 ret = call_vb_qop(vb, buf_init, vb); in __qbuf_dmabuf()
1601 ret = call_vb_qop(vb, buf_prepare, vb); in __qbuf_dmabuf()
1604 call_void_vb_qop(vb, buf_cleanup, vb); in __qbuf_dmabuf()
1611 __vb2_buf_dmabuf_put(vb); in __qbuf_dmabuf()
1619 static void __enqueue_in_driver(struct vb2_buffer *vb) in __enqueue_in_driver() argument
1621 struct vb2_queue *q = vb->vb2_queue; in __enqueue_in_driver()
1624 vb->state = VB2_BUF_STATE_ACTIVE; in __enqueue_in_driver()
1628 for (plane = 0; plane < vb->num_planes; ++plane) in __enqueue_in_driver()
1629 call_void_memop(vb, prepare, vb->planes[plane].mem_priv); in __enqueue_in_driver()
1631 call_void_vb_qop(vb, buf_queue, vb); in __enqueue_in_driver()
1634 static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __buf_prepare() argument
1636 struct vb2_queue *q = vb->vb2_queue; in __buf_prepare()
1639 ret = __verify_length(vb, b); in __buf_prepare()
1663 vb->state = VB2_BUF_STATE_PREPARING; in __buf_prepare()
1664 vb->v4l2_buf.timestamp.tv_sec = 0; in __buf_prepare()
1665 vb->v4l2_buf.timestamp.tv_usec = 0; in __buf_prepare()
1666 vb->v4l2_buf.sequence = 0; in __buf_prepare()
1670 ret = __qbuf_mmap(vb, b); in __buf_prepare()
1674 ret = __qbuf_userptr(vb, b); in __buf_prepare()
1678 ret = __qbuf_dmabuf(vb, b); in __buf_prepare()
1687 vb->state = ret ? VB2_BUF_STATE_DEQUEUED : VB2_BUF_STATE_PREPARED; in __buf_prepare()
1736 struct vb2_buffer *vb; in vb2_prepare_buf() local
1748 vb = q->bufs[b->index]; in vb2_prepare_buf()
1749 if (vb->state != VB2_BUF_STATE_DEQUEUED) { in vb2_prepare_buf()
1751 vb->state); in vb2_prepare_buf()
1755 ret = __buf_prepare(vb, b); in vb2_prepare_buf()
1758 __fill_v4l2_buffer(vb, b); in vb2_prepare_buf()
1760 dprintk(1, "prepare of buffer %d succeeded\n", vb->v4l2_buf.index); in vb2_prepare_buf()
1779 struct vb2_buffer *vb; in vb2_start_streaming() local
1786 list_for_each_entry(vb, &q->queued_list, queued_entry) in vb2_start_streaming()
1787 __enqueue_in_driver(vb); in vb2_start_streaming()
1813 vb = q->bufs[i]; in vb2_start_streaming()
1814 if (vb->state == VB2_BUF_STATE_ACTIVE) in vb2_start_streaming()
1815 vb2_buffer_done(vb, VB2_BUF_STATE_QUEUED); in vb2_start_streaming()
1832 struct vb2_buffer *vb; in vb2_internal_qbuf() local
1837 vb = q->bufs[b->index]; in vb2_internal_qbuf()
1839 switch (vb->state) { in vb2_internal_qbuf()
1841 ret = __buf_prepare(vb, b); in vb2_internal_qbuf()
1851 dprintk(1, "invalid buffer state %d\n", vb->state); in vb2_internal_qbuf()
1859 list_add_tail(&vb->queued_entry, &q->queued_list); in vb2_internal_qbuf()
1862 vb->state = VB2_BUF_STATE_QUEUED; in vb2_internal_qbuf()
1870 vb->v4l2_buf.timestamp = b->timestamp; in vb2_internal_qbuf()
1871 vb->v4l2_buf.flags |= b->flags & V4L2_BUF_FLAG_TIMECODE; in vb2_internal_qbuf()
1873 vb->v4l2_buf.timecode = b->timecode; in vb2_internal_qbuf()
1881 __enqueue_in_driver(vb); in vb2_internal_qbuf()
1884 __fill_v4l2_buffer(vb, b); in vb2_internal_qbuf()
1899 dprintk(1, "qbuf of buffer %d succeeded\n", vb->v4l2_buf.index); in vb2_internal_qbuf()
2007 static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb, in __vb2_get_done_vb() argument
2025 *vb = list_first_entry(&q->done_list, struct vb2_buffer, done_entry); in __vb2_get_done_vb()
2030 ret = __verify_planes_array(*vb, b); in __vb2_get_done_vb()
2032 list_del(&(*vb)->done_entry); in __vb2_get_done_vb()
2063 static void __vb2_dqbuf(struct vb2_buffer *vb) in __vb2_dqbuf() argument
2065 struct vb2_queue *q = vb->vb2_queue; in __vb2_dqbuf()
2069 if (vb->state == VB2_BUF_STATE_DEQUEUED) in __vb2_dqbuf()
2072 vb->state = VB2_BUF_STATE_DEQUEUED; in __vb2_dqbuf()
2076 for (i = 0; i < vb->num_planes; ++i) { in __vb2_dqbuf()
2077 if (!vb->planes[i].dbuf_mapped) in __vb2_dqbuf()
2079 call_void_memop(vb, unmap_dmabuf, vb->planes[i].mem_priv); in __vb2_dqbuf()
2080 vb->planes[i].dbuf_mapped = 0; in __vb2_dqbuf()
2086 struct vb2_buffer *vb = NULL; in vb2_internal_dqbuf() local
2093 ret = __vb2_get_done_vb(q, &vb, b, nonblocking); in vb2_internal_dqbuf()
2097 switch (vb->state) { in vb2_internal_dqbuf()
2109 call_void_vb_qop(vb, buf_finish, vb); in vb2_internal_dqbuf()
2112 __fill_v4l2_buffer(vb, b); in vb2_internal_dqbuf()
2114 list_del(&vb->queued_entry); in vb2_internal_dqbuf()
2117 __vb2_dqbuf(vb); in vb2_internal_dqbuf()
2120 vb->v4l2_buf.index, vb->state); in vb2_internal_dqbuf()
2214 struct vb2_buffer *vb = q->bufs[i]; in __vb2_queue_cancel() local
2216 if (vb->state != VB2_BUF_STATE_DEQUEUED) { in __vb2_queue_cancel()
2217 vb->state = VB2_BUF_STATE_PREPARED; in __vb2_queue_cancel()
2218 call_void_vb_qop(vb, buf_finish, vb); in __vb2_queue_cancel()
2220 __vb2_dqbuf(vb); in __vb2_queue_cancel()
2365 struct vb2_buffer *vb; in __find_plane_by_offset() local
2374 vb = q->bufs[buffer]; in __find_plane_by_offset()
2376 for (plane = 0; plane < vb->num_planes; ++plane) { in __find_plane_by_offset()
2377 if (vb->v4l2_planes[plane].m.mem_offset == off) { in __find_plane_by_offset()
2399 struct vb2_buffer *vb = NULL; in vb2_expbuf() local
2429 vb = q->bufs[eb->index]; in vb2_expbuf()
2431 if (eb->plane >= vb->num_planes) { in vb2_expbuf()
2441 vb_plane = &vb->planes[eb->plane]; in vb2_expbuf()
2443 dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv, eb->flags & O_ACCMODE); in vb2_expbuf()
2488 struct vb2_buffer *vb; in vb2_mmap() local
2528 vb = q->bufs[buffer]; in vb2_mmap()
2535 length = PAGE_ALIGN(vb->v4l2_planes[plane].length); in vb2_mmap()
2543 ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma); in vb2_mmap()
2561 struct vb2_buffer *vb; in vb2_get_unmapped_area() local
2578 vb = q->bufs[buffer]; in vb2_get_unmapped_area()
2580 vaddr = vb2_plane_vaddr(vb, plane); in vb2_get_unmapped_area()
2612 struct vb2_buffer *vb = NULL; in vb2_poll() local
2679 vb = list_first_entry(&q->done_list, struct vb2_buffer, in vb2_poll()
2683 if (vb && (vb->state == VB2_BUF_STATE_DONE in vb2_poll()
2684 || vb->state == VB2_BUF_STATE_ERROR)) { in vb2_poll()
3177 struct vb2_buffer *vb; in vb2_thread() local
3199 vb = q->bufs[fileio->b.index]; in vb2_thread()
3201 if (threadio->fnc(vb, threadio->priv)) in vb2_thread()