summaryrefslogtreecommitdiffstats
path: root/drivers/media/usb
diff options
context:
space:
mode:
authorFrank Schaefer <fschaefer.oss@googlemail.com>2013-02-10 16:05:13 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-04 14:42:30 -0300
commitb83741383565f675bd13861fc39cfacdd68d18c1 (patch)
tree91086b1191637ac0d8d779cbc2749daa5aba7c06 /drivers/media/usb
parent6b09a21cbc01521dcc4855484e2c0ffe8aab2a78 (diff)
[media] em28xx: add function scale_to_size()
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 197823cfd26..f745617aeec 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -815,6 +815,17 @@ static void size_to_scale(struct em28xx *dev,
*vscale = EM28XX_HVSCALE_MAX;
}
+static void scale_to_size(struct em28xx *dev,
+ unsigned int hscale, unsigned int vscale,
+ unsigned int *width, unsigned int *height)
+{
+ unsigned int maxw = norm_maxw(dev);
+ unsigned int maxh = norm_maxh(dev);
+
+ *width = (((unsigned long)maxw) << 12) / (hscale + 4096L);
+ *height = (((unsigned long)maxh) << 12) / (vscale + 4096L);
+}
+
/* ------------------------------------------------------------------
IOCTL vidioc handling
------------------------------------------------------------------*/
@@ -890,9 +901,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
}
size_to_scale(dev, width, height, &hscale, &vscale);
-
- width = (((unsigned long)maxw) << 12) / (hscale + 4096L);
- height = (((unsigned long)maxh) << 12) / (vscale + 4096L);
+ scale_to_size(dev, hscale, hscale, &width, &height);
f->fmt.pix.width = width;
f->fmt.pix.height = height;