media: i2c: cap exposure at height + vblank in ov8865
Exposure limits depend on the total height; when vblank is altered (and thus the total height is altered), change the exposure limits to reflect the new cap. Signed-off-by: Daniel Scally <djrscally@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
295786e535
commit
ca28690ebe
1 changed files with 26 additions and 2 deletions
|
@ -143,6 +143,7 @@
|
||||||
#define OV8865_EXPOSURE_CTRL_L_REG 0x3502
|
#define OV8865_EXPOSURE_CTRL_L_REG 0x3502
|
||||||
#define OV8865_EXPOSURE_CTRL_L(v) ((v) & GENMASK(7, 0))
|
#define OV8865_EXPOSURE_CTRL_L(v) ((v) & GENMASK(7, 0))
|
||||||
#define OV8865_EXPOSURE_GAIN_MANUAL_REG 0x3503
|
#define OV8865_EXPOSURE_GAIN_MANUAL_REG 0x3503
|
||||||
|
#define OV8865_INTEGRATION_TIME_MARGIN 8
|
||||||
|
|
||||||
#define OV8865_GAIN_CTRL_H_REG 0x3508
|
#define OV8865_GAIN_CTRL_H_REG 0x3508
|
||||||
#define OV8865_GAIN_CTRL_H(v) (((v) & GENMASK(12, 8)) >> 8)
|
#define OV8865_GAIN_CTRL_H(v) (((v) & GENMASK(12, 8)) >> 8)
|
||||||
|
@ -677,6 +678,7 @@ struct ov8865_ctrls {
|
||||||
struct v4l2_ctrl *pixel_rate;
|
struct v4l2_ctrl *pixel_rate;
|
||||||
struct v4l2_ctrl *hblank;
|
struct v4l2_ctrl *hblank;
|
||||||
struct v4l2_ctrl *vblank;
|
struct v4l2_ctrl *vblank;
|
||||||
|
struct v4l2_ctrl *exposure;
|
||||||
|
|
||||||
struct v4l2_ctrl_handler handler;
|
struct v4l2_ctrl_handler handler;
|
||||||
};
|
};
|
||||||
|
@ -2454,6 +2456,20 @@ static int ov8865_s_ctrl(struct v4l2_ctrl *ctrl)
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* If VBLANK is altered we need to update exposure to compensate */
|
||||||
|
if (ctrl->id == V4L2_CID_VBLANK) {
|
||||||
|
int exposure_max;
|
||||||
|
|
||||||
|
exposure_max = sensor->state.mode->output_size_y + ctrl->val -
|
||||||
|
OV8865_INTEGRATION_TIME_MARGIN;
|
||||||
|
__v4l2_ctrl_modify_range(sensor->ctrls.exposure,
|
||||||
|
sensor->ctrls.exposure->minimum,
|
||||||
|
exposure_max,
|
||||||
|
sensor->ctrls.exposure->step,
|
||||||
|
min(sensor->ctrls.exposure->val,
|
||||||
|
exposure_max));
|
||||||
|
}
|
||||||
|
|
||||||
/* Wait for the sensor to be on before setting controls. */
|
/* Wait for the sensor to be on before setting controls. */
|
||||||
if (pm_runtime_suspended(sensor->dev))
|
if (pm_runtime_suspended(sensor->dev))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2510,8 +2526,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)
|
||||||
|
|
||||||
/* Exposure */
|
/* Exposure */
|
||||||
|
|
||||||
v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 16, 1048575, 16,
|
ctrls->exposure = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 16,
|
||||||
512);
|
1048575, 16, 512);
|
||||||
|
|
||||||
/* Gain */
|
/* Gain */
|
||||||
|
|
||||||
|
@ -2700,6 +2716,7 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev,
|
||||||
u32 mbus_code = 0;
|
u32 mbus_code = 0;
|
||||||
unsigned int hblank;
|
unsigned int hblank;
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
|
int exposure_max;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
mutex_lock(&sensor->mutex);
|
mutex_lock(&sensor->mutex);
|
||||||
|
@ -2747,6 +2764,13 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev,
|
||||||
__v4l2_ctrl_modify_range(sensor->ctrls.hblank, hblank, hblank, 1,
|
__v4l2_ctrl_modify_range(sensor->ctrls.hblank, hblank, hblank, 1,
|
||||||
hblank);
|
hblank);
|
||||||
|
|
||||||
|
exposure_max = mode->vts - OV8865_INTEGRATION_TIME_MARGIN;
|
||||||
|
__v4l2_ctrl_modify_range(sensor->ctrls.exposure,
|
||||||
|
sensor->ctrls.exposure->minimum, exposure_max,
|
||||||
|
sensor->ctrls.exposure->step,
|
||||||
|
min(sensor->ctrls.exposure->val,
|
||||||
|
exposure_max));
|
||||||
|
|
||||||
complete:
|
complete:
|
||||||
mutex_unlock(&sensor->mutex);
|
mutex_unlock(&sensor->mutex);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue