Patch Detail
Show a patch.
GET /api/patches/23699/?format=api
{ "id": 23699, "url": "https://patchwork.libcamera.org/api/patches/23699/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23699/", "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": "<20250701085818.2447600-3-antoine.bouyer@nxp.com>", "date": "2025-07-01T08:58:17", "name": "[v4,2/2] pipeline: imx8-isi: Add multicamera support", "commit_ref": "92df79112fb22a9e08cdb5f354652a5a7ade7a6e", "pull_url": null, "state": "accepted", "archived": false, "hash": "904fd6d288558406eddb4563dea923d4998ffaef", "submitter": { "id": 218, "url": "https://patchwork.libcamera.org/api/people/218/?format=api", "name": "Antoine Bouyer", "email": "antoine.bouyer@nxp.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23699/mbox/", "series": [ { "id": 5260, "url": "https://patchwork.libcamera.org/api/series/5260/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5260", "date": "2025-07-01T08:58:15", "name": "pipeline: imx8-isi: Add multicamera support", "version": 4, "mbox": "https://patchwork.libcamera.org/series/5260/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23699/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23699/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 7904FC3293\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 1 Jul 2025 09:00:36 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2549468E1C;\n\tTue, 1 Jul 2025 11:00:32 +0200 (CEST)", "from AS8PR04CU009.outbound.protection.outlook.com\n\t(mail-westeuropeazlp170110003.outbound.protection.outlook.com\n\t[IPv6:2a01:111:f403:c201::3])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3431368E14\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 1 Jul 2025 11:00:29 +0200 (CEST)", "from GVXPR04MB9831.eurprd04.prod.outlook.com (2603:10a6:150:11c::8)\n\tby AS8PR04MB7896.eurprd04.prod.outlook.com (2603:10a6:20b:2a2::12)\n\twith Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.23;\n\tTue, 1 Jul 2025 09:00:28 +0000", "from GVXPR04MB9831.eurprd04.prod.outlook.com\n\t([fe80::4634:3d9c:c4a:641a]) by\n\tGVXPR04MB9831.eurprd04.prod.outlook.com\n\t([fe80::4634:3d9c:c4a:641a%5]) with mapi id 15.20.8901.018;\n\tTue, 1 Jul 2025 09:00:27 +0000" ], "Authentication-Results": [ "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=nxp.com header.i=@nxp.com header.b=\"OEpH7Dx1\";\n\tdkim-atps=neutral", "dkim=none (message not signed)\n\theader.d=none;dmarc=none action=none header.from=nxp.com;" ], "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n\tb=X3CpJF6MYcx3wW5s6RKbn/77w6Sawmr24cgg+bDlQj6mbKNV3zGLHIV9dHR4TaswWWyKIwkfCYCjNqMQ7Ls0+izcwhtET4l307zjw3nBlrn1gjs2DipM9UlUXhz5FJCrUJcdFCjkMKvm44aSME0X3bc77t46bA1TmhpymI8cT6jIEIEnceqGtFI4YCKuMnFLEky/aFcrurg7ZEqjkAmVKbtWr8MoprUimzuam9A9ctvfKJGss/dbfSgf37fr/+WzKDw6cMb3ZVs6S0KuygWUC2/5ECaSenA9agzJJsxpI/N/zqRWd7e65to862vgv5XKNBjoDyZpeoFntva643pgZw==", "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n\ts=arcselector10001;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n\tbh=QRlsf8El1s0fYDgbYG3OXQ3Zk+cyQvlWW1pdWrtidvo=;\n\tb=gLEyy+M62ekxu4LaIVgvVvSSftDXFzefjns7z4C4dE4a7SvMkTZOdFrALQKNMnkVM1yYV/eI/zH34rf1Wctcr+HivtIjzgiyDdBxO1R3SeAXo7xqLl3rkvi6vccmGygAfvflNser0Mzv437M14QboXJz+qiPVn+HrG0djZ/lUwCHuROVpHg/oFdF2nqMPFRSXkcXRAH5P9LXv49Uqcj6XXeUQ5kApM69X432Db/I8tVRCVi2h0f6l1+bXdJbaI1+2kQo/pknrA46fdpk14NcaUcyJRFY1E/1NjPGGpuMXTGuf+dBP/MxIUkBpcG2LPbw72HcXMyjipzWekr2XlTSbw==", "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass\n\tsmtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com;\n\tdkim=pass header.d=nxp.com; arc=none", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n\tbh=QRlsf8El1s0fYDgbYG3OXQ3Zk+cyQvlWW1pdWrtidvo=;\n\tb=OEpH7Dx18Mzhyc8PRCDzejLC5k7MU7EB5v6CTfe9/vUBAZhR8HjPGla/5JJSC/XJ7bXaLTDC64AoEYg+ofJr5xpQ8mUwHOVv2PTEQXQaN40P0SvIuOEnJYweDh3KkkdyZBhZSxwUWqmzonH8FsfC4htA/143ir0MhE9yn5VUgDMkUjjubVdTFqydt1/BawVMAAONGlH2gDhdPCk/UQsEt7qI8SYGYkgukVpKIAljF2E+TJUYuP/UvpbS27NX4enCqaVY4biSYWXGU6nkxwvr+jLAUyH9ETL9FXMG+M/r9I2Uohg4z+jSRXUwCIJrrRilnGvlqBVcJwxxWuhRCuwWIg==", "From": "Antoine Bouyer <antoine.bouyer@nxp.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "julien.vuillaumier@nxp.com, Antoine Bouyer <antoine.bouyer@nxp.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>", "Subject": "[PATCH v4 2/2] pipeline: imx8-isi: Add multicamera support", "Date": "Tue, 1 Jul 2025 10:58:17 +0200", "Message-Id": "<20250701085818.2447600-3-antoine.bouyer@nxp.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20250701085818.2447600-1-antoine.bouyer@nxp.com>", "References": "<20250701085818.2447600-1-antoine.bouyer@nxp.com>", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain", "X-ClientProxiedBy": "FR4P281CA0220.DEUP281.PROD.OUTLOOK.COM\n\t(2603:10a6:d10:e4::15) To GVXPR04MB9831.eurprd04.prod.outlook.com\n\t(2603:10a6:150:11c::8)", "MIME-Version": "1.0", "X-MS-PublicTrafficType": "Email", "X-MS-TrafficTypeDiagnostic": "GVXPR04MB9831:EE_|AS8PR04MB7896:EE_", "X-MS-Office365-Filtering-Correlation-Id": "38ec3f06-583d-48b7-7330-08ddb87db88a", "X-LD-Processed": "686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr", "X-MS-Exchange-SenderADCheck": "1", "X-MS-Exchange-AntiSpam-Relay": "0", "X-Microsoft-Antispam": "BCL:0;\n\tARA:13230040|52116014|366016|376014|19092799006|1800799024|38350700014;", "X-Microsoft-Antispam-Message-Info": "X40MP9Rrf8DG0YY5Sp1OGRTsWvGVPnZszsqG17lV09lpOXGH8Uty+ptZL6TOdaaVSD4SlK8055mXE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F8Hg0BtlNfEJamI+Y7acFb05oi37lAqHIaq7jNCaC0tGVNwKofsy+1nTVdllNLINgYy7kwAr+oGKnIgaIx6WCBcao79V4mOdDbYZ0a6NW8oejHzprEJysd/H+W8Cc2ObDB5EQCZG8lmnkkMIdjUTzwLU5u7LnD/tkwCFordMU5ZLyuJpD8ckbAlPwvD+qCo6z0pH6DVIIROn5Red7g7BSXjt4n7bNuRajPjruLMfD2S9L/hQ1jWijKv5dq98rl1fLNF/g0lxmUDVR/eWfkDkqLM65dHN7y7Dqzrvk5BBIaLCc8rOmJNE4pXD97vLnCmPnVdILMQvHT3ObqnFpzd9BuPjnQY9g==", "X-Forefront-Antispam-Report": "CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;\n\tIPV:NLI; SFV:NSPM; H:GVXPR04MB9831.eurprd04.prod.outlook.com; PTR:;\n\tCAT:NONE; \n\tSFS:(13230040)(52116014)(366016)(376014)(19092799006)(1800799024)(38350700014);\n\tDIR:OUT; SFP:1101; ", "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1", "X-MS-Exchange-AntiSpam-MessageData-0": "CJ2lt6wTo2S9Sewe6nWEVJ706C9oIAQTt8j27sAXj9+nLFg0vIjfWt2JkYQSN7AKYzeqKRkdo7GSlSnFfqZ6gLR/wsGqYWJrrEwM7frwqtFYC4euYT5wLkoy+KLBiCoOrCqx0fG3KByyBs78JgLADMRQ1DO4tZ+/g2pmQ2txL+YOV+EimxxNTCJ5U5K73IxXQQzu8FgPbOp4Pbwrbl3sqKBgLKB+Wx7AgDdSAmtB39Kj3g5Yfvd6o2KaBjDjsm9VUFCP4ZCkvLfJO98nxMXrH+h2E0fuq7s4wJPrbdRxQ940442FGrNb0LXwXwh/Ixa03tlP2iZn/XFWXeKZ6cJVEn6oHawG07g41bCjKVS49DGrWLDRPO7+gIK/gYlSrmOVbxUiKxBS3g58n8GvhRe6PKCAp5TPfD6Ph62y/L2MP8q1etCdGUykQLob3uCLpQHjCZgYEREENhc40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bLCFZ3myrDM7r3bif3+2/4fb0guTdSqJ+CDbi85vh4tfAqY/iymeqhQvSvdIY0VSBdkutVRrKi8b+sGjuQwq71J54/Cr9SDA==", "X-OriginatorOrg": "nxp.com", "X-MS-Exchange-CrossTenant-Network-Message-Id": "38ec3f06-583d-48b7-7330-08ddb87db88a", "X-MS-Exchange-CrossTenant-AuthSource": "GVXPR04MB9831.eurprd04.prod.outlook.com", "X-MS-Exchange-CrossTenant-AuthAs": "Internal", "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "01 Jul 2025 09:00:26.6066\n\t(UTC)", "X-MS-Exchange-CrossTenant-FromEntityHeader": "Hosted", "X-MS-Exchange-CrossTenant-Id": "686ea1d3-bc2b-4c6f-a92c-d99c5c301635", "X-MS-Exchange-CrossTenant-MailboxType": "HOSTED", "X-MS-Exchange-CrossTenant-UserPrincipalName": "7nKkBMnbVsC4jlL6MZeRFZ8QtEjd3T58OPPayV9xGlVyN+83p95qJo5jKCM2b3rGBGmZxLdw9nthkTKKNgITNA==", "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "AS8PR04MB7896", "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": "ISI can be used to support multiple cameras at the same time in the media\ndevice. A dedicated pad is assigned to each camera by HW (dts). We then\nassign one (or more) source pad(s) depending on ISI constraints in the SoC.\n\nSince ISI may have different number of pipes depending on SoC, the number\nof cameras is computed _before_ going through all pipeline's components,\nto limit number of pipes that could be assigned to a camera.\n\nFor instance, 3 is targeted as maximum amount of streams per camera as\ndefined by 'kNumStreams' constant. If 2 cameras are connected, with\nonly 5 ISI pipes, this target cannot be achieved. In such case, 2 streams\nare assigned to each camera.\n\nOn the other hand, if ISI has 8 source pads (from index 6 to 13) and 2\ncameras, first three source pads [6:8] are assigned to first camera, and\nthe three next source pads [9:11] are assigned to the second camera. All\nthese pads (sink and sources) must have same format to prevent configuration\nmismatch during start.\n\nHowever, since ISI routing must be performed _before_ any stream becomes\nactive, 'setRouting' is now executed during the 'match' step, instead of\n'configure'. Indeed, it is up to the application to decide when a camera\n'start' is executed: this could happen before or after the other camera\nconfiguration is executed. Moving routing into the 'match' step makes sure\nthe routing is correctly applied before any 'start' is executed.\n\nSigned-off-by: Antoine Bouyer <antoine.bouyer@nxp.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 112 ++++++++++++-------\n 1 file changed, 74 insertions(+), 38 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\nindex 4e632e852ebf..72e055e400c6 100644\n--- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n+++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n@@ -55,7 +55,7 @@ public:\n \n \tunsigned int pipeIndex(const Stream *stream)\n \t{\n-\t\treturn stream - &*streams_.begin();\n+\t\treturn stream - &*streams_.begin() + xbarSourceOffset_;\n \t}\n \n \tunsigned int getRawMediaBusFormat(PixelFormat *pixelFormat) const;\n@@ -69,7 +69,8 @@ public:\n \n \tstd::vector<Stream *> enabledStreams_;\n \n-\tunsigned int xbarSink_;\n+\tunsigned int xbarSink_ = 0;\n+\tunsigned int xbarSourceOffset_ = 0;\n };\n \n class ISICameraConfiguration : public CameraConfiguration\n@@ -807,34 +808,9 @@ int PipelineHandlerISI::configure(Camera *camera, CameraConfiguration *c)\n \tISICameraConfiguration *camConfig = static_cast<ISICameraConfiguration *>(c);\n \tISICameraData *data = cameraData(camera);\n \n-\t/* All links are immutable except the sensor -> csis link. */\n-\tconst MediaPad *sensorSrc = data->sensor_->entity()->getPadByIndex(0);\n-\tsensorSrc->links()[0]->setEnabled(true);\n-\n-\t/*\n-\t * Reset the crossbar switch routing and enable one route for each\n-\t * requested stream configuration.\n-\t *\n-\t * \\todo Handle concurrent usage of multiple cameras by adjusting the\n-\t * routing table instead of resetting it.\n-\t */\n-\tV4L2Subdevice::Routing routing = {};\n-\tunsigned int xbarFirstSource = crossbar_->entity()->pads().size() - pipes_.size();\n-\n-\tfor (const auto &[idx, config] : utils::enumerate(*c)) {\n-\t\tuint32_t sourcePad = xbarFirstSource + idx;\n-\t\trouting.emplace_back(V4L2Subdevice::Stream{ data->xbarSink_, 0 },\n-\t\t\t\t V4L2Subdevice::Stream{ sourcePad, 0 },\n-\t\t\t\t V4L2_SUBDEV_ROUTE_FL_ACTIVE);\n-\t}\n-\n-\tint ret = crossbar_->setRouting(&routing, V4L2Subdevice::ActiveFormat);\n-\tif (ret)\n-\t\treturn ret;\n-\n-\t/* Apply format to the sensor and CSIS receiver. */\n+\t/* Apply format to the sensor, CSIS receiver and crossbar sink pad. */\n \tV4L2SubdeviceFormat format = camConfig->sensorFormat_;\n-\tret = data->sensor_->setFormat(&format);\n+\tint ret = data->sensor_->setFormat(&format);\n \tif (ret)\n \t\treturn ret;\n \n@@ -846,10 +822,17 @@ int PipelineHandlerISI::configure(Camera *camera, CameraConfiguration *c)\n \tif (ret)\n \t\treturn ret;\n \n-\t/* Now configure the ISI and video node instances, one per stream. */\n-\tdata->enabledStreams_.clear();\n-\tfor (const auto &config : *c) {\n-\t\tPipe *pipe = pipeFromStream(camera, config.stream());\n+\t/*\n+\t * As links on the output of the crossbar switch are immutable, the\n+\t * routing table configured at match() time creates a media pipeline\n+\t * that includes all the ISI pipelines corresponding to streams of this\n+\t * camera, regardless of whether or not the streams are used in the\n+\t * camera configuration. Set the format on the sink pad of all\n+\t * corresponding ISI pipelines to avoid link validation failures when\n+\t * starting streaming on the media pipeline.\n+\t */\n+\tfor (unsigned i = 0; i < data->streams_.size(); i++) {\n+\t\tPipe *pipe = &pipes_.at(data->xbarSourceOffset_ + i);\n \n \t\t/*\n \t\t * Set the format on the ISI sink pad: it must match what is\n@@ -858,6 +841,15 @@ int PipelineHandlerISI::configure(Camera *camera, CameraConfiguration *c)\n \t\tret = pipe->isi->setFormat(0, &format);\n \t\tif (ret)\n \t\t\treturn ret;\n+\t}\n+\n+\t/*\n+\t * Now configure the ISI pipeline source pad and video node instances,\n+\t * one per enabled stream.\n+\t */\n+\tdata->enabledStreams_.clear();\n+\tfor (const auto &config : *c) {\n+\t\tPipe *pipe = pipeFromStream(camera, config.stream());\n \n \t\t/*\n \t\t * Configure the ISI sink compose rectangle to downscale the\n@@ -969,6 +961,20 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator)\n \tif (!isiDev_)\n \t\treturn false;\n \n+\t/* Count the number of sensors, to create one camera per sensor. */\n+\tunsigned cameraCount = 0;\n+\tfor (MediaEntity *entity : isiDev_->entities()) {\n+\t\tif (entity->function() != MEDIA_ENT_F_CAM_SENSOR)\n+\t\t\tcontinue;\n+\n+\t\tcameraCount++;\n+\t}\n+\n+\tif (!cameraCount) {\n+\t\tLOG(ISI, Error) << \"No camera sensor found\";\n+\t\treturn false;\n+\t}\n+\n \t/*\n \t * Acquire the subdevs and video nodes for the crossbar switch and the\n \t * processing pipelines.\n@@ -1012,12 +1018,24 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \t}\n \n+\tif (cameraCount > pipes_.size()) {\n+\t\tLOG(ISI, Error) << \"Too many cameras\";\n+\t\treturn false;\n+\t}\n+\n \t/*\n \t * Loop over all the crossbar switch sink pads to find connected CSI-2\n \t * receivers and camera sensors.\n+\t *\n+\t * In multicamera case, limit maximum amount of streams to allow all\n+\t * sensors to get at least one dedicated pipe.\n \t */\n \tunsigned int numCameras = 0;\n \tunsigned int numSinks = 0;\n+\tconst unsigned int xbarFirstSource = crossbar_->entity()->pads().size() - pipes_.size();\n+\tconst unsigned int maxStreams = pipes_.size() / cameraCount;\n+\tV4L2Subdevice::Routing routing = {};\n+\n \tfor (MediaPad *pad : crossbar_->entity()->pads()) {\n \t\tunsigned int sink = numSinks;\n \n@@ -1048,17 +1066,23 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator)\n \t\t\tcontinue;\n \t\t}\n \n+\t\t/* All links are immutable except the sensor -> csis link. */\n+\t\tconst MediaPad *sensorSrc = sensor->getPadByIndex(0);\n+\t\tsensorSrc->links()[0]->setEnabled(true);\n+\n \t\t/* Create the camera data. */\n-\t\t/*\n-\t\t * \\todo compute available pipes per camera instead of using\n-\t\t * pipes_.size() for multi cameras case.\n-\t\t */\n \t\tstd::unique_ptr<ISICameraData> data =\n-\t\t\tstd::make_unique<ISICameraData>(this, pipes_.size());\n+\t\t\tstd::make_unique<ISICameraData>(this, maxStreams);\n \n \t\tdata->sensor_ = CameraSensorFactoryBase::create(sensor);\n \t\tdata->csis_ = std::make_unique<V4L2Subdevice>(csi);\n \t\tdata->xbarSink_ = sink;\n+\t\tdata->xbarSourceOffset_ = numCameras * data->streams_.size();\n+\n+\t\tLOG(ISI, Debug)\n+\t\t\t<< \"cam\" << numCameras\n+\t\t\t<< \" streams \" << data->streams_.size()\n+\t\t\t<< \" offset \" << data->xbarSourceOffset_;\n \n \t\tret = data->init();\n \t\tif (ret) {\n@@ -1073,6 +1097,14 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator)\n \t\t\t std::inserter(streams, streams.end()),\n \t\t\t [](Stream &s) { return &s; });\n \n+\t\t/* Add routes to the crossbar switch routing table. */\n+\t\tfor (unsigned i = 0; i < data->streams_.size(); i++) {\n+\t\t\tunsigned int sourcePad = xbarFirstSource + data->xbarSourceOffset_ + i;\n+\t\t\trouting.emplace_back(V4L2Subdevice::Stream{ data->xbarSink_, 0 },\n+\t\t\t\t\t V4L2Subdevice::Stream{ sourcePad, 0 },\n+\t\t\t\t\t V4L2_SUBDEV_ROUTE_FL_ACTIVE);\n+\t\t}\n+\n \t\tstd::shared_ptr<Camera> camera =\n \t\t\tCamera::create(std::move(data), id, streams);\n \n@@ -1080,6 +1112,10 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator)\n \t\tnumCameras++;\n \t}\n \n+\tret = crossbar_->setRouting(&routing, V4L2Subdevice::ActiveFormat);\n+\tif (ret)\n+\t\treturn false;\n+\n \treturn numCameras > 0;\n }\n \n", "prefixes": [ "v4", "2/2" ] }