From patchwork Fri May 17 00:54:46 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: 1215 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EDA1260E4C for ; Fri, 17 May 2019 02:55:15 +0200 (CEST) X-Halon-ID: 6e415324-783e-11e9-8d05-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 6e415324-783e-11e9-8d05-005056917f90; Fri, 17 May 2019 02:55:14 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 17 May 2019 02:54:46 +0200 Message-Id: <20190517005447.27171-11-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190517005447.27171-1-niklas.soderlund@ragnatech.se> References: <20190517005447.27171-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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: Fri, 17 May 2019 00:55:16 -0000 Add lock() and unlock() which are backed by the MediaDevice implementation and lock all media devices claimed by a pipeline handler instance. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/include/pipeline_handler.h | 3 ++ src/libcamera/pipeline_handler.cpp | 36 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 8e6a136dd4907d9f..9f5fe3d673e294c8 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -57,6 +57,9 @@ public: MediaDevice *acquireMediaDevice(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 c92ee782701f57bf..1eeaf4bb6dae8601 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -181,6 +181,42 @@ MediaDevice *PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator, return media.get(); } +/** + * \brief Lock all media devices acquired by the pipeline + * + * This method shall not be called from pipeline handler implementation, as the + * Camera class handles locking directly. + * + * \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 pipeline handler implementation, as the + * Camera class handles locking directly. + * + * \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