mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-16 07:32:22 -05:00
media: atomisp: gc0310: Drop custom ATOMISP_IOC_S_EXPOSURE support
Exposure and gain control should use standard v4l2 controls, not a custom ioctl. The next patch in this series will re-add support as standard controls, this is split into 2 patches for easier reviewing. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
51e4d56cfe
commit
47088fb910
@@ -57,104 +57,6 @@ static int gc0310_write_reg_array(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gc0310_set_gain(struct v4l2_subdev *sd, int gain)
|
||||
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
int ret;
|
||||
u8 again, dgain;
|
||||
|
||||
if (gain < 0x20)
|
||||
gain = 0x20;
|
||||
if (gain > 0x80)
|
||||
gain = 0x80;
|
||||
|
||||
if (gain >= 0x20 && gain < 0x40) {
|
||||
again = 0x0; /* sqrt(2) */
|
||||
dgain = gain;
|
||||
} else {
|
||||
again = 0x2; /* 2 * sqrt(2) */
|
||||
dgain = gain / 2;
|
||||
}
|
||||
|
||||
dev_dbg(&client->dev, "gain=0x%x again=0x%x dgain=0x%x\n", gain, again, dgain);
|
||||
|
||||
/* set analog gain */
|
||||
ret = i2c_smbus_write_byte_data(client, GC0310_AGC_ADJ, again);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* set digital gain */
|
||||
ret = i2c_smbus_write_byte_data(client, GC0310_DGC_ADJ, dgain);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __gc0310_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
|
||||
int gain, int digitgain)
|
||||
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
int ret;
|
||||
|
||||
dev_dbg(&client->dev, "coarse_itg=%d gain=%d digitgain=%d\n", coarse_itg, gain, digitgain);
|
||||
|
||||
/* set exposure */
|
||||
ret = i2c_smbus_write_word_swapped(client, GC0310_AEC_PK_EXPO_H, coarse_itg);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = gc0310_set_gain(sd, gain);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gc0310_set_exposure(struct v4l2_subdev *sd, int exposure,
|
||||
int gain, int digitgain)
|
||||
{
|
||||
struct gc0310_device *dev = to_gc0310_sensor(sd);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&dev->input_lock);
|
||||
ret = __gc0310_set_exposure(sd, exposure, gain, digitgain);
|
||||
mutex_unlock(&dev->input_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long gc0310_s_exposure(struct v4l2_subdev *sd,
|
||||
struct atomisp_exposure *exposure)
|
||||
{
|
||||
int exp = exposure->integration_time[0];
|
||||
int gain = exposure->gain[0];
|
||||
int digitgain = exposure->gain[1];
|
||||
|
||||
/* we should not accept the invalid value below. */
|
||||
if (gain == 0) {
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
|
||||
v4l2_err(client, "%s: invalid value\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return gc0310_set_exposure(sd, exp, gain, digitgain);
|
||||
}
|
||||
|
||||
static long gc0310_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
||||
{
|
||||
switch (cmd) {
|
||||
case ATOMISP_IOC_S_EXPOSURE:
|
||||
return gc0310_s_exposure(sd, arg);
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gc0310_s_ctrl(struct v4l2_ctrl *ctrl)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -627,7 +529,6 @@ static const struct v4l2_subdev_video_ops gc0310_video_ops = {
|
||||
|
||||
static const struct v4l2_subdev_core_ops gc0310_core_ops = {
|
||||
.s_power = gc0310_s_power,
|
||||
.ioctl = gc0310_ioctl,
|
||||
};
|
||||
|
||||
static const struct v4l2_subdev_pad_ops gc0310_pad_ops = {
|
||||
|
||||
Reference in New Issue
Block a user