diff mbox series

[v5,14/17] media: i2c: Switch exposure control unit to lines

Message ID 20211123000017.43187-15-djrscally@gmail.com (mailing list archive)
State New, archived
Headers show
Series Extensions to ov8865 driver | expand

Commit Message

Daniel Scally Nov. 23, 2021, midnight UTC
The ov8865 driver currently has the unit of the V4L2_CID_EXPOSURE control
as 1/16th of a line. This is what the sensor expects, but isn't very
intuitive. Switch the control to be in units of a line and simply do the
16x multiplication before passing the value to the sensor.

The datasheet for this sensor gives minimum exposure as 2 lines, so take
the opportunity to correct the lower bounds of the control.

Signed-off-by: Daniel Scally <djrscally@gmail.com>
---
Changes in v5: 

	- None

 drivers/media/i2c/ov8865.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Jean-Michel Hautbois Nov. 23, 2021, 6:24 a.m. UTC | #1
Hi Daniel,

Thanks for the patch !

On 23/11/2021 01:00, Daniel Scally wrote:
> The ov8865 driver currently has the unit of the V4L2_CID_EXPOSURE control
> as 1/16th of a line. This is what the sensor expects, but isn't very
> intuitive. Switch the control to be in units of a line and simply do the
> 16x multiplication before passing the value to the sensor.
> 
> The datasheet for this sensor gives minimum exposure as 2 lines, so take
> the opportunity to correct the lower bounds of the control.
> 
> Signed-off-by: Daniel Scally <djrscally@gmail.com>
Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>

> ---
> Changes in v5:
> 
> 	- None
> 
>   drivers/media/i2c/ov8865.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c
> index 45b569f1e7c0..1cc9f78bb97a 100644
> --- a/drivers/media/i2c/ov8865.c
> +++ b/drivers/media/i2c/ov8865.c
> @@ -2126,6 +2126,9 @@ static int ov8865_exposure_configure(struct ov8865_sensor *sensor, u32 exposure)
>   {
>   	int ret;
>   
> +	/* The sensor stores exposure in units of 1/16th of a line */
> +	exposure *= 16;
> +
>   	ret = ov8865_write(sensor, OV8865_EXPOSURE_CTRL_HH_REG,
>   			   OV8865_EXPOSURE_CTRL_HH(exposure));
>   	if (ret)
> @@ -2527,8 +2530,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)
>   
>   	/* Exposure */
>   
> -	ctrls->exposure = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 16,
> -					    1048575, 16, 512);
> +	ctrls->exposure = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 2,
> +					    65535, 1, 32);
>   
>   	/* Gain */
>   
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c
index 45b569f1e7c0..1cc9f78bb97a 100644
--- a/drivers/media/i2c/ov8865.c
+++ b/drivers/media/i2c/ov8865.c
@@ -2126,6 +2126,9 @@  static int ov8865_exposure_configure(struct ov8865_sensor *sensor, u32 exposure)
 {
 	int ret;
 
+	/* The sensor stores exposure in units of 1/16th of a line */
+	exposure *= 16;
+
 	ret = ov8865_write(sensor, OV8865_EXPOSURE_CTRL_HH_REG,
 			   OV8865_EXPOSURE_CTRL_HH(exposure));
 	if (ret)
@@ -2527,8 +2530,8 @@  static int ov8865_ctrls_init(struct ov8865_sensor *sensor)
 
 	/* Exposure */
 
-	ctrls->exposure = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 16,
-					    1048575, 16, 512);
+	ctrls->exposure = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 2,
+					    65535, 1, 32);
 
 	/* Gain */