2 * generic helper functions for handling video4linux capture buffers
4 * (c) 2007 Mauro Carvalho Chehab, <mchehab@infradead.org>
6 * Highly based on video-buf written originally by:
7 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
8 * (c) 2006 Mauro Carvalho Chehab, <mchehab@infradead.org>
9 * (c) 2006 Ted Walther and John Sokol
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2
16 #include <linux/init.h>
17 #include <linux/module.h>
18 #include <linux/moduleparam.h>
19 #include <linux/slab.h>
20 #include <linux/interrupt.h>
22 #include <media/videobuf-core.h>
24 #define MAGIC_BUFFER 0x20070728
25 #define MAGIC_CHECK(is, should) do { \
26 if (unlikely((is) != (should))) { \
27 printk(KERN_ERR "magic mismatch: %x (expected %x)\n", is, should); \
31 module_param(debug, int, 0644);
33 MODULE_DESCRIPTION("helper module to manage video4linux buffers");
34 MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
35 MODULE_LICENSE("GPL");
37 #define dprintk(level, fmt, arg...) do { \
39 printk(KERN_DEBUG "vbuf: " fmt , ## arg); } while (0)
41 /* --------------------------------------------------------------------- */
43 #define CALL(q, f, arg...) \
44 ((q->int_ops->f) ? q->int_ops->f(arg) : 0)
46 void *videobuf_alloc(struct videobuf_queue *q)
48 struct videobuf_buffer *vb;
50 BUG_ON(q->msize < sizeof(*vb));
52 if (!q->int_ops || !q->int_ops->alloc) {
53 printk(KERN_ERR "No specific ops defined!\n");
57 vb = q->int_ops->alloc(q->msize);
60 init_waitqueue_head(&vb->done);
61 vb->magic = MAGIC_BUFFER;
67 int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
70 DECLARE_WAITQUEUE(wait, current);
72 MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
73 add_wait_queue(&vb->done, &wait);
74 while (vb->state == VIDEOBUF_ACTIVE || vb->state == VIDEOBUF_QUEUED) {
79 set_current_state(intr ? TASK_INTERRUPTIBLE
80 : TASK_UNINTERRUPTIBLE);
81 if (vb->state == VIDEOBUF_ACTIVE ||
82 vb->state == VIDEOBUF_QUEUED)
84 set_current_state(TASK_RUNNING);
85 if (intr && signal_pending(current)) {
86 dprintk(1, "buffer waiton: -EINTR\n");
91 remove_wait_queue(&vb->done, &wait);
95 int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb,
96 struct v4l2_framebuffer *fbuf)
98 MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
99 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
101 /* This is required to avoid OOPS on some cases,
102 since mmap_mapper() method should be called before _iolock.
103 On some cases, the mmap_mapper() is called only after scheduling.
105 wait_event_timeout(vb->done, q->is_mmapped, msecs_to_jiffies(100));
106 if (!q->is_mmapped) {
107 printk(KERN_ERR "Error: mmap_mapper() never called!\n");
111 return CALL(q, iolock, q, vb, fbuf);
114 /* --------------------------------------------------------------------- */
117 void videobuf_queue_core_init(struct videobuf_queue *q,
118 struct videobuf_queue_ops *ops,
121 enum v4l2_buf_type type,
122 enum v4l2_field field,
125 struct videobuf_qtype_ops *int_ops)
127 memset(q, 0, sizeof(*q));
128 q->irqlock = irqlock;
135 q->int_ops = int_ops;
137 /* All buffer operations are mandatory */
138 BUG_ON(!q->ops->buf_setup);
139 BUG_ON(!q->ops->buf_prepare);
140 BUG_ON(!q->ops->buf_queue);
141 BUG_ON(!q->ops->buf_release);
143 /* Having implementations for abstract methods are mandatory */
146 mutex_init(&q->lock);
147 INIT_LIST_HEAD(&q->stream);
150 /* Locking: Only usage in bttv unsafe find way to remove */
151 int videobuf_queue_is_busy(struct videobuf_queue *q)
155 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
158 dprintk(1, "busy: streaming active\n");
162 dprintk(1, "busy: pending read #1\n");
166 dprintk(1, "busy: pending read #2\n");
169 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
170 if (NULL == q->bufs[i])
172 if (q->bufs[i]->map) {
173 dprintk(1, "busy: buffer #%d mapped\n", i);
176 if (q->bufs[i]->state == VIDEOBUF_QUEUED) {
177 dprintk(1, "busy: buffer #%d queued\n", i);
180 if (q->bufs[i]->state == VIDEOBUF_ACTIVE) {
181 dprintk(1, "busy: buffer #%d avtive\n", i);
188 /* Locking: Caller holds q->lock */
189 void videobuf_queue_cancel(struct videobuf_queue *q)
191 unsigned long flags = 0;
194 /* remove queued buffers from list */
196 spin_lock_irqsave(q->irqlock, flags);
197 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
198 if (NULL == q->bufs[i])
200 if (q->bufs[i]->state == VIDEOBUF_QUEUED) {
201 list_del(&q->bufs[i]->queue);
202 q->bufs[i]->state = VIDEOBUF_ERROR;
206 spin_unlock_irqrestore(q->irqlock, flags);
208 /* free all buffers + clear queue */
209 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
210 if (NULL == q->bufs[i])
212 q->ops->buf_release(q, q->bufs[i]);
214 INIT_LIST_HEAD(&q->stream);
217 /* --------------------------------------------------------------------- */
219 /* Locking: Caller holds q->lock */
220 enum v4l2_field videobuf_next_field(struct videobuf_queue *q)
222 enum v4l2_field field = q->field;
224 BUG_ON(V4L2_FIELD_ANY == field);
226 if (V4L2_FIELD_ALTERNATE == field) {
227 if (V4L2_FIELD_TOP == q->last) {
228 field = V4L2_FIELD_BOTTOM;
229 q->last = V4L2_FIELD_BOTTOM;
231 field = V4L2_FIELD_TOP;
232 q->last = V4L2_FIELD_TOP;
238 /* Locking: Caller holds q->lock */
239 static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
240 struct videobuf_buffer *vb, enum v4l2_buf_type type)
242 MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
243 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
248 b->memory = vb->memory;
250 case V4L2_MEMORY_MMAP:
251 b->m.offset = vb->boff;
252 b->length = vb->bsize;
254 case V4L2_MEMORY_USERPTR:
255 b->m.userptr = vb->baddr;
256 b->length = vb->bsize;
258 case V4L2_MEMORY_OVERLAY:
259 b->m.offset = vb->boff;
265 b->flags |= V4L2_BUF_FLAG_MAPPED;
268 case VIDEOBUF_PREPARED:
269 case VIDEOBUF_QUEUED:
270 case VIDEOBUF_ACTIVE:
271 b->flags |= V4L2_BUF_FLAG_QUEUED;
275 b->flags |= V4L2_BUF_FLAG_DONE;
277 case VIDEOBUF_NEEDS_INIT:
283 if (vb->input != UNSET) {
284 b->flags |= V4L2_BUF_FLAG_INPUT;
285 b->input = vb->input;
288 b->field = vb->field;
289 b->timestamp = vb->ts;
290 b->bytesused = vb->size;
291 b->sequence = vb->field_count >> 1;
294 /* Locking: Caller holds q->lock */
295 static int __videobuf_mmap_free(struct videobuf_queue *q)
303 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
306 rc = CALL(q, mmap_free, q);
313 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
314 if (NULL == q->bufs[i])
316 q->ops->buf_release(q, q->bufs[i]);
324 int videobuf_mmap_free(struct videobuf_queue *q)
327 mutex_lock(&q->lock);
328 ret = __videobuf_mmap_free(q);
329 mutex_unlock(&q->lock);
333 /* Locking: Caller holds q->lock */
334 static int __videobuf_mmap_setup(struct videobuf_queue *q,
335 unsigned int bcount, unsigned int bsize,
336 enum v4l2_memory memory)
341 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
343 err = __videobuf_mmap_free(q);
347 /* Allocate and initialize buffers */
348 for (i = 0; i < bcount; i++) {
349 q->bufs[i] = videobuf_alloc(q);
351 if (q->bufs[i] == NULL)
355 q->bufs[i]->input = UNSET;
356 q->bufs[i]->memory = memory;
357 q->bufs[i]->bsize = bsize;
359 case V4L2_MEMORY_MMAP:
360 q->bufs[i]->boff = bsize * i;
362 case V4L2_MEMORY_USERPTR:
363 case V4L2_MEMORY_OVERLAY:
372 dprintk(1, "mmap setup: %d buffers, %d bytes each\n",
378 int videobuf_mmap_setup(struct videobuf_queue *q,
379 unsigned int bcount, unsigned int bsize,
380 enum v4l2_memory memory)
383 mutex_lock(&q->lock);
384 ret = __videobuf_mmap_setup(q, bcount, bsize, memory);
385 mutex_unlock(&q->lock);
389 int videobuf_reqbufs(struct videobuf_queue *q,
390 struct v4l2_requestbuffers *req)
392 unsigned int size, count;
395 if (req->count < 1) {
396 dprintk(1, "reqbufs: count invalid (%d)\n", req->count);
400 if (req->memory != V4L2_MEMORY_MMAP &&
401 req->memory != V4L2_MEMORY_USERPTR &&
402 req->memory != V4L2_MEMORY_OVERLAY) {
403 dprintk(1, "reqbufs: memory type invalid\n");
407 mutex_lock(&q->lock);
408 if (req->type != q->type) {
409 dprintk(1, "reqbufs: queue type invalid\n");
415 dprintk(1, "reqbufs: streaming already exists\n");
419 if (!list_empty(&q->stream)) {
420 dprintk(1, "reqbufs: stream running\n");
426 if (count > VIDEO_MAX_FRAME)
427 count = VIDEO_MAX_FRAME;
429 q->ops->buf_setup(q, &count, &size);
430 size = PAGE_ALIGN(size);
431 dprintk(1, "reqbufs: bufs=%d, size=0x%x [%d pages total]\n",
432 count, size, (count*size)>>PAGE_SHIFT);
434 retval = __videobuf_mmap_setup(q, count, size, req->memory);
436 dprintk(1, "reqbufs: mmap setup returned %d\n", retval);
443 mutex_unlock(&q->lock);
447 int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
451 mutex_lock(&q->lock);
452 if (unlikely(b->type != q->type)) {
453 dprintk(1, "querybuf: Wrong type.\n");
456 if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) {
457 dprintk(1, "querybuf: index out of range.\n");
460 if (unlikely(NULL == q->bufs[b->index])) {
461 dprintk(1, "querybuf: buffer is null.\n");
465 videobuf_status(q, b, q->bufs[b->index], q->type);
469 mutex_unlock(&q->lock);
473 int videobuf_qbuf(struct videobuf_queue *q,
474 struct v4l2_buffer *b)
476 struct videobuf_buffer *buf;
477 enum v4l2_field field;
478 unsigned long flags = 0;
481 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
483 if (b->memory == V4L2_MEMORY_MMAP)
484 down_read(¤t->mm->mmap_sem);
486 mutex_lock(&q->lock);
489 dprintk(1, "qbuf: Reading running...\n");
493 if (b->type != q->type) {
494 dprintk(1, "qbuf: Wrong type.\n");
497 if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
498 dprintk(1, "qbuf: index out of range.\n");
501 buf = q->bufs[b->index];
503 dprintk(1, "qbuf: buffer is null.\n");
506 MAGIC_CHECK(buf->magic, MAGIC_BUFFER);
507 if (buf->memory != b->memory) {
508 dprintk(1, "qbuf: memory type is wrong.\n");
511 if (buf->state != VIDEOBUF_NEEDS_INIT && buf->state != VIDEOBUF_IDLE) {
512 dprintk(1, "qbuf: buffer is already queued or active.\n");
516 if (b->flags & V4L2_BUF_FLAG_INPUT) {
517 if (b->input >= q->inputs) {
518 dprintk(1, "qbuf: wrong input.\n");
521 buf->input = b->input;
527 case V4L2_MEMORY_MMAP:
528 if (0 == buf->baddr) {
529 dprintk(1, "qbuf: mmap requested "
530 "but buffer addr is zero!\n");
534 case V4L2_MEMORY_USERPTR:
535 if (b->length < buf->bsize) {
536 dprintk(1, "qbuf: buffer length is not enough\n");
539 if (VIDEOBUF_NEEDS_INIT != buf->state &&
540 buf->baddr != b->m.userptr)
541 q->ops->buf_release(q, buf);
542 buf->baddr = b->m.userptr;
544 case V4L2_MEMORY_OVERLAY:
545 buf->boff = b->m.offset;
548 dprintk(1, "qbuf: wrong memory type\n");
552 dprintk(1, "qbuf: requesting next field\n");
553 field = videobuf_next_field(q);
554 retval = q->ops->buf_prepare(q, buf, field);
556 dprintk(1, "qbuf: buffer_prepare returned %d\n", retval);
560 list_add_tail(&buf->stream, &q->stream);
563 spin_lock_irqsave(q->irqlock, flags);
564 q->ops->buf_queue(q, buf);
566 spin_unlock_irqrestore(q->irqlock, flags);
568 dprintk(1, "qbuf: succeded\n");
572 mutex_unlock(&q->lock);
574 if (b->memory == V4L2_MEMORY_MMAP)
575 up_read(¤t->mm->mmap_sem);
580 int videobuf_dqbuf(struct videobuf_queue *q,
581 struct v4l2_buffer *b, int nonblocking)
583 struct videobuf_buffer *buf;
586 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
588 mutex_lock(&q->lock);
591 dprintk(1, "dqbuf: Reading running...\n");
595 if (b->type != q->type) {
596 dprintk(1, "dqbuf: Wrong type.\n");
599 if (list_empty(&q->stream)) {
600 dprintk(1, "dqbuf: stream running\n");
603 buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
604 retval = videobuf_waiton(buf, nonblocking, 1);
606 dprintk(1, "dqbuf: waiton returned %d\n", retval);
609 switch (buf->state) {
611 dprintk(1, "dqbuf: state is error\n");
613 CALL(q, sync, q, buf);
614 buf->state = VIDEOBUF_IDLE;
617 dprintk(1, "dqbuf: state is done\n");
618 CALL(q, sync, q, buf);
619 buf->state = VIDEOBUF_IDLE;
622 dprintk(1, "dqbuf: state invalid\n");
626 list_del(&buf->stream);
627 memset(b, 0, sizeof(*b));
628 videobuf_status(q, b, buf, q->type);
631 mutex_unlock(&q->lock);
635 int videobuf_streamon(struct videobuf_queue *q)
637 struct videobuf_buffer *buf;
638 unsigned long flags = 0;
641 mutex_lock(&q->lock);
650 spin_lock_irqsave(q->irqlock, flags);
651 list_for_each_entry(buf, &q->stream, stream)
652 if (buf->state == VIDEOBUF_PREPARED)
653 q->ops->buf_queue(q, buf);
655 spin_unlock_irqrestore(q->irqlock, flags);
658 mutex_unlock(&q->lock);
662 /* Locking: Caller holds q->lock */
663 static int __videobuf_streamoff(struct videobuf_queue *q)
668 videobuf_queue_cancel(q);
674 int videobuf_streamoff(struct videobuf_queue *q)
678 mutex_lock(&q->lock);
679 retval = __videobuf_streamoff(q);
680 mutex_unlock(&q->lock);
685 /* Locking: Caller holds q->lock */
686 static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
688 size_t count, loff_t *ppos)
690 enum v4l2_field field;
691 unsigned long flags = 0;
694 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
697 q->read_buf = videobuf_alloc(q);
698 if (NULL == q->read_buf)
701 q->read_buf->memory = V4L2_MEMORY_USERPTR;
702 q->read_buf->baddr = (unsigned long)data;
703 q->read_buf->bsize = count;
705 field = videobuf_next_field(q);
706 retval = q->ops->buf_prepare(q, q->read_buf, field);
710 /* start capture & wait */
712 spin_lock_irqsave(q->irqlock, flags);
713 q->ops->buf_queue(q, q->read_buf);
715 spin_unlock_irqrestore(q->irqlock, flags);
716 retval = videobuf_waiton(q->read_buf, 0, 0);
718 CALL(q, sync, q, q->read_buf);
719 if (VIDEOBUF_ERROR == q->read_buf->state)
722 retval = q->read_buf->size;
727 q->ops->buf_release(q, q->read_buf);
733 ssize_t videobuf_read_one(struct videobuf_queue *q,
734 char __user *data, size_t count, loff_t *ppos,
737 enum v4l2_field field;
738 unsigned long flags = 0;
739 unsigned size, nbufs;
742 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
744 mutex_lock(&q->lock);
747 q->ops->buf_setup(q, &nbufs, &size);
749 if (NULL == q->read_buf &&
752 retval = videobuf_read_zerocopy(q, data, count, ppos);
753 if (retval >= 0 || retval == -EIO)
756 /* fallback to kernel bounce buffer on failures */
759 if (NULL == q->read_buf) {
760 /* need to capture a new frame */
762 q->read_buf = videobuf_alloc(q);
764 dprintk(1, "video alloc=0x%p\n", q->read_buf);
765 if (NULL == q->read_buf)
767 q->read_buf->memory = V4L2_MEMORY_USERPTR;
768 q->read_buf->bsize = count; /* preferred size */
769 field = videobuf_next_field(q);
770 retval = q->ops->buf_prepare(q, q->read_buf, field);
778 spin_lock_irqsave(q->irqlock, flags);
780 q->ops->buf_queue(q, q->read_buf);
782 spin_unlock_irqrestore(q->irqlock, flags);
786 /* wait until capture is done */
787 retval = videobuf_waiton(q->read_buf, nonblocking, 1);
791 CALL(q, sync, q, q->read_buf);
793 if (VIDEOBUF_ERROR == q->read_buf->state) {
794 /* catch I/O errors */
795 q->ops->buf_release(q, q->read_buf);
802 /* Copy to userspace */
803 retval = CALL(q, video_copy_to_user, q, data, count, nonblocking);
807 q->read_off += retval;
808 if (q->read_off == q->read_buf->size) {
809 /* all data copied, cleanup */
810 q->ops->buf_release(q, q->read_buf);
816 mutex_unlock(&q->lock);
820 /* Locking: Caller holds q->lock */
821 static int __videobuf_read_start(struct videobuf_queue *q)
823 enum v4l2_field field;
824 unsigned long flags = 0;
825 unsigned int count = 0, size = 0;
828 q->ops->buf_setup(q, &count, &size);
831 if (count > VIDEO_MAX_FRAME)
832 count = VIDEO_MAX_FRAME;
833 size = PAGE_ALIGN(size);
835 err = __videobuf_mmap_setup(q, count, size, V4L2_MEMORY_USERPTR);
841 for (i = 0; i < count; i++) {
842 field = videobuf_next_field(q);
843 err = q->ops->buf_prepare(q, q->bufs[i], field);
846 list_add_tail(&q->bufs[i]->stream, &q->stream);
849 spin_lock_irqsave(q->irqlock, flags);
850 for (i = 0; i < count; i++)
851 q->ops->buf_queue(q, q->bufs[i]);
853 spin_unlock_irqrestore(q->irqlock, flags);
858 static void __videobuf_read_stop(struct videobuf_queue *q)
863 videobuf_queue_cancel(q);
864 __videobuf_mmap_free(q);
865 INIT_LIST_HEAD(&q->stream);
866 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
867 if (NULL == q->bufs[i])
877 int videobuf_read_start(struct videobuf_queue *q)
881 mutex_lock(&q->lock);
882 rc = __videobuf_read_start(q);
883 mutex_unlock(&q->lock);
888 void videobuf_read_stop(struct videobuf_queue *q)
890 mutex_lock(&q->lock);
891 __videobuf_read_stop(q);
892 mutex_unlock(&q->lock);
895 void videobuf_stop(struct videobuf_queue *q)
897 mutex_lock(&q->lock);
900 __videobuf_streamoff(q);
903 __videobuf_read_stop(q);
905 mutex_unlock(&q->lock);
909 ssize_t videobuf_read_stream(struct videobuf_queue *q,
910 char __user *data, size_t count, loff_t *ppos,
911 int vbihack, int nonblocking)
914 unsigned long flags = 0;
916 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
918 dprintk(2, "%s\n", __FUNCTION__);
919 mutex_lock(&q->lock);
924 retval = __videobuf_read_start(q);
931 /* get / wait for data */
932 if (NULL == q->read_buf) {
933 q->read_buf = list_entry(q->stream.next,
934 struct videobuf_buffer,
936 list_del(&q->read_buf->stream);
939 rc = videobuf_waiton(q->read_buf, nonblocking, 1);
946 if (q->read_buf->state == VIDEOBUF_DONE) {
947 rc = CALL(q, copy_stream, q, data + retval, count,
948 retval, vbihack, nonblocking);
958 q->read_off = q->read_buf->size;
963 /* requeue buffer when done with copying */
964 if (q->read_off == q->read_buf->size) {
965 list_add_tail(&q->read_buf->stream,
968 spin_lock_irqsave(q->irqlock, flags);
969 q->ops->buf_queue(q, q->read_buf);
971 spin_unlock_irqrestore(q->irqlock, flags);
979 mutex_unlock(&q->lock);
983 unsigned int videobuf_poll_stream(struct file *file,
984 struct videobuf_queue *q,
987 struct videobuf_buffer *buf = NULL;
990 mutex_lock(&q->lock);
992 if (!list_empty(&q->stream))
993 buf = list_entry(q->stream.next,
994 struct videobuf_buffer, stream);
997 __videobuf_read_start(q);
1000 } else if (NULL == q->read_buf) {
1001 q->read_buf = list_entry(q->stream.next,
1002 struct videobuf_buffer,
1004 list_del(&q->read_buf->stream);
1013 poll_wait(file, &buf->done, wait);
1014 if (buf->state == VIDEOBUF_DONE ||
1015 buf->state == VIDEOBUF_ERROR)
1016 rc = POLLIN|POLLRDNORM;
1018 mutex_unlock(&q->lock);
1022 int videobuf_mmap_mapper(struct videobuf_queue *q,
1023 struct vm_area_struct *vma)
1027 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
1029 mutex_lock(&q->lock);
1030 retval = CALL(q, mmap_mapper, q, vma);
1032 mutex_unlock(&q->lock);
1037 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1038 int videobuf_cgmbuf(struct videobuf_queue *q,
1039 struct video_mbuf *mbuf, int count)
1041 struct v4l2_requestbuffers req;
1044 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
1046 memset(&req, 0, sizeof(req));
1049 req.memory = V4L2_MEMORY_MMAP;
1050 rc = videobuf_reqbufs(q, &req);
1054 mbuf->frames = req.count;
1056 for (i = 0; i < mbuf->frames; i++) {
1057 mbuf->offsets[i] = q->bufs[i]->boff;
1058 mbuf->size += q->bufs[i]->bsize;
1063 EXPORT_SYMBOL_GPL(videobuf_cgmbuf);
1066 /* --------------------------------------------------------------------- */
1068 EXPORT_SYMBOL_GPL(videobuf_waiton);
1069 EXPORT_SYMBOL_GPL(videobuf_iolock);
1071 EXPORT_SYMBOL_GPL(videobuf_alloc);
1073 EXPORT_SYMBOL_GPL(videobuf_queue_core_init);
1074 EXPORT_SYMBOL_GPL(videobuf_queue_cancel);
1075 EXPORT_SYMBOL_GPL(videobuf_queue_is_busy);
1077 EXPORT_SYMBOL_GPL(videobuf_next_field);
1078 EXPORT_SYMBOL_GPL(videobuf_reqbufs);
1079 EXPORT_SYMBOL_GPL(videobuf_querybuf);
1080 EXPORT_SYMBOL_GPL(videobuf_qbuf);
1081 EXPORT_SYMBOL_GPL(videobuf_dqbuf);
1082 EXPORT_SYMBOL_GPL(videobuf_streamon);
1083 EXPORT_SYMBOL_GPL(videobuf_streamoff);
1085 EXPORT_SYMBOL_GPL(videobuf_read_start);
1086 EXPORT_SYMBOL_GPL(videobuf_read_stop);
1087 EXPORT_SYMBOL_GPL(videobuf_stop);
1088 EXPORT_SYMBOL_GPL(videobuf_read_stream);
1089 EXPORT_SYMBOL_GPL(videobuf_read_one);
1090 EXPORT_SYMBOL_GPL(videobuf_poll_stream);
1092 EXPORT_SYMBOL_GPL(videobuf_mmap_setup);
1093 EXPORT_SYMBOL_GPL(videobuf_mmap_free);
1094 EXPORT_SYMBOL_GPL(videobuf_mmap_mapper);