From patchwork Wed Mar 3 14:16:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11475 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 DDF63BD80C for ; Wed, 3 Mar 2021 14:16:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6D6A068A91; Wed, 3 Mar 2021 15:16:55 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E4D6B68A7E for ; Wed, 3 Mar 2021 15:16:53 +0100 (CET) Received: from guri.fritz.box (p200300c7cf3838007d25342b1528aa90.dip0.t-ipconnect.de [IPv6:2003:c7:cf38:3800:7d25:342b:1528:aa90]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 5A4231F45D4E; Wed, 3 Mar 2021 14:16:53 +0000 (GMT) From: Dafna Hirschfeld To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Mar 2021 15:16:44 +0100 Message-Id: <20210303141644.10873-1-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 Subject: [libcamera-devel] [PATCH] libcamera: pipeline: simple: walk the pipline by following the first link 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: , Cc: kernel@collabora.com MIME-Version: 1.0 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When walking the pipeline, follow the first link of each source pad. This patch removes a redundant condition for choosing the link: "(link->flags() & MEDIA_LNK_FL_ENABLED) || !(link->flags() & MEDIA_LNK_FL_IMMUTABLE)" since it always returns true. Signed-off-by: Dafna Hirschfeld Reviewed-by: Laurent Pinchart Tested-by: Laurent Pinchart --- Note, I could only make sure that the patch compiles, but I don't have the hardware to test it. src/libcamera/pipeline/simple/simple.cpp | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 7fba495c..1aeabcf7 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -279,12 +279,17 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, if (source->function() == MEDIA_ENT_F_IO_V4L) break; - /* Use the first output pad that has links. */ + /* + * Use the first output pad that has links and follow its first + * link. + */ MediaPad *sourcePad = nullptr; + MediaLink *sourceLink = nullptr; for (MediaPad *pad : source->pads()) { if ((pad->flags() & MEDIA_PAD_FL_SOURCE) && !pad->links().empty()) { sourcePad = pad; + sourceLink = pad->links().front(); break; } } @@ -292,22 +297,6 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, if (!sourcePad) return; - /* - * Use the first link that is enabled or can be enabled (not - * immutable). - */ - MediaLink *sourceLink = nullptr; - for (MediaLink *link : sourcePad->links()) { - if ((link->flags() & MEDIA_LNK_FL_ENABLED) || - !(link->flags() & MEDIA_LNK_FL_IMMUTABLE)) { - sourceLink = link; - break; - } - } - - if (!sourceLink) - return; - entities_.push_back({ source, sourceLink }); source = sourceLink->sink()->entity();