Skip to content

Commit d8be84a

Browse files
committed
media: i2c: imx283: Fix binned mode blanking timings
The IMX283 supports binning modes which combine multiple measured pixels into a single output pixel. The minimum timings for this must account for the operations on all measured pixels, not the output pixel sizes. Determine and calculate all hmax and vmax values in respect of the HBLANK and VBLANK controls against the native resolution of the mode as specified in the mode crop rectangle as opposed to the output mode width and height. Signed-off-by: Kieran Bingham <[email protected]>
1 parent 5f68734 commit d8be84a

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

drivers/media/i2c/imx283.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ static int imx283_set_ctrl(struct v4l2_ctrl *ctrl)
875875
/* Honour the VBLANK limits when setting exposure. */
876876
s64 current_exposure, max_exposure, min_exposure;
877877

878-
imx283->vmax = mode->height + ctrl->val;
878+
imx283->vmax = mode->crop.height + ctrl->val;
879879

880880
imx283_exposure_limits(imx283, mode,
881881
&min_exposure, &max_exposure);
@@ -905,7 +905,7 @@ static int imx283_set_ctrl(struct v4l2_ctrl *ctrl)
905905

906906
case V4L2_CID_HBLANK:
907907
pixel_rate = imx283_pixel_rate(imx283, mode);
908-
imx283->hmax = imx283_internal_clock(pixel_rate, mode->width + ctrl->val);
908+
imx283->hmax = imx283_internal_clock(pixel_rate, mode->crop.width + ctrl->val);
909909
dev_dbg(imx283->dev, "V4L2_CID_HBLANK : %d HMAX : %u\n",
910910
ctrl->val, imx283->hmax);
911911
ret = cci_write(imx283->cci, IMX283_REG_HMAX, imx283->hmax, NULL);
@@ -917,7 +917,7 @@ static int imx283_set_ctrl(struct v4l2_ctrl *ctrl)
917917
break;
918918

919919
case V4L2_CID_VBLANK:
920-
imx283->vmax = mode->height + ctrl->val;
920+
imx283->vmax = mode->crop.height + ctrl->val;
921921
dev_dbg(imx283->dev, "V4L2_CID_VBLANK : %d VMAX : %u\n",
922922
ctrl->val, imx283->vmax);
923923
ret = cci_write(imx283->cci, IMX283_REG_VMAX, imx283->vmax, NULL);
@@ -1042,6 +1042,9 @@ static void imx283_set_framing_limits(struct imx283 *imx283,
10421042
u64 pixel_rate = imx283_pixel_rate(imx283, mode);
10431043
u64 min_hblank, max_hblank, def_hblank;
10441044

1045+
/* Use crop for timings from native sensor units */
1046+
const struct v4l2_rect *crop = &mode->crop;
1047+
10451048
/* Initialise hmax and vmax for exposure calculations */
10461049
imx283->hmax = imx283_internal_clock(pixel_rate, mode->default_hmax);
10471050
imx283->vmax = mode->default_vmax;
@@ -1050,18 +1053,18 @@ static void imx283_set_framing_limits(struct imx283 *imx283,
10501053
* Horizontal Blanking
10511054
* Convert the HMAX_MAX (72MHz) to Pixel rate values for HBLANK_MAX
10521055
*/
1053-
min_hblank = mode->min_hmax - mode->width;
1054-
max_hblank = imx283_iclk_to_pix(pixel_rate, IMX283_HMAX_MAX) - mode->width;
1055-
def_hblank = mode->default_hmax - mode->width;
1056+
min_hblank = mode->min_hmax - crop->width;
1057+
max_hblank = imx283_iclk_to_pix(pixel_rate, IMX283_HMAX_MAX) - crop->width;
1058+
def_hblank = mode->default_hmax - crop->width;
10561059
__v4l2_ctrl_modify_range(imx283->hblank, min_hblank, max_hblank, 1,
10571060
def_hblank);
10581061
__v4l2_ctrl_s_ctrl(imx283->hblank, def_hblank);
10591062

10601063
/* Vertical Blanking */
1061-
__v4l2_ctrl_modify_range(imx283->vblank, mode->min_vmax - mode->height,
1062-
IMX283_VMAX_MAX - mode->height, 1,
1064+
__v4l2_ctrl_modify_range(imx283->vblank, mode->min_vmax - crop->height,
1065+
IMX283_VMAX_MAX - crop->height, 1,
10631066
mode->default_vmax - mode->height);
1064-
__v4l2_ctrl_s_ctrl(imx283->vblank, mode->default_vmax - mode->height);
1067+
__v4l2_ctrl_s_ctrl(imx283->vblank, mode->default_vmax - crop->height);
10651068
}
10661069

10671070
static int imx283_set_pad_format(struct v4l2_subdev *sd,
@@ -1511,13 +1514,13 @@ static int imx283_init_controls(struct imx283 *imx283)
15111514
/* Initialise vblank/hblank/exposure based on the current mode. */
15121515
imx283->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx283_ctrl_ops,
15131516
V4L2_CID_VBLANK,
1514-
mode->min_vmax - mode->height,
1517+
mode->min_vmax - mode->crop.height,
15151518
IMX283_VMAX_MAX, 1,
1516-
mode->default_vmax - mode->height);
1519+
mode->default_vmax - mode->crop.height);
15171520

1518-
min_hblank = mode->min_hmax - mode->width;
1519-
max_hblank = imx283_iclk_to_pix(pixel_rate, IMX283_HMAX_MAX) - mode->width;
1520-
def_hblank = mode->default_hmax - mode->width;
1521+
min_hblank = mode->min_hmax - mode->crop.width;
1522+
max_hblank = imx283_iclk_to_pix(pixel_rate, IMX283_HMAX_MAX) - mode->crop.width;
1523+
def_hblank = mode->default_hmax - mode->crop.width;
15211524
imx283->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx283_ctrl_ops,
15221525
V4L2_CID_HBLANK, min_hblank, max_hblank,
15231526
1, def_hblank);

0 commit comments

Comments
 (0)