From patchwork Thu Aug 5 22:24:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13233 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 D2ACEC3238 for ; Thu, 5 Aug 2021 22:25:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A36E68888; Fri, 6 Aug 2021 00:24:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="efA7V7Pv"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 688396880D for ; Fri, 6 Aug 2021 00:24:56 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 10D3EE6B for ; Fri, 6 Aug 2021 00:24:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628202296; bh=Dv6AGKiQbU1IefbMdrQivJnjZwPcTQwEyUhtER1M2OE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=efA7V7PvZD7bZF2VsCqnCagMeQMP87Bx0V2n9gLaAf3MdzydyxmzJx22QsiTX0MqE 55zMXCfkXP/ThntoxiN6Jpf69B4vMIprvXuI6GKlB5EcPzPOrJbA91VuIS7xy1sktu SvuE67CBYGm2EdYwydIZezzkAytCCWCqNfH9tIu4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 6 Aug 2021 01:24:28 +0300 Message-Id: <20210805222436.6263-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210805222436.6263-1-laurent.pinchart@ideasonboard.com> References: <20210805222436.6263-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 02/10] libcamera: pipeline: simple: Add sink and source pads to entity data 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Record the sink and source pads through which an entity is traversed in the list of entities stored in the camera data. This prepares for implementing mutually exclusive access to entities between cameras. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/simple/simple.cpp | 38 ++++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index b29fff9820e5..e0695d052629 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -166,7 +166,22 @@ public: } struct Entity { + /* The media entity, always valid. */ MediaEntity *entity; + /* + * The local sink pad connected to the upstream entity, null for + * the camera sensor at the beginning of the pipeline. + */ + const MediaPad *sink; + /* + * The local source pad connected to the downstream entity, null + * for the video node at the end of the pipeline. + */ + const MediaPad *source; + /* + * The link to the downstream entity, null for the video node at + * the end of the pipeline. + */ MediaLink *link; }; @@ -288,16 +303,18 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, * encoders and image converters, and will end in a CSI capture device. */ std::unordered_set visited; - std::queue queue; + std::queue> queue; /* Remember at each entity where we came from. */ std::unordered_map parents; MediaEntity *entity = nullptr; - queue.push(sensor); + queue.push({ sensor, nullptr }); while (!queue.empty()) { - entity = queue.front(); + MediaPad *sinkPad; + + std::tie(entity, sinkPad) = queue.front(); queue.pop(); /* Found the capture device. */ @@ -317,8 +334,8 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, for (MediaLink *link : pad->links()) { MediaEntity *next = link->sink()->entity(); if (visited.find(next) == visited.end()) { - queue.push(next); - parents.insert({ next, { entity, link } }); + queue.push({ next, link->sink() }); + parents.insert({ next, { entity, sinkPad, pad, link } }); } } } @@ -349,7 +366,16 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, LOG(SimplePipeline, Debug) << "Found pipeline: " << utils::join(entities_, " -> ", - [](const Entity &e) { return e.entity->name(); }); + [](const Entity &e) { + std::string s = "["; + if (e.sink) + s += std::to_string(e.sink->index()) + "|"; + s += e.entity->name(); + if (e.source) + s += "|" + std::to_string(e.source->index()); + s += "]"; + return s; + }); } int SimpleCameraData::init()