[2/2] ipa: simple: data: Add OV2740 tuning file
diff mbox series

Message ID 20260225221859.600869-3-floss@jetm.me
State New
Headers show
Series
  • ipa: simple: Proportional AGC and OV2740 tuning
Related show

Commit Message

Javier Tia Feb. 25, 2026, 10:18 p.m. UTC
Add a sensor-specific tuning file for the OmniVision OV2740, commonly
found in Intel IPU6 laptops (ThinkPad X1 Carbon, XPS, Surface).

The tuning enables all Simple IPA algorithms including AGC, AWB, black
level correction, and a color correction matrix calibrated for 6500K.
The CCM compensates for the green bias inherent in Bayer demosaicing
(the GRBG pattern has 2x green pixels vs red/blue).

Without this file, libcamera falls back to uncalibrated.yaml which
produces a heavy green tint on the OV2740.

Signed-off-by: Javier Tia <floss@jetm.me>
---
 src/ipa/simple/data/meson.build |  1 +
 src/ipa/simple/data/ov2740.yaml | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
 create mode 100644 src/ipa/simple/data/ov2740.yaml

Comments

Milan Zamazal Feb. 26, 2026, 12:28 p.m. UTC | #1
Hi Javier,

thank you for the patch, tuning files are much needed.

Javier Tia <floss@jetm.me> writes:

> Add a sensor-specific tuning file for the OmniVision OV2740, commonly
> found in Intel IPU6 laptops (ThinkPad X1 Carbon, XPS, Surface).
>
> The tuning enables all Simple IPA algorithms including AGC, AWB, black
> level correction, and a color correction matrix calibrated for 6500K.
> The CCM compensates for the green bias inherent in Bayer demosaicing
> (the GRBG pattern has 2x green pixels vs red/blue).
>
> Without this file, libcamera falls back to uncalibrated.yaml which
> produces a heavy green tint on the OV2740.

I wonder what's the cause of the green tint really.  I'm not sure I
understand the Bayer pattern argument: Software ISP uses the grey world
white balance algorithm that basically takes a look at average colour
channel values; how many pixels represent each of the colours doesn't
have direct influence on the averages.  If there is a strong tint then
something may be wrong.  Or it's perhaps a property of the sensor.  We
know the current processing has flaws and it's a priority to get them
fixed.  Understanding the current problems would help.

There may be other variables like incorrect black level (which is
auto-guessed when its value is not specified in the tuning file) or its
incorrect handling.

> Signed-off-by: Javier Tia <floss@jetm.me>
> ---
>  src/ipa/simple/data/meson.build |  1 +
>  src/ipa/simple/data/ov2740.yaml | 22 ++++++++++++++++++++++
>  2 files changed, 23 insertions(+)
>  create mode 100644 src/ipa/simple/data/ov2740.yaml
>
> diff --git a/src/ipa/simple/data/meson.build b/src/ipa/simple/data/meson.build
> index 92795ee4..e3e4de74 100644
> --- a/src/ipa/simple/data/meson.build
> +++ b/src/ipa/simple/data/meson.build
> @@ -1,6 +1,7 @@
>  # SPDX-License-Identifier: CC0-1.0
>  
>  conf_files = files([
> +    'ov2740.yaml',
>      'uncalibrated.yaml',
>  ])
>  
> diff --git a/src/ipa/simple/data/ov2740.yaml b/src/ipa/simple/data/ov2740.yaml
> new file mode 100644
> index 00000000..b48d50ce
> --- /dev/null
> +++ b/src/ipa/simple/data/ov2740.yaml
> @@ -0,0 +1,22 @@
> +# SPDX-License-Identifier: CC0-1.0
> +#
> +# OmniVision OV2740 tuning for libcamera Simple/SoftISP pipeline.
> +#
> +# Tested on ThinkPad X1 Carbon Gen 10 (Alder Lake) with Intel IPU6 ISYS.
> +# The CCM corrects the green bias inherent in Bayer demosaicing (2:1 green
> +# to red/blue pixel ratio in the CFA). Values were iteratively calibrated
> +# from captured frame measurements under 6500K lighting.
> +%YAML 1.1
> +---
> +version: 1
> +algorithms:
> +  - BlackLevel:
> +  - Awb:
> +  - Ccm:
> +      ccms:
> +        - ct: 6500
> +          ccm: [ 2.49, -0.91, -0.26,
> +                -0.30,  1.20,  0.10,
> +                 0.07, -0.80,  2.19 ]
> +  - Adjust:
> +  - Agc:
Robert Mader Feb. 26, 2026, 1:53 p.m. UTC | #2
Hi, very happy to see this!

