libipa: camera_sensor_helper: add imx681
diff mbox series

Message ID 20260831180812.68940-1-lsa.uz@pm.me
State New
Headers show
Series
  • libipa: camera_sensor_helper: add imx681
Related show

Commit Message

Sergey Lebedev Aug. 31, 2026, 6:08 p.m. UTC
Without a helper the Sony IMX681 front camera on the Microsoft Surface
Pro 11 is unusable in the soft ISP: libcamera logs

  IPASoftIsp: Failed to create camera sensor helper for imx681

and then takes the raw V4L2 gain code for the gain itself. The AGC sees
an analogue gain of 1020, concludes the sensor is enormously
over-amplified and holds the exposure down. Same scene, same build, only
this helper differing:

              AGC believes            mean luma
  without     analogue-gain: 1020        23.8
  with        analogue-gain: 21.3       110.7

The gain model is the usual Sony form, and the driver states it:

  /* Gain formula: gain = 1024/(1024-code). */

Verified against the sensor rather than taken on trust, at fixed
exposure, on raw Bayer from the CSI-2 receiver:

  code      1024/(1024-code)     measured
     0                  1.00         1.00
   512                  2.00         1.91
   768                  4.00         3.79
   896                  8.00         7.51
   960                 16.00        15.05

Black level measured the same way, at minimum exposure and minimum
gain: median and mode both exactly 64 at 10 bits, so 4096.

Signed-off-by: Sergey Lebedev <lsa.uz@pm.me>
---
 src/ipa/libipa/camera_sensor_helper.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Patch
diff mbox series

diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp
--- a/src/ipa/libipa/camera_sensor_helper.cpp
+++ b/src/ipa/libipa/camera_sensor_helper.cpp
@@ -691,6 +691,18 @@  public:
 };
 REGISTER_CAMERA_SENSOR_HELPER("imx678", CameraSensorHelperImx678)
 
+class CameraSensorHelperImx681 : public CameraSensorHelper
+{
+public:
+	CameraSensorHelperImx681()
+	{
+		/* Measured on the sensor: 64 at 10bits. */
+		blackLevel_ = 4096;
+		gain_ = AnalogueGainLinear{ 0, 1024, -1, 1024 };
+	}
+};
+REGISTER_CAMERA_SENSOR_HELPER("imx681", CameraSensorHelperImx681)
+
 class CameraSensorHelperImx708 : public CameraSensorHelper
 {
 public: