From patchwork Thu Aug 1 15:54:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 1722 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3BFDC615DF for ; Thu, 1 Aug 2019 17:53:05 +0200 (CEST) X-Originating-IP: 82.58.19.211 Received: from uno.homenet.telecomitalia.it (host211-19-dynamic.58-82-r.retail.telecomitalia.it [82.58.19.211]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 96B9EE0009; Thu, 1 Aug 2019 15:53:04 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Aug 2019 17:54:16 +0200 Message-Id: <20190801155420.24694-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190801155420.24694-1-jacopo@jmondi.org> References: <20190801155420.24694-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] libcamera: camera: Make camera state accessible 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: Thu, 01 Aug 2019 15:53:05 -0000 Make the Camera state accessible by providing an accessor operation and moving the State enumeration definition in the public scope. Signed-off-by: Jacopo Mondi --- include/libcamera/camera.h | 16 +++++++++------- src/libcamera/camera.cpp | 33 +++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 21fac550f412..6e627943b3f1 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -66,6 +66,14 @@ protected: std::vector config_; }; +enum State { + CameraAvailable, + CameraAcquired, + CameraConfigured, + CameraPrepared, + CameraRunning, +}; + class Camera final : public std::enable_shared_from_this { public: @@ -77,6 +85,7 @@ public: Camera &operator=(const Camera &) = delete; const std::string &name() const; + State state() const { return state_; } Signal bufferCompleted; Signal &> requestCompleted; @@ -101,13 +110,6 @@ public: int stop(); private: - enum State { - CameraAvailable, - CameraAcquired, - CameraConfigured, - CameraPrepared, - CameraRunning, - }; Camera(PipelineHandler *pipe, const std::string &name); ~Camera(); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 76c737cb9381..e924c2085816 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -253,6 +253,21 @@ std::size_t CameraConfiguration::size() const * \brief The vector of stream configurations */ +/** + * \enum State + * \brief Describe the Camera state as defined in \ref camera_states + * \var State::CameraAvailable + * See \ref camera_available + * \var State::CameraAcquired + * See \ref camera_acquired + * \var State::CameraConfigured + * See \ref camera_configured + * \var State::CameraPrepared + * See \ref camera_prepared + * \var State::CameraRunning + * See \ref camera_running + */ + /** * \class Camera * \brief Camera device @@ -284,7 +299,7 @@ std::size_t CameraConfiguration::size() const * not released. The camera may also be reconfigured provided that all * resources allocated are freed prior to the reconfiguration. * - * \subsection Camera States + * \subsection camera_states Camera States * * To help manage the sequence of operations needed to control the camera a set * of states are defined. Each state describes which operations may be performed @@ -318,27 +333,27 @@ std::size_t CameraConfiguration::size() const * } * \enddot * - * \subsubsection Available + * \subsubsection camera_available Available * The base state of a camera, an application can inspect the properties of the * camera to determine if it wishes to use it. If an application wishes to use * a camera it should acquire() it to proceed to the Acquired state. * - * \subsubsection Acquired + * \subsubsection camera_acquired Acquired * In the acquired state an application has exclusive access to the camera and * may modify the camera's parameters to configure it and proceed to the * Configured state. * - * \subsubsection Configured + * \subsubsection camera_configured Configured * The camera is configured and ready for the application to prepare it with * resources. The camera may be reconfigured multiple times until resources * are provided and the state progresses to Prepared. * - * \subsubsection Prepared + * \subsubsection camera_prepared Prepared * The camera has been configured and provided with resources and is ready to be * started. The application may free the camera's resources to get back to the * Configured state or start() it to progress to the Running state. * - * \subsubsection Running + * \subsubsection camera_running Running * The camera is running and ready to process requests queued by the * application. The camera remains in this state until it is stopped and moved * to the Prepared state. @@ -380,6 +395,12 @@ const std::string &Camera::name() const return name_; } +/** + * \fn Camera::state() + * \brief Retrieve the current camera state as defined in \ref camera_states + * \return The current camera state + */ + /** * \var Camera::bufferCompleted * \brief Signal emitted when a buffer for a request queued to the camera has