On 26.02.26 13:28, Milan Zamazal wrote:
> Hi Javier,
>
> thank you for the patch, tuning files are much needed.
>
> Javier Tia<floss@jetm.me> writes:
>
>> Add a sensor-specific tuning file for the OmniVision OV2740, commonly
>> found in Intel IPU6 laptops (ThinkPad X1 Carbon, XPS, Surface).
>>
>> The tuning enables all Simple IPA algorithms including AGC, AWB, black
>> level correction, and a color correction matrix calibrated for 6500K.
>> The CCM compensates for the green bias inherent in Bayer demosaicing
>> (the GRBG pattern has 2x green pixels vs red/blue).
>>
>> Without this file, libcamera falls back to uncalibrated.yaml which
>> produces a heavy green tint on the OV2740.
> I wonder what's the cause of the green tint really.  I'm not sure I
> understand the Bayer pattern argument: Software ISP uses the grey world
> white balance algorithm that basically takes a look at average colour
> channel values; how many pixels represent each of the colours doesn't
> have direct influence on the averages.  If there is a strong tint then
> something may be wrong.  Or it's perhaps a property of the sensor.  We
> know the current processing has flaws and it's a priority to get them
> fixed.  Understanding the current problems would help.
>
> There may be other variables like incorrect black level (which is
> auto-guessed when its value is not specified in the tuning file) or its
> incorrect handling.

Just a note regarding black level: this should be taken from the 
CameraSensorHelper if possible. There is already 
CameraSensorHelperOv2740, however it's missing a blackLevel_ value - it 
would be great to add that as part of this series.

Regards,

Robert

>> Signed-off-by: Javier Tia<floss@jetm.me>
>> ---
>>   src/ipa/simple/data/meson.build |  1 +
>>   src/ipa/simple/data/ov2740.yaml | 22 ++++++++++++++++++++++
>>   2 files changed, 23 insertions(+)
>>   create mode 100644 src/ipa/simple/data/ov2740.yaml
>>
>> diff --git a/src/ipa/simple/data/meson.build b/src/ipa/simple/data/meson.build
>> index 92795ee4..e3e4de74 100644
>> --- a/src/ipa/simple/data/meson.build
>> +++ b/src/ipa/simple/data/meson.build
>> @@ -1,6 +1,7 @@
>>   # SPDX-License-Identifier: CC0-1.0
>>   
>>   conf_files = files([
>> +    'ov2740.yaml',
>>       'uncalibrated.yaml',
>>   ])
>>   
>> diff --git a/src/ipa/simple/data/ov2740.yaml b/src/ipa/simple/data/ov2740.yaml
>> new file mode 100644
>> index 00000000..b48d50ce
>> --- /dev/null
>> +++ b/src/ipa/simple/data/ov2740.yaml
>> @@ -0,0 +1,22 @@
>> +# SPDX-License-Identifier: CC0-1.0
>> +#
>> +# OmniVision OV2740 tuning for libcamera Simple/SoftISP pipeline.
>> +#
>> +# Tested on ThinkPad X1 Carbon Gen 10 (Alder Lake) with Intel IPU6 ISYS.
>> +# The CCM corrects the green bias inherent in Bayer demosaicing (2:1 green
>> +# to red/blue pixel ratio in the CFA). Values were iteratively calibrated
>> +# from captured frame measurements under 6500K lighting.
>> +%YAML 1.1
>> +---
>> +version: 1
>> +algorithms:
>> +  - BlackLevel:
>> +  - Awb:
>> +  - Ccm:
>> +      ccms:
>> +        - ct: 6500
>> +          ccm: [ 2.49, -0.91, -0.26,
>> +                -0.30,  1.20,  0.10,
>> +                 0.07, -0.80,  2.19 ]
>> +  - Adjust:
>> +  - Agc:
Kieran Bingham Feb. 26, 2026, 4:22 p.m. UTC | #3
Quoting Milan Zamazal (2026-02-26 12:28:44)
> Hi Javier,
> 
> thank you for the patch, tuning files are much needed.
> 
> Javier Tia <floss@jetm.me> writes:
> 
> > Add a sensor-specific tuning file for the OmniVision OV2740, commonly
> > found in Intel IPU6 laptops (ThinkPad X1 Carbon, XPS, Surface).
> >
> > The tuning enables all Simple IPA algorithms including AGC, AWB, black
> > level correction, and a color correction matrix calibrated for 6500K.
> > The CCM compensates for the green bias inherent in Bayer demosaicing
> > (the GRBG pattern has 2x green pixels vs red/blue).
> >
> > Without this file, libcamera falls back to uncalibrated.yaml which
> > produces a heavy green tint on the OV2740.
> 
> I wonder what's the cause of the green tint really.  I'm not sure I
> understand the Bayer pattern argument: Software ISP uses the grey world
> white balance algorithm that basically takes a look at average colour
> channel values; how many pixels represent each of the colours doesn't
> have direct influence on the averages.  If there is a strong tint then
> something may be wrong.  Or it's perhaps a property of the sensor.  We

