{"id":13311,"url":"https://patchwork.libcamera.org/api/1.1/patches/13311/?format=json","web_url":"https://patchwork.libcamera.org/patch/13311/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210811232625.17280-4-laurent.pinchart@ideasonboard.com>","date":"2021-08-11T23:26:14","name":"[libcamera-devel,v3,03/14] libcamera: pipeline_handler: Move CameraData members to Camera::Private","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"3f1979ba3aef05ff574e22f33dbf59c2bf7d8b73","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13311/mbox/","series":[{"id":2341,"url":"https://patchwork.libcamera.org/api/1.1/series/2341/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2341","date":"2021-08-11T23:26:11","name":"libcamera: Replace CameraData with Camera::Private","version":3,"mbox":"https://patchwork.libcamera.org/series/2341/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13311/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13311/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D230FBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 11 Aug 2021 23:26:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7461968887;\n\tThu, 12 Aug 2021 01:26:42 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CEFE0687F0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Aug 2021 01:26:33 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 78EB2268\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Aug 2021 01:26:33 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"PvVyRGua\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628724393;\n\tbh=p0vPqWAF8VvJseCOi1oxT1WEpxkDb5n04tMRGELGIOw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=PvVyRGuanq8RMOsbezkm8SNNFX2CxlEbj0QoprE6qK6WcaO+MU/3c+6hSJK41wlSi\n\tm4fCWQ3conO+Q9PVyly9yx2EGe2T+mjGtz0a6KntQ3jpoB0MTCyBKhUhGktfvfSOcr\n\taJI4MVcXW006KOXnxQJnzJTdDRn44W+QncPBmLi4=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 12 Aug 2021 02:26:14 +0300","Message-Id":"<20210811232625.17280-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210811232625.17280-1-laurent.pinchart@ideasonboard.com>","References":"<20210811232625.17280-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 03/14] libcamera: pipeline_handler:\n\tMove CameraData members to Camera::Private","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"With pipeline handlers now being able to subclass Camera::Private, start\nthe migration from CameraData to Camera::Private by moving the members\nof the base CameraData class. The controlInfo_, properties_ and pipe_\nmembers are duplicated for now, to allow migrating pipeline handlers one\nby one.\n\nThe Camera::Private class is now properly documented, don't exclude it\nfrom documentation generation.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\nChanges since v2:\n\n- Include <list> where appropriate\n- Minor documentation update\n\nChanges since v1:\n\n- Add \\todo comment for controlInfo_\n---\n Documentation/Doxyfile.in                     |  1 -\n include/libcamera/internal/camera.h           |  9 +++\n include/libcamera/internal/pipeline_handler.h |  6 +-\n src/libcamera/camera.cpp                      | 65 ++++++++++++++++++-\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      |  2 +-\n src/libcamera/pipeline_handler.cpp            | 45 +++++--------\n 6 files changed, 89 insertions(+), 39 deletions(-)","diff":"diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in\nindex fb321ad25f6f..e3b77428cd4f 100644\n--- a/Documentation/Doxyfile.in\n+++ b/Documentation/Doxyfile.in\n@@ -882,7 +882,6 @@ EXCLUDE_SYMBOLS        = libcamera::BoundMethodArgs \\\n                          libcamera::BoundMethodPack \\\n                          libcamera::BoundMethodPackBase \\\n                          libcamera::BoundMethodStatic \\\n-                         libcamera::Camera::Private \\\n                          libcamera::CameraManager::Private \\\n                          libcamera::SignalBase \\\n                          *::details \\\ndiff --git a/include/libcamera/internal/camera.h b/include/libcamera/internal/camera.h\nindex 9ec8321a9a21..1a08da0cedc4 100644\n--- a/include/libcamera/internal/camera.h\n+++ b/include/libcamera/internal/camera.h\n@@ -8,6 +8,7 @@\n #define __LIBCAMERA_INTERNAL_CAMERA_H__\n \n #include <atomic>\n+#include <list>\n #include <memory>\n #include <set>\n #include <string>\n@@ -29,6 +30,14 @@ public:\n \tPrivate(PipelineHandler *pipe);\n \t~Private();\n \n+\tPipelineHandler *pipe() { return pipe_.get(); }\n+\n+\tstd::list<Request *> queuedRequests_;\n+\tControlInfoMap controlInfo_;\n+\tControlList properties_;\n+\n+\tuint32_t requestSequence_;\n+\n private:\n \tenum State {\n \t\tCameraAvailable,\ndiff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex 9e2d65d6f2c5..24b0c5ca081c 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -7,7 +7,6 @@\n #ifndef __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__\n #define __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__\n \n-#include <list>\n #include <map>\n #include <memory>\n #include <set>\n@@ -39,18 +38,15 @@ class CameraData\n {\n public:\n \texplicit CameraData(PipelineHandler *pipe)\n-\t\t: pipe_(pipe), requestSequence_(0)\n+\t\t: pipe_(pipe)\n \t{\n \t}\n \tvirtual ~CameraData() = default;\n \n \tPipelineHandler *pipe_;\n-\tstd::list<Request *> queuedRequests_;\n \tControlInfoMap controlInfo_;\n \tControlList properties_;\n \n-\tuint32_t requestSequence_;\n-\n private:\n \tLIBCAMERA_DISABLE_COPY(CameraData)\n };\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex d9f6b784e0dc..4080da151af1 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -332,13 +332,25 @@ std::size_t CameraConfiguration::size() const\n  * \\brief The vector of stream configurations\n  */\n \n+/**\n+ * \\class Camera::Private\n+ * \\brief Base class for camera private data\n+ *\n+ * The Camera::Private class stores all private data associated with a camera.\n+ * In addition to hiding core Camera data from the public API, it is expected to\n+ * be subclassed by pipeline handlers to store pipeline-specific data.\n+ *\n+ * Pipeline handlers can obtain the Camera::Private instance associated with a\n+ * camera by calling Camera::_d().\n+ */\n+\n /**\n  * \\brief Construct a Camera::Private instance\n  * \\param[in] pipe The pipeline handler responsible for the camera device\n  */\n Camera::Private::Private(PipelineHandler *pipe)\n-\t: pipe_(pipe->shared_from_this()), disconnected_(false),\n-\t  state_(CameraAvailable)\n+\t: requestSequence_(0), pipe_(pipe->shared_from_this()),\n+\t  disconnected_(false), state_(CameraAvailable)\n {\n }\n \n@@ -348,6 +360,55 @@ Camera::Private::~Private()\n \t\tLOG(Camera, Error) << \"Removing camera while still in use\";\n }\n \n+/**\n+ * \\fn Camera::Private::pipe()\n+ * \\brief Retrieve the pipeline handler related to this camera\n+ * \\return The pipeline handler that created this camera\n+ */\n+\n+/**\n+ * \\var Camera::Private::queuedRequests_\n+ * \\brief The list of queued and not yet completed request\n+ *\n+ * The list of queued request is used to track requests queued in order to\n+ * ensure completion of all requests when the pipeline handler is stopped.\n+ *\n+ * \\sa PipelineHandler::queueRequest(), PipelineHandler::stop(),\n+ * PipelineHandler::completeRequest()\n+ */\n+\n+/**\n+ * \\var Camera::Private::controlInfo_\n+ * \\brief The set of controls supported by the camera\n+ *\n+ * The control information shall be initialised by the pipeline handler when\n+ * creating the camera.\n+ *\n+ * \\todo This member was initially meant to stay constant after the camera is\n+ * created. Several pipeline handlers are already updating it when the camera\n+ * is configured. Update the documentation accordingly, and possibly the API as\n+ * well, when implementing official support for control info updates.\n+ */\n+\n+/**\n+ * \\var Camera::Private::properties_\n+ * \\brief The list of properties supported by the camera\n+ *\n+ * The list of camera properties shall be initialised by the pipeline handler\n+ * when creating the camera, and shall not be modified afterwards.\n+ */\n+\n+/**\n+ * \\var Camera::Private::requestSequence_\n+ * \\brief The queuing sequence of the request\n+ *\n+ * When requests are queued, they are given a per-camera sequence number to\n+ * facilitate debugging of internal request usage.\n+ *\n+ * The requestSequence_ tracks the number of requests queued to a camera\n+ * over its lifetime.\n+ */\n+\n static const char *const camera_state_names[] = {\n \t\"Available\",\n \t\"Acquired\",\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex c2872289337b..cebd94b2c18b 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -847,7 +847,7 @@ void PipelineHandlerRkISP1::stop(Camera *camera)\n \t\tLOG(RkISP1, Warning)\n \t\t\t<< \"Failed to stop parameters for \" << camera->id();\n \n-\tASSERT(data->queuedRequests_.empty());\n+\tASSERT(camera->_d()->queuedRequests_.empty());\n \tdata->frameInfo_.clear();\n \n \tfreeBuffers(camera);\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 1ab237c8052e..0e571d8981df 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -16,6 +16,7 @@\n #include <libcamera/camera_manager.h>\n #include <libcamera/framebuffer.h>\n \n+#include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/media_device.h\"\n #include \"libcamera/internal/tracepoints.h\"\n@@ -71,17 +72,6 @@ LOG_DEFINE_CATEGORY(Pipeline)\n  * and remains valid until the instance is destroyed.\n  */\n \n-/**\n- * \\var CameraData::queuedRequests_\n- * \\brief The list of queued and not yet completed request\n- *\n- * The list of queued request is used to track requests queued in order to\n- * ensure completion of all requests when the pipeline handler is stopped.\n- *\n- * \\sa PipelineHandler::queueRequest(), PipelineHandler::stop(),\n- * PipelineHandler::completeRequest()\n- */\n-\n /**\n  * \\var CameraData::controlInfo_\n  * \\brief The set of controls supported by the camera\n@@ -98,17 +88,6 @@ LOG_DEFINE_CATEGORY(Pipeline)\n  * when creating the camera, and shall not be modified afterwards.\n  */\n \n-/**\n- * \\var CameraData::requestSequence_\n- * \\brief The queuing sequence of the request\n- *\n- * When requests are queued, they are given a per-camera sequence number to\n- * facilitate debugging of internal request usage.\n- *\n- * The requestSequence_ tracks the number of requests queued to a camera\n- * over its lifetime.\n- */\n-\n /**\n  * \\class PipelineHandler\n  * \\brief Create and manage cameras based on a set of media devices\n@@ -254,8 +233,7 @@ void PipelineHandler::unlock()\n  */\n const ControlInfoMap &PipelineHandler::controls(const Camera *camera) const\n {\n-\tconst CameraData *data = cameraData(camera);\n-\treturn data->controlInfo_;\n+\treturn camera->_d()->controlInfo_;\n }\n \n /**\n@@ -265,8 +243,7 @@ const ControlInfoMap &PipelineHandler::controls(const Camera *camera) const\n  */\n const ControlList &PipelineHandler::properties(const Camera *camera) const\n {\n-\tconst CameraData *data = cameraData(camera);\n-\treturn data->properties_;\n+\treturn camera->_d()->properties_;\n }\n \n /**\n@@ -380,8 +357,7 @@ const ControlList &PipelineHandler::properties(const Camera *camera) const\n  */\n bool PipelineHandler::hasPendingRequests(const Camera *camera) const\n {\n-\tconst CameraData *data = cameraData(camera);\n-\treturn !data->queuedRequests_.empty();\n+\treturn !camera->_d()->queuedRequests_.empty();\n }\n \n /**\n@@ -406,7 +382,7 @@ void PipelineHandler::queueRequest(Request *request)\n \tLIBCAMERA_TRACEPOINT(request_queue, request);\n \n \tCamera *camera = request->camera_;\n-\tCameraData *data = cameraData(camera);\n+\tCamera::Private *data = camera->_d();\n \tdata->queuedRequests_.push_back(request);\n \n \trequest->sequence_ = data->requestSequence_++;\n@@ -479,7 +455,7 @@ void PipelineHandler::completeRequest(Request *request)\n \n \trequest->complete();\n \n-\tCameraData *data = cameraData(camera);\n+\tCamera::Private *data = camera->_d();\n \n \twhile (!data->queuedRequests_.empty()) {\n \t\tRequest *req = data->queuedRequests_.front();\n@@ -507,6 +483,15 @@ void PipelineHandler::completeRequest(Request *request)\n void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera,\n \t\t\t\t     std::unique_ptr<CameraData> data)\n {\n+\t/*\n+\t * To be removed once all pipeline handlers will have migrated from\n+\t * CameraData to Camera::Private.\n+\t */\n+\tif (data) {\n+\t\tcamera->_d()->controlInfo_ = std::move(data->controlInfo_);\n+\t\tcamera->_d()->properties_ = std::move(data->properties_);\n+\t}\n+\n \tcameraData_[camera.get()] = std::move(data);\n \tcameras_.push_back(camera);\n \n","prefixes":["libcamera-devel","v3","03/14"]}