From patchwork Mon Aug 1 00:05:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16887 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 21B89BE173 for ; Mon, 1 Aug 2022 00:06:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CFE3A63330; Mon, 1 Aug 2022 02:06:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659312364; bh=A+plz7jYk6G2UzvKnAwXKWZGJTdy/JSjFZehHss5AQM=; 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=AZ/C4dgTYRlPbtuCn86A3xwoTnpy1o8uh23g0y+HevG/Ywnquh/5+aIGBQF4Hf8Mp VY0uK/qpc3PKIMz25IdwW+oDRLASHTScXnGG/TAuatPDLzCZxGtaepBt1YsqpDDj3d N7LulyDKXi8AglkKmxmw4qpUb6pUz6XiyR7QMcwtuVHDWr2KQ8eDzCDZPgFco34sVj Gd8WrJzcAjx9CTEH0vUdVYv/trRysmgqHdJuelOQRbL5ixcwuIHy+QUY/a87se7weJ 5EL5t/QPJ2rIW9B7KYOJjlkpyKAKTNs3GhYPrEHzK0GbFygmgQY1fjCikmV2/mDNYK 4osYVaWWCJUhQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2133D63323 for ; Mon, 1 Aug 2022 02:06:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JNA3ygGK"; 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 B0AF69AA for ; Mon, 1 Aug 2022 02:06:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659312362; bh=A+plz7jYk6G2UzvKnAwXKWZGJTdy/JSjFZehHss5AQM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JNA3ygGKrAkuYp7H7vCXMQ/NuTNeGvG3mpeSUCc/d8ihxsHpDJwo3OIfXY3ybJv7L PBhP86qxHVoYr8ldohnSK4zAAMyjhWm5MZwdP0tJCVRs8IssrqjbuS1D6WSTjvGhxa GUB27oP9w0QV6vvKinK3Q1/7bYVCzyWAMvReepQc= To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Aug 2022 03:05:40 +0300 Message-Id: <20220801000543.3501-11-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 10/13] libcamera: pipeline: simple: Setup links in the context of sink entities 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" To setup links the pipeline handler iterates over all entities in the pipeline and disables all links but the ones we want to enable. Some entities don't allow multiple sink links to be enabled, so the iteration needs to be based on sink entities, disabling all their links first and then enabling the sink link that is part of the pipeline. The loop implementation iterates over all Entity instances, and uses their source link to locate the MediaEntity for the connected sink. The sink entity is then processed in the context of the source's loop iteration. This prevents the code from being able to access extra information about the sink entity, as we only have access to the MediaEntity, not the Entity. To prepare for subdev routing support that will require accessing additional entity information, refactor the loop to process the sink entity in the context of its Entity instance. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/simple/simple.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 731d355efda6..4bde9caa7254 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -578,15 +578,23 @@ int SimpleCameraData::setupLinks() * multiple sink links to be enabled together, even on different sink * pads. We must thus start by disabling all sink links (but the one we * want to enable) before enabling the pipeline link. + * + * The entities_ list stores entities along with their source link. We + * need to process the link in the context of the sink entity, so + * record the source link of the current entity as the sink link of the + * next entity, and skip the first entity in the loop. */ + MediaLink *sinkLink = nullptr; + for (SimpleCameraData::Entity &e : entities_) { - if (!e.sourceLink) - break; + if (!sinkLink) { + sinkLink = e.sourceLink; + continue; + } - MediaEntity *remote = e.sourceLink->sink()->entity(); - for (MediaPad *pad : remote->pads()) { + for (MediaPad *pad : e.entity->pads()) { for (MediaLink *link : pad->links()) { - if (link == e.sourceLink) + if (link == sinkLink) continue; if ((link->flags() & MEDIA_LNK_FL_ENABLED) && @@ -598,11 +606,13 @@ int SimpleCameraData::setupLinks() } } - if (!(e.sourceLink->flags() & MEDIA_LNK_FL_ENABLED)) { - ret = e.sourceLink->setEnabled(true); + if (!(sinkLink->flags() & MEDIA_LNK_FL_ENABLED)) { + ret = sinkLink->setEnabled(true); if (ret < 0) return ret; } + + sinkLink = e.sourceLink; } return 0;