Patch Detail
Show a patch.
GET /api/1.1/patches/15102/?format=api
{ "id": 15102, "url": "https://patchwork.libcamera.org/api/1.1/patches/15102/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15102/", "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": "<20211209133252.2234668-3-naush@raspberrypi.com>", "date": "2021-12-09T13:32:52", "name": "[libcamera-devel,v3,2/2] pipeline: raspberrypi: Add support for Video Mux and Bridge devices", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "25602bf78588de806fd55413835a94cf3d5a4743", "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/15102/mbox/", "series": [ { "id": 2832, "url": "https://patchwork.libcamera.org/api/1.1/series/2832/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2832", "date": "2021-12-09T13:32:50", "name": "Raspberry Pi: Add video mux and bridge support", "version": 3, "mbox": "https://patchwork.libcamera.org/series/2832/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15102/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15102/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 C91DCC324B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 9 Dec 2021 13:33:02 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C9A9D6087E;\n\tThu, 9 Dec 2021 14:33:00 +0100 (CET)", "from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com\n\t[IPv6:2a00:1450:4864:20::32e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DEAC460876\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 9 Dec 2021 14:32:57 +0100 (CET)", "by mail-wm1-x32e.google.com with SMTP id\n\ti8-20020a7bc948000000b0030db7b70b6bso6571241wml.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 09 Dec 2021 05:32:57 -0800 (PST)", "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:a3bd:8799:8317:6d3f])\n\tby smtp.gmail.com with ESMTPSA id\n\tr15sm8449244wmh.13.2021.12.09.05.32.56\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 09 Dec 2021 05:32:56 -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=\"Y0gXpZ+k\"; 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=w2OtKuHX6CYbNhGvo4cGz+74cdbg5QRxPILGyFh9P+g=;\n\tb=Y0gXpZ+kxnuI2DSCOxmsFWFL6c/eQrDeSxprWW6GFj8rljRGj2Cf2wc7hsBlqITEJ1\n\tgtugQcpgIDX2lIYDpmnyfqwutZ+cSWvU2PIRBgqyghVBK2YDimFFDrbR7e+UGF/ckb6n\n\t1fshAqV0/kxuE7rYNMFIJz+ce0NYFKr4mnbdsS2NL+VJK13eSlWY7k8x81mZbjvRKuFK\n\tjCvrTQxPOQlXOkeiknwJDqgOLkRapnqD9OpHIS4ruD4l9b/tRKCrC4fTyMBgdvuiLtRk\n\tGsj2S4cXPfJk3R4b9bgv5B7jvqnAOuaxAyl5hpt718LY9h6z5GQTuOFAbw7xW3mG3STZ\n\tjCsQ==", "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=w2OtKuHX6CYbNhGvo4cGz+74cdbg5QRxPILGyFh9P+g=;\n\tb=wfH9n3xT5fdOY/x4IIi+qsEw3ziRpxE/g66LzR2dU3dqnH4BLWD/SUI22OOwI+bxGk\n\tDn8KwT68V8kfvDfTsq6IMTomNadVdZvHW9BDZZDCwz3QBZUE+zzkdNOWWcI3MmMNYsgA\n\tzdzMpDxfJ19e4H/+MXi559eVioNCMdwgluer2gjQhJ0ol1tmPrfg6ebn/57OW3s36RFM\n\t2psMW6AocSDdcKa1RAXwf1lZ8jrs2SV/devcTFCPsnaZwnn6FMrzVgVcb7xsNtUYhhAT\n\tbXdbwJoWWKmdNe8hRMDJQxunNz7Yek7Hz6ZXrmbdutdOnpmZhwmcnnGFRgsE4D4GsqwN\n\tE7Hg==", "X-Gm-Message-State": "AOAM531lhLr7bB8XQNVuywqTFvq5fefk4ZD+vN4hBEYZzEPTWjiE7xgH\n\t1h6dcg9/D18FyTS4d/vltpvjTyn3F2nonET7", "X-Google-Smtp-Source": "ABdhPJy8cbLo7bcYn68RiJRZEj9sZ0lwVIQPC6EFCP3qftMJSo+4ZGXKDJs9iVIZ5eGAg+LtP+x2rw==", "X-Received": "by 2002:a05:600c:4e07:: with SMTP id\n\tb7mr6966524wmq.16.1639056777255; \n\tThu, 09 Dec 2021 05:32:57 -0800 (PST)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 9 Dec 2021 13:32:52 +0000", "Message-Id": "<20211209133252.2234668-3-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20211209133252.2234668-1-naush@raspberrypi.com>", "References": "<20211209133252.2234668-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 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>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp | 119 ++++++++++++++++++\n 1 file changed, 119 insertions(+)", "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 2a2fb5273eb8..49dbefd8637c 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,33 @@ 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/* Next, enable the entity -> entity links, 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\tif (ret) {\n+\t\t\tLOG(RPI, Error) << \"Failed to set format on \" << device->entity()->name()\n+\t\t\t\t\t<< \" pad \" << srcPad->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, Info) << \"Configured media link on device \" << device->entity()->name()\n+\t\t\t << \" on pad \" << srcPad->index();\n+\t}\n+\n \treturn ret;\n }\n \n@@ -1098,6 +1132,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 +1265,84 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me\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 disables 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 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", "v3", "2/2" ] }