Somebody gave a talk about that quite recently:
 - https://video.fosdem.org/2026/ud2120/BQJPUP-libcamera-tuning.av1.webm


> know the current processing has flaws and it's a priority to get them
> fixed.  Understanding the current problems would help.
> 
> There may be other variables like incorrect black level (which is
> auto-guessed when its value is not specified in the tuning file) or its
> incorrect handling.
> 
> > Signed-off-by: Javier Tia <floss@jetm.me>
> > ---
> >  src/ipa/simple/data/meson.build |  1 +
> >  src/ipa/simple/data/ov2740.yaml | 22 ++++++++++++++++++++++
> >  2 files changed, 23 insertions(+)
> >  create mode 100644 src/ipa/simple/data/ov2740.yaml
> >
> > diff --git a/src/ipa/simple/data/meson.build b/src/ipa/simple/data/meson.build
> > index 92795ee4..e3e4de74 100644
> > --- a/src/ipa/simple/data/meson.build
> > +++ b/src/ipa/simple/data/meson.build
> > @@ -1,6 +1,7 @@
> >  # SPDX-License-Identifier: CC0-1.0
> >  
> >  conf_files = files([
> > +    'ov2740.yaml',
> >      'uncalibrated.yaml',
> >  ])
> >  
> > diff --git a/src/ipa/simple/data/ov2740.yaml b/src/ipa/simple/data/ov2740.yaml
> > new file mode 100644
> > index 00000000..b48d50ce
> > --- /dev/null
> > +++ b/src/ipa/simple/data/ov2740.yaml
> > @@ -0,0 +1,22 @@
> > +# SPDX-License-Identifier: CC0-1.0
> > +#
> > +# OmniVision OV2740 tuning for libcamera Simple/SoftISP pipeline.
> > +#
> > +# Tested on ThinkPad X1 Carbon Gen 10 (Alder Lake) with Intel IPU6 ISYS.
> > +# The CCM corrects the green bias inherent in Bayer demosaicing (2:1 green
> > +# to red/blue pixel ratio in the CFA). Values were iteratively calibrated
> > +# from captured frame measurements under 6500K lighting.
> > +%YAML 1.1
> > +---
> > +version: 1
> > +algorithms:
> > +  - BlackLevel:
> > +  - Awb:
> > +  - Ccm:
> > +      ccms:
> > +        - ct: 6500
> > +          ccm: [ 2.49, -0.91, -0.26,
> > +                -0.30,  1.20,  0.10,
> > +                 0.07, -0.80,  2.19 ]

It's actually important that these add up to '1' in each row. Otherwise
it's applying an artificial gain as well.

The talk at
https://video.fosdem.org/2026/ud2120/BQJPUP-libcamera-tuning.av1.webm is
precisely about dealing with how we need to capture and determine these
values correctly.

--
Kieran


> > +  - Adjust:
> > +  - Agc:
>

Patch
diff mbox series

diff --git a/src/ipa/simple/data/meson.build b/src/ipa/simple/data/meson.build
index 92795ee4..e3e4de74 100644
--- a/src/ipa/simple/data/meson.build
+++ b/src/ipa/simple/data/meson.build
@@ -1,6 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 
 conf_files = files([
+    'ov2740.yaml',
     'uncalibrated.yaml',
 ])
 
diff --git a/src/ipa/simple/data/ov2740.yaml b/src/ipa/simple/data/ov2740.yaml
new file mode 100644
index 00000000..b48d50ce
--- /dev/null
+++ b/src/ipa/simple/data/ov2740.yaml
@@ -0,0 +1,22 @@ 
+# SPDX-License-Identifier: CC0-1.0
+#
+# OmniVision OV2740 tuning for libcamera Simple/SoftISP pipeline.
+#
+# Tested on ThinkPad X1 Carbon Gen 10 (Alder Lake) with Intel IPU6 ISYS.
+# The CCM corrects the green bias inherent in Bayer demosaicing (2:1 green
+# to red/blue pixel ratio in the CFA). Values were iteratively calibrated
+# from captured frame measurements under 6500K lighting.
+%YAML 1.1
+---
+version: 1
+algorithms:
+  - BlackLevel:
+  - Awb:
+  - Ccm:
+      ccms:
+        - ct: 6500
+          ccm: [ 2.49, -0.91, -0.26,
+                -0.30,  1.20,  0.10,
+                 0.07, -0.80,  2.19 ]
+  - Adjust:
+  - Agc: