From patchwork Tue Aug 2 10:34:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16909 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 93A76BE173 for ; Tue, 2 Aug 2022 10:34:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1CA4963313; Tue, 2 Aug 2022 12:34:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659436457; bh=nSWB8sNepG9Fvpdxftwhk62VrOc2D1WLkQGCKEBvEEw=; 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=jPl88a9aKw2HSnH6VV75JGE7UaJolekYiBLvYpyo/ErV2wHewic2a+SbVVEggwhcg gbcBYK/FrFa53s/5qSdcHyzINT4Iwygq32kUEHPf9pGOBtH69EixEESTxWzCBQBAAt TXNc8tSZsKaDbj0i3O4LnV33YnfeMwFLbBgPvNcHKq0xWZL+MZxqvG2fWs5RYxrLua P16wDNDTtZIUgnfLAB8d/5lXU9wBtMetGoBO7xvZBY+LoaXHPDGUbEFreCvncpyZUE yNuFOgQ9B3vPZJg717dbpWXRIngfYPSfYTviAfrS0EnEhxRmAxp5TF9vzFCkMsIpce HrKa7phBToW7A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 203E8603E7 for ; Tue, 2 Aug 2022 12:34:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BE8ipUGD"; 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 998FD25B for ; Tue, 2 Aug 2022 12:34:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659436455; bh=nSWB8sNepG9Fvpdxftwhk62VrOc2D1WLkQGCKEBvEEw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BE8ipUGDDEeNjHmzAUn39SxBJgNLeXMBlsAJLKUuANZtu5L8xasPeiE/Y3UsvJFn1 zxuL4ZymOe2KJY2qQfnoXnT3/XferOPVK4PdTYXS6rV3odwVeVGGeJS/ZIyt2ML0RG hpZMSXptwWdBhu0csBzl7KdyoLVhRLQS73tXTeWA= To: libcamera-devel@lists.libcamera.org Date: Tue, 2 Aug 2022 13:34:10 +0300 Message-Id: <20220802103410.2735-1-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 v1.1 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" 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 Reviewed-by: Jacopo Mondi --- Changes since v1: - Simplify a condition - Fix author --- src/libcamera/pipeline/simple/simple.cpp | 26 +++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 2a8811183907..0e169fbec1b5 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,15 @@ 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 && pad != e.sink && pad != e.source) + continue; + for (MediaLink *link : pad->links()) { if (link == sinkLink) continue;