[RFC] libcamera: Increment tuning file format version to 2
diff mbox series

Message ID 20261029173524.1213552-1-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • [RFC] libcamera: Increment tuning file format version to 2
Related show

Commit Message

Stefan Klug Oct. 29, 2026, 5:35 p.m. UTC
Because of commit 974102049a41 ("libcamera: controls: Remove common enum
prefix") the format of the tuning files changed in a backwards
incompatible way. To make that very transparent to the users, increment
the required tuning file version so that a old tuning file results in an
error. Apply these checks to ipu3, mali-c55, rkisp1 and softisp.

For user reading this due to the error:

To migrate from version 1 to version 2, increment the version entry to 2
and drop the prefix from the following entries:
- MeteringCentreWeighted
- MeteringSpot
- MeteringMatrix

- ExposureNormal
- ExposureShort

- ConstraintNormal
- ConstraintHighlight

- AwbAuto
- AwbIncandescent
- AwbTungsten
- AwbFluorescent
- AwbIndoor
- AwbDaylight
- AwbCloudy

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
Hi all,

I'm not super happy with this patch (hence the RFC) but at least it loudly warns
the users. The problems are:

- Again more code duplication. But given that we have no central tuning file
  loading logic this might be acceptable
- It errors out in many cases where the tuning files might actually be
  compatible. E.g. if the tuning file only use the grey world awb. But checking
  for that specifically would be way more work
- It is only compile tested

Feedback welcome.

Best regards,
Stefan
---
 src/ipa/ipu3/data/uncalibrated.yaml              | 2 +-
 src/ipa/ipu3/ipu3.cpp                            | 6 ++++--
 src/ipa/mali-c55/data/imx415.yaml                | 2 +-
 src/ipa/mali-c55/data/uncalibrated.yaml          | 2 +-
 src/ipa/mali-c55/mali-c55.cpp                    | 9 +++++++++
 src/ipa/rkisp1/data/imx219.yaml                  | 2 +-
 src/ipa/rkisp1/data/imx258.yaml                  | 2 +-
 src/ipa/rkisp1/data/mira220.yaml                 | 2 +-
 src/ipa/rkisp1/data/ov2685.yaml                  | 2 +-
 src/ipa/rkisp1/data/ov4689.yaml                  | 2 +-
 src/ipa/rkisp1/data/ov5640.yaml                  | 2 +-
 src/ipa/rkisp1/data/ov5695.yaml                  | 2 +-
 src/ipa/rkisp1/data/ov8858.yaml                  | 2 +-
 src/ipa/rkisp1/rkisp1.cpp                        | 6 ++++--
 src/ipa/softisp/data/uncalibrated.yaml           | 2 +-
 src/ipa/softisp/softisp.cpp                      | 8 ++++++++
 utils/tuning/libtuning/generators/yaml_output.py | 4 ++--
 17 files changed, 39 insertions(+), 18 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/ipu3/data/uncalibrated.yaml b/src/ipa/ipu3/data/uncalibrated.yaml
index 415ca4578fab..d17189aa467d 100644
--- a/src/ipa/ipu3/data/uncalibrated.yaml
+++ b/src/ipa/ipu3/data/uncalibrated.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - Af:
   - Agc:
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 30d52cfcf9c6..0294e7f92908 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -249,9 +249,11 @@  int IPAIPU3::init(const IPASettings &settings,
 		return -EINVAL;
 
 	unsigned int version = (*data)["version"].get<uint32_t>(0);
-	if (version != 1) {
+	if (version != 2) {
 		LOG(IPAIPU3, Error)
-			<< "Invalid tuning file version " << version;
+			<< "The tuning file " << settings.configurationFile
+			<< " is version " << version
+			<< " but version 2 is required";
 		return -EINVAL;
 	}
 
diff --git a/src/ipa/mali-c55/data/imx415.yaml b/src/ipa/mali-c55/data/imx415.yaml
index 126b427af339..3a1e71098297 100644
--- a/src/ipa/mali-c55/data/imx415.yaml
+++ b/src/ipa/mali-c55/data/imx415.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - Agc:
   - Awb:
diff --git a/src/ipa/mali-c55/data/uncalibrated.yaml b/src/ipa/mali-c55/data/uncalibrated.yaml
index ea44c58c9efb..df4060d2f9d0 100644
--- a/src/ipa/mali-c55/data/uncalibrated.yaml
+++ b/src/ipa/mali-c55/data/uncalibrated.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - Agc:
   - Awb:
diff --git a/src/ipa/mali-c55/mali-c55.cpp b/src/ipa/mali-c55/mali-c55.cpp
index 9a2918cf2cf1..22ad10e3bcfa 100644
--- a/src/ipa/mali-c55/mali-c55.cpp
+++ b/src/ipa/mali-c55/mali-c55.cpp
@@ -114,6 +114,15 @@  int IPAMaliC55::init(const IPASettings &settings, const IPAConfigInfo &ipaConfig
 	if (!data)
 		return -EINVAL;
 
+	unsigned int version = (*data)["version"].get<uint32_t>(0);
+	if (version != 2) {
+		LOG(IPAMaliC55, Error)
+			<< "The tuning file " << settings.configurationFile
+			<< " is version " << version
+			<< " but version 2 is required";
+		return -EINVAL;
+	}
+
 	if (!data->contains("algorithms")) {
 		LOG(IPAMaliC55, Error)
 			<< "Tuning file doesn't contain any algorithm";
diff --git a/src/ipa/rkisp1/data/imx219.yaml b/src/ipa/rkisp1/data/imx219.yaml
index 0d99cb529392..033484a991f4 100644
--- a/src/ipa/rkisp1/data/imx219.yaml
+++ b/src/ipa/rkisp1/data/imx219.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - Agc:
   - Awb:
diff --git a/src/ipa/rkisp1/data/imx258.yaml b/src/ipa/rkisp1/data/imx258.yaml
index 202af36afbee..77eda84f3f03 100644
--- a/src/ipa/rkisp1/data/imx258.yaml
+++ b/src/ipa/rkisp1/data/imx258.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - Agc:
   - Awb:
diff --git a/src/ipa/rkisp1/data/mira220.yaml b/src/ipa/rkisp1/data/mira220.yaml
index 4751d311a84b..dc9798860d38 100644
--- a/src/ipa/rkisp1/data/mira220.yaml
+++ b/src/ipa/rkisp1/data/mira220.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - Agc:
       AeMeteringMode:
diff --git a/src/ipa/rkisp1/data/ov2685.yaml b/src/ipa/rkisp1/data/ov2685.yaml
index fdfc98d35267..a110d4ea811a 100644
--- a/src/ipa/rkisp1/data/ov2685.yaml
+++ b/src/ipa/rkisp1/data/ov2685.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - Agc:
   - Awb:
diff --git a/src/ipa/rkisp1/data/ov4689.yaml b/src/ipa/rkisp1/data/ov4689.yaml
index 609012967e02..2847ed0f8ef4 100644
--- a/src/ipa/rkisp1/data/ov4689.yaml
+++ b/src/ipa/rkisp1/data/ov4689.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - Agc:
   - Awb:
diff --git a/src/ipa/rkisp1/data/ov5640.yaml b/src/ipa/rkisp1/data/ov5640.yaml
index 4b21d412e44e..e5e0538a7071 100644
--- a/src/ipa/rkisp1/data/ov5640.yaml
+++ b/src/ipa/rkisp1/data/ov5640.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - Agc:
   - Awb:
diff --git a/src/ipa/rkisp1/data/ov5695.yaml b/src/ipa/rkisp1/data/ov5695.yaml
index 2e39e3a59b3f..7955463cb417 100644
--- a/src/ipa/rkisp1/data/ov5695.yaml
+++ b/src/ipa/rkisp1/data/ov5695.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - Agc:
   - Awb:
diff --git a/src/ipa/rkisp1/data/ov8858.yaml b/src/ipa/rkisp1/data/ov8858.yaml
index f297b0e0e8d2..0401d420102f 100644
--- a/src/ipa/rkisp1/data/ov8858.yaml
+++ b/src/ipa/rkisp1/data/ov8858.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - Agc:
   - Awb:
diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index 79ab7338c140..bc200c603361 100644
--- a/src/ipa/rkisp1/rkisp1.cpp
+++ b/src/ipa/rkisp1/rkisp1.cpp
@@ -181,9 +181,11 @@  int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,
 		return -EINVAL;
 
 	unsigned int version = (*data)["version"].get<uint32_t>(0);
-	if (version != 1) {
+	if (version != 2) {
 		LOG(IPARkISP1, Error)
-			<< "Invalid tuning file version " << version;
+			<< "The tuning file " << settings.configurationFile
+			<< " is version " << version
+			<< " but version 2 is required";
 		return -EINVAL;
 	}
 
diff --git a/src/ipa/softisp/data/uncalibrated.yaml b/src/ipa/softisp/data/uncalibrated.yaml
index fc90ca526eab..f7a8144f12af 100644
--- a/src/ipa/softisp/data/uncalibrated.yaml
+++ b/src/ipa/softisp/data/uncalibrated.yaml
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: CC0-1.0
 %YAML 1.1
 ---
-version: 1
+version: 2
 algorithms:
   - BlackLevel:
   - Awb:
diff --git a/src/ipa/softisp/softisp.cpp b/src/ipa/softisp/softisp.cpp
index 00249a300430..1b7de1ed5f64 100644
--- a/src/ipa/softisp/softisp.cpp
+++ b/src/ipa/softisp/softisp.cpp
@@ -129,6 +129,14 @@  int IPASoftIsp::init(const IPASettings &settings,
 	unsigned int version = (*data)["version"].get<uint32_t>(0);
 	LOG(IPASoftIsp, Debug) << "Tuning file version " << version;
 
+	if (version != 2) {
+		LOG(IPASoftIsp, Error)
+			<< "The tuning file " << settings.configurationFile
+			<< " is version " << version
+			<< " but version 2 is required";
+		return -EINVAL;
+	}
+
 	if (!data->contains("algorithms")) {
 		LOG(IPASoftIsp, Error) << "Tuning file doesn't contain algorithms";
 		return -EINVAL;
diff --git a/utils/tuning/libtuning/generators/yaml_output.py b/utils/tuning/libtuning/generators/yaml_output.py
index c490081d7de7..2da122e5ec17 100644
--- a/utils/tuning/libtuning/generators/yaml_output.py
+++ b/utils/tuning/libtuning/generators/yaml_output.py
@@ -99,10 +99,10 @@  class YamlOutput(Generator):
         out_lines = [
             '%YAML 1.1',
             '---',
-            'version: 1',
+            'version: 2',
             # No need to condition this, as libtuning already guarantees that
             # we have at least one module. Even if the module has no output,
-            # its prescence is meaningful.
+            # its presence is meaningful.
             'algorithms:'
         ]