mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 13:30:45 -05:00
media: i2c: imx219: Propagate errors from control range updates
Propagate return values from __v4l2_ctrl_modify_range() and __v4l2_ctrl_s_ctrl() in imx219_set_ctrl() and imx219_set_pad_format(). This ensures proper error handling instead of ignoring possible failures. Also return the result of imx219_set_pad_format() from imx219_init_state(). Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com> Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
committed by
Hans Verkuil
parent
4985b66fbd
commit
dff10c7044
@@ -453,10 +453,14 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
|
||||
exposure_max = format->height + ctrl->val - 4;
|
||||
exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ?
|
||||
exposure_max : IMX219_EXPOSURE_DEFAULT;
|
||||
__v4l2_ctrl_modify_range(imx219->exposure,
|
||||
imx219->exposure->minimum,
|
||||
exposure_max, imx219->exposure->step,
|
||||
exposure_def);
|
||||
ret = __v4l2_ctrl_modify_range(imx219->exposure,
|
||||
imx219->exposure->minimum,
|
||||
exposure_max,
|
||||
imx219->exposure->step,
|
||||
exposure_def);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -848,6 +852,7 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
|
||||
struct v4l2_rect *crop;
|
||||
u8 bin_h, bin_v, binning;
|
||||
u32 prev_line_len;
|
||||
int ret;
|
||||
|
||||
format = v4l2_subdev_state_get_format(state, 0);
|
||||
prev_line_len = format->width + imx219->hblank->val;
|
||||
@@ -883,19 +888,28 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
|
||||
int pixel_rate;
|
||||
|
||||
/* Update limits and set FPS to default */
|
||||
__v4l2_ctrl_modify_range(imx219->vblank, IMX219_VBLANK_MIN,
|
||||
IMX219_FLL_MAX - mode->height, 1,
|
||||
ret = __v4l2_ctrl_modify_range(imx219->vblank, IMX219_VBLANK_MIN,
|
||||
IMX219_FLL_MAX - mode->height, 1,
|
||||
mode->fll_def - mode->height);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = __v4l2_ctrl_s_ctrl(imx219->vblank,
|
||||
mode->fll_def - mode->height);
|
||||
__v4l2_ctrl_s_ctrl(imx219->vblank,
|
||||
mode->fll_def - mode->height);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Update max exposure while meeting expected vblanking */
|
||||
exposure_max = mode->fll_def - 4;
|
||||
exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ?
|
||||
exposure_max : IMX219_EXPOSURE_DEFAULT;
|
||||
__v4l2_ctrl_modify_range(imx219->exposure,
|
||||
imx219->exposure->minimum,
|
||||
exposure_max, imx219->exposure->step,
|
||||
exposure_def);
|
||||
ret = __v4l2_ctrl_modify_range(imx219->exposure,
|
||||
imx219->exposure->minimum,
|
||||
exposure_max,
|
||||
imx219->exposure->step,
|
||||
exposure_def);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* With analog binning the default minimum line length of 3448
|
||||
@@ -906,9 +920,12 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
|
||||
imx219_get_binning(state, &bin_h, &bin_v);
|
||||
llp_min = (bin_h & bin_v) == IMX219_BINNING_X2_ANALOG ?
|
||||
IMX219_BINNED_LLP_MIN : IMX219_LLP_MIN;
|
||||
__v4l2_ctrl_modify_range(imx219->hblank, llp_min - mode->width,
|
||||
IMX219_LLP_MAX - mode->width, 1,
|
||||
llp_min - mode->width);
|
||||
ret = __v4l2_ctrl_modify_range(imx219->hblank,
|
||||
llp_min - mode->width,
|
||||
IMX219_LLP_MAX - mode->width, 1,
|
||||
llp_min - mode->width);
|
||||
if (ret)
|
||||
return ret;
|
||||
/*
|
||||
* Retain PPL setting from previous mode so that the
|
||||
* line time does not change on a mode change.
|
||||
@@ -917,13 +934,17 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
|
||||
* mode width subtracted.
|
||||
*/
|
||||
hblank = prev_line_len - mode->width;
|
||||
__v4l2_ctrl_s_ctrl(imx219->hblank, hblank);
|
||||
ret = __v4l2_ctrl_s_ctrl(imx219->hblank, hblank);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Scale the pixel rate based on the mode specific factor */
|
||||
pixel_rate = imx219_get_pixel_rate(imx219) *
|
||||
imx219_get_rate_factor(state);
|
||||
__v4l2_ctrl_modify_range(imx219->pixel_rate, pixel_rate,
|
||||
pixel_rate, 1, pixel_rate);
|
||||
ret = __v4l2_ctrl_modify_range(imx219->pixel_rate, pixel_rate,
|
||||
pixel_rate, 1, pixel_rate);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -972,9 +993,7 @@ static int imx219_init_state(struct v4l2_subdev *sd,
|
||||
},
|
||||
};
|
||||
|
||||
imx219_set_pad_format(sd, state, &fmt);
|
||||
|
||||
return 0;
|
||||
return imx219_set_pad_format(sd, state, &fmt);
|
||||
}
|
||||
|
||||
static const struct v4l2_subdev_video_ops imx219_video_ops = {
|
||||
|
||||
Reference in New Issue
Block a user