[1/4] ipa: rpi: cam_helper: Increase frameIntegrationDiff for IMX662
diff mbox series

Message ID 20260803123012.10175-2-david.plowman@raspberrypi.com
State New
Headers show
Series
  • Black level and other fixes for IMX662
Related show

Commit Message

David Plowman Aug. 3, 2026, 12:07 p.m. UTC
IMX662 can still share its CamHelper with the IMX290 and other
sensors, but requires a frameIntegrationDiff of 6 (as opposed to 2 for
the others). The value 2 is invalid for the IMX662 and can lead to bad
black level values in HCG (High Conversion Gain) mode.

The CamHelperImx290 constructor is refactored slightly to allow the
IMX662 version to be created with a custom frameIntegrationDiff.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 src/ipa/rpi/cam_helper/cam_helper_imx290.cpp | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx290.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx290.cpp
index b69d38c31..2b9cfee21 100644
--- a/src/ipa/rpi/cam_helper/cam_helper_imx290.cpp
+++ b/src/ipa/rpi/cam_helper/cam_helper_imx290.cpp
@@ -14,7 +14,7 @@  using namespace RPiController;
 class CamHelperImx290 : public CamHelper
 {
 public:
-	CamHelperImx290();
+	CamHelperImx290(unsigned int frameIntegrationDiff = kFrameIntegrationDiff);
 	uint32_t gainCode(double gain) const override;
 	double gain(uint32_t gainCode) const override;
 	unsigned int hideFramesStartup() const override;
@@ -25,10 +25,10 @@  private:
 	 * Smallest difference between the frame length and integration time,
 	 * in units of lines.
 	 */
-	static constexpr int frameIntegrationDiff = 2;
+	static constexpr unsigned int kFrameIntegrationDiff = 2;
 };
 
-CamHelperImx290::CamHelperImx290()
+CamHelperImx290::CamHelperImx290(unsigned int frameIntegrationDiff)
 	: CamHelper({}, frameIntegrationDiff)
 {
 }
@@ -61,7 +61,18 @@  static CamHelper *create()
 	return new CamHelperImx290();
 }
 
+static CamHelper *createImx662()
+{
+	/*
+	 * The imx662 requires a frame integration diff of at least 4,
+	 * according to the datasheet, but in practice this didn't prevent
+	 * bad black level values in HCG (high conversion gain) mode.
+	 * So instead, we go with 6 for "safety".
+	 */
+	return new CamHelperImx290(6);
+}
+
 static RegisterCamHelper reg("imx290", &create);
 static RegisterCamHelper reg327("imx327", &create);
 static RegisterCamHelper reg462("imx462", &create);
-static RegisterCamHelper reg662("imx662", &create);
+static RegisterCamHelper reg662("imx662", &createImx662);