From patchwork Wed May 8 15:18:30 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: 1175 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E35360E66 for ; Wed, 8 May 2019 17:18:58 +0200 (CEST) X-Halon-ID: 98b4a296-71a4-11e9-8fa2-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from localhost.localdomain (unknown [79.138.136.66]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 98b4a296-71a4-11e9-8fa2-005056917a89; Wed, 08 May 2019 17:18:56 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 8 May 2019 17:18:30 +0200 Message-Id: <20190508151831.12274-11-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190508151831.12274-1-niklas.soderlund@ragnatech.se> References: <20190508151831.12274-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 10/11] libcamera: pipeline_handler: Add functions to lock a whole pipeline 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, 08 May 2019 15:18:58 -0000 Add lock() and unlock() which backed by the MediaDevice implementation can will lock all media devices claimed by a pipeline handler instance. Signed-off-by: Niklas Söderlund --- src/libcamera/include/pipeline_handler.h | 3 ++ src/libcamera/pipeline_handler.cpp | 38 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 4c13496246c2251c..019c8f4751a8c2b2 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -57,6 +57,9 @@ public: MediaDevice *tryAcquire(DeviceEnumerator *enumerator, const DeviceMatch &dm); + bool lock(); + void unlock(); + virtual CameraConfiguration streamConfiguration(Camera *camera, const std::vector &usages) = 0; virtual int configureStreams(Camera *camera, const CameraConfiguration &config) = 0; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 8f50ef51f0c23301..6aa6c6ede49beb12 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -182,6 +182,44 @@ out: return media.get(); } +/** + * \brief Lock all media devices acquired by the pipeline + * + * This method shall not be called from a pipeline handler implementation + * directly, as the Camera handles this on the behalf of the specified + * implementation. + * + * \return True if the devices could be locked, false otherwise + * \sa unlock() + * \sa MediaDevice::lock() + */ +bool PipelineHandler::lock() +{ + for (std::shared_ptr media : mediaDevices_) { + if (!media->lock()) { + unlock(); + return false; + } + } + + return true; +} + +/** + * \brief Unlock all media devices acquired by the pipeline + * + * This method shall not be called from a pipeline handler implementation + * directly, as the Camera handles this on the behalf of the specified + * implementation. + * + * \sa lock() + */ +void PipelineHandler::unlock() +{ + for (std::shared_ptr media : mediaDevices_) + media->unlock(); +} + /** * \fn PipelineHandler::streamConfiguration() * \brief Retrieve a group of stream configurations for a specified camera