Patch Detail
Show a patch.
GET /api/patches/191/?format=api
{ "id": 191, "url": "https://patchwork.libcamera.org/api/patches/191/?format=api", "web_url": "https://patchwork.libcamera.org/patch/191/", "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": "<20190108204733.10823-2-jacopo@jmondi.org>", "date": "2019-01-08T20:47:31", "name": "[libcamera-devel,v3,1/3] libcamera: Add pointer to MediaDevice to MediaObject", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "0f9c66cb896383ab0ac7d1c1f6cbd9e25a87a546", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/191/mbox/", "series": [ { "id": 63, "url": "https://patchwork.libcamera.org/api/series/63/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=63", "date": "2019-01-08T20:47:30", "name": "libcamera: media device: Add link handling", "version": 3, "mbox": "https://patchwork.libcamera.org/series/63/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/191/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/191/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 172FA60B30\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 8 Jan 2019 21:47:33 +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 relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 4E6C440007;\n\tTue, 8 Jan 2019 20:47:32 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 8 Jan 2019 21:47:31 +0100", "Message-Id": "<20190108204733.10823-2-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190108204733.10823-1-jacopo@jmondi.org>", "References": "<20190108204733.10823-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 1/3] 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 20:47:33 -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\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/media_object.h | 7 ++++--\n src/libcamera/media_device.cpp | 4 ++--\n src/libcamera/media_object.cpp | 33 +++++++++++++++++++++-------\n 3 files changed, 32 insertions(+), 12 deletions(-)", "diff": "diff --git a/src/libcamera/include/media_object.h b/src/libcamera/include/media_object.h\nindex 04b9a89..b2c3d8e 100644\n--- a/src/libcamera/include/media_object.h\n+++ b/src/libcamera/include/media_object.h\n@@ -21,14 +21,17 @@ class MediaPad;\n class MediaObject\n {\n public:\n+\tMediaDevice *device() { return dev_; }\n \tunsigned int id() const { return id_; }\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 *dev, 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..4ff9620 100644\n--- a/src/libcamera/media_object.cpp\n+++ b/src/libcamera/media_object.cpp\n@@ -42,28 +42,43 @@ 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 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 * This constraint is neither enforced nor checked by the MediaObject.\n */\n \n+/**\n+ * \\fn MediaObject::device()\n+ * \\brief Retrieve the media device the media object belongs to\n+ * \\return The MediaDevice\n+ */\n+\n /**\n * \\fn MediaObject::id()\n * \\brief Retrieve the media object id\n * \\return 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 * \\var MediaObject::id_\n * \\brief The media object id\n@@ -88,7 +103,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->device(), link->id), source_(source),\n \t sink_(sink), flags_(link->flags)\n {\n }\n@@ -139,7 +154,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->device(), pad->id), index_(pad->index), entity_(entity),\n \t flags_(pad->flags)\n {\n }\n@@ -283,13 +298,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", "v3", "1/3" ] }