return -EINVAL;
        }
 
-       // EXPOSURE CONTROL DISABLED FOR INITIAL CHECKIN, TUNING DOESN'T WORK
        return ov2680_set_exposure(sd, coarse_itg, analog_gain, digital_gain);
 }
 
        struct i2c_client *client = v4l2_get_subdevdata(sd);
        struct camera_mipi_info *ov2680_info = NULL;
        struct ov2680_resolution *res;
-       int ret = 0;
+       int vts, ret = 0;
 
        dev_dbg(&client->dev, "%s: %s: pad: %d, fmt: %p\n",
                __func__,
                dev_err(&client->dev,
                        "ov2680 write resolution register err: %d\n", ret);
 
+       /* If necessary increase the VTS to match exposure + MARGIN */
+       if (dev->exposure > vts - OV2680_INTEGRATION_TIME_MARGIN)
+               vts = dev->exposure + OV2680_INTEGRATION_TIME_MARGIN;
+       else
+               vts = dev->res->lines_per_frame;
+
+       ret = ov2680_write_reg(client, 2, OV2680_TIMING_VTS_H, vts);
+       if (ret)
+               dev_err(&client->dev, "ov2680 write vts err: %d\n", ret);
+
        ret = ov2680_get_intg_factor(client, ov2680_info, res);
        if (ret) {
                dev_err(&client->dev, "failed to get integration factor\n");
 
        {0x380b, 0xa0},
        {0x380c, 0x06},
        {0x380d, 0xb0},
-       {0x380e, 0x02},
-       {0x380f, 0x84},
        {0x3810, 0x00},
        {0x3811, 0x04},
        {0x3812, 0x00},
        {0x380b, 0x30},
        {0x380c, 0x06},
        {0x380d, 0xb0},
-       {0x380e, 0x02},
-       {0x380f, 0x84},
        {0x3810, 0x00},
        {0x3811, 0x04},
        {0x3812, 0x00},
        {0x380b, 0x00},
        {0x380c, 0x06},
        {0x380d, 0xb0},
-       {0x380e, 0x02},
-       {0x380f, 0x84},
        {0x3810, 0x00},
        {0x3811, 0x04},
        {0x3812, 0x00},
        {0x380b, 0xf0},
        {0x380c, 0x06},
        {0x380d, 0xb0},
-       {0x380e, 0x02},
-       {0x380f, 0x84},
        {0x3810, 0x00},
        {0x3811, 0x04},
        {0x3812, 0x00},
        {0x380b, 0x50}, // Y_OUTPUT_SIZE;
        {0x380c, 0x06},
        {0x380d, 0xac}, // HTS;
-       {0x380e, 0x02},
-       {0x380f, 0x84}, // VTS;
        {0x3810, 0x00},
        {0x3811, 0x00},
        {0x3812, 0x00},
        {0x380b, 0x58},
        {0x380c, 0x06},
        {0x380d, 0xac},
-       {0x380e, 0x02},
-       {0x380f, 0x84},
        {0x3810, 0x00},
        {0x3811, 0x00},
        {0x3812, 0x00},
        {0x380b, 0xe0},
        {0x380c, 0x06},
        {0x380d, 0xa8},
-       {0x380e, 0x05},
-       {0x380f, 0x0e},
        {0x3810, 0x00},
        {0x3811, 0x08},
        {0x3812, 0x00},
        {0x380b, 0xd0},
        {0x380c, 0x06},
        {0x380d, 0xa8},
-       {0x380e, 0x05},
-       {0x380f, 0x0e},
        {0x3810, 0x00},
        {0x3811, 0x08},
        {0x3812, 0x00},
        {0x380b, 0x48},
        {0x380c, 0x06},
        {0x380d, 0xa8},
-       {0x380e, 0x05},
-       {0x380f, 0x0e},
        {0x3810, 0x00},
        {0x3811, 0x08},
        {0x3812, 0x00},
        {0x380b, 0x94},
        {0x380c, 0x06},
        {0x380d, 0xa8},
-       {0x380e, 0x05},
-       {0x380f, 0x0e},
        {0x3810, 0x00},
        {0x3811, 0x00},
        {0x3812, 0x00},
        {0x380b, 0x3a},
        {0x380c, 0x06},
        {0x380d, 0xa8},
-       {0x380e, 0x05},
-       {0x380f, 0x0e},
        {0x3810, 0x00},
        {0x3811, 0x00},
        {0x3812, 0x00},
        {0x380b, 0xc0},//c0},
        {0x380c, 0x06},
        {0x380d, 0xa8},
-       {0x380e, 0x05},
-       {0x380f, 0x0e},
        {0x3810, 0x00},
        {0x3811, 0x00},
        {0x3812, 0x00},