Lines Matching full:q
37 #define dprintk(q, level, fmt, arg...) \ argument
40 pr_info("[%s] %s: " fmt, (q)->name, __func__, \
93 #define log_qop(q, op) \ argument
94 dprintk(q, 2, "call_qop(%s)%s\n", #op, \
95 (q)->ops->op ? "" : " (nop)")
97 #define call_qop(q, op, args...) \ argument
101 log_qop(q, op); \
102 err = (q)->ops->op ? (q)->ops->op(args) : 0; \
104 (q)->cnt_ ## op++; \
108 #define call_void_qop(q, op, args...) \ argument
110 log_qop(q, op); \
111 if ((q)->ops->op) \
112 (q)->ops->op(args); \
113 (q)->cnt_ ## op++; \
157 #define call_qop(q, op, args...) \ argument
158 ((q)->ops->op ? (q)->ops->op(args) : 0)
160 #define call_void_qop(q, op, args...) \ argument
162 if ((q)->ops->op) \
163 (q)->ops->op(args); \
177 #define call_bufop(q, op, args...) \ argument
180 if (q && q->buf_ops && q->buf_ops->op) \
181 ret = q->buf_ops->op(args); \
185 #define call_void_bufop(q, op, args...) \ argument
187 if (q && q->buf_ops && q->buf_ops->op) \
188 q->buf_ops->op(args); \
191 static void __vb2_queue_cancel(struct vb2_queue *q);
216 struct vb2_queue *q = vb->vb2_queue; in __vb2_buf_mem_alloc() local
235 q->alloc_devs[plane] ? : q->dev, in __vb2_buf_mem_alloc()
361 struct vb2_queue *q = vb->vb2_queue; in __setup_offsets() local
366 struct vb2_buffer *prev = q->bufs[vb->index - 1]; in __setup_offsets()
375 dprintk(q, 3, "buffer %d, plane %d offset 0x%08lx\n", in __setup_offsets()
383 static void init_buffer_cache_hints(struct vb2_queue *q, struct vb2_buffer *vb) in init_buffer_cache_hints() argument
390 if (q->memory == VB2_MEMORY_DMABUF) { in init_buffer_cache_hints()
400 if (q->dma_dir == DMA_TO_DEVICE) in init_buffer_cache_hints()
411 static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, in __vb2_queue_alloc() argument
419 /* Ensure that q->num_buffers+num_buffers is below VB2_MAX_FRAME */ in __vb2_queue_alloc()
421 VB2_MAX_FRAME - q->num_buffers); in __vb2_queue_alloc()
425 vb = kzalloc(q->buf_struct_size, GFP_KERNEL); in __vb2_queue_alloc()
427 dprintk(q, 1, "memory alloc for buffer struct failed\n"); in __vb2_queue_alloc()
432 vb->vb2_queue = q; in __vb2_queue_alloc()
434 vb->index = q->num_buffers + buffer; in __vb2_queue_alloc()
435 vb->type = q->type; in __vb2_queue_alloc()
437 init_buffer_cache_hints(q, vb); in __vb2_queue_alloc()
442 call_void_bufop(q, init_buffer, vb); in __vb2_queue_alloc()
444 q->bufs[vb->index] = vb; in __vb2_queue_alloc()
450 dprintk(q, 1, "failed allocating memory for buffer %d\n", in __vb2_queue_alloc()
452 q->bufs[vb->index] = NULL; in __vb2_queue_alloc()
464 dprintk(q, 1, "buffer %d %p initialization failed\n", in __vb2_queue_alloc()
467 q->bufs[vb->index] = NULL; in __vb2_queue_alloc()
474 dprintk(q, 3, "allocated %d buffers, %d plane(s) each\n", in __vb2_queue_alloc()
483 static void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers) in __vb2_free_mem() argument
488 for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; in __vb2_free_mem()
490 vb = q->bufs[buffer]; in __vb2_free_mem()
495 if (q->memory == VB2_MEMORY_MMAP) in __vb2_free_mem()
497 else if (q->memory == VB2_MEMORY_DMABUF) in __vb2_free_mem()
509 static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) in __vb2_queue_free() argument
513 lockdep_assert_held(&q->mmap_lock); in __vb2_queue_free()
516 for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; in __vb2_queue_free()
518 struct vb2_buffer *vb = q->bufs[buffer]; in __vb2_queue_free()
525 __vb2_free_mem(q, buffers); in __vb2_queue_free()
533 if (q->num_buffers) { in __vb2_queue_free()
534 bool unbalanced = q->cnt_start_streaming != q->cnt_stop_streaming || in __vb2_queue_free()
535 q->cnt_prepare_streaming != q->cnt_unprepare_streaming || in __vb2_queue_free()
536 q->cnt_wait_prepare != q->cnt_wait_finish; in __vb2_queue_free()
539 pr_info("counters for queue %p:%s\n", q, in __vb2_queue_free()
542 q->cnt_queue_setup, q->cnt_start_streaming, in __vb2_queue_free()
543 q->cnt_stop_streaming); in __vb2_queue_free()
545 q->cnt_prepare_streaming, q->cnt_unprepare_streaming); in __vb2_queue_free()
547 q->cnt_wait_prepare, q->cnt_wait_finish); in __vb2_queue_free()
549 q->cnt_queue_setup = 0; in __vb2_queue_free()
550 q->cnt_wait_prepare = 0; in __vb2_queue_free()
551 q->cnt_wait_finish = 0; in __vb2_queue_free()
552 q->cnt_prepare_streaming = 0; in __vb2_queue_free()
553 q->cnt_start_streaming = 0; in __vb2_queue_free()
554 q->cnt_stop_streaming = 0; in __vb2_queue_free()
555 q->cnt_unprepare_streaming = 0; in __vb2_queue_free()
557 for (buffer = 0; buffer < q->num_buffers; ++buffer) { in __vb2_queue_free()
558 struct vb2_buffer *vb = q->bufs[buffer]; in __vb2_queue_free()
570 q, buffer, unbalanced ? " UNBALANCED!" : ""); in __vb2_queue_free()
596 for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; in __vb2_queue_free()
598 kfree(q->bufs[buffer]); in __vb2_queue_free()
599 q->bufs[buffer] = NULL; in __vb2_queue_free()
602 q->num_buffers -= buffers; in __vb2_queue_free()
603 if (!q->num_buffers) { in __vb2_queue_free()
604 q->memory = VB2_MEMORY_UNKNOWN; in __vb2_queue_free()
605 INIT_LIST_HEAD(&q->queued_list); in __vb2_queue_free()
609 bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb) in vb2_buffer_in_use() argument
631 static bool __buffers_in_use(struct vb2_queue *q) in __buffers_in_use() argument
634 for (buffer = 0; buffer < q->num_buffers; ++buffer) { in __buffers_in_use()
635 if (vb2_buffer_in_use(q, q->bufs[buffer])) in __buffers_in_use()
641 void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb) in vb2_core_querybuf() argument
643 call_void_bufop(q, fill_user_buffer, q->bufs[index], pb); in vb2_core_querybuf()
651 static int __verify_userptr_ops(struct vb2_queue *q) in __verify_userptr_ops() argument
653 if (!(q->io_modes & VB2_USERPTR) || !q->mem_ops->get_userptr || in __verify_userptr_ops()
654 !q->mem_ops->put_userptr) in __verify_userptr_ops()
664 static int __verify_mmap_ops(struct vb2_queue *q) in __verify_mmap_ops() argument
666 if (!(q->io_modes & VB2_MMAP) || !q->mem_ops->alloc || in __verify_mmap_ops()
667 !q->mem_ops->put || !q->mem_ops->mmap) in __verify_mmap_ops()
677 static int __verify_dmabuf_ops(struct vb2_queue *q) in __verify_dmabuf_ops() argument
679 if (!(q->io_modes & VB2_DMABUF) || !q->mem_ops->attach_dmabuf || in __verify_dmabuf_ops()
680 !q->mem_ops->detach_dmabuf || !q->mem_ops->map_dmabuf || in __verify_dmabuf_ops()
681 !q->mem_ops->unmap_dmabuf) in __verify_dmabuf_ops()
687 int vb2_verify_memory_type(struct vb2_queue *q, in vb2_verify_memory_type() argument
692 dprintk(q, 1, "unsupported memory type\n"); in vb2_verify_memory_type()
696 if (type != q->type) { in vb2_verify_memory_type()
697 dprintk(q, 1, "requested type is incorrect\n"); in vb2_verify_memory_type()
705 if (memory == VB2_MEMORY_MMAP && __verify_mmap_ops(q)) { in vb2_verify_memory_type()
706 dprintk(q, 1, "MMAP for current setup unsupported\n"); in vb2_verify_memory_type()
710 if (memory == VB2_MEMORY_USERPTR && __verify_userptr_ops(q)) { in vb2_verify_memory_type()
711 dprintk(q, 1, "USERPTR for current setup unsupported\n"); in vb2_verify_memory_type()
715 if (memory == VB2_MEMORY_DMABUF && __verify_dmabuf_ops(q)) { in vb2_verify_memory_type()
716 dprintk(q, 1, "DMABUF for current setup unsupported\n"); in vb2_verify_memory_type()
725 if (vb2_fileio_is_active(q)) { in vb2_verify_memory_type()
726 dprintk(q, 1, "file io in progress\n"); in vb2_verify_memory_type()
733 static void set_queue_coherency(struct vb2_queue *q, bool non_coherent_mem) in set_queue_coherency() argument
735 q->non_coherent_mem = 0; in set_queue_coherency()
737 if (!vb2_queue_allows_cache_hints(q)) in set_queue_coherency()
739 q->non_coherent_mem = non_coherent_mem; in set_queue_coherency()
742 static bool verify_coherency_flags(struct vb2_queue *q, bool non_coherent_mem) in verify_coherency_flags() argument
744 if (non_coherent_mem != q->non_coherent_mem) { in verify_coherency_flags()
745 dprintk(q, 1, "memory coherency model mismatch\n"); in verify_coherency_flags()
751 int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, in vb2_core_reqbufs() argument
760 if (q->streaming) { in vb2_core_reqbufs()
761 dprintk(q, 1, "streaming active\n"); in vb2_core_reqbufs()
765 if (q->waiting_in_dqbuf && *count) { in vb2_core_reqbufs()
766 dprintk(q, 1, "another dup()ped fd is waiting for a buffer\n"); in vb2_core_reqbufs()
770 if (*count == 0 || q->num_buffers != 0 || in vb2_core_reqbufs()
771 (q->memory != VB2_MEMORY_UNKNOWN && q->memory != memory) || in vb2_core_reqbufs()
772 !verify_coherency_flags(q, non_coherent_mem)) { in vb2_core_reqbufs()
777 mutex_lock(&q->mmap_lock); in vb2_core_reqbufs()
778 if (debug && q->memory == VB2_MEMORY_MMAP && in vb2_core_reqbufs()
779 __buffers_in_use(q)) in vb2_core_reqbufs()
780 dprintk(q, 1, "memory in use, orphaning buffers\n"); in vb2_core_reqbufs()
787 __vb2_queue_cancel(q); in vb2_core_reqbufs()
788 __vb2_queue_free(q, q->num_buffers); in vb2_core_reqbufs()
789 mutex_unlock(&q->mmap_lock); in vb2_core_reqbufs()
802 WARN_ON(q->min_buffers_needed > VB2_MAX_FRAME); in vb2_core_reqbufs()
803 num_buffers = max_t(unsigned int, *count, q->min_buffers_needed); in vb2_core_reqbufs()
805 memset(q->alloc_devs, 0, sizeof(q->alloc_devs)); in vb2_core_reqbufs()
807 * Set this now to ensure that drivers see the correct q->memory value in vb2_core_reqbufs()
810 mutex_lock(&q->mmap_lock); in vb2_core_reqbufs()
811 q->memory = memory; in vb2_core_reqbufs()
812 mutex_unlock(&q->mmap_lock); in vb2_core_reqbufs()
813 set_queue_coherency(q, non_coherent_mem); in vb2_core_reqbufs()
819 ret = call_qop(q, queue_setup, q, &num_buffers, &num_planes, in vb2_core_reqbufs()
820 plane_sizes, q->alloc_devs); in vb2_core_reqbufs()
838 __vb2_queue_alloc(q, memory, num_buffers, num_planes, plane_sizes); in vb2_core_reqbufs()
840 dprintk(q, 1, "memory allocation failed\n"); in vb2_core_reqbufs()
849 if (allocated_buffers < q->min_buffers_needed) in vb2_core_reqbufs()
865 ret = call_qop(q, queue_setup, q, &num_buffers, in vb2_core_reqbufs()
866 &num_planes, plane_sizes, q->alloc_devs); in vb2_core_reqbufs()
877 mutex_lock(&q->mmap_lock); in vb2_core_reqbufs()
878 q->num_buffers = allocated_buffers; in vb2_core_reqbufs()
883 * from q->num_buffers and it will reset q->memory to in vb2_core_reqbufs()
886 __vb2_queue_free(q, allocated_buffers); in vb2_core_reqbufs()
887 mutex_unlock(&q->mmap_lock); in vb2_core_reqbufs()
890 mutex_unlock(&q->mmap_lock); in vb2_core_reqbufs()
897 q->waiting_for_buffers = !q->is_output; in vb2_core_reqbufs()
902 mutex_lock(&q->mmap_lock); in vb2_core_reqbufs()
903 q->memory = VB2_MEMORY_UNKNOWN; in vb2_core_reqbufs()
904 mutex_unlock(&q->mmap_lock); in vb2_core_reqbufs()
909 int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, in vb2_core_create_bufs() argument
917 bool no_previous_buffers = !q->num_buffers; in vb2_core_create_bufs()
920 if (q->num_buffers == VB2_MAX_FRAME) { in vb2_core_create_bufs()
921 dprintk(q, 1, "maximum number of buffers already allocated\n"); in vb2_core_create_bufs()
926 if (q->waiting_in_dqbuf && *count) { in vb2_core_create_bufs()
927 dprintk(q, 1, "another dup()ped fd is waiting for a buffer\n"); in vb2_core_create_bufs()
930 memset(q->alloc_devs, 0, sizeof(q->alloc_devs)); in vb2_core_create_bufs()
932 * Set this now to ensure that drivers see the correct q->memory in vb2_core_create_bufs()
935 mutex_lock(&q->mmap_lock); in vb2_core_create_bufs()
936 q->memory = memory; in vb2_core_create_bufs()
937 mutex_unlock(&q->mmap_lock); in vb2_core_create_bufs()
938 q->waiting_for_buffers = !q->is_output; in vb2_core_create_bufs()
939 set_queue_coherency(q, non_coherent_mem); in vb2_core_create_bufs()
941 if (q->memory != memory) { in vb2_core_create_bufs()
942 dprintk(q, 1, "memory model mismatch\n"); in vb2_core_create_bufs()
945 if (!verify_coherency_flags(q, non_coherent_mem)) in vb2_core_create_bufs()
949 num_buffers = min(*count, VB2_MAX_FRAME - q->num_buffers); in vb2_core_create_bufs()
960 ret = call_qop(q, queue_setup, q, &num_buffers, in vb2_core_create_bufs()
961 &num_planes, plane_sizes, q->alloc_devs); in vb2_core_create_bufs()
966 allocated_buffers = __vb2_queue_alloc(q, memory, num_buffers, in vb2_core_create_bufs()
969 dprintk(q, 1, "memory allocation failed\n"); in vb2_core_create_bufs()
981 * q->num_buffers contains the total number of buffers, that the in vb2_core_create_bufs()
984 ret = call_qop(q, queue_setup, q, &num_buffers, in vb2_core_create_bufs()
985 &num_planes, plane_sizes, q->alloc_devs); in vb2_core_create_bufs()
996 mutex_lock(&q->mmap_lock); in vb2_core_create_bufs()
997 q->num_buffers += allocated_buffers; in vb2_core_create_bufs()
1002 * from q->num_buffers and it will reset q->memory to in vb2_core_create_bufs()
1005 __vb2_queue_free(q, allocated_buffers); in vb2_core_create_bufs()
1006 mutex_unlock(&q->mmap_lock); in vb2_core_create_bufs()
1009 mutex_unlock(&q->mmap_lock); in vb2_core_create_bufs()
1021 mutex_lock(&q->mmap_lock); in vb2_core_create_bufs()
1022 q->memory = VB2_MEMORY_UNKNOWN; in vb2_core_create_bufs()
1023 mutex_unlock(&q->mmap_lock); in vb2_core_create_bufs()
1050 struct vb2_queue *q = vb->vb2_queue; in vb2_buffer_done() local
1068 dprintk(q, 4, "done processing on buffer %d, state: %s\n", in vb2_buffer_done()
1074 spin_lock_irqsave(&q->done_lock, flags); in vb2_buffer_done()
1079 list_add_tail(&vb->done_entry, &q->done_list); in vb2_buffer_done()
1082 atomic_dec(&q->owned_by_drv_count); in vb2_buffer_done()
1089 spin_unlock_irqrestore(&q->done_lock, flags); in vb2_buffer_done()
1091 trace_vb2_buf_done(q, vb); in vb2_buffer_done()
1098 wake_up(&q->done_wq); in vb2_buffer_done()
1104 void vb2_discard_done(struct vb2_queue *q) in vb2_discard_done() argument
1109 spin_lock_irqsave(&q->done_lock, flags); in vb2_discard_done()
1110 list_for_each_entry(vb, &q->done_list, done_entry) in vb2_discard_done()
1112 spin_unlock_irqrestore(&q->done_lock, flags); in vb2_discard_done()
1134 struct vb2_queue *q = vb->vb2_queue; in __prepare_userptr() local
1154 dprintk(q, 3, "userspace address for plane %d changed, reacquiring memory\n", in __prepare_userptr()
1159 dprintk(q, 1, "provided buffer size %u is less than setup size %u for plane %d\n", in __prepare_userptr()
1186 q->alloc_devs[plane] ? : q->dev, in __prepare_userptr()
1190 dprintk(q, 1, "failed acquiring userspace memory for plane %d\n", in __prepare_userptr()
1217 dprintk(q, 1, "buffer initialization failed\n"); in __prepare_userptr()
1224 dprintk(q, 1, "buffer preparation failed\n"); in __prepare_userptr()
1250 struct vb2_queue *q = vb->vb2_queue; in __prepare_dmabuf() local
1267 dprintk(q, 1, "invalid dmabuf fd for plane %d\n", in __prepare_dmabuf()
1278 dprintk(q, 1, "invalid dmabuf length %u for plane %d, minimum length %u\n", in __prepare_dmabuf()
1293 dprintk(q, 3, "buffer for plane %d changed\n", plane); in __prepare_dmabuf()
1307 q->alloc_devs[plane] ? : q->dev, in __prepare_dmabuf()
1311 dprintk(q, 1, "failed to attach dmabuf\n"); in __prepare_dmabuf()
1332 dprintk(q, 1, "failed to map dmabuf for plane %d\n", in __prepare_dmabuf()
1357 dprintk(q, 1, "buffer initialization failed\n"); in __prepare_dmabuf()
1364 dprintk(q, 1, "buffer preparation failed\n"); in __prepare_dmabuf()
1382 struct vb2_queue *q = vb->vb2_queue; in __enqueue_in_driver() local
1385 atomic_inc(&q->owned_by_drv_count); in __enqueue_in_driver()
1387 trace_vb2_buf_queue(q, vb); in __enqueue_in_driver()
1394 struct vb2_queue *q = vb->vb2_queue; in __buf_prepare() local
1398 if (q->error) { in __buf_prepare()
1399 dprintk(q, 1, "fatal error occurred on queue\n"); in __buf_prepare()
1407 if (q->is_output) { in __buf_prepare()
1410 dprintk(q, 1, "buffer validation failed\n"); in __buf_prepare()
1417 switch (q->memory) { in __buf_prepare()
1434 dprintk(q, 1, "buffer preparation failed: %d\n", ret); in __buf_prepare()
1473 int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
1486 * The only exception is -EIO which is returned if q->error is in vb2_req_queue()
1545 int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb) in vb2_core_prepare_buf() argument
1550 vb = q->bufs[index]; in vb2_core_prepare_buf()
1552 dprintk(q, 1, "invalid buffer state %s\n", in vb2_core_prepare_buf()
1557 dprintk(q, 1, "buffer already prepared\n"); in vb2_core_prepare_buf()
1566 call_void_bufop(q, fill_user_buffer, vb, pb); in vb2_core_prepare_buf()
1568 dprintk(q, 2, "prepare of buffer %d succeeded\n", vb->index); in vb2_core_prepare_buf()
1576 * @q: videobuf2 queue
1579 * at least q->min_buffers_needed buffers queued up (i.e. the minimum
1585 static int vb2_start_streaming(struct vb2_queue *q) in vb2_start_streaming() argument
1594 list_for_each_entry(vb, &q->queued_list, queued_entry) in vb2_start_streaming()
1598 q->start_streaming_called = 1; in vb2_start_streaming()
1599 ret = call_qop(q, start_streaming, q, in vb2_start_streaming()
1600 atomic_read(&q->owned_by_drv_count)); in vb2_start_streaming()
1604 q->start_streaming_called = 0; in vb2_start_streaming()
1606 dprintk(q, 1, "driver refused to start streaming\n"); in vb2_start_streaming()
1613 if (WARN_ON(atomic_read(&q->owned_by_drv_count))) { in vb2_start_streaming()
1620 for (i = 0; i < q->num_buffers; ++i) { in vb2_start_streaming()
1621 vb = q->bufs[i]; in vb2_start_streaming()
1626 WARN_ON(atomic_read(&q->owned_by_drv_count)); in vb2_start_streaming()
1633 WARN_ON(!list_empty(&q->done_list)); in vb2_start_streaming()
1637 int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, in vb2_core_qbuf() argument
1644 if (q->error) { in vb2_core_qbuf()
1645 dprintk(q, 1, "fatal error occurred on queue\n"); in vb2_core_qbuf()
1649 vb = q->bufs[index]; in vb2_core_qbuf()
1652 q->requires_requests) { in vb2_core_qbuf()
1653 dprintk(q, 1, "qbuf requires a request\n"); in vb2_core_qbuf()
1657 if ((req && q->uses_qbuf) || in vb2_core_qbuf()
1659 q->uses_requests)) { in vb2_core_qbuf()
1660 dprintk(q, 1, "queue in wrong mode (qbuf vs requests)\n"); in vb2_core_qbuf()
1667 q->uses_requests = 1; in vb2_core_qbuf()
1669 dprintk(q, 1, "buffer %d not in dequeued state\n", in vb2_core_qbuf()
1674 if (q->is_output && !vb->prepared) { in vb2_core_qbuf()
1677 dprintk(q, 1, "buffer validation failed\n"); in vb2_core_qbuf()
1689 q, true, &vb->req_obj); in vb2_core_qbuf()
1709 call_void_bufop(q, copy_timestamp, vb, pb); in vb2_core_qbuf()
1710 call_void_bufop(q, fill_user_buffer, vb, pb); in vb2_core_qbuf()
1713 dprintk(q, 2, "qbuf of buffer %d succeeded\n", vb->index); in vb2_core_qbuf()
1718 q->uses_qbuf = 1; in vb2_core_qbuf()
1730 dprintk(q, 1, "buffer still being prepared\n"); in vb2_core_qbuf()
1733 dprintk(q, 1, "invalid buffer state %s\n", in vb2_core_qbuf()
1743 list_add_tail(&vb->queued_entry, &q->queued_list); in vb2_core_qbuf()
1744 q->queued_count++; in vb2_core_qbuf()
1745 q->waiting_for_buffers = false; in vb2_core_qbuf()
1749 call_void_bufop(q, copy_timestamp, vb, pb); in vb2_core_qbuf()
1751 trace_vb2_qbuf(q, vb); in vb2_core_qbuf()
1757 if (q->start_streaming_called) in vb2_core_qbuf()
1762 call_void_bufop(q, fill_user_buffer, vb, pb); in vb2_core_qbuf()
1770 if (q->streaming && !q->start_streaming_called && in vb2_core_qbuf()
1771 q->queued_count >= q->min_buffers_needed) { in vb2_core_qbuf()
1772 ret = vb2_start_streaming(q); in vb2_core_qbuf()
1780 q->queued_count--; in vb2_core_qbuf()
1786 dprintk(q, 2, "qbuf of buffer %d succeeded\n", vb->index); in vb2_core_qbuf()
1797 static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking) in __vb2_wait_for_done_vb() argument
1811 if (q->waiting_in_dqbuf) { in __vb2_wait_for_done_vb()
1812 dprintk(q, 1, "another dup()ped fd is waiting for a buffer\n"); in __vb2_wait_for_done_vb()
1816 if (!q->streaming) { in __vb2_wait_for_done_vb()
1817 dprintk(q, 1, "streaming off, will not wait for buffers\n"); in __vb2_wait_for_done_vb()
1821 if (q->error) { in __vb2_wait_for_done_vb()
1822 dprintk(q, 1, "Queue in error state, will not wait for buffers\n"); in __vb2_wait_for_done_vb()
1826 if (q->last_buffer_dequeued) { in __vb2_wait_for_done_vb()
1827 dprintk(q, 3, "last buffer dequeued already, will not wait for buffers\n"); in __vb2_wait_for_done_vb()
1831 if (!list_empty(&q->done_list)) { in __vb2_wait_for_done_vb()
1839 dprintk(q, 3, "nonblocking and no buffers to dequeue, will not wait\n"); in __vb2_wait_for_done_vb()
1843 q->waiting_in_dqbuf = 1; in __vb2_wait_for_done_vb()
1849 call_void_qop(q, wait_prepare, q); in __vb2_wait_for_done_vb()
1854 dprintk(q, 3, "will sleep waiting for buffers\n"); in __vb2_wait_for_done_vb()
1855 ret = wait_event_interruptible(q->done_wq, in __vb2_wait_for_done_vb()
1856 !list_empty(&q->done_list) || !q->streaming || in __vb2_wait_for_done_vb()
1857 q->error); in __vb2_wait_for_done_vb()
1863 call_void_qop(q, wait_finish, q); in __vb2_wait_for_done_vb()
1864 q->waiting_in_dqbuf = 0; in __vb2_wait_for_done_vb()
1866 dprintk(q, 1, "sleep was interrupted\n"); in __vb2_wait_for_done_vb()
1878 static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb, in __vb2_get_done_vb() argument
1887 ret = __vb2_wait_for_done_vb(q, nonblocking); in __vb2_get_done_vb()
1895 spin_lock_irqsave(&q->done_lock, flags); in __vb2_get_done_vb()
1896 *vb = list_first_entry(&q->done_list, struct vb2_buffer, done_entry); in __vb2_get_done_vb()
1903 ret = call_bufop(q, verify_planes_array, *vb, pb); in __vb2_get_done_vb()
1906 spin_unlock_irqrestore(&q->done_lock, flags); in __vb2_get_done_vb()
1911 int vb2_wait_for_all_buffers(struct vb2_queue *q) in vb2_wait_for_all_buffers() argument
1913 if (!q->streaming) { in vb2_wait_for_all_buffers()
1914 dprintk(q, 1, "streaming off, will not wait for buffers\n"); in vb2_wait_for_all_buffers()
1918 if (q->start_streaming_called) in vb2_wait_for_all_buffers()
1919 wait_event(q->done_wq, !atomic_read(&q->owned_by_drv_count)); in vb2_wait_for_all_buffers()
1929 struct vb2_queue *q = vb->vb2_queue; in __vb2_dqbuf() local
1937 call_void_bufop(q, init_buffer, vb); in __vb2_dqbuf()
1940 int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb, in vb2_core_dqbuf() argument
1946 ret = __vb2_get_done_vb(q, &vb, pb, nonblocking); in vb2_core_dqbuf()
1952 dprintk(q, 3, "returning done buffer\n"); in vb2_core_dqbuf()
1955 dprintk(q, 3, "returning done buffer with errors\n"); in vb2_core_dqbuf()
1958 dprintk(q, 1, "invalid buffer state %s\n", in vb2_core_dqbuf()
1971 call_void_bufop(q, fill_user_buffer, vb, pb); in vb2_core_dqbuf()
1975 q->queued_count--; in vb2_core_dqbuf()
1977 trace_vb2_dqbuf(q, vb); in vb2_core_dqbuf()
1990 dprintk(q, 2, "dqbuf of buffer %d, state: %s\n", in vb2_core_dqbuf()
2004 static void __vb2_queue_cancel(struct vb2_queue *q) in __vb2_queue_cancel() argument
2012 if (q->start_streaming_called) in __vb2_queue_cancel()
2013 call_void_qop(q, stop_streaming, q); in __vb2_queue_cancel()
2015 if (q->streaming) in __vb2_queue_cancel()
2016 call_void_qop(q, unprepare_streaming, q); in __vb2_queue_cancel()
2024 if (WARN_ON(atomic_read(&q->owned_by_drv_count))) { in __vb2_queue_cancel()
2025 for (i = 0; i < q->num_buffers; ++i) in __vb2_queue_cancel()
2026 if (q->bufs[i]->state == VB2_BUF_STATE_ACTIVE) { in __vb2_queue_cancel()
2028 q->bufs[i]); in __vb2_queue_cancel()
2029 vb2_buffer_done(q->bufs[i], VB2_BUF_STATE_ERROR); in __vb2_queue_cancel()
2032 WARN_ON(atomic_read(&q->owned_by_drv_count)); in __vb2_queue_cancel()
2035 q->streaming = 0; in __vb2_queue_cancel()
2036 q->start_streaming_called = 0; in __vb2_queue_cancel()
2037 q->queued_count = 0; in __vb2_queue_cancel()
2038 q->error = 0; in __vb2_queue_cancel()
2039 q->uses_requests = 0; in __vb2_queue_cancel()
2040 q->uses_qbuf = 0; in __vb2_queue_cancel()
2045 INIT_LIST_HEAD(&q->queued_list); in __vb2_queue_cancel()
2050 INIT_LIST_HEAD(&q->done_list); in __vb2_queue_cancel()
2051 atomic_set(&q->owned_by_drv_count, 0); in __vb2_queue_cancel()
2052 wake_up_all(&q->done_wq); in __vb2_queue_cancel()
2063 for (i = 0; i < q->num_buffers; ++i) { in __vb2_queue_cancel()
2064 struct vb2_buffer *vb = q->bufs[i]; in __vb2_queue_cancel()
2104 int vb2_core_streamon(struct vb2_queue *q, unsigned int type) in vb2_core_streamon() argument
2108 if (type != q->type) { in vb2_core_streamon()
2109 dprintk(q, 1, "invalid stream type\n"); in vb2_core_streamon()
2113 if (q->streaming) { in vb2_core_streamon()
2114 dprintk(q, 3, "already streaming\n"); in vb2_core_streamon()
2118 if (!q->num_buffers) { in vb2_core_streamon()
2119 dprintk(q, 1, "no buffers have been allocated\n"); in vb2_core_streamon()
2123 if (q->num_buffers < q->min_buffers_needed) { in vb2_core_streamon()
2124 dprintk(q, 1, "need at least %u allocated buffers\n", in vb2_core_streamon()
2125 q->min_buffers_needed); in vb2_core_streamon()
2129 ret = call_qop(q, prepare_streaming, q); in vb2_core_streamon()
2137 if (q->queued_count >= q->min_buffers_needed) { in vb2_core_streamon()
2138 ret = vb2_start_streaming(q); in vb2_core_streamon()
2143 q->streaming = 1; in vb2_core_streamon()
2145 dprintk(q, 3, "successful\n"); in vb2_core_streamon()
2149 call_void_qop(q, unprepare_streaming, q); in vb2_core_streamon()
2154 void vb2_queue_error(struct vb2_queue *q) in vb2_queue_error() argument
2156 q->error = 1; in vb2_queue_error()
2158 wake_up_all(&q->done_wq); in vb2_queue_error()
2162 int vb2_core_streamoff(struct vb2_queue *q, unsigned int type) in vb2_core_streamoff() argument
2164 if (type != q->type) { in vb2_core_streamoff()
2165 dprintk(q, 1, "invalid stream type\n"); in vb2_core_streamoff()
2173 * Note that we do this even if q->streaming == 0: if you prepare or in vb2_core_streamoff()
2178 __vb2_queue_cancel(q); in vb2_core_streamoff()
2179 q->waiting_for_buffers = !q->is_output; in vb2_core_streamoff()
2180 q->last_buffer_dequeued = false; in vb2_core_streamoff()
2182 dprintk(q, 3, "successful\n"); in vb2_core_streamoff()
2190 static int __find_plane_by_offset(struct vb2_queue *q, unsigned long off, in __find_plane_by_offset() argument
2200 lockdep_assert_held(&q->mmap_lock); in __find_plane_by_offset()
2202 if (q->memory != VB2_MEMORY_MMAP) { in __find_plane_by_offset()
2203 dprintk(q, 1, "queue is not currently set up for mmap\n"); in __find_plane_by_offset()
2207 if (vb2_fileio_is_active(q)) { in __find_plane_by_offset()
2208 dprintk(q, 1, "file io in progress\n"); in __find_plane_by_offset()
2217 for (buffer = 0; buffer < q->num_buffers; ++buffer) { in __find_plane_by_offset()
2218 vb = q->bufs[buffer]; in __find_plane_by_offset()
2232 int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, in vb2_core_expbuf() argument
2240 if (q->memory != VB2_MEMORY_MMAP) { in vb2_core_expbuf()
2241 dprintk(q, 1, "queue is not currently set up for mmap\n"); in vb2_core_expbuf()
2245 if (!q->mem_ops->get_dmabuf) { in vb2_core_expbuf()
2246 dprintk(q, 1, "queue does not support DMA buffer exporting\n"); in vb2_core_expbuf()
2251 dprintk(q, 1, "queue does support only O_CLOEXEC and access mode flags\n"); in vb2_core_expbuf()
2255 if (type != q->type) { in vb2_core_expbuf()
2256 dprintk(q, 1, "invalid buffer type\n"); in vb2_core_expbuf()
2260 if (index >= q->num_buffers) { in vb2_core_expbuf()
2261 dprintk(q, 1, "buffer index out of range\n"); in vb2_core_expbuf()
2265 vb = q->bufs[index]; in vb2_core_expbuf()
2268 dprintk(q, 1, "buffer plane out of range\n"); in vb2_core_expbuf()
2272 if (vb2_fileio_is_active(q)) { in vb2_core_expbuf()
2273 dprintk(q, 1, "expbuf: file io in progress\n"); in vb2_core_expbuf()
2284 dprintk(q, 1, "failed to export buffer %d, plane %d\n", in vb2_core_expbuf()
2291 dprintk(q, 3, "buffer %d, plane %d failed to export (%d)\n", in vb2_core_expbuf()
2297 dprintk(q, 3, "buffer %d, plane %d exported as %d descriptor\n", in vb2_core_expbuf()
2305 int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) in vb2_mmap() argument
2317 dprintk(q, 1, "invalid vma flags, VM_SHARED needed\n"); in vb2_mmap()
2320 if (q->is_output) { in vb2_mmap()
2322 dprintk(q, 1, "invalid vma flags, VM_WRITE needed\n"); in vb2_mmap()
2327 dprintk(q, 1, "invalid vma flags, VM_READ needed\n"); in vb2_mmap()
2332 mutex_lock(&q->mmap_lock); in vb2_mmap()
2338 ret = __find_plane_by_offset(q, off, &buffer, &plane); in vb2_mmap()
2342 vb = q->bufs[buffer]; in vb2_mmap()
2351 dprintk(q, 1, in vb2_mmap()
2367 mutex_unlock(&q->mmap_lock); in vb2_mmap()
2371 dprintk(q, 3, "buffer %d, plane %d successfully mapped\n", buffer, plane); in vb2_mmap()
2377 unsigned long vb2_get_unmapped_area(struct vb2_queue *q, in vb2_get_unmapped_area() argument
2389 mutex_lock(&q->mmap_lock); in vb2_get_unmapped_area()
2395 ret = __find_plane_by_offset(q, off, &buffer, &plane); in vb2_get_unmapped_area()
2399 vb = q->bufs[buffer]; in vb2_get_unmapped_area()
2402 mutex_unlock(&q->mmap_lock); in vb2_get_unmapped_area()
2406 mutex_unlock(&q->mmap_lock); in vb2_get_unmapped_area()
2412 int vb2_core_queue_init(struct vb2_queue *q) in vb2_core_queue_init() argument
2417 if (WARN_ON(!q) || in vb2_core_queue_init()
2418 WARN_ON(!q->ops) || in vb2_core_queue_init()
2419 WARN_ON(!q->mem_ops) || in vb2_core_queue_init()
2420 WARN_ON(!q->type) || in vb2_core_queue_init()
2421 WARN_ON(!q->io_modes) || in vb2_core_queue_init()
2422 WARN_ON(!q->ops->queue_setup) || in vb2_core_queue_init()
2423 WARN_ON(!q->ops->buf_queue)) in vb2_core_queue_init()
2426 if (WARN_ON(q->requires_requests && !q->supports_requests)) in vb2_core_queue_init()
2431 * q->min_buffers_needed can cause vb2_core_qbuf() to fail if in vb2_core_queue_init()
2437 if (WARN_ON(q->supports_requests && q->min_buffers_needed)) in vb2_core_queue_init()
2440 INIT_LIST_HEAD(&q->queued_list); in vb2_core_queue_init()
2441 INIT_LIST_HEAD(&q->done_list); in vb2_core_queue_init()
2442 spin_lock_init(&q->done_lock); in vb2_core_queue_init()
2443 mutex_init(&q->mmap_lock); in vb2_core_queue_init()
2444 init_waitqueue_head(&q->done_wq); in vb2_core_queue_init()
2446 q->memory = VB2_MEMORY_UNKNOWN; in vb2_core_queue_init()
2448 if (q->buf_struct_size == 0) in vb2_core_queue_init()
2449 q->buf_struct_size = sizeof(struct vb2_buffer); in vb2_core_queue_init()
2451 if (q->bidirectional) in vb2_core_queue_init()
2452 q->dma_dir = DMA_BIDIRECTIONAL; in vb2_core_queue_init()
2454 q->dma_dir = q->is_output ? DMA_TO_DEVICE : DMA_FROM_DEVICE; in vb2_core_queue_init()
2456 if (q->name[0] == '\0') in vb2_core_queue_init()
2457 snprintf(q->name, sizeof(q->name), "%s-%p", in vb2_core_queue_init()
2458 q->is_output ? "out" : "cap", q); in vb2_core_queue_init()
2464 static int __vb2_init_fileio(struct vb2_queue *q, int read);
2465 static int __vb2_cleanup_fileio(struct vb2_queue *q);
2466 void vb2_core_queue_release(struct vb2_queue *q) in vb2_core_queue_release() argument
2468 __vb2_cleanup_fileio(q); in vb2_core_queue_release()
2469 __vb2_queue_cancel(q); in vb2_core_queue_release()
2470 mutex_lock(&q->mmap_lock); in vb2_core_queue_release()
2471 __vb2_queue_free(q, q->num_buffers); in vb2_core_queue_release()
2472 mutex_unlock(&q->mmap_lock); in vb2_core_queue_release()
2476 __poll_t vb2_core_poll(struct vb2_queue *q, struct file *file, in vb2_core_poll() argument
2490 poll_wait(file, &q->done_wq, wait); in vb2_core_poll()
2492 if (!q->is_output && !(req_events & (EPOLLIN | EPOLLRDNORM))) in vb2_core_poll()
2494 if (q->is_output && !(req_events & (EPOLLOUT | EPOLLWRNORM))) in vb2_core_poll()
2500 if (q->num_buffers == 0 && !vb2_fileio_is_active(q)) { in vb2_core_poll()
2501 if (!q->is_output && (q->io_modes & VB2_READ) && in vb2_core_poll()
2503 if (__vb2_init_fileio(q, 1)) in vb2_core_poll()
2506 if (q->is_output && (q->io_modes & VB2_WRITE) && in vb2_core_poll()
2508 if (__vb2_init_fileio(q, 0)) in vb2_core_poll()
2521 if (!vb2_is_streaming(q) || q->error) in vb2_core_poll()
2530 if (q->quirk_poll_must_check_waiting_for_buffers && in vb2_core_poll()
2531 q->waiting_for_buffers && (req_events & (EPOLLIN | EPOLLRDNORM))) in vb2_core_poll()
2538 if (q->is_output && q->fileio && q->queued_count < q->num_buffers) in vb2_core_poll()
2541 if (list_empty(&q->done_list)) { in vb2_core_poll()
2546 if (q->last_buffer_dequeued) in vb2_core_poll()
2553 spin_lock_irqsave(&q->done_lock, flags); in vb2_core_poll()
2554 if (!list_empty(&q->done_list)) in vb2_core_poll()
2555 vb = list_first_entry(&q->done_list, struct vb2_buffer, in vb2_core_poll()
2557 spin_unlock_irqrestore(&q->done_lock, flags); in vb2_core_poll()
2561 return (q->is_output) ? in vb2_core_poll()
2587 * written to. If equal to q->num_buffers then a new buffer
2598 * in this field. Once it is equal to q->num_buffers all
2622 * @q: videobuf2 queue
2625 static int __vb2_init_fileio(struct vb2_queue *q, int read) in __vb2_init_fileio() argument
2634 if (WARN_ON((read && !(q->io_modes & VB2_READ)) || in __vb2_init_fileio()
2635 (!read && !(q->io_modes & VB2_WRITE)))) in __vb2_init_fileio()
2641 if (!q->mem_ops->vaddr) in __vb2_init_fileio()
2647 if (q->streaming || q->num_buffers > 0) in __vb2_init_fileio()
2651 * Start with q->min_buffers_needed + 1, driver can increase it in in __vb2_init_fileio()
2658 count = max(2, q->min_buffers_needed + 1); in __vb2_init_fileio()
2660 dprintk(q, 3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n", in __vb2_init_fileio()
2661 (read) ? "read" : "write", count, q->fileio_read_once, in __vb2_init_fileio()
2662 q->fileio_write_immediately); in __vb2_init_fileio()
2668 fileio->read_once = q->fileio_read_once; in __vb2_init_fileio()
2669 fileio->write_immediately = q->fileio_write_immediately; in __vb2_init_fileio()
2677 fileio->type = q->type; in __vb2_init_fileio()
2678 q->fileio = fileio; in __vb2_init_fileio()
2679 ret = vb2_core_reqbufs(q, fileio->memory, 0, &fileio->count); in __vb2_init_fileio()
2687 if (q->bufs[0]->num_planes != 1) { in __vb2_init_fileio()
2695 for (i = 0; i < q->num_buffers; i++) { in __vb2_init_fileio()
2696 fileio->bufs[i].vaddr = vb2_plane_vaddr(q->bufs[i], 0); in __vb2_init_fileio()
2701 fileio->bufs[i].size = vb2_plane_size(q->bufs[i], 0); in __vb2_init_fileio()
2711 for (i = 0; i < q->num_buffers; i++) { in __vb2_init_fileio()
2712 ret = vb2_core_qbuf(q, i, NULL, NULL); in __vb2_init_fileio()
2719 * initial_index to q->num_buffers in __vb2_init_fileio()
2721 fileio->initial_index = q->num_buffers; in __vb2_init_fileio()
2722 fileio->cur_index = q->num_buffers; in __vb2_init_fileio()
2728 ret = vb2_core_streamon(q, q->type); in __vb2_init_fileio()
2736 vb2_core_reqbufs(q, fileio->memory, 0, &fileio->count); in __vb2_init_fileio()
2739 q->fileio = NULL; in __vb2_init_fileio()
2746 * @q: videobuf2 queue
2748 static int __vb2_cleanup_fileio(struct vb2_queue *q) in __vb2_cleanup_fileio() argument
2750 struct vb2_fileio_data *fileio = q->fileio; in __vb2_cleanup_fileio()
2753 vb2_core_streamoff(q, q->type); in __vb2_cleanup_fileio()
2754 q->fileio = NULL; in __vb2_cleanup_fileio()
2756 vb2_core_reqbufs(q, fileio->memory, 0, &fileio->count); in __vb2_cleanup_fileio()
2758 dprintk(q, 3, "file io emulator closed\n"); in __vb2_cleanup_fileio()
2765 * @q: videobuf2 queue
2772 static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_t count, in __vb2_perform_fileio() argument
2777 bool is_multiplanar = q->is_multiplanar; in __vb2_perform_fileio()
2783 bool copy_timestamp = !read && q->copy_timestamp; in __vb2_perform_fileio()
2787 dprintk(q, 3, "mode %s, offset %ld, count %zd, %sblocking\n", in __vb2_perform_fileio()
2794 if (q->waiting_in_dqbuf) { in __vb2_perform_fileio()
2795 dprintk(q, 3, "another dup()ped fd is %s\n", in __vb2_perform_fileio()
2803 if (!vb2_fileio_is_active(q)) { in __vb2_perform_fileio()
2804 ret = __vb2_init_fileio(q, read); in __vb2_perform_fileio()
2805 dprintk(q, 3, "vb2_init_fileio result: %d\n", ret); in __vb2_perform_fileio()
2809 fileio = q->fileio; in __vb2_perform_fileio()
2815 if (index >= q->num_buffers) { in __vb2_perform_fileio()
2821 ret = vb2_core_dqbuf(q, &index, NULL, nonblock); in __vb2_perform_fileio()
2822 dprintk(q, 5, "vb2_dqbuf result: %d\n", ret); in __vb2_perform_fileio()
2829 b = q->bufs[index]; in __vb2_perform_fileio()
2836 buf->size = read ? vb2_get_plane_payload(q->bufs[index], 0) in __vb2_perform_fileio()
2837 : vb2_plane_size(q->bufs[index], 0); in __vb2_perform_fileio()
2853 dprintk(q, 5, "reducing read count: %zd\n", count); in __vb2_perform_fileio()
2859 dprintk(q, 3, "copying %zd bytes - buffer %d, offset %u\n", in __vb2_perform_fileio()
2866 dprintk(q, 3, "error copying data\n"); in __vb2_perform_fileio()
2880 struct vb2_buffer *b = q->bufs[index]; in __vb2_perform_fileio()
2886 dprintk(q, 3, "read limit reached\n"); in __vb2_perform_fileio()
2887 return __vb2_cleanup_fileio(q); in __vb2_perform_fileio()
2897 ret = vb2_core_qbuf(q, index, NULL, NULL); in __vb2_perform_fileio()
2898 dprintk(q, 5, "vb2_dbuf result: %d\n", ret); in __vb2_perform_fileio()
2907 buf->size = vb2_plane_size(q->bufs[index], 0); in __vb2_perform_fileio()
2913 if (fileio->initial_index < q->num_buffers) in __vb2_perform_fileio()
2917 * queued for the first time (initial_index < q->num_buffers) in __vb2_perform_fileio()
2918 * or it is equal to q->num_buffers, meaning that the next in __vb2_perform_fileio()
2933 size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count, in vb2_read() argument
2936 return __vb2_perform_fileio(q, data, count, ppos, nonblocking, 1); in vb2_read()
2940 size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count, in vb2_write() argument
2943 return __vb2_perform_fileio(q, (char __user *) data, count, in vb2_write()
2957 struct vb2_queue *q = data; in vb2_thread() local
2958 struct vb2_threadio_data *threadio = q->threadio; in vb2_thread()
2964 if (q->is_output) { in vb2_thread()
2965 prequeue = q->num_buffers; in vb2_thread()
2966 copy_timestamp = q->copy_timestamp; in vb2_thread()
2978 vb = q->bufs[index++]; in vb2_thread()
2981 call_void_qop(q, wait_finish, q); in vb2_thread()
2983 ret = vb2_core_dqbuf(q, &index, NULL, 0); in vb2_thread()
2984 call_void_qop(q, wait_prepare, q); in vb2_thread()
2985 dprintk(q, 5, "file io: vb2_dqbuf result: %d\n", ret); in vb2_thread()
2987 vb = q->bufs[index]; in vb2_thread()
2996 call_void_qop(q, wait_finish, q); in vb2_thread()
3000 ret = vb2_core_qbuf(q, vb->index, NULL, NULL); in vb2_thread()
3001 call_void_qop(q, wait_prepare, q); in vb2_thread()
3019 int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv, in vb2_thread_start() argument
3025 if (q->threadio) in vb2_thread_start()
3027 if (vb2_is_busy(q)) in vb2_thread_start()
3029 if (WARN_ON(q->fileio)) in vb2_thread_start()
3038 ret = __vb2_init_fileio(q, !q->is_output); in vb2_thread_start()
3039 dprintk(q, 3, "file io: vb2_init_fileio result: %d\n", ret); in vb2_thread_start()
3042 q->threadio = threadio; in vb2_thread_start()
3043 threadio->thread = kthread_run(vb2_thread, q, "vb2-%s", thread_name); in vb2_thread_start()
3052 __vb2_cleanup_fileio(q); in vb2_thread_start()
3059 int vb2_thread_stop(struct vb2_queue *q) in vb2_thread_stop() argument
3061 struct vb2_threadio_data *threadio = q->threadio; in vb2_thread_stop()
3068 vb2_queue_error(q); in vb2_thread_stop()
3070 __vb2_cleanup_fileio(q); in vb2_thread_stop()
3073 q->threadio = NULL; in vb2_thread_stop()