From patchwork Wed Jun 25 08:41:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 23650 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 0CBDCBDCBF for ; Wed, 25 Jun 2025 08:42:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 45C6068DF0; Wed, 25 Jun 2025 10:42:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="n3iNIdCI"; dkim-atps=neutral Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D294468DE6 for ; Wed, 25 Jun 2025 10:42:16 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3a4e57d018cso871078f8f.1 for ; Wed, 25 Jun 2025 01:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1750840936; x=1751445736; 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=h4YFCnw/Vnf4bWX7DPoVXHfCEVt0AT65TY4/SmZkWNM=; b=n3iNIdCIiDltzbx3SqgNRfWUtCBgKU7LCUj3Mc+Va0MfuxMqzsMqlos4OLbIoqJRt+ AoOkildZXi/EvvJn1DsKmR+EnglR3XsYVVsQpDIS/PRHZtCBRGikRyUnjbWbzga7ywG7 VQ45WBDRwSgLIpPnw5eY/yuTtJK9c+bTdPuKWWnzryQrg04CblzuXp0MYA7ea2A2qbG1 uRpg/CWR+Jc1HwQMqeAKgrWaBtC94i4RcqaZX5UBGmwPMm6owOXdndLLr8vLosscXfVh cpjJRBTEQtOxlC6WTMe3h2jo2EXGPRUn09Q/qDpNlJ16l9+R3w/a11/4HJfzTA9aSAv5 lktw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750840936; x=1751445736; 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=h4YFCnw/Vnf4bWX7DPoVXHfCEVt0AT65TY4/SmZkWNM=; b=oRyhTo8m87hnbCiAUeuw4gLs2g/C/eW3b0zrox84DbyEGm8BuR7VXQAVnENOXyfBD5 vQI0uPkvzSAS8r6bP+s0bRE3Kzq0/rQvM0c48TOLROoMDitjxxCdCDeW1WI8n1Fb4D2e sWpDljFQjdDebu14GzYW+w3u6S6qmKnRXmpwe+uF4POLQCFvbkcn5EdYMf7cOjyrcT2H SbDeC7+9PSHQksCObXnXO0EHIDC5thv6ncrbah2vKRwiZc+LOSkp47tj1nRoSV/dUNGt ZQAcSXt8thwr+Ri34w8lO+jom8ab+skOjWHd3jp3ZE6BOU3tqR4jMAWhVwfqGDrUOlmO crDg== X-Gm-Message-State: AOJu0YyzFmo6ItGVJO+lnm6NcuftvRYvVWfzAxs3plYBHTSoDV8SZ0mr rT4fohvWKp+Pwu6CyS7I+Dehqx7NBqoXUJDbkkDJVlAsm1W9xosUfXYgEvETgEw3zS3rU91P/vw RVjMe X-Gm-Gg: ASbGnct0i8yWaC7qgk/FpRKrO219jcqrjsQ7vrTMpNWSUxqXZ/M3sDB9Swc8idvpwlo 9FhEZb7t4o6WZj1zGp6ZhsorNheXKpi76kKI/zKmRCrveZow9XNjZR0U0L8bCF8i6OSZHFZUqQ1 WRdJGFs7UPvKonZ7lxBFqqvZ9Xo8sr1nK33+SLJowYURPUHjl5v9hLo5i1Uf5hVxyV6J4Bc4aZx b4GkHeXoA33eIXKq93hk/fArYkm/0nDAJkGc2cbVZlF+xAkHKdoqSNL07DauXpXwPkcJpvwgJ21 ghiFY7LyJV3mVyR8PVJXb4lSDofXoBeIldYp/yu3vQq+UWmK9L3+jtWZ4xORjM1py9FihaEWIY+ vgS93mg== X-Google-Smtp-Source: AGHT+IG3a15v2N/CJJHDO/EMVpA7vyosQYRr+19nnug/2K1ZW8ZG8kivIZTBK+x8wfa+yA5PeX+AIw== X-Received: by 2002:a05:600c:c059:20b0:453:59b5:25cc with SMTP id 5b1f17b1804b1-45381b15784mr3824225e9.7.1750840935963; Wed, 25 Jun 2025 01:42:15 -0700 (PDT) Received: from NAUSH-P-DELL.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a6e80f296bsm3974297f8f.60.2025.06.25.01.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jun 2025 01:42:15 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: dave.stevenson@raspberrypi.com, Naushir Patuck Subject: [PATCH v1 2/3] pipeline: rpi: Move media device configuration into its own function Date: Wed, 25 Jun 2025 09:41:17 +0100 Message-ID: <20250625084212.858487-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250625084212.858487-1-naush@raspberrypi.com> References: <20250625084212.858487-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" Add a new function configureMediaDevices() used to configure the media links and pads for all known bridge/mux entities in the media graph. No functional change, this simply moves existing code into a new function in prepartion for further changes in a subsequent commit. Signed-off-by: Naushir Patuck Reviewed-by: Umang Jain --- .../pipeline/rpi/common/pipeline_base.cpp | 84 ++++++++++--------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index eafe94427dbc..219bd81cc63a 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -85,6 +85,51 @@ std::optional findValidColorSpace(const ColorSpace &colourSpace) return std::nullopt; } +int configureMediaDevices(std::vector, MediaLink *>> &bridgeDevices, + V4L2SubdeviceFormat *sensorFormat) +{ + int ret = 0; + + /* Setup the Video Mux/Bridge entities. */ + for (auto &[device, link] : bridgeDevices) { + /* + * Start by disabling all the sink pad links on the devices in the + * cascade, with the exception of the link connecting the device. + */ + for (const MediaPad *p : device->entity()->pads()) { + if (!(p->flags() & MEDIA_PAD_FL_SINK)) + continue; + + for (MediaLink *l : p->links()) { + if (l != link) + l->setEnabled(false); + } + } + + /* + * Next, enable the entity -> entity links, and setup the pad format. + * + * \todo Some bridge devices may chainge the media bus code, so we + * ought to read the source pad format and propagate it to the sink pad. + */ + link->setEnabled(true); + const MediaPad *sinkPad = link->sink(); + ret = device->setFormat(sinkPad->index(), sensorFormat); + if (ret) { + LOG(RPI, Error) << "Failed to set format on " << device->entity()->name() + << " pad " << sinkPad->index() + << " with format " << *sensorFormat + << ": " << ret; + return ret; + } + + LOG(RPI, Debug) << "Configured media link on device " << device->entity()->name() + << " on pad " << sinkPad->index(); + } + + return ret; +} + } /* namespace */ /* @@ -589,44 +634,7 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config) data->controlInfo_ = ControlInfoMap(std::move(ctrlMap), result.controlInfo.idmap()); - /* Setup the Video Mux/Bridge entities. */ - for (auto &[device, link] : data->bridgeDevices_) { - /* - * Start by disabling all the sink pad links on the devices in the - * cascade, with the exception of the link connecting the device. - */ - for (const MediaPad *p : device->entity()->pads()) { - if (!(p->flags() & MEDIA_PAD_FL_SINK)) - continue; - - for (MediaLink *l : p->links()) { - if (l != link) - l->setEnabled(false); - } - } - - /* - * Next, enable the entity -> entity links, and setup the pad format. - * - * \todo Some bridge devices may chainge the media bus code, so we - * ought to read the source pad format and propagate it to the sink pad. - */ - link->setEnabled(true); - const MediaPad *sinkPad = link->sink(); - ret = device->setFormat(sinkPad->index(), sensorFormat); - if (ret) { - LOG(RPI, Error) << "Failed to set format on " << device->entity()->name() - << " pad " << sinkPad->index() - << " with format " << *sensorFormat - << ": " << ret; - return ret; - } - - LOG(RPI, Debug) << "Configured media link on device " << device->entity()->name() - << " on pad " << sinkPad->index(); - } - - return 0; + return configureMediaDevices(data->bridgeDevices_, sensorFormat); } int PipelineHandlerBase::exportFrameBuffers([[maybe_unused]] Camera *camera, libcamera::Stream *stream,