Patch Detail
Show a patch.
GET /api/patches/15083/?format=api
{ "id": 15083, "url": "https://patchwork.libcamera.org/api/patches/15083/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15083/", "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": "<20211208151527.1404715-3-naush@raspberrypi.com>", "date": "2021-12-08T15:15:27", "name": "[libcamera-devel,v2,2/2] pipeline: raspberrypi: Add support for Video Mux and Bridge devices", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "b70c6e633343455c0dd6575dc0d0c2c636ead67c", "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/15083/mbox/", "series": [ { "id": 2828, "url": "https://patchwork.libcamera.org/api/series/2828/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2828", "date": "2021-12-08T15:15:25", "name": "Raspberry Pi: Add video mux and bridge support", "version": 2, "mbox": "https://patchwork.libcamera.org/series/2828/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15083/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15083/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 D5762BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 8 Dec 2021 15:15:37 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 842ED6088E;\n\tWed, 8 Dec 2021 16:15:37 +0100 (CET)", "from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4BEC660725\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 8 Dec 2021 16:15:34 +0100 (CET)", "by mail-wm1-x32b.google.com with SMTP id p18so2000996wmq.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 08 Dec 2021 07:15:34 -0800 (PST)", "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:27d5:9305:f572:6623])\n\tby smtp.gmail.com with ESMTPSA id\n\t10sm3998857wrb.75.2021.12.08.07.15.32\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 08 Dec 2021 07:15:32 -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=\"kC8s62K+\"; 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=KRWYQebGKAW4ly9N4vPVLysxEY4G5yLfOO4ApQ+gj60=;\n\tb=kC8s62K+LND9eqn2ugLndMVaLiBarhqmfTEMxOqprDqm4geqFGVIzmmvzsqJJIG7nD\n\t5tQxcQIteyzNwZfd0bq6i9FfQw5g3zgqroyzXlm1HjWQaAP93VXo/AhqcSnNlLO3MB0b\n\t2b0W+Kkn1MhH3zeukfW1gY+l8m3EUj9fFLI0qv0LZbuYS9HghXtPXNLf2mLx6tiA5ZzP\n\tur3VmlUsmy3xpg/ttbk1K9guwVCn81dAVw/K8A4XehI/czPJbwR/bZX7P4XyfQNb763m\n\t0LEP6HFB2XP7zuRF9uQHuEIiY7lRGNya/L3pPkjW5D7uf/6tUACh5smvCWQF2oE8NgCB\n\t/CEA==", "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=KRWYQebGKAW4ly9N4vPVLysxEY4G5yLfOO4ApQ+gj60=;\n\tb=mOMnnlTZW8Zm+inA9disvuldbdjY8Bwkn9V8op8gZwpaUm6s3NfcAtKOI4vP1u0C6v\n\t6KUpBtoIA/igfQlrYt65MZG4Jp+MZPZcHgqnpQUYf5WZpnanAMWfRZRMfHFKgtfDOc6j\n\tRQFmk5qWteJ1XmOQy1uP19ejFzsi1Q9Ia6bLR+e31DCIXmS+NqRhLe/gkevX6bwohv3M\n\t864TqDnTl4HzPyABC5ciHhqLPaUdMtHdMuv/y3FEcsZ7YSPWEGFfKb9sa3QHmNkRwedA\n\te8qukDsslBN77fn3ota0bCWNX6EcARp3MPJl5LcQM9Pc3GvFF8YDonY93f2DMBW6gz9W\n\tF5aQ==", "X-Gm-Message-State": "AOAM532B3dyVhTxJp3gcLAg+opO9NR0ocuVAZGKQ9tXQOxKXjEdYaAml\n\tG7t1vkgGKMRFf6S9x23+nzqvwjIWz7K0j7FN", "X-Google-Smtp-Source": "ABdhPJyxgGBVVu3yaG7ceENTLsr+q4hq82aATIt7ph8u/SKcf6EpXDGmDUJMWbSVcZmyrP5rwGL/uA==", "X-Received": "by 2002:a05:600c:1c1a:: with SMTP id\n\tj26mr17284377wms.28.1638976533529; \n\tWed, 08 Dec 2021 07:15:33 -0800 (PST)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 8 Dec 2021 15:15:27 +0000", "Message-Id": "<20211208151527.1404715-3-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20211208151527.1404715-1-naush@raspberrypi.com>", "References": "<20211208151527.1404715-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 2/2] pipeline: raspberrypi: Add support\n\tfor Video Mux and Bridge devices", "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": "This change will allow the pipeline handler to enumerate and control Video\nMux or Bridge devices that may be attached between sensors and a particular\nUnicam instance. Cascaded mux or bridge devices are also handled.\n\nA new member function enumerateVideoDevices(), called from registerCamera(), is\nused to identify and open all mux and bridge subdevices present in the\nsensor -> Unicam link.\n\nRelevent links are enabled/disabled and pad formats correctly set in configure()\nbefore the camera is started.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp | 78 +++++++++++++++++++\n 1 file changed, 78 insertions(+)", "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 756878c70036..ca176ecb40ec 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -12,6 +12,7 @@\n #include <mutex>\n #include <queue>\n #include <unordered_set>\n+#include <utility>\n \n #include <libcamera/base/shared_fd.h>\n #include <libcamera/base/utils.h>\n@@ -220,6 +221,11 @@ public:\n \tstd::vector<RPi::Stream *> streams_;\n \t/* Stores the ids of the buffers mapped in the IPA. */\n \tstd::unordered_set<unsigned int> ipaBuffers_;\n+\t/*\n+\t * Stores a cascade of Video Mux or Bridge devices between the sensor and\n+\t * Unicam together with media link across the entities.\n+\t */\n+\tstd::vector<std::pair<std::unique_ptr<V4L2Subdevice>, MediaLink *>> bridgeDevices_;\n \n \t/* DMAHEAP allocation helper. */\n \tRPi::DmaHeap dmaHeap_;\n@@ -311,6 +317,7 @@ private:\n \t}\n \n \tint registerCamera(MediaDevice *unicam, MediaDevice *isp, MediaEntity *sensorEntity);\n+\tvoid enumerateVideoDevices(RPiCameraData *data, MediaLink *link);\n \tint queueAllBuffers(Camera *camera);\n \tint prepareBuffers(Camera *camera);\n \tvoid freeBuffers(Camera *camera);\n@@ -868,6 +875,25 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \t */\n \tdata->properties_.set(properties::ScalerCropMaximum, data->sensorInfo_.analogCrop);\n \n+\t/* Setup the Video Mux/Bridge entities. */\n+\tfor (auto &[device, link] : data->bridgeDevices_) {\n+\t\t/* Start by disabling all the sink pad links on the devices in the cascade. */\n+\t\tfor (const MediaPad *p : device->entity()->pads()) {\n+\t\t\tif (!(p->flags() & MEDIA_PAD_FL_SINK))\n+\t\t\t\tcontinue;\n+\n+\t\t\tfor (MediaLink *l : p->links())\n+\t\t\t\tl->setEnabled(false);\n+\t\t}\n+\n+\t\t/* Finally enable the link, and setup the pad format. */\n+\t\tlink->setEnabled(true);\n+\t\tconst MediaPad *srcPad = link->sink();\n+\t\tret = device->setFormat(srcPad->index(), &sensorFormat);\n+\t\tLOG(RPI, Info) << \"Configured media link on device \" << device->entity()->name()\n+\t\t\t << \" at pad \" << srcPad->index();\n+\t}\n+\n \treturn ret;\n }\n \n@@ -1098,6 +1124,13 @@ 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 * link. There may be a cascade of devices in this link!\n+\t */\n+\tMediaLink *link = sensorEntity->getPadByIndex(0)->links()[0];\n+\tenumerateVideoDevices(data.get(), link);\n+\n \tdata->sensorFormats_ = populateSensorFormats(data->sensor_);\n \n \tipa::RPi::SensorConfig sensorConfig;\n@@ -1224,6 +1257,51 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me\n \treturn 0;\n }\n \n+void PipelineHandlerRPi::enumerateVideoDevices(RPiCameraData *data, 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+\tLOG(RPI, Info) << \"Found video mux device \" << entity->name()\n+\t\t << \" linked to sink pad \" << sinkPad->index();\n+\n+\tdata->bridgeDevices_.emplace_back(std::make_unique<V4L2Subdevice>(entity), link);\n+\tdata->bridgeDevices_.back().first->open();\n+\n+\tfor (const MediaPad *pad : entity->pads()) {\n+\t\t/*\n+\t\t * Iterate through all the sink pads down the cascade to find any\n+\t\t * other Video Mux and Bridge devices.\n+\t\t */\n+\t\tif (!(pad->flags() & MEDIA_PAD_FL_SOURCE))\n+\t\t\tcontinue;\n+\n+\t\tfor (MediaLink *l : pad->links()) {\n+\t\t\tenumerateVideoDevices(data, l);\n+\t\t\tif (l->sink()->entity()->name() == \"unicam-image\")\n+\t\t\t\tunicamFound = true;\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\tdata->bridgeDevices_.clear();\n+\t\t}\n+\t}\n+}\n+\n int PipelineHandlerRPi::queueAllBuffers(Camera *camera)\n {\n \tRPiCameraData *data = cameraData(camera);\n", "prefixes": [ "libcamera-devel", "v2", "2/2" ] }