diff options
author | Todor Tomov <todor.tomov@linaro.org> | 2018-03-21 04:42:36 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2018-04-04 06:12:53 -0400 |
commit | 5b81c53c4996c4382f8ea85c1706152c9e5af5c7 (patch) | |
tree | ad83f727c19662dfcec08dcf04688d293ec1abe7 | |
parent | 06fe932307d58108a11c3e603517dd2a73a57b80 (diff) |
media: ov5645: Use v4l2_find_nearest_size
Use v4l2_find_nearest_size instead of a driver specific function to find
nearest matching size.
Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/i2c/ov5645.c | 24 |
1 files 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, | |||
959 | } | 959 | } |
960 | } | 960 | } |
961 | 961 | ||
962 | static const struct ov5645_mode_info * | ||
963 | ov5645_find_nearest_mode(unsigned int width, unsigned int height) | ||
964 | { | ||
965 | int i; | ||
966 | |||
967 | for (i = ARRAY_SIZE(ov5645_mode_info_data) - 1; i >= 0; i--) { | ||
968 | if (ov5645_mode_info_data[i].width <= width && | ||
969 | ov5645_mode_info_data[i].height <= height) | ||
970 | break; | ||
971 | } | ||
972 | |||
973 | if (i < 0) | ||
974 | i = 0; | ||
975 | |||
976 | return &ov5645_mode_info_data[i]; | ||
977 | } | ||
978 | |||
979 | static int ov5645_set_format(struct v4l2_subdev *sd, | 962 | static int ov5645_set_format(struct v4l2_subdev *sd, |
980 | struct v4l2_subdev_pad_config *cfg, | 963 | struct v4l2_subdev_pad_config *cfg, |
981 | struct v4l2_subdev_format *format) | 964 | struct v4l2_subdev_format *format) |
@@ -989,8 +972,11 @@ static int ov5645_set_format(struct v4l2_subdev *sd, | |||
989 | __crop = __ov5645_get_pad_crop(ov5645, cfg, format->pad, | 972 | __crop = __ov5645_get_pad_crop(ov5645, cfg, format->pad, |
990 | format->which); | 973 | format->which); |
991 | 974 | ||
992 | new_mode = ov5645_find_nearest_mode(format->format.width, | 975 | new_mode = v4l2_find_nearest_size(ov5645_mode_info_data, |
993 | format->format.height); | 976 | ARRAY_SIZE(ov5645_mode_info_data), |
977 | width, height, | ||
978 | format->format.width, format->format.height); | ||
979 | |||
994 | __crop->width = new_mode->width; | 980 | __crop->width = new_mode->width; |
995 | __crop->height = new_mode->height; | 981 | __crop->height = new_mode->height; |
996 | 982 | ||