V4L/DVB (11910): mt9: Use v4l bounding/alignment function
authorTrent Piepho <xyzzy@speakeasy.org>
Sun, 31 May 2009 00:45:46 +0000 (21:45 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 23 Jun 2009 06:21:19 +0000 (03:21 -0300)
The v4l function has a better algorithm for aligning image size.

Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/mt9m001.c
drivers/media/video/mt9t031.c
drivers/media/video/mt9v022.c

index 459c04cbf69dd0fb9b23efeb869cda79d7135e15..4d794b42d6cdeb1c3f4ce46904a86e7f160dbe2f 100644 (file)
@@ -280,15 +280,9 @@ static int mt9m001_try_fmt(struct soc_camera_device *icd,
 {
        struct v4l2_pix_format *pix = &f->fmt.pix;
 
-       if (pix->height < 32 + icd->y_skip_top)
-               pix->height = 32 + icd->y_skip_top;
-       if (pix->height > 1024 + icd->y_skip_top)
-               pix->height = 1024 + icd->y_skip_top;
-       if (pix->width < 48)
-               pix->width = 48;
-       if (pix->width > 1280)
-               pix->width = 1280;
-       pix->width &= ~0x01; /* has to be even, unsure why was ~3 */
+       v4l_bound_align_image(&pix->width, 48, 1280, 1,
+                             &pix->height, 32 + icd->y_skip_top,
+                             1024 + icd->y_skip_top, 0, 0);
 
        return 0;
 }
index f72aeb7c4deb974afa6241566fd8b922858c9090..4207fb342670d47284e8d5f78db28f83744572ab 100644 (file)
@@ -385,17 +385,9 @@ static int mt9t031_try_fmt(struct soc_camera_device *icd,
 {
        struct v4l2_pix_format *pix = &f->fmt.pix;
 
-       if (pix->height < MT9T031_MIN_HEIGHT)
-               pix->height = MT9T031_MIN_HEIGHT;
-       if (pix->height > MT9T031_MAX_HEIGHT)
-               pix->height = MT9T031_MAX_HEIGHT;
-       if (pix->width < MT9T031_MIN_WIDTH)
-               pix->width = MT9T031_MIN_WIDTH;
-       if (pix->width > MT9T031_MAX_WIDTH)
-               pix->width = MT9T031_MAX_WIDTH;
-
-       pix->width &= ~0x01; /* has to be even */
-       pix->height &= ~0x01; /* has to be even */
+       v4l_bound_align_image(
+               &pix->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1,
+               &pix->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0);
 
        return 0;
 }
index be20d312b1dc5784f8c85a63a367c2e219d467c0..dbdcc86ae50dbb86d0d2dbf2df30fc5229271903 100644 (file)
@@ -364,15 +364,9 @@ static int mt9v022_try_fmt(struct soc_camera_device *icd,
 {
        struct v4l2_pix_format *pix = &f->fmt.pix;
 
-       if (pix->height < 32 + icd->y_skip_top)
-               pix->height = 32 + icd->y_skip_top;
-       if (pix->height > 480 + icd->y_skip_top)
-               pix->height = 480 + icd->y_skip_top;
-       if (pix->width < 48)
-               pix->width = 48;
-       if (pix->width > 752)
-               pix->width = 752;
-       pix->width &= ~0x03; /* ? */
+       v4l_bound_align_image(&pix->width, 48, 752, 2 /* ? */,
+                             &pix->height, 32 + icd->y_skip_top,
+                             480 + icd->y_skip_top, 0, 0);
 
        return 0;
 }