[libcamera-devel] ipa: raspberrypi: Limit minimum exposure time for the IMX296
diff mbox series

Message ID 20220926093639.29946-1-naush@raspberrypi.com
State Accepted
Headers show
Series
  • [libcamera-devel] ipa: raspberrypi: Limit minimum exposure time for the IMX296
Related show

Commit Message

Naushir Patuck Sept. 26, 2022, 9:36 a.m. UTC
Limit the minimum allowable exposure time to a single line in the IMX296 camera
helper. This equates to approximately 30us.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 src/ipa/raspberrypi/cam_helper_imx296.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Jacopo Mondi Sept. 28, 2022, 7:09 a.m. UTC | #1
Hi Naush

On Mon, Sep 26, 2022 at 10:36:39AM +0100, Naushir Patuck via libcamera-devel wrote:
> Limit the minimum allowable exposure time to a single line in the IMX296 camera
> helper. This equates to approximately 30us.
>
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> ---
>  src/ipa/raspberrypi/cam_helper_imx296.cpp | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/ipa/raspberrypi/cam_helper_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp
> index 09f828ea6249..66d21e36ecd0 100644
> --- a/src/ipa/raspberrypi/cam_helper_imx296.cpp
> +++ b/src/ipa/raspberrypi/cam_helper_imx296.cpp
> @@ -26,6 +26,7 @@ public:
>  	void getDelays(int &exposureDelay, int &gainDelay, int &vblankDelay) const override;
>
>  private:
> +	static constexpr uint32_t minExposureLines = 1;
>  	static constexpr uint32_t maxGainCode = 239;
>  	static constexpr Duration timePerLine = 550.0 / 37.125e6 * 1.0s;
>
> @@ -54,12 +55,12 @@ double CamHelperImx296::gain(uint32_t gainCode) const
>
>  uint32_t CamHelperImx296::exposureLines(Duration exposure) const
>  {
> -	return (exposure - 14.26us) / timePerLine;
> +	return std::max<uint32_t>(minExposureLines, (exposure - 14.26us) / timePerLine);
>  }
>
>  Duration CamHelperImx296::exposure(uint32_t exposureLines) const
>  {
> -	return exposureLines * timePerLine + 14.26us;
> +	return std::max<uint32_t>(minExposureLines, exposureLines) * timePerLine + 14.26us;
>  }
>
>  void CamHelperImx296::getDelays(int &exposureDelay, int &gainDelay,
> --
> 2.25.1
>
David Plowman Oct. 3, 2022, 9:27 a.m. UTC | #2
Hi Naush

Thanks for the patch!

On Wed, 28 Sept 2022 at 08:09, Jacopo Mondi via libcamera-devel
<libcamera-devel@lists.libcamera.org> wrote:
>
> Hi Naush
>
> On Mon, Sep 26, 2022 at 10:36:39AM +0100, Naushir Patuck via libcamera-devel wrote:
> > Limit the minimum allowable exposure time to a single line in the IMX296 camera
> > helper. This equates to approximately 30us.
> >
> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
>
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: David Plowman <david.plowman@raspberrypi.com>

Thanks!
David

>
> Thanks
>   j
>
> > ---
> >  src/ipa/raspberrypi/cam_helper_imx296.cpp | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/ipa/raspberrypi/cam_helper_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp
> > index 09f828ea6249..66d21e36ecd0 100644
> > --- a/src/ipa/raspberrypi/cam_helper_imx296.cpp
> > +++ b/src/ipa/raspberrypi/cam_helper_imx296.cpp
> > @@ -26,6 +26,7 @@ public:
> >       void getDelays(int &exposureDelay, int &gainDelay, int &vblankDelay) const override;
> >
> >  private:
> > +     static constexpr uint32_t minExposureLines = 1;
> >       static constexpr uint32_t maxGainCode = 239;
> >       static constexpr Duration timePerLine = 550.0 / 37.125e6 * 1.0s;
> >
> > @@ -54,12 +55,12 @@ double CamHelperImx296::gain(uint32_t gainCode) const
> >
> >  uint32_t CamHelperImx296::exposureLines(Duration exposure) const
> >  {
> > -     return (exposure - 14.26us) / timePerLine;
> > +     return std::max<uint32_t>(minExposureLines, (exposure - 14.26us) / timePerLine);
> >  }
> >
> >  Duration CamHelperImx296::exposure(uint32_t exposureLines) const
> >  {
> > -     return exposureLines * timePerLine + 14.26us;
> > +     return std::max<uint32_t>(minExposureLines, exposureLines) * timePerLine + 14.26us;
> >  }
> >
> >  void CamHelperImx296::getDelays(int &exposureDelay, int &gainDelay,
> > --
> > 2.25.1
> >

Patch
diff mbox series

diff --git a/src/ipa/raspberrypi/cam_helper_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp
index 09f828ea6249..66d21e36ecd0 100644
--- a/src/ipa/raspberrypi/cam_helper_imx296.cpp
+++ b/src/ipa/raspberrypi/cam_helper_imx296.cpp
@@ -26,6 +26,7 @@  public:
 	void getDelays(int &exposureDelay, int &gainDelay, int &vblankDelay) const override;
 
 private:
+	static constexpr uint32_t minExposureLines = 1;
 	static constexpr uint32_t maxGainCode = 239;
 	static constexpr Duration timePerLine = 550.0 / 37.125e6 * 1.0s;
 
@@ -54,12 +55,12 @@  double CamHelperImx296::gain(uint32_t gainCode) const
 
 uint32_t CamHelperImx296::exposureLines(Duration exposure) const
 {
-	return (exposure - 14.26us) / timePerLine;
+	return std::max<uint32_t>(minExposureLines, (exposure - 14.26us) / timePerLine);
 }
 
 Duration CamHelperImx296::exposure(uint32_t exposureLines) const
 {
-	return exposureLines * timePerLine + 14.26us;
+	return std::max<uint32_t>(minExposureLines, exposureLines) * timePerLine + 14.26us;
 }
 
 void CamHelperImx296::getDelays(int &exposureDelay, int &gainDelay,