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 /* FIXME: This is required to avoid OOPS on some cases, since mmap_mapper()
98 method should be called before _iolock.
99 On some cases, the mmap_mapper() is called only after scheduling.
101 However, this way is just too dirty! Better to wait for some event.
103 schedule_timeout(HZ
);
105 return CALL(q
,iolock
,q
,vb
,fbuf
);
108 /* --------------------------------------------------------------------- */
111 void videobuf_queue_core_init(struct videobuf_queue
* q
,
112 struct videobuf_queue_ops
*ops
,
115 enum v4l2_buf_type type
,
116 enum v4l2_field field
,
119 struct videobuf_qtype_ops
*int_ops
)
121 memset(q
,0,sizeof(*q
));
122 q
->irqlock
= irqlock
;
129 q
->int_ops
= int_ops
;
131 /* All buffer operations are mandatory */
132 BUG_ON (!q
->ops
->buf_setup
);
133 BUG_ON (!q
->ops
->buf_prepare
);
134 BUG_ON (!q
->ops
->buf_queue
);
135 BUG_ON (!q
->ops
->buf_release
);
137 /* Having implementations for abstract methods are mandatory */
138 BUG_ON (!q
->int_ops
);
140 mutex_init(&q
->lock
);
141 INIT_LIST_HEAD(&q
->stream
);
144 int videobuf_queue_is_busy(struct videobuf_queue
*q
)
148 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
151 dprintk(1,"busy: streaming active\n");
155 dprintk(1,"busy: pending read #1\n");
159 dprintk(1,"busy: pending read #2\n");
162 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
163 if (NULL
== q
->bufs
[i
])
165 if (q
->bufs
[i
]->map
) {
166 dprintk(1,"busy: buffer #%d mapped\n",i
);
169 if (q
->bufs
[i
]->state
== STATE_QUEUED
) {
170 dprintk(1,"busy: buffer #%d queued\n",i
);
173 if (q
->bufs
[i
]->state
== STATE_ACTIVE
) {
174 dprintk(1,"busy: buffer #%d avtive\n",i
);
181 void videobuf_queue_cancel(struct videobuf_queue
*q
)
183 unsigned long flags
=0;
186 /* remove queued buffers from list */
188 spin_lock_irqsave(q
->irqlock
,flags
);
189 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
190 if (NULL
== q
->bufs
[i
])
192 if (q
->bufs
[i
]->state
== STATE_QUEUED
) {
193 list_del(&q
->bufs
[i
]->queue
);
194 q
->bufs
[i
]->state
= STATE_ERROR
;
198 spin_unlock_irqrestore(q
->irqlock
,flags
);
200 /* free all buffers + clear queue */
201 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
202 if (NULL
== q
->bufs
[i
])
204 q
->ops
->buf_release(q
,q
->bufs
[i
]);
206 INIT_LIST_HEAD(&q
->stream
);
209 /* --------------------------------------------------------------------- */
211 enum v4l2_field
videobuf_next_field(struct videobuf_queue
*q
)
213 enum v4l2_field field
= q
->field
;
215 BUG_ON(V4L2_FIELD_ANY
== field
);
217 if (V4L2_FIELD_ALTERNATE
== field
) {
218 if (V4L2_FIELD_TOP
== q
->last
) {
219 field
= V4L2_FIELD_BOTTOM
;
220 q
->last
= V4L2_FIELD_BOTTOM
;
222 field
= V4L2_FIELD_TOP
;
223 q
->last
= V4L2_FIELD_TOP
;
229 static void videobuf_status(struct videobuf_queue
*q
, struct v4l2_buffer
*b
,
230 struct videobuf_buffer
*vb
, enum v4l2_buf_type type
)
232 MAGIC_CHECK(vb
->magic
,MAGIC_BUFFER
);
233 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
238 b
->memory
= vb
->memory
;
240 case V4L2_MEMORY_MMAP
:
241 b
->m
.offset
= vb
->boff
;
242 b
->length
= vb
->bsize
;
244 case V4L2_MEMORY_USERPTR
:
245 b
->m
.userptr
= vb
->baddr
;
246 b
->length
= vb
->bsize
;
248 case V4L2_MEMORY_OVERLAY
:
249 b
->m
.offset
= vb
->boff
;
255 b
->flags
|= V4L2_BUF_FLAG_MAPPED
;
261 b
->flags
|= V4L2_BUF_FLAG_QUEUED
;
265 b
->flags
|= V4L2_BUF_FLAG_DONE
;
267 case STATE_NEEDS_INIT
:
273 if (vb
->input
!= UNSET
) {
274 b
->flags
|= V4L2_BUF_FLAG_INPUT
;
275 b
->input
= vb
->input
;
278 b
->field
= vb
->field
;
279 b
->timestamp
= vb
->ts
;
280 b
->bytesused
= vb
->size
;
281 b
->sequence
= vb
->field_count
>> 1;
284 int videobuf_reqbufs(struct videobuf_queue
*q
,
285 struct v4l2_requestbuffers
*req
)
287 unsigned int size
,count
;
290 if (req
->type
!= q
->type
) {
291 dprintk(1,"reqbufs: queue type invalid\n");
294 if (req
->count
< 1) {
295 dprintk(1,"reqbufs: count invalid (%d)\n",req
->count
);
298 if (req
->memory
!= V4L2_MEMORY_MMAP
&&
299 req
->memory
!= V4L2_MEMORY_USERPTR
&&
300 req
->memory
!= V4L2_MEMORY_OVERLAY
) {
301 dprintk(1,"reqbufs: memory type invalid\n");
305 mutex_lock(&q
->lock
);
307 dprintk(1,"reqbufs: streaming already exists\n");
311 if (!list_empty(&q
->stream
)) {
312 dprintk(1,"reqbufs: stream running\n");
318 if (count
> VIDEO_MAX_FRAME
)
319 count
= VIDEO_MAX_FRAME
;
321 q
->ops
->buf_setup(q
,&count
,&size
);
322 size
= PAGE_ALIGN(size
);
323 dprintk(1,"reqbufs: bufs=%d, size=0x%x [%d pages total]\n",
324 count
, size
, (count
*size
)>>PAGE_SHIFT
);
326 retval
= videobuf_mmap_setup(q
,count
,size
,req
->memory
);
328 dprintk(1,"reqbufs: mmap setup returned %d\n",retval
);
335 mutex_unlock(&q
->lock
);
339 int videobuf_querybuf(struct videobuf_queue
*q
, struct v4l2_buffer
*b
)
341 if (unlikely(b
->type
!= q
->type
)) {
342 dprintk(1,"querybuf: Wrong type.\n");
345 if (unlikely(b
->index
< 0 || b
->index
>= VIDEO_MAX_FRAME
)) {
346 dprintk(1,"querybuf: index out of range.\n");
349 if (unlikely(NULL
== q
->bufs
[b
->index
])) {
350 dprintk(1,"querybuf: buffer is null.\n");
353 videobuf_status(q
,b
,q
->bufs
[b
->index
],q
->type
);
357 int videobuf_qbuf(struct videobuf_queue
*q
,
358 struct v4l2_buffer
*b
)
360 struct videobuf_buffer
*buf
;
361 enum v4l2_field field
;
362 unsigned long flags
=0;
365 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
367 if (b
->memory
== V4L2_MEMORY_MMAP
)
368 down_read(¤t
->mm
->mmap_sem
);
370 mutex_lock(&q
->lock
);
373 dprintk(1,"qbuf: Reading running...\n");
377 if (b
->type
!= q
->type
) {
378 dprintk(1,"qbuf: Wrong type.\n");
381 if (b
->index
< 0 || b
->index
>= VIDEO_MAX_FRAME
) {
382 dprintk(1,"qbuf: index out of range.\n");
385 buf
= q
->bufs
[b
->index
];
387 dprintk(1,"qbuf: buffer is null.\n");
390 MAGIC_CHECK(buf
->magic
,MAGIC_BUFFER
);
391 if (buf
->memory
!= b
->memory
) {
392 dprintk(1,"qbuf: memory type is wrong.\n");
395 if (buf
->state
!= STATE_NEEDS_INIT
&& buf
->state
!= STATE_IDLE
) {
396 dprintk(1,"qbuf: buffer is already queued or active.\n");
400 if (b
->flags
& V4L2_BUF_FLAG_INPUT
) {
401 if (b
->input
>= q
->inputs
) {
402 dprintk(1,"qbuf: wrong input.\n");
405 buf
->input
= b
->input
;
411 case V4L2_MEMORY_MMAP
:
412 if (0 == buf
->baddr
) {
413 dprintk(1,"qbuf: mmap requested but buffer addr is zero!\n");
417 case V4L2_MEMORY_USERPTR
:
418 if (b
->length
< buf
->bsize
) {
419 dprintk(1,"qbuf: buffer length is not enough\n");
422 if (STATE_NEEDS_INIT
!= buf
->state
&& buf
->baddr
!= b
->m
.userptr
)
423 q
->ops
->buf_release(q
,buf
);
424 buf
->baddr
= b
->m
.userptr
;
426 case V4L2_MEMORY_OVERLAY
:
427 buf
->boff
= b
->m
.offset
;
430 dprintk(1,"qbuf: wrong memory type\n");
434 dprintk(1,"qbuf: requesting next field\n");
435 field
= videobuf_next_field(q
);
436 retval
= q
->ops
->buf_prepare(q
,buf
,field
);
438 dprintk(1,"qbuf: buffer_prepare returned %d\n",retval
);
442 list_add_tail(&buf
->stream
,&q
->stream
);
445 spin_lock_irqsave(q
->irqlock
,flags
);
446 q
->ops
->buf_queue(q
,buf
);
448 spin_unlock_irqrestore(q
->irqlock
,flags
);
450 dprintk(1,"qbuf: succeded\n");
454 mutex_unlock(&q
->lock
);
456 if (b
->memory
== V4L2_MEMORY_MMAP
)
457 up_read(¤t
->mm
->mmap_sem
);
462 int videobuf_dqbuf(struct videobuf_queue
*q
,
463 struct v4l2_buffer
*b
, int nonblocking
)
465 struct videobuf_buffer
*buf
;
468 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
470 mutex_lock(&q
->lock
);
473 dprintk(1,"dqbuf: Reading running...\n");
477 if (b
->type
!= q
->type
) {
478 dprintk(1,"dqbuf: Wrong type.\n");
481 if (list_empty(&q
->stream
)) {
482 dprintk(1,"dqbuf: stream running\n");
485 buf
= list_entry(q
->stream
.next
, struct videobuf_buffer
, stream
);
486 retval
= videobuf_waiton(buf
, nonblocking
, 1);
488 dprintk(1,"dqbuf: waiton returned %d\n",retval
);
491 switch (buf
->state
) {
493 dprintk(1,"dqbuf: state is error\n");
496 buf
->state
= STATE_IDLE
;
499 dprintk(1,"dqbuf: state is done\n");
501 buf
->state
= STATE_IDLE
;
504 dprintk(1,"dqbuf: state invalid\n");
508 list_del(&buf
->stream
);
509 memset(b
,0,sizeof(*b
));
510 videobuf_status(q
,b
,buf
,q
->type
);
513 mutex_unlock(&q
->lock
);
517 int videobuf_streamon(struct videobuf_queue
*q
)
519 struct videobuf_buffer
*buf
;
520 struct list_head
*list
;
521 unsigned long flags
=0;
524 mutex_lock(&q
->lock
);
533 spin_lock_irqsave(q
->irqlock
,flags
);
534 list_for_each(list
,&q
->stream
) {
535 buf
= list_entry(list
, struct videobuf_buffer
, stream
);
536 if (buf
->state
== STATE_PREPARED
)
537 q
->ops
->buf_queue(q
,buf
);
540 spin_unlock_irqrestore(q
->irqlock
,flags
);
543 mutex_unlock(&q
->lock
);
547 int videobuf_streamoff(struct videobuf_queue
*q
)
549 int retval
= -EINVAL
;
551 mutex_lock(&q
->lock
);
554 videobuf_queue_cancel(q
);
559 mutex_unlock(&q
->lock
);
563 static ssize_t
videobuf_read_zerocopy(struct videobuf_queue
*q
,
565 size_t count
, loff_t
*ppos
)
567 enum v4l2_field field
;
568 unsigned long flags
=0;
571 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
574 q
->read_buf
= videobuf_alloc(q
);
575 if (NULL
== q
->read_buf
)
578 q
->read_buf
->memory
= V4L2_MEMORY_USERPTR
;
579 q
->read_buf
->baddr
= (unsigned long)data
;
580 q
->read_buf
->bsize
= count
;
582 field
= videobuf_next_field(q
);
583 retval
= q
->ops
->buf_prepare(q
,q
->read_buf
,field
);
587 /* start capture & wait */
589 spin_lock_irqsave(q
->irqlock
,flags
);
590 q
->ops
->buf_queue(q
,q
->read_buf
);
592 spin_unlock_irqrestore(q
->irqlock
,flags
);
593 retval
= videobuf_waiton(q
->read_buf
,0,0);
595 CALL(q
,sync
,q
,q
->read_buf
);
596 if (STATE_ERROR
== q
->read_buf
->state
)
599 retval
= q
->read_buf
->size
;
604 q
->ops
->buf_release(q
,q
->read_buf
);
610 ssize_t
videobuf_read_one(struct videobuf_queue
*q
,
611 char __user
*data
, size_t count
, loff_t
*ppos
,
614 enum v4l2_field field
;
615 unsigned long flags
=0;
616 unsigned size
, nbufs
;
619 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
621 mutex_lock(&q
->lock
);
624 q
->ops
->buf_setup(q
,&nbufs
,&size
);
626 if (NULL
== q
->read_buf
&&
629 retval
= videobuf_read_zerocopy(q
,data
,count
,ppos
);
630 if (retval
>= 0 || retval
== -EIO
)
633 /* fallback to kernel bounce buffer on failures */
636 if (NULL
== q
->read_buf
) {
637 /* need to capture a new frame */
639 q
->read_buf
= videobuf_alloc(q
);
641 dprintk(1,"video alloc=0x%p\n", q
->read_buf
);
642 if (NULL
== q
->read_buf
)
644 q
->read_buf
->memory
= V4L2_MEMORY_USERPTR
;
645 q
->read_buf
->bsize
= count
; /* preferred size */
646 field
= videobuf_next_field(q
);
647 retval
= q
->ops
->buf_prepare(q
,q
->read_buf
,field
);
655 spin_lock_irqsave(q
->irqlock
,flags
);
657 q
->ops
->buf_queue(q
,q
->read_buf
);
659 spin_unlock_irqrestore(q
->irqlock
,flags
);
663 /* wait until capture is done */
664 retval
= videobuf_waiton(q
->read_buf
, nonblocking
, 1);
668 CALL(q
,sync
,q
,q
->read_buf
);
670 if (STATE_ERROR
== q
->read_buf
->state
) {
671 /* catch I/O errors */
672 q
->ops
->buf_release(q
,q
->read_buf
);
679 /* Copy to userspace */
680 retval
=CALL(q
,copy_to_user
,q
,data
,count
,nonblocking
);
684 q
->read_off
+= retval
;
685 if (q
->read_off
== q
->read_buf
->size
) {
686 /* all data copied, cleanup */
687 q
->ops
->buf_release(q
,q
->read_buf
);
693 mutex_unlock(&q
->lock
);
697 int videobuf_read_start(struct videobuf_queue
*q
)
699 enum v4l2_field field
;
700 unsigned long flags
=0;
701 int count
= 0, size
= 0;
704 q
->ops
->buf_setup(q
,&count
,&size
);
707 if (count
> VIDEO_MAX_FRAME
)
708 count
= VIDEO_MAX_FRAME
;
709 size
= PAGE_ALIGN(size
);
711 err
= videobuf_mmap_setup(q
, count
, size
, V4L2_MEMORY_USERPTR
);
715 for (i
= 0; i
< count
; i
++) {
716 field
= videobuf_next_field(q
);
717 err
= q
->ops
->buf_prepare(q
,q
->bufs
[i
],field
);
720 list_add_tail(&q
->bufs
[i
]->stream
, &q
->stream
);
723 spin_lock_irqsave(q
->irqlock
,flags
);
724 for (i
= 0; i
< count
; i
++)
725 q
->ops
->buf_queue(q
,q
->bufs
[i
]);
727 spin_unlock_irqrestore(q
->irqlock
,flags
);
732 void videobuf_read_stop(struct videobuf_queue
*q
)
736 videobuf_queue_cancel(q
);
737 videobuf_mmap_free(q
);
738 INIT_LIST_HEAD(&q
->stream
);
739 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
740 if (NULL
== q
->bufs
[i
])
749 ssize_t
videobuf_read_stream(struct videobuf_queue
*q
,
750 char __user
*data
, size_t count
, loff_t
*ppos
,
751 int vbihack
, int nonblocking
)
754 unsigned long flags
=0;
756 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
758 dprintk(2,"%s\n",__FUNCTION__
);
759 mutex_lock(&q
->lock
);
764 retval
= videobuf_read_start(q
);
771 /* get / wait for data */
772 if (NULL
== q
->read_buf
) {
773 q
->read_buf
= list_entry(q
->stream
.next
,
774 struct videobuf_buffer
,
776 list_del(&q
->read_buf
->stream
);
779 rc
= videobuf_waiton(q
->read_buf
, nonblocking
, 1);
786 if (q
->read_buf
->state
== STATE_DONE
) {
787 rc
= CALL (q
,copy_stream
, q
, data
+ retval
, count
,
788 retval
, vbihack
, nonblocking
);
798 q
->read_off
= q
->read_buf
->size
;
803 /* requeue buffer when done with copying */
804 if (q
->read_off
== q
->read_buf
->size
) {
805 list_add_tail(&q
->read_buf
->stream
,
808 spin_lock_irqsave(q
->irqlock
,flags
);
809 q
->ops
->buf_queue(q
,q
->read_buf
);
811 spin_unlock_irqrestore(q
->irqlock
,flags
);
819 mutex_unlock(&q
->lock
);
823 unsigned int videobuf_poll_stream(struct file
*file
,
824 struct videobuf_queue
*q
,
827 struct videobuf_buffer
*buf
= NULL
;
830 mutex_lock(&q
->lock
);
832 if (!list_empty(&q
->stream
))
833 buf
= list_entry(q
->stream
.next
,
834 struct videobuf_buffer
, stream
);
837 videobuf_read_start(q
);
840 } else if (NULL
== q
->read_buf
) {
841 q
->read_buf
= list_entry(q
->stream
.next
,
842 struct videobuf_buffer
,
844 list_del(&q
->read_buf
->stream
);
853 poll_wait(file
, &buf
->done
, wait
);
854 if (buf
->state
== STATE_DONE
||
855 buf
->state
== STATE_ERROR
)
856 rc
= POLLIN
|POLLRDNORM
;
858 mutex_unlock(&q
->lock
);
862 int videobuf_mmap_setup(struct videobuf_queue
*q
,
863 unsigned int bcount
, unsigned int bsize
,
864 enum v4l2_memory memory
)
869 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
871 err
= videobuf_mmap_free(q
);
875 /* Allocate and initialize buffers */
876 for (i
= 0; i
< bcount
; i
++) {
877 q
->bufs
[i
] = videobuf_alloc(q
);
880 q
->bufs
[i
]->input
= UNSET
;
881 q
->bufs
[i
]->memory
= memory
;
882 q
->bufs
[i
]->bsize
= bsize
;
884 case V4L2_MEMORY_MMAP
:
885 q
->bufs
[i
]->boff
= bsize
* i
;
887 case V4L2_MEMORY_USERPTR
:
888 case V4L2_MEMORY_OVERLAY
:
894 dprintk(1,"mmap setup: %d buffers, %d bytes each\n",
900 int videobuf_mmap_free(struct videobuf_queue
*q
)
908 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
910 rc
= CALL(q
,mmap_free
,q
);
914 for (i
= 0; i
< VIDEO_MAX_FRAME
; i
++) {
915 if (NULL
== q
->bufs
[i
])
917 q
->ops
->buf_release(q
,q
->bufs
[i
]);
925 int videobuf_mmap_mapper(struct videobuf_queue
*q
,
926 struct vm_area_struct
*vma
)
930 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
932 mutex_lock(&q
->lock
);
933 retval
=CALL(q
,mmap_mapper
,q
,vma
);
934 mutex_unlock(&q
->lock
);
939 #ifdef CONFIG_VIDEO_V4L1_COMPAT
940 int videobuf_cgmbuf(struct videobuf_queue
*q
,
941 struct video_mbuf
*mbuf
, int count
)
943 struct v4l2_requestbuffers req
;
946 MAGIC_CHECK(q
->int_ops
->magic
,MAGIC_QTYPE_OPS
);
948 memset(&req
,0,sizeof(req
));
951 req
.memory
= V4L2_MEMORY_MMAP
;
952 rc
= videobuf_reqbufs(q
,&req
);
956 mbuf
->frames
= req
.count
;
958 for (i
= 0; i
< mbuf
->frames
; i
++) {
959 mbuf
->offsets
[i
] = q
->bufs
[i
]->boff
;
960 mbuf
->size
+= q
->bufs
[i
]->bsize
;
967 /* --------------------------------------------------------------------- */
969 EXPORT_SYMBOL_GPL(videobuf_waiton
);
970 EXPORT_SYMBOL_GPL(videobuf_iolock
);
972 EXPORT_SYMBOL_GPL(videobuf_alloc
);
974 EXPORT_SYMBOL_GPL(videobuf_queue_core_init
);
975 EXPORT_SYMBOL_GPL(videobuf_queue_cancel
);
976 EXPORT_SYMBOL_GPL(videobuf_queue_is_busy
);
978 EXPORT_SYMBOL_GPL(videobuf_next_field
);
979 EXPORT_SYMBOL_GPL(videobuf_reqbufs
);
980 EXPORT_SYMBOL_GPL(videobuf_querybuf
);
981 EXPORT_SYMBOL_GPL(videobuf_qbuf
);
982 EXPORT_SYMBOL_GPL(videobuf_dqbuf
);
983 EXPORT_SYMBOL_GPL(videobuf_cgmbuf
);
984 EXPORT_SYMBOL_GPL(videobuf_streamon
);
985 EXPORT_SYMBOL_GPL(videobuf_streamoff
);
987 EXPORT_SYMBOL_GPL(videobuf_read_start
);
988 EXPORT_SYMBOL_GPL(videobuf_read_stop
);
989 EXPORT_SYMBOL_GPL(videobuf_read_stream
);
990 EXPORT_SYMBOL_GPL(videobuf_read_one
);
991 EXPORT_SYMBOL_GPL(videobuf_poll_stream
);
993 EXPORT_SYMBOL_GPL(videobuf_mmap_setup
);
994 EXPORT_SYMBOL_GPL(videobuf_mmap_free
);
995 EXPORT_SYMBOL_GPL(videobuf_mmap_mapper
);