[v3,4/4] ipa: Allow pipelines to have differently named IPA
diff mbox series

Message ID 20251015-ipa-match-by-name-v3-4-11f9c774c7fc@ideasonboard.com
State New
Headers show
Series
  • ipa: Allow IPA creation by name
Related show

Commit Message

Jacopo Mondi Oct. 15, 2025, 3:55 p.m. UTC
Right now the build system assumes a 1-to-1 matching between a pipeline
handler name and an IPA module.

This, as also acknowledged by a \todo comment, is quite a rigid
requirement and only allows a 1-to-1 matching between pipeline and IPA
names. The more platforms libcamera supports, the more it is likely that
a pipeline handler could re-use an IPA module. This is particularly
relevant for the softISP IPA module which could theoretically be plugged
to any pipeline. Likewise, the forthcoming R-Car Gen4 support uses the
RkISP1 IPA and at the moment would require building the 'rkisp1'
pipeline in to have the IPA module available.

When building IPAs, the build system iterates the list of enabled
pipeline handlers and for each of them tries to verify if the 'ipas'
list contains a corresponding entry for it. The 'ipas' meson options is
an array option and, as no default value is specified for it, it
contains by default all its possible choices.

In this way if no value is specified for the 'ipas' option, compiling
the pipeline handlers ['X','Y', 'Z'] will compile the ['X', 'Y', 'Z']
IPAs. If instead the user specifies '-Dipas=X' during the configuration
then only IPA module ['X'] will be built, regardless of which pipeline is
enabled. Building an IPA module will anyway require to build a
corresponding pipeline with the same name.

Relax the 1-to-1 'pipeline'-'IPA' naming requirement by introducing a
dictionary that associates pipelines with IPA modules.

For each enabled pipeline:
1) Make sure an IPA module exists for it
2) Make sure the IPA module is enabled by the 'ipas' option
3) Make sure the IPA is compiled once only

This will require every new pipeline to add an entry to the dictionary
and specify which IPA module they would like to use.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/meson.build | 40 ++++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/meson.build b/src/ipa/meson.build
index eb7846e47888d4056b81e4a68f1903f134e6a662..c583c7efdd35170ab31d92fd8347ecdceaba5a31 100644
--- a/src/ipa/meson.build
+++ b/src/ipa/meson.build
@@ -24,6 +24,16 @@  subdir('libipa')
 
 ipa_sign = files('ipa-sign.sh')
 
+supported_ipas = {
+    'ipu3':       'ipu3',
+    'mali-c55':   'mali-c55',
+    'rkisp1':     'rkisp1',
+    'rpi/pisp':   'rpi/pisp',
+    'rpi/vc4':    'rpi/vc4',
+    'simple':     'simple',
+    'vimc':       'vimc'
+}
+
 ipa_modules = get_option('ipas')
 
 # Tests require the vimc IPA, similar to vimc pipline-handler for their
@@ -39,24 +49,34 @@  ipa_names = []
 
 subdirs = []
 foreach pipeline : pipelines
-    # The current implementation expects the IPA module name to match the
-    # pipeline name.
-    # \todo Make the IPA naming scheme more flexible.
-    if not ipa_modules.contains(pipeline)
+    # Make sure an IPA exists for the pipeline
+    if not supported_ipas.has_key(pipeline)
+        continue
+    endif
+
+    ipa = supported_ipas.get(pipeline)
+
+    # Only build IPAs specified with '-Dipas'
+    if not ipa_modules.contains(ipa)
+        continue
+    endif
+
+    # If enabled already do not add it twice
+    if enabled_ipa_names.contains(ipa)
         continue
     endif
-    enabled_ipa_names += pipeline
+    enabled_ipa_names += ipa
 
     # Allow multi-level directory structuring for the IPAs if needed.
-    pipeline = pipeline.split('/')[0]
-    if pipeline in subdirs
+    ipa = ipa.split('/')[0]
+    if ipa in subdirs
         continue
     endif
 
-    subdirs += pipeline
-    subdir(pipeline)
+    subdirs += ipa
+    subdir(ipa)
 
-    # Don't reuse the pipeline variable below, the subdirectory may have
+    # Don't reuse the ipa variable below, the subdirectory may have
     # overwritten it.
 endforeach