From patchwork Mon Aug 1 00:05:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16889 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0E217C3276 for ; Mon, 1 Aug 2022 00:06:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BAD5063337; Mon, 1 Aug 2022 02:06:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659312366; bh=TQk6fI5Q2AksPdVVauwqZKx9y+y0bSo+Py1Sg3KJbO4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=st9lQQvrh22XlAsUva0cbfPrjNBlvFiWGFYwk8zjrViML28/MAJ+OxiyLGGvlFkIM mFduMyjA9PtirX6qKKrBzeIN+rAm+59XEnJWJXrrsW0/7kJ43RuoBkjXsRUscg9PEt gCOcJKexRYEOSJh98hQQn0d8txyk9NaVMe6egOHRVF5xWzwaVkewZfrSlWtxuvMM3B NBKVm5bw1o35SgrwB41kw9psq1/GMCJ9lM1zjQs8hvL2YBNCR6MNbIMOV5TZ1BWwZk m5ASgj3xM81sDwV7SR5SpxWkdty1U54h5jP2bmeQ3KnHFm0wqHBLnd6se0g1MjrgmE EixPgyojpbwDg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C8A5263317 for ; Mon, 1 Aug 2022 02:06:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WCGM3AWC"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6012930B; Mon, 1 Aug 2022 02:06:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659312365; bh=TQk6fI5Q2AksPdVVauwqZKx9y+y0bSo+Py1Sg3KJbO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WCGM3AWClLtj9kZV60zZu/r6FxPekUsXeGUvusXx8My2qzaJIjisajb9N498e8qac hz9S7cGL7SF+BhNyEjy6qtJzmMG0vZAKyEQG4YflecorCKAq33LrN8hFU8UIdUn3gF MFMgGHrPBObFO/E+LwGRfDoTp60flHcMVnI/+ldM= To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Aug 2022 03:05:42 +0300 Message-Id: <20220801000543.3501-13-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220801000543.3501-1-laurent.pinchart@ideasonboard.com> References: <20220801000543.3501-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 12/13] libcamera: pipeline: simple: Don't disable links carrying other streams X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Phi-Bang Nguyen If a subdev supports the internal routing API, pads unrelated to the pipeline for a given camera sensor may carry streams for other cameras. The link setup logic is updated to take this into account, by avoiding disabling links to unrelated pads. Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/simple/simple.cpp | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 2a8811183907..c80e462bc449 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -221,6 +221,11 @@ public: struct Entity { /* The media entity, always valid. */ MediaEntity *entity; + /* + * Whether or not the entity is a subdev that supports the + * routing API. + */ + bool supportsRouting; /* * The local sink pad connected to the upstream entity, null for * the camera sensor at the beginning of the pipeline. @@ -404,9 +409,13 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, */ std::vector pads; + bool supportsRouting = false; - if (sinkPad) + if (sinkPad) { pads = routedSourcePads(sinkPad); + if (!pads.empty()) + supportsRouting = true; + } if (pads.empty()) { for (const MediaPad *pad : entity->pads()) { @@ -421,7 +430,9 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, MediaEntity *next = link->sink()->entity(); if (visited.find(next) == visited.end()) { queue.push({ next, link->sink() }); - parents.insert({ next, { entity, sinkPad, pad, link } }); + + Entity e{ entity, supportsRouting, sinkPad, pad, link }; + parents.insert({ next, e }); } } } @@ -435,7 +446,7 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, * to the sensor. Store all the entities in the pipeline, from the * camera sensor to the video node, in entities_. */ - entities_.push_front({ entity, sinkPad, nullptr, nullptr }); + entities_.push_front({ entity, false, sinkPad, nullptr, nullptr }); for (auto it = parents.find(entity); it != parents.end(); it = parents.find(entity)) { @@ -617,6 +628,17 @@ int SimpleCameraData::setupLinks() } for (MediaPad *pad : e.entity->pads()) { + /* + * If the entity supports the V4L2 internal routing API, + * assume that it may carry multiple independent streams + * concurrently, and only disable links on the sink and + * source pads used by the pipeline. + */ + if (e.supportsRouting) { + if (pad != e.sink && pad != e.source) + continue; + } + for (MediaLink *link : pad->links()) { if (link == sinkLink) continue;