aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/videobuf-core.c
diff options
context:
space:
mode:
authorPawel Osciak <p.osciak@samsung.com>2010-03-17 03:01:04 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-17 23:50:25 -0400
commit7a02264ca9ec5409e22b9d41f32b431d08eadbce (patch)
tree4c7cd63a863c10f0fbe8d8ec7927e203e9d7577f /drivers/media/video/videobuf-core.c
parent85e092190b5f7dfe9b78556440472c5590a32b4e (diff)
V4L/DVB: v4l: videobuf: code cleanup
Make videobuf pass checkpatch; minor code cleanups. Signed-off-by: Pawel Osciak <p.osciak@samsung.com> Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/videobuf-core.c')
-rw-r--r--drivers/media/video/videobuf-core.c116
1 files changed, 53 insertions, 63 deletions
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c
index 471178e1701..63d7043502d 100644
--- a/drivers/media/video/videobuf-core.c
+++ b/drivers/media/video/videobuf-core.c
@@ -24,10 +24,15 @@
24#include <media/videobuf-core.h> 24#include <media/videobuf-core.h>
25 25
26#define MAGIC_BUFFER 0x20070728 26#define MAGIC_BUFFER 0x20070728
27#define MAGIC_CHECK(is, should) do { \ 27#define MAGIC_CHECK(is, should) \
28 if (unlikely((is) != (should))) { \ 28 do { \
29 printk(KERN_ERR "magic mismatch: %x (expected %x)\n", is, should); \ 29 if (unlikely((is) != (should))) { \
30 BUG(); } } while (0) 30 printk(KERN_ERR \
31 "magic mismatch: %x (expected %x)\n", \
32 is, should); \
33 BUG(); \
34 } \
35 } while (0)
31 36
32static int debug; 37static int debug;
33module_param(debug, int, 0644); 38module_param(debug, int, 0644);
@@ -36,9 +41,11 @@ MODULE_DESCRIPTION("helper module to manage video4linux buffers");
36MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); 41MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
37MODULE_LICENSE("GPL"); 42MODULE_LICENSE("GPL");
38 43
39#define dprintk(level, fmt, arg...) do { \ 44#define dprintk(level, fmt, arg...) \
40 if (debug >= level) \ 45 do { \
41 printk(KERN_DEBUG "vbuf: " fmt , ## arg); } while (0) 46 if (debug >= level) \
47 printk(KERN_DEBUG "vbuf: " fmt, ## arg); \
48 } while (0)
42 49
43/* --------------------------------------------------------------------- */ 50/* --------------------------------------------------------------------- */
44 51
@@ -57,14 +64,14 @@ void *videobuf_alloc(struct videobuf_queue *q)
57 } 64 }
58 65
59 vb = q->int_ops->alloc(q->msize); 66 vb = q->int_ops->alloc(q->msize);
60
61 if (NULL != vb) { 67 if (NULL != vb) {
62 init_waitqueue_head(&vb->done); 68 init_waitqueue_head(&vb->done);
63 vb->magic = MAGIC_BUFFER; 69 vb->magic = MAGIC_BUFFER;
64 } 70 }
65 71
66 return vb; 72 return vb;
67} 73}
74EXPORT_SYMBOL_GPL(videobuf_alloc);
68 75
69#define WAITON_CONDITION (vb->state != VIDEOBUF_ACTIVE &&\ 76#define WAITON_CONDITION (vb->state != VIDEOBUF_ACTIVE &&\
70 vb->state != VIDEOBUF_QUEUED) 77 vb->state != VIDEOBUF_QUEUED)
@@ -86,6 +93,7 @@ int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
86 93
87 return 0; 94 return 0;
88} 95}
96EXPORT_SYMBOL_GPL(videobuf_waiton);
89 97
90int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, 98int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb,
91 struct v4l2_framebuffer *fbuf) 99 struct v4l2_framebuffer *fbuf)
@@ -95,9 +103,10 @@ int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb,
95 103
96 return CALL(q, iolock, q, vb, fbuf); 104 return CALL(q, iolock, q, vb, fbuf);
97} 105}
106EXPORT_SYMBOL_GPL(videobuf_iolock);
98 107
99void *videobuf_queue_to_vmalloc (struct videobuf_queue *q, 108void *videobuf_queue_to_vmalloc(struct videobuf_queue *q,
100 struct videobuf_buffer *buf) 109 struct videobuf_buffer *buf)
101{ 110{
102 if (q->int_ops->vmalloc) 111 if (q->int_ops->vmalloc)
103 return q->int_ops->vmalloc(buf); 112 return q->int_ops->vmalloc(buf);
@@ -146,6 +155,7 @@ void videobuf_queue_core_init(struct videobuf_queue *q,
146 init_waitqueue_head(&q->wait); 155 init_waitqueue_head(&q->wait);
147 INIT_LIST_HEAD(&q->stream); 156 INIT_LIST_HEAD(&q->stream);
148} 157}
158EXPORT_SYMBOL_GPL(videobuf_queue_core_init);
149 159
150/* Locking: Only usage in bttv unsafe find way to remove */ 160/* Locking: Only usage in bttv unsafe find way to remove */
151int videobuf_queue_is_busy(struct videobuf_queue *q) 161int videobuf_queue_is_busy(struct videobuf_queue *q)
@@ -184,6 +194,7 @@ int videobuf_queue_is_busy(struct videobuf_queue *q)
184 } 194 }
185 return 0; 195 return 0;
186} 196}
197EXPORT_SYMBOL_GPL(videobuf_queue_is_busy);
187 198
188/* Locking: Caller holds q->vb_lock */ 199/* Locking: Caller holds q->vb_lock */
189void videobuf_queue_cancel(struct videobuf_queue *q) 200void videobuf_queue_cancel(struct videobuf_queue *q)
@@ -216,6 +227,7 @@ void videobuf_queue_cancel(struct videobuf_queue *q)
216 } 227 }
217 INIT_LIST_HEAD(&q->stream); 228 INIT_LIST_HEAD(&q->stream);
218} 229}
230EXPORT_SYMBOL_GPL(videobuf_queue_cancel);
219 231
220/* --------------------------------------------------------------------- */ 232/* --------------------------------------------------------------------- */
221 233
@@ -237,6 +249,7 @@ enum v4l2_field videobuf_next_field(struct videobuf_queue *q)
237 } 249 }
238 return field; 250 return field;
239} 251}
252EXPORT_SYMBOL_GPL(videobuf_next_field);
240 253
241/* Locking: Caller holds q->vb_lock */ 254/* Locking: Caller holds q->vb_lock */
242static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, 255static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
@@ -305,8 +318,7 @@ static int __videobuf_mmap_free(struct videobuf_queue *q)
305 318
306 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); 319 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
307 320
308 321 rc = CALL(q, mmap_free, q);
309 rc = CALL(q, mmap_free, q);
310 322
311 q->is_mmapped = 0; 323 q->is_mmapped = 0;
312 324
@@ -332,6 +344,7 @@ int videobuf_mmap_free(struct videobuf_queue *q)
332 mutex_unlock(&q->vb_lock); 344 mutex_unlock(&q->vb_lock);
333 return ret; 345 return ret;
334} 346}
347EXPORT_SYMBOL_GPL(videobuf_mmap_free);
335 348
336/* Locking: Caller holds q->vb_lock */ 349/* Locking: Caller holds q->vb_lock */
337int __videobuf_mmap_setup(struct videobuf_queue *q, 350int __videobuf_mmap_setup(struct videobuf_queue *q,
@@ -351,7 +364,7 @@ int __videobuf_mmap_setup(struct videobuf_queue *q,
351 for (i = 0; i < bcount; i++) { 364 for (i = 0; i < bcount; i++) {
352 q->bufs[i] = videobuf_alloc(q); 365 q->bufs[i] = videobuf_alloc(q);
353 366
354 if (q->bufs[i] == NULL) 367 if (NULL == q->bufs[i])
355 break; 368 break;
356 369
357 q->bufs[i]->i = i; 370 q->bufs[i]->i = i;
@@ -372,11 +385,11 @@ int __videobuf_mmap_setup(struct videobuf_queue *q,
372 if (!i) 385 if (!i)
373 return -ENOMEM; 386 return -ENOMEM;
374 387
375 dprintk(1, "mmap setup: %d buffers, %d bytes each\n", 388 dprintk(1, "mmap setup: %d buffers, %d bytes each\n", i, bsize);
376 i, bsize);
377 389
378 return i; 390 return i;
379} 391}
392EXPORT_SYMBOL_GPL(__videobuf_mmap_setup);
380 393
381int videobuf_mmap_setup(struct videobuf_queue *q, 394int videobuf_mmap_setup(struct videobuf_queue *q,
382 unsigned int bcount, unsigned int bsize, 395 unsigned int bcount, unsigned int bsize,
@@ -388,6 +401,7 @@ int videobuf_mmap_setup(struct videobuf_queue *q,
388 mutex_unlock(&q->vb_lock); 401 mutex_unlock(&q->vb_lock);
389 return ret; 402 return ret;
390} 403}
404EXPORT_SYMBOL_GPL(videobuf_mmap_setup);
391 405
392int videobuf_reqbufs(struct videobuf_queue *q, 406int videobuf_reqbufs(struct videobuf_queue *q,
393 struct v4l2_requestbuffers *req) 407 struct v4l2_requestbuffers *req)
@@ -432,7 +446,7 @@ int videobuf_reqbufs(struct videobuf_queue *q,
432 q->ops->buf_setup(q, &count, &size); 446 q->ops->buf_setup(q, &count, &size);
433 dprintk(1, "reqbufs: bufs=%d, size=0x%x [%u pages total]\n", 447 dprintk(1, "reqbufs: bufs=%d, size=0x%x [%u pages total]\n",
434 count, size, 448 count, size,
435 (unsigned int)((count*PAGE_ALIGN(size))>>PAGE_SHIFT) ); 449 (unsigned int)((count * PAGE_ALIGN(size)) >> PAGE_SHIFT));
436 450
437 retval = __videobuf_mmap_setup(q, count, size, req->memory); 451 retval = __videobuf_mmap_setup(q, count, size, req->memory);
438 if (retval < 0) { 452 if (retval < 0) {
@@ -447,6 +461,7 @@ int videobuf_reqbufs(struct videobuf_queue *q,
447 mutex_unlock(&q->vb_lock); 461 mutex_unlock(&q->vb_lock);
448 return retval; 462 return retval;
449} 463}
464EXPORT_SYMBOL_GPL(videobuf_reqbufs);
450 465
451int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b) 466int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
452{ 467{
@@ -473,9 +488,9 @@ done:
473 mutex_unlock(&q->vb_lock); 488 mutex_unlock(&q->vb_lock);
474 return ret; 489 return ret;
475} 490}
491EXPORT_SYMBOL_GPL(videobuf_querybuf);
476 492
477int videobuf_qbuf(struct videobuf_queue *q, 493int videobuf_qbuf(struct videobuf_queue *q, struct v4l2_buffer *b)
478 struct v4l2_buffer *b)
479{ 494{
480 struct videobuf_buffer *buf; 495 struct videobuf_buffer *buf;
481 enum v4l2_field field; 496 enum v4l2_field field;
@@ -571,7 +586,7 @@ int videobuf_qbuf(struct videobuf_queue *q,
571 retval = 0; 586 retval = 0;
572 wake_up_interruptible_sync(&q->wait); 587 wake_up_interruptible_sync(&q->wait);
573 588
574 done: 589done:
575 mutex_unlock(&q->vb_lock); 590 mutex_unlock(&q->vb_lock);
576 591
577 if (b->memory == V4L2_MEMORY_MMAP) 592 if (b->memory == V4L2_MEMORY_MMAP)
@@ -579,7 +594,7 @@ int videobuf_qbuf(struct videobuf_queue *q,
579 594
580 return retval; 595 return retval;
581} 596}
582 597EXPORT_SYMBOL_GPL(videobuf_qbuf);
583 598
584/* Locking: Caller holds q->vb_lock */ 599/* Locking: Caller holds q->vb_lock */
585static int stream_next_buffer_check_queue(struct videobuf_queue *q, int noblock) 600static int stream_next_buffer_check_queue(struct videobuf_queue *q, int noblock)
@@ -624,7 +639,6 @@ done:
624 return retval; 639 return retval;
625} 640}
626 641
627
628/* Locking: Caller holds q->vb_lock */ 642/* Locking: Caller holds q->vb_lock */
629static int stream_next_buffer(struct videobuf_queue *q, 643static int stream_next_buffer(struct videobuf_queue *q,
630 struct videobuf_buffer **vb, int nonblocking) 644 struct videobuf_buffer **vb, int nonblocking)
@@ -647,7 +661,7 @@ done:
647} 661}
648 662
649int videobuf_dqbuf(struct videobuf_queue *q, 663int videobuf_dqbuf(struct videobuf_queue *q,
650 struct v4l2_buffer *b, int nonblocking) 664 struct v4l2_buffer *b, int nonblocking)
651{ 665{
652 struct videobuf_buffer *buf = NULL; 666 struct videobuf_buffer *buf = NULL;
653 int retval; 667 int retval;
@@ -682,11 +696,11 @@ int videobuf_dqbuf(struct videobuf_queue *q,
682 list_del(&buf->stream); 696 list_del(&buf->stream);
683 memset(b, 0, sizeof(*b)); 697 memset(b, 0, sizeof(*b));
684 videobuf_status(q, b, buf, q->type); 698 videobuf_status(q, b, buf, q->type);
685 699done:
686 done:
687 mutex_unlock(&q->vb_lock); 700 mutex_unlock(&q->vb_lock);
688 return retval; 701 return retval;
689} 702}
703EXPORT_SYMBOL_GPL(videobuf_dqbuf);
690 704
691int videobuf_streamon(struct videobuf_queue *q) 705int videobuf_streamon(struct videobuf_queue *q)
692{ 706{
@@ -709,10 +723,11 @@ int videobuf_streamon(struct videobuf_queue *q)
709 spin_unlock_irqrestore(q->irqlock, flags); 723 spin_unlock_irqrestore(q->irqlock, flags);
710 724
711 wake_up_interruptible_sync(&q->wait); 725 wake_up_interruptible_sync(&q->wait);
712 done: 726done:
713 mutex_unlock(&q->vb_lock); 727 mutex_unlock(&q->vb_lock);
714 return retval; 728 return retval;
715} 729}
730EXPORT_SYMBOL_GPL(videobuf_streamon);
716 731
717/* Locking: Caller holds q->vb_lock */ 732/* Locking: Caller holds q->vb_lock */
718static int __videobuf_streamoff(struct videobuf_queue *q) 733static int __videobuf_streamoff(struct videobuf_queue *q)
@@ -735,6 +750,7 @@ int videobuf_streamoff(struct videobuf_queue *q)
735 750
736 return retval; 751 return retval;
737} 752}
753EXPORT_SYMBOL_GPL(videobuf_streamoff);
738 754
739/* Locking: Caller holds q->vb_lock */ 755/* Locking: Caller holds q->vb_lock */
740static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q, 756static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
@@ -774,7 +790,7 @@ static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
774 retval = q->read_buf->size; 790 retval = q->read_buf->size;
775 } 791 }
776 792
777 done: 793done:
778 /* cleanup */ 794 /* cleanup */
779 q->ops->buf_release(q, q->read_buf); 795 q->ops->buf_release(q, q->read_buf);
780 kfree(q->read_buf); 796 kfree(q->read_buf);
@@ -862,10 +878,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
862 q->read_buf = NULL; 878 q->read_buf = NULL;
863 } 879 }
864 880
865 done: 881done:
866 mutex_unlock(&q->vb_lock); 882 mutex_unlock(&q->vb_lock);
867 return retval; 883 return retval;
868} 884}
885EXPORT_SYMBOL_GPL(videobuf_read_one);
869 886
870/* Locking: Caller holds q->vb_lock */ 887/* Locking: Caller holds q->vb_lock */
871static int __videobuf_read_start(struct videobuf_queue *q) 888static int __videobuf_read_start(struct videobuf_queue *q)
@@ -917,7 +934,6 @@ static void __videobuf_read_stop(struct videobuf_queue *q)
917 q->bufs[i] = NULL; 934 q->bufs[i] = NULL;
918 } 935 }
919 q->read_buf = NULL; 936 q->read_buf = NULL;
920
921} 937}
922 938
923int videobuf_read_start(struct videobuf_queue *q) 939int videobuf_read_start(struct videobuf_queue *q)
@@ -930,6 +946,7 @@ int videobuf_read_start(struct videobuf_queue *q)
930 946
931 return rc; 947 return rc;
932} 948}
949EXPORT_SYMBOL_GPL(videobuf_read_start);
933 950
934void videobuf_read_stop(struct videobuf_queue *q) 951void videobuf_read_stop(struct videobuf_queue *q)
935{ 952{
@@ -937,6 +954,7 @@ void videobuf_read_stop(struct videobuf_queue *q)
937 __videobuf_read_stop(q); 954 __videobuf_read_stop(q);
938 mutex_unlock(&q->vb_lock); 955 mutex_unlock(&q->vb_lock);
939} 956}
957EXPORT_SYMBOL_GPL(videobuf_read_stop);
940 958
941void videobuf_stop(struct videobuf_queue *q) 959void videobuf_stop(struct videobuf_queue *q)
942{ 960{
@@ -950,7 +968,7 @@ void videobuf_stop(struct videobuf_queue *q)
950 968
951 mutex_unlock(&q->vb_lock); 969 mutex_unlock(&q->vb_lock);
952} 970}
953 971EXPORT_SYMBOL_GPL(videobuf_stop);
954 972
955ssize_t videobuf_read_stream(struct videobuf_queue *q, 973ssize_t videobuf_read_stream(struct videobuf_queue *q,
956 char __user *data, size_t count, loff_t *ppos, 974 char __user *data, size_t count, loff_t *ppos,
@@ -1019,10 +1037,11 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
1019 break; 1037 break;
1020 } 1038 }
1021 1039
1022 done: 1040done:
1023 mutex_unlock(&q->vb_lock); 1041 mutex_unlock(&q->vb_lock);
1024 return retval; 1042 return retval;
1025} 1043}
1044EXPORT_SYMBOL_GPL(videobuf_read_stream);
1026 1045
1027unsigned int videobuf_poll_stream(struct file *file, 1046unsigned int videobuf_poll_stream(struct file *file,
1028 struct videobuf_queue *q, 1047 struct videobuf_queue *q,
@@ -1062,9 +1081,9 @@ unsigned int videobuf_poll_stream(struct file *file,
1062 mutex_unlock(&q->vb_lock); 1081 mutex_unlock(&q->vb_lock);
1063 return rc; 1082 return rc;
1064} 1083}
1084EXPORT_SYMBOL_GPL(videobuf_poll_stream);
1065 1085
1066int videobuf_mmap_mapper(struct videobuf_queue *q, 1086int videobuf_mmap_mapper(struct videobuf_queue *q, struct vm_area_struct *vma)
1067 struct vm_area_struct *vma)
1068{ 1087{
1069 int retval; 1088 int retval;
1070 1089
@@ -1077,6 +1096,7 @@ int videobuf_mmap_mapper(struct videobuf_queue *q,
1077 1096
1078 return retval; 1097 return retval;
1079} 1098}
1099EXPORT_SYMBOL_GPL(videobuf_mmap_mapper);
1080 1100
1081#ifdef CONFIG_VIDEO_V4L1_COMPAT 1101#ifdef CONFIG_VIDEO_V4L1_COMPAT
1082int videobuf_cgmbuf(struct videobuf_queue *q, 1102int videobuf_cgmbuf(struct videobuf_queue *q,
@@ -1107,33 +1127,3 @@ int videobuf_cgmbuf(struct videobuf_queue *q,
1107EXPORT_SYMBOL_GPL(videobuf_cgmbuf); 1127EXPORT_SYMBOL_GPL(videobuf_cgmbuf);
1108#endif 1128#endif
1109 1129
1110/* --------------------------------------------------------------------- */
1111
1112EXPORT_SYMBOL_GPL(videobuf_waiton);
1113EXPORT_SYMBOL_GPL(videobuf_iolock);
1114
1115EXPORT_SYMBOL_GPL(videobuf_alloc);
1116
1117EXPORT_SYMBOL_GPL(videobuf_queue_core_init);
1118EXPORT_SYMBOL_GPL(videobuf_queue_cancel);
1119EXPORT_SYMBOL_GPL(videobuf_queue_is_busy);
1120
1121EXPORT_SYMBOL_GPL(videobuf_next_field);
1122EXPORT_SYMBOL_GPL(videobuf_reqbufs);
1123EXPORT_SYMBOL_GPL(videobuf_querybuf);
1124EXPORT_SYMBOL_GPL(videobuf_qbuf);
1125EXPORT_SYMBOL_GPL(videobuf_dqbuf);
1126EXPORT_SYMBOL_GPL(videobuf_streamon);
1127EXPORT_SYMBOL_GPL(videobuf_streamoff);
1128
1129EXPORT_SYMBOL_GPL(videobuf_read_start);
1130EXPORT_SYMBOL_GPL(videobuf_read_stop);
1131EXPORT_SYMBOL_GPL(videobuf_stop);
1132EXPORT_SYMBOL_GPL(videobuf_read_stream);
1133EXPORT_SYMBOL_GPL(videobuf_read_one);
1134EXPORT_SYMBOL_GPL(videobuf_poll_stream);
1135
1136EXPORT_SYMBOL_GPL(__videobuf_mmap_setup);
1137EXPORT_SYMBOL_GPL(videobuf_mmap_setup);
1138EXPORT_SYMBOL_GPL(videobuf_mmap_free);
1139EXPORT_SYMBOL_GPL(videobuf_mmap_mapper);