2424#include <media/videobuf-core.h>
2525
2626#define MAGIC_BUFFER 0x20070728
27- #define MAGIC_CHECK (is , should ) do { \
28- if (unlikely((is) != (should))) { \
29- printk(KERN_ERR "magic mismatch: %x (expected %x)\n", is, should); \
30- BUG(); } } while (0)
27+ #define MAGIC_CHECK (is , should ) \
28+ do { \
29+ if (unlikely((is) != (should))) { \
30+ printk(KERN_ERR \
31+ "magic mismatch: %x (expected %x)\n", \
32+ is, should); \
33+ BUG(); \
34+ } \
35+ } while (0)
3136
3237static int debug ;
3338module_param (debug , int , 0644 );
@@ -36,9 +41,11 @@ MODULE_DESCRIPTION("helper module to manage video4linux buffers");
3641MODULE_AUTHOR ("Mauro Carvalho Chehab <mchehab@infradead.org>" );
3742MODULE_LICENSE ("GPL" );
3843
39- #define dprintk (level , fmt , arg ...) do { \
40- if (debug >= level) \
41- printk(KERN_DEBUG "vbuf: " fmt , ## arg); } while (0)
44+ #define dprintk (level , fmt , arg ...) \
45+ do { \
46+ if (debug >= level) \
47+ printk(KERN_DEBUG "vbuf: " fmt, ## arg); \
48+ } while (0)
4249
4350/* --------------------------------------------------------------------- */
4451
@@ -57,14 +64,14 @@ void *videobuf_alloc(struct videobuf_queue *q)
5764 }
5865
5966 vb = q -> int_ops -> alloc (q -> msize );
60-
6167 if (NULL != vb ) {
6268 init_waitqueue_head (& vb -> done );
63- vb -> magic = MAGIC_BUFFER ;
69+ vb -> magic = MAGIC_BUFFER ;
6470 }
6571
6672 return vb ;
6773}
74+ EXPORT_SYMBOL_GPL (videobuf_alloc );
6875
6976#define WAITON_CONDITION (vb->state != VIDEOBUF_ACTIVE &&\
7077 vb->state != VIDEOBUF_QUEUED)
@@ -86,6 +93,7 @@ int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
8693
8794 return 0 ;
8895}
96+ EXPORT_SYMBOL_GPL (videobuf_waiton );
8997
9098int videobuf_iolock (struct videobuf_queue * q , struct videobuf_buffer * vb ,
9199 struct v4l2_framebuffer * fbuf )
@@ -95,9 +103,10 @@ int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb,
95103
96104 return CALL (q , iolock , q , vb , fbuf );
97105}
106+ EXPORT_SYMBOL_GPL (videobuf_iolock );
98107
99- void * videobuf_queue_to_vmalloc (struct videobuf_queue * q ,
100- struct videobuf_buffer * buf )
108+ void * videobuf_queue_to_vmalloc (struct videobuf_queue * q ,
109+ struct videobuf_buffer * buf )
101110{
102111 if (q -> int_ops -> vmalloc )
103112 return q -> int_ops -> vmalloc (buf );
@@ -146,6 +155,7 @@ void videobuf_queue_core_init(struct videobuf_queue *q,
146155 init_waitqueue_head (& q -> wait );
147156 INIT_LIST_HEAD (& q -> stream );
148157}
158+ EXPORT_SYMBOL_GPL (videobuf_queue_core_init );
149159
150160/* Locking: Only usage in bttv unsafe find way to remove */
151161int videobuf_queue_is_busy (struct videobuf_queue * q )
@@ -184,6 +194,7 @@ int videobuf_queue_is_busy(struct videobuf_queue *q)
184194 }
185195 return 0 ;
186196}
197+ EXPORT_SYMBOL_GPL (videobuf_queue_is_busy );
187198
188199/* Locking: Caller holds q->vb_lock */
189200void videobuf_queue_cancel (struct videobuf_queue * q )
@@ -216,6 +227,7 @@ void videobuf_queue_cancel(struct videobuf_queue *q)
216227 }
217228 INIT_LIST_HEAD (& q -> stream );
218229}
230+ EXPORT_SYMBOL_GPL (videobuf_queue_cancel );
219231
220232/* --------------------------------------------------------------------- */
221233
@@ -237,6 +249,7 @@ enum v4l2_field videobuf_next_field(struct videobuf_queue *q)
237249 }
238250 return field ;
239251}
252+ EXPORT_SYMBOL_GPL (videobuf_next_field );
240253
241254/* Locking: Caller holds q->vb_lock */
242255static void videobuf_status (struct videobuf_queue * q , struct v4l2_buffer * b ,
@@ -305,8 +318,7 @@ static int __videobuf_mmap_free(struct videobuf_queue *q)
305318
306319 MAGIC_CHECK (q -> int_ops -> magic , MAGIC_QTYPE_OPS );
307320
308-
309- rc = CALL (q , mmap_free , q );
321+ rc = CALL (q , mmap_free , q );
310322
311323 q -> is_mmapped = 0 ;
312324
@@ -332,6 +344,7 @@ int videobuf_mmap_free(struct videobuf_queue *q)
332344 mutex_unlock (& q -> vb_lock );
333345 return ret ;
334346}
347+ EXPORT_SYMBOL_GPL (videobuf_mmap_free );
335348
336349/* Locking: Caller holds q->vb_lock */
337350int __videobuf_mmap_setup (struct videobuf_queue * q ,
@@ -351,7 +364,7 @@ int __videobuf_mmap_setup(struct videobuf_queue *q,
351364 for (i = 0 ; i < bcount ; i ++ ) {
352365 q -> bufs [i ] = videobuf_alloc (q );
353366
354- if (q -> bufs [i ] == NULL )
367+ if (NULL == q -> bufs [i ])
355368 break ;
356369
357370 q -> bufs [i ]-> i = i ;
@@ -372,11 +385,11 @@ int __videobuf_mmap_setup(struct videobuf_queue *q,
372385 if (!i )
373386 return - ENOMEM ;
374387
375- dprintk (1 , "mmap setup: %d buffers, %d bytes each\n" ,
376- i , bsize );
388+ dprintk (1 , "mmap setup: %d buffers, %d bytes each\n" , i , bsize );
377389
378390 return i ;
379391}
392+ EXPORT_SYMBOL_GPL (__videobuf_mmap_setup );
380393
381394int videobuf_mmap_setup (struct videobuf_queue * q ,
382395 unsigned int bcount , unsigned int bsize ,
@@ -388,6 +401,7 @@ int videobuf_mmap_setup(struct videobuf_queue *q,
388401 mutex_unlock (& q -> vb_lock );
389402 return ret ;
390403}
404+ EXPORT_SYMBOL_GPL (videobuf_mmap_setup );
391405
392406int videobuf_reqbufs (struct videobuf_queue * q ,
393407 struct v4l2_requestbuffers * req )
@@ -432,7 +446,7 @@ int videobuf_reqbufs(struct videobuf_queue *q,
432446 q -> ops -> buf_setup (q , & count , & size );
433447 dprintk (1 , "reqbufs: bufs=%d, size=0x%x [%u pages total]\n" ,
434448 count , size ,
435- (unsigned int )((count * PAGE_ALIGN (size ))>> PAGE_SHIFT ) );
449+ (unsigned int )((count * PAGE_ALIGN (size )) >> PAGE_SHIFT ));
436450
437451 retval = __videobuf_mmap_setup (q , count , size , req -> memory );
438452 if (retval < 0 ) {
@@ -447,6 +461,7 @@ int videobuf_reqbufs(struct videobuf_queue *q,
447461 mutex_unlock (& q -> vb_lock );
448462 return retval ;
449463}
464+ EXPORT_SYMBOL_GPL (videobuf_reqbufs );
450465
451466int videobuf_querybuf (struct videobuf_queue * q , struct v4l2_buffer * b )
452467{
@@ -473,9 +488,9 @@ int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
473488 mutex_unlock (& q -> vb_lock );
474489 return ret ;
475490}
491+ EXPORT_SYMBOL_GPL (videobuf_querybuf );
476492
477- int videobuf_qbuf (struct videobuf_queue * q ,
478- struct v4l2_buffer * b )
493+ int videobuf_qbuf (struct videobuf_queue * q , struct v4l2_buffer * b )
479494{
480495 struct videobuf_buffer * buf ;
481496 enum v4l2_field field ;
@@ -571,15 +586,15 @@ int videobuf_qbuf(struct videobuf_queue *q,
571586 retval = 0 ;
572587 wake_up_interruptible_sync (& q -> wait );
573588
574- done :
589+ done :
575590 mutex_unlock (& q -> vb_lock );
576591
577592 if (b -> memory == V4L2_MEMORY_MMAP )
578593 up_read (& current -> mm -> mmap_sem );
579594
580595 return retval ;
581596}
582-
597+ EXPORT_SYMBOL_GPL ( videobuf_qbuf );
583598
584599/* Locking: Caller holds q->vb_lock */
585600static int stream_next_buffer_check_queue (struct videobuf_queue * q , int noblock )
@@ -624,7 +639,6 @@ static int stream_next_buffer_check_queue(struct videobuf_queue *q, int noblock)
624639 return retval ;
625640}
626641
627-
628642/* Locking: Caller holds q->vb_lock */
629643static int stream_next_buffer (struct videobuf_queue * q ,
630644 struct videobuf_buffer * * vb , int nonblocking )
@@ -647,7 +661,7 @@ static int stream_next_buffer(struct videobuf_queue *q,
647661}
648662
649663int videobuf_dqbuf (struct videobuf_queue * q ,
650- struct v4l2_buffer * b , int nonblocking )
664+ struct v4l2_buffer * b , int nonblocking )
651665{
652666 struct videobuf_buffer * buf = NULL ;
653667 int retval ;
@@ -682,11 +696,11 @@ int videobuf_dqbuf(struct videobuf_queue *q,
682696 list_del (& buf -> stream );
683697 memset (b , 0 , sizeof (* b ));
684698 videobuf_status (q , b , buf , q -> type );
685-
686- done :
699+ done :
687700 mutex_unlock (& q -> vb_lock );
688701 return retval ;
689702}
703+ EXPORT_SYMBOL_GPL (videobuf_dqbuf );
690704
691705int videobuf_streamon (struct videobuf_queue * q )
692706{
@@ -709,10 +723,11 @@ int videobuf_streamon(struct videobuf_queue *q)
709723 spin_unlock_irqrestore (q -> irqlock , flags );
710724
711725 wake_up_interruptible_sync (& q -> wait );
712- done :
726+ done :
713727 mutex_unlock (& q -> vb_lock );
714728 return retval ;
715729}
730+ EXPORT_SYMBOL_GPL (videobuf_streamon );
716731
717732/* Locking: Caller holds q->vb_lock */
718733static int __videobuf_streamoff (struct videobuf_queue * q )
@@ -735,6 +750,7 @@ int videobuf_streamoff(struct videobuf_queue *q)
735750
736751 return retval ;
737752}
753+ EXPORT_SYMBOL_GPL (videobuf_streamoff );
738754
739755/* Locking: Caller holds q->vb_lock */
740756static ssize_t videobuf_read_zerocopy (struct videobuf_queue * q ,
@@ -774,7 +790,7 @@ static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
774790 retval = q -> read_buf -> size ;
775791 }
776792
777- done :
793+ done :
778794 /* cleanup */
779795 q -> ops -> buf_release (q , q -> read_buf );
780796 kfree (q -> read_buf );
@@ -862,10 +878,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
862878 q -> read_buf = NULL ;
863879 }
864880
865- done :
881+ done :
866882 mutex_unlock (& q -> vb_lock );
867883 return retval ;
868884}
885+ EXPORT_SYMBOL_GPL (videobuf_read_one );
869886
870887/* Locking: Caller holds q->vb_lock */
871888static int __videobuf_read_start (struct videobuf_queue * q )
@@ -917,7 +934,6 @@ static void __videobuf_read_stop(struct videobuf_queue *q)
917934 q -> bufs [i ] = NULL ;
918935 }
919936 q -> read_buf = NULL ;
920-
921937}
922938
923939int videobuf_read_start (struct videobuf_queue * q )
@@ -930,13 +946,15 @@ int videobuf_read_start(struct videobuf_queue *q)
930946
931947 return rc ;
932948}
949+ EXPORT_SYMBOL_GPL (videobuf_read_start );
933950
934951void videobuf_read_stop (struct videobuf_queue * q )
935952{
936953 mutex_lock (& q -> vb_lock );
937954 __videobuf_read_stop (q );
938955 mutex_unlock (& q -> vb_lock );
939956}
957+ EXPORT_SYMBOL_GPL (videobuf_read_stop );
940958
941959void videobuf_stop (struct videobuf_queue * q )
942960{
@@ -950,7 +968,7 @@ void videobuf_stop(struct videobuf_queue *q)
950968
951969 mutex_unlock (& q -> vb_lock );
952970}
953-
971+ EXPORT_SYMBOL_GPL ( videobuf_stop );
954972
955973ssize_t videobuf_read_stream (struct videobuf_queue * q ,
956974 char __user * data , size_t count , loff_t * ppos ,
@@ -1019,10 +1037,11 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
10191037 break ;
10201038 }
10211039
1022- done :
1040+ done :
10231041 mutex_unlock (& q -> vb_lock );
10241042 return retval ;
10251043}
1044+ EXPORT_SYMBOL_GPL (videobuf_read_stream );
10261045
10271046unsigned int videobuf_poll_stream (struct file * file ,
10281047 struct videobuf_queue * q ,
@@ -1062,9 +1081,9 @@ unsigned int videobuf_poll_stream(struct file *file,
10621081 mutex_unlock (& q -> vb_lock );
10631082 return rc ;
10641083}
1084+ EXPORT_SYMBOL_GPL (videobuf_poll_stream );
10651085
1066- int videobuf_mmap_mapper (struct videobuf_queue * q ,
1067- struct vm_area_struct * vma )
1086+ int videobuf_mmap_mapper (struct videobuf_queue * q , struct vm_area_struct * vma )
10681087{
10691088 int retval ;
10701089
@@ -1077,6 +1096,7 @@ int videobuf_mmap_mapper(struct videobuf_queue *q,
10771096
10781097 return retval ;
10791098}
1099+ EXPORT_SYMBOL_GPL (videobuf_mmap_mapper );
10801100
10811101#ifdef CONFIG_VIDEO_V4L1_COMPAT
10821102int videobuf_cgmbuf (struct videobuf_queue * q ,
@@ -1107,33 +1127,3 @@ int videobuf_cgmbuf(struct videobuf_queue *q,
11071127EXPORT_SYMBOL_GPL (videobuf_cgmbuf );
11081128#endif
11091129
1110- /* --------------------------------------------------------------------- */
1111-
1112- EXPORT_SYMBOL_GPL (videobuf_waiton );
1113- EXPORT_SYMBOL_GPL (videobuf_iolock );
1114-
1115- EXPORT_SYMBOL_GPL (videobuf_alloc );
1116-
1117- EXPORT_SYMBOL_GPL (videobuf_queue_core_init );
1118- EXPORT_SYMBOL_GPL (videobuf_queue_cancel );
1119- EXPORT_SYMBOL_GPL (videobuf_queue_is_busy );
1120-
1121- EXPORT_SYMBOL_GPL (videobuf_next_field );
1122- EXPORT_SYMBOL_GPL (videobuf_reqbufs );
1123- EXPORT_SYMBOL_GPL (videobuf_querybuf );
1124- EXPORT_SYMBOL_GPL (videobuf_qbuf );
1125- EXPORT_SYMBOL_GPL (videobuf_dqbuf );
1126- EXPORT_SYMBOL_GPL (videobuf_streamon );
1127- EXPORT_SYMBOL_GPL (videobuf_streamoff );
1128-
1129- EXPORT_SYMBOL_GPL (videobuf_read_start );
1130- EXPORT_SYMBOL_GPL (videobuf_read_stop );
1131- EXPORT_SYMBOL_GPL (videobuf_stop );
1132- EXPORT_SYMBOL_GPL (videobuf_read_stream );
1133- EXPORT_SYMBOL_GPL (videobuf_read_one );
1134- EXPORT_SYMBOL_GPL (videobuf_poll_stream );
1135-
1136- EXPORT_SYMBOL_GPL (__videobuf_mmap_setup );
1137- EXPORT_SYMBOL_GPL (videobuf_mmap_setup );
1138- EXPORT_SYMBOL_GPL (videobuf_mmap_free );
1139- EXPORT_SYMBOL_GPL (videobuf_mmap_mapper );
0 commit comments