Patch Detail
Show a patch.
GET /api/patches/8852/?format=api
{ "id": 8852, "url": "https://patchwork.libcamera.org/api/patches/8852/?format=api", "web_url": "https://patchwork.libcamera.org/patch/8852/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200718132324.867815-4-niklas.soderlund@ragnatech.se>", "date": "2020-07-18T13:23:18", "name": "[libcamera-devel,3/9] libcamera: camera: Add camera ID", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "49e7c0d016c1447516ccee1db6db74ff146b372d", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": { "id": 16, "url": "https://patchwork.libcamera.org/api/users/16/?format=api", "username": "neg", "first_name": "Niklas", "last_name": "Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "mbox": "https://patchwork.libcamera.org/patch/8852/mbox/", "series": [ { "id": 1115, "url": "https://patchwork.libcamera.org/api/series/1115/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1115", "date": "2020-07-18T13:23:15", "name": "libcamera: camera: Add camera ID", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1115/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/8852/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/8852/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 BFB75C2E67\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 18 Jul 2020 13:23:37 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CD7B160732;\n\tSat, 18 Jul 2020 15:23:36 +0200 (CEST)", "from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B64B260589\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 Jul 2020 15:23:33 +0200 (CEST)", "from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de\n\t[79.202.46.202]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid dfb350e3-c8f9-11ea-933e-005056917a89;\n\tSat, 18 Jul 2020 15:23:31 +0200 (CEST)" ], "X-Halon-ID": "dfb350e3-c8f9-11ea-933e-005056917a89", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 18 Jul 2020 15:23:18 +0200", "Message-Id": "<20200718132324.867815-4-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200718132324.867815-1-niklas.soderlund@ragnatech.se>", "References": "<20200718132324.867815-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 3/9] libcamera: camera: Add camera ID", "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>", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add an ID when creating a camera. The ID is a free form string that must\nbe unique for the camera in the system. The ID shall also be persistent\nbetween reboots.\n\nAll but the UVC pipeline is modified to use the ID of the sensor of each\ncamera. The ID of the sensor guarantees the properties required of the\ncamera ID. The UVC pipeline does not have a sensor so instead creates a\nunique and persistent ID from the video device path which includes the\nUSB bus information and thus satisfy the camera ID requirements.\n\nFuture changes will make use of and enforce the uniqueness of camera\nIDs.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/camera.h | 6 ++--\n src/libcamera/camera.cpp | 34 +++++++++++++------\n src/libcamera/pipeline/ipu3/ipu3.cpp | 1 +\n .../pipeline/raspberrypi/raspberrypi.cpp | 5 ++-\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 3 +-\n src/libcamera/pipeline/simple/simple.cpp | 3 +-\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 7 +++-\n src/libcamera/pipeline/vimc/vimc.cpp | 3 +-\n 8 files changed, 45 insertions(+), 17 deletions(-)", "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 4d1a4a9f52ec0fac..132225a37dcd1ef4 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -70,12 +70,14 @@ class Camera final : public std::enable_shared_from_this<Camera>\n {\n public:\n \tstatic std::shared_ptr<Camera> create(PipelineHandler *pipe,\n+\t\t\t\t\t const std::string &id,\n \t\t\t\t\t const std::string &name,\n \t\t\t\t\t const std::set<Stream *> &streams);\n \n \tCamera(const Camera &) = delete;\n \tCamera &operator=(const Camera &) = delete;\n \n+\tconst std::string &id() const;\n \tconst std::string &name() const;\n \n \tSignal<Request *, FrameBuffer *> bufferCompleted;\n@@ -99,8 +101,8 @@ public:\n \tint stop();\n \n private:\n-\tCamera(PipelineHandler *pipe, const std::string &name,\n-\t const std::set<Stream *> &streams);\n+\tCamera(PipelineHandler *pipe, const std::string &id,\n+\t const std::string &name, const std::set<Stream *> &streams);\n \t~Camera();\n \n \tclass Private;\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 69a1b4428e3f4eca..638d15e0da5e1ca9 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -265,8 +265,8 @@ public:\n \t\tCameraRunning,\n \t};\n \n-\tPrivate(PipelineHandler *pipe, const std::string &name,\n-\t\tconst std::set<Stream *> &streams);\n+\tPrivate(PipelineHandler *pipe, const std::string &id,\n+\t\tconst std::string &name, const std::set<Stream *> &streams);\n \t~Private();\n \n \tint isAccessAllowed(State state, bool allowDisconnected = false) const;\n@@ -277,6 +277,7 @@ public:\n \tvoid setState(State state);\n \n \tstd::shared_ptr<PipelineHandler> pipe_;\n+\tstd::string id_;\n \tstd::string name_;\n \tstd::set<Stream *> streams_;\n \tstd::set<Stream *> activeStreams_;\n@@ -286,10 +287,11 @@ private:\n \tstd::atomic<State> state_;\n };\n \n-Camera::Private::Private(PipelineHandler *pipe, const std::string &name,\n+Camera::Private::Private(PipelineHandler *pipe, const std::string &id,\n+\t\t\t const std::string &name,\n \t\t\t const std::set<Stream *> &streams)\n-\t: pipe_(pipe->shared_from_this()), name_(name), streams_(streams),\n-\t disconnected_(false), state_(CameraAvailable)\n+\t: pipe_(pipe->shared_from_this()), id_(id), name_(name),\n+\t streams_(streams), disconnected_(false), state_(CameraAvailable)\n {\n }\n \n@@ -450,14 +452,16 @@ void Camera::Private::setState(State state)\n /**\n * \\brief Create a camera instance\n * \\param[in] pipe The pipeline handler responsible for the camera device\n+ * \\param[in] id The ID of the camera device\n * \\param[in] name The name of the camera device\n * \\param[in] streams Array of streams the camera provides\n *\n- * The caller is responsible for guaranteeing unicity of the camera name.\n+ * The caller is responsible for guaranteeing unicity of the camera ID.\n *\n * \\return A shared pointer to the newly created camera object\n */\n std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,\n+\t\t\t\t const std::string &id,\n \t\t\t\t const std::string &name,\n \t\t\t\t const std::set<Stream *> &streams)\n {\n@@ -468,7 +472,7 @@ std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,\n \t\t}\n \t};\n \n-\tCamera *camera = new Camera(pipe, name, streams);\n+\tCamera *camera = new Camera(pipe, id, name, streams);\n \n \treturn std::shared_ptr<Camera>(camera, Deleter());\n }\n@@ -483,6 +487,16 @@ const std::string &Camera::name() const\n \treturn p_->name_;\n }\n \n+/**\n+ * \\brief Retrieve the camera ID\n+ * \\context This function is \\threadsafe.\n+ * \\return Unique ID of the camera device\n+ */\n+const std::string &Camera::id() const\n+{\n+\treturn p_->id_;\n+}\n+\n /**\n * \\var Camera::bufferCompleted\n * \\brief Signal emitted when a buffer for a request queued to the camera has\n@@ -506,9 +520,9 @@ const std::string &Camera::name() const\n * application API calls by returning errors immediately.\n */\n \n-Camera::Camera(PipelineHandler *pipe, const std::string &name,\n-\t const std::set<Stream *> &streams)\n-\t: p_(new Private(pipe, name, streams))\n+Camera::Camera(PipelineHandler *pipe, const std::string &id,\n+\t const std::string &name, const std::set<Stream *> &streams)\n+\t: p_(new Private(pipe, id, name, streams))\n {\n }\n \ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex eb00eecfd10a89e4..09bab78b999b8b52 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -815,6 +815,7 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t/* Create and register the Camera instance. */\n \t\tstd::string cameraName = cio2->sensor()->entity()->name();\n \t\tstd::shared_ptr<Camera> camera = Camera::create(this,\n+\t\t\t\t\t\t\t\tcio2->sensor()->id(),\n \t\t\t\t\t\t\t\tcameraName,\n \t\t\t\t\t\t\t\tstreams);\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex bf1c77144f855df9..487dc819daa1d0ec 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -973,7 +973,10 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)\n \tstreams.insert(&data->isp_[Isp::Stats]);\n \n \t/* Create and register the camera. */\n-\tstd::shared_ptr<Camera> camera = Camera::create(this, data->sensor_->model(), streams);\n+\tstd::shared_ptr<Camera> camera = Camera::create(this,\n+\t\t\t\t\t\t\tdata->sensor_->id(),\n+\t\t\t\t\t\t\tdata->sensor_->model(),\n+\t\t\t\t\t\t\tstreams);\n \tregisterCamera(std::move(camera), std::move(data));\n \n \treturn true;\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 52a0d862417cc4ec..6f3699fe1a53eeaf 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -971,7 +971,8 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)\n \n \tstd::set<Stream *> streams{ &data->stream_ };\n \tstd::shared_ptr<Camera> camera =\n-\t\tCamera::create(this, sensor->name(), streams);\n+\t\tCamera::create(this, data->sensor_->id(), sensor->name(),\n+\t\t\t streams);\n \tregisterCamera(std::move(camera), std::move(data));\n \n \treturn 0;\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 28d367883323d855..3c27cc28f672e020 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -800,7 +800,8 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n \t\t\tcontinue;\n \n \t\tstd::shared_ptr<Camera> camera =\n-\t\t\tCamera::create(this, data->sensor_->entity()->name(),\n+\t\t\tCamera::create(this, data->sensor_->id(),\n+\t\t\t\t data->sensor_->entity()->name(),\n \t\t\t\t data->streams());\n \t\tregisterCamera(std::move(camera), std::move(data));\n \t}\ndiff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex 47f383d1551d5193..4484b70c6ec5f0ca 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -406,8 +406,13 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \n \t/* Create and register the camera. */\n+\tstd::string id = data->video_->devicePath();\n+\tconst std::string dropStr = \"/sys/devices/\";\n+\tif (id.find(dropStr) == 0)\n+\t\tid.erase(0, dropStr.length());\n+\n \tstd::set<Stream *> streams{ &data->stream_ };\n-\tstd::shared_ptr<Camera> camera = Camera::create(this, media->model(), streams);\n+\tstd::shared_ptr<Camera> camera = Camera::create(this, id, media->model(), streams);\n \tregisterCamera(std::move(camera), std::move(data));\n \n \t/* Enable hot-unplug notifications. */\ndiff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex 4f461b928514022d..38656d28b357dd1b 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -434,7 +434,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n \t/* Create and register the camera. */\n \tstd::string name{ \"VIMC \" + data->sensor_->model() };\n \tstd::set<Stream *> streams{ &data->stream_ };\n-\tstd::shared_ptr<Camera> camera = Camera::create(this, name, streams);\n+\tstd::shared_ptr<Camera> camera = Camera::create(this, data->sensor_->id(),\n+\t\t\t\t\t\t\tname, streams);\n \tregisterCamera(std::move(camera), std::move(data));\n \n \treturn true;\n", "prefixes": [ "libcamera-devel", "3/9" ] }