Patch Detail
Show a patch.
GET /api/1.1/patches/15244/?format=api
{ "id": 15244, "url": "https://patchwork.libcamera.org/api/1.1/patches/15244/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15244/", "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": "<20220104125709.1273546-3-naush@raspberrypi.com>", "date": "2022-01-04T12:57:09", "name": "[libcamera-devel,v5,2/2] pipeline: raspberrypi: Add support for Video Mux and Bridge devices", "commit_ref": "44d59841e1ce59042b8069b8078bc9f7b1bfa73b", "pull_url": null, "state": "accepted", "archived": false, "hash": "827abb26d4f2e4ede054dab3eaf3aca2e3ac244a", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/15244/mbox/", "series": [ { "id": 2875, "url": "https://patchwork.libcamera.org/api/1.1/series/2875/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2875", "date": "2022-01-04T12:57:07", "name": "Raspberry Pi: Add video mux and bridge support", "version": 5, "mbox": "https://patchwork.libcamera.org/series/2875/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15244/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15244/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 75594C3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 4 Jan 2022 12:57:21 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2410E60927;\n\tTue, 4 Jan 2022 13:57:20 +0100 (CET)", "from mail-wr1-x436.google.com (mail-wr1-x436.google.com\n\t[IPv6:2a00:1450:4864:20::436])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D588B604F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 4 Jan 2022 13:57:17 +0100 (CET)", "by mail-wr1-x436.google.com with SMTP id s1so76116370wrg.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 04 Jan 2022 04:57:17 -0800 (PST)", "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:cf71:3c12:f0dd:e082])\n\tby smtp.gmail.com with ESMTPSA id\n\tp15sm35673753wmj.46.2022.01.04.04.57.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 04 Jan 2022 04:57:16 -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=\"EkaVfDzu\"; 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=Ky1hhFEI9Nur/24AXsXA4ap2z+oByp8M83gncjnbIac=;\n\tb=EkaVfDzueRPAa9gVADh/Ho6b4rXme9Cb+MBGQrVXdYDeaC06rVq5CCsn19RmTGmkSZ\n\tz5OlMLJ5Fs4U1lbdCOC+4OyAhj5OoEwy4IO6UqJnWFEZBOBhUjkLFHB4e/pRPNJZEvu1\n\tmz1ImslkChjCweIbA86wvNM68lN2jVGCkyLrmGEk14ULRPre6O71IJQjollJ2UXhG9wt\n\timYIKiCdDHUzWjn23J9pQquUluI0EnZ0Ocpt96cN9ldticIPsanqiXwaP6zSVdg0F4m4\n\tuAdEowrqT+6q6OzxG9VcDTj6drtxBm0kKlJafXa/J7tTndjXwP2GPXvY/oNAr1o8M8Le\n\tDPiQ==", "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=Ky1hhFEI9Nur/24AXsXA4ap2z+oByp8M83gncjnbIac=;\n\tb=3ETLPPm4vbDdEbUUq9rKGBqJrvaEaBYMA+nm5Yn9whUkakJHEGHTggzc6fwFMOjEsc\n\tWzZOax28B/7Te+UgvinVi3RXFv6G7uyQyx7xfvy1sKogAbwwCrTAChZgPT4vNXr6Cm7E\n\tpG7s67chv6v7ZJ2C9KxEhcoRbhIkMfKFvAqcbW6M1s5RuUWpeMXupgWBgSzHe6+xf1Qc\n\tPHwV2qvY9VEb9X4vIH3GzF6znKq8/NzQbetpAKU3FmF3Q63AqrcVBKOY/Ij1zc9EzGyB\n\tYzw0ZgxtL1lo2yydADf6pLDA/yNi/0tNuzkQv803Bpk2dchejK+cCW79VqA73/lZYBC0\n\tjemg==", "X-Gm-Message-State": "AOAM530qZGaQo9Q2Y5qwj1Fc33+qI/YMhdJfvyQFRYQR1pzucWVKaQYG\n\tcTj8QRZ8CLHoYgJbO6N03EAekMyrjMWvhw==", "X-Google-Smtp-Source": "ABdhPJz3mKd983gtSyaJdreDdo6qukc8RIvFSZyzOlP9DMqgrkDkKdF3QVl9YcxEAx/sD02ZLm/SxQ==", "X-Received": "by 2002:a05:6000:178b:: with SMTP id\n\te11mr38432525wrg.348.1641301037291; \n\tTue, 04 Jan 2022 04:57:17 -0800 (PST)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 4 Jan 2022 12:57:09 +0000", "Message-Id": "<20220104125709.1273546-3-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20220104125709.1273546-1-naush@raspberrypi.com>", "References": "<20220104125709.1273546-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 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 RPiCameraData::enumerateVideoDevices(), called from\nPipelineHandlerRPi::registerCamera(), is used to identify and open all mux and\nbridge subdevices present in the sensor -> Unicam link.\n\nRelevant links are enabled/disabled and pad formats correctly set in\nPipelineHandlerRPi::configure() before the camera is started.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp | 144 ++++++++++++++++++\n 1 file changed, 144 insertions(+)", "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex a6d1e8570abf..168bbcef819c 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@@ -193,6 +194,8 @@ 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@@ -222,6 +225,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@@ -908,6 +916,43 @@ 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/*\n+\t\t * Start by disabling all the sink pad links on the devices in the\n+\t\t * cascade, with the exception of the link connecting the device.\n+\t\t */\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\tif (l != link)\n+\t\t\t\t\tl->setEnabled(false);\n+\t\t\t}\n+\t\t}\n+\n+\t\t/*\n+\t\t * Next, enable the entity -> entity links, and setup the pad format.\n+\t\t *\n+\t\t * \\todo Some bridge devices may chainge the media bus code, so we\n+\t\t * ought to read the source pad format and propagate it to the sink pad.\n+\t\t */\n+\t\tlink->setEnabled(true);\n+\t\tconst MediaPad *sinkPad = link->sink();\n+\t\tret = device->setFormat(sinkPad->index(), &sensorFormat);\n+\t\tif (ret) {\n+\t\t\tLOG(RPI, Error) << \"Failed to set format on \" << device->entity()->name()\n+\t\t\t\t\t<< \" pad \" << sinkPad->index()\n+\t\t\t\t\t<< \" with format \" << format.toString()\n+\t\t\t\t\t<< \": \" << ret;\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\tLOG(RPI, Debug) << \"Configured media link on device \" << device->entity()->name()\n+\t\t\t\t<< \" on pad \" << sinkPad->index();\n+\t}\n+\n \treturn ret;\n }\n \n@@ -1138,6 +1183,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 * 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+\n \tdata->sensorFormats_ = populateSensorFormats(data->sensor_);\n \n \tipa::RPi::SensorConfig sensorConfig;\n@@ -1487,6 +1539,98 @@ 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", "v5", "2/2" ] }