[libcamera-devel] [PATCH v3 2/3] ipa: raspberrypi: Add CamHelper::ColourGainCode method

Naushir Patuck naush at raspberrypi.com
Wed Apr 14 12:33:53 CEST 2021


Hi David,


On Wed, 14 Apr 2021 at 11:30, David Plowman <david.plowman at raspberrypi.com>
wrote:

> Some sensors may require the V4L2_RED/BLUE_BALANCE to be set. These
> will require a ColourGainCode method in the CamHelper, analogous to
> the GainCode method, but which converts the red and blue gains to the
> codes that the driver will want.
>
> Most sensors don't require these values so it's helpful to provide a
> default method - noting that it should then never be called.
>
> Signed-off-by: David Plowman <david.plowman at raspberrypi.com>
> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
>

Reviewed-by: Naushir Patuck <naush at raspberrypi.com>


> ---
>  src/ipa/raspberrypi/cam_helper.cpp | 18 ++++++++++++++++++
>  src/ipa/raspberrypi/cam_helper.hpp |  4 +++-
>  2 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/src/ipa/raspberrypi/cam_helper.cpp
> b/src/ipa/raspberrypi/cam_helper.cpp
> index 0ae0baa0..ad344d29 100644
> --- a/src/ipa/raspberrypi/cam_helper.cpp
> +++ b/src/ipa/raspberrypi/cam_helper.cpp
> @@ -17,6 +17,11 @@
>  #include "md_parser.hpp"
>
>  using namespace RPiController;
> +using namespace libcamera;
> +
> +namespace libcamera {
> +LOG_DECLARE_CATEGORY(IPARPI)
> +}
>
>  static std::map<std::string, CamHelperCreateFunc> cam_helpers;
>
> @@ -57,6 +62,19 @@ double CamHelper::Exposure(uint32_t exposure_lines)
> const
>         return exposure_lines * mode_.line_length / 1000.0;
>  }
>
> +uint32_t CamHelper::ColourGainCode([[maybe_unused]] double gain) const
> +{
> +       /*
> +        * This is only used when the sensor has RED/BLUE_BALANCE controls.
> +        * Most do not, so supplying a default is helpful - though no one
> +        * should be calling it.
> +        */
> +       LOG(IPARPI, Fatal)
> +               << "Sensor is requesting RED/BLUE gains so a proper "
> +               << "implementation of ColourGainCode must be provided";
> +       return 0;
> +}
> +
>  uint32_t CamHelper::GetVBlanking(double &exposure, double
> minFrameDuration,
>                                  double maxFrameDuration) const
>  {
> diff --git a/src/ipa/raspberrypi/cam_helper.hpp
> b/src/ipa/raspberrypi/cam_helper.hpp
> index 4053a870..a0b6b987 100644
> --- a/src/ipa/raspberrypi/cam_helper.hpp
> +++ b/src/ipa/raspberrypi/cam_helper.hpp
> @@ -26,7 +26,8 @@ namespace RPiController {
>  //
>  // The ability to convert between number of lines of exposure and actual
>  // exposure time, and to convert between the sensor's gain codes and
> actual
> -// gains.
> +// gains. Some sensors like to be told the colour (red and blue) gains, so
> +// there's a method for converting these to gain codes too.
>  //
>  // A method to return the number of frames of delay between updating
> exposure,
>  // analogue gain and vblanking, and for the changes to take effect. For
> many
> @@ -72,6 +73,7 @@ public:
>                                       double maxFrameDuration) const;
>         virtual uint32_t GainCode(double gain) const = 0;
>         virtual double Gain(uint32_t gain_code) const = 0;
> +       virtual uint32_t ColourGainCode(double gain) const;
>         virtual void GetDelays(int &exposure_delay, int &gain_delay,
>                                int &vblank_delay) const;
>         virtual bool SensorEmbeddedDataPresent() const;
> --
> 2.20.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20210414/292ee060/attachment.htm>


More information about the libcamera-devel mailing list