From 81948970e1d8eba1e3cc3544fe8f982867215643 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Sun, 16 Aug 2026 21:03:10 +0200 Subject: [PATCH] libcamera: add the IMX896 sensor helper and properties (r3) Teaches the software ISP's AGC the IMX896 gain law (gain = 16384/(16384-code), inverted from the vendor driver and round-tripped against all 3009 vendor gain-table entries, max error 0.049%) and adds the sensor properties (1.0um unit cell, test-pattern map). Same shape as the OV13B10 pair; both verified to apply and compile on v0.7.2 after 0001-0004. The extracted-CCM tuning yaml is deliberately NOT packaged yet - the color matrices come from the vendor Chromatix blob and the licensing call is open (see the camera journal). Co-Authored-By: Claude Fable 5 --- ...-Add-camera-sensor-helper-for-IMX896.patch | 47 +++++++++++++++++++ ...-sensor-Add-IMX896-sensor-properties.patch | 41 ++++++++++++++++ aports/temp/libcamera/APKBUILD | 6 ++- 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 aports/temp/libcamera/0005-libipa-Add-camera-sensor-helper-for-IMX896.patch create mode 100644 aports/temp/libcamera/0006-libcamera-sensor-Add-IMX896-sensor-properties.patch diff --git a/aports/temp/libcamera/0005-libipa-Add-camera-sensor-helper-for-IMX896.patch b/aports/temp/libcamera/0005-libipa-Add-camera-sensor-helper-for-IMX896.patch new file mode 100644 index 0000000..0fc7b50 --- /dev/null +++ b/aports/temp/libcamera/0005-libipa-Add-camera-sensor-helper-for-IMX896.patch @@ -0,0 +1,47 @@ +From 4008fe2ced7bbf1026267ec47028b735173cc0db Mon Sep 17 00:00:00 2001 +From: Jorijn van der Graaf +Date: Sun, 16 Aug 2026 20:49:31 +0200 +Subject: [PATCH] libipa: Add camera sensor helper for IMX896 + +The Sony IMX896 (main sensor on the Fairphone 6 / milos) needs a +CameraSensorHelper so the software ISP AGC can map the analogue gain +register code to a real gain multiplier. Without it libcamera logs +"IPASoft: Failed to create camera sensor helper for imx896" and the +AGC misinterprets the raw gain code (0..16128) as a linear gain. + +The IMX896 uses the common Sony analogue gain model with a 14 bit +code: gain = 16384 / (16384 - code), so code 0 is 1x and the maximum +code 16128 is 64x. Derived from the vendor kernel driver's gain2reg +conversion (regGain = 16384 - 16384 * BASEGAIN / gain, with the gain +table spanning 1024..65536 in 1/1024 units) and matching the mainline +imx896 driver's gain register documentation. + +Assisted-by: Claude:claude-fable-5 +--- + src/ipa/libipa/camera_sensor_helper.cpp | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp +index 9457d62..cf2482b 100644 +--- a/src/ipa/libipa/camera_sensor_helper.cpp ++++ b/src/ipa/libipa/camera_sensor_helper.cpp +@@ -665,6 +665,16 @@ public: + }; + REGISTER_CAMERA_SENSOR_HELPER("imx708", CameraSensorHelperImx708) + ++class CameraSensorHelperImx896 : public CameraSensorHelper ++{ ++public: ++ CameraSensorHelperImx896() ++ { ++ gain_ = AnalogueGainLinear{ 0, 16384, -1, 16384 }; ++ } ++}; ++REGISTER_CAMERA_SENSOR_HELPER("imx896", CameraSensorHelperImx896) ++ + class CameraSensorHelperOv01a10 : public CameraSensorHelper + { + public: +-- +2.55.0 + diff --git a/aports/temp/libcamera/0006-libcamera-sensor-Add-IMX896-sensor-properties.patch b/aports/temp/libcamera/0006-libcamera-sensor-Add-IMX896-sensor-properties.patch new file mode 100644 index 0000000..a9aa93c --- /dev/null +++ b/aports/temp/libcamera/0006-libcamera-sensor-Add-IMX896-sensor-properties.patch @@ -0,0 +1,41 @@ +From 262906b13ff727473679cf7895618e4745f3ba4c Mon Sep 17 00:00:00 2001 +From: Jorijn van der Graaf +Date: Sun, 16 Aug 2026 20:49:31 +0200 +Subject: [PATCH] libcamera: sensor: Add IMX896 sensor properties + +Add the Sony IMX896 (Fairphone 6 main camera, 50 MP, 8192x6144) to +the static properties database: 1.0 um unit cell and the test pattern +modes exposed by the kernel driver (V4L2 menu indices map 1:1 to +register 0x0600 values). Removes the "No static properties available +for 'imx896'" warning. + +Assisted-by: Claude:claude-fable-5 +--- + src/libcamera/sensor/camera_sensor_properties.cpp | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp +index 2804315..63050c2 100644 +--- a/src/libcamera/sensor/camera_sensor_properties.cpp ++++ b/src/libcamera/sensor/camera_sensor_properties.cpp +@@ -335,6 +335,17 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen + .hblankDelay = 3 + }, + } }, ++ { "imx896", { ++ .unitCellSize = { 1000, 1000 }, ++ .testPatternModes = { ++ { controls::draft::TestPatternModeOff, 0 }, ++ { controls::draft::TestPatternModeSolidColor, 1 }, ++ { controls::draft::TestPatternModeColorBars, 2 }, ++ { controls::draft::TestPatternModeColorBarsFadeToGray, 3 }, ++ { controls::draft::TestPatternModePn9, 4 }, ++ }, ++ .sensorDelays = { }, ++ } }, + { "ov2685", { + .unitCellSize = { 1750, 1750 }, + .testPatternModes = { +-- +2.55.0 + diff --git a/aports/temp/libcamera/APKBUILD b/aports/temp/libcamera/APKBUILD index 4b02af8..0592f08 100644 --- a/aports/temp/libcamera/APKBUILD +++ b/aports/temp/libcamera/APKBUILD @@ -3,7 +3,7 @@ maintainer="Robert Mader " pkgname=libcamera _pkgver=0.7.2 pkgver=9999$_pkgver -pkgrel=2 +pkgrel=3 pkgdesc="Linux camera framework" url="https://libcamera.org/" arch="all" @@ -61,6 +61,8 @@ source="https://gitlab.freedesktop.org/camera/libcamera/-/archive/v$_pkgver/libc 0002-libcamera-simple-Skip-hwISP-formats-if-swISP-is-acti.patch 0003-libipa-Add-OV13B10-camera-sensor-helper.patch 0004-libcamera-sensor-Add-OV13B10-sensor-properties.patch + 0005-libipa-Add-camera-sensor-helper-for-IMX896.patch + 0006-libcamera-sensor-Add-IMX896-sensor-properties.patch qcam.desktop $_tuning_files " @@ -178,6 +180,8 @@ eef5e38efc874f2049d17f08b04d9f21c3e4616f66873358cd2c446e651f78d6952ae25ee13a6ef9 191dfa09cfd08bcdf0d0d07410d17af590cf78b8bc8f8b7587fd2dc1c645a9ca07f2926b5d98381c011319b1f4e1d6195dd0d6dba65fd8c723882e6be0d6117d 0002-libcamera-simple-Skip-hwISP-formats-if-swISP-is-acti.patch 594e2c31bd51dac8f5f184b026301028431b1c67e48edb245790444713b64e927fac99cb8a33f0b7042c9689359079158b3f1d344b250904472c977f1313f83e 0003-libipa-Add-OV13B10-camera-sensor-helper.patch 89e0fc4a12aa4d5fbdc77b50e28b0a6d2cf8dfeb884b536507b6c24aa2ae5c616a32a517deb086e3284c72a82e6d6ddcf6eaa88f6c1c021adc6a0167194b7711 0004-libcamera-sensor-Add-OV13B10-sensor-properties.patch +f746cff46f78a8e7bd4cadd72c4ab05044971e36e412a56d4a14a420aeb1c9168b1f4ef411f4cc81a596159cab3d8a3713214a4ff0b2a4daf839b1a380c09b6e 0005-libipa-Add-camera-sensor-helper-for-IMX896.patch +1ac9747c941787c7ae76ed6520585b0d26494eb0f697bd74a9155ed04736a7b61f838dfb1bad01cf13b9cdd36f644a95a6ec1cbfe4f5c5a42cb23d4b6d9aa166 0006-libcamera-sensor-Add-IMX896-sensor-properties.patch 22167a4eceb6d1b40b0b7c45fdf116c71684f5340de7f767535cb8e160ad9d2ae0f00cb3d461f73a344520a48a4641cf46226841d78bee06bfbfd2a91337f754 qcam.desktop 2ee566653b17d565d2c0de67cbe6ebad25df5aac6051cad78e6bae52016fa2ca0247e964d735ac776b3e0bd447ead9c4fcb26cd7629228cdba3ceb91b46f378f hi846.yaml 55dab9dcb9b1982143b9d63e4e51138c5bffd7c8f4a8e4e122750b3ad9d475446956bc297d9f564819ade4be75a575d06633a064e14f8ba3ef77986783c5f067 imx355.yaml