media: v4l: Bring back array_size parameter to v4l2_find_nearest_size

An older version of the driver patches were merged accidentally which
resulted in missing the array_size parameter that tells the length of the
array that contains the different supported sizes.

Bring it back to v4l2_find_nearest size and make the corresponding change
for the drivers using it as well.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
Sakari Ailus 2018-03-21 16:29:27 -04:00 committed by Mauro Carvalho Chehab
parent dd5747fb92
commit d2dc57b10a
4 changed files with 12 additions and 6 deletions

View File

@ -1375,7 +1375,9 @@ ov13858_set_pad_format(struct v4l2_subdev *sd,
if (fmt->format.code != MEDIA_BUS_FMT_SGRBG10_1X10) if (fmt->format.code != MEDIA_BUS_FMT_SGRBG10_1X10)
fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10; fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
mode = v4l2_find_nearest_size(supported_modes, width, height, mode = v4l2_find_nearest_size(supported_modes,
ARRAY_SIZE(supported_modes),
width, height,
fmt->format.width, fmt->format.height); fmt->format.width, fmt->format.height);
ov13858_update_pad_format(mode, fmt); ov13858_update_pad_format(mode, fmt);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {

View File

@ -2230,7 +2230,9 @@ static int ov5670_set_pad_format(struct v4l2_subdev *sd,
fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10; fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
mode = v4l2_find_nearest_size(supported_modes, width, height, mode = v4l2_find_nearest_size(supported_modes,
ARRAY_SIZE(supported_modes),
width, height,
fmt->format.width, fmt->format.height); fmt->format.width, fmt->format.height);
ov5670_update_pad_format(mode, fmt); ov5670_update_pad_format(mode, fmt);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {

View File

@ -561,8 +561,9 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv,
mp->field = vivid_field_cap(dev, mp->field); mp->field = vivid_field_cap(dev, mp->field);
if (vivid_is_webcam(dev)) { if (vivid_is_webcam(dev)) {
const struct v4l2_frmsize_discrete *sz = const struct v4l2_frmsize_discrete *sz =
v4l2_find_nearest_size(webcam_sizes, width, height, v4l2_find_nearest_size(webcam_sizes,
mp->width, mp->height); VIVID_WEBCAM_SIZES, width,
height, mp->width, mp->height);
w = sz->width; w = sz->width;
h = sz->height; h = sz->height;

View File

@ -320,6 +320,7 @@ void v4l_bound_align_image(unsigned int *width, unsigned int wmin,
* set of resolutions contained in an array of a driver specific struct. * set of resolutions contained in an array of a driver specific struct.
* *
* @array: a driver specific array of image sizes * @array: a driver specific array of image sizes
* @array_size: the length of the driver specific array of image sizes
* @width_field: the name of the width field in the driver specific struct * @width_field: the name of the width field in the driver specific struct
* @height_field: the name of the height field in the driver specific struct * @height_field: the name of the height field in the driver specific struct
* @width: desired width. * @width: desired width.
@ -332,13 +333,13 @@ void v4l_bound_align_image(unsigned int *width, unsigned int wmin,
* *
* Returns the best match or NULL if the length of the array is zero. * Returns the best match or NULL if the length of the array is zero.
*/ */
#define v4l2_find_nearest_size(array, width_field, height_field, \ #define v4l2_find_nearest_size(array, array_size, width_field, height_field, \
width, height) \ width, height) \
({ \ ({ \
BUILD_BUG_ON(sizeof((array)->width_field) != sizeof(u32) || \ BUILD_BUG_ON(sizeof((array)->width_field) != sizeof(u32) || \
sizeof((array)->height_field) != sizeof(u32)); \ sizeof((array)->height_field) != sizeof(u32)); \
(typeof(&(*(array))))__v4l2_find_nearest_size( \ (typeof(&(*(array))))__v4l2_find_nearest_size( \
(array), ARRAY_SIZE(array), sizeof(*(array)), \ (array), array_size, sizeof(*(array)), \
offsetof(typeof(*(array)), width_field), \ offsetof(typeof(*(array)), width_field), \
offsetof(typeof(*(array)), height_field), \ offsetof(typeof(*(array)), height_field), \
width, height); \ width, height); \