aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ivtv/ivtv-fileops.c
diff options
context:
space:
mode:
authorIan Armstrong <ian@iarmst.demon.co.uk>2007-11-05 12:27:09 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:03:11 -0500
commit77aded6ba51f01335840ce8e18b413067810b68e (patch)
tree2763dd287dd0f40bed5a1ba5262e0e13f58bf4e4 /drivers/media/video/ivtv/ivtv-fileops.c
parent3b5c1c8e71eb8fe2297a5884db59108e3c8b44c5 (diff)
V4L/DVB (6717): ivtv: Initial merge of video48 yuv handling into the IVTV_IOC_DMA_FRAME framework
Previously, all yuv data written to /dev/video48 had only basic support with no double buffering to avoid display tearing. With this patch, yuv frames written to video48 are now handled by the existing IVTV_IOC_DMA_FRAME framework. As such, the frames are hardware buffered to avoid tearing, and honour scaling mode & field order options. Unlike the proprietary IVTV_IOC_DMA_FRAME ioctl, all parameters are controlled by the V4L2 API. Due to mpeg & yuv output restrictions being different, their V4L2 output controls have been separated. To control the yuv output, the V4L2 calls must be done via video48. If the ivtvfb module is loaded, there will be one side effect to this merge. The yuv output window will be constrained to the visible framebuffer area. In the event that a virtual framebuffer size is being used, the limit to the output size will be the virtual dimensions, but only the portion that falls within the currently visible area of the framebuffer will be shown. Like the IVTV_IOC_DMA_FRAME ioctl, the supplied frames must be padded to 720 pixels wide. However the height must only be padded up the nearest multiple of 32. This would mean an image of 102 lines must be padded to 128. As long as the true source image size is given, the padding will not be visible in the final output. Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-fileops.c')
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 58ad0d9c680a..6fb96f19a866 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -581,6 +581,24 @@ ssize_t ivtv_v4l2_write(struct file *filp, const char __user *user_buf, size_t c
581 set_bit(IVTV_F_S_APPL_IO, &s->s_flags); 581 set_bit(IVTV_F_S_APPL_IO, &s->s_flags);
582 582
583retry: 583retry:
584 /* If possible, just DMA the entire frame - Check the data transfer size
585 since we may get here before the stream has been fully set-up */
586 if (mode == OUT_YUV && s->q_full.length == 0 && itv->dma_data_req_size) {
587 while (count >= itv->dma_data_req_size) {
588 if (!ivtv_yuv_udma_stream_frame (itv, (void *)user_buf)) {
589 bytes_written += itv->dma_data_req_size;
590 user_buf += itv->dma_data_req_size;
591 count -= itv->dma_data_req_size;
592 } else {
593 break;
594 }
595 }
596 if (count == 0) {
597 IVTV_DEBUG_HI_FILE("Wrote %d bytes to %s (%d)\n", bytes_written, s->name, s->q_full.bytesused);
598 return bytes_written;
599 }
600 }
601
584 for (;;) { 602 for (;;) {
585 /* Gather buffers */ 603 /* Gather buffers */
586 while (q.length - q.bytesused < count && (buf = ivtv_dequeue(s, &s->q_io))) 604 while (q.length - q.bytesused < count && (buf = ivtv_dequeue(s, &s->q_io)))
@@ -660,6 +678,9 @@ retry:
660 if (s->q_full.length >= itv->dma_data_req_size) { 678 if (s->q_full.length >= itv->dma_data_req_size) {
661 int got_sig; 679 int got_sig;
662 680
681 if (mode == OUT_YUV)
682 ivtv_yuv_setup_stream_frame(itv);
683
663 prepare_to_wait(&itv->dma_waitq, &wait, TASK_INTERRUPTIBLE); 684 prepare_to_wait(&itv->dma_waitq, &wait, TASK_INTERRUPTIBLE);
664 while (!(got_sig = signal_pending(current)) && 685 while (!(got_sig = signal_pending(current)) &&
665 test_bit(IVTV_F_S_DMA_PENDING, &s->s_flags)) { 686 test_bit(IVTV_F_S_DMA_PENDING, &s->s_flags)) {
@@ -946,7 +967,7 @@ static int ivtv_serialized_open(struct ivtv_stream *s, struct file *filp)
946 set_bit(IVTV_F_I_DEC_YUV, &itv->i_flags); 967 set_bit(IVTV_F_I_DEC_YUV, &itv->i_flags);
947 /* For yuv, we need to know the dma size before we start */ 968 /* For yuv, we need to know the dma size before we start */
948 itv->dma_data_req_size = 969 itv->dma_data_req_size =
949 itv->params.width * itv->params.height * 3 / 2; 970 1080 * ((itv->yuv_info.v4l2_src_h + 31) & ~31);
950 itv->yuv_info.stream_size = 0; 971 itv->yuv_info.stream_size = 0;
951 } 972 }
952 return 0; 973 return 0;