[media] em28xx: add function scale_to_size()
authorFrank Schaefer <fschaefer.oss@googlemail.com>
Sun, 10 Feb 2013 19:05:13 +0000 (16:05 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 4 Mar 2013 17:42:30 +0000 (14:42 -0300)
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/usb/em28xx/em28xx-video.c

index 197823cfd2631b6aac068d7d7397a2d8e281cc1f..f745617aeece8867595309ef323a09a016b3d9dc 100644 (file)
@@ -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;