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 if (vb->memory == V4L2_MEMORY_MMAP) {
106 wait_event_timeout(vb->done, q->is_mmapped,
107 msecs_to_jiffies(100));
108 if (!q->is_mmapped) {
110 "Error: mmap_mapper() never called!\n");
115 return CALL(q, iolock, q, vb, fbuf);
118 /* --------------------------------------------------------------------- */
121 void videobuf_queue_core_init(struct videobuf_queue *q,
122 struct videobuf_queue_ops *ops,
125 enum v4l2_buf_type type,
126 enum v4l2_field field,
129 struct videobuf_qtype_ops *int_ops)
131 memset(q, 0, sizeof(*q));
132 q->irqlock = irqlock;
139 q->int_ops = int_ops;
141 /* All buffer operations are mandatory */
142 BUG_ON(!q->ops->buf_setup);
143 BUG_ON(!q->ops->buf_prepare);
144 BUG_ON(!q->ops->buf_queue);
145 BUG_ON(!q->ops->buf_release);
147 /* Having implementations for abstract methods are mandatory */
150 mutex_init(&q->lock);
151 INIT_LIST_HEAD(&q->stream);
154 /* Locking: Only usage in bttv unsafe find way to remove */
155 int videobuf_queue_is_busy(struct videobuf_queue *q)
159 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
162 dprintk(1, "busy: streaming active\n");
166 dprintk(1, "busy: pending read #1\n");
170 dprintk(1, "busy: pending read #2\n");
173 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
174 if (NULL == q->bufs[i])
176 if (q->bufs[i]->map) {
177 dprintk(1, "busy: buffer #%d mapped\n", i);
180 if (q->bufs[i]->state == VIDEOBUF_QUEUED) {
181 dprintk(1, "busy: buffer #%d queued\n", i);
184 if (q->bufs[i]->state == VIDEOBUF_ACTIVE) {
185 dprintk(1, "busy: buffer #%d avtive\n", i);
192 /* Locking: Caller holds q->lock */
193 void videobuf_queue_cancel(struct videobuf_queue *q)
195 unsigned long flags = 0;
198 /* remove queued buffers from list */
200 spin_lock_irqsave(q->irqlock, flags);
201 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
202 if (NULL == q->bufs[i])
204 if (q->bufs[i]->state == VIDEOBUF_QUEUED) {
205 list_del(&q->bufs[i]->queue);
206 q->bufs[i]->state = VIDEOBUF_ERROR;
210 spin_unlock_irqrestore(q->irqlock, flags);
212 /* free all buffers + clear queue */
213 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
214 if (NULL == q->bufs[i])
216 q->ops->buf_release(q, q->bufs[i]);
218 INIT_LIST_HEAD(&q->stream);
221 /* --------------------------------------------------------------------- */
223 /* Locking: Caller holds q->lock */
224 enum v4l2_field videobuf_next_field(struct videobuf_queue *q)
226 enum v4l2_field field = q->field;
228 BUG_ON(V4L2_FIELD_ANY == field);
230 if (V4L2_FIELD_ALTERNATE == field) {
231 if (V4L2_FIELD_TOP == q->last) {
232 field = V4L2_FIELD_BOTTOM;
233 q->last = V4L2_FIELD_BOTTOM;
235 field = V4L2_FIELD_TOP;
236 q->last = V4L2_FIELD_TOP;
242 /* Locking: Caller holds q->lock */
243 static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
244 struct videobuf_buffer *vb, enum v4l2_buf_type type)
246 MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
247 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
252 b->memory = vb->memory;
254 case V4L2_MEMORY_MMAP:
255 b->m.offset = vb->boff;
256 b->length = vb->bsize;
258 case V4L2_MEMORY_USERPTR:
259 b->m.userptr = vb->baddr;
260 b->length = vb->bsize;
262 case V4L2_MEMORY_OVERLAY:
263 b->m.offset = vb->boff;
269 b->flags |= V4L2_BUF_FLAG_MAPPED;
272 case VIDEOBUF_PREPARED:
273 case VIDEOBUF_QUEUED:
274 case VIDEOBUF_ACTIVE:
275 b->flags |= V4L2_BUF_FLAG_QUEUED;
279 b->flags |= V4L2_BUF_FLAG_DONE;
281 case VIDEOBUF_NEEDS_INIT:
287 if (vb->input != UNSET) {
288 b->flags |= V4L2_BUF_FLAG_INPUT;
289 b->input = vb->input;
292 b->field = vb->field;
293 b->timestamp = vb->ts;
294 b->bytesused = vb->size;
295 b->sequence = vb->field_count >> 1;
298 /* Locking: Caller holds q->lock */
299 static int __videobuf_mmap_free(struct videobuf_queue *q)
307 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
310 rc = CALL(q, mmap_free, q);
317 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
318 if (NULL == q->bufs[i])
320 q->ops->buf_release(q, q->bufs[i]);
328 int videobuf_mmap_free(struct videobuf_queue *q)
331 mutex_lock(&q->lock);
332 ret = __videobuf_mmap_free(q);
333 mutex_unlock(&q->lock);
337 /* Locking: Caller holds q->lock */
338 static int __videobuf_mmap_setup(struct videobuf_queue *q,
339 unsigned int bcount, unsigned int bsize,
340 enum v4l2_memory memory)
345 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
347 err = __videobuf_mmap_free(q);
351 /* Allocate and initialize buffers */
352 for (i = 0; i < bcount; i++) {
353 q->bufs[i] = videobuf_alloc(q);
355 if (q->bufs[i] == NULL)
359 q->bufs[i]->input = UNSET;
360 q->bufs[i]->memory = memory;
361 q->bufs[i]->bsize = bsize;
363 case V4L2_MEMORY_MMAP:
364 q->bufs[i]->boff = bsize * i;
366 case V4L2_MEMORY_USERPTR:
367 case V4L2_MEMORY_OVERLAY:
376 dprintk(1, "mmap setup: %d buffers, %d bytes each\n",
382 int videobuf_mmap_setup(struct videobuf_queue *q,
383 unsigned int bcount, unsigned int bsize,
384 enum v4l2_memory memory)
387 mutex_lock(&q->lock);
388 ret = __videobuf_mmap_setup(q, bcount, bsize, memory);
389 mutex_unlock(&q->lock);
393 int videobuf_reqbufs(struct videobuf_queue *q,
394 struct v4l2_requestbuffers *req)
396 unsigned int size, count;
399 if (req->count < 1) {
400 dprintk(1, "reqbufs: count invalid (%d)\n", req->count);
404 if (req->memory != V4L2_MEMORY_MMAP &&
405 req->memory != V4L2_MEMORY_USERPTR &&
406 req->memory != V4L2_MEMORY_OVERLAY) {
407 dprintk(1, "reqbufs: memory type invalid\n");
411 mutex_lock(&q->lock);
412 if (req->type != q->type) {
413 dprintk(1, "reqbufs: queue type invalid\n");
419 dprintk(1, "reqbufs: streaming already exists\n");
423 if (!list_empty(&q->stream)) {
424 dprintk(1, "reqbufs: stream running\n");
430 if (count > VIDEO_MAX_FRAME)
431 count = VIDEO_MAX_FRAME;
433 q->ops->buf_setup(q, &count, &size);
434 size = PAGE_ALIGN(size);
435 dprintk(1, "reqbufs: bufs=%d, size=0x%x [%d pages total]\n",
436 count, size, (count*size)>>PAGE_SHIFT);
438 retval = __videobuf_mmap_setup(q, count, size, req->memory);
440 dprintk(1, "reqbufs: mmap setup returned %d\n", retval);
447 mutex_unlock(&q->lock);
451 int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
455 mutex_lock(&q->lock);
456 if (unlikely(b->type != q->type)) {
457 dprintk(1, "querybuf: Wrong type.\n");
460 if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) {
461 dprintk(1, "querybuf: index out of range.\n");
464 if (unlikely(NULL == q->bufs[b->index])) {
465 dprintk(1, "querybuf: buffer is null.\n");
469 videobuf_status(q, b, q->bufs[b->index], q->type);
473 mutex_unlock(&q->lock);
477 int videobuf_qbuf(struct videobuf_queue *q,
478 struct v4l2_buffer *b)
480 struct videobuf_buffer *buf;
481 enum v4l2_field field;
482 unsigned long flags = 0;
485 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
487 if (b->memory == V4L2_MEMORY_MMAP)
488 down_read(¤t->mm->mmap_sem);
490 mutex_lock(&q->lock);
493 dprintk(1, "qbuf: Reading running...\n");
497 if (b->type != q->type) {
498 dprintk(1, "qbuf: Wrong type.\n");
501 if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
502 dprintk(1, "qbuf: index out of range.\n");
505 buf = q->bufs[b->index];
507 dprintk(1, "qbuf: buffer is null.\n");
510 MAGIC_CHECK(buf->magic, MAGIC_BUFFER);
511 if (buf->memory != b->memory) {
512 dprintk(1, "qbuf: memory type is wrong.\n");
515 if (buf->state != VIDEOBUF_NEEDS_INIT && buf->state != VIDEOBUF_IDLE) {
516 dprintk(1, "qbuf: buffer is already queued or active.\n");
520 if (b->flags & V4L2_BUF_FLAG_INPUT) {
521 if (b->input >= q->inputs) {
522 dprintk(1, "qbuf: wrong input.\n");
525 buf->input = b->input;
531 case V4L2_MEMORY_MMAP:
532 if (0 == buf->baddr) {
533 dprintk(1, "qbuf: mmap requested "
534 "but buffer addr is zero!\n");
538 case V4L2_MEMORY_USERPTR:
539 if (b->length < buf->bsize) {
540 dprintk(1, "qbuf: buffer length is not enough\n");
543 if (VIDEOBUF_NEEDS_INIT != buf->state &&
544 buf->baddr != b->m.userptr)
545 q->ops->buf_release(q, buf);
546 buf->baddr = b->m.userptr;
548 case V4L2_MEMORY_OVERLAY:
549 buf->boff = b->m.offset;
552 dprintk(1, "qbuf: wrong memory type\n");
556 dprintk(1, "qbuf: requesting next field\n");
557 field = videobuf_next_field(q);
558 retval = q->ops->buf_prepare(q, buf, field);
560 dprintk(1, "qbuf: buffer_prepare returned %d\n", retval);
564 list_add_tail(&buf->stream, &q->stream);
567 spin_lock_irqsave(q->irqlock, flags);
568 q->ops->buf_queue(q, buf);
570 spin_unlock_irqrestore(q->irqlock, flags);
572 dprintk(1, "qbuf: succeded\n");
576 mutex_unlock(&q->lock);
578 if (b->memory == V4L2_MEMORY_MMAP)
579 up_read(¤t->mm->mmap_sem);
584 int videobuf_dqbuf(struct videobuf_queue *q,
585 struct v4l2_buffer *b, int nonblocking)
587 struct videobuf_buffer *buf;
590 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
592 mutex_lock(&q->lock);
595 dprintk(1, "dqbuf: Reading running...\n");
599 if (b->type != q->type) {
600 dprintk(1, "dqbuf: Wrong type.\n");
603 if (list_empty(&q->stream)) {
604 dprintk(1, "dqbuf: stream running\n");
607 buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
608 retval = videobuf_waiton(buf, nonblocking, 1);
610 dprintk(1, "dqbuf: waiton returned %d\n", retval);
613 switch (buf->state) {
615 dprintk(1, "dqbuf: state is error\n");
617 CALL(q, sync, q, buf);
618 buf->state = VIDEOBUF_IDLE;
621 dprintk(1, "dqbuf: state is done\n");
622 CALL(q, sync, q, buf);
623 buf->state = VIDEOBUF_IDLE;
626 dprintk(1, "dqbuf: state invalid\n");
630 list_del(&buf->stream);
631 memset(b, 0, sizeof(*b));
632 videobuf_status(q, b, buf, q->type);
635 mutex_unlock(&q->lock);
639 int videobuf_streamon(struct videobuf_queue *q)
641 struct videobuf_buffer *buf;
642 unsigned long flags = 0;
645 mutex_lock(&q->lock);
654 spin_lock_irqsave(q->irqlock, flags);
655 list_for_each_entry(buf, &q->stream, stream)
656 if (buf->state == VIDEOBUF_PREPARED)
657 q->ops->buf_queue(q, buf);
659 spin_unlock_irqrestore(q->irqlock, flags);
662 mutex_unlock(&q->lock);
666 /* Locking: Caller holds q->lock */
667 static int __videobuf_streamoff(struct videobuf_queue *q)
672 videobuf_queue_cancel(q);
678 int videobuf_streamoff(struct videobuf_queue *q)
682 mutex_lock(&q->lock);
683 retval = __videobuf_streamoff(q);
684 mutex_unlock(&q->lock);
689 /* Locking: Caller holds q->lock */
690 static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
692 size_t count, loff_t *ppos)
694 enum v4l2_field field;
695 unsigned long flags = 0;
698 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
701 q->read_buf = videobuf_alloc(q);
702 if (NULL == q->read_buf)
705 q->read_buf->memory = V4L2_MEMORY_USERPTR;
706 q->read_buf->baddr = (unsigned long)data;
707 q->read_buf->bsize = count;
709 field = videobuf_next_field(q);
710 retval = q->ops->buf_prepare(q, q->read_buf, field);
714 /* start capture & wait */
716 spin_lock_irqsave(q->irqlock, flags);
717 q->ops->buf_queue(q, q->read_buf);
719 spin_unlock_irqrestore(q->irqlock, flags);
720 retval = videobuf_waiton(q->read_buf, 0, 0);
722 CALL(q, sync, q, q->read_buf);
723 if (VIDEOBUF_ERROR == q->read_buf->state)
726 retval = q->read_buf->size;
731 q->ops->buf_release(q, q->read_buf);
737 ssize_t videobuf_read_one(struct videobuf_queue *q,
738 char __user *data, size_t count, loff_t *ppos,
741 enum v4l2_field field;
742 unsigned long flags = 0;
743 unsigned size, nbufs;
746 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
748 mutex_lock(&q->lock);
751 q->ops->buf_setup(q, &nbufs, &size);
753 if (NULL == q->read_buf &&
756 retval = videobuf_read_zerocopy(q, data, count, ppos);
757 if (retval >= 0 || retval == -EIO)
760 /* fallback to kernel bounce buffer on failures */
763 if (NULL == q->read_buf) {
764 /* need to capture a new frame */
766 q->read_buf = videobuf_alloc(q);
768 dprintk(1, "video alloc=0x%p\n", q->read_buf);
769 if (NULL == q->read_buf)
771 q->read_buf->memory = V4L2_MEMORY_USERPTR;
772 q->read_buf->bsize = count; /* preferred size */
773 field = videobuf_next_field(q);
774 retval = q->ops->buf_prepare(q, q->read_buf, field);
782 spin_lock_irqsave(q->irqlock, flags);
784 q->ops->buf_queue(q, q->read_buf);
786 spin_unlock_irqrestore(q->irqlock, flags);
790 /* wait until capture is done */
791 retval = videobuf_waiton(q->read_buf, nonblocking, 1);
795 CALL(q, sync, q, q->read_buf);
797 if (VIDEOBUF_ERROR == q->read_buf->state) {
798 /* catch I/O errors */
799 q->ops->buf_release(q, q->read_buf);
806 /* Copy to userspace */
807 retval = CALL(q, video_copy_to_user, q, data, count, nonblocking);
811 q->read_off += retval;
812 if (q->read_off == q->read_buf->size) {
813 /* all data copied, cleanup */
814 q->ops->buf_release(q, q->read_buf);
820 mutex_unlock(&q->lock);
824 /* Locking: Caller holds q->lock */
825 static int __videobuf_read_start(struct videobuf_queue *q)
827 enum v4l2_field field;
828 unsigned long flags = 0;
829 unsigned int count = 0, size = 0;
832 q->ops->buf_setup(q, &count, &size);
835 if (count > VIDEO_MAX_FRAME)
836 count = VIDEO_MAX_FRAME;
837 size = PAGE_ALIGN(size);
839 err = __videobuf_mmap_setup(q, count, size, V4L2_MEMORY_USERPTR);
845 for (i = 0; i < count; i++) {
846 field = videobuf_next_field(q);
847 err = q->ops->buf_prepare(q, q->bufs[i], field);
850 list_add_tail(&q->bufs[i]->stream, &q->stream);
853 spin_lock_irqsave(q->irqlock, flags);
854 for (i = 0; i < count; i++)
855 q->ops->buf_queue(q, q->bufs[i]);
857 spin_unlock_irqrestore(q->irqlock, flags);
862 static void __videobuf_read_stop(struct videobuf_queue *q)
867 videobuf_queue_cancel(q);
868 __videobuf_mmap_free(q);
869 INIT_LIST_HEAD(&q->stream);
870 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
871 if (NULL == q->bufs[i])
881 int videobuf_read_start(struct videobuf_queue *q)
885 mutex_lock(&q->lock);
886 rc = __videobuf_read_start(q);
887 mutex_unlock(&q->lock);
892 void videobuf_read_stop(struct videobuf_queue *q)
894 mutex_lock(&q->lock);
895 __videobuf_read_stop(q);
896 mutex_unlock(&q->lock);
899 void videobuf_stop(struct videobuf_queue *q)
901 mutex_lock(&q->lock);
904 __videobuf_streamoff(q);
907 __videobuf_read_stop(q);
909 mutex_unlock(&q->lock);
913 ssize_t videobuf_read_stream(struct videobuf_queue *q,
914 char __user *data, size_t count, loff_t *ppos,
915 int vbihack, int nonblocking)
918 unsigned long flags = 0;
920 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
922 dprintk(2, "%s\n", __FUNCTION__);
923 mutex_lock(&q->lock);
928 retval = __videobuf_read_start(q);
935 /* get / wait for data */
936 if (NULL == q->read_buf) {
937 q->read_buf = list_entry(q->stream.next,
938 struct videobuf_buffer,
940 list_del(&q->read_buf->stream);
943 rc = videobuf_waiton(q->read_buf, nonblocking, 1);
950 if (q->read_buf->state == VIDEOBUF_DONE) {
951 rc = CALL(q, copy_stream, q, data + retval, count,
952 retval, vbihack, nonblocking);
962 q->read_off = q->read_buf->size;
967 /* requeue buffer when done with copying */
968 if (q->read_off == q->read_buf->size) {
969 list_add_tail(&q->read_buf->stream,
972 spin_lock_irqsave(q->irqlock, flags);
973 q->ops->buf_queue(q, q->read_buf);
975 spin_unlock_irqrestore(q->irqlock, flags);
983 mutex_unlock(&q->lock);
987 unsigned int videobuf_poll_stream(struct file *file,
988 struct videobuf_queue *q,
991 struct videobuf_buffer *buf = NULL;
994 mutex_lock(&q->lock);
996 if (!list_empty(&q->stream))
997 buf = list_entry(q->stream.next,
998 struct videobuf_buffer, stream);
1001 __videobuf_read_start(q);
1004 } else if (NULL == q->read_buf) {
1005 q->read_buf = list_entry(q->stream.next,
1006 struct videobuf_buffer,
1008 list_del(&q->read_buf->stream);
1017 poll_wait(file, &buf->done, wait);
1018 if (buf->state == VIDEOBUF_DONE ||
1019 buf->state == VIDEOBUF_ERROR)
1020 rc = POLLIN|POLLRDNORM;
1022 mutex_unlock(&q->lock);
1026 int videobuf_mmap_mapper(struct videobuf_queue *q,
1027 struct vm_area_struct *vma)
1031 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
1033 mutex_lock(&q->lock);
1034 retval = CALL(q, mmap_mapper, q, vma);
1036 mutex_unlock(&q->lock);
1041 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1042 int videobuf_cgmbuf(struct videobuf_queue *q,
1043 struct video_mbuf *mbuf, int count)
1045 struct v4l2_requestbuffers req;
1048 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
1050 memset(&req, 0, sizeof(req));
1053 req.memory = V4L2_MEMORY_MMAP;
1054 rc = videobuf_reqbufs(q, &req);
1058 mbuf->frames = req.count;
1060 for (i = 0; i < mbuf->frames; i++) {
1061 mbuf->offsets[i] = q->bufs[i]->boff;
1062 mbuf->size += q->bufs[i]->bsize;
1067 EXPORT_SYMBOL_GPL(videobuf_cgmbuf);
1070 /* --------------------------------------------------------------------- */
1072 EXPORT_SYMBOL_GPL(videobuf_waiton);
1073 EXPORT_SYMBOL_GPL(videobuf_iolock);
1075 EXPORT_SYMBOL_GPL(videobuf_alloc);
1077 EXPORT_SYMBOL_GPL(videobuf_queue_core_init);
1078 EXPORT_SYMBOL_GPL(videobuf_queue_cancel);
1079 EXPORT_SYMBOL_GPL(videobuf_queue_is_busy);
1081 EXPORT_SYMBOL_GPL(videobuf_next_field);
1082 EXPORT_SYMBOL_GPL(videobuf_reqbufs);
1083 EXPORT_SYMBOL_GPL(videobuf_querybuf);
1084 EXPORT_SYMBOL_GPL(videobuf_qbuf);
1085 EXPORT_SYMBOL_GPL(videobuf_dqbuf);
1086 EXPORT_SYMBOL_GPL(videobuf_streamon);
1087 EXPORT_SYMBOL_GPL(videobuf_streamoff);
1089 EXPORT_SYMBOL_GPL(videobuf_read_start);
1090 EXPORT_SYMBOL_GPL(videobuf_read_stop);
1091 EXPORT_SYMBOL_GPL(videobuf_stop);
1092 EXPORT_SYMBOL_GPL(videobuf_read_stream);
1093 EXPORT_SYMBOL_GPL(videobuf_read_one);
1094 EXPORT_SYMBOL_GPL(videobuf_poll_stream);
1096 EXPORT_SYMBOL_GPL(videobuf_mmap_setup);
1097 EXPORT_SYMBOL_GPL(videobuf_mmap_free);
1098 EXPORT_SYMBOL_GPL(videobuf_mmap_mapper);