{"id":23359,"url":"https://patchwork.libcamera.org/api/patches/23359/?format=json","web_url":"https://patchwork.libcamera.org/patch/23359/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250510141220.54872-8-hdegoede@redhat.com>","date":"2025-05-10T14:12:19","name":"[v2,7/8] libcamera: ipa_manager: createIPA: Allow matching by IPA name instead of by pipeline","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"c0979abd8edc87075b3922f0412601def0ffbf51","submitter":{"id":102,"url":"https://patchwork.libcamera.org/api/people/102/?format=json","name":"Hans de Goede","email":"hdegoede@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23359/mbox/","series":[{"id":5169,"url":"https://patchwork.libcamera.org/api/series/5169/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5169","date":"2025-05-10T14:12:12","name":"libcamera: Add swstats_cpu::processFrame() and atomisp pipeline handler","version":2,"mbox":"https://patchwork.libcamera.org/series/5169/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23359/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23359/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id AC4B8C3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 10 May 2025 14:12:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6CA0A68B6F;\n\tSat, 10 May 2025 16:12:48 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0126A68B6E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 10 May 2025 16:12:45 +0200 (CEST)","from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-371-oPKHrd4POkiYi7nwJ7B86Q-1;\n\tSat, 10 May 2025 10:12:43 -0400","from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.93])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS\n\tid 3682B180035F for <libcamera-devel@lists.libcamera.org>;\n\tSat, 10 May 2025 14:12:42 +0000 (UTC)","from localhost.localdomain (unknown [10.45.224.58])\n\tby mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id DE9BE1800359; Sat, 10 May 2025 14:12:40 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"FzHkZDR1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1746886365;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=++/VEgWw8B32Yd9HvFe7+lB5JQrsALJ1AyoyckTnUDY=;\n\tb=FzHkZDR1cb49pBFshtVwybmNyYwVcXTpK9VS0ZY5P2wdFcWHFOFIDreUeytrgFtT9084zL\n\tf8XYc8L83fpHKGn11reafUPLH1EqKd+ey2T0R6niiGOCs2qVjJepn/BMcWsdgQeRpVH6KA\n\tDpRQ+ZQOP+EHDupJkZVsstlmOH+MYOw=","X-MC-Unique":"oPKHrd4POkiYi7nwJ7B86Q-1","X-Mimecast-MFC-AGG-ID":"oPKHrd4POkiYi7nwJ7B86Q_1746886362","From":"Hans de Goede <hdegoede@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>, Hans de Goede <hdegoede@redhat.com>","Subject":"[PATCH v2 7/8] libcamera: ipa_manager: createIPA: Allow matching by\n\tIPA name instead of by pipeline","Date":"Sat, 10 May 2025 16:12:19 +0200","Message-ID":"<20250510141220.54872-8-hdegoede@redhat.com>","In-Reply-To":"<20250510141220.54872-1-hdegoede@redhat.com>","References":"<20250510141220.54872-1-hdegoede@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.93","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"onu6OcFFOPz2cAyaDukJp8CrIktC-WMXAdvi78SpCVQ_1746886362","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Parts of the software ISP and the ipa_soft_simple.so IPA may be useful for\nmore then 1 pipeline handler.\n\nCurrently createIPA() / IPAManager::module() assume that there is a 1:1\nrelationship between pipeline handlers and IPAs and IPA matching is done\nbased on matching the pipe to ipaModuleInfo.pipelineName[].\n\nOne way to allow using a single IPA with multiple pipelines would be to\nallow the IPA to declare itself compatible with more then one pipeline,\nturning ipaModuleInfo.pipelineName[] into e.g. a vector. But the way\nipaModuleInfo is loaded as an ELF symbol requires it to be a simple flat\nC-struct.\n\nInstead add an optional ipaName argument to createIPA() which when set\nswitches things over to matching ipaModuleInfo.name[] allowing pipelines\nto request a specific shared IPA module this way.\n\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n---\n include/libcamera/internal/ipa_manager.h |  7 ++++---\n include/libcamera/internal/ipa_module.h  |  4 ++--\n src/libcamera/ipa_manager.cpp            |  6 ++++--\n src/libcamera/ipa_module.cpp             | 19 +++++++++++++------\n 4 files changed, 23 insertions(+), 13 deletions(-)","diff":"diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h\nindex a0d448cf..af784c9c 100644\n--- a/include/libcamera/internal/ipa_manager.h\n+++ b/include/libcamera/internal/ipa_manager.h\n@@ -34,11 +34,12 @@ public:\n \ttemplate<typename T>\n \tstatic std::unique_ptr<T> createIPA(PipelineHandler *pipe,\n \t\t\t\t\t    uint32_t minVersion,\n-\t\t\t\t\t    uint32_t maxVersion)\n+\t\t\t\t\t    uint32_t maxVersion,\n+\t\t\t\t\t    const char *ipaName = NULL)\n \t{\n \t\tCameraManager *cm = pipe->cameraManager();\n \t\tIPAManager *self = cm->_d()->ipaManager();\n-\t\tIPAModule *m = self->module(pipe, minVersion, maxVersion);\n+\t\tIPAModule *m = self->module(pipe, minVersion, maxVersion, ipaName);\n \t\tif (!m)\n \t\t\treturn nullptr;\n \n@@ -64,7 +65,7 @@ private:\n \tunsigned int addDir(const char *libDir, unsigned int maxDepth = 0);\n \n \tIPAModule *module(PipelineHandler *pipe, uint32_t minVersion,\n-\t\t\t  uint32_t maxVersion);\n+\t\t\t  uint32_t maxVersion, const char *ipaName);\n \n \tbool isSignatureValid(IPAModule *ipa) const;\n \ndiff --git a/include/libcamera/internal/ipa_module.h b/include/libcamera/internal/ipa_module.h\nindex 15f19492..e7b00fdb 100644\n--- a/include/libcamera/internal/ipa_module.h\n+++ b/include/libcamera/internal/ipa_module.h\n@@ -36,8 +36,8 @@ public:\n \n \tIPAInterface *createInterface();\n \n-\tbool match(PipelineHandler *pipe,\n-\t\t   uint32_t minVersion, uint32_t maxVersion) const;\n+\tbool match(PipelineHandler *pipe, uint32_t minVersion,\n+\t\t   uint32_t maxVersion, const char *ipaName = NULL) const;\n \n protected:\n \tstd::string logPrefix() const override;\ndiff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\nindex 830750dc..2ef8b98e 100644\n--- a/src/libcamera/ipa_manager.cpp\n+++ b/src/libcamera/ipa_manager.cpp\n@@ -240,12 +240,13 @@ unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth)\n  * \\param[in] pipe The pipeline handler\n  * \\param[in] minVersion Minimum acceptable version of IPA module\n  * \\param[in] maxVersion Maximum acceptable version of IPA module\n+ * \\param[in] ipaName If set match IPA module by this name instead of by pipe\n  */\n IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion,\n-\t\t\t      uint32_t maxVersion)\n+\t\t\t      uint32_t maxVersion, const char *ipaName)\n {\n \tfor (const auto &module : modules_) {\n-\t\tif (module->match(pipe, minVersion, maxVersion))\n+\t\tif (module->match(pipe, minVersion, maxVersion, ipaName))\n \t\t\treturn module.get();\n \t}\n \n@@ -258,6 +259,7 @@ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion,\n  * \\param[in] pipe The pipeline handler that wants a matching IPA proxy\n  * \\param[in] minVersion Minimum acceptable version of IPA module\n  * \\param[in] maxVersion Maximum acceptable version of IPA module\n+ * \\param[in] ipaName If set match IPA module by this name instead of by pipe\n  *\n  * \\return A newly created IPA proxy, or nullptr if no matching IPA module is\n  * found or if the IPA proxy fails to initialize\ndiff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp\nindex e6ea61e4..b7004b1c 100644\n--- a/src/libcamera/ipa_module.cpp\n+++ b/src/libcamera/ipa_module.cpp\n@@ -466,18 +466,25 @@ IPAInterface *IPAModule::createInterface()\n  * \\param[in] pipe Pipeline handler to match with\n  * \\param[in] minVersion Minimum acceptable version of IPA module\n  * \\param[in] maxVersion Maximum acceptable version of IPA module\n+ * \\param[in] ipaName If set match IPA module by this name instead of by pipe\n  *\n  * This function checks if this IPA module matches the \\a pipe pipeline handler,\n- * and the input version range.\n+ * and the input version range. If \\a ipaName is non-null then the IPA module\n+ * name is matched against \\a ipaName instead of matching \\a pipe.\n  *\n  * \\return True if the pipeline handler matches the IPA module, or false otherwise\n  */\n-bool IPAModule::match(PipelineHandler *pipe,\n-\t\t      uint32_t minVersion, uint32_t maxVersion) const\n+bool IPAModule::match(PipelineHandler *pipe, uint32_t minVersion,\n+\t\t      uint32_t maxVersion, const char *ipaName) const\n {\n-\treturn info_.pipelineVersion >= minVersion &&\n-\t       info_.pipelineVersion <= maxVersion &&\n-\t       !strcmp(info_.pipelineName, pipe->name());\n+\tif (info_.pipelineVersion < minVersion ||\n+\t    info_.pipelineVersion > maxVersion)\n+\t\treturn false;\n+\n+\tif (ipaName)\n+\t\treturn !strcmp(info_.name, ipaName);\n+\telse\n+\t\treturn !strcmp(info_.pipelineName, pipe->name());\n }\n \n std::string IPAModule::logPrefix() const\n","prefixes":["v2","7/8"]}