{"id":659,"url":"https://patchwork.libcamera.org/api/1.1/patches/659/?format=json","web_url":"https://patchwork.libcamera.org/patch/659/","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":"<20190228162913.6508-7-laurent.pinchart@ideasonboard.com>","date":"2019-02-28T16:29:09","name":"[libcamera-devel,06/10] libcamera: pipeline_handler: Make pipeline-specific data mandatory","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"8ecc78f53eab742078daea256a857b8f9d496b43","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/659/mbox/","series":[{"id":196,"url":"https://patchwork.libcamera.org/api/1.1/series/196/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=196","date":"2019-02-28T16:29:03","name":"Rework request completion handling","version":1,"mbox":"https://patchwork.libcamera.org/series/196/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/659/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/659/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 29A99610C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 17:29:27 +0100 (CET)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 95CBB988\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 17:29:26 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551371366;\n\tbh=9tcO8ejHe9LiecA5bcaLEI7h/BG/tJna7/U9DP5oIUg=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=I4WF+UFaYwcBooVwQQUQHfIlFadIiNhLwbx5FJALnn9oZ0rOeJXOXPwdh3QPNiXgp\n\t2vXMkkPWYx59tzx6qOwsg0Hk7RtW22qxbhKvl3uS+2QeHuGaqQSDHWIuzlN+4g3hQ/\n\tcee3BwL54mhMYItQ91QN3A5+h/XCSQdd8mRx9B3k=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 28 Feb 2019 18:29:09 +0200","Message-Id":"<20190228162913.6508-7-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.19.2","In-Reply-To":"<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>","References":"<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 06/10] libcamera: pipeline_handler: Make\n\tpipeline-specific data mandatory","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Thu, 28 Feb 2019 16:29:27 -0000"},"content":"Mandate creationg of pipeline-specific data by pipeline handlers. This\nallows simplifying the API by passing the pipeline-specific data to the\nregisterCamera() method and removing the separate setCameraData()\nmethod.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/pipeline_handler.h |  4 +-\n src/libcamera/pipeline/ipu3/ipu3.cpp     |  3 +-\n src/libcamera/pipeline/uvcvideo.cpp      |  4 +-\n src/libcamera/pipeline/vimc.cpp          |  4 +-\n src/libcamera/pipeline_handler.cpp       | 56 +++++-------------------\n 5 files changed, 15 insertions(+), 56 deletions(-)","diff":"diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\nindex bc4da5820ac4..b2b9c94cebdc 100644\n--- a/src/libcamera/include/pipeline_handler.h\n+++ b/src/libcamera/include/pipeline_handler.h\n@@ -63,11 +63,11 @@ public:\n \tvirtual int queueRequest(Camera *camera, Request *request) = 0;\n \n protected:\n-\tvoid registerCamera(std::shared_ptr<Camera> camera);\n+\tvoid registerCamera(std::shared_ptr<Camera> camera,\n+\t\t\t    std::unique_ptr<CameraData> data);\n \tvoid hotplugMediaDevice(MediaDevice *media);\n \n \tCameraData *cameraData(const Camera *camera);\n-\tvoid setCameraData(const Camera *camera, std::unique_ptr<CameraData> data);\n \n \tCameraManager *manager_;\n \ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 347ee657fddf..776b7f07f78d 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -406,8 +406,7 @@ void PipelineHandlerIPU3::registerCameras()\n \t\tif (ret)\n \t\t\tcontinue;\n \n-\t\tsetCameraData(camera.get(), std::move(data));\n-\t\tregisterCamera(std::move(camera));\n+\t\tregisterCamera(std::move(camera), std::move(data));\n \n \t\tLOG(IPU3, Info)\n \t\t\t<< \"Registered Camera[\" << numCameras << \"] \\\"\"\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex 9af4838891f4..f121d3c5633e 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -201,9 +201,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n \t/* Create and register the camera. */\n \tstd::vector<Stream *> streams{ &data->stream_ };\n \tstd::shared_ptr<Camera> camera = Camera::create(this, media_->model(), streams);\n-\n-\tsetCameraData(camera.get(), std::move(data));\n-\tregisterCamera(std::move(camera));\n+\tregisterCamera(std::move(camera), std::move(data));\n \n \t/* Enable hot-unplug notifications. */\n \thotplugMediaDevice(media_.get());\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex c4c1eb0dc19f..6d022c37eb9f 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -209,9 +209,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n \tstd::vector<Stream *> streams{ &data->stream_ };\n \tstd::shared_ptr<Camera> camera = Camera::create(this, \"VIMC Sensor B\",\n \t\t\t\t\t\t\tstreams);\n-\n-\tsetCameraData(camera.get(), std::move(data));\n-\tregisterCamera(std::move(camera));\n+\tregisterCamera(std::move(camera), std::move(data));\n \n \treturn true;\n }\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex ac1acea5a318..54f237942a48 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -247,20 +247,18 @@ PipelineHandler::~PipelineHandler()\n /**\n  * \\brief Register a camera to the camera manager and pipeline handler\n  * \\param[in] camera The camera to be added\n+ * \\param[in] data Pipeline-specific data for the camera\n  *\n  * This method is called by pipeline handlers to register the cameras they\n- * handle with the camera manager. If no CameraData has been associated with\n- * the camera with setCameraData() by the pipeline handler, the method creates\n- * a default CameraData instance for the \\a camera.\n+ * handle with the camera manager. It associates the pipeline-specific \\a data\n+ * with the camera, for later retrieval with cameraData(). Ownership of \\a data\n+ * is transferred to the PipelineHandler.\n  */\n-void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera)\n+void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera,\n+\t\t\t\t     std::unique_ptr<CameraData> data)\n {\n-\tif (!cameraData_.count(camera.get())) {\n-\t\tstd::unique_ptr<CameraData> data = utils::make_unique<CameraData>(this);\n-\t\tsetCameraData(camera.get(), std::move(data));\n-\t}\n-\n-\tcameraData(camera.get())->camera_ = camera.get();\n+\tdata->camera_ = camera.get();\n+\tcameraData_[camera.get()] = std::move(data);\n \tcameras_.push_back(camera);\n \tmanager_->addCamera(std::move(camera));\n }\n@@ -325,51 +323,17 @@ void PipelineHandler::disconnect()\n  * \\brief Retrieve the pipeline-specific data associated with a Camera\n  * \\param camera The camera whose data to retrieve\n  *\n- * \\return A pointer to the pipeline-specific data set with setCameraData().\n+ * \\return A pointer to the pipeline-specific data passed to registerCamera().\n  * The returned pointer is a borrowed reference and is guaranteed to remain\n  * valid until the pipeline handler is destroyed. It shall not be deleted\n  * manually by the caller.\n  */\n CameraData *PipelineHandler::cameraData(const Camera *camera)\n {\n-\tif (!cameraData_.count(camera)) {\n-\t\tLOG(Pipeline, Error)\n-\t\t\t<< \"Cannot get data associated with camera \"\n-\t\t\t<< camera->name();\n-\t\treturn nullptr;\n-\t}\n-\n+\tASSERT(cameraData_.count(camera));\n \treturn cameraData_[camera].get();\n }\n \n-/**\n- * \\brief Set pipeline-specific data for the camera\n- * \\param camera The camera to associate data to\n- * \\param data The pipeline-specific data\n- *\n- * This method allows pipeline handlers to associate pipeline-specific\n- * information with \\a camera. Ownership of \\a data is transferred to\n- * the PipelineHandler.\n- *\n- * Pipeline-specific data can only be set once, and shall be set before\n- * registering the camera with registerCamera(). Any attempt to call this\n- * method more than once for the same camera, or to call it after registering\n- * the camera, will not change the pipeline-specific data.\n- *\n- * The data can be retrieved by pipeline handlers using the cameraData() method.\n- */\n-void PipelineHandler::setCameraData(const Camera *camera,\n-\t\t\t\t    std::unique_ptr<CameraData> data)\n-{\n-\tif (cameraData_.find(camera) != cameraData_.end()) {\n-\t\tLOG(Pipeline, Error)\n-\t\t\t<< \"Replacing data associated with a camera is forbidden\";\n-\t\treturn;\n-\t}\n-\n-\tcameraData_[camera] = std::move(data);\n-}\n-\n /**\n  * \\var PipelineHandler::manager_\n  * \\brief The Camera manager associated with the pipeline handler\n","prefixes":["libcamera-devel","06/10"]}