From patchwork Fri Sep 27 02:44:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 2025 Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F2F95616FF for ; Fri, 27 Sep 2019 04:45:24 +0200 (CEST) X-Halon-ID: cba09546-e0d0-11e9-bdc3-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [84.172.88.101]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id cba09546-e0d0-11e9-bdc3-005056917a89; Fri, 27 Sep 2019 04:44:59 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Sep 2019 04:44:05 +0200 Message-Id: <20190927024417.725906-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190927024417.725906-1-niklas.soderlund@ragnatech.se> References: <20190927024417.725906-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 01/13] libcamera: pipeline: Move IPA from pipeline to camera data 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: , X-List-Received-Date: Fri, 27 Sep 2019 02:45:25 -0000 The IPA acts on a camera and not on a pipeline which can expose more then one camera. Move the IPA reference to the CameraData and move the loading of an IPA from the specific pipeline handler implementation to base PipelineHandler. It's still possible to expose a camera without an IPA but if an IPA is request the camera is not valid and will not be registered in the system if a suiting IPA module can't be found. Signed-off-by: Niklas Söderlund --- src/libcamera/include/pipeline_handler.h | 4 +++ src/libcamera/pipeline/vimc.cpp | 17 ++++++------ src/libcamera/pipeline_handler.cpp | 33 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 1fdef9cea40f1f0a..4400c7ed835f551d 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -39,10 +40,13 @@ public: } virtual ~CameraData() {} + virtual int loadIPA() { return 0; }; + Camera *camera_; PipelineHandler *pipe_; std::list queuedRequests_; ControlInfoMap controlInfo_; + std::unique_ptr ipa_; private: CameraData(const CameraData &) = delete; diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index f26a91f86ec1794c..2fa48586fea0b80e 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -52,6 +52,15 @@ public: delete raw_; } + int loadIPA() override + { + ipa_ = IPAManager::instance()->createIPA(pipe_, 0, 0); + if (!ipa_) + return -ENOENT; + + return 0; + } + int init(MediaDevice *media); void bufferReady(Buffer *buffer); @@ -100,8 +109,6 @@ private: return static_cast( PipelineHandler::cameraData(camera)); } - - std::unique_ptr ipa_; }; VimcCameraConfiguration::VimcCameraConfiguration() @@ -361,12 +368,6 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) if (!media) return false; - ipa_ = IPAManager::instance()->createIPA(this, 0, 0); - if (ipa_ == nullptr) - LOG(VIMC, Warning) << "no matching IPA found"; - else - ipa_->init(); - std::unique_ptr data = utils::make_unique(this); /* Locate and open the capture video node. */ diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 3e54aa23d92b9a36..b8a3787e10a587b5 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -12,6 +12,7 @@ #include #include "device_enumerator.h" +#include "ipa_manager.h" #include "log.h" #include "media_device.h" #include "utils.h" @@ -58,6 +59,20 @@ LOG_DEFINE_CATEGORY(Pipeline) * exists. */ +/** + * \fn CameraData::loadIPA() + * \brief Load an IPA for the camera + * + * This function shall be implemented by pipeline handlers that wish to have an + * IPA. The function must locate and load an IPA, storing a pointer to it in + * the \a ipa_ or fail. + * + * If the pipeline handler do not wish to use an IPA this function shall not + * be implemented. + * + * \return True if a IPA could be loaded, false otherwise + */ + /** * \var CameraData::camera_ * \brief The camera related to this CameraData instance @@ -96,6 +111,14 @@ LOG_DEFINE_CATEGORY(Pipeline) * creating the camera, and shall not be modified afterwards. */ +/** + * \var CameraData::ipa_ + * \brief The IPA module used by the camera + * + * Reference to the Image Processing Algorithms (IPA) operating on the camera's + * stream(s). If no IPAs are in operation this should be set to nullptr. + */ + /** * \class PipelineHandler * \brief Create and manage cameras based on a set of media devices @@ -425,6 +448,16 @@ void PipelineHandler::registerCamera(std::shared_ptr camera, std::unique_ptr data) { data->camera_ = camera.get(); + + if (data->loadIPA()) { + LOG(Pipeline, Warning) << "Skipping " << camera->name() + << " no IPA found"; + return; + } + + if (data->ipa_) + data->ipa_->init(); + cameraData_[camera.get()] = std::move(data); cameras_.push_back(camera); manager_->addCamera(std::move(camera));