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) if (unlikely((is) != (should))) \
26 { printk(KERN_ERR "magic mismatch: %x (expected %x)\n",is,should); BUG(); }
29 module_param(debug
, int, 0644);
31 MODULE_DESCRIPTION("helper module to manage video4linux buffers");
32 MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
33 MODULE_LICENSE("GPL");
35 #define dprintk(level, fmt, arg...) if (debug >= level) \
36 printk(KERN_DEBUG "vbuf: " fmt , ## arg)
38 /* --------------------------------------------------------------------- */
40 #define CALL(q, f, arg...) \
41 ( (q->int_ops->f)? q->int_ops->f(arg) : 0)
43 void* videobuf_alloc(struct videobuf_queue
* q
)
45 struct videobuf_buffer
*vb
;
47 BUG_ON (q
->msize
<sizeof(*vb
));
49 if (!q
->int_ops
|| !q
->int_ops
->alloc
) {
50 printk(KERN_ERR
"No specific ops defined!\n");
54 vb
= q
->int_ops
->alloc(q
->msize
);
57 init_waitqueue_head(&vb
->done
);
58 vb
->magic
= MAGIC_BUFFER
;
64 int videobuf_waiton(struct videobuf_buffer
*vb
, int non_blocking
, int intr
)
67 DECLARE_WAITQUEUE(wait
, current
);
69 MAGIC_CHECK(vb
->magic
,MAGIC_BUFFER
);
70 add_wait_queue(&vb
->done
, &wait
);
71 while (vb
->state
== STATE_ACTIVE
|| vb
->state
== STATE_QUEUED
) {
76 set_current_state(intr
? TASK_INTERRUPTIBLE
77 : TASK_UNINTERRUPTIBLE
);
78 if (vb
->state
== STATE_ACTIVE
|| vb
->state
== STATE_QUEUED
)
80 set_current_state(TASK_RUNNING
);
81 if (intr
&& signal_pending(current
)) {
82 dprintk(1,"buffer waiton: -EINTR\n");
87 remove_wait_queue(&vb
->done
, &wait
);
91 int videobuf_iolock(struct videobuf_queue
* q
, struct videobuf_buffer
*vb
,
92 struct v4l2_framebuffer
*fbuf
)
94 MAGIC_CHECK(vb
->magic
,MAGIC_BUFFER
);
95 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
97 return CALL(q
,iolock
,q
,vb
,fbuf
);
100 /* --------------------------------------------------------------------- */
103 void videobuf_queue_init(struct videobuf_queue
* q
,
104 struct videobuf_queue_ops
*ops
,
107 enum v4l2_buf_type type
,
108 enum v4l2_field field
,
112 memset(q
,0,sizeof(*q
));
113 q
->irqlock
= irqlock
;
121 /* All buffer operations are mandatory */
122 BUG_ON (!q
->ops
->buf_setup
);
123 BUG_ON (!q
->ops
->buf_prepare
);
124 BUG_ON (!q
->ops
->buf_queue
);
125 BUG_ON (!q
->ops
->buf_release
);
127 mutex_init(&q
->lock
);
128 INIT_LIST_HEAD(&q
->stream
);
131 int videobuf_queue_is_busy(struct videobuf_queue
*q
)
135 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
138 dprintk(1,"busy: streaming active\n");
142 dprintk(1,"busy: pending read #1\n");
146 dprintk(1,"busy: pending read #2\n");
149 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
150 if (NULL
== q
->bufs
[i
])
152 if (q
->bufs
[i
]->map
) {
153 dprintk(1,"busy: buffer #%d mapped\n",i
);
156 if (q
->bufs
[i
]->state
== STATE_QUEUED
) {
157 dprintk(1,"busy: buffer #%d queued\n",i
);
160 if (q
->bufs
[i
]->state
== STATE_ACTIVE
) {
161 dprintk(1,"busy: buffer #%d avtive\n",i
);
168 void videobuf_queue_cancel(struct videobuf_queue
*q
)
170 unsigned long flags
=0;
173 /* remove queued buffers from list */
175 spin_lock_irqsave(q
->irqlock
,flags
);
176 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
177 if (NULL
== q
->bufs
[i
])
179 if (q
->bufs
[i
]->state
== STATE_QUEUED
) {
180 list_del(&q
->bufs
[i
]->queue
);
181 q
->bufs
[i
]->state
= STATE_ERROR
;
185 spin_unlock_irqrestore(q
->irqlock
,flags
);
187 /* free all buffers + clear queue */
188 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
189 if (NULL
== q
->bufs
[i
])
191 q
->ops
->buf_release(q
,q
->bufs
[i
]);
193 INIT_LIST_HEAD(&q
->stream
);
196 /* --------------------------------------------------------------------- */
198 enum v4l2_field
videobuf_next_field(struct videobuf_queue
*q
)
200 enum v4l2_field field
= q
->field
;
202 BUG_ON(V4L2_FIELD_ANY
== field
);
204 if (V4L2_FIELD_ALTERNATE
== field
) {
205 if (V4L2_FIELD_TOP
== q
->last
) {
206 field
= V4L2_FIELD_BOTTOM
;
207 q
->last
= V4L2_FIELD_BOTTOM
;
209 field
= V4L2_FIELD_TOP
;
210 q
->last
= V4L2_FIELD_TOP
;
216 static void videobuf_status(struct videobuf_queue
*q
, struct v4l2_buffer
*b
,
217 struct videobuf_buffer
*vb
, enum v4l2_buf_type type
)
219 MAGIC_CHECK(vb
->magic
,MAGIC_BUFFER
);
220 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
225 b
->memory
= vb
->memory
;
227 case V4L2_MEMORY_MMAP
:
228 b
->m
.offset
= vb
->boff
;
229 b
->length
= vb
->bsize
;
231 case V4L2_MEMORY_USERPTR
:
232 b
->m
.userptr
= vb
->baddr
;
233 b
->length
= vb
->bsize
;
235 case V4L2_MEMORY_OVERLAY
:
236 b
->m
.offset
= vb
->boff
;
242 b
->flags
|= V4L2_BUF_FLAG_MAPPED
;
248 b
->flags
|= V4L2_BUF_FLAG_QUEUED
;
252 b
->flags
|= V4L2_BUF_FLAG_DONE
;
254 case STATE_NEEDS_INIT
:
260 if (vb
->input
!= UNSET
) {
261 b
->flags
|= V4L2_BUF_FLAG_INPUT
;
262 b
->input
= vb
->input
;
265 b
->field
= vb
->field
;
266 b
->timestamp
= vb
->ts
;
267 b
->bytesused
= vb
->size
;
268 b
->sequence
= vb
->field_count
>> 1;
271 int videobuf_reqbufs(struct videobuf_queue
*q
,
272 struct v4l2_requestbuffers
*req
)
274 unsigned int size
,count
;
277 if (req
->type
!= q
->type
) {
278 dprintk(1,"reqbufs: queue type invalid\n");
281 if (req
->count
< 1) {
282 dprintk(1,"reqbufs: count invalid (%d)\n",req
->count
);
285 if (req
->memory
!= V4L2_MEMORY_MMAP
&&
286 req
->memory
!= V4L2_MEMORY_USERPTR
&&
287 req
->memory
!= V4L2_MEMORY_OVERLAY
) {
288 dprintk(1,"reqbufs: memory type invalid\n");
292 mutex_lock(&q
->lock
);
294 dprintk(1,"reqbufs: streaming already exists\n");
298 if (!list_empty(&q
->stream
)) {
299 dprintk(1,"reqbufs: stream running\n");
305 if (count
> VIDEO_MAX_FRAME
)
306 count
= VIDEO_MAX_FRAME
;
308 q
->ops
->buf_setup(q
,&count
,&size
);
309 size
= PAGE_ALIGN(size
);
310 dprintk(1,"reqbufs: bufs=%d, size=0x%x [%d pages total]\n",
311 count
, size
, (count
*size
)>>PAGE_SHIFT
);
313 retval
= videobuf_mmap_setup(q
,count
,size
,req
->memory
);
315 dprintk(1,"reqbufs: mmap setup returned %d\n",retval
);
322 mutex_unlock(&q
->lock
);
326 int videobuf_querybuf(struct videobuf_queue
*q
, struct v4l2_buffer
*b
)
328 if (unlikely(b
->type
!= q
->type
)) {
329 dprintk(1,"querybuf: Wrong type.\n");
332 if (unlikely(b
->index
< 0 || b
->index
>= VIDEO_MAX_FRAME
)) {
333 dprintk(1,"querybuf: index out of range.\n");
336 if (unlikely(NULL
== q
->bufs
[b
->index
])) {
337 dprintk(1,"querybuf: buffer is null.\n");
340 videobuf_status(q
,b
,q
->bufs
[b
->index
],q
->type
);
344 int videobuf_qbuf(struct videobuf_queue
*q
,
345 struct v4l2_buffer
*b
)
347 struct videobuf_buffer
*buf
;
348 enum v4l2_field field
;
349 unsigned long flags
=0;
352 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
354 if (b
->memory
== V4L2_MEMORY_MMAP
)
355 down_read(¤t
->mm
->mmap_sem
);
357 mutex_lock(&q
->lock
);
360 dprintk(1,"qbuf: Reading running...\n");
364 if (b
->type
!= q
->type
) {
365 dprintk(1,"qbuf: Wrong type.\n");
368 if (b
->index
< 0 || b
->index
>= VIDEO_MAX_FRAME
) {
369 dprintk(1,"qbuf: index out of range.\n");
372 buf
= q
->bufs
[b
->index
];
374 dprintk(1,"qbuf: buffer is null.\n");
377 MAGIC_CHECK(buf
->magic
,MAGIC_BUFFER
);
378 if (buf
->memory
!= b
->memory
) {
379 dprintk(1,"qbuf: memory type is wrong.\n");
382 if (buf
->state
!= STATE_NEEDS_INIT
&& buf
->state
!= STATE_IDLE
) {
383 dprintk(1,"qbuf: buffer is already queued or active.\n");
387 if (b
->flags
& V4L2_BUF_FLAG_INPUT
) {
388 if (b
->input
>= q
->inputs
) {
389 dprintk(1,"qbuf: wrong input.\n");
392 buf
->input
= b
->input
;
398 case V4L2_MEMORY_MMAP
:
399 if (0 == buf
->baddr
) {
400 dprintk(1,"qbuf: mmap requested but buffer addr is zero!\n");
404 case V4L2_MEMORY_USERPTR
:
405 if (b
->length
< buf
->bsize
) {
406 dprintk(1,"qbuf: buffer length is not enough\n");
409 if (STATE_NEEDS_INIT
!= buf
->state
&& buf
->baddr
!= b
->m
.userptr
)
410 q
->ops
->buf_release(q
,buf
);
411 buf
->baddr
= b
->m
.userptr
;
413 case V4L2_MEMORY_OVERLAY
:
414 buf
->boff
= b
->m
.offset
;
417 dprintk(1,"qbuf: wrong memory type\n");
421 dprintk(1,"qbuf: requesting next field\n");
422 field
= videobuf_next_field(q
);
423 retval
= q
->ops
->buf_prepare(q
,buf
,field
);
425 dprintk(1,"qbuf: buffer_prepare returned %d\n",retval
);
429 list_add_tail(&buf
->stream
,&q
->stream
);
432 spin_lock_irqsave(q
->irqlock
,flags
);
433 q
->ops
->buf_queue(q
,buf
);
435 spin_unlock_irqrestore(q
->irqlock
,flags
);
437 dprintk(1,"qbuf: succeded\n");
441 mutex_unlock(&q
->lock
);
443 if (b
->memory
== V4L2_MEMORY_MMAP
)
444 up_read(¤t
->mm
->mmap_sem
);
449 int videobuf_dqbuf(struct videobuf_queue
*q
,
450 struct v4l2_buffer
*b
, int nonblocking
)
452 struct videobuf_buffer
*buf
;
455 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
457 mutex_lock(&q
->lock
);
460 dprintk(1,"dqbuf: Reading running...\n");
464 if (b
->type
!= q
->type
) {
465 dprintk(1,"dqbuf: Wrong type.\n");
468 if (list_empty(&q
->stream
)) {
469 dprintk(1,"dqbuf: stream running\n");
472 buf
= list_entry(q
->stream
.next
, struct videobuf_buffer
, stream
);
473 retval
= videobuf_waiton(buf
, nonblocking
, 1);
475 dprintk(1,"dqbuf: waiton returned %d\n",retval
);
478 switch (buf
->state
) {
480 dprintk(1,"dqbuf: state is error\n");
483 buf
->state
= STATE_IDLE
;
486 dprintk(1,"dqbuf: state is done\n");
488 buf
->state
= STATE_IDLE
;
491 dprintk(1,"dqbuf: state invalid\n");
495 list_del(&buf
->stream
);
496 memset(b
,0,sizeof(*b
));
497 videobuf_status(q
,b
,buf
,q
->type
);
500 mutex_unlock(&q
->lock
);
504 int videobuf_streamon(struct videobuf_queue
*q
)
506 struct videobuf_buffer
*buf
;
507 struct list_head
*list
;
508 unsigned long flags
=0;
511 mutex_lock(&q
->lock
);
520 spin_lock_irqsave(q
->irqlock
,flags
);
521 list_for_each(list
,&q
->stream
) {
522 buf
= list_entry(list
, struct videobuf_buffer
, stream
);
523 if (buf
->state
== STATE_PREPARED
)
524 q
->ops
->buf_queue(q
,buf
);
527 spin_unlock_irqrestore(q
->irqlock
,flags
);
530 mutex_unlock(&q
->lock
);
534 int videobuf_streamoff(struct videobuf_queue
*q
)
536 int retval
= -EINVAL
;
538 mutex_lock(&q
->lock
);
541 videobuf_queue_cancel(q
);
546 mutex_unlock(&q
->lock
);
550 static ssize_t
videobuf_read_zerocopy(struct videobuf_queue
*q
,
552 size_t count
, loff_t
*ppos
)
554 enum v4l2_field field
;
555 unsigned long flags
=0;
558 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
561 q
->read_buf
= videobuf_alloc(q
);
562 if (NULL
== q
->read_buf
)
565 q
->read_buf
->memory
= V4L2_MEMORY_USERPTR
;
566 q
->read_buf
->baddr
= (unsigned long)data
;
567 q
->read_buf
->bsize
= count
;
569 field
= videobuf_next_field(q
);
570 retval
= q
->ops
->buf_prepare(q
,q
->read_buf
,field
);
574 /* start capture & wait */
576 spin_lock_irqsave(q
->irqlock
,flags
);
577 q
->ops
->buf_queue(q
,q
->read_buf
);
579 spin_unlock_irqrestore(q
->irqlock
,flags
);
580 retval
= videobuf_waiton(q
->read_buf
,0,0);
582 CALL(q
,sync
,q
,q
->read_buf
);
583 if (STATE_ERROR
== q
->read_buf
->state
)
586 retval
= q
->read_buf
->size
;
591 q
->ops
->buf_release(q
,q
->read_buf
);
597 ssize_t
videobuf_read_one(struct videobuf_queue
*q
,
598 char __user
*data
, size_t count
, loff_t
*ppos
,
601 enum v4l2_field field
;
602 unsigned long flags
=0;
603 unsigned size
, nbufs
;
606 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
608 mutex_lock(&q
->lock
);
611 q
->ops
->buf_setup(q
,&nbufs
,&size
);
613 if (NULL
== q
->read_buf
&&
616 retval
= videobuf_read_zerocopy(q
,data
,count
,ppos
);
617 if (retval
>= 0 || retval
== -EIO
)
620 /* fallback to kernel bounce buffer on failures */
623 if (NULL
== q
->read_buf
) {
624 /* need to capture a new frame */
626 q
->read_buf
= videobuf_alloc(q
);
628 dprintk(1,"video alloc=0x%p\n", q
->read_buf
);
629 if (NULL
== q
->read_buf
)
631 q
->read_buf
->memory
= V4L2_MEMORY_USERPTR
;
632 q
->read_buf
->bsize
= count
; /* preferred size */
633 field
= videobuf_next_field(q
);
634 retval
= q
->ops
->buf_prepare(q
,q
->read_buf
,field
);
642 spin_lock_irqsave(q
->irqlock
,flags
);
644 q
->ops
->buf_queue(q
,q
->read_buf
);
646 spin_unlock_irqrestore(q
->irqlock
,flags
);
650 /* wait until capture is done */
651 retval
= videobuf_waiton(q
->read_buf
, nonblocking
, 1);
655 CALL(q
,sync
,q
,q
->read_buf
);
657 if (STATE_ERROR
== q
->read_buf
->state
) {
658 /* catch I/O errors */
659 q
->ops
->buf_release(q
,q
->read_buf
);
666 /* Copy to userspace */
667 retval
=CALL(q
,copy_to_user
,q
,data
,count
,nonblocking
);
671 q
->read_off
+= retval
;
672 if (q
->read_off
== q
->read_buf
->size
) {
673 /* all data copied, cleanup */
674 q
->ops
->buf_release(q
,q
->read_buf
);
680 mutex_unlock(&q
->lock
);
684 int videobuf_read_start(struct videobuf_queue
*q
)
686 enum v4l2_field field
;
687 unsigned long flags
=0;
688 int count
= 0, size
= 0;
691 q
->ops
->buf_setup(q
,&count
,&size
);
694 if (count
> VIDEO_MAX_FRAME
)
695 count
= VIDEO_MAX_FRAME
;
696 size
= PAGE_ALIGN(size
);
698 err
= videobuf_mmap_setup(q
, count
, size
, V4L2_MEMORY_USERPTR
);
702 for (i
= 0; i
< count
; i
++) {
703 field
= videobuf_next_field(q
);
704 err
= q
->ops
->buf_prepare(q
,q
->bufs
[i
],field
);
707 list_add_tail(&q
->bufs
[i
]->stream
, &q
->stream
);
710 spin_lock_irqsave(q
->irqlock
,flags
);
711 for (i
= 0; i
< count
; i
++)
712 q
->ops
->buf_queue(q
,q
->bufs
[i
]);
714 spin_unlock_irqrestore(q
->irqlock
,flags
);
719 void videobuf_read_stop(struct videobuf_queue
*q
)
723 videobuf_queue_cancel(q
);
724 videobuf_mmap_free(q
);
725 INIT_LIST_HEAD(&q
->stream
);
726 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
727 if (NULL
== q
->bufs
[i
])
736 ssize_t
videobuf_read_stream(struct videobuf_queue
*q
,
737 char __user
*data
, size_t count
, loff_t
*ppos
,
738 int vbihack
, int nonblocking
)
741 unsigned long flags
=0;
743 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
745 dprintk(2,"%s\n",__FUNCTION__
);
746 mutex_lock(&q
->lock
);
751 retval
= videobuf_read_start(q
);
758 /* get / wait for data */
759 if (NULL
== q
->read_buf
) {
760 q
->read_buf
= list_entry(q
->stream
.next
,
761 struct videobuf_buffer
,
763 list_del(&q
->read_buf
->stream
);
766 rc
= videobuf_waiton(q
->read_buf
, nonblocking
, 1);
773 if (q
->read_buf
->state
== STATE_DONE
) {
774 rc
= CALL (q
,copy_stream
, q
, data
+ retval
, count
,
775 retval
, vbihack
, nonblocking
);
785 q
->read_off
= q
->read_buf
->size
;
790 /* requeue buffer when done with copying */
791 if (q
->read_off
== q
->read_buf
->size
) {
792 list_add_tail(&q
->read_buf
->stream
,
795 spin_lock_irqsave(q
->irqlock
,flags
);
796 q
->ops
->buf_queue(q
,q
->read_buf
);
798 spin_unlock_irqrestore(q
->irqlock
,flags
);
806 mutex_unlock(&q
->lock
);
810 unsigned int videobuf_poll_stream(struct file
*file
,
811 struct videobuf_queue
*q
,
814 struct videobuf_buffer
*buf
= NULL
;
817 mutex_lock(&q
->lock
);
819 if (!list_empty(&q
->stream
))
820 buf
= list_entry(q
->stream
.next
,
821 struct videobuf_buffer
, stream
);
824 videobuf_read_start(q
);
827 } else if (NULL
== q
->read_buf
) {
828 q
->read_buf
= list_entry(q
->stream
.next
,
829 struct videobuf_buffer
,
831 list_del(&q
->read_buf
->stream
);
840 poll_wait(file
, &buf
->done
, wait
);
841 if (buf
->state
== STATE_DONE
||
842 buf
->state
== STATE_ERROR
)
843 rc
= POLLIN
|POLLRDNORM
;
845 mutex_unlock(&q
->lock
);
849 int videobuf_mmap_setup(struct videobuf_queue
*q
,
850 unsigned int bcount
, unsigned int bsize
,
851 enum v4l2_memory memory
)
856 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
858 err
= videobuf_mmap_free(q
);
862 /* Allocate and initialize buffers */
863 for (i
= 0; i
< bcount
; i
++) {
864 q
->bufs
[i
] = videobuf_alloc(q
);
867 q
->bufs
[i
]->input
= UNSET
;
868 q
->bufs
[i
]->memory
= memory
;
869 q
->bufs
[i
]->bsize
= bsize
;
871 case V4L2_MEMORY_MMAP
:
872 q
->bufs
[i
]->boff
= bsize
* i
;
874 case V4L2_MEMORY_USERPTR
:
875 case V4L2_MEMORY_OVERLAY
:
881 dprintk(1,"mmap setup: %d buffers, %d bytes each\n",
887 int videobuf_mmap_free(struct videobuf_queue
*q
)
895 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
897 rc
= CALL(q
,mmap_free
,q
);
901 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
902 if (NULL
== q
->bufs
[i
])
904 q
->ops
->buf_release(q
,q
->bufs
[i
]);
912 int videobuf_mmap_mapper(struct videobuf_queue
*q
,
913 struct vm_area_struct
*vma
)
917 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
919 mutex_lock(&q
->lock
);
920 retval
=CALL(q
,mmap_mapper
,q
,vma
);
921 mutex_unlock(&q
->lock
);
926 #ifdef CONFIG_VIDEO_V4L1_COMPAT
927 int videobuf_cgmbuf(struct videobuf_queue
*q
,
928 struct video_mbuf
*mbuf
, int count
)
930 struct v4l2_requestbuffers req
;
933 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
935 memset(&req
,0,sizeof(req
));
938 req
.memory
= V4L2_MEMORY_MMAP
;
939 rc
= videobuf_reqbufs(q
,&req
);
943 mbuf
->frames
= req
.count
;
945 for (i
= 0; i
< mbuf
->frames
; i
++) {
946 mbuf
->offsets
[i
] = q
->bufs
[i
]->boff
;
947 mbuf
->size
+= q
->bufs
[i
]->bsize
;
954 /* --------------------------------------------------------------------- */
956 EXPORT_SYMBOL_GPL(videobuf_waiton
);
957 EXPORT_SYMBOL_GPL(videobuf_iolock
);
959 EXPORT_SYMBOL_GPL(videobuf_alloc
);
961 EXPORT_SYMBOL_GPL(videobuf_queue_init
);
962 EXPORT_SYMBOL_GPL(videobuf_queue_cancel
);
963 EXPORT_SYMBOL_GPL(videobuf_queue_is_busy
);
965 EXPORT_SYMBOL_GPL(videobuf_next_field
);
966 EXPORT_SYMBOL_GPL(videobuf_reqbufs
);
967 EXPORT_SYMBOL_GPL(videobuf_querybuf
);
968 EXPORT_SYMBOL_GPL(videobuf_qbuf
);
969 EXPORT_SYMBOL_GPL(videobuf_dqbuf
);
970 EXPORT_SYMBOL_GPL(videobuf_cgmbuf
);
971 EXPORT_SYMBOL_GPL(videobuf_streamon
);
972 EXPORT_SYMBOL_GPL(videobuf_streamoff
);
974 EXPORT_SYMBOL_GPL(videobuf_read_start
);
975 EXPORT_SYMBOL_GPL(videobuf_read_stop
);
976 EXPORT_SYMBOL_GPL(videobuf_read_stream
);
977 EXPORT_SYMBOL_GPL(videobuf_read_one
);
978 EXPORT_SYMBOL_GPL(videobuf_poll_stream
);
980 EXPORT_SYMBOL_GPL(videobuf_mmap_setup
);
981 EXPORT_SYMBOL_GPL(videobuf_mmap_free
);
982 EXPORT_SYMBOL_GPL(videobuf_mmap_mapper
);