diff options
-rw-r--r-- | drivers/media/video/videobuf-core.c | 47 | ||||
-rw-r--r-- | drivers/media/video/videobuf-dma-contig.c | 55 | ||||
-rw-r--r-- | drivers/media/video/videobuf-dma-sg.c | 49 | ||||
-rw-r--r-- | drivers/media/video/videobuf-vmalloc.c | 51 | ||||
-rw-r--r-- | include/media/videobuf-core.h | 10 |
5 files changed, 45 insertions, 167 deletions
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c index fabe45c4163e..f1dfcff44e1b 100644 --- a/drivers/media/video/videobuf-core.c +++ b/drivers/media/video/videobuf-core.c | |||
@@ -793,6 +793,49 @@ done: | |||
793 | return retval; | 793 | return retval; |
794 | } | 794 | } |
795 | 795 | ||
796 | static int __videobuf_copy_to_user(struct videobuf_queue *q, | ||
797 | struct videobuf_buffer *buf, | ||
798 | char __user *data, size_t count, | ||
799 | int nonblocking) | ||
800 | { | ||
801 | void *vaddr = CALL(q, vaddr, buf); | ||
802 | |||
803 | /* copy to userspace */ | ||
804 | if (count > buf->size - q->read_off) | ||
805 | count = buf->size - q->read_off; | ||
806 | |||
807 | if (copy_to_user(data, vaddr + q->read_off, count)) | ||
808 | return -EFAULT; | ||
809 | |||
810 | return count; | ||
811 | } | ||
812 | |||
813 | static int __videobuf_copy_stream(struct videobuf_queue *q, | ||
814 | struct videobuf_buffer *buf, | ||
815 | char __user *data, size_t count, size_t pos, | ||
816 | int vbihack, int nonblocking) | ||
817 | { | ||
818 | unsigned int *fc = CALL(q, vaddr, buf); | ||
819 | |||
820 | if (vbihack) { | ||
821 | /* dirty, undocumented hack -- pass the frame counter | ||
822 | * within the last four bytes of each vbi data block. | ||
823 | * We need that one to maintain backward compatibility | ||
824 | * to all vbi decoding software out there ... */ | ||
825 | fc += (buf->size >> 2) - 1; | ||
826 | *fc = buf->field_count >> 1; | ||
827 | dprintk(1, "vbihack: %d\n", *fc); | ||
828 | } | ||
829 | |||
830 | /* copy stuff using the common method */ | ||
831 | count = __videobuf_copy_to_user(q, buf, data, count, nonblocking); | ||
832 | |||
833 | if ((count == -EFAULT) && (pos == 0)) | ||
834 | return -EFAULT; | ||
835 | |||
836 | return count; | ||
837 | } | ||
838 | |||
796 | ssize_t videobuf_read_one(struct videobuf_queue *q, | 839 | ssize_t videobuf_read_one(struct videobuf_queue *q, |
797 | char __user *data, size_t count, loff_t *ppos, | 840 | char __user *data, size_t count, loff_t *ppos, |
798 | int nonblocking) | 841 | int nonblocking) |
@@ -861,7 +904,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, | |||
861 | } | 904 | } |
862 | 905 | ||
863 | /* Copy to userspace */ | 906 | /* Copy to userspace */ |
864 | retval = CALL(q, video_copy_to_user, q, data, count, nonblocking); | 907 | retval = __videobuf_copy_to_user(q, q->read_buf, data, count, nonblocking); |
865 | if (retval < 0) | 908 | if (retval < 0) |
866 | goto done; | 909 | goto done; |
867 | 910 | ||
@@ -1003,7 +1046,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, | |||
1003 | } | 1046 | } |
1004 | 1047 | ||
1005 | if (q->read_buf->state == VIDEOBUF_DONE) { | 1048 | if (q->read_buf->state == VIDEOBUF_DONE) { |
1006 | rc = CALL(q, copy_stream, q, data + retval, count, | 1049 | rc = __videobuf_copy_stream(q, q->read_buf, data + retval, count, |
1007 | retval, vbihack, nonblocking); | 1050 | retval, vbihack, nonblocking); |
1008 | if (rc < 0) { | 1051 | if (rc < 0) { |
1009 | retval = rc; | 1052 | retval = rc; |
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c index 7226ca47cbf5..0a0ff85140b7 100644 --- a/drivers/media/video/videobuf-dma-contig.c +++ b/drivers/media/video/videobuf-dma-contig.c | |||
@@ -353,67 +353,12 @@ error: | |||
353 | return -ENOMEM; | 353 | return -ENOMEM; |
354 | } | 354 | } |
355 | 355 | ||
356 | static int __videobuf_copy_to_user(struct videobuf_queue *q, | ||
357 | char __user *data, size_t count, | ||
358 | int nonblocking) | ||
359 | { | ||
360 | struct videobuf_dma_contig_memory *mem = q->read_buf->priv; | ||
361 | void *vaddr; | ||
362 | |||
363 | BUG_ON(!mem); | ||
364 | MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); | ||
365 | BUG_ON(!mem->vaddr); | ||
366 | |||
367 | /* copy to userspace */ | ||
368 | if (count > q->read_buf->size - q->read_off) | ||
369 | count = q->read_buf->size - q->read_off; | ||
370 | |||
371 | vaddr = mem->vaddr; | ||
372 | |||
373 | if (copy_to_user(data, vaddr + q->read_off, count)) | ||
374 | return -EFAULT; | ||
375 | |||
376 | return count; | ||
377 | } | ||
378 | |||
379 | static int __videobuf_copy_stream(struct videobuf_queue *q, | ||
380 | char __user *data, size_t count, size_t pos, | ||
381 | int vbihack, int nonblocking) | ||
382 | { | ||
383 | unsigned int *fc; | ||
384 | struct videobuf_dma_contig_memory *mem = q->read_buf->priv; | ||
385 | |||
386 | BUG_ON(!mem); | ||
387 | MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); | ||
388 | |||
389 | if (vbihack) { | ||
390 | /* dirty, undocumented hack -- pass the frame counter | ||
391 | * within the last four bytes of each vbi data block. | ||
392 | * We need that one to maintain backward compatibility | ||
393 | * to all vbi decoding software out there ... */ | ||
394 | fc = (unsigned int *)mem->vaddr; | ||
395 | fc += (q->read_buf->size >> 2) - 1; | ||
396 | *fc = q->read_buf->field_count >> 1; | ||
397 | dev_dbg(q->dev, "vbihack: %d\n", *fc); | ||
398 | } | ||
399 | |||
400 | /* copy stuff using the common method */ | ||
401 | count = __videobuf_copy_to_user(q, data, count, nonblocking); | ||
402 | |||
403 | if ((count == -EFAULT) && (pos == 0)) | ||
404 | return -EFAULT; | ||
405 | |||
406 | return count; | ||
407 | } | ||
408 | |||
409 | static struct videobuf_qtype_ops qops = { | 356 | static struct videobuf_qtype_ops qops = { |
410 | .magic = MAGIC_QTYPE_OPS, | 357 | .magic = MAGIC_QTYPE_OPS, |
411 | 358 | ||
412 | .alloc = __videobuf_alloc, | 359 | .alloc = __videobuf_alloc, |
413 | .iolock = __videobuf_iolock, | 360 | .iolock = __videobuf_iolock, |
414 | .mmap_mapper = __videobuf_mmap_mapper, | 361 | .mmap_mapper = __videobuf_mmap_mapper, |
415 | .video_copy_to_user = __videobuf_copy_to_user, | ||
416 | .copy_stream = __videobuf_copy_stream, | ||
417 | .vaddr = __videobuf_to_vaddr, | 362 | .vaddr = __videobuf_to_vaddr, |
418 | }; | 363 | }; |
419 | 364 | ||
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c index 43e78ee24a10..5c55bd392ea3 100644 --- a/drivers/media/video/videobuf-dma-sg.c +++ b/drivers/media/video/videobuf-dma-sg.c | |||
@@ -644,53 +644,6 @@ done: | |||
644 | return retval; | 644 | return retval; |
645 | } | 645 | } |
646 | 646 | ||
647 | static int __videobuf_copy_to_user(struct videobuf_queue *q, | ||
648 | char __user *data, size_t count, | ||
649 | int nonblocking) | ||
650 | { | ||
651 | struct videobuf_dma_sg_memory *mem = q->read_buf->priv; | ||
652 | BUG_ON(!mem); | ||
653 | MAGIC_CHECK(mem->magic, MAGIC_SG_MEM); | ||
654 | |||
655 | /* copy to userspace */ | ||
656 | if (count > q->read_buf->size - q->read_off) | ||
657 | count = q->read_buf->size - q->read_off; | ||
658 | |||
659 | if (copy_to_user(data, mem->dma.vmalloc+q->read_off, count)) | ||
660 | return -EFAULT; | ||
661 | |||
662 | return count; | ||
663 | } | ||
664 | |||
665 | static int __videobuf_copy_stream(struct videobuf_queue *q, | ||
666 | char __user *data, size_t count, size_t pos, | ||
667 | int vbihack, int nonblocking) | ||
668 | { | ||
669 | unsigned int *fc; | ||
670 | struct videobuf_dma_sg_memory *mem = q->read_buf->priv; | ||
671 | BUG_ON(!mem); | ||
672 | MAGIC_CHECK(mem->magic, MAGIC_SG_MEM); | ||
673 | |||
674 | if (vbihack) { | ||
675 | /* dirty, undocumented hack -- pass the frame counter | ||
676 | * within the last four bytes of each vbi data block. | ||
677 | * We need that one to maintain backward compatibility | ||
678 | * to all vbi decoding software out there ... */ | ||
679 | fc = (unsigned int *)mem->dma.vmalloc; | ||
680 | fc += (q->read_buf->size >> 2) - 1; | ||
681 | *fc = q->read_buf->field_count >> 1; | ||
682 | dprintk(1, "vbihack: %d\n", *fc); | ||
683 | } | ||
684 | |||
685 | /* copy stuff using the common method */ | ||
686 | count = __videobuf_copy_to_user(q, data, count, nonblocking); | ||
687 | |||
688 | if ((count == -EFAULT) && (0 == pos)) | ||
689 | return -EFAULT; | ||
690 | |||
691 | return count; | ||
692 | } | ||
693 | |||
694 | static struct videobuf_qtype_ops sg_ops = { | 647 | static struct videobuf_qtype_ops sg_ops = { |
695 | .magic = MAGIC_QTYPE_OPS, | 648 | .magic = MAGIC_QTYPE_OPS, |
696 | 649 | ||
@@ -698,8 +651,6 @@ static struct videobuf_qtype_ops sg_ops = { | |||
698 | .iolock = __videobuf_iolock, | 651 | .iolock = __videobuf_iolock, |
699 | .sync = __videobuf_sync, | 652 | .sync = __videobuf_sync, |
700 | .mmap_mapper = __videobuf_mmap_mapper, | 653 | .mmap_mapper = __videobuf_mmap_mapper, |
701 | .video_copy_to_user = __videobuf_copy_to_user, | ||
702 | .copy_stream = __videobuf_copy_stream, | ||
703 | .vaddr = __videobuf_to_vaddr, | 654 | .vaddr = __videobuf_to_vaddr, |
704 | }; | 655 | }; |
705 | 656 | ||
diff --git a/drivers/media/video/videobuf-vmalloc.c b/drivers/media/video/videobuf-vmalloc.c index 6db412abeacd..ad655839827b 100644 --- a/drivers/media/video/videobuf-vmalloc.c +++ b/drivers/media/video/videobuf-vmalloc.c | |||
@@ -315,55 +315,6 @@ error: | |||
315 | return -ENOMEM; | 315 | return -ENOMEM; |
316 | } | 316 | } |
317 | 317 | ||
318 | static int __videobuf_copy_to_user(struct videobuf_queue *q, | ||
319 | char __user *data, size_t count, | ||
320 | int nonblocking) | ||
321 | { | ||
322 | struct videobuf_vmalloc_memory *mem = q->read_buf->priv; | ||
323 | BUG_ON(!mem); | ||
324 | MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); | ||
325 | |||
326 | BUG_ON(!mem->vmalloc); | ||
327 | |||
328 | /* copy to userspace */ | ||
329 | if (count > q->read_buf->size - q->read_off) | ||
330 | count = q->read_buf->size - q->read_off; | ||
331 | |||
332 | if (copy_to_user(data, mem->vmalloc+q->read_off, count)) | ||
333 | return -EFAULT; | ||
334 | |||
335 | return count; | ||
336 | } | ||
337 | |||
338 | static int __videobuf_copy_stream(struct videobuf_queue *q, | ||
339 | char __user *data, size_t count, size_t pos, | ||
340 | int vbihack, int nonblocking) | ||
341 | { | ||
342 | unsigned int *fc; | ||
343 | struct videobuf_vmalloc_memory *mem = q->read_buf->priv; | ||
344 | BUG_ON(!mem); | ||
345 | MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); | ||
346 | |||
347 | if (vbihack) { | ||
348 | /* dirty, undocumented hack -- pass the frame counter | ||
349 | * within the last four bytes of each vbi data block. | ||
350 | * We need that one to maintain backward compatibility | ||
351 | * to all vbi decoding software out there ... */ | ||
352 | fc = (unsigned int *)mem->vmalloc; | ||
353 | fc += (q->read_buf->size >> 2) - 1; | ||
354 | *fc = q->read_buf->field_count >> 1; | ||
355 | dprintk(1, "vbihack: %d\n", *fc); | ||
356 | } | ||
357 | |||
358 | /* copy stuff using the common method */ | ||
359 | count = __videobuf_copy_to_user(q, data, count, nonblocking); | ||
360 | |||
361 | if ((count == -EFAULT) && (0 == pos)) | ||
362 | return -EFAULT; | ||
363 | |||
364 | return count; | ||
365 | } | ||
366 | |||
367 | static struct videobuf_qtype_ops qops = { | 318 | static struct videobuf_qtype_ops qops = { |
368 | .magic = MAGIC_QTYPE_OPS, | 319 | .magic = MAGIC_QTYPE_OPS, |
369 | 320 | ||
@@ -371,8 +322,6 @@ static struct videobuf_qtype_ops qops = { | |||
371 | .iolock = __videobuf_iolock, | 322 | .iolock = __videobuf_iolock, |
372 | .sync = __videobuf_sync, | 323 | .sync = __videobuf_sync, |
373 | .mmap_mapper = __videobuf_mmap_mapper, | 324 | .mmap_mapper = __videobuf_mmap_mapper, |
374 | .video_copy_to_user = __videobuf_copy_to_user, | ||
375 | .copy_stream = __videobuf_copy_stream, | ||
376 | .vaddr = videobuf_to_vmalloc, | 325 | .vaddr = videobuf_to_vmalloc, |
377 | }; | 326 | }; |
378 | 327 | ||
diff --git a/include/media/videobuf-core.h b/include/media/videobuf-core.h index f73e297e3735..821a530f4957 100644 --- a/include/media/videobuf-core.h +++ b/include/media/videobuf-core.h | |||
@@ -134,16 +134,6 @@ struct videobuf_qtype_ops { | |||
134 | struct v4l2_framebuffer *fbuf); | 134 | struct v4l2_framebuffer *fbuf); |
135 | int (*sync) (struct videobuf_queue *q, | 135 | int (*sync) (struct videobuf_queue *q, |
136 | struct videobuf_buffer *buf); | 136 | struct videobuf_buffer *buf); |
137 | int (*video_copy_to_user)(struct videobuf_queue *q, | ||
138 | char __user *data, | ||
139 | size_t count, | ||
140 | int nonblocking); | ||
141 | int (*copy_stream) (struct videobuf_queue *q, | ||
142 | char __user *data, | ||
143 | size_t count, | ||
144 | size_t pos, | ||
145 | int vbihack, | ||
146 | int nonblocking); | ||
147 | int (*mmap_mapper) (struct videobuf_queue *q, | 137 | int (*mmap_mapper) (struct videobuf_queue *q, |
148 | struct vm_area_struct *vma); | 138 | struct vm_area_struct *vma); |
149 | }; | 139 | }; |