From patchwork Fri Jun 27 09:46:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 23670 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 7C8F7BDCBF for ; Fri, 27 Jun 2025 09:48:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 24EB368E00; Fri, 27 Jun 2025 11:48:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Bv8+oMTJ"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DA32568DF4 for ; Fri, 27 Jun 2025 11:48:12 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-45362642f3bso2800135e9.2 for ; Fri, 27 Jun 2025 02:48:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1751017692; x=1751622492; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6FiYlkSSoNgr+KpU0D0i7w6SDl0C32f+GR8qpH8YvxM=; b=Bv8+oMTJiwYnzNtteXoIX3nrgX7KIojaMDwgRUTdWVtk663z98z0yh7tUhGkTpjP8H biS2/tSYGwOK63YfckdstEMVdHIMEZ/FCHRBJqIBIvXqkIVqUEfXYyGxNO7XUxZIy3Ee YSUaOFRpCCqA3JZfrb4GbzWD2b2ZRTgbR0l4+2DIwdS/JYFIqd8M/pyjiCpGCnY4SDNL eB2CXi2X2vBqWdZ+6aoqy0jDmJD/XdWDDxPJ1gZCnO8FIjYgf9KdciG13MDk3/ZFWIAC cpTJREfGrUrxXfAXEAkXtHGnmJuAiACZoViezEDec5sGzSQe159BnWtUNozGrNw3jsm0 xa3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751017692; x=1751622492; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6FiYlkSSoNgr+KpU0D0i7w6SDl0C32f+GR8qpH8YvxM=; b=n1TVJRpy68Y19oLxSTpt1DwpXhXeX8ZPogcT/t7Xdb1saLVY8IB8gtNQo1rI4Wjs8e Tlb/jfYVOwitBXsm25Y8xJP+lBaVMi6GVF9gMX4ADDBiBTO/UMmMGoWNB89XF0xcXhNR lnBehk565+s2dbAisc/impUYlPi8Sck9o17T++n7KsDtLtKc54u+30lcTALkPl9cr4Gm rnwogodthMexkhZdCyrzEnxhrmY5CGpCuQ6GkyDo6/YgVGywOZrEm9xAV+BXxnCxlEZE BqxLHjo0KDv5av4DLmdRo0VLutu38zk/tr3SaiVtBqEty+tKXDxZCBO2ekkIvNBc2cuz FnDg== X-Gm-Message-State: AOJu0YznAvzx6CtAvz9AM5iQ76fTnqLgdXXM8PNmvDOK5H+8AjLcCbRV U5SM57KZdEMAsZcPqYib4sfHR51B8Bic0qFBg1xg0bv8EQD5eMU8mfRDc0oYfc+ETCBkExzlsj1 +Qxui X-Gm-Gg: ASbGncvAhQxzX+XvG161wHzvk90my/5z/JMu52xdPnEJxSkUGJWFTDV0s/Qj0hXOxrA cifJT4pUddlAW2W5COBzUygJ9bWceSn0PcknzBgNHm4deLfhpIslu/x7gKfIMenjLm0XzIBwwzh ypov6h+ZdVfg77EzA4xHG0TaCF1If0no5Md7tlEQj9UyQkR3h9qB+bwcBLXQ/s6a+0x8lGbQFgQ m6QS+EZWC04kfqRHHutNiWj9hgygYolw9fijIgHtkfTcX1m4Kh1Mdi+NWXJP6cc17izAedA1IT9 UJlxaXdVbeTeYRm9JqHAUuJmKIxPKkhWd6YhABXv12TNeJiNBXOlao2AovK7Ov+mET9fafwHgEy 3/EmLcA== X-Google-Smtp-Source: AGHT+IE6m6dEDe5t6z5z8C0WBZz9fkwsSa3DdQVzcfTEyhn11mQ3ktnhvVp0BLyvFwbhYogQf0PZcg== X-Received: by 2002:a05:600c:c05a:b0:453:435a:6cda with SMTP id 5b1f17b1804b1-4538ee345a6mr7747775e9.2.1751017691876; Fri, 27 Jun 2025 02:48:11 -0700 (PDT) Received: from NAUSH-P-DELL.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a88c7fa2a7sm2218406f8f.21.2025.06.27.02.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jun 2025 02:48:11 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck , Umang Jain , Laurent Pinchart Subject: [PATCH v2 1/1] pipeline: rpi: Fix for enumerating the media graphs Date: Fri, 27 Jun 2025 10:46:26 +0100 Message-ID: <20250627094809.1296587-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250627094809.1296587-1-naush@raspberrypi.com> References: <20250627094809.1296587-1-naush@raspberrypi.com> MIME-Version: 1.0 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" When there are multiple entities between the sensor and CFE device (e.g. a serialiser and deserialiser or multiple mux devices), the media graph enumeration would work incorrectly and report that the frontend entity was not found. This is because the found flag was stored locally in a boolean and got lost in the recursion. Fix this by explicitly tracking and returning the frontend found flag through the return value of enumerateVideoDevices(). This ensures the flag does not get lost through nested recursion. This flag can also be used to fail a camera registration if the frontend is not found. Signed-off-by: Naushir Patuck Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- .../pipeline/rpi/common/pipeline_base.cpp | 22 +++++++++++-------- .../pipeline/rpi/common/pipeline_base.h | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index e14d3b913aaa..eafe94427dbc 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -806,7 +806,8 @@ int PipelineHandlerBase::registerCamera(std::unique_ptr &camera * chain. There may be a cascade of devices in this chain! */ MediaLink *link = sensorEntity->getPadByIndex(0)->links()[0]; - data->enumerateVideoDevices(link, frontendName); + if (!data->enumerateVideoDevices(link, frontendName)) + return -EINVAL; ipa::RPi::InitResult result; if (data->loadIPA(&result)) { @@ -1018,16 +1019,20 @@ void CameraData::freeBuffers() * | Sensor2 | | Sensor3 | * +---------+ +---------+ */ -void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &frontend) +bool CameraData::enumerateVideoDevices(MediaLink *link, const std::string &frontend) { const MediaPad *sinkPad = link->sink(); const MediaEntity *entity = sinkPad->entity(); bool frontendFound = false; + /* Once we reach the Frontend entity, we are done. */ + if (link->sink()->entity()->name() == frontend) + return true; + /* We only deal with Video Mux and Bridge devices in cascade. */ if (entity->function() != MEDIA_ENT_F_VID_MUX && entity->function() != MEDIA_ENT_F_VID_IF_BRIDGE) - return; + return false; /* Find the source pad for this Video Mux or Bridge device. */ const MediaPad *sourcePad = nullptr; @@ -1039,7 +1044,7 @@ void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &front * and this branch in the cascade. */ if (sourcePad) - return; + return false; sourcePad = pad; } @@ -1056,12 +1061,9 @@ void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &front * other Video Mux and Bridge devices. */ for (MediaLink *l : sourcePad->links()) { - enumerateVideoDevices(l, frontend); - /* Once we reach the Frontend entity, we are done. */ - if (l->sink()->entity()->name() == frontend) { - frontendFound = true; + frontendFound = enumerateVideoDevices(l, frontend); + if (frontendFound) break; - } } /* This identifies the end of our entity enumeration recursion. */ @@ -1076,6 +1078,8 @@ void CameraData::enumerateVideoDevices(MediaLink *link, const std::string &front bridgeDevices_.clear(); } } + + return frontendFound; } int CameraData::loadPipelineConfiguration() diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h index 4c5743e04f86..4bce4ec4f978 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.h +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h @@ -68,7 +68,7 @@ public: void freeBuffers(); virtual void platformFreeBuffers() = 0; - void enumerateVideoDevices(MediaLink *link, const std::string &frontend); + bool enumerateVideoDevices(MediaLink *link, const std::string &frontend); int loadPipelineConfiguration(); int loadIPA(ipa::RPi::InitResult *result);