From patchwork Tue Feb 5 00:06:58 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: 506 X-Patchwork-Delegate: niklas.soderlund@ragnatech.se Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7068E60DC2 for ; Tue, 5 Feb 2019 01:07:56 +0100 (CET) X-Halon-ID: 14d7db0e-28da-11e9-b530-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from localhost.localdomain (unknown [81.164.19.127]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 14d7db0e-28da-11e9-b530-005056917a89; Tue, 05 Feb 2019 01:07:53 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Feb 2019 01:06:58 +0100 Message-Id: <20190205000702.15370-4-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190205000702.15370-1-niklas.soderlund@ragnatech.se> References: <20190205000702.15370-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 3/7] libcamera: camera: implement start and stop of a camera 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: Tue, 05 Feb 2019 00:07:56 -0000 Add an interface for the application to start and stop a camera. Once a camera is started the pipeline handler of the camera will begin processing request queued to the camera by the application until it's stopped. Signed-off-by: Niklas Söderlund --- include/libcamera/camera.h | 4 ++++ src/libcamera/camera.cpp | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 4940c344440e2ca2..de338c616641c074 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -15,6 +15,7 @@ namespace libcamera { +class Buffer; class PipelineHandler; class Stream; class StreamConfiguration; @@ -41,6 +42,9 @@ public: streamConfiguration(std::vector &streams); int configureStreams(std::map &config); + int start(); + int stop(); + private: Camera(PipelineHandler *pipe, const std::string &name); ~Camera(); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index bcf3d54ab1c3eb29..bf09acfdb9cd0007 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include "log.h" @@ -248,4 +249,51 @@ int Camera::configureStreams(std::map &config) return pipe_->configureStreams(this, config); } +/** + * \brief Start capture from camera + * + * Start the camera capture session. Once the camera is started the application + * can queue requests to the camera to process and return to the application + * until the capture session is terminated with \a stop(). + * + * \return 0 on success or a negative error code on error. + * \retval -ENODEV The camera is not connected to any hardware + * \retval -EACCES The user has not acquired exclusive access to the camera + */ +int Camera::start() +{ + if (disconnected_) + return -ENODEV; + + if (!acquired_) + return -EACCES; + + return pipe_->start(this); +} + +/** + * \brief Stop capture from camera + * + * Stop the running capture session. Once the camera is stooped the may not + * queue any new requests and any already queued requests might that have not + * been queued to the hardware might be returned to the application not + * fulfilled. + * + * \return 0 on success or a negative error code on error. + * \retval -ENODEV The camera is not connected to any hardware + * \retval -EACCES The user has not acquired exclusive access to the camera + */ +int Camera::stop() +{ + if (disconnected_) + return -ENODEV; + + if (!acquired_) + return -EACCES; + + pipe_->stop(this); + + return 0; +} + } /* namespace libcamera */