[1/2] ipa: libipa: add camera sensor helpers for GC08A8 and S5KJNS
diff mbox series

Message ID 20261017153829.442320-2-xiaqinghuan@mail.ustc.edu.cn
State New
Headers show
Series
  • ipa: libipa: add sensor helpers for GC08A8/S5KJNS and make the AGC target tunable
Related show

Commit Message

Qianhui Xu Oct. 17, 2026, 3:38 p.m. UTC
Add gain models and black levels for the two image sensors used by the
Lenovo Legion Y700 Gen4 (TB322FC, SM8750):

- gc08a8 (GalaxyCore, front): the V4L2 analogue gain control is the raw
  sensor gain code in 1/1024 steps, pedestal is 64 at 10 bits.
- s5kjns (Samsung, rear): the V4L2 analogue gain control is the raw
  sensor gain code in 1/32 steps, pedestal is 64 at 10 bits.

Without these helpers the software ISP interprets the V4L2 analogue gain
code as a multiplier (for instance gain code 32 as 32x) and leaves the
black level at zero, so the AGC converges to an almost black image.

Keeping the raw gain code in the kernel drivers and describing it in
libipa preserves the sensors' natural V4L2 control semantics.

Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
 src/ipa/libipa/camera_sensor_helper.cpp | 32 +++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Comments

Kieran Bingham Oct. 17, 2026, 3:58 p.m. UTC | #1
Quoting Qianhui Xu (2026-10-17 16:38:28)
> Add gain models and black levels for the two image sensors used by the
> Lenovo Legion Y700 Gen4 (TB322FC, SM8750):
> 
> - gc08a8 (GalaxyCore, front): the V4L2 analogue gain control is the raw
>   sensor gain code in 1/1024 steps, pedestal is 64 at 10 bits.
> - s5kjns (Samsung, rear): the V4L2 analogue gain control is the raw
>   sensor gain code in 1/32 steps, pedestal is 64 at 10 bits.
> 
> Without these helpers the software ISP interprets the V4L2 analogue gain
> code as a multiplier (for instance gain code 32 as 32x) and leaves the
> black level at zero, so the AGC converges to an almost black image.
> 

git grep on the kernel isn't finding these sensors yet. Can you link to
the upstream driver postings please ?

 - https://lore.kernel.org/all/?q=gc08a8 gives nothing

and neither does

 - https://lore.kernel.org/all/?q=s5kjns

And with that - one sensor per patch please to keep it easy.

Drivers for the sensors must be on their way upstream Linux for support
to be added to libcamera.

Referencing any public datasheet or brief after the --- will help
verifying too.

Regards
--
Kieran

Patch
diff mbox series

diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp
index e3e3e53..0013d89 100644
--- a/src/ipa/libipa/camera_sensor_helper.cpp
+++ b/src/ipa/libipa/camera_sensor_helper.cpp
@@ -789,6 +789,38 @@  public:
 };
 REGISTER_CAMERA_SENSOR_HELPER("ov13858", CameraSensorHelperOv13858)
 
+class CameraSensorHelperGc08a8 : public CameraSensorHelper
+{
+public:
+	CameraSensorHelperGc08a8()
+	{
+		/*
+		 * GalaxyCore GC08A8: the V4L2 analogue gain control is the raw
+		 * sensor gain code in 1/1024 steps (0x0400 == 1.0x).
+		 * Pedestal is 64 at 10 bits (see vendor register defaults).
+		 */
+		blackLevel_ = 4096;
+		gain_ = AnalogueGainLinear{ 1, 0, 0, 1024 };
+	}
+};
+REGISTER_CAMERA_SENSOR_HELPER("gc08a8", CameraSensorHelperGc08a8)
+
+class CameraSensorHelperS5kjns : public CameraSensorHelper
+{
+public:
+	CameraSensorHelperS5kjns()
+	{
+		/*
+		 * Samsung S5KJNS: the V4L2 analogue gain control is the raw
+		 * sensor gain code in 1/32 steps (0x0020 == 1.0x).
+		 * Pedestal is 64 at 10 bits (see vendor register defaults).
+		 */
+		blackLevel_ = 4096;
+		gain_ = AnalogueGainLinear{ 1, 0, 0, 32 };
+	}
+};
+REGISTER_CAMERA_SENSOR_HELPER("s5kjns", CameraSensorHelperS5kjns)
+
 class CameraSensorHelperVd55g1 : public CameraSensorHelper
 {
 public: