From patchwork Mon Jul 1 20:14:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1563 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AEB386157D for ; Mon, 1 Jul 2019 22:15:29 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 59CD51200 for ; Mon, 1 Jul 2019 22:15:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562012129; bh=SzGGUSuBzXMnb5DuPM1IX8QwlJlyjWsmnxEH5UUpnKo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bd0xx8FophDTEi98cmy000GWdIgEQV1SmeTHHqv/TJs82rc86+KR+SE/ILQiXPPp0 2h377Rrhizj4sUfNx+/w1gUTVKTJHQiAPc2ZMyXNYiKvbBicLnhhvLI1xx3DObZQiB BfXuQk730N1pibjrBfX7M3Ykz6JvsyLEagWhllfw= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Jul 2019 23:14:55 +0300 Message-Id: <20190701201504.28487-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190701201504.28487-1-laurent.pinchart@ideasonboard.com> References: <20190701201504.28487-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 04/13] libcamera: camera: Provide a list of ControlInfo 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: Mon, 01 Jul 2019 20:15:30 -0000 From: Kieran Bingham Extend the Camera class to expose the controls it supports. Each pipeline should generate a list of controls supported by each camera it creates. These are represented by a ControlInfoMap, and an associated ControlList of default values. Signed-off-by: Kieran Bingham Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- include/libcamera/camera.h | 3 +++ include/libcamera/controls.h | 2 ++ src/libcamera/camera.cpp | 12 ++++++++++++ src/libcamera/controls.cpp | 5 +++++ src/libcamera/include/pipeline_handler.h | 4 ++++ src/libcamera/pipeline_handler.cpp | 19 +++++++++++++++++++ 6 files changed, 45 insertions(+) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index fb2f7ba3423c..6d693d9a6c7a 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -83,6 +84,8 @@ public: int acquire(); int release(); + const ControlInfoMap &controls(); + const std::set &streams() const; std::unique_ptr generateConfiguration(const StreamRoles &roles); int configure(CameraConfiguration *config); diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 2206155909ca..18293c9462cf 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -99,6 +99,8 @@ static inline bool operator!=(const ControlInfo &lhs, const ControlId &rhs) return !(lhs == rhs); } +using ControlInfoMap = std::unordered_map; + class ControlList { private: diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 617ea99cdf71..592dfd39eacc 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -548,6 +548,18 @@ int Camera::release() return 0; } +/** + * \brief Retrieve the list of controls supported by the camera + * + * Camera controls remain constant through the lifetime of the camera. + * + * \return A ControlInfoMap listing the controls supported by the camera + */ +const ControlInfoMap &Camera::controls() +{ + return pipe_->controls(this); +} + /** * \brief Retrieve all the camera's stream information * diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 7fac1169cbfd..cd2cf337b379 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -325,6 +325,11 @@ bool operator==(const ControlInfo &lhs, const ControlId &rhs) return lhs.id() == rhs; } +/** + * \typedef ControlInfoMap + * \brief A map of ControlId to ControlInfo + */ + /** * \class ControlList * \brief Associate a list of ControlId with their values for a camera diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index a4cbc593a179..f836d5d1a600 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -14,6 +14,7 @@ #include #include +#include #include namespace libcamera { @@ -41,6 +42,7 @@ public: Camera *camera_; PipelineHandler *pipe_; std::list queuedRequests_; + ControlInfoMap controlInfo_; private: CameraData(const CameraData &) = delete; @@ -60,6 +62,8 @@ public: bool lock(); void unlock(); + const ControlInfoMap &controls(Camera *camera); + virtual CameraConfiguration *generateConfiguration(Camera *camera, const StreamRoles &roles) = 0; virtual int configure(Camera *camera, CameraConfiguration *config) = 0; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index c91ef2f7d336..0283e4e5ad51 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -88,6 +88,14 @@ LOG_DEFINE_CATEGORY(Pipeline) * PipelineHandler::completeRequest() */ +/** + * \var CameraData::controlInfo_ + * \brief The set of controls supported by the camera + * + * The control information shall be initialised by the pipeline handler when + * creating the camera, and shall not be modified afterwards. + */ + /** * \class PipelineHandler * \brief Create and manage cameras based on a set of media devices @@ -217,6 +225,17 @@ void PipelineHandler::unlock() media->unlock(); } +/** + * \brief Retrieve the list of controls for a camera + * \param[in] camera The camera + * \return A ControlInfoMap listing the controls support by \a camera + */ +const ControlInfoMap &PipelineHandler::controls(Camera *camera) +{ + CameraData *data = cameraData(camera); + return data->controlInfo_; +} + /** * \fn PipelineHandler::generateConfiguration() * \brief Generate a camera configuration for a specified camera