• Home
  • Raw
  • Download

Lines Matching refs:vb

54 #define log_memop(vb, op)						\  argument
55 dprintk((vb)->vb2_queue, 2, "call_memop(%d, %s)%s\n", \
56 (vb)->index, #op, \
57 (vb)->vb2_queue->mem_ops->op ? "" : " (nop)")
59 #define call_memop(vb, op, args...) \ argument
61 struct vb2_queue *_q = (vb)->vb2_queue; \
64 log_memop(vb, op); \
67 (vb)->cnt_mem_ ## op++; \
71 #define call_ptr_memop(op, vb, args...) \ argument
73 struct vb2_queue *_q = (vb)->vb2_queue; \
76 log_memop(vb, op); \
77 ptr = _q->mem_ops->op ? _q->mem_ops->op(vb, args) : NULL; \
79 (vb)->cnt_mem_ ## op++; \
83 #define call_void_memop(vb, op, args...) \ argument
85 struct vb2_queue *_q = (vb)->vb2_queue; \
87 log_memop(vb, op); \
90 (vb)->cnt_mem_ ## op++; \
116 #define log_vb_qop(vb, op, args...) \ argument
117 dprintk((vb)->vb2_queue, 2, "call_vb_qop(%d, %s)%s\n", \
118 (vb)->index, #op, \
119 (vb)->vb2_queue->ops->op ? "" : " (nop)")
121 #define call_vb_qop(vb, op, args...) \ argument
125 log_vb_qop(vb, op); \
126 err = (vb)->vb2_queue->ops->op ? \
127 (vb)->vb2_queue->ops->op(args) : 0; \
129 (vb)->cnt_ ## op++; \
133 #define call_void_vb_qop(vb, op, args...) \ argument
135 log_vb_qop(vb, op); \
136 if ((vb)->vb2_queue->ops->op) \
137 (vb)->vb2_queue->ops->op(args); \
138 (vb)->cnt_ ## op++; \
143 #define call_memop(vb, op, args...) \ argument
144 ((vb)->vb2_queue->mem_ops->op ? \
145 (vb)->vb2_queue->mem_ops->op(args) : 0)
147 #define call_ptr_memop(op, vb, args...) \ argument
148 ((vb)->vb2_queue->mem_ops->op ? \
149 (vb)->vb2_queue->mem_ops->op(vb, args) : NULL)
151 #define call_void_memop(vb, op, args...) \ argument
153 if ((vb)->vb2_queue->mem_ops->op) \
154 (vb)->vb2_queue->mem_ops->op(args); \
166 #define call_vb_qop(vb, op, args...) \ argument
167 ((vb)->vb2_queue->ops->op ? (vb)->vb2_queue->ops->op(args) : 0)
169 #define call_void_vb_qop(vb, op, args...) \ argument
171 if ((vb)->vb2_queue->ops->op) \
172 (vb)->vb2_queue->ops->op(args); \
192 static void __enqueue_in_driver(struct vb2_buffer *vb);
214 static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) in __vb2_buf_mem_alloc() argument
216 struct vb2_queue *q = vb->vb2_queue; in __vb2_buf_mem_alloc()
225 for (plane = 0; plane < vb->num_planes; ++plane) { in __vb2_buf_mem_alloc()
227 unsigned long size = PAGE_ALIGN(vb->planes[plane].length); in __vb2_buf_mem_alloc()
230 if (size < vb->planes[plane].length) in __vb2_buf_mem_alloc()
234 vb, in __vb2_buf_mem_alloc()
244 vb->planes[plane].mem_priv = mem_priv; in __vb2_buf_mem_alloc()
251 call_void_memop(vb, put, vb->planes[plane - 1].mem_priv); in __vb2_buf_mem_alloc()
252 vb->planes[plane - 1].mem_priv = NULL; in __vb2_buf_mem_alloc()
261 static void __vb2_buf_mem_free(struct vb2_buffer *vb) in __vb2_buf_mem_free() argument
265 for (plane = 0; plane < vb->num_planes; ++plane) { in __vb2_buf_mem_free()
266 call_void_memop(vb, put, vb->planes[plane].mem_priv); in __vb2_buf_mem_free()
267 vb->planes[plane].mem_priv = NULL; in __vb2_buf_mem_free()
268 dprintk(vb->vb2_queue, 3, "freed plane %d of buffer %d\n", in __vb2_buf_mem_free()
269 plane, vb->index); in __vb2_buf_mem_free()
277 static void __vb2_buf_userptr_put(struct vb2_buffer *vb) in __vb2_buf_userptr_put() argument
281 for (plane = 0; plane < vb->num_planes; ++plane) { in __vb2_buf_userptr_put()
282 if (vb->planes[plane].mem_priv) in __vb2_buf_userptr_put()
283 call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv); in __vb2_buf_userptr_put()
284 vb->planes[plane].mem_priv = NULL; in __vb2_buf_userptr_put()
292 static void __vb2_plane_dmabuf_put(struct vb2_buffer *vb, struct vb2_plane *p) in __vb2_plane_dmabuf_put() argument
298 call_void_memop(vb, unmap_dmabuf, p->mem_priv); in __vb2_plane_dmabuf_put()
300 call_void_memop(vb, detach_dmabuf, p->mem_priv); in __vb2_plane_dmabuf_put()
311 static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) in __vb2_buf_dmabuf_put() argument
315 for (plane = 0; plane < vb->num_planes; ++plane) in __vb2_buf_dmabuf_put()
316 __vb2_plane_dmabuf_put(vb, &vb->planes[plane]); in __vb2_buf_dmabuf_put()
323 static void __vb2_buf_mem_prepare(struct vb2_buffer *vb) in __vb2_buf_mem_prepare() argument
327 if (vb->synced) in __vb2_buf_mem_prepare()
330 vb->synced = 1; in __vb2_buf_mem_prepare()
331 for (plane = 0; plane < vb->num_planes; ++plane) in __vb2_buf_mem_prepare()
332 call_void_memop(vb, prepare, vb->planes[plane].mem_priv); in __vb2_buf_mem_prepare()
339 static void __vb2_buf_mem_finish(struct vb2_buffer *vb) in __vb2_buf_mem_finish() argument
343 if (!vb->synced) in __vb2_buf_mem_finish()
346 vb->synced = 0; in __vb2_buf_mem_finish()
347 for (plane = 0; plane < vb->num_planes; ++plane) in __vb2_buf_mem_finish()
348 call_void_memop(vb, finish, vb->planes[plane].mem_priv); in __vb2_buf_mem_finish()
355 static void __setup_offsets(struct vb2_buffer *vb) in __setup_offsets() argument
357 struct vb2_queue *q = vb->vb2_queue; in __setup_offsets()
361 if (vb->index) { in __setup_offsets()
362 struct vb2_buffer *prev = q->bufs[vb->index - 1]; in __setup_offsets()
368 for (plane = 0; plane < vb->num_planes; ++plane) { in __setup_offsets()
369 vb->planes[plane].m.offset = off; in __setup_offsets()
372 vb->index, plane, off); in __setup_offsets()
374 off += vb->planes[plane].length; in __setup_offsets()
379 static void init_buffer_cache_hints(struct vb2_queue *q, struct vb2_buffer *vb) in init_buffer_cache_hints() argument
387 vb->skip_cache_sync_on_finish = 1; in init_buffer_cache_hints()
388 vb->skip_cache_sync_on_prepare = 1; in init_buffer_cache_hints()
397 vb->skip_cache_sync_on_finish = 1; in init_buffer_cache_hints()
412 struct vb2_buffer *vb; in __vb2_queue_alloc() local
421 vb = kzalloc(q->buf_struct_size, GFP_KERNEL); in __vb2_queue_alloc()
422 if (!vb) { in __vb2_queue_alloc()
427 vb->state = VB2_BUF_STATE_DEQUEUED; in __vb2_queue_alloc()
428 vb->vb2_queue = q; in __vb2_queue_alloc()
429 vb->num_planes = num_planes; in __vb2_queue_alloc()
430 vb->index = q->num_buffers + buffer; in __vb2_queue_alloc()
431 vb->type = q->type; in __vb2_queue_alloc()
432 vb->memory = memory; in __vb2_queue_alloc()
433 init_buffer_cache_hints(q, vb); in __vb2_queue_alloc()
435 vb->planes[plane].length = plane_sizes[plane]; in __vb2_queue_alloc()
436 vb->planes[plane].min_length = plane_sizes[plane]; in __vb2_queue_alloc()
438 call_void_bufop(q, init_buffer, vb); in __vb2_queue_alloc()
440 q->bufs[vb->index] = vb; in __vb2_queue_alloc()
444 ret = __vb2_buf_mem_alloc(vb); in __vb2_queue_alloc()
448 q->bufs[vb->index] = NULL; in __vb2_queue_alloc()
449 kfree(vb); in __vb2_queue_alloc()
452 __setup_offsets(vb); in __vb2_queue_alloc()
458 ret = call_vb_qop(vb, buf_init, vb); in __vb2_queue_alloc()
461 buffer, vb); in __vb2_queue_alloc()
462 __vb2_buf_mem_free(vb); in __vb2_queue_alloc()
463 q->bufs[vb->index] = NULL; in __vb2_queue_alloc()
464 kfree(vb); in __vb2_queue_alloc()
482 struct vb2_buffer *vb; in __vb2_free_mem() local
486 vb = q->bufs[buffer]; in __vb2_free_mem()
487 if (!vb) in __vb2_free_mem()
492 __vb2_buf_mem_free(vb); in __vb2_free_mem()
494 __vb2_buf_dmabuf_put(vb); in __vb2_free_mem()
496 __vb2_buf_userptr_put(vb); in __vb2_free_mem()
530 struct vb2_buffer *vb = q->bufs[buffer]; in __vb2_queue_free() local
532 if (vb && vb->planes[0].mem_priv) in __vb2_queue_free()
533 call_void_vb_qop(vb, buf_cleanup, vb); in __vb2_queue_free()
565 struct vb2_buffer *vb = q->bufs[buffer]; in __vb2_queue_free() local
566 bool unbalanced = vb->cnt_mem_alloc != vb->cnt_mem_put || in __vb2_queue_free()
567 vb->cnt_mem_prepare != vb->cnt_mem_finish || in __vb2_queue_free()
568 vb->cnt_mem_get_userptr != vb->cnt_mem_put_userptr || in __vb2_queue_free()
569 vb->cnt_mem_attach_dmabuf != vb->cnt_mem_detach_dmabuf || in __vb2_queue_free()
570 vb->cnt_mem_map_dmabuf != vb->cnt_mem_unmap_dmabuf || in __vb2_queue_free()
571 vb->cnt_buf_queue != vb->cnt_buf_done || in __vb2_queue_free()
572 vb->cnt_buf_prepare != vb->cnt_buf_finish || in __vb2_queue_free()
573 vb->cnt_buf_init != vb->cnt_buf_cleanup; in __vb2_queue_free()
579 vb->cnt_buf_init, vb->cnt_buf_cleanup, in __vb2_queue_free()
580 vb->cnt_buf_prepare, vb->cnt_buf_finish); in __vb2_queue_free()
582 vb->cnt_buf_out_validate, vb->cnt_buf_queue, in __vb2_queue_free()
583 vb->cnt_buf_done, vb->cnt_buf_request_complete); in __vb2_queue_free()
585 vb->cnt_mem_alloc, vb->cnt_mem_put, in __vb2_queue_free()
586 vb->cnt_mem_prepare, vb->cnt_mem_finish, in __vb2_queue_free()
587 vb->cnt_mem_mmap); in __vb2_queue_free()
589 vb->cnt_mem_get_userptr, vb->cnt_mem_put_userptr); in __vb2_queue_free()
591 vb->cnt_mem_attach_dmabuf, vb->cnt_mem_detach_dmabuf, in __vb2_queue_free()
592 vb->cnt_mem_map_dmabuf, vb->cnt_mem_unmap_dmabuf); in __vb2_queue_free()
594 vb->cnt_mem_get_dmabuf, in __vb2_queue_free()
595 vb->cnt_mem_num_users, in __vb2_queue_free()
596 vb->cnt_mem_vaddr, in __vb2_queue_free()
597 vb->cnt_mem_cookie); in __vb2_queue_free()
617 bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb) in vb2_buffer_in_use() argument
620 for (plane = 0; plane < vb->num_planes; ++plane) { in vb2_buffer_in_use()
621 void *mem_priv = vb->planes[plane].mem_priv; in vb2_buffer_in_use()
628 if (mem_priv && call_memop(vb, num_users, mem_priv) > 1) in vb2_buffer_in_use()
1039 void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no) in vb2_plane_vaddr() argument
1041 if (plane_no >= vb->num_planes || !vb->planes[plane_no].mem_priv) in vb2_plane_vaddr()
1044 return call_ptr_memop(vaddr, vb, vb->planes[plane_no].mem_priv); in vb2_plane_vaddr()
1049 void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no) in vb2_plane_cookie() argument
1051 if (plane_no >= vb->num_planes || !vb->planes[plane_no].mem_priv) in vb2_plane_cookie()
1054 return call_ptr_memop(cookie, vb, vb->planes[plane_no].mem_priv); in vb2_plane_cookie()
1058 void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) in vb2_buffer_done() argument
1060 struct vb2_queue *q = vb->vb2_queue; in vb2_buffer_done()
1063 if (WARN_ON(vb->state != VB2_BUF_STATE_ACTIVE)) in vb2_buffer_done()
1076 vb->cnt_buf_done++; in vb2_buffer_done()
1079 vb->index, vb2_state_name(state)); in vb2_buffer_done()
1082 __vb2_buf_mem_finish(vb); in vb2_buffer_done()
1086 vb->state = VB2_BUF_STATE_QUEUED; in vb2_buffer_done()
1089 list_add_tail(&vb->done_entry, &q->done_list); in vb2_buffer_done()
1090 vb->state = state; in vb2_buffer_done()
1094 if (state != VB2_BUF_STATE_QUEUED && vb->req_obj.req) { in vb2_buffer_done()
1095 media_request_object_unbind(&vb->req_obj); in vb2_buffer_done()
1096 media_request_object_put(&vb->req_obj); in vb2_buffer_done()
1101 trace_vb2_buf_done(q, vb); in vb2_buffer_done()
1116 struct vb2_buffer *vb; in vb2_discard_done() local
1120 list_for_each_entry(vb, &q->done_list, done_entry) in vb2_discard_done()
1121 vb->state = VB2_BUF_STATE_ERROR; in vb2_discard_done()
1129 static int __prepare_mmap(struct vb2_buffer *vb) in __prepare_mmap() argument
1133 ret = call_bufop(vb->vb2_queue, fill_vb2_buffer, in __prepare_mmap()
1134 vb, vb->planes); in __prepare_mmap()
1135 return ret ? ret : call_vb_qop(vb, buf_prepare, vb); in __prepare_mmap()
1141 static int __prepare_userptr(struct vb2_buffer *vb) in __prepare_userptr() argument
1144 struct vb2_queue *q = vb->vb2_queue; in __prepare_userptr()
1148 bool reacquired = vb->planes[0].mem_priv == NULL; in __prepare_userptr()
1150 memset(planes, 0, sizeof(planes[0]) * vb->num_planes); in __prepare_userptr()
1152 ret = call_bufop(vb->vb2_queue, fill_vb2_buffer, in __prepare_userptr()
1153 vb, planes); in __prepare_userptr()
1157 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_userptr()
1159 if (vb->planes[plane].m.userptr && in __prepare_userptr()
1160 vb->planes[plane].m.userptr == planes[plane].m.userptr in __prepare_userptr()
1161 && vb->planes[plane].length == planes[plane].length) in __prepare_userptr()
1168 if (planes[plane].length < vb->planes[plane].min_length) { in __prepare_userptr()
1171 vb->planes[plane].min_length, in __prepare_userptr()
1178 if (vb->planes[plane].mem_priv) { in __prepare_userptr()
1181 vb->copied_timestamp = 0; in __prepare_userptr()
1182 call_void_vb_qop(vb, buf_cleanup, vb); in __prepare_userptr()
1184 call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv); in __prepare_userptr()
1187 vb->planes[plane].mem_priv = NULL; in __prepare_userptr()
1188 vb->planes[plane].bytesused = 0; in __prepare_userptr()
1189 vb->planes[plane].length = 0; in __prepare_userptr()
1190 vb->planes[plane].m.userptr = 0; in __prepare_userptr()
1191 vb->planes[plane].data_offset = 0; in __prepare_userptr()
1195 vb, in __prepare_userptr()
1205 vb->planes[plane].mem_priv = mem_priv; in __prepare_userptr()
1212 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_userptr()
1213 vb->planes[plane].bytesused = planes[plane].bytesused; in __prepare_userptr()
1214 vb->planes[plane].length = planes[plane].length; in __prepare_userptr()
1215 vb->planes[plane].m.userptr = planes[plane].m.userptr; in __prepare_userptr()
1216 vb->planes[plane].data_offset = planes[plane].data_offset; in __prepare_userptr()
1225 ret = call_vb_qop(vb, buf_init, vb); in __prepare_userptr()
1232 ret = call_vb_qop(vb, buf_prepare, vb); in __prepare_userptr()
1235 call_void_vb_qop(vb, buf_cleanup, vb); in __prepare_userptr()
1242 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_userptr()
1243 if (vb->planes[plane].mem_priv) in __prepare_userptr()
1244 call_void_memop(vb, put_userptr, in __prepare_userptr()
1245 vb->planes[plane].mem_priv); in __prepare_userptr()
1246 vb->planes[plane].mem_priv = NULL; in __prepare_userptr()
1247 vb->planes[plane].m.userptr = 0; in __prepare_userptr()
1248 vb->planes[plane].length = 0; in __prepare_userptr()
1257 static int __prepare_dmabuf(struct vb2_buffer *vb) in __prepare_dmabuf() argument
1260 struct vb2_queue *q = vb->vb2_queue; in __prepare_dmabuf()
1264 bool reacquired = vb->planes[0].mem_priv == NULL; in __prepare_dmabuf()
1266 memset(planes, 0, sizeof(planes[0]) * vb->num_planes); in __prepare_dmabuf()
1268 ret = call_bufop(vb->vb2_queue, fill_vb2_buffer, in __prepare_dmabuf()
1269 vb, planes); in __prepare_dmabuf()
1273 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_dmabuf()
1287 if (planes[plane].length < vb->planes[plane].min_length) { in __prepare_dmabuf()
1290 vb->planes[plane].min_length); in __prepare_dmabuf()
1297 if (dbuf == vb->planes[plane].dbuf && in __prepare_dmabuf()
1298 vb->planes[plane].length == planes[plane].length) { in __prepare_dmabuf()
1307 vb->copied_timestamp = 0; in __prepare_dmabuf()
1308 call_void_vb_qop(vb, buf_cleanup, vb); in __prepare_dmabuf()
1312 __vb2_plane_dmabuf_put(vb, &vb->planes[plane]); in __prepare_dmabuf()
1313 vb->planes[plane].bytesused = 0; in __prepare_dmabuf()
1314 vb->planes[plane].length = 0; in __prepare_dmabuf()
1315 vb->planes[plane].m.fd = 0; in __prepare_dmabuf()
1316 vb->planes[plane].data_offset = 0; in __prepare_dmabuf()
1320 vb, in __prepare_dmabuf()
1331 vb->planes[plane].dbuf = dbuf; in __prepare_dmabuf()
1332 vb->planes[plane].mem_priv = mem_priv; in __prepare_dmabuf()
1340 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_dmabuf()
1341 if (vb->planes[plane].dbuf_mapped) in __prepare_dmabuf()
1344 ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv); in __prepare_dmabuf()
1350 vb->planes[plane].dbuf_mapped = 1; in __prepare_dmabuf()
1357 for (plane = 0; plane < vb->num_planes; ++plane) { in __prepare_dmabuf()
1358 vb->planes[plane].bytesused = planes[plane].bytesused; in __prepare_dmabuf()
1359 vb->planes[plane].length = planes[plane].length; in __prepare_dmabuf()
1360 vb->planes[plane].m.fd = planes[plane].m.fd; in __prepare_dmabuf()
1361 vb->planes[plane].data_offset = planes[plane].data_offset; in __prepare_dmabuf()
1369 ret = call_vb_qop(vb, buf_init, vb); in __prepare_dmabuf()
1376 ret = call_vb_qop(vb, buf_prepare, vb); in __prepare_dmabuf()
1379 call_void_vb_qop(vb, buf_cleanup, vb); in __prepare_dmabuf()
1386 __vb2_buf_dmabuf_put(vb); in __prepare_dmabuf()
1394 static void __enqueue_in_driver(struct vb2_buffer *vb) in __enqueue_in_driver() argument
1396 struct vb2_queue *q = vb->vb2_queue; in __enqueue_in_driver()
1398 vb->state = VB2_BUF_STATE_ACTIVE; in __enqueue_in_driver()
1401 trace_vb2_buf_queue(q, vb); in __enqueue_in_driver()
1403 call_void_vb_qop(vb, buf_queue, vb); in __enqueue_in_driver()
1406 static int __buf_prepare(struct vb2_buffer *vb) in __buf_prepare() argument
1408 struct vb2_queue *q = vb->vb2_queue; in __buf_prepare()
1409 enum vb2_buffer_state orig_state = vb->state; in __buf_prepare()
1417 if (vb->prepared) in __buf_prepare()
1419 WARN_ON(vb->synced); in __buf_prepare()
1422 ret = call_vb_qop(vb, buf_out_validate, vb); in __buf_prepare()
1429 vb->state = VB2_BUF_STATE_PREPARING; in __buf_prepare()
1433 ret = __prepare_mmap(vb); in __buf_prepare()
1436 ret = __prepare_userptr(vb); in __buf_prepare()
1439 ret = __prepare_dmabuf(vb); in __buf_prepare()
1449 vb->state = orig_state; in __buf_prepare()
1453 __vb2_buf_mem_prepare(vb); in __buf_prepare()
1454 vb->prepared = 1; in __buf_prepare()
1455 vb->state = orig_state; in __buf_prepare()
1462 struct vb2_buffer *vb = container_of(obj, struct vb2_buffer, req_obj); in vb2_req_prepare() local
1465 if (WARN_ON(vb->state != VB2_BUF_STATE_IN_REQUEST)) in vb2_req_prepare()
1468 mutex_lock(vb->vb2_queue->lock); in vb2_req_prepare()
1469 ret = __buf_prepare(vb); in vb2_req_prepare()
1470 mutex_unlock(vb->vb2_queue->lock); in vb2_req_prepare()
1474 static void __vb2_dqbuf(struct vb2_buffer *vb);
1478 struct vb2_buffer *vb = container_of(obj, struct vb2_buffer, req_obj); in vb2_req_unprepare() local
1480 mutex_lock(vb->vb2_queue->lock); in vb2_req_unprepare()
1481 __vb2_dqbuf(vb); in vb2_req_unprepare()
1482 vb->state = VB2_BUF_STATE_IN_REQUEST; in vb2_req_unprepare()
1483 mutex_unlock(vb->vb2_queue->lock); in vb2_req_unprepare()
1484 WARN_ON(!vb->req_obj.req); in vb2_req_unprepare()
1492 struct vb2_buffer *vb = container_of(obj, struct vb2_buffer, req_obj); in vb2_req_queue() local
1495 mutex_lock(vb->vb2_queue->lock); in vb2_req_queue()
1504 err = vb2_core_qbuf(vb->vb2_queue, vb->index, NULL, NULL); in vb2_req_queue()
1506 mutex_unlock(vb->vb2_queue->lock); in vb2_req_queue()
1511 struct vb2_buffer *vb = container_of(obj, struct vb2_buffer, req_obj); in vb2_req_unbind() local
1513 if (vb->state == VB2_BUF_STATE_IN_REQUEST) in vb2_req_unbind()
1514 call_void_bufop(vb->vb2_queue, init_buffer, vb); in vb2_req_unbind()
1519 struct vb2_buffer *vb = container_of(obj, struct vb2_buffer, req_obj); in vb2_req_release() local
1521 if (vb->state == VB2_BUF_STATE_IN_REQUEST) { in vb2_req_release()
1522 vb->state = VB2_BUF_STATE_DEQUEUED; in vb2_req_release()
1523 if (vb->request) in vb2_req_release()
1524 media_request_put(vb->request); in vb2_req_release()
1525 vb->request = NULL; in vb2_req_release()
1561 struct vb2_buffer *vb; in vb2_core_prepare_buf() local
1564 vb = q->bufs[index]; in vb2_core_prepare_buf()
1565 if (vb->state != VB2_BUF_STATE_DEQUEUED) { in vb2_core_prepare_buf()
1567 vb2_state_name(vb->state)); in vb2_core_prepare_buf()
1570 if (vb->prepared) { in vb2_core_prepare_buf()
1575 ret = __buf_prepare(vb); in vb2_core_prepare_buf()
1580 call_void_bufop(q, fill_user_buffer, vb, pb); in vb2_core_prepare_buf()
1582 dprintk(q, 2, "prepare of buffer %d succeeded\n", vb->index); in vb2_core_prepare_buf()
1601 struct vb2_buffer *vb; in vb2_start_streaming() local
1608 list_for_each_entry(vb, &q->queued_list, queued_entry) in vb2_start_streaming()
1609 __enqueue_in_driver(vb); in vb2_start_streaming()
1635 vb = q->bufs[i]; in vb2_start_streaming()
1636 if (vb->state == VB2_BUF_STATE_ACTIVE) in vb2_start_streaming()
1637 vb2_buffer_done(vb, VB2_BUF_STATE_QUEUED); in vb2_start_streaming()
1654 struct vb2_buffer *vb; in vb2_core_qbuf() local
1663 vb = q->bufs[index]; in vb2_core_qbuf()
1665 if (!req && vb->state != VB2_BUF_STATE_IN_REQUEST && in vb2_core_qbuf()
1672 (!req && vb->state != VB2_BUF_STATE_IN_REQUEST && in vb2_core_qbuf()
1682 if (vb->state != VB2_BUF_STATE_DEQUEUED) { in vb2_core_qbuf()
1684 vb->index); in vb2_core_qbuf()
1688 if (q->is_output && !vb->prepared) { in vb2_core_qbuf()
1689 ret = call_vb_qop(vb, buf_out_validate, vb); in vb2_core_qbuf()
1696 media_request_object_init(&vb->req_obj); in vb2_core_qbuf()
1703 q, true, &vb->req_obj); in vb2_core_qbuf()
1708 vb->state = VB2_BUF_STATE_IN_REQUEST; in vb2_core_qbuf()
1719 vb->request = req; in vb2_core_qbuf()
1723 call_void_bufop(q, copy_timestamp, vb, pb); in vb2_core_qbuf()
1724 call_void_bufop(q, fill_user_buffer, vb, pb); in vb2_core_qbuf()
1727 dprintk(q, 2, "qbuf of buffer %d succeeded\n", vb->index); in vb2_core_qbuf()
1731 if (vb->state != VB2_BUF_STATE_IN_REQUEST) in vb2_core_qbuf()
1734 switch (vb->state) { in vb2_core_qbuf()
1737 if (!vb->prepared) { in vb2_core_qbuf()
1738 ret = __buf_prepare(vb); in vb2_core_qbuf()
1748 vb2_state_name(vb->state)); in vb2_core_qbuf()
1756 orig_state = vb->state; in vb2_core_qbuf()
1757 list_add_tail(&vb->queued_entry, &q->queued_list); in vb2_core_qbuf()
1760 vb->state = VB2_BUF_STATE_QUEUED; in vb2_core_qbuf()
1763 call_void_bufop(q, copy_timestamp, vb, pb); in vb2_core_qbuf()
1765 trace_vb2_qbuf(q, vb); in vb2_core_qbuf()
1772 __enqueue_in_driver(vb); in vb2_core_qbuf()
1776 call_void_bufop(q, fill_user_buffer, vb, pb); in vb2_core_qbuf()
1793 list_del(&vb->queued_entry); in vb2_core_qbuf()
1795 vb->state = orig_state; in vb2_core_qbuf()
1800 dprintk(q, 2, "qbuf of buffer %d succeeded\n", vb->index); in vb2_core_qbuf()
1892 static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb, in __vb2_get_done_vb() argument
1910 *vb = list_first_entry(&q->done_list, struct vb2_buffer, done_entry); in __vb2_get_done_vb()
1917 ret = call_bufop(q, verify_planes_array, *vb, pb); in __vb2_get_done_vb()
1919 list_del(&(*vb)->done_entry); in __vb2_get_done_vb()
1941 static void __vb2_dqbuf(struct vb2_buffer *vb) in __vb2_dqbuf() argument
1943 struct vb2_queue *q = vb->vb2_queue; in __vb2_dqbuf()
1946 if (vb->state == VB2_BUF_STATE_DEQUEUED) in __vb2_dqbuf()
1949 vb->state = VB2_BUF_STATE_DEQUEUED; in __vb2_dqbuf()
1951 call_void_bufop(q, init_buffer, vb); in __vb2_dqbuf()
1957 struct vb2_buffer *vb = NULL; in vb2_core_dqbuf() local
1960 ret = __vb2_get_done_vb(q, &vb, pb, nonblocking); in vb2_core_dqbuf()
1964 switch (vb->state) { in vb2_core_dqbuf()
1973 vb2_state_name(vb->state)); in vb2_core_dqbuf()
1977 call_void_vb_qop(vb, buf_finish, vb); in vb2_core_dqbuf()
1978 vb->prepared = 0; in vb2_core_dqbuf()
1981 *pindex = vb->index; in vb2_core_dqbuf()
1985 call_void_bufop(q, fill_user_buffer, vb, pb); in vb2_core_dqbuf()
1988 list_del(&vb->queued_entry); in vb2_core_dqbuf()
1991 trace_vb2_dqbuf(q, vb); in vb2_core_dqbuf()
1994 __vb2_dqbuf(vb); in vb2_core_dqbuf()
1996 if (WARN_ON(vb->req_obj.req)) { in vb2_core_dqbuf()
1997 media_request_object_unbind(&vb->req_obj); in vb2_core_dqbuf()
1998 media_request_object_put(&vb->req_obj); in vb2_core_dqbuf()
2000 if (vb->request) in vb2_core_dqbuf()
2001 media_request_put(vb->request); in vb2_core_dqbuf()
2002 vb->request = NULL; in vb2_core_dqbuf()
2005 vb->index, vb2_state_name(vb->state)); in vb2_core_dqbuf()
2075 struct vb2_buffer *vb = q->bufs[i]; in __vb2_queue_cancel() local
2076 struct media_request *req = vb->req_obj.req; in __vb2_queue_cancel()
2093 call_void_vb_qop(vb, buf_request_complete, vb); in __vb2_queue_cancel()
2096 __vb2_buf_mem_finish(vb); in __vb2_queue_cancel()
2098 if (vb->prepared) { in __vb2_queue_cancel()
2099 call_void_vb_qop(vb, buf_finish, vb); in __vb2_queue_cancel()
2100 vb->prepared = 0; in __vb2_queue_cancel()
2102 __vb2_dqbuf(vb); in __vb2_queue_cancel()
2104 if (vb->req_obj.req) { in __vb2_queue_cancel()
2105 media_request_object_unbind(&vb->req_obj); in __vb2_queue_cancel()
2106 media_request_object_put(&vb->req_obj); in __vb2_queue_cancel()
2108 if (vb->request) in __vb2_queue_cancel()
2109 media_request_put(vb->request); in __vb2_queue_cancel()
2110 vb->request = NULL; in __vb2_queue_cancel()
2111 vb->copied_timestamp = 0; in __vb2_queue_cancel()
2199 struct vb2_buffer *vb; in __find_plane_by_offset() local
2224 vb = q->bufs[buffer]; in __find_plane_by_offset()
2226 for (plane = 0; plane < vb->num_planes; ++plane) { in __find_plane_by_offset()
2227 if (vb->planes[plane].m.offset == off) { in __find_plane_by_offset()
2241 struct vb2_buffer *vb = NULL; in vb2_core_expbuf() local
2271 vb = q->bufs[index]; in vb2_core_expbuf()
2273 if (plane >= vb->num_planes) { in vb2_core_expbuf()
2283 vb_plane = &vb->planes[plane]; in vb2_core_expbuf()
2286 vb, in vb2_core_expbuf()
2314 struct vb2_buffer *vb; in vb2_mmap() local
2348 vb = q->bufs[buffer]; in vb2_mmap()
2355 length = PAGE_ALIGN(vb->planes[plane].length); in vb2_mmap()
2370 ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma); in vb2_mmap()
2390 struct vb2_buffer *vb; in vb2_get_unmapped_area() local
2405 vb = q->bufs[buffer]; in vb2_get_unmapped_area()
2407 vaddr = vb2_plane_vaddr(vb, plane); in vb2_get_unmapped_area()
2486 struct vb2_buffer *vb = NULL; in vb2_core_poll() local
2561 vb = list_first_entry(&q->done_list, struct vb2_buffer, in vb2_core_poll()
2565 if (vb && (vb->state == VB2_BUF_STATE_DONE in vb2_core_poll()
2566 || vb->state == VB2_BUF_STATE_ERROR)) { in vb2_core_poll()
2973 struct vb2_buffer *vb; in vb2_thread() local
2979 vb = q->bufs[index++]; in vb2_thread()
2988 vb = q->bufs[index]; in vb2_thread()
2994 if (vb->state != VB2_BUF_STATE_ERROR) in vb2_thread()
2995 if (threadio->fnc(vb, threadio->priv)) in vb2_thread()
2999 vb->timestamp = ktime_get_ns(); in vb2_thread()
3001 ret = vb2_core_qbuf(q, vb->index, NULL, NULL); in vb2_thread()