Patch Detail
Show a patch.
GET /api/1.1/patches/182/?format=api
{ "id": 182, "url": "https://patchwork.libcamera.org/api/1.1/patches/182/?format=api", "web_url": "https://patchwork.libcamera.org/patch/182/", "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": "<20190108170407.4770-2-jacopo@jmondi.org>", "date": "2019-01-08T17:04:04", "name": "[libcamera-devel,v2,1/4] libcamera: Add pointer to MediaDevice to MediaObject", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "0a6f1fdefa03c03a788a09d07fc4047d7b0bb760", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/182/mbox/", "series": [ { "id": 61, "url": "https://patchwork.libcamera.org/api/1.1/series/61/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=61", "date": "2019-01-08T17:04:03", "name": "libcamera: media device: Add link handling", "version": 2, "mbox": "https://patchwork.libcamera.org/series/61/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/182/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/182/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C20260B2E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 8 Jan 2019 18:04:09 +0100 (CET)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id E012B20000D;\n\tTue, 8 Jan 2019 17:04:08 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 8 Jan 2019 18:04:04 +0100", "Message-Id": "<20190108170407.4770-2-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190108170407.4770-1-jacopo@jmondi.org>", "References": "<20190108170407.4770-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 1/4] libcamera: Add pointer to\n\tMediaDevice to MediaObject", "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": "Tue, 08 Jan 2019 17:04:09 -0000" }, "content": "Add a MediaDevice member field to the MediaObject class hierarcy.\nEach media object now has a reference to the media device it belongs to,\nand which it has been created by.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nv1->v2:\n- Use the entity MediaDevice in MediaPad and MediaLink constructors\n- Incorporate comments changes from Laurent and Niklas on v1\n\n src/libcamera/include/media_object.h | 7 +++++--\n src/libcamera/media_device.cpp | 4 ++--\n src/libcamera/media_object.cpp | 27 +++++++++++++++++++--------\n 3 files changed, 26 insertions(+), 12 deletions(-)\n\n--\n2.20.1", "diff": "diff --git a/src/libcamera/include/media_object.h b/src/libcamera/include/media_object.h\nindex 04b9a89..d92aab3 100644\n--- a/src/libcamera/include/media_object.h\n+++ b/src/libcamera/include/media_object.h\n@@ -22,13 +22,16 @@ class MediaObject\n {\n public:\n \tunsigned int id() const { return id_; }\n+\tMediaDevice *dev() const { return dev_; }\n\n protected:\n \tfriend class MediaDevice;\n\n-\tMediaObject(unsigned int id) : id_(id) { }\n+\tMediaObject(MediaDevice *dev, unsigned int id) :\n+\t\tdev_(dev), id_(id) { }\n \tvirtual ~MediaObject() { }\n\n+\tMediaDevice *dev_;\n \tunsigned int id_;\n };\n\n@@ -93,7 +96,7 @@ public:\n private:\n \tfriend class MediaDevice;\n\n-\tMediaEntity(const struct media_v2_entity *entity,\n+\tMediaEntity(MediaDevice *media, const struct media_v2_entity *entity,\n \t\t unsigned int major = 0, unsigned int minor = 0);\n \tMediaEntity(const MediaEntity &) = delete;\n \t~MediaEntity();\ndiff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex cf4ff90..b0d10ed 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -430,11 +430,11 @@ bool MediaDevice::populateEntities(const struct media_v2_topology &topology)\n\n \t\tMediaEntity *entity;\n \t\tif (iface)\n-\t\t\tentity = new MediaEntity(&mediaEntities[i],\n+\t\t\tentity = new MediaEntity(this, &mediaEntities[i],\n \t\t\t\t\t\t iface->devnode.major,\n \t\t\t\t\t\t iface->devnode.minor);\n \t\telse\n-\t\t\tentity = new MediaEntity(&mediaEntities[i]);\n+\t\t\tentity = new MediaEntity(this, &mediaEntities[i]);\n\n \t\tif (!addObject(entity)) {\n \t\t\tdelete entity;\ndiff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp\nindex 06a8d64..612550d 100644\n--- a/src/libcamera/media_object.cpp\n+++ b/src/libcamera/media_object.cpp\n@@ -42,16 +42,20 @@ namespace libcamera {\n * \\class MediaObject\n * \\brief Base class for all media objects\n *\n- * MediaObject is an abstract base class for all media objects in the media\n- * graph. Every media graph object is identified by an id unique in the media\n- * device context, and this base class provides that.\n+ * MediaObject is an abstract base class for all media objects in the\n+ * media graph. Each object is identified by a reference to the media\n+ * device it belongs to and a unique id within that media device.\n+ * This base class provide helpers to media objects to keep track of\n+ * these identifiers.\n *\n * \\sa MediaEntity, MediaPad, MediaLink\n */\n\n /**\n * \\fn MediaObject::MediaObject()\n- * \\brief Construct a MediaObject with \\a id\n+ * \\brief Construct a MediaObject part of the MediaDevice \\a dev,\n+ * identified by the \\a id unique in within the device\n+ * \\param dev The media device this object belongs to\n * \\param id The media object id\n *\n * The caller shall ensure unicity of the object id in the media device context.\n@@ -69,6 +73,11 @@ namespace libcamera {\n * \\brief The media object id\n */\n\n+/**\n+ * \\var MediaObject::dev_\n+ * \\brief The media device the media object belongs to\n+ */\n+\n /**\n * \\class MediaLink\n * \\brief The MediaLink represents a link between two pads in the media graph.\n@@ -88,7 +97,7 @@ namespace libcamera {\n */\n MediaLink::MediaLink(const struct media_v2_link *link, MediaPad *source,\n \t\t MediaPad *sink)\n-\t: MediaObject(link->id), source_(source),\n+\t: MediaObject(source->dev(), link->id), source_(source),\n \t sink_(sink), flags_(link->flags)\n {\n }\n@@ -139,7 +148,7 @@ MediaLink::MediaLink(const struct media_v2_link *link, MediaPad *source,\n * \\param entity The entity the pad belongs to\n */\n MediaPad::MediaPad(const struct media_v2_pad *pad, MediaEntity *entity)\n-\t: MediaObject(pad->id), index_(pad->index), entity_(entity),\n+\t: MediaObject(entity->dev(), pad->id), index_(pad->index), entity_(entity),\n \t flags_(pad->flags)\n {\n }\n@@ -283,13 +292,15 @@ int MediaEntity::setDeviceNode(const std::string &devnode)\n\n /**\n * \\brief Construct a MediaEntity\n+ * \\param dev The media device this entity belongs to\n * \\param entity The media entity kernel data\n * \\param major The major number of the entity associated interface\n * \\param minor The minor number of the entity associated interface\n */\n-MediaEntity::MediaEntity(const struct media_v2_entity *entity,\n+MediaEntity::MediaEntity(MediaDevice *dev,\n+\t\t\t const struct media_v2_entity *entity,\n \t\t\t unsigned int major, unsigned int minor)\n-\t: MediaObject(entity->id), name_(entity->name),\n+\t: MediaObject(dev, entity->id), name_(entity->name),\n \t major_(major), minor_(minor)\n {\n }\n", "prefixes": [ "libcamera-devel", "v2", "1/4" ] }