Patch Detail
Show a patch.
GET /api/patches/9184/?format=api
{ "id": 9184, "url": "https://patchwork.libcamera.org/api/patches/9184/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9184/", "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": "<20200804161358.1628962-2-niklas.soderlund@ragnatech.se>", "date": "2020-08-04T16:13:50", "name": "[libcamera-devel,v7,1/9] libcamera: sysfs: Add new namespace to interact with sysfs", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "36e9add08e2f11fab2c2f5c5eda59ff2fcfbc704", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/9184/mbox/", "series": [ { "id": 1190, "url": "https://patchwork.libcamera.org/api/series/1190/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1190", "date": "2020-08-04T16:13:49", "name": "libcamera: Generate unique and stable camera IDs", "version": 7, "mbox": "https://patchwork.libcamera.org/series/1190/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9184/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9184/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 C9F28BD87A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 4 Aug 2020 16:14:22 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9CD9F6055A;\n\tTue, 4 Aug 2020 18:14:21 +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 9AC8E60547\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 4 Aug 2020 18:14:20 +0200 (CEST)", "from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de\n\t[84.172.82.168]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 8c9998c5-d66d-11ea-b48b-0050569116f7;\n\tTue, 04 Aug 2020 18:14:19 +0200 (CEST)" ], "X-Halon-ID": "8c9998c5-d66d-11ea-b48b-0050569116f7", "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": "Tue, 4 Aug 2020 18:13:50 +0200", "Message-Id": "<20200804161358.1628962-2-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.28.0", "In-Reply-To": "<20200804161358.1628962-1-niklas.soderlund@ragnatech.se>", "References": "<20200804161358.1628962-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v7 1/9] libcamera: sysfs: Add new\n\tnamespace to interact with sysfs", "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": "To support stable and unique camera IDs access to information in sysfs\nis needed. Add a new libcamera::sysfs namespace to contain such sysfs\nhelpers.\n\nAs a first helper add a method to lookup a character device sysfs path.\n\nSuggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/internal/meson.build | 1 +\n include/libcamera/internal/sysfs.h | 22 ++++++++++++\n src/libcamera/meson.build | 1 +\n src/libcamera/sysfs.cpp | 48 ++++++++++++++++++++++++++\n 4 files changed, 72 insertions(+)\n create mode 100644 include/libcamera/internal/sysfs.h\n create mode 100644 src/libcamera/sysfs.cpp", "diff": "diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex d868eff47f920da0..150103388fdb219d 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -25,6 +25,7 @@ libcamera_internal_headers = files([\n 'process.h',\n 'pub_key.h',\n 'semaphore.h',\n+ 'sysfs.h',\n 'thread.h',\n 'utils.h',\n 'v4l2_controls.h',\ndiff --git a/include/libcamera/internal/sysfs.h b/include/libcamera/internal/sysfs.h\nnew file mode 100644\nindex 0000000000000000..72f436205d8d30e8\n--- /dev/null\n+++ b/include/libcamera/internal/sysfs.h\n@@ -0,0 +1,22 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * sysfs.h - Miscellaneous utility functions to access sysfs\n+ */\n+#ifndef __LIBCAMERA_INTERNAL_SYSFS_H__\n+#define __LIBCAMERA_INTERNAL_SYSFS_H__\n+\n+#include <string>\n+\n+namespace libcamera {\n+\n+namespace sysfs {\n+\n+std::string charDevPath(const std::string &devicePath);\n+\n+} /* namespace sysfs */\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_INTERNAL_SYSFS_H__ */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 3aad4386ffc296db..bada45bcb11e9e88 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -41,6 +41,7 @@ libcamera_sources = files([\n 'semaphore.cpp',\n 'signal.cpp',\n 'stream.cpp',\n+ 'sysfs.cpp',\n 'thread.cpp',\n 'timer.cpp',\n 'utils.cpp',\ndiff --git a/src/libcamera/sysfs.cpp b/src/libcamera/sysfs.cpp\nnew file mode 100644\nindex 0000000000000000..3b2920663e9c3bcc\n--- /dev/null\n+++ b/src/libcamera/sysfs.cpp\n@@ -0,0 +1,48 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * sysfs.cpp - Miscellaneous utility functions to access sysfs\n+ */\n+\n+#include \"libcamera/internal/sysfs.h\"\n+\n+#include <sys/stat.h>\n+#include <sys/sysmacros.h>\n+\n+#include \"libcamera/internal/log.h\"\n+\n+/**\n+ * \\file sysfs.h\n+ * \\brief Miscellaneous utility functions to access sysfs\n+ */\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(SYSFS);\n+\n+namespace sysfs {\n+\n+/**\n+ * \\brief Retrive the sysfs path for a characther device\n+ * \\param[in] devicePath Path to charachter device\n+ * \\return The sysfs path on success or empty string on failure\n+ */\n+std::string charDevPath(const std::string &devicePath)\n+{\n+\tstruct stat st;\n+\tint ret = stat(devicePath.c_str(), &st);\n+\tif (ret < 0) {\n+\t\tLOG(SYSFS, Error)\n+\t\t\t<< \"Unable to stat '\" << devicePath << \"'\";\n+\t\treturn {};\n+\t}\n+\n+\tstd::ostringstream dev(\"/sys/dev/char/\", std::ios_base::ate);\n+\tdev << major(st.st_rdev) << \":\" << minor(st.st_rdev);\n+\treturn dev.str();\n+}\n+\n+} /* namespace sysfs */\n+\n+} /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "v7", "1/9" ] }