Patch Detail
Show a patch.
GET /api/1.1/patches/18931/?format=api
{ "id": 18931, "url": "https://patchwork.libcamera.org/api/1.1/patches/18931/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18931/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20230808125228.29043-5-jacopo.mondi@ideasonboard.com>", "date": "2023-08-08T12:52:23", "name": "[libcamera-devel,RFC,4/9] libcamera: Introduce CameraDevice and USBDevice", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "d6254173112aa38454c378d0f2846f37ae137f4e", "submitter": { "id": 143, "url": "https://patchwork.libcamera.org/api/1.1/people/143/?format=api", "name": "Jacopo Mondi", "email": "jacopo.mondi@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18931/mbox/", "series": [ { "id": 4002, "url": "https://patchwork.libcamera.org/api/1.1/series/4002/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4002", "date": "2023-08-08T12:52:19", "name": "libcamera: Generalize device match and support USB devices", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4002/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18931/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18931/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 3F784C32A9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 8 Aug 2023 12:52:56 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BC358627ED;\n\tTue, 8 Aug 2023 14:52:55 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B88C8627EC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 8 Aug 2023 14:52:48 +0200 (CEST)", "from uno.localdomain (mob-5-90-60-22.net.vodafone.it [5.90.60.22])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D4B72396D; \n\tTue, 8 Aug 2023 14:51:40 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1691499175;\n\tbh=+/Rkd7Z+xBQAH+rNSIjq7t7JFy+zXhHsZnkvSO6d3VU=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=bfWEJunW0+NUqZoQxpI7FlAxLnsKTdM4Qu45OCuxw1zE55/N+w50N2EvPFndqUYZf\n\tCKFG73CLlbT6gLdPZg49st5tSiyPmqFzMZxvcPcEOY010Iw/J5Zxq/2NUvgHAa5lV2\n\tJTxkDOn2o7axdYbZozmaMFoR6rxCoEET+BmHBxEaUn6dfWg4/WlYsMhWul5K9XNgzE\n\te29aMdamU/wPndOSwf9IMQc/dH/ggKmf+LaMeF/V5bu0reXB82V0djQID/0Fi2fOqg\n\t/uMWGrBETW/QxZUfmVTwbK71OF8Iys3Eu1c3JU4nMjpqS/j05OC4ke0r40tghlYmKx\n\tQ4fyx6Jk0yiZQ==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1691499101;\n\tbh=+/Rkd7Z+xBQAH+rNSIjq7t7JFy+zXhHsZnkvSO6d3VU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=AOQ82FU+V3At2vgtArnZHPv83zvtHWXBOv1rAx6EbWi8M1VUfbuYXsuuUQyJsZo+j\n\tdSxYAsODXX6QURNeiYbXaY36WOHeABW1Nja0QkEzNfxl98uyBKyFhgLpVLu1Vuiphj\n\tTSAuncmqD7+Jl8hz1oVVebQArAdq+5cGjhuc1atQ=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"AOQ82FU+\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org, Sophie Friedrich <dev@flowerpot.me>", "Date": "Tue, 8 Aug 2023 14:52:23 +0200", "Message-Id": "<20230808125228.29043-5-jacopo.mondi@ideasonboard.com>", "X-Mailer": "git-send-email 2.40.1", "In-Reply-To": "<20230808125228.29043-1-jacopo.mondi@ideasonboard.com>", "References": "<20230808125228.29043-1-jacopo.mondi@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC 4/9] libcamera: Introduce CameraDevice and\n\tUSBDevice", "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>", "From": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Introduce a CameraDevice base class from which the MediaDevice and\nUSBDevice derive from.\n\nThis allows to generalize the PipelineHandler base class implementation\nto use a generic 'CameraDevice' type in the later patches.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n include/libcamera/internal/camera_device.h | 31 +++++++++++++\n include/libcamera/internal/media_device.h | 13 +++---\n include/libcamera/internal/meson.build | 2 +\n include/libcamera/internal/usb_device.h | 52 ++++++++++++++++++++++\n src/libcamera/camera_device.cpp | 22 +++++++++\n src/libcamera/media_device.cpp | 2 +-\n src/libcamera/meson.build | 1 +\n 7 files changed, 115 insertions(+), 8 deletions(-)\n create mode 100644 include/libcamera/internal/camera_device.h\n create mode 100644 include/libcamera/internal/usb_device.h\n create mode 100644 src/libcamera/camera_device.cpp", "diff": "diff --git a/include/libcamera/internal/camera_device.h b/include/libcamera/internal/camera_device.h\nnew file mode 100644\nindex 000000000000..421d77e8d6cf\n--- /dev/null\n+++ b/include/libcamera/internal/camera_device.h\n@@ -0,0 +1,31 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Ideas On Board Oy\n+ *\n+ * camera_device.h - Base class for camera devices\n+ */\n+\n+#pragma once\n+\n+namespace libcamera {\n+\n+class CameraDevice\n+{\n+public:\n+\tCameraDevice()\n+\t\t: acquired_(false)\n+\t{\n+\t}\n+\n+\tvirtual bool acquire() = 0;\n+\tvirtual void release() = 0;\n+\tbool busy() const { return acquired_; }\n+\n+\tvirtual bool lock() = 0;\n+\tvirtual void unlock() = 0;\n+\n+protected:\n+\tbool acquired_;\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h\nindex eb8cfde48e20..2c748ae66545 100644\n--- a/include/libcamera/internal/media_device.h\n+++ b/include/libcamera/internal/media_device.h\n@@ -18,22 +18,22 @@\n #include <libcamera/base/signal.h>\n #include <libcamera/base/unique_fd.h>\n \n+#include \"libcamera/internal/camera_device.h\"\n #include \"libcamera/internal/media_object.h\"\n \n namespace libcamera {\n \n-class MediaDevice : protected Loggable\n+class MediaDevice : protected Loggable, public CameraDevice\n {\n public:\n \tMediaDevice(const std::string &deviceNode);\n \t~MediaDevice();\n \n-\tbool acquire();\n-\tvoid release();\n-\tbool busy() const { return acquired_; }\n+\tbool acquire() override;\n+\tvoid release() override;\n \n-\tbool lock();\n-\tvoid unlock();\n+\tbool lock() override;\n+\tvoid unlock() override;\n \n \tint populate();\n \tbool isValid() const { return valid_; }\n@@ -85,7 +85,6 @@ private:\n \n \tUniqueFD fd_;\n \tbool valid_;\n-\tbool acquired_;\n \n \tstd::map<unsigned int, MediaObject *> objects_;\n \tstd::vector<MediaEntity *> entities_;\ndiff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex 169e06557106..c683283da37d 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -14,6 +14,7 @@ libcamera_internal_headers = files([\n 'byte_stream_buffer.h',\n 'camera.h',\n 'camera_controls.h',\n+ 'camera_device.h',\n 'camera_lens.h',\n 'camera_manager.h',\n 'camera_sensor.h',\n@@ -41,6 +42,7 @@ libcamera_internal_headers = files([\n 'request.h',\n 'source_paths.h',\n 'sysfs.h',\n+ 'usb_device.h',\n 'v4l2_device.h',\n 'v4l2_pixelformat.h',\n 'v4l2_subdevice.h',\ndiff --git a/include/libcamera/internal/usb_device.h b/include/libcamera/internal/usb_device.h\nnew file mode 100644\nindex 000000000000..7fe0f7c4d6a9\n--- /dev/null\n+++ b/include/libcamera/internal/usb_device.h\n@@ -0,0 +1,52 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Ideas On Board Oy\n+ *\n+ * usb_device.h - Description of a USB device\n+ */\n+\n+#pragma once\n+\n+#include \"libcamera/internal/camera_device.h\"\n+\n+namespace libcamera {\n+\n+class USBDevice : public CameraDevice\n+{\n+public:\n+\tUSBDevice(const char *vid, const char *pid)\n+\t\t: CameraDevice(), vid_(vid), pid_(pid)\n+\t{\n+\t}\n+\n+\t/* \\todo Implement acquire/release and lock/unlock */\n+\tbool acquire() override\n+\t{\n+\t\t/* This only works within the same process!! */\n+\t\tif (acquired_)\n+\t\t\treturn false;\n+\n+\t\tacquired_ = true;\n+\t\treturn true;\n+\t}\n+\tvoid release() override\n+\t{\n+\t}\n+\n+\tbool lock() override\n+\t{\n+\t\treturn true;\n+\t}\n+\tvoid unlock() override\n+\t{\n+\t}\n+\n+\tconst std::string &vid() const { return vid_; };\n+\tconst std::string &pid() const { return pid_; };\n+\n+private:\n+\tstd::string vid_;\n+\tstd::string pid_;\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/camera_device.cpp b/src/libcamera/camera_device.cpp\nnew file mode 100644\nindex 000000000000..a0ceba0db5af\n--- /dev/null\n+++ b/src/libcamera/camera_device.cpp\n@@ -0,0 +1,22 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Ideas On Board Oy\n+ *\n+ * camera_device.cpp - Base class for camera devices\n+ */\n+\n+#include \"libcamera/internal/camera_device.h\"\n+\n+/**\n+ * \\file camera_device.h\n+ * \\brief Base class for camera devices\n+ */\n+\n+namespace libcamera {\n+\n+/**\n+ * \\class CameraDevice\n+ * \\brief Base class for camera devices\n+ */\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex 2949816b4a64..f9c2dbf289f1 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -63,7 +63,7 @@ LOG_DEFINE_CATEGORY(MediaDevice)\n * populate() before the media graph can be queried.\n */\n MediaDevice::MediaDevice(const std::string &deviceNode)\n-\t: deviceNode_(deviceNode), valid_(false), acquired_(false)\n+\t: CameraDevice(), deviceNode_(deviceNode), valid_(false)\n {\n }\n \ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex d5562afc50c7..3a70946a6f78 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -5,6 +5,7 @@ libcamera_sources = files([\n 'byte_stream_buffer.cpp',\n 'camera.cpp',\n 'camera_controls.cpp',\n+ 'camera_device.cpp',\n 'camera_lens.cpp',\n 'camera_manager.cpp',\n 'camera_sensor.cpp',\n", "prefixes": [ "libcamera-devel", "RFC", "4/9" ] }