Commit 4ed2caf8 authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

media: atomisp-ov2680: Save/restore exposure and gain over sensor power-down

Save/restore exposure and gain over sensor power-down and don't write them
to the sensor when ov2680_set_exposure() is called while the sensor is off.

Link: https://lore.kernel.org/linux-media/20211107171549.267583-7-hdegoede@redhat.comSigned-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 8eed52e1
...@@ -359,7 +359,14 @@ static int ov2680_set_exposure(struct v4l2_subdev *sd, int exposure, ...@@ -359,7 +359,14 @@ static int ov2680_set_exposure(struct v4l2_subdev *sd, int exposure,
int ret; int ret;
mutex_lock(&dev->input_lock); mutex_lock(&dev->input_lock);
dev->exposure = exposure;
dev->gain = gain;
dev->digitgain = digitgain;
if (dev->power_on)
ret = __ov2680_set_exposure(sd, exposure, gain, digitgain); ret = __ov2680_set_exposure(sd, exposure, gain, digitgain);
mutex_unlock(&dev->input_lock); mutex_unlock(&dev->input_lock);
return ret; return ret;
...@@ -748,6 +755,10 @@ static int power_up(struct v4l2_subdev *sd) ...@@ -748,6 +755,10 @@ static int power_up(struct v4l2_subdev *sd)
if (ret) if (ret)
goto fail_init_registers; goto fail_init_registers;
ret = __ov2680_set_exposure(sd, dev->exposure, dev->gain, dev->digitgain);
if (ret)
goto fail_init_registers;
dev->power_on = true; dev->power_on = true;
return 0; return 0;
...@@ -1140,6 +1151,8 @@ static int ov2680_probe(struct i2c_client *client) ...@@ -1140,6 +1151,8 @@ static int ov2680_probe(struct i2c_client *client)
mutex_init(&dev->input_lock); mutex_init(&dev->input_lock);
dev->res = &ov2680_res_preview[0]; dev->res = &ov2680_res_preview[0];
dev->exposure = dev->res->lines_per_frame - OV2680_INTEGRATION_TIME_MARGIN;
dev->gain = 250; /* 0-2047 */
v4l2_i2c_subdev_init(&dev->sd, client, &ov2680_ops); v4l2_i2c_subdev_init(&dev->sd, client, &ov2680_ops);
pdata = gmin_camera_platform_data(&dev->sd, pdata = gmin_camera_platform_data(&dev->sd,
......
...@@ -174,6 +174,9 @@ struct ov2680_device { ...@@ -174,6 +174,9 @@ struct ov2680_device {
struct ov2680_resolution *res; struct ov2680_resolution *res;
struct camera_sensor_platform_data *platform_data; struct camera_sensor_platform_data *platform_data;
bool power_on; bool power_on;
u16 exposure;
u16 gain;
u16 digitgain;
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment