]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
media: ov2680: Add hblank control
authorHans de Goede <hdegoede@redhat.com>
Mon, 15 Apr 2024 13:03:17 +0000 (15:03 +0200)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 22 Apr 2024 09:41:05 +0000 (11:41 +0200)
Add hblank control so that the sensor has all the mandatory
controls for libcamera.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/i2c/ov2680.c

index 5847122dc01b97d13257736e5f5efde808a06bbf..03df910f75648021a79cd30619b4e86259e9fbe6 100644 (file)
@@ -130,6 +130,7 @@ struct ov2680_ctrls {
        struct v4l2_ctrl *link_freq;
        struct v4l2_ctrl *pixel_rate;
        struct v4l2_ctrl *vblank;
+       struct v4l2_ctrl *hblank;
 };
 
 struct ov2680_mode {
@@ -689,6 +690,12 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd,
 
        /* exposure range depends on vts which may have changed */
        ret = ov2680_exposure_update_range(sensor);
+       if (ret)
+               goto unlock;
+
+       /* adjust hblank value for new width */
+       def = OV2680_PIXELS_PER_LINE - width;
+       ret = __v4l2_ctrl_modify_range(sensor->ctrls.hblank, def, def, 1, def);
 
 unlock:
        mutex_unlock(&sensor->lock);
@@ -993,6 +1000,10 @@ static int ov2680_v4l2_register(struct ov2680_dev *sensor)
        ctrls->vblank = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_VBLANK,
                                          OV2680_MIN_VBLANK, max, 1, def);
 
+       def = OV2680_PIXELS_PER_LINE - OV2680_DEFAULT_WIDTH;
+       ctrls->hblank = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_HBLANK,
+                                         def, def, 1, def);
+
        if (hdl->error) {
                ret = hdl->error;
                goto cleanup_entity;
@@ -1001,6 +1012,7 @@ static int ov2680_v4l2_register(struct ov2680_dev *sensor)
        ctrls->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
        ctrls->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
        ctrls->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
+       ctrls->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
        sensor->sd.ctrl_handler = hdl;