Lines Matching refs:vb

53 #define log_memop(vb, op)						\  argument
55 (vb)->vb2_queue, (vb)->index, #op, \
56 (vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
58 #define call_memop(vb, op, args...) \ argument
60 struct vb2_queue *_q = (vb)->vb2_queue; \
63 log_memop(vb, op); \
66 (vb)->cnt_mem_ ## op++; \
70 #define call_ptr_memop(vb, op, args...) \ argument
72 struct vb2_queue *_q = (vb)->vb2_queue; \
75 log_memop(vb, op); \
78 (vb)->cnt_mem_ ## op++; \
82 #define call_void_memop(vb, op, args...) \ argument
84 struct vb2_queue *_q = (vb)->vb2_queue; \
86 log_memop(vb, op); \
89 (vb)->cnt_mem_ ## op++; \
115 #define log_vb_qop(vb, op, args...) \ argument
117 (vb)->vb2_queue, (vb)->index, #op, \
118 (vb)->vb2_queue->ops->op ? "" : " (nop)")
120 #define call_vb_qop(vb, op, args...) \ argument
124 log_vb_qop(vb, op); \
125 err = (vb)->vb2_queue->ops->op ? \
126 (vb)->vb2_queue->ops->op(args) : 0; \
128 (vb)->cnt_ ## op++; \
132 #define call_void_vb_qop(vb, op, args...) \ argument
134 log_vb_qop(vb, op); \
135 if ((vb)->vb2_queue->ops->op) \
136 (vb)->vb2_queue->ops->op(args); \
137 (vb)->cnt_ ## op++; \
142 #define call_memop(vb, op, args...) \ argument
143 ((vb)->vb2_queue->mem_ops->op ? \
144 (vb)->vb2_queue->mem_ops->op(args) : 0)
146 #define call_ptr_memop(vb, op, args...) \ argument
147 ((vb)->vb2_queue->mem_ops->op ? \
148 (vb)->vb2_queue->mem_ops->op(args) : NULL)
150 #define call_void_memop(vb, op, args...) \ argument
152 if ((vb)->vb2_queue->mem_ops->op) \
153 (vb)->vb2_queue->mem_ops->op(args); \
165 #define call_vb_qop(vb, op, args...) \ argument
166 ((vb)->vb2_queue->ops->op ? (vb)->vb2_queue->ops->op(args) : 0)
168 #define call_void_vb_qop(vb, op, args...) \ argument
170 if ((vb)->vb2_queue->ops->op) \
171 (vb)->vb2_queue->ops->op(args); \
191 static void __enqueue_in_driver(struct vb2_buffer *vb);
196 static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) in __vb2_buf_mem_alloc() argument
198 struct vb2_queue *q = vb->vb2_queue; in __vb2_buf_mem_alloc()
207 for (plane = 0; plane < vb->num_planes; ++plane) { in __vb2_buf_mem_alloc()
208 unsigned long size = PAGE_ALIGN(vb->planes[plane].length); in __vb2_buf_mem_alloc()
210 mem_priv = call_ptr_memop(vb, alloc, in __vb2_buf_mem_alloc()
220 vb->planes[plane].mem_priv = mem_priv; in __vb2_buf_mem_alloc()
227 call_void_memop(vb, put, vb->planes[plane - 1].mem_priv); in __vb2_buf_mem_alloc()
228 vb->planes[plane - 1].mem_priv = NULL; in __vb2_buf_mem_alloc()
237 static void __vb2_buf_mem_free(struct vb2_buffer *vb) in __vb2_buf_mem_free() argument
241 for (plane = 0; plane < vb->num_planes; ++plane) { in __vb2_buf_mem_free()
242 call_void_memop(vb, put, vb->planes[plane].mem_priv); in __vb2_buf_mem_free()
243 vb->planes[plane].mem_priv = NULL; in __vb2_buf_mem_free()
244 dprintk(3, "freed plane %d of buffer %d\n", plane, vb->index); in __vb2_buf_mem_free()
252 static void __vb2_buf_userptr_put(struct vb2_buffer *vb) in __vb2_buf_userptr_put() argument
256 for (plane = 0; plane < vb->num_planes; ++plane) { in __vb2_buf_userptr_put()
257 if (vb->planes[plane].mem_priv) in __vb2_buf_userptr_put()
258 call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv); in __vb2_buf_userptr_put()
259 vb->planes[plane].mem_priv = NULL; in __vb2_buf_userptr_put()
267 static void __vb2_plane_dmabuf_put(struct vb2_buffer *vb, struct vb2_plane *p) in __vb2_plane_dmabuf_put() argument
273 call_void_memop(vb, unmap_dmabuf, p->mem_priv); in __vb2_plane_dmabuf_put()
275 call_void_memop(vb, detach_dmabuf, p->mem_priv); in __vb2_plane_dmabuf_put()
286 static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) in __vb2_buf_dmabuf_put() argument
290 for (plane = 0; plane < vb->num_planes; ++plane) in __vb2_buf_dmabuf_put()
291 __vb2_plane_dmabuf_put(vb, &vb->planes[plane]); in __vb2_buf_dmabuf_put()
298 static void __setup_offsets(struct vb2_buffer *vb) in __setup_offsets() argument
300 struct vb2_queue *q = vb->vb2_queue; in __setup_offsets()
304 if (vb->index) { in __setup_offsets()
305 struct vb2_buffer *prev = q->bufs[vb->index - 1]; in __setup_offsets()
311 for (plane = 0; plane < vb->num_planes; ++plane) { in __setup_offsets()
312 vb->planes[plane].m.offset = off; in __setup_offsets()
315 vb->index, plane, off); in __setup_offsets()
317 off += vb->planes[plane].length; in __setup_offsets()
334 struct vb2_buffer *vb; in __vb2_queue_alloc() local
343 vb = kzalloc(q->buf_struct_size, GFP_KERNEL); in __vb2_queue_alloc()
344 if (!vb) { in __vb2_queue_alloc()
349 vb->state = VB2_BUF_STATE_DEQUEUED; in __vb2_queue_alloc()
350 vb->vb2_queue = q; in __vb2_queue_alloc()
351 vb->num_planes = num_planes; in __vb2_queue_alloc()
352 vb->index = q->num_buffers + buffer; in __vb2_queue_alloc()
353 vb->type = q->type; in __vb2_queue_alloc()
354 vb->memory = memory; in __vb2_queue_alloc()
356 vb->planes[plane].length = plane_sizes[plane]; in __vb2_queue_alloc()
357 vb->planes[plane].min_length = plane_sizes[plane]; in __vb2_queue_alloc()
359 q->bufs[vb->index] = vb; in __vb2_queue_alloc()
363 ret = __vb2_buf_mem_alloc(vb); in __vb2_queue_alloc()
367 q->bufs[vb->index] = NULL; in __vb2_queue_alloc()
368 kfree(vb); in __vb2_queue_alloc()
371 __setup_offsets(vb); in __vb2_queue_alloc()
377 ret = call_vb_qop(vb, buf_init, vb); in __vb2_queue_alloc()
380 buffer, vb); in __vb2_queue_alloc()
381 __vb2_buf_mem_free(vb); in __vb2_queue_alloc()
382 q->bufs[vb->index] = NULL; in __vb2_queue_alloc()
383 kfree(vb); in __vb2_queue_alloc()
401 struct vb2_buffer *vb; in __vb2_free_mem() local
405 vb = q->bufs[buffer]; in __vb2_free_mem()
406 if (!vb) in __vb2_free_mem()
411 __vb2_buf_mem_free(vb); in __vb2_free_mem()
413 __vb2_buf_dmabuf_put(vb); in __vb2_free_mem()
415 __vb2_buf_userptr_put(vb); in __vb2_free_mem()
449 struct vb2_buffer *vb = q->bufs[buffer]; in __vb2_queue_free() local
451 if (vb && vb->planes[0].mem_priv) in __vb2_queue_free()
452 call_void_vb_qop(vb, buf_cleanup, vb); in __vb2_queue_free()
484 struct vb2_buffer *vb = q->bufs[buffer]; in __vb2_queue_free() local
485 bool unbalanced = vb->cnt_mem_alloc != vb->cnt_mem_put || in __vb2_queue_free()
486 vb->cnt_mem_prepare != vb->cnt_mem_finish || in __vb2_queue_free()
487 vb->cnt_mem_get_userptr != vb->cnt_mem_put_userptr || in __vb2_queue_free()
488 vb->cnt_mem_attach_dmabuf != vb->cnt_mem_detach_dmabuf || in __vb2_queue_free()
489 vb->cnt_mem_map_dmabuf != vb->cnt_mem_unmap_dmabuf || in __vb2_queue_free()
490 vb->cnt_buf_queue != vb->cnt_buf_done || in __vb2_queue_free()
491 vb->cnt_buf_prepare != vb->cnt_buf_finish || in __vb2_queue_free()
492 vb->cnt_buf_init != vb->cnt_buf_cleanup; in __vb2_queue_free()
498 vb->cnt_buf_init, vb->cnt_buf_cleanup, in __vb2_queue_free()
499 vb->cnt_buf_prepare, vb->cnt_buf_finish); in __vb2_queue_free()
501 vb->cnt_buf_queue, vb->cnt_buf_done); in __vb2_queue_free()
503 vb->cnt_mem_alloc, vb->cnt_mem_put, in __vb2_queue_free()
504 vb->cnt_mem_prepare, vb->cnt_mem_finish, in __vb2_queue_free()
505 vb->cnt_mem_mmap); in __vb2_queue_free()
507 vb->cnt_mem_get_userptr, vb->cnt_mem_put_userptr); in __vb2_queue_free()
509 vb->cnt_mem_attach_dmabuf, vb->cnt_mem_detach_dmabuf, in __vb2_queue_free()
510 vb->cnt_mem_map_dmabuf, vb->cnt_mem_unmap_dmabuf); in __vb2_queue_free()
512 vb->cnt_mem_get_dmabuf, in __vb2_queue_free()
513 vb->cnt_mem_num_users, in __vb2_queue_free()
514 vb->cnt_mem_vaddr, in __vb2_queue_free()
515 vb->cnt_mem_cookie); in __vb2_queue_free()
535 bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb) in vb2_buffer_in_use() argument
538 for (plane = 0; plane < vb->num_planes; ++plane) { in vb2_buffer_in_use()
539 void *mem_priv = vb->planes[plane].mem_priv; in vb2_buffer_in_use()
546 if (mem_priv && call_memop(vb, num_users, mem_priv) > 1) in vb2_buffer_in_use()
875 void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no) in vb2_plane_vaddr() argument
877 if (plane_no >= vb->num_planes || !vb->planes[plane_no].mem_priv) in vb2_plane_vaddr()
880 return call_ptr_memop(vb, vaddr, vb->planes[plane_no].mem_priv); in vb2_plane_vaddr()
885 void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no) in vb2_plane_cookie() argument
887 if (plane_no >= vb->num_planes || !vb->planes[plane_no].mem_priv) in vb2_plane_cookie()
890 return call_ptr_memop(vb, cookie, vb->planes[plane_no].mem_priv); in vb2_plane_cookie()
894 void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) in vb2_buffer_done() argument
896 struct vb2_queue *q = vb->vb2_queue; in vb2_buffer_done()
900 if (WARN_ON(vb->state != VB2_BUF_STATE_ACTIVE)) in vb2_buffer_done()
914 vb->cnt_buf_done++; in vb2_buffer_done()
917 vb->index, state); in vb2_buffer_done()
922 for (plane = 0; plane < vb->num_planes; ++plane) in vb2_buffer_done()
923 call_void_memop(vb, finish, vb->planes[plane].mem_priv); in vb2_buffer_done()
929 vb->state = VB2_BUF_STATE_QUEUED; in vb2_buffer_done()
932 list_add_tail(&vb->done_entry, &q->done_list); in vb2_buffer_done()
933 vb->state = state; in vb2_buffer_done()
938 trace_vb2_buf_done(q, vb); in vb2_buffer_done()
945 __enqueue_in_driver(vb); in vb2_buffer_done()
957 struct vb2_buffer *vb; in vb2_discard_done() local
961 list_for_each_entry(vb, &q->done_list, done_entry) in vb2_discard_done()
962 vb->state = VB2_BUF_STATE_ERROR; in vb2_discard_done()
970 static int __prepare_mmap(struct vb2_buffer *vb, const void *pb) in __prepare_mmap() argument
975 ret = call_bufop(vb->vb2_queue, fill_vb2_buffer, in __prepare_mmap()
976 vb, pb, vb->planes); in __prepare_mmap()
977 return ret ? ret : call_vb_qop(vb, buf_prepare, vb); in __prepare_mmap()
983 static int __prepare_userptr(struct vb2_buffer *vb, const void *pb) in __prepare_userptr() argument
986 struct vb2_queue *q = vb->vb2_queue; in __prepare_userptr()
990 bool reacquired = vb->planes[0].mem_priv == NULL; in __prepare_userptr()
992 memset(planes, 0, sizeof(planes[0]) * vb->num_planes); in __prepare_userptr()
995 ret = call_bufop(vb->vb2_queue, fill_vb2_buffer, in __prepare_userptr()
996 vb, pb, planes); in __prepare_userptr()
1001 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_userptr()
1003 if (vb->planes[plane].m.userptr && in __prepare_userptr()
1004 vb->planes[plane].m.userptr == planes[plane].m.userptr in __prepare_userptr()
1005 && vb->planes[plane].length == planes[plane].length) in __prepare_userptr()
1012 if (planes[plane].length < vb->planes[plane].min_length) { in __prepare_userptr()
1015 vb->planes[plane].min_length, in __prepare_userptr()
1022 if (vb->planes[plane].mem_priv) { in __prepare_userptr()
1025 call_void_vb_qop(vb, buf_cleanup, vb); in __prepare_userptr()
1027 call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv); in __prepare_userptr()
1030 vb->planes[plane].mem_priv = NULL; in __prepare_userptr()
1031 vb->planes[plane].bytesused = 0; in __prepare_userptr()
1032 vb->planes[plane].length = 0; in __prepare_userptr()
1033 vb->planes[plane].m.userptr = 0; in __prepare_userptr()
1034 vb->planes[plane].data_offset = 0; in __prepare_userptr()
1037 mem_priv = call_ptr_memop(vb, get_userptr, in __prepare_userptr()
1047 vb->planes[plane].mem_priv = mem_priv; in __prepare_userptr()
1054 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_userptr()
1055 vb->planes[plane].bytesused = planes[plane].bytesused; in __prepare_userptr()
1056 vb->planes[plane].length = planes[plane].length; in __prepare_userptr()
1057 vb->planes[plane].m.userptr = planes[plane].m.userptr; in __prepare_userptr()
1058 vb->planes[plane].data_offset = planes[plane].data_offset; in __prepare_userptr()
1067 ret = call_vb_qop(vb, buf_init, vb); in __prepare_userptr()
1074 ret = call_vb_qop(vb, buf_prepare, vb); in __prepare_userptr()
1077 call_void_vb_qop(vb, buf_cleanup, vb); in __prepare_userptr()
1084 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_userptr()
1085 if (vb->planes[plane].mem_priv) in __prepare_userptr()
1086 call_void_memop(vb, put_userptr, in __prepare_userptr()
1087 vb->planes[plane].mem_priv); in __prepare_userptr()
1088 vb->planes[plane].mem_priv = NULL; in __prepare_userptr()
1089 vb->planes[plane].m.userptr = 0; in __prepare_userptr()
1090 vb->planes[plane].length = 0; in __prepare_userptr()
1099 static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb) in __prepare_dmabuf() argument
1102 struct vb2_queue *q = vb->vb2_queue; in __prepare_dmabuf()
1106 bool reacquired = vb->planes[0].mem_priv == NULL; in __prepare_dmabuf()
1108 memset(planes, 0, sizeof(planes[0]) * vb->num_planes); in __prepare_dmabuf()
1111 ret = call_bufop(vb->vb2_queue, fill_vb2_buffer, in __prepare_dmabuf()
1112 vb, pb, planes); in __prepare_dmabuf()
1117 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_dmabuf()
1131 if (planes[plane].length < vb->planes[plane].min_length) { in __prepare_dmabuf()
1134 vb->planes[plane].min_length); in __prepare_dmabuf()
1141 if (dbuf == vb->planes[plane].dbuf && in __prepare_dmabuf()
1142 vb->planes[plane].length == planes[plane].length) { in __prepare_dmabuf()
1151 call_void_vb_qop(vb, buf_cleanup, vb); in __prepare_dmabuf()
1155 __vb2_plane_dmabuf_put(vb, &vb->planes[plane]); in __prepare_dmabuf()
1156 vb->planes[plane].bytesused = 0; in __prepare_dmabuf()
1157 vb->planes[plane].length = 0; in __prepare_dmabuf()
1158 vb->planes[plane].m.fd = 0; in __prepare_dmabuf()
1159 vb->planes[plane].data_offset = 0; in __prepare_dmabuf()
1162 mem_priv = call_ptr_memop(vb, attach_dmabuf, in __prepare_dmabuf()
1172 vb->planes[plane].dbuf = dbuf; in __prepare_dmabuf()
1173 vb->planes[plane].mem_priv = mem_priv; in __prepare_dmabuf()
1181 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_dmabuf()
1182 ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv); in __prepare_dmabuf()
1188 vb->planes[plane].dbuf_mapped = 1; in __prepare_dmabuf()
1195 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_dmabuf()
1196 vb->planes[plane].bytesused = planes[plane].bytesused; in __prepare_dmabuf()
1197 vb->planes[plane].length = planes[plane].length; in __prepare_dmabuf()
1198 vb->planes[plane].m.fd = planes[plane].m.fd; in __prepare_dmabuf()
1199 vb->planes[plane].data_offset = planes[plane].data_offset; in __prepare_dmabuf()
1207 ret = call_vb_qop(vb, buf_init, vb); in __prepare_dmabuf()
1214 ret = call_vb_qop(vb, buf_prepare, vb); in __prepare_dmabuf()
1217 call_void_vb_qop(vb, buf_cleanup, vb); in __prepare_dmabuf()
1224 __vb2_buf_dmabuf_put(vb); in __prepare_dmabuf()
1232 static void __enqueue_in_driver(struct vb2_buffer *vb) in __enqueue_in_driver() argument
1234 struct vb2_queue *q = vb->vb2_queue; in __enqueue_in_driver()
1236 vb->state = VB2_BUF_STATE_ACTIVE; in __enqueue_in_driver()
1239 trace_vb2_buf_queue(q, vb); in __enqueue_in_driver()
1241 call_void_vb_qop(vb, buf_queue, vb); in __enqueue_in_driver()
1244 static int __buf_prepare(struct vb2_buffer *vb, const void *pb) in __buf_prepare() argument
1246 struct vb2_queue *q = vb->vb2_queue; in __buf_prepare()
1255 vb->state = VB2_BUF_STATE_PREPARING; in __buf_prepare()
1259 ret = __prepare_mmap(vb, pb); in __buf_prepare()
1262 ret = __prepare_userptr(vb, pb); in __buf_prepare()
1265 ret = __prepare_dmabuf(vb, pb); in __buf_prepare()
1274 vb->state = VB2_BUF_STATE_DEQUEUED; in __buf_prepare()
1279 for (plane = 0; plane < vb->num_planes; ++plane) in __buf_prepare()
1280 call_void_memop(vb, prepare, vb->planes[plane].mem_priv); in __buf_prepare()
1282 vb->state = VB2_BUF_STATE_PREPARED; in __buf_prepare()
1289 struct vb2_buffer *vb; in vb2_core_prepare_buf() local
1292 vb = q->bufs[index]; in vb2_core_prepare_buf()
1293 if (vb->state != VB2_BUF_STATE_DEQUEUED) { in vb2_core_prepare_buf()
1295 vb->state); in vb2_core_prepare_buf()
1299 ret = __buf_prepare(vb, pb); in vb2_core_prepare_buf()
1304 call_void_bufop(q, fill_user_buffer, vb, pb); in vb2_core_prepare_buf()
1306 dprintk(2, "prepare of buffer %d succeeded\n", vb->index); in vb2_core_prepare_buf()
1325 struct vb2_buffer *vb; in vb2_start_streaming() local
1332 list_for_each_entry(vb, &q->queued_list, queued_entry) in vb2_start_streaming()
1333 __enqueue_in_driver(vb); in vb2_start_streaming()
1359 vb = q->bufs[i]; in vb2_start_streaming()
1360 if (vb->state == VB2_BUF_STATE_ACTIVE) in vb2_start_streaming()
1361 vb2_buffer_done(vb, VB2_BUF_STATE_QUEUED); in vb2_start_streaming()
1377 struct vb2_buffer *vb; in vb2_core_qbuf() local
1385 vb = q->bufs[index]; in vb2_core_qbuf()
1387 switch (vb->state) { in vb2_core_qbuf()
1389 ret = __buf_prepare(vb, pb); in vb2_core_qbuf()
1399 dprintk(1, "invalid buffer state %d\n", vb->state); in vb2_core_qbuf()
1407 list_add_tail(&vb->queued_entry, &q->queued_list); in vb2_core_qbuf()
1410 vb->state = VB2_BUF_STATE_QUEUED; in vb2_core_qbuf()
1413 call_void_bufop(q, copy_timestamp, vb, pb); in vb2_core_qbuf()
1415 trace_vb2_qbuf(q, vb); in vb2_core_qbuf()
1422 __enqueue_in_driver(vb); in vb2_core_qbuf()
1426 call_void_bufop(q, fill_user_buffer, vb, pb); in vb2_core_qbuf()
1441 dprintk(2, "qbuf of buffer %d succeeded\n", vb->index); in vb2_core_qbuf()
1526 static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb, in __vb2_get_done_vb() argument
1544 *vb = list_first_entry(&q->done_list, struct vb2_buffer, done_entry); in __vb2_get_done_vb()
1551 ret = call_bufop(q, verify_planes_array, *vb, pb); in __vb2_get_done_vb()
1553 list_del(&(*vb)->done_entry); in __vb2_get_done_vb()
1575 static void __vb2_dqbuf(struct vb2_buffer *vb) in __vb2_dqbuf() argument
1577 struct vb2_queue *q = vb->vb2_queue; in __vb2_dqbuf()
1581 if (vb->state == VB2_BUF_STATE_DEQUEUED) in __vb2_dqbuf()
1584 vb->state = VB2_BUF_STATE_DEQUEUED; in __vb2_dqbuf()
1588 for (i = 0; i < vb->num_planes; ++i) { in __vb2_dqbuf()
1589 if (!vb->planes[i].dbuf_mapped) in __vb2_dqbuf()
1591 call_void_memop(vb, unmap_dmabuf, vb->planes[i].mem_priv); in __vb2_dqbuf()
1592 vb->planes[i].dbuf_mapped = 0; in __vb2_dqbuf()
1599 struct vb2_buffer *vb = NULL; in vb2_core_dqbuf() local
1602 ret = __vb2_get_done_vb(q, &vb, pb, nonblocking); in vb2_core_dqbuf()
1606 switch (vb->state) { in vb2_core_dqbuf()
1618 call_void_vb_qop(vb, buf_finish, vb); in vb2_core_dqbuf()
1621 *pindex = vb->index; in vb2_core_dqbuf()
1625 call_void_bufop(q, fill_user_buffer, vb, pb); in vb2_core_dqbuf()
1628 list_del(&vb->queued_entry); in vb2_core_dqbuf()
1631 trace_vb2_dqbuf(q, vb); in vb2_core_dqbuf()
1634 __vb2_dqbuf(vb); in vb2_core_dqbuf()
1637 vb->index, vb->state); in vb2_core_dqbuf()
1705 struct vb2_buffer *vb = q->bufs[i]; in __vb2_queue_cancel() local
1707 if (vb->state == VB2_BUF_STATE_PREPARED || in __vb2_queue_cancel()
1708 vb->state == VB2_BUF_STATE_QUEUED) { in __vb2_queue_cancel()
1711 for (plane = 0; plane < vb->num_planes; ++plane) in __vb2_queue_cancel()
1712 call_void_memop(vb, finish, in __vb2_queue_cancel()
1713 vb->planes[plane].mem_priv); in __vb2_queue_cancel()
1716 if (vb->state != VB2_BUF_STATE_DEQUEUED) { in __vb2_queue_cancel()
1717 vb->state = VB2_BUF_STATE_PREPARED; in __vb2_queue_cancel()
1718 call_void_vb_qop(vb, buf_finish, vb); in __vb2_queue_cancel()
1720 __vb2_dqbuf(vb); in __vb2_queue_cancel()
1810 struct vb2_buffer *vb; in __find_plane_by_offset() local
1819 vb = q->bufs[buffer]; in __find_plane_by_offset()
1821 for (plane = 0; plane < vb->num_planes; ++plane) { in __find_plane_by_offset()
1822 if (vb->planes[plane].m.offset == off) { in __find_plane_by_offset()
1836 struct vb2_buffer *vb = NULL; in vb2_core_expbuf() local
1866 vb = q->bufs[index]; in vb2_core_expbuf()
1868 if (plane >= vb->num_planes) { in vb2_core_expbuf()
1878 vb_plane = &vb->planes[plane]; in vb2_core_expbuf()
1880 dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv, in vb2_core_expbuf()
1907 struct vb2_buffer *vb; in vb2_mmap() local
1947 vb = q->bufs[buffer]; in vb2_mmap()
1954 length = PAGE_ALIGN(vb->planes[plane].length); in vb2_mmap()
1962 ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma); in vb2_mmap()
1980 struct vb2_buffer *vb; in vb2_get_unmapped_area() local
1997 vb = q->bufs[buffer]; in vb2_get_unmapped_area()
1999 vaddr = vb2_plane_vaddr(vb, plane); in vb2_get_unmapped_area()
2055 struct vb2_buffer *vb = NULL; in vb2_core_poll() local
2123 vb = list_first_entry(&q->done_list, struct vb2_buffer, in vb2_core_poll()
2127 if (vb && (vb->state == VB2_BUF_STATE_DONE in vb2_core_poll()
2128 || vb->state == VB2_BUF_STATE_ERROR)) { in vb2_core_poll()
2529 struct vb2_buffer *vb; in vb2_thread() local
2535 vb = q->bufs[index++]; in vb2_thread()
2544 vb = q->bufs[index]; in vb2_thread()
2550 if (vb->state != VB2_BUF_STATE_ERROR) in vb2_thread()
2551 if (threadio->fnc(vb, threadio->priv)) in vb2_thread()
2555 vb->timestamp = ktime_get_ns(); in vb2_thread()
2557 ret = vb2_core_qbuf(q, vb->index, NULL); in vb2_thread()