soc-camera: mt9m111: Fix auto-exposure control

Message ID 1361903569-30244-1-git-send-email-benoit.thebaudeau@advansee.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Benoît Thébaudeau Feb. 26, 2013, 6:32 p.m. UTC
  Commit f9bd5843658e18a7097fc7258c60fb840109eaa8 changed V4L2_CID_EXPOSURE_AUTO
from boolean to enum, and commit af8425c54beb3c32cbb503a379132b3975535289
changed the creation of this control into a menu for the mt9m111. However,
mt9m111_set_autoexposure() is still interpreting the value set for this control
as a boolean, which also conflicts with the default value of this control set to
V4L2_EXPOSURE_AUTO (0).

This patch makes mt9m111_set_autoexposure() interpret the value set for
V4L2_CID_EXPOSURE_AUTO as defined by enum v4l2_exposure_auto_type.

Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Mickaël Guivarc'h <mickael.guivarch@advansee.com>
Cc: <linux-media@vger.kernel.org>
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
---
 drivers/media/i2c/soc_camera/mt9m111.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Javier Martin March 7, 2013, 12:35 p.m. UTC | #1
Hi,

On 26 February 2013 19:32, Benoît Thébaudeau
<benoit.thebaudeau@advansee.com> wrote:
> Commit f9bd5843658e18a7097fc7258c60fb840109eaa8 changed V4L2_CID_EXPOSURE_AUTO
> from boolean to enum, and commit af8425c54beb3c32cbb503a379132b3975535289
> changed the creation of this control into a menu for the mt9m111. However,
> mt9m111_set_autoexposure() is still interpreting the value set for this control
> as a boolean, which also conflicts with the default value of this control set to
> V4L2_EXPOSURE_AUTO (0).
>
> This patch makes mt9m111_set_autoexposure() interpret the value set for
> V4L2_CID_EXPOSURE_AUTO as defined by enum v4l2_exposure_auto_type.
>
> Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> Cc: Mickaël Guivarc'h <mickael.guivarch@advansee.com>
> Cc: <linux-media@vger.kernel.org>
> Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
> ---
>  drivers/media/i2c/soc_camera/mt9m111.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c
> index bbc4ff9..0b0ebaa 100644
> --- a/drivers/media/i2c/soc_camera/mt9m111.c
> +++ b/drivers/media/i2c/soc_camera/mt9m111.c
> @@ -701,11 +701,11 @@ static int mt9m111_set_global_gain(struct mt9m111 *mt9m111, int gain)
>         return reg_write(GLOBAL_GAIN, val);
>  }
>
> -static int mt9m111_set_autoexposure(struct mt9m111 *mt9m111, int on)
> +static int mt9m111_set_autoexposure(struct mt9m111 *mt9m111, int val)
>  {
>         struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev);
>
> -       if (on)
> +       if (val == V4L2_EXPOSURE_AUTO)
>                 return reg_set(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOEXPO_EN);
>         return reg_clear(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOEXPO_EN);
>  }
> --
> 1.7.10.4

This solves a real issue.

Tested-By: Javier Martin <javier.martin@vista-silicon.com>
  
Guennadi Liakhovetski March 7, 2013, 10:53 p.m. UTC | #2
On Thu, 7 Mar 2013, javier Martin wrote:

> Hi,
> 
> On 26 February 2013 19:32, Benoît Thébaudeau
> <benoit.thebaudeau@advansee.com> wrote:
> > Commit f9bd5843658e18a7097fc7258c60fb840109eaa8 changed V4L2_CID_EXPOSURE_AUTO
> > from boolean to enum, and commit af8425c54beb3c32cbb503a379132b3975535289
> > changed the creation of this control into a menu for the mt9m111. However,
> > mt9m111_set_autoexposure() is still interpreting the value set for this control
> > as a boolean, which also conflicts with the default value of this control set to
> > V4L2_EXPOSURE_AUTO (0).
> >
> > This patch makes mt9m111_set_autoexposure() interpret the value set for
> > V4L2_CID_EXPOSURE_AUTO as defined by enum v4l2_exposure_auto_type.
> >
> > Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > Cc: Mickaël Guivarc'h <mickael.guivarch@advansee.com>
> > Cc: <linux-media@vger.kernel.org>
> > Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
> > ---
> >  drivers/media/i2c/soc_camera/mt9m111.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c
> > index bbc4ff9..0b0ebaa 100644
> > --- a/drivers/media/i2c/soc_camera/mt9m111.c
> > +++ b/drivers/media/i2c/soc_camera/mt9m111.c
> > @@ -701,11 +701,11 @@ static int mt9m111_set_global_gain(struct mt9m111 *mt9m111, int gain)
> >         return reg_write(GLOBAL_GAIN, val);
> >  }
> >
> > -static int mt9m111_set_autoexposure(struct mt9m111 *mt9m111, int on)
> > +static int mt9m111_set_autoexposure(struct mt9m111 *mt9m111, int val)
> >  {
> >         struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev);
> >
> > -       if (on)
> > +       if (val == V4L2_EXPOSURE_AUTO)
> >                 return reg_set(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOEXPO_EN);
> >         return reg_clear(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOEXPO_EN);
> >  }
> > --
> > 1.7.10.4
> 
> This solves a real issue.
> 
> Tested-By: Javier Martin <javier.martin@vista-silicon.com>

Thanks, will push to 3.9 + stable.

Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c
index bbc4ff9..0b0ebaa 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -701,11 +701,11 @@  static int mt9m111_set_global_gain(struct mt9m111 *mt9m111, int gain)
 	return reg_write(GLOBAL_GAIN, val);
 }
 
-static int mt9m111_set_autoexposure(struct mt9m111 *mt9m111, int on)
+static int mt9m111_set_autoexposure(struct mt9m111 *mt9m111, int val)
 {
 	struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev);
 
-	if (on)
+	if (val == V4L2_EXPOSURE_AUTO)
 		return reg_set(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOEXPO_EN);
 	return reg_clear(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOEXPO_EN);
 }