Skip to content

Commit 19479ab

Browse files
committed
media: i2c: imx283: Update exposure range on blanking changes
The exposure ranges are updated currently whenever the VBLANK control is updated. However, the total exposure limits are a factor of both the HBLANK and the VBLANK durations. Determine the hmax value any time the control is set, including if the device is not yet streaming and update the limits accordingly. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
1 parent d8be84a commit 19479ab

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

drivers/media/i2c/imx283.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ static int imx283_set_ctrl(struct v4l2_ctrl *ctrl)
857857
const struct imx283_mode *mode_list;
858858
struct v4l2_subdev_state *state;
859859
unsigned int num_modes;
860-
u64 shr, pixel_rate;
860+
u64 shr;
861861
int ret = 0;
862862

863863
state = v4l2_subdev_get_locked_active_state(&imx283->sd);
@@ -868,15 +868,24 @@ static int imx283_set_ctrl(struct v4l2_ctrl *ctrl)
868868
fmt->width, fmt->height);
869869

870870
/*
871-
* The VBLANK control may change the limits of usable exposure, so check
872-
* and adjust if necessary.
871+
* The VBLANK/HBLANK controls change the limits of usable exposure,
872+
* so check and adjust if necessary.
873873
*/
874-
if (ctrl->id == V4L2_CID_VBLANK) {
875-
/* Honour the VBLANK limits when setting exposure. */
876-
s64 current_exposure, max_exposure, min_exposure;
874+
if (ctrl->id == V4L2_CID_HBLANK) {
875+
u64 pixel_rate = imx283_pixel_rate(imx283, mode);
876+
u32 max_width = mode->crop.width + ctrl->val;
877+
878+
imx283->hmax = imx283_internal_clock(pixel_rate, max_width);
879+
}
877880

881+
if (ctrl->id == V4L2_CID_VBLANK)
878882
imx283->vmax = mode->crop.height + ctrl->val;
879883

884+
if (ctrl->id == V4L2_CID_HBLANK ||
885+
ctrl->id == V4L2_CID_VBLANK) {
886+
/* Honour the VBLANK limits when setting exposure. */
887+
s64 current_exposure, max_exposure, min_exposure;
888+
880889
imx283_exposure_limits(imx283, mode,
881890
&min_exposure, &max_exposure);
882891

@@ -904,8 +913,6 @@ static int imx283_set_ctrl(struct v4l2_ctrl *ctrl)
904913
break;
905914

906915
case V4L2_CID_HBLANK:
907-
pixel_rate = imx283_pixel_rate(imx283, mode);
908-
imx283->hmax = imx283_internal_clock(pixel_rate, mode->crop.width + ctrl->val);
909916
dev_dbg(imx283->dev, "V4L2_CID_HBLANK : %d HMAX : %u\n",
910917
ctrl->val, imx283->hmax);
911918
ret = cci_write(imx283->cci, IMX283_REG_HMAX, imx283->hmax, NULL);

0 commit comments

Comments
 (0)