libcamera: libipa: camera_sensor: define AR0521 helper functions inline
diff mbox series

Message ID 20240603224855.25011-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit d9c6835e23ec9ff719acc76abb8cde89450680c2
Headers show
Series
  • libcamera: libipa: camera_sensor: define AR0521 helper functions inline
Related show

Commit Message

Laurent Pinchart June 3, 2024, 10:48 p.m. UTC
All CameraSensorHelper subclasses define their member functions inline,
except for the CameraSensorHelperAr0521 class. Inline the gainCode() and
gain() functions to match the other classes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/ipa/libipa/camera_sensor_helper.cpp | 36 +++++++++++--------------
 1 file changed, 16 insertions(+), 20 deletions(-)


base-commit: 6cd17515ffeb67fb38ffcc4d57aadf9732b54800

Comments

Kieran Bingham June 5, 2024, 8:57 a.m. UTC | #1
Quoting Laurent Pinchart (2024-06-03 23:48:55)
> All CameraSensorHelper subclasses define their member functions inline,
> except for the CameraSensorHelperAr0521 class. Inline the gainCode() and
> gain() functions to match the other classes.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>


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

> ---
>  src/ipa/libipa/camera_sensor_helper.cpp | 36 +++++++++++--------------
>  1 file changed, 16 insertions(+), 20 deletions(-)
> 
> diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp
> index 2cd61fccfbb9..782ff9904e81 100644
> --- a/src/ipa/libipa/camera_sensor_helper.cpp
> +++ b/src/ipa/libipa/camera_sensor_helper.cpp
> @@ -369,30 +369,26 @@ static constexpr double expGainDb(double step)
>  class CameraSensorHelperAr0521 : public CameraSensorHelper
>  {
>  public:
> -       uint32_t gainCode(double gain) const override;
> -       double gain(uint32_t gainCode) const override;
> +       uint32_t gainCode(double gain) const override
> +       {
> +               gain = std::clamp(gain, 1.0, 15.5);
> +               unsigned int coarse = std::log2(gain);
> +               unsigned int fine = (gain / (1 << coarse) - 1) * kStep_;
> +
> +               return (coarse << 4) | (fine & 0xf);
> +       }
> +
> +       double gain(uint32_t gainCode) const override
> +       {
> +               unsigned int coarse = gainCode >> 4;
> +               unsigned int fine = gainCode & 0xf;
> +
> +               return (1 << coarse) * (1 + fine / kStep_);
> +       }
>  
>  private:
>         static constexpr double kStep_ = 16;
>  };
> -
> -uint32_t CameraSensorHelperAr0521::gainCode(double gain) const
> -{
> -       gain = std::clamp(gain, 1.0, 15.5);
> -       unsigned int coarse = std::log2(gain);
> -       unsigned int fine = (gain / (1 << coarse) - 1) * kStep_;
> -
> -       return (coarse << 4) | (fine & 0xf);
> -}
> -
> -double CameraSensorHelperAr0521::gain(uint32_t gainCode) const
> -{
> -       unsigned int coarse = gainCode >> 4;
> -       unsigned int fine = gainCode & 0xf;
> -
> -       return (1 << coarse) * (1 + fine / kStep_);
> -}
> -
>  REGISTER_CAMERA_SENSOR_HELPER("ar0521", CameraSensorHelperAr0521)
>  
>  class CameraSensorHelperImx219 : public CameraSensorHelper
> 
> base-commit: 6cd17515ffeb67fb38ffcc4d57aadf9732b54800
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp
index 2cd61fccfbb9..782ff9904e81 100644
--- a/src/ipa/libipa/camera_sensor_helper.cpp
+++ b/src/ipa/libipa/camera_sensor_helper.cpp
@@ -369,30 +369,26 @@  static constexpr double expGainDb(double step)
 class CameraSensorHelperAr0521 : public CameraSensorHelper
 {
 public:
-	uint32_t gainCode(double gain) const override;
-	double gain(uint32_t gainCode) const override;
+	uint32_t gainCode(double gain) const override
+	{
+		gain = std::clamp(gain, 1.0, 15.5);
+		unsigned int coarse = std::log2(gain);
+		unsigned int fine = (gain / (1 << coarse) - 1) * kStep_;
+
+		return (coarse << 4) | (fine & 0xf);
+	}
+
+	double gain(uint32_t gainCode) const override
+	{
+		unsigned int coarse = gainCode >> 4;
+		unsigned int fine = gainCode & 0xf;
+
+		return (1 << coarse) * (1 + fine / kStep_);
+	}
 
 private:
 	static constexpr double kStep_ = 16;
 };
-
-uint32_t CameraSensorHelperAr0521::gainCode(double gain) const
-{
-	gain = std::clamp(gain, 1.0, 15.5);
-	unsigned int coarse = std::log2(gain);
-	unsigned int fine = (gain / (1 << coarse) - 1) * kStep_;
-
-	return (coarse << 4) | (fine & 0xf);
-}
-
-double CameraSensorHelperAr0521::gain(uint32_t gainCode) const
-{
-	unsigned int coarse = gainCode >> 4;
-	unsigned int fine = gainCode & 0xf;
-
-	return (1 << coarse) * (1 + fine / kStep_);
-}
-
 REGISTER_CAMERA_SENSOR_HELPER("ar0521", CameraSensorHelperAr0521)
 
 class CameraSensorHelperImx219 : public CameraSensorHelper