From patchwork Wed Aug 28 01:16:59 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: 1867 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 677AF60C10 for ; Wed, 28 Aug 2019 03:17:37 +0200 (CEST) X-Halon-ID: 953a03c8-c931-11e9-bdc3-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [95.195.154.80]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 953a03c8-c931-11e9-bdc3-005056917a89; Wed, 28 Aug 2019 03:17:21 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Aug 2019 03:16:59 +0200 Message-Id: <20190828011710.32128-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20190828011710.32128-1-niklas.soderlund@ragnatech.se> References: <20190828011710.32128-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 02/13] libcamera: pipeline: Move IPA from pipeline to camera data X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 01:17:37 -0000 The IPA acts on a camera and not on a pipeline which can expose more then once 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 Reviewed-by: Kieran Bingham --- src/libcamera/include/pipeline_handler.h | 12 ++++++-- src/libcamera/pipeline/vimc.cpp | 10 +----- src/libcamera/pipeline_handler.cpp | 39 +++++++++++++++++++++++- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 1fdef9cea40f1f0a..ffc7adb802215313 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -15,6 +15,7 @@ #include #include +#include #include namespace libcamera { @@ -33,8 +34,11 @@ class Request; class CameraData { public: - explicit CameraData(PipelineHandler *pipe) - : pipe_(pipe) + explicit CameraData(PipelineHandler *pipe, + uint32_t minIPAVersion = 0, + uint32_t maxIPAVersion = 0) + : pipe_(pipe), ipa_(nullptr), minIPAVersion_(minIPAVersion), + maxIPAVersion_(maxIPAVersion) { } virtual ~CameraData() {} @@ -44,6 +48,10 @@ public: std::list queuedRequests_; ControlInfoMap controlInfo_; + std::unique_ptr ipa_; + const uint32_t minIPAVersion_; + const uint32_t maxIPAVersion_; + private: CameraData(const CameraData &) = delete; CameraData &operator=(const CameraData &) = delete; diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index e5c4890501db71c8..be6507cd4bc0d1b9 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -38,7 +38,7 @@ class VimcCameraData : public CameraData { public: VimcCameraData(PipelineHandler *pipe) - : CameraData(pipe), sensor_(nullptr), debayer_(nullptr), + : CameraData(pipe, 1, 1), sensor_(nullptr), debayer_(nullptr), scaler_(nullptr), video_(nullptr), raw_(nullptr) { } @@ -100,8 +100,6 @@ private: return static_cast( PipelineHandler::cameraData(camera)); } - - std::unique_ptr ipa_; }; VimcCameraConfiguration::VimcCameraConfiguration() @@ -361,12 +359,6 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) if (!media) return false; - ipa_ = IPAManager::instance()->createIPA(this, 1, 1); - 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..89b67806597728f9 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" @@ -49,13 +50,20 @@ LOG_DEFINE_CATEGORY(Pipeline) */ /** - * \fn CameraData::CameraData(PipelineHandler *pipe) + * \fn CameraData::CameraData(PipelineHandler *pipe, uint32_t minIPAVersion, + * uint32_t maxIPAVersion) * \brief Construct a CameraData instance for the given pipeline handler * \param[in] pipe The pipeline handler + * \param[in] minIPAVersion Minimum acceptable version of IPA module + * \param[in] maxIPAVersion Maximum acceptable version of IPA module * * The reference to the pipeline handler is stored internally, the caller shall * guarantee that the pointer remains valid as long as the CameraData instance * exists. + * + * The IPA maximum and minimum version numbers are used to match with an IPA + * interface that would be compatible with the Camera. If no IPA interface + * is needed for the camera both parameters should be set to 0. */ /** @@ -96,6 +104,24 @@ 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 IPA are in operation this should be set to nullptr. + */ + +/** + * \var CameraData::minIPAVersion_ + * \brief Minimum acceptable version of IPA module + */ + +/** + * \var CameraData::maxIPAVersion_ + * \brief Maximum acceptable version of IPA module + */ + /** * \class PipelineHandler * \brief Create and manage cameras based on a set of media devices @@ -424,6 +450,17 @@ void PipelineHandler::completeRequest(Camera *camera, Request *request) void PipelineHandler::registerCamera(std::shared_ptr camera, std::unique_ptr data) { + if (data->minIPAVersion_ || data->maxIPAVersion_) { + data->ipa_ = IPAManager::instance()->createIPA(this, + data->minIPAVersion_, + data->maxIPAVersion_); + if (!data->ipa_) { + LOG(Pipeline, Warning) << "Skipping " << camera->name() + << " no IPA found"; + return; + } + } + data->camera_ = camera.get(); cameraData_[camera.get()] = std::move(data); cameras_.push_back(camera);