diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2010-03-28 08:22:53 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-19 11:57:53 -0400 |
commit | 37111039c9521c751ce0597c129fe6d45ba72818 (patch) | |
tree | 00e6d6e75a4604a95d1062e6a2846196fd2054e8 /drivers/media/video/videobuf-dma-sg.c | |
parent | f4fce60e8b1559306fa1112287bc8765f6977de3 (diff) |
V4L/DVB: v4l videobuf: move video_copy_to_user and copy_stream to core
The video_copy_to_user and copy_stream ops are almost identical for all
videobuf memtype variants. All that is needed is to use the new vaddr
op and these functions can be moved into the core, ensuring we have just
one single implementation instead of three.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/videobuf-dma-sg.c')
-rw-r--r-- | drivers/media/video/videobuf-dma-sg.c | 49 |
1 files changed, 0 insertions, 49 deletions
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 | ||