diff options
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-video.c | 77 |
1 files changed, 68 insertions, 9 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index ff37b4c15f44..ab079d9256c4 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -194,15 +194,24 @@ static void em28xx_copy_video(struct em28xx *dev, | |||
194 | startread = p; | 194 | startread = p; |
195 | remain = len; | 195 | remain = len; |
196 | 196 | ||
197 | /* Interlaces frame */ | 197 | if (dev->progressive) |
198 | if (buf->top_field) | ||
199 | fieldstart = outp; | 198 | fieldstart = outp; |
200 | else | 199 | else { |
201 | fieldstart = outp + bytesperline; | 200 | /* Interlaces two half frames */ |
201 | if (buf->top_field) | ||
202 | fieldstart = outp; | ||
203 | else | ||
204 | fieldstart = outp + bytesperline; | ||
205 | } | ||
202 | 206 | ||
203 | linesdone = dma_q->pos / bytesperline; | 207 | linesdone = dma_q->pos / bytesperline; |
204 | currlinedone = dma_q->pos % bytesperline; | 208 | currlinedone = dma_q->pos % bytesperline; |
205 | offset = linesdone * bytesperline * 2 + currlinedone; | 209 | |
210 | if (dev->progressive) | ||
211 | offset = linesdone * bytesperline + currlinedone; | ||
212 | else | ||
213 | offset = linesdone * bytesperline * 2 + currlinedone; | ||
214 | |||
206 | startwrite = fieldstart + offset; | 215 | startwrite = fieldstart + offset; |
207 | lencopy = bytesperline - currlinedone; | 216 | lencopy = bytesperline - currlinedone; |
208 | lencopy = lencopy > remain ? remain : lencopy; | 217 | lencopy = lencopy > remain ? remain : lencopy; |
@@ -376,7 +385,7 @@ static inline int em28xx_isoc_copy(struct em28xx *dev, struct urb *urb) | |||
376 | em28xx_isocdbg("Video frame %d, length=%i, %s\n", p[2], | 385 | em28xx_isocdbg("Video frame %d, length=%i, %s\n", p[2], |
377 | len, (p[2] & 1) ? "odd" : "even"); | 386 | len, (p[2] & 1) ? "odd" : "even"); |
378 | 387 | ||
379 | if (!(p[2] & 1)) { | 388 | if (dev->progressive || !(p[2] & 1)) { |
380 | if (buf != NULL) | 389 | if (buf != NULL) |
381 | buffer_filled(dev, dma_q, buf); | 390 | buffer_filled(dev, dma_q, buf); |
382 | get_next_buf(dma_q, &buf); | 391 | get_next_buf(dma_q, &buf); |
@@ -689,7 +698,10 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | |||
689 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 698 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
690 | 699 | ||
691 | /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ | 700 | /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ |
692 | f->fmt.pix.field = dev->interlaced ? | 701 | if (dev->progressive) |
702 | f->fmt.pix.field = V4L2_FIELD_NONE; | ||
703 | else | ||
704 | f->fmt.pix.field = dev->interlaced ? | ||
693 | V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; | 705 | V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; |
694 | 706 | ||
695 | mutex_unlock(&dev->lock); | 707 | mutex_unlock(&dev->lock); |
@@ -753,7 +765,11 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
753 | f->fmt.pix.bytesperline = (dev->width * fmt->depth + 7) >> 3; | 765 | f->fmt.pix.bytesperline = (dev->width * fmt->depth + 7) >> 3; |
754 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height; | 766 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height; |
755 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 767 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
756 | f->fmt.pix.field = V4L2_FIELD_INTERLACED; | 768 | if (dev->progressive) |
769 | f->fmt.pix.field = V4L2_FIELD_NONE; | ||
770 | else | ||
771 | f->fmt.pix.field = dev->interlaced ? | ||
772 | V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; | ||
757 | 773 | ||
758 | return 0; | 774 | return 0; |
759 | } | 775 | } |
@@ -846,6 +862,41 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) | |||
846 | return 0; | 862 | return 0; |
847 | } | 863 | } |
848 | 864 | ||
865 | static int vidioc_g_parm(struct file *file, void *priv, | ||
866 | struct v4l2_streamparm *p) | ||
867 | { | ||
868 | struct em28xx_fh *fh = priv; | ||
869 | struct em28xx *dev = fh->dev; | ||
870 | int rc = 0; | ||
871 | |||
872 | if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
873 | return -EINVAL; | ||
874 | |||
875 | if (dev->board.is_webcam) | ||
876 | rc = v4l2_device_call_until_err(&dev->v4l2_dev, 0, | ||
877 | video, g_parm, p); | ||
878 | else | ||
879 | v4l2_video_std_frame_period(dev->norm, | ||
880 | &p->parm.capture.timeperframe); | ||
881 | |||
882 | return rc; | ||
883 | } | ||
884 | |||
885 | static int vidioc_s_parm(struct file *file, void *priv, | ||
886 | struct v4l2_streamparm *p) | ||
887 | { | ||
888 | struct em28xx_fh *fh = priv; | ||
889 | struct em28xx *dev = fh->dev; | ||
890 | |||
891 | if (!dev->board.is_webcam) | ||
892 | return -EINVAL; | ||
893 | |||
894 | if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
895 | return -EINVAL; | ||
896 | |||
897 | return v4l2_device_call_until_err(&dev->v4l2_dev, 0, video, s_parm, p); | ||
898 | } | ||
899 | |||
849 | static const char *iname[] = { | 900 | static const char *iname[] = { |
850 | [EM28XX_VMUX_COMPOSITE1] = "Composite1", | 901 | [EM28XX_VMUX_COMPOSITE1] = "Composite1", |
851 | [EM28XX_VMUX_COMPOSITE2] = "Composite2", | 902 | [EM28XX_VMUX_COMPOSITE2] = "Composite2", |
@@ -1624,6 +1675,7 @@ static int em28xx_v4l2_open(struct file *filp) | |||
1624 | struct em28xx *dev; | 1675 | struct em28xx *dev; |
1625 | enum v4l2_buf_type fh_type; | 1676 | enum v4l2_buf_type fh_type; |
1626 | struct em28xx_fh *fh; | 1677 | struct em28xx_fh *fh; |
1678 | enum v4l2_field field; | ||
1627 | 1679 | ||
1628 | dev = em28xx_get_device(minor, &fh_type, &radio); | 1680 | dev = em28xx_get_device(minor, &fh_type, &radio); |
1629 | 1681 | ||
@@ -1665,8 +1717,13 @@ static int em28xx_v4l2_open(struct file *filp) | |||
1665 | 1717 | ||
1666 | dev->users++; | 1718 | dev->users++; |
1667 | 1719 | ||
1720 | if (dev->progressive) | ||
1721 | field = V4L2_FIELD_NONE; | ||
1722 | else | ||
1723 | field = V4L2_FIELD_INTERLACED; | ||
1724 | |||
1668 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &em28xx_video_qops, | 1725 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &em28xx_video_qops, |
1669 | NULL, &dev->slock, fh->type, V4L2_FIELD_INTERLACED, | 1726 | NULL, &dev->slock, fh->type, field, |
1670 | sizeof(struct em28xx_buffer), fh); | 1727 | sizeof(struct em28xx_buffer), fh); |
1671 | 1728 | ||
1672 | mutex_unlock(&dev->lock); | 1729 | mutex_unlock(&dev->lock); |
@@ -1885,6 +1942,8 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
1885 | .vidioc_qbuf = vidioc_qbuf, | 1942 | .vidioc_qbuf = vidioc_qbuf, |
1886 | .vidioc_dqbuf = vidioc_dqbuf, | 1943 | .vidioc_dqbuf = vidioc_dqbuf, |
1887 | .vidioc_s_std = vidioc_s_std, | 1944 | .vidioc_s_std = vidioc_s_std, |
1945 | .vidioc_g_parm = vidioc_g_parm, | ||
1946 | .vidioc_s_parm = vidioc_s_parm, | ||
1888 | .vidioc_enum_input = vidioc_enum_input, | 1947 | .vidioc_enum_input = vidioc_enum_input, |
1889 | .vidioc_g_input = vidioc_g_input, | 1948 | .vidioc_g_input = vidioc_g_input, |
1890 | .vidioc_s_input = vidioc_s_input, | 1949 | .vidioc_s_input = vidioc_s_input, |