aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-video.c
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2009-05-30 20:45:46 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-23 02:21:19 -0400
commitccb83408b258f7e9f9fe763f9a7d06ebcc21134f (patch)
tree49144494f537303767e9f0ca32c4fb50730413c5 /drivers/media/video/em28xx/em28xx-video.c
parent9bd0e8d7d1bf0dc586bad905c7878b611da3acdc (diff)
V4L/DVB (11912): em28xx: Use v4l bounding/alignment function
The v4l function has a better algorithm for aligning image size. It appears that the em2800 can only scale by 50% or 100%, i.e. the only heights supported might be 240 and 480. In that case the old code would set any height other than 240 to 480. Request 240 get 240, but request 239 and then you get 480. Change it to round to the nearest supported value. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 882796e84dbc..8fe1beecfffa 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -687,8 +687,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
687{ 687{
688 struct em28xx_fh *fh = priv; 688 struct em28xx_fh *fh = priv;
689 struct em28xx *dev = fh->dev; 689 struct em28xx *dev = fh->dev;
690 int width = f->fmt.pix.width; 690 unsigned int width = f->fmt.pix.width;
691 int height = f->fmt.pix.height; 691 unsigned int height = f->fmt.pix.height;
692 unsigned int maxw = norm_maxw(dev); 692 unsigned int maxw = norm_maxw(dev);
693 unsigned int maxh = norm_maxh(dev); 693 unsigned int maxh = norm_maxh(dev);
694 unsigned int hscale, vscale; 694 unsigned int hscale, vscale;
@@ -701,34 +701,20 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
701 return -EINVAL; 701 return -EINVAL;
702 } 702 }
703 703
704 /* width must even because of the YUYV format
705 height must be even because of interlacing */
706 height &= 0xfffe;
707 width &= 0xfffe;
708
709 if (unlikely(height < 32))
710 height = 32;
711 if (unlikely(height > maxh))
712 height = maxh;
713 if (unlikely(width < 48))
714 width = 48;
715 if (unlikely(width > maxw))
716 width = maxw;
717
718 if (dev->board.is_em2800) { 704 if (dev->board.is_em2800) {
719 /* the em2800 can only scale down to 50% */ 705 /* the em2800 can only scale down to 50% */
720 if (height % (maxh / 2)) 706 height = height > (3 * maxh / 4) ? maxh : maxh / 2;
721 height = maxh; 707 width = width > (3 * maxw / 4) ? maxw : maxw / 2;
722 if (width % (maxw / 2)) 708 /* According to empiatech support the MaxPacketSize is too small
723 width = maxw; 709 * to support framesizes larger than 640x480 @ 30 fps or 640x576
724 /* according to empiatech support */ 710 * @ 25 fps. As this would cut of a part of the image we prefer
725 /* the MaxPacketSize is to small to support */ 711 * 360x576 or 360x480 for now */
726 /* framesizes larger than 640x480 @ 30 fps */
727 /* or 640x576 @ 25 fps. As this would cut */
728 /* of a part of the image we prefer */
729 /* 360x576 or 360x480 for now */
730 if (width == maxw && height == maxh) 712 if (width == maxw && height == maxh)
731 width /= 2; 713 width /= 2;
714 } else {
715 /* width must even because of the YUYV format
716 height must be even because of interlacing */
717 v4l_bound_align_image(&width, 48, maxw, 1, &height, 32, maxh, 1, 0);
732 } 718 }
733 719
734 get_scale(dev, width, height, &hscale, &vscale); 720 get_scale(dev, width, height, &hscale, &vscale);