Patch Detail
Show a patch.
GET /api/1.1/patches/24166/?format=api
{ "id": 24166, "url": "https://patchwork.libcamera.org/api/1.1/patches/24166/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24166/", "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": "<20250820132316.1033443-2-dan.scally@ideasonboard.com>", "date": "2025-08-20T13:23:14", "name": "[1/3] libcamera: media_device: Expand return values for populateEntities()", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "d3fc29c4385b4320aa5c0c37d4eda0fd3cfb3725", "submitter": { "id": 156, "url": "https://patchwork.libcamera.org/api/1.1/people/156/?format=api", "name": "Dan Scally", "email": "dan.scally@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24166/mbox/", "series": [ { "id": 5396, "url": "https://patchwork.libcamera.org/api/1.1/series/5396/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5396", "date": "2025-08-20T13:23:13", "name": "Fix fast-booting device enumeration problems", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5396/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24166/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24166/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 CFA32BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Aug 2025 13:23:44 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5D0C6692E5;\n\tWed, 20 Aug 2025 15:23:40 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 048BF6142C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Aug 2025 15:23:37 +0200 (CEST)", "from mail.ideasonboard.com\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3FA24B0B;\n\tWed, 20 Aug 2025 15:22:38 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"sCBZBU9m\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755696158;\n\tbh=QsJiDoh1KBHgRuOEwcExXG5glWOhBMzyXXI5IhXstns=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=sCBZBU9mF5Rvx+8vbO10mWj8rIghQ/lI9zH/oM11XrpCDabMnmNlT0QZ6SIMwksMO\n\tBHhpl9YwXpAvQ6AXnWLrsvK4Z9nL+FRp5gXGejUuqnqsFVkGQ1qKdg4WYHVRG6Ibj5\n\t0bzYHWwFWkvT/7A0Gb/ZkH2yE/gmNuYB0h0IvrHs=", "From": "Daniel Scally <dan.scally@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "dan.scally@ideasonboard.com", "Subject": "[PATCH 1/3] libcamera: media_device: Expand return values for\n\tpopulateEntities()", "Date": "Wed, 20 Aug 2025 14:23:14 +0100", "Message-ID": "<20250820132316.1033443-2-dan.scally@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20250820132316.1033443-1-dan.scally@ideasonboard.com>", "References": "<20250820132316.1033443-1-dan.scally@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "At the moment populateEntities() just returns true or false to indicate\nsuccess or failure. Although the populate() function assumes that the\ntopology is settled once the version number stops incrementing, that's\nnot guaranteed to be the case. One indicator that it's likely to increase\nagain in the future is the absence of interfaces for an entity, which\nwould only be created for V4L2 subdevices once the v4l2-async framework\nhad run to completion.\n\nUpdate populateEntities() to return -EAGAIN in the event an entity has\nno associated interface yet and pass that error out from populate to\nindicate to callers that they should re-try the population at a later\ntime.\n\nSigned-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n---\n include/libcamera/internal/media_device.h | 2 +-\n src/libcamera/media_device.cpp | 27 ++++++++++++++---------\n 2 files changed, 17 insertions(+), 12 deletions(-)", "diff": "diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h\nindex b3a48b98d..d3c5eaa02 100644\n--- a/include/libcamera/internal/media_device.h\n+++ b/include/libcamera/internal/media_device.h\n@@ -70,7 +70,7 @@ private:\n \n \tstruct media_v2_interface *findInterface(const struct media_v2_topology &topology,\n \t\t\t\t\t\t unsigned int entityId);\n-\tbool populateEntities(const struct media_v2_topology &topology);\n+\tint populateEntities(const struct media_v2_topology &topology);\n \tbool populatePads(const struct media_v2_topology &topology);\n \tbool populateLinks(const struct media_v2_topology &topology);\n \tvoid fixupEntityFlags(struct media_v2_entity *entity);\ndiff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex 353f34a81..6d58f09eb 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -257,12 +257,13 @@ int MediaDevice::populate()\n \t}\n \n \t/* Populate entities, pads and links. */\n-\tif (populateEntities(topology) &&\n-\t populatePads(topology) &&\n-\t populateLinks(topology))\n-\t\tvalid_ = true;\n+\tif (!(ret = populateEntities(topology))) {\n+\t\tif (populatePads(topology) && populateLinks(topology))\n+\t\t\tvalid_ = true;\n+\t\telse\n+\t\t\tret = -EINVAL;\n+\t}\n \n-\tret = 0;\n done:\n \tclose();\n \n@@ -271,10 +272,8 @@ done:\n \tdelete[] pads;\n \tdelete[] links;\n \n-\tif (!valid_) {\n+\tif (!valid_)\n \t\tclear();\n-\t\treturn -EINVAL;\n-\t}\n \n \treturn ret;\n }\n@@ -618,7 +617,7 @@ struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topo\n * For each entity in the media graph create a MediaEntity and store a\n * reference in the media device objects map and entities list.\n */\n-bool MediaDevice::populateEntities(const struct media_v2_topology &topology)\n+int MediaDevice::populateEntities(const struct media_v2_topology &topology)\n {\n \tstruct media_v2_entity *mediaEntities = reinterpret_cast<struct media_v2_entity *>\n \t\t\t\t\t\t(topology.ptr_entities);\n@@ -639,17 +638,23 @@ bool MediaDevice::populateEntities(const struct media_v2_topology &topology)\n \t\t */\n \t\tstruct media_v2_interface *iface =\n \t\t\tfindInterface(topology, ent->id);\n+\t\tif (!iface) {\n+\t\t\tLOG(MediaDevice, Debug)\n+\t\t\t\t<< \"Entity \" << ent->name << \" has no interface yet\";\n+\t\t\treturn -EAGAIN;\n+\t\t}\n+\n \t\tMediaEntity *entity = new MediaEntity(this, ent, iface);\n \n \t\tif (!addObject(entity)) {\n \t\t\tdelete entity;\n-\t\t\treturn false;\n+\t\t\treturn -EINVAL;\n \t\t}\n \n \t\tentities_.push_back(entity);\n \t}\n \n-\treturn true;\n+\treturn 0;\n }\n \n bool MediaDevice::populatePads(const struct media_v2_topology &topology)\n", "prefixes": [ "1/3" ] }