{"id":8851,"url":"https://patchwork.libcamera.org/api/patches/8851/?format=json","web_url":"https://patchwork.libcamera.org/patch/8851/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20200718132324.867815-3-niklas.soderlund@ragnatech.se>","date":"2020-07-18T13:23:17","name":"[libcamera-devel,2/9] libcamera: camera_sensor: Expose a sensor ID","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"996c020ce2c92d7731f5d8b3f40643c99d69f3a2","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":{"id":16,"url":"https://patchwork.libcamera.org/api/users/16/?format=json","username":"neg","first_name":"Niklas","last_name":"Söderlund","email":"niklas.soderlund@ragnatech.se"},"mbox":"https://patchwork.libcamera.org/patch/8851/mbox/","series":[{"id":1115,"url":"https://patchwork.libcamera.org/api/series/1115/?format=json","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/8851/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8851/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 8270DC0109\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 9D96660493;\n\tSat, 18 Jul 2020 15:23:35 +0200 (CEST)","from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E038C6053A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 Jul 2020 15:23:32 +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 df6cc57f-c8f9-11ea-933e-005056917a89;\n\tSat, 18 Jul 2020 15:23:31 +0200 (CEST)"],"X-Halon-ID":"df6cc57f-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:17 +0200","Message-Id":"<20200718132324.867815-3-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 2/9] libcamera: camera_sensor: Expose a\n\tsensor 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":"Expose a constant unique string ID for the sensor. The ID is generated\nfrom the sensors device and inherits the paths properties, it is unique\nand persistent across reboots of the system.\n\nTo make ID a bit more user friendly drop '/sys/devices/' from the path.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/internal/camera_sensor.h |  2 ++\n src/libcamera/camera_sensor.cpp            | 17 +++++++++++++++++\n 2 files changed, 19 insertions(+)","diff":"diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex 7f07413f95602881..4be25042a0d6b387 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -49,6 +49,7 @@ public:\n \tint init();\n \n \tconst std::string &model() const { return model_; }\n+\tconst std::string &id() const { return id_; }\n \tconst MediaEntity *entity() const { return entity_; }\n \tconst std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }\n \tconst std::vector<Size> &sizes() const { return sizes_; }\n@@ -74,6 +75,7 @@ private:\n \tunsigned int pad_;\n \n \tstd::string model_;\n+\tstd::string id_;\n \n \tImageFormats formats_;\n \tSize resolution_;\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 6e93cc51155ba678..733ddf6866bd1ec1 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -205,6 +205,12 @@ int CameraSensor::init()\n \tif (ret < 0)\n \t\treturn ret;\n \n+\t/* Create ID from sysfs device path. */\n+\tid_ = subdev_->devicePath();\n+\tconst std::string dropStr = \"/sys/devices/\";\n+\tif (id_.find(dropStr) == 0)\n+\t\tid_.erase(0, dropStr.length());\n+\n \t/* Retrieve and store the camera sensor properties. */\n \tconst ControlInfoMap &controls = subdev_->controls();\n \tint32_t propertyValue;\n@@ -284,6 +290,17 @@ int CameraSensor::init()\n  * \\return The sensor model name\n  */\n \n+/**\n+ * \\fn CameraSensor::id()\n+ * \\brief Retrieve the sensor ID\n+ *\n+ * The sensor ID is a free-formed string that uniquely identifies the sensor in\n+ * the system. The ID is persisted between different instances of libcamera and\n+ * between resets of the system.\n+ *\n+ * \\return The sensor ID\n+ */\n+\n /**\n  * \\fn CameraSensor::entity()\n  * \\brief Retrieve the sensor media entity\n","prefixes":["libcamera-devel","2/9"]}