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->vb_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->vb_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;
207 wake_up_all(&q->bufs[i]->done);
211 spin_unlock_irqrestore(q->irqlock, flags);
213 /* free all buffers + clear queue */
214 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
215 if (NULL == q->bufs[i])
217 q->ops->buf_release(q, q->bufs[i]);
219 INIT_LIST_HEAD(&q->stream);
222 /* --------------------------------------------------------------------- */
224 /* Locking: Caller holds q->vb_lock */
225 enum v4l2_field videobuf_next_field(struct videobuf_queue *q)
227 enum v4l2_field field = q->field;
229 BUG_ON(V4L2_FIELD_ANY == field);
231 if (V4L2_FIELD_ALTERNATE == field) {
232 if (V4L2_FIELD_TOP == q->last) {
233 field = V4L2_FIELD_BOTTOM;
234 q->last = V4L2_FIELD_BOTTOM;
236 field = V4L2_FIELD_TOP;
237 q->last = V4L2_FIELD_TOP;
243 /* Locking: Caller holds q->vb_lock */
244 static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
245 struct videobuf_buffer *vb, enum v4l2_buf_type type)
247 MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
248 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
253 b->memory = vb->memory;
255 case V4L2_MEMORY_MMAP:
256 b->m.offset = vb->boff;
257 b->length = vb->bsize;
259 case V4L2_MEMORY_USERPTR:
260 b->m.userptr = vb->baddr;
261 b->length = vb->bsize;
263 case V4L2_MEMORY_OVERLAY:
264 b->m.offset = vb->boff;
270 b->flags |= V4L2_BUF_FLAG_MAPPED;
273 case VIDEOBUF_PREPARED:
274 case VIDEOBUF_QUEUED:
275 case VIDEOBUF_ACTIVE:
276 b->flags |= V4L2_BUF_FLAG_QUEUED;
280 b->flags |= V4L2_BUF_FLAG_DONE;
282 case VIDEOBUF_NEEDS_INIT:
288 if (vb->input != UNSET) {
289 b->flags |= V4L2_BUF_FLAG_INPUT;
290 b->input = vb->input;
293 b->field = vb->field;
294 b->timestamp = vb->ts;
295 b->bytesused = vb->size;
296 b->sequence = vb->field_count >> 1;
299 /* Locking: Caller holds q->vb_lock */
300 static int __videobuf_mmap_free(struct videobuf_queue *q)
308 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
311 rc = CALL(q, mmap_free, q);
318 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
319 if (NULL == q->bufs[i])
321 q->ops->buf_release(q, q->bufs[i]);
329 int videobuf_mmap_free(struct videobuf_queue *q)
332 mutex_lock(&q->vb_lock);
333 ret = __videobuf_mmap_free(q);
334 mutex_unlock(&q->vb_lock);
338 /* Locking: Caller holds q->vb_lock */
339 static int __videobuf_mmap_setup(struct videobuf_queue *q,
340 unsigned int bcount, unsigned int bsize,
341 enum v4l2_memory memory)
346 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
348 err = __videobuf_mmap_free(q);
352 /* Allocate and initialize buffers */
353 for (i = 0; i < bcount; i++) {
354 q->bufs[i] = videobuf_alloc(q);
356 if (q->bufs[i] == NULL)
360 q->bufs[i]->input = UNSET;
361 q->bufs[i]->memory = memory;
362 q->bufs[i]->bsize = bsize;
364 case V4L2_MEMORY_MMAP:
365 q->bufs[i]->boff = bsize * i;
367 case V4L2_MEMORY_USERPTR:
368 case V4L2_MEMORY_OVERLAY:
377 dprintk(1, "mmap setup: %d buffers, %d bytes each\n",
383 int videobuf_mmap_setup(struct videobuf_queue *q,
384 unsigned int bcount, unsigned int bsize,
385 enum v4l2_memory memory)
388 mutex_lock(&q->vb_lock);
389 ret = __videobuf_mmap_setup(q, bcount, bsize, memory);
390 mutex_unlock(&q->vb_lock);
394 int videobuf_reqbufs(struct videobuf_queue *q,
395 struct v4l2_requestbuffers *req)
397 unsigned int size, count;
400 if (req->count < 1) {
401 dprintk(1, "reqbufs: count invalid (%d)\n", req->count);
405 if (req->memory != V4L2_MEMORY_MMAP &&
406 req->memory != V4L2_MEMORY_USERPTR &&
407 req->memory != V4L2_MEMORY_OVERLAY) {
408 dprintk(1, "reqbufs: memory type invalid\n");
412 mutex_lock(&q->vb_lock);
413 if (req->type != q->type) {
414 dprintk(1, "reqbufs: queue type invalid\n");
420 dprintk(1, "reqbufs: streaming already exists\n");
424 if (!list_empty(&q->stream)) {
425 dprintk(1, "reqbufs: stream running\n");
431 if (count > VIDEO_MAX_FRAME)
432 count = VIDEO_MAX_FRAME;
434 q->ops->buf_setup(q, &count, &size);
435 size = PAGE_ALIGN(size);
436 dprintk(1, "reqbufs: bufs=%d, size=0x%x [%d pages total]\n",
437 count, size, (count*size)>>PAGE_SHIFT);
439 retval = __videobuf_mmap_setup(q, count, size, req->memory);
441 dprintk(1, "reqbufs: mmap setup returned %d\n", retval);
448 mutex_unlock(&q->vb_lock);
452 int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
456 mutex_lock(&q->vb_lock);
457 if (unlikely(b->type != q->type)) {
458 dprintk(1, "querybuf: Wrong type.\n");
461 if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) {
462 dprintk(1, "querybuf: index out of range.\n");
465 if (unlikely(NULL == q->bufs[b->index])) {
466 dprintk(1, "querybuf: buffer is null.\n");
470 videobuf_status(q, b, q->bufs[b->index], q->type);
474 mutex_unlock(&q->vb_lock);
478 int videobuf_qbuf(struct videobuf_queue *q,
479 struct v4l2_buffer *b)
481 struct videobuf_buffer *buf;
482 enum v4l2_field field;
483 unsigned long flags = 0;
486 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
488 if (b->memory == V4L2_MEMORY_MMAP)
489 down_read(¤t->mm->mmap_sem);
491 mutex_lock(&q->vb_lock);
494 dprintk(1, "qbuf: Reading running...\n");
498 if (b->type != q->type) {
499 dprintk(1, "qbuf: Wrong type.\n");
502 if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
503 dprintk(1, "qbuf: index out of range.\n");
506 buf = q->bufs[b->index];
508 dprintk(1, "qbuf: buffer is null.\n");
511 MAGIC_CHECK(buf->magic, MAGIC_BUFFER);
512 if (buf->memory != b->memory) {
513 dprintk(1, "qbuf: memory type is wrong.\n");
516 if (buf->state != VIDEOBUF_NEEDS_INIT && buf->state != VIDEOBUF_IDLE) {
517 dprintk(1, "qbuf: buffer is already queued or active.\n");
521 if (b->flags & V4L2_BUF_FLAG_INPUT) {
522 if (b->input >= q->inputs) {
523 dprintk(1, "qbuf: wrong input.\n");
526 buf->input = b->input;
532 case V4L2_MEMORY_MMAP:
533 if (0 == buf->baddr) {
534 dprintk(1, "qbuf: mmap requested "
535 "but buffer addr is zero!\n");
539 case V4L2_MEMORY_USERPTR:
540 if (b->length < buf->bsize) {
541 dprintk(1, "qbuf: buffer length is not enough\n");
544 if (VIDEOBUF_NEEDS_INIT != buf->state &&
545 buf->baddr != b->m.userptr)
546 q->ops->buf_release(q, buf);
547 buf->baddr = b->m.userptr;
549 case V4L2_MEMORY_OVERLAY:
550 buf->boff = b->m.offset;
553 dprintk(1, "qbuf: wrong memory type\n");
557 dprintk(1, "qbuf: requesting next field\n");
558 field = videobuf_next_field(q);
559 retval = q->ops->buf_prepare(q, buf, field);
561 dprintk(1, "qbuf: buffer_prepare returned %d\n", retval);
565 list_add_tail(&buf->stream, &q->stream);
568 spin_lock_irqsave(q->irqlock, flags);
569 q->ops->buf_queue(q, buf);
571 spin_unlock_irqrestore(q->irqlock, flags);
573 dprintk(1, "qbuf: succeded\n");
577 mutex_unlock(&q->vb_lock);
579 if (b->memory == V4L2_MEMORY_MMAP)
580 up_read(¤t->mm->mmap_sem);
585 int videobuf_dqbuf(struct videobuf_queue *q,
586 struct v4l2_buffer *b, int nonblocking)
588 struct videobuf_buffer *buf;
591 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
593 mutex_lock(&q->vb_lock);
596 dprintk(1, "dqbuf: Reading running...\n");
600 if (b->type != q->type) {
601 dprintk(1, "dqbuf: Wrong type.\n");
604 if (list_empty(&q->stream)) {
605 dprintk(1, "dqbuf: stream running\n");
608 buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
609 mutex_unlock(&q->vb_lock);
610 retval = videobuf_waiton(buf, nonblocking, 1);
611 mutex_lock(&q->vb_lock);
613 dprintk(1, "dqbuf: waiton returned %d\n", retval);
616 switch (buf->state) {
618 dprintk(1, "dqbuf: state is error\n");
620 CALL(q, sync, q, buf);
621 buf->state = VIDEOBUF_IDLE;
624 dprintk(1, "dqbuf: state is done\n");
625 CALL(q, sync, q, buf);
626 buf->state = VIDEOBUF_IDLE;
629 dprintk(1, "dqbuf: state invalid\n");
633 list_del(&buf->stream);
634 memset(b, 0, sizeof(*b));
635 videobuf_status(q, b, buf, q->type);
638 mutex_unlock(&q->vb_lock);
642 int videobuf_streamon(struct videobuf_queue *q)
644 struct videobuf_buffer *buf;
645 unsigned long flags = 0;
648 mutex_lock(&q->vb_lock);
657 spin_lock_irqsave(q->irqlock, flags);
658 list_for_each_entry(buf, &q->stream, stream)
659 if (buf->state == VIDEOBUF_PREPARED)
660 q->ops->buf_queue(q, buf);
662 spin_unlock_irqrestore(q->irqlock, flags);
665 mutex_unlock(&q->vb_lock);
669 /* Locking: Caller holds q->vb_lock */
670 static int __videobuf_streamoff(struct videobuf_queue *q)
675 videobuf_queue_cancel(q);
681 int videobuf_streamoff(struct videobuf_queue *q)
685 mutex_lock(&q->vb_lock);
686 retval = __videobuf_streamoff(q);
687 mutex_unlock(&q->vb_lock);
692 /* Locking: Caller holds q->vb_lock */
693 static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
695 size_t count, loff_t *ppos)
697 enum v4l2_field field;
698 unsigned long flags = 0;
701 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
704 q->read_buf = videobuf_alloc(q);
705 if (NULL == q->read_buf)
708 q->read_buf->memory = V4L2_MEMORY_USERPTR;
709 q->read_buf->baddr = (unsigned long)data;
710 q->read_buf->bsize = count;
712 field = videobuf_next_field(q);
713 retval = q->ops->buf_prepare(q, q->read_buf, field);
717 /* start capture & wait */
719 spin_lock_irqsave(q->irqlock, flags);
720 q->ops->buf_queue(q, q->read_buf);
722 spin_unlock_irqrestore(q->irqlock, flags);
723 retval = videobuf_waiton(q->read_buf, 0, 0);
725 CALL(q, sync, q, q->read_buf);
726 if (VIDEOBUF_ERROR == q->read_buf->state)
729 retval = q->read_buf->size;
734 q->ops->buf_release(q, q->read_buf);
740 ssize_t videobuf_read_one(struct videobuf_queue *q,
741 char __user *data, size_t count, loff_t *ppos,
744 enum v4l2_field field;
745 unsigned long flags = 0;
746 unsigned size = 0, nbufs = 1;
749 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
751 mutex_lock(&q->vb_lock);
753 q->ops->buf_setup(q, &nbufs, &size);
755 if (NULL == q->read_buf &&
758 retval = videobuf_read_zerocopy(q, data, count, ppos);
759 if (retval >= 0 || retval == -EIO)
762 /* fallback to kernel bounce buffer on failures */
765 if (NULL == q->read_buf) {
766 /* need to capture a new frame */
768 q->read_buf = videobuf_alloc(q);
770 dprintk(1, "video alloc=0x%p\n", q->read_buf);
771 if (NULL == q->read_buf)
773 q->read_buf->memory = V4L2_MEMORY_USERPTR;
774 q->read_buf->bsize = count; /* preferred size */
775 field = videobuf_next_field(q);
776 retval = q->ops->buf_prepare(q, q->read_buf, field);
784 spin_lock_irqsave(q->irqlock, flags);
786 q->ops->buf_queue(q, q->read_buf);
788 spin_unlock_irqrestore(q->irqlock, flags);
792 /* wait until capture is done */
793 retval = videobuf_waiton(q->read_buf, nonblocking, 1);
797 CALL(q, sync, q, q->read_buf);
799 if (VIDEOBUF_ERROR == q->read_buf->state) {
800 /* catch I/O errors */
801 q->ops->buf_release(q, q->read_buf);
808 /* Copy to userspace */
809 retval = CALL(q, video_copy_to_user, q, data, count, nonblocking);
813 q->read_off += retval;
814 if (q->read_off == q->read_buf->size) {
815 /* all data copied, cleanup */
816 q->ops->buf_release(q, q->read_buf);
822 mutex_unlock(&q->vb_lock);
826 /* Locking: Caller holds q->vb_lock */
827 static int __videobuf_read_start(struct videobuf_queue *q)
829 enum v4l2_field field;
830 unsigned long flags = 0;
831 unsigned int count = 0, size = 0;
834 q->ops->buf_setup(q, &count, &size);
837 if (count > VIDEO_MAX_FRAME)
838 count = VIDEO_MAX_FRAME;
839 size = PAGE_ALIGN(size);
841 err = __videobuf_mmap_setup(q, count, size, V4L2_MEMORY_USERPTR);
847 for (i = 0; i < count; i++) {
848 field = videobuf_next_field(q);
849 err = q->ops->buf_prepare(q, q->bufs[i], field);
852 list_add_tail(&q->bufs[i]->stream, &q->stream);
855 spin_lock_irqsave(q->irqlock, flags);
856 for (i = 0; i < count; i++)
857 q->ops->buf_queue(q, q->bufs[i]);
859 spin_unlock_irqrestore(q->irqlock, flags);
864 static void __videobuf_read_stop(struct videobuf_queue *q)
869 videobuf_queue_cancel(q);
870 __videobuf_mmap_free(q);
871 INIT_LIST_HEAD(&q->stream);
872 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
873 if (NULL == q->bufs[i])
883 int videobuf_read_start(struct videobuf_queue *q)
887 mutex_lock(&q->vb_lock);
888 rc = __videobuf_read_start(q);
889 mutex_unlock(&q->vb_lock);
894 void videobuf_read_stop(struct videobuf_queue *q)
896 mutex_lock(&q->vb_lock);
897 __videobuf_read_stop(q);
898 mutex_unlock(&q->vb_lock);
901 void videobuf_stop(struct videobuf_queue *q)
903 mutex_lock(&q->vb_lock);
906 __videobuf_streamoff(q);
909 __videobuf_read_stop(q);
911 mutex_unlock(&q->vb_lock);
915 ssize_t videobuf_read_stream(struct videobuf_queue *q,
916 char __user *data, size_t count, loff_t *ppos,
917 int vbihack, int nonblocking)
920 unsigned long flags = 0;
922 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
924 dprintk(2, "%s\n", __FUNCTION__);
925 mutex_lock(&q->vb_lock);
930 retval = __videobuf_read_start(q);
937 /* get / wait for data */
938 if (NULL == q->read_buf) {
939 q->read_buf = list_entry(q->stream.next,
940 struct videobuf_buffer,
942 list_del(&q->read_buf->stream);
945 rc = videobuf_waiton(q->read_buf, nonblocking, 1);
952 if (q->read_buf->state == VIDEOBUF_DONE) {
953 rc = CALL(q, copy_stream, q, data + retval, count,
954 retval, vbihack, nonblocking);
964 q->read_off = q->read_buf->size;
969 /* requeue buffer when done with copying */
970 if (q->read_off == q->read_buf->size) {
971 list_add_tail(&q->read_buf->stream,
974 spin_lock_irqsave(q->irqlock, flags);
975 q->ops->buf_queue(q, q->read_buf);
977 spin_unlock_irqrestore(q->irqlock, flags);
985 mutex_unlock(&q->vb_lock);
989 unsigned int videobuf_poll_stream(struct file *file,
990 struct videobuf_queue *q,
993 struct videobuf_buffer *buf = NULL;
996 mutex_lock(&q->vb_lock);
998 if (!list_empty(&q->stream))
999 buf = list_entry(q->stream.next,
1000 struct videobuf_buffer, stream);
1003 __videobuf_read_start(q);
1006 } else if (NULL == q->read_buf) {
1007 q->read_buf = list_entry(q->stream.next,
1008 struct videobuf_buffer,
1010 list_del(&q->read_buf->stream);
1019 poll_wait(file, &buf->done, wait);
1020 if (buf->state == VIDEOBUF_DONE ||
1021 buf->state == VIDEOBUF_ERROR)
1022 rc = POLLIN|POLLRDNORM;
1024 mutex_unlock(&q->vb_lock);
1028 int videobuf_mmap_mapper(struct videobuf_queue *q,
1029 struct vm_area_struct *vma)
1033 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
1035 mutex_lock(&q->vb_lock);
1036 retval = CALL(q, mmap_mapper, q, vma);
1038 mutex_unlock(&q->vb_lock);
1043 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1044 int videobuf_cgmbuf(struct videobuf_queue *q,
1045 struct video_mbuf *mbuf, int count)
1047 struct v4l2_requestbuffers req;
1050 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
1052 memset(&req, 0, sizeof(req));
1055 req.memory = V4L2_MEMORY_MMAP;
1056 rc = videobuf_reqbufs(q, &req);
1060 mbuf->frames = req.count;
1062 for (i = 0; i < mbuf->frames; i++) {
1063 mbuf->offsets[i] = q->bufs[i]->boff;
1064 mbuf->size += q->bufs[i]->bsize;
1069 EXPORT_SYMBOL_GPL(videobuf_cgmbuf);
1072 /* --------------------------------------------------------------------- */
1074 EXPORT_SYMBOL_GPL(videobuf_waiton);
1075 EXPORT_SYMBOL_GPL(videobuf_iolock);
1077 EXPORT_SYMBOL_GPL(videobuf_alloc);
1079 EXPORT_SYMBOL_GPL(videobuf_queue_core_init);
1080 EXPORT_SYMBOL_GPL(videobuf_queue_cancel);
1081 EXPORT_SYMBOL_GPL(videobuf_queue_is_busy);
1083 EXPORT_SYMBOL_GPL(videobuf_next_field);
1084 EXPORT_SYMBOL_GPL(videobuf_reqbufs);
1085 EXPORT_SYMBOL_GPL(videobuf_querybuf);
1086 EXPORT_SYMBOL_GPL(videobuf_qbuf);
1087 EXPORT_SYMBOL_GPL(videobuf_dqbuf);
1088 EXPORT_SYMBOL_GPL(videobuf_streamon);
1089 EXPORT_SYMBOL_GPL(videobuf_streamoff);
1091 EXPORT_SYMBOL_GPL(videobuf_read_start);
1092 EXPORT_SYMBOL_GPL(videobuf_read_stop);
1093 EXPORT_SYMBOL_GPL(videobuf_stop);
1094 EXPORT_SYMBOL_GPL(videobuf_read_stream);
1095 EXPORT_SYMBOL_GPL(videobuf_read_one);
1096 EXPORT_SYMBOL_GPL(videobuf_poll_stream);
1098 EXPORT_SYMBOL_GPL(videobuf_mmap_setup);
1099 EXPORT_SYMBOL_GPL(videobuf_mmap_free);
1100 EXPORT_SYMBOL_GPL(videobuf_mmap_mapper);