From patchwork Sat May 10 14:12:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 23359 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id AC4B8C3226 for ; Sat, 10 May 2025 14:12:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6CA0A68B6F; Sat, 10 May 2025 16:12:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="FzHkZDR1"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0126A68B6E for ; Sat, 10 May 2025 16:12:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746886365; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=++/VEgWw8B32Yd9HvFe7+lB5JQrsALJ1AyoyckTnUDY=; b=FzHkZDR1cb49pBFshtVwybmNyYwVcXTpK9VS0ZY5P2wdFcWHFOFIDreUeytrgFtT9084zL f8XYc8L83fpHKGn11reafUPLH1EqKd+ey2T0R6niiGOCs2qVjJepn/BMcWsdgQeRpVH6KA DpRQ+ZQOP+EHDupJkZVsstlmOH+MYOw= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-371-oPKHrd4POkiYi7nwJ7B86Q-1; Sat, 10 May 2025 10:12:43 -0400 X-MC-Unique: oPKHrd4POkiYi7nwJ7B86Q-1 X-Mimecast-MFC-AGG-ID: oPKHrd4POkiYi7nwJ7B86Q_1746886362 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3682B180035F for ; Sat, 10 May 2025 14:12:42 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.224.58]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DE9BE1800359; Sat, 10 May 2025 14:12:40 +0000 (UTC) From: Hans de Goede To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Hans de Goede Subject: [PATCH v2 7/8] libcamera: ipa_manager: createIPA: Allow matching by IPA 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-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Parts of the software ISP and the ipa_soft_simple.so IPA may be useful for more then 1 pipeline handler. Currently createIPA() / IPAManager::module() assume that there is a 1:1 relationship between pipeline handlers and IPAs and IPA matching is done based on matching the pipe to ipaModuleInfo.pipelineName[]. One way to allow using a single IPA with multiple pipelines would be to allow the IPA to declare itself compatible with more then one pipeline, turning ipaModuleInfo.pipelineName[] into e.g. a vector. But the way ipaModuleInfo is loaded as an ELF symbol requires it to be a simple flat C-struct. Instead add an optional ipaName argument to createIPA() which when set switches things over to matching ipaModuleInfo.name[] allowing pipelines to request a specific shared IPA module this way. Signed-off-by: Hans de Goede Reviewed-by: Kieran Bingham --- include/libcamera/internal/ipa_manager.h | 7 ++++--- include/libcamera/internal/ipa_module.h | 4 ++-- src/libcamera/ipa_manager.cpp | 6 ++++-- src/libcamera/ipa_module.cpp | 19 +++++++++++++------ 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h index a0d448cf..af784c9c 100644 --- a/include/libcamera/internal/ipa_manager.h +++ b/include/libcamera/internal/ipa_manager.h @@ -34,11 +34,12 @@ public: template static std::unique_ptr createIPA(PipelineHandler *pipe, uint32_t minVersion, - uint32_t maxVersion) + uint32_t maxVersion, + const char *ipaName = NULL) { CameraManager *cm = pipe->cameraManager(); IPAManager *self = cm->_d()->ipaManager(); - IPAModule *m = self->module(pipe, minVersion, maxVersion); + IPAModule *m = self->module(pipe, minVersion, maxVersion, ipaName); if (!m) return nullptr; @@ -64,7 +65,7 @@ private: unsigned int addDir(const char *libDir, unsigned int maxDepth = 0); IPAModule *module(PipelineHandler *pipe, uint32_t minVersion, - uint32_t maxVersion); + uint32_t maxVersion, const char *ipaName); bool isSignatureValid(IPAModule *ipa) const; diff --git a/include/libcamera/internal/ipa_module.h b/include/libcamera/internal/ipa_module.h index 15f19492..e7b00fdb 100644 --- a/include/libcamera/internal/ipa_module.h +++ b/include/libcamera/internal/ipa_module.h @@ -36,8 +36,8 @@ public: IPAInterface *createInterface(); - bool match(PipelineHandler *pipe, - uint32_t minVersion, uint32_t maxVersion) const; + bool match(PipelineHandler *pipe, uint32_t minVersion, + uint32_t maxVersion, const char *ipaName = NULL) const; protected: std::string logPrefix() const override; diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 830750dc..2ef8b98e 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -240,12 +240,13 @@ unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth) * \param[in] pipe The pipeline handler * \param[in] minVersion Minimum acceptable version of IPA module * \param[in] maxVersion Maximum acceptable version of IPA module + * \param[in] ipaName If set match IPA module by this name instead of by pipe */ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion, - uint32_t maxVersion) + uint32_t maxVersion, const char *ipaName) { for (const auto &module : modules_) { - if (module->match(pipe, minVersion, maxVersion)) + if (module->match(pipe, minVersion, maxVersion, ipaName)) return module.get(); } @@ -258,6 +259,7 @@ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion, * \param[in] pipe The pipeline handler that wants a matching IPA proxy * \param[in] minVersion Minimum acceptable version of IPA module * \param[in] maxVersion Maximum acceptable version of IPA module + * \param[in] ipaName If set match IPA module by this name instead of by pipe * * \return A newly created IPA proxy, or nullptr if no matching IPA module is * found or if the IPA proxy fails to initialize diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index e6ea61e4..b7004b1c 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -466,18 +466,25 @@ IPAInterface *IPAModule::createInterface() * \param[in] pipe Pipeline handler to match with * \param[in] minVersion Minimum acceptable version of IPA module * \param[in] maxVersion Maximum acceptable version of IPA module + * \param[in] ipaName If set match IPA module by this name instead of by pipe * * This function checks if this IPA module matches the \a pipe pipeline handler, - * and the input version range. + * and the input version range. If \a ipaName is non-null then the IPA module + * name is matched against \a ipaName instead of matching \a pipe. * * \return True if the pipeline handler matches the IPA module, or false otherwise */ -bool IPAModule::match(PipelineHandler *pipe, - uint32_t minVersion, uint32_t maxVersion) const +bool IPAModule::match(PipelineHandler *pipe, uint32_t minVersion, + uint32_t maxVersion, const char *ipaName) const { - return info_.pipelineVersion >= minVersion && - info_.pipelineVersion <= maxVersion && - !strcmp(info_.pipelineName, pipe->name()); + if (info_.pipelineVersion < minVersion || + info_.pipelineVersion > maxVersion) + return false; + + if (ipaName) + return !strcmp(info_.name, ipaName); + else + return !strcmp(info_.pipelineName, pipe->name()); } std::string IPAModule::logPrefix() const