diff mbox series

[4/5] media: ov2680: Add hblank control

Message ID 20240216223237.326523-5-hdegoede@redhat.com
State New
Headers show
Series media: ov2680: Add all controls required by libcamera | expand

Commit Message

Hans de Goede Feb. 16, 2024, 10:32 p.m. UTC
Add hblank control so that the sensor has all the mandatory
controls for libcamera.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/media/i2c/ov2680.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Kieran Bingham Feb. 17, 2024, 3:53 p.m. UTC | #1
Quoting Hans de Goede (2024-02-16 22:32:36)
> 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>
> ---
>  drivers/media/i2c/ov2680.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
> index 4c9db83d876e..fef9e11ee141 100644
> --- a/drivers/media/i2c/ov2680.c
> +++ b/drivers/media/i2c/ov2680.c
> @@ -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 {
> @@ -684,6 +685,10 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd,
>         /* exposure range depends on vts which may have changed */
>         ov2680_exposure_update_range(sensor);
>  
> +       /* adjust hblank value for new width */
> +       def = OV2680_PIXELS_PER_LINE - width;

I presume HTS 'could' be modified ... but I think it's reasonable to
keep it fixed.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> +       __v4l2_ctrl_modify_range(sensor->ctrls.hblank, def, def, 1, def);
> +
>  unlock:
>         mutex_unlock(&sensor->lock);
>  
> @@ -984,6 +989,12 @@ 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 (ctrls->hblank)
> +               ctrls->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
> +
>         if (hdl->error) {
>                 ret = hdl->error;
>                 goto cleanup_entity;
> -- 
> 2.43.0
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
index 4c9db83d876e..fef9e11ee141 100644
--- a/drivers/media/i2c/ov2680.c
+++ b/drivers/media/i2c/ov2680.c
@@ -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 {
@@ -684,6 +685,10 @@  static int ov2680_set_fmt(struct v4l2_subdev *sd,
 	/* exposure range depends on vts which may have changed */
 	ov2680_exposure_update_range(sensor);
 
+	/* adjust hblank value for new width */
+	def = OV2680_PIXELS_PER_LINE - width;
+	__v4l2_ctrl_modify_range(sensor->ctrls.hblank, def, def, 1, def);
+
 unlock:
 	mutex_unlock(&sensor->lock);
 
@@ -984,6 +989,12 @@  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 (ctrls->hblank)
+		ctrls->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
+
 	if (hdl->error) {
 		ret = hdl->error;
 		goto cleanup_entity;