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 /* FIXME: 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 However, this way is just too dirty! Better to wait for some event.
107 schedule_timeout(HZ);
109 return CALL(q, iolock, q, vb, fbuf);
112 /* --------------------------------------------------------------------- */
115 void videobuf_queue_core_init(struct videobuf_queue *q,
116 struct videobuf_queue_ops *ops,
119 enum v4l2_buf_type type,
120 enum v4l2_field field,
123 struct videobuf_qtype_ops *int_ops)
125 memset(q, 0, sizeof(*q));
126 q->irqlock = irqlock;
133 q->int_ops = int_ops;
135 /* All buffer operations are mandatory */
136 BUG_ON(!q->ops->buf_setup);
137 BUG_ON(!q->ops->buf_prepare);
138 BUG_ON(!q->ops->buf_queue);
139 BUG_ON(!q->ops->buf_release);
141 /* Having implementations for abstract methods are mandatory */
144 mutex_init(&q->lock);
145 INIT_LIST_HEAD(&q->stream);
148 /* Locking: Only usage in bttv unsafe find way to remove */
149 int videobuf_queue_is_busy(struct videobuf_queue *q)
153 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
156 dprintk(1, "busy: streaming active\n");
160 dprintk(1, "busy: pending read #1\n");
164 dprintk(1, "busy: pending read #2\n");
167 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
168 if (NULL == q->bufs[i])
170 if (q->bufs[i]->map) {
171 dprintk(1, "busy: buffer #%d mapped\n", i);
174 if (q->bufs[i]->state == VIDEOBUF_QUEUED) {
175 dprintk(1, "busy: buffer #%d queued\n", i);
178 if (q->bufs[i]->state == VIDEOBUF_ACTIVE) {
179 dprintk(1, "busy: buffer #%d avtive\n", i);
186 /* Locking: Caller holds q->lock */
187 void videobuf_queue_cancel(struct videobuf_queue *q)
189 unsigned long flags = 0;
192 /* remove queued buffers from list */
194 spin_lock_irqsave(q->irqlock, flags);
195 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
196 if (NULL == q->bufs[i])
198 if (q->bufs[i]->state == VIDEOBUF_QUEUED) {
199 list_del(&q->bufs[i]->queue);
200 q->bufs[i]->state = VIDEOBUF_ERROR;
204 spin_unlock_irqrestore(q->irqlock, flags);
206 /* free all buffers + clear queue */
207 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
208 if (NULL == q->bufs[i])
210 q->ops->buf_release(q, q->bufs[i]);
212 INIT_LIST_HEAD(&q->stream);
215 /* --------------------------------------------------------------------- */
217 /* Locking: Caller holds q->lock */
218 enum v4l2_field videobuf_next_field(struct videobuf_queue *q)
220 enum v4l2_field field = q->field;
222 BUG_ON(V4L2_FIELD_ANY == field);
224 if (V4L2_FIELD_ALTERNATE == field) {
225 if (V4L2_FIELD_TOP == q->last) {
226 field = V4L2_FIELD_BOTTOM;
227 q->last = V4L2_FIELD_BOTTOM;
229 field = V4L2_FIELD_TOP;
230 q->last = V4L2_FIELD_TOP;
236 /* Locking: Caller holds q->lock */
237 static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
238 struct videobuf_buffer *vb, enum v4l2_buf_type type)
240 MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
241 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
246 b->memory = vb->memory;
248 case V4L2_MEMORY_MMAP:
249 b->m.offset = vb->boff;
250 b->length = vb->bsize;
252 case V4L2_MEMORY_USERPTR:
253 b->m.userptr = vb->baddr;
254 b->length = vb->bsize;
256 case V4L2_MEMORY_OVERLAY:
257 b->m.offset = vb->boff;
263 b->flags |= V4L2_BUF_FLAG_MAPPED;
266 case VIDEOBUF_PREPARED:
267 case VIDEOBUF_QUEUED:
268 case VIDEOBUF_ACTIVE:
269 b->flags |= V4L2_BUF_FLAG_QUEUED;
273 b->flags |= V4L2_BUF_FLAG_DONE;
275 case VIDEOBUF_NEEDS_INIT:
281 if (vb->input != UNSET) {
282 b->flags |= V4L2_BUF_FLAG_INPUT;
283 b->input = vb->input;
286 b->field = vb->field;
287 b->timestamp = vb->ts;
288 b->bytesused = vb->size;
289 b->sequence = vb->field_count >> 1;
292 /* Locking: Caller holds q->lock */
293 static int __videobuf_mmap_free(struct videobuf_queue *q)
301 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
303 rc = CALL(q, mmap_free, q);
307 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
308 if (NULL == q->bufs[i])
310 q->ops->buf_release(q, q->bufs[i]);
318 int videobuf_mmap_free(struct videobuf_queue *q)
321 mutex_lock(&q->lock);
322 ret = __videobuf_mmap_free(q);
323 mutex_unlock(&q->lock);
327 /* Locking: Caller holds q->lock */
328 static int __videobuf_mmap_setup(struct videobuf_queue *q,
329 unsigned int bcount, unsigned int bsize,
330 enum v4l2_memory memory)
335 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
337 err = __videobuf_mmap_free(q);
341 /* Allocate and initialize buffers */
342 for (i = 0; i < bcount; i++) {
343 q->bufs[i] = videobuf_alloc(q);
345 if (q->bufs[i] == NULL)
349 q->bufs[i]->input = UNSET;
350 q->bufs[i]->memory = memory;
351 q->bufs[i]->bsize = bsize;
353 case V4L2_MEMORY_MMAP:
354 q->bufs[i]->boff = bsize * i;
356 case V4L2_MEMORY_USERPTR:
357 case V4L2_MEMORY_OVERLAY:
366 dprintk(1, "mmap setup: %d buffers, %d bytes each\n",
372 int videobuf_mmap_setup(struct videobuf_queue *q,
373 unsigned int bcount, unsigned int bsize,
374 enum v4l2_memory memory)
377 mutex_lock(&q->lock);
378 ret = __videobuf_mmap_setup(q, bcount, bsize, memory);
379 mutex_unlock(&q->lock);
383 int videobuf_reqbufs(struct videobuf_queue *q,
384 struct v4l2_requestbuffers *req)
386 unsigned int size, count;
389 if (req->count < 1) {
390 dprintk(1, "reqbufs: count invalid (%d)\n", req->count);
394 if (req->memory != V4L2_MEMORY_MMAP &&
395 req->memory != V4L2_MEMORY_USERPTR &&
396 req->memory != V4L2_MEMORY_OVERLAY) {
397 dprintk(1, "reqbufs: memory type invalid\n");
401 mutex_lock(&q->lock);
402 if (req->type != q->type) {
403 dprintk(1, "reqbufs: queue type invalid\n");
409 dprintk(1, "reqbufs: streaming already exists\n");
413 if (!list_empty(&q->stream)) {
414 dprintk(1, "reqbufs: stream running\n");
420 if (count > VIDEO_MAX_FRAME)
421 count = VIDEO_MAX_FRAME;
423 q->ops->buf_setup(q, &count, &size);
424 size = PAGE_ALIGN(size);
425 dprintk(1, "reqbufs: bufs=%d, size=0x%x [%d pages total]\n",
426 count, size, (count*size)>>PAGE_SHIFT);
428 retval = __videobuf_mmap_setup(q, count, size, req->memory);
430 dprintk(1, "reqbufs: mmap setup returned %d\n", retval);
437 mutex_unlock(&q->lock);
441 int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
445 mutex_lock(&q->lock);
446 if (unlikely(b->type != q->type)) {
447 dprintk(1, "querybuf: Wrong type.\n");
450 if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) {
451 dprintk(1, "querybuf: index out of range.\n");
454 if (unlikely(NULL == q->bufs[b->index])) {
455 dprintk(1, "querybuf: buffer is null.\n");
459 videobuf_status(q, b, q->bufs[b->index], q->type);
463 mutex_unlock(&q->lock);
467 int videobuf_qbuf(struct videobuf_queue *q,
468 struct v4l2_buffer *b)
470 struct videobuf_buffer *buf;
471 enum v4l2_field field;
472 unsigned long flags = 0;
475 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
477 if (b->memory == V4L2_MEMORY_MMAP)
478 down_read(¤t->mm->mmap_sem);
480 mutex_lock(&q->lock);
483 dprintk(1, "qbuf: Reading running...\n");
487 if (b->type != q->type) {
488 dprintk(1, "qbuf: Wrong type.\n");
491 if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
492 dprintk(1, "qbuf: index out of range.\n");
495 buf = q->bufs[b->index];
497 dprintk(1, "qbuf: buffer is null.\n");
500 MAGIC_CHECK(buf->magic, MAGIC_BUFFER);
501 if (buf->memory != b->memory) {
502 dprintk(1, "qbuf: memory type is wrong.\n");
505 if (buf->state != VIDEOBUF_NEEDS_INIT && buf->state != VIDEOBUF_IDLE) {
506 dprintk(1, "qbuf: buffer is already queued or active.\n");
510 if (b->flags & V4L2_BUF_FLAG_INPUT) {
511 if (b->input >= q->inputs) {
512 dprintk(1, "qbuf: wrong input.\n");
515 buf->input = b->input;
521 case V4L2_MEMORY_MMAP:
522 if (0 == buf->baddr) {
523 dprintk(1, "qbuf: mmap requested "
524 "but buffer addr is zero!\n");
528 case V4L2_MEMORY_USERPTR:
529 if (b->length < buf->bsize) {
530 dprintk(1, "qbuf: buffer length is not enough\n");
533 if (VIDEOBUF_NEEDS_INIT != buf->state &&
534 buf->baddr != b->m.userptr)
535 q->ops->buf_release(q, buf);
536 buf->baddr = b->m.userptr;
538 case V4L2_MEMORY_OVERLAY:
539 buf->boff = b->m.offset;
542 dprintk(1, "qbuf: wrong memory type\n");
546 dprintk(1, "qbuf: requesting next field\n");
547 field = videobuf_next_field(q);
548 retval = q->ops->buf_prepare(q, buf, field);
550 dprintk(1, "qbuf: buffer_prepare returned %d\n", retval);
554 list_add_tail(&buf->stream, &q->stream);
557 spin_lock_irqsave(q->irqlock, flags);
558 q->ops->buf_queue(q, buf);
560 spin_unlock_irqrestore(q->irqlock, flags);
562 dprintk(1, "qbuf: succeded\n");
566 mutex_unlock(&q->lock);
568 if (b->memory == V4L2_MEMORY_MMAP)
569 up_read(¤t->mm->mmap_sem);
574 int videobuf_dqbuf(struct videobuf_queue *q,
575 struct v4l2_buffer *b, int nonblocking)
577 struct videobuf_buffer *buf;
580 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
582 mutex_lock(&q->lock);
585 dprintk(1, "dqbuf: Reading running...\n");
589 if (b->type != q->type) {
590 dprintk(1, "dqbuf: Wrong type.\n");
593 if (list_empty(&q->stream)) {
594 dprintk(1, "dqbuf: stream running\n");
597 buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
598 retval = videobuf_waiton(buf, nonblocking, 1);
600 dprintk(1, "dqbuf: waiton returned %d\n", retval);
603 switch (buf->state) {
605 dprintk(1, "dqbuf: state is error\n");
607 CALL(q, sync, q, buf);
608 buf->state = VIDEOBUF_IDLE;
611 dprintk(1, "dqbuf: state is done\n");
612 CALL(q, sync, q, buf);
613 buf->state = VIDEOBUF_IDLE;
616 dprintk(1, "dqbuf: state invalid\n");
620 list_del(&buf->stream);
621 memset(b, 0, sizeof(*b));
622 videobuf_status(q, b, buf, q->type);
625 mutex_unlock(&q->lock);
629 int videobuf_streamon(struct videobuf_queue *q)
631 struct videobuf_buffer *buf;
632 unsigned long flags = 0;
635 mutex_lock(&q->lock);
644 spin_lock_irqsave(q->irqlock, flags);
645 list_for_each_entry(buf, &q->stream, stream)
646 if (buf->state == VIDEOBUF_PREPARED)
647 q->ops->buf_queue(q, buf);
649 spin_unlock_irqrestore(q->irqlock, flags);
652 mutex_unlock(&q->lock);
656 /* Locking: Caller holds q->lock */
657 static int __videobuf_streamoff(struct videobuf_queue *q)
662 videobuf_queue_cancel(q);
668 int videobuf_streamoff(struct videobuf_queue *q)
672 mutex_lock(&q->lock);
673 retval = __videobuf_streamoff(q);
674 mutex_unlock(&q->lock);
679 /* Locking: Caller holds q->lock */
680 static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
682 size_t count, loff_t *ppos)
684 enum v4l2_field field;
685 unsigned long flags = 0;
688 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
691 q->read_buf = videobuf_alloc(q);
692 if (NULL == q->read_buf)
695 q->read_buf->memory = V4L2_MEMORY_USERPTR;
696 q->read_buf->baddr = (unsigned long)data;
697 q->read_buf->bsize = count;
699 field = videobuf_next_field(q);
700 retval = q->ops->buf_prepare(q, q->read_buf, field);
704 /* start capture & wait */
706 spin_lock_irqsave(q->irqlock, flags);
707 q->ops->buf_queue(q, q->read_buf);
709 spin_unlock_irqrestore(q->irqlock, flags);
710 retval = videobuf_waiton(q->read_buf, 0, 0);
712 CALL(q, sync, q, q->read_buf);
713 if (VIDEOBUF_ERROR == q->read_buf->state)
716 retval = q->read_buf->size;
721 q->ops->buf_release(q, q->read_buf);
727 ssize_t videobuf_read_one(struct videobuf_queue *q,
728 char __user *data, size_t count, loff_t *ppos,
731 enum v4l2_field field;
732 unsigned long flags = 0;
733 unsigned size, nbufs;
736 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
738 mutex_lock(&q->lock);
741 q->ops->buf_setup(q, &nbufs, &size);
743 if (NULL == q->read_buf &&
746 retval = videobuf_read_zerocopy(q, data, count, ppos);
747 if (retval >= 0 || retval == -EIO)
750 /* fallback to kernel bounce buffer on failures */
753 if (NULL == q->read_buf) {
754 /* need to capture a new frame */
756 q->read_buf = videobuf_alloc(q);
758 dprintk(1, "video alloc=0x%p\n", q->read_buf);
759 if (NULL == q->read_buf)
761 q->read_buf->memory = V4L2_MEMORY_USERPTR;
762 q->read_buf->bsize = count; /* preferred size */
763 field = videobuf_next_field(q);
764 retval = q->ops->buf_prepare(q, q->read_buf, field);
772 spin_lock_irqsave(q->irqlock, flags);
774 q->ops->buf_queue(q, q->read_buf);
776 spin_unlock_irqrestore(q->irqlock, flags);
780 /* wait until capture is done */
781 retval = videobuf_waiton(q->read_buf, nonblocking, 1);
785 CALL(q, sync, q, q->read_buf);
787 if (VIDEOBUF_ERROR == q->read_buf->state) {
788 /* catch I/O errors */
789 q->ops->buf_release(q, q->read_buf);
796 /* Copy to userspace */
797 retval = CALL(q, video_copy_to_user, q, data, count, nonblocking);
801 q->read_off += retval;
802 if (q->read_off == q->read_buf->size) {
803 /* all data copied, cleanup */
804 q->ops->buf_release(q, q->read_buf);
810 mutex_unlock(&q->lock);
814 /* Locking: Caller holds q->lock */
815 int __videobuf_read_start(struct videobuf_queue *q)
817 enum v4l2_field field;
818 unsigned long flags = 0;
819 unsigned int count = 0, size = 0;
822 q->ops->buf_setup(q, &count, &size);
825 if (count > VIDEO_MAX_FRAME)
826 count = VIDEO_MAX_FRAME;
827 size = PAGE_ALIGN(size);
829 err = __videobuf_mmap_setup(q, count, size, V4L2_MEMORY_USERPTR);
835 for (i = 0; i < count; i++) {
836 field = videobuf_next_field(q);
837 err = q->ops->buf_prepare(q, q->bufs[i], field);
840 list_add_tail(&q->bufs[i]->stream, &q->stream);
843 spin_lock_irqsave(q->irqlock, flags);
844 for (i = 0; i < count; i++)
845 q->ops->buf_queue(q, q->bufs[i]);
847 spin_unlock_irqrestore(q->irqlock, flags);
852 static void __videobuf_read_stop(struct videobuf_queue *q)
857 videobuf_queue_cancel(q);
858 __videobuf_mmap_free(q);
859 INIT_LIST_HEAD(&q->stream);
860 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
861 if (NULL == q->bufs[i])
871 int videobuf_read_start(struct videobuf_queue *q)
875 mutex_lock(&q->lock);
876 rc = __videobuf_read_start(q);
877 mutex_unlock(&q->lock);
882 void videobuf_read_stop(struct videobuf_queue *q)
884 mutex_lock(&q->lock);
885 __videobuf_read_stop(q);
886 mutex_unlock(&q->lock);
889 void videobuf_stop(struct videobuf_queue *q)
891 mutex_lock(&q->lock);
894 __videobuf_streamoff(q);
897 __videobuf_read_stop(q);
899 mutex_unlock(&q->lock);
903 ssize_t videobuf_read_stream(struct videobuf_queue *q,
904 char __user *data, size_t count, loff_t *ppos,
905 int vbihack, int nonblocking)
908 unsigned long flags = 0;
910 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
912 dprintk(2, "%s\n", __FUNCTION__);
913 mutex_lock(&q->lock);
918 retval = __videobuf_read_start(q);
925 /* get / wait for data */
926 if (NULL == q->read_buf) {
927 q->read_buf = list_entry(q->stream.next,
928 struct videobuf_buffer,
930 list_del(&q->read_buf->stream);
933 rc = videobuf_waiton(q->read_buf, nonblocking, 1);
940 if (q->read_buf->state == VIDEOBUF_DONE) {
941 rc = CALL(q, copy_stream, q, data + retval, count,
942 retval, vbihack, nonblocking);
952 q->read_off = q->read_buf->size;
957 /* requeue buffer when done with copying */
958 if (q->read_off == q->read_buf->size) {
959 list_add_tail(&q->read_buf->stream,
962 spin_lock_irqsave(q->irqlock, flags);
963 q->ops->buf_queue(q, q->read_buf);
965 spin_unlock_irqrestore(q->irqlock, flags);
973 mutex_unlock(&q->lock);
977 unsigned int videobuf_poll_stream(struct file *file,
978 struct videobuf_queue *q,
981 struct videobuf_buffer *buf = NULL;
984 mutex_lock(&q->lock);
986 if (!list_empty(&q->stream))
987 buf = list_entry(q->stream.next,
988 struct videobuf_buffer, stream);
991 __videobuf_read_start(q);
994 } else if (NULL == q->read_buf) {
995 q->read_buf = list_entry(q->stream.next,
996 struct videobuf_buffer,
998 list_del(&q->read_buf->stream);
1007 poll_wait(file, &buf->done, wait);
1008 if (buf->state == VIDEOBUF_DONE ||
1009 buf->state == VIDEOBUF_ERROR)
1010 rc = POLLIN|POLLRDNORM;
1012 mutex_unlock(&q->lock);
1016 int videobuf_mmap_mapper(struct videobuf_queue *q,
1017 struct vm_area_struct *vma)
1021 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
1023 mutex_lock(&q->lock);
1024 retval = CALL(q, mmap_mapper, q, vma);
1025 mutex_unlock(&q->lock);
1030 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1031 int videobuf_cgmbuf(struct videobuf_queue *q,
1032 struct video_mbuf *mbuf, int count)
1034 struct v4l2_requestbuffers req;
1037 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
1039 memset(&req, 0, sizeof(req));
1042 req.memory = V4L2_MEMORY_MMAP;
1043 rc = videobuf_reqbufs(q, &req);
1047 mbuf->frames = req.count;
1049 for (i = 0; i < mbuf->frames; i++) {
1050 mbuf->offsets[i] = q->bufs[i]->boff;
1051 mbuf->size += q->bufs[i]->bsize;
1056 EXPORT_SYMBOL_GPL(videobuf_cgmbuf);
1059 /* --------------------------------------------------------------------- */
1061 EXPORT_SYMBOL_GPL(videobuf_waiton);
1062 EXPORT_SYMBOL_GPL(videobuf_iolock);
1064 EXPORT_SYMBOL_GPL(videobuf_alloc);
1066 EXPORT_SYMBOL_GPL(videobuf_queue_core_init);
1067 EXPORT_SYMBOL_GPL(videobuf_queue_cancel);
1068 EXPORT_SYMBOL_GPL(videobuf_queue_is_busy);
1070 EXPORT_SYMBOL_GPL(videobuf_next_field);
1071 EXPORT_SYMBOL_GPL(videobuf_reqbufs);
1072 EXPORT_SYMBOL_GPL(videobuf_querybuf);
1073 EXPORT_SYMBOL_GPL(videobuf_qbuf);
1074 EXPORT_SYMBOL_GPL(videobuf_dqbuf);
1075 EXPORT_SYMBOL_GPL(videobuf_streamon);
1076 EXPORT_SYMBOL_GPL(videobuf_streamoff);
1078 EXPORT_SYMBOL_GPL(videobuf_read_start);
1079 EXPORT_SYMBOL_GPL(videobuf_read_stop);
1080 EXPORT_SYMBOL_GPL(videobuf_stop);
1081 EXPORT_SYMBOL_GPL(videobuf_read_stream);
1082 EXPORT_SYMBOL_GPL(videobuf_read_one);
1083 EXPORT_SYMBOL_GPL(videobuf_poll_stream);
1085 EXPORT_SYMBOL_GPL(videobuf_mmap_setup);
1086 EXPORT_SYMBOL_GPL(videobuf_mmap_free);
1087 EXPORT_SYMBOL_GPL(videobuf_mmap_mapper);