This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: ov5645: Use v4l2_find_nearest_size
Author:  Todor Tomov <[email protected]>
Date:    Wed Mar 21 04:42:36 2018 -0400

Use v4l2_find_nearest_size instead of a driver specific function to find
nearest matching size.

Signed-off-by: Todor Tomov <[email protected]>
Signed-off-by: Sakari Ailus <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 drivers/media/i2c/ov5645.c | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

---

diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index a31fe18c71d6..4e3142a7e5a7 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -959,23 +959,6 @@ __ov5645_get_pad_crop(struct ov5645 *ov5645, struct 
v4l2_subdev_pad_config *cfg,
        }
 }
 
-static const struct ov5645_mode_info *
-ov5645_find_nearest_mode(unsigned int width, unsigned int height)
-{
-       int i;
-
-       for (i = ARRAY_SIZE(ov5645_mode_info_data) - 1; i >= 0; i--) {
-               if (ov5645_mode_info_data[i].width <= width &&
-                   ov5645_mode_info_data[i].height <= height)
-                       break;
-       }
-
-       if (i < 0)
-               i = 0;
-
-       return &ov5645_mode_info_data[i];
-}
-
 static int ov5645_set_format(struct v4l2_subdev *sd,
                             struct v4l2_subdev_pad_config *cfg,
                             struct v4l2_subdev_format *format)
@@ -989,8 +972,11 @@ static int ov5645_set_format(struct v4l2_subdev *sd,
        __crop = __ov5645_get_pad_crop(ov5645, cfg, format->pad,
                        format->which);
 
-       new_mode = ov5645_find_nearest_mode(format->format.width,
-                                           format->format.height);
+       new_mode = v4l2_find_nearest_size(ov5645_mode_info_data,
+                              ARRAY_SIZE(ov5645_mode_info_data),
+                              width, height,
+                              format->format.width, format->format.height);
+
        __crop->width = new_mode->width;
        __crop->height = new_mode->height;
 

_______________________________________________
linuxtv-commits mailing list
[email protected]
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to