Show a patch.

GET /api/patches/15277/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 15277,
    "url": "https://patchwork.libcamera.org/api/patches/15277/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15277/",
    "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": "<20220113102529.3163441-3-naush@raspberrypi.com>",
    "date": "2022-01-13T10:25:29",
    "name": "[libcamera-devel,RFC,v1,2/2] pipeline: raspberrypi: Use MediaDevice::enumerateMediaWalks()",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": false,
    "hash": "e4be0ea40793ebb647e5eeb1ddc04c24db8b3e31",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15277/mbox/",
    "series": [
        {
            "id": 2892,
            "url": "https://patchwork.libcamera.org/api/series/2892/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2892",
            "date": "2022-01-13T10:25:27",
            "name": "MediaDevice enumeration helper",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2892/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15277/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15277/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 BFD42BE086\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Jan 2022 10:25:39 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7FABE6093F;\n\tThu, 13 Jan 2022 11:25:38 +0100 (CET)",
            "from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com\n\t[IPv6:2a00:1450:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BF2D1604F4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Jan 2022 11:25:36 +0100 (CET)",
            "by mail-wr1-x42a.google.com with SMTP id q8so9135224wra.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Jan 2022 02:25:36 -0800 (PST)",
            "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:194e:c2b:3339:eb51])\n\tby smtp.gmail.com with ESMTPSA id\n\ts22sm6757855wmc.1.2022.01.13.02.25.35\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 13 Jan 2022 02:25:35 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"T5crmhsK\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=pybYtv+XgN2g1EUB39IWeK5ug3VPIt8Yt9FxyC7pas8=;\n\tb=T5crmhsKgvTkga31EM4WLDjN9o1uudC+urANVld8g5RUitzaP7aio6irAXxBansZZJ\n\teHAIyXzULIYk3/6vAP9MtXTFkYCIk78bvLaml9Kmb0L1x93l7+SdpoX0bDCee9pELw0v\n\tTIrHhy5hAy1gYUn8LR7wy7XPbUJbPVAev8gKtq9VhjadIVV2G/JQPaUJnBtw5sqRZb3Y\n\tlEcu5fQqXW07g4uuLQULd9Nh/ElNBAf95Ma+pje8nkYH2njfbA4QABUYSGNb6F+xrdDT\n\tDztIjtgyGGJXLfyWhMJZWaiSiaaD4s5OsX8ho63PaY1EAbE6pKnmk2GFVyAvfwq6qhpO\n\tnPAg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=pybYtv+XgN2g1EUB39IWeK5ug3VPIt8Yt9FxyC7pas8=;\n\tb=NhFmkx8uJyTxWU6azAIWpgtnILIJQRHXxJclO6g8+4zI8N0sxnTLLHTxSR0ee04XBm\n\tApwt40zXiZ16yS3cE047kGlWLAsjTrM8ahRSmRuqqmifNlVoho5OvFqH6xrGXG49ZLtL\n\tSF7vvs7Ca/QdPIKwU7sC1JzT1toSGm1mPRnZdxGxvs6VBvctlb1eIPuP3DmjlqLm5WkK\n\tzl4oiRG84BLzCmAX2m1PckmxRy4MTtf2GUkhdvA093+42HGl/SOZ/vjd7q2dk/2X49RY\n\tzYYznC6Xgvf7cIWkOUB9CBPZK80ojO8SL9KuzmtZPg/K01XInb2WwAUk/a3YQ+P6nxoC\n\tKn5g==",
        "X-Gm-Message-State": "AOAM531zgrp+Zd1v6kt3kGbhWlsDcwAIp7GHFMpYRu55FrOEQzFnpbQS\n\tTMgdVOAbwBz4EQ5M3begqAbmfpyVI0W34dJY",
        "X-Google-Smtp-Source": "ABdhPJzXWwhlWwbxmmG6LPNWEvjY+8o2ReUqFEWgQoK28xbewYYtgit/aleI8mc2CxxeegH+9RuR7Q==",
        "X-Received": "by 2002:a5d:4609:: with SMTP id t9mr3506603wrq.551.1642069536159;\n\tThu, 13 Jan 2022 02:25:36 -0800 (PST)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 13 Jan 2022 10:25:29 +0000",
        "Message-Id": "<20220113102529.3163441-3-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220113102529.3163441-1-naush@raspberrypi.com>",
        "References": "<20220113102529.3163441-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [RFC v1 2/2] pipeline: raspberrypi: Use\n\tMediaDevice::enumerateMediaWalks()",
        "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": "Use the new MediaDevice::enumerateMediaWalks() helper to enumerate the Unicam\nMediaDevice, replacing the existing enumerateVideoDevices() function.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 142 ++++--------------\n 1 file changed, 32 insertions(+), 110 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 5ee713fe66a6..36f3acf1393a 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -194,8 +194,6 @@ public:\n \tint loadIPA(ipa::RPi::SensorConfig *sensorConfig);\n \tint configureIPA(const CameraConfiguration *config);\n \n-\tvoid enumerateVideoDevices(MediaLink *link);\n-\n \tvoid statsMetadataComplete(uint32_t bufferId, const ControlList &controls);\n \tvoid runIsp(uint32_t bufferId);\n \tvoid embeddedComplete(uint32_t bufferId);\n@@ -326,7 +324,7 @@ private:\n \t\treturn static_cast<RPiCameraData *>(camera->_d());\n \t}\n \n-\tint registerCamera(MediaDevice *unicam, MediaDevice *isp, MediaEntity *sensorEntity);\n+\tint registerCamera(MediaDevice *unicam, MediaDevice *isp, const MediaDevice::MediaWalk &walk);\n \tint queueAllBuffers(Camera *camera);\n \tint prepareBuffers(Camera *camera);\n \tvoid freeBuffers(Camera *camera);\n@@ -1111,30 +1109,34 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \t}\n \n+\tstd::vector<MediaDevice::MediaWalk> walks = unicamDevice->enumerateMediaWalks();\n+\n \t/*\n \t * The loop below is used to register multiple cameras behind one or more\n \t * video mux devices that are attached to a particular Unicam instance.\n \t * Obviously these cameras cannot be used simultaneously.\n \t */\n \tunsigned int numCameras = 0;\n-\tfor (MediaEntity *entity : unicamDevice->entities()) {\n-\t\tif (entity->function() != MEDIA_ENT_F_CAM_SENSOR)\n-\t\t\tcontinue;\n+\tfor (const MediaDevice::MediaWalk &walk : walks) {\n+\t\tMediaEntity *sensorEntity = walk.front().entity;\n \n-\t\tint ret = registerCamera(unicamDevice, ispDevice, entity);\n-\t\tif (ret)\n+\t\tint ret = registerCamera(unicamDevice, ispDevice, walk);\n+\t\tif (ret) {\n \t\t\tLOG(RPI, Error) << \"Failed to register camera \"\n-\t\t\t\t\t<< entity->name() << \": \" << ret;\n-\t\telse\n-\t\t\tnumCameras++;\n+\t\t\t\t\t<< sensorEntity->name() << \": \" << ret;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tnumCameras++;\n \t}\n \n \treturn !!numCameras;\n }\n \n-int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, MediaEntity *sensorEntity)\n+int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, const MediaDevice::MediaWalk &walk)\n {\n \tstd::unique_ptr<RPiCameraData> data = std::make_unique<RPiCameraData>(this);\n+\tMediaEntity *sensorEntity = walk.front().entity;\n \n \tif (!data->dmaHeap_.isValid())\n \t\treturn -ENOMEM;\n@@ -1180,12 +1182,24 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me\n \tif (data->sensor_->init())\n \t\treturn -EINVAL;\n \n-\t/*\n-\t * Enumerate all the Video Mux/Bridge devices across the sensor -> unicam\n-\t * chain. There may be a cascade of devices in this chain!\n-\t */\n-\tMediaLink *link = sensorEntity->getPadByIndex(0)->links()[0];\n-\tdata->enumerateVideoDevices(link);\n+\t/* See if we can auto configure this MC graph. */\n+\tfor (auto it = walk.begin() + 1; it < walk.end() - 1; ++it) {\n+\t\tMediaEntity *entity = it->entity;\n+\t\tMediaLink *sinkLink = it->sinkLink;\n+\n+\t\t/* We only deal with Video Mux and Bridge devices in cascade. */\n+\t\tif (entity->function() != MEDIA_ENT_F_VID_MUX &&\n+\t\t    entity->function() != MEDIA_ENT_F_VID_IF_BRIDGE) {\n+\t\t\tdata->bridgeDevices_.clear();\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tLOG(RPI, Info) << \"Found video mux/bridge device \" << entity->name()\n+\t\t\t       << \" linked to sink pad \" << sinkLink->sink()->index();\n+\n+\t\tdata->bridgeDevices_.emplace_back(std::make_unique<V4L2Subdevice>(entity), sinkLink);\n+\t\tdata->bridgeDevices_.back().first->open();\n+\t}\n \n \tdata->sensorFormats_ = populateSensorFormats(data->sensor_);\n \n@@ -1545,98 +1559,6 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)\n \treturn 0;\n }\n \n-/*\n- * enumerateVideoDevices() iterates over the Media Controller topology, starting\n- * at the sensor and finishing at Unicam. For each sensor, RPiCameraData stores\n- * a unique list of any intermediate video mux or bridge devices connected in a\n- * cascade, together with the entity to entity link.\n- *\n- * Entity pad configuration and link enabling happens at the end of configure().\n- * We first disable all pad links on each entity device in the chain, and then\n- * selectively enabling the specific links to link sensor to Unicam across all\n- * intermediate muxes and bridges.\n- *\n- * In the cascaded topology below, if Sensor1 is used, the Mux2 -> Mux1 link\n- * will be disabled, and Sensor1 -> Mux1 -> Unicam links enabled. Alternatively,\n- * if Sensor3 is used, the Sensor2 -> Mux2 and Sensor1 -> Mux1 links are disabled,\n- * and Sensor3 -> Mux2 -> Mux1 -> Unicam links are enabled. All other links will\n- * remain unchanged.\n- *\n- *  +----------+\n- *  |  Unicam  |\n- *  +-----^----+\n- *        |\n- *    +---+---+\n- *    |  Mux1 <-------+\n- *    +--^----+       |\n- *       |            |\n- * +-----+---+    +---+---+\n- * | Sensor1 |    |  Mux2 |<--+\n- * +---------+    +-^-----+   |\n- *                  |         |\n- *          +-------+-+   +---+-----+\n- *          | Sensor2 |   | Sensor3 |\n- *          +---------+   +---------+\n- */\n-void RPiCameraData::enumerateVideoDevices(MediaLink *link)\n-{\n-\tconst MediaPad *sinkPad = link->sink();\n-\tconst MediaEntity *entity = sinkPad->entity();\n-\tbool unicamFound = false;\n-\n-\t/* We only deal with Video Mux and Bridge devices in cascade. */\n-\tif (entity->function() != MEDIA_ENT_F_VID_MUX &&\n-\t    entity->function() != MEDIA_ENT_F_VID_IF_BRIDGE)\n-\t\treturn;\n-\n-\t/* Find the source pad for this Video Mux or Bridge device. */\n-\tconst MediaPad *sourcePad = nullptr;\n-\tfor (const MediaPad *pad : entity->pads()) {\n-\t\tif (pad->flags() & MEDIA_PAD_FL_SOURCE) {\n-\t\t\t/*\n-\t\t\t * We can only deal with devices that have a single source\n-\t\t\t * pad. If this device has multiple source pads, ignore it\n-\t\t\t * and this branch in the cascade.\n-\t\t\t */\n-\t\t\tif (sourcePad)\n-\t\t\t\treturn;\n-\n-\t\t\tsourcePad = pad;\n-\t\t}\n-\t}\n-\n-\tLOG(RPI, Debug) << \"Found video mux device \" << entity->name()\n-\t\t\t<< \" linked to sink pad \" << sinkPad->index();\n-\n-\tbridgeDevices_.emplace_back(std::make_unique<V4L2Subdevice>(entity), link);\n-\tbridgeDevices_.back().first->open();\n-\n-\t/*\n-\t * Iterate through all the sink pad links down the cascade to find any\n-\t * other Video Mux and Bridge devices.\n-\t */\n-\tfor (MediaLink *l : sourcePad->links()) {\n-\t\tenumerateVideoDevices(l);\n-\t\t/* Once we reach the Unicam entity, we are done. */\n-\t\tif (l->sink()->entity()->name() == \"unicam-image\") {\n-\t\t\tunicamFound = true;\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\n-\t/* This identifies the end of our entity enumeration recursion. */\n-\tif (link->source()->entity()->function() == MEDIA_ENT_F_CAM_SENSOR) {\n-\t\t/*\n-\t\t* If Unicam is not at the end of this cascade, we cannot configure\n-\t\t* this topology automatically, so remove all entity references.\n-\t\t*/\n-\t\tif (!unicamFound) {\n-\t\t\tLOG(RPI, Warning) << \"Cannot automatically configure this MC topology!\";\n-\t\t\tbridgeDevices_.clear();\n-\t\t}\n-\t}\n-}\n-\n void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &controls)\n {\n \tif (state_ == State::Stopped)\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "v1",
        "2/2"
    ]
}