[{"id":34644,"web_url":"https://patchwork.libcamera.org/comment/34644/","msgid":"<b8c87aea-f689-49e1-88cc-f9e1e45e7cbe@igalia.com>","date":"2025-06-26T06:55:25","subject":"Re: [PATCH v1 2/3] pipeline: rpi: Move media device configuration\n\tinto its own function","submitter":{"id":232,"url":"https://patchwork.libcamera.org/api/people/232/","name":"Umang Jain","email":"uajain@igalia.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn 6/25/25 2:11 PM, Naushir Patuck wrote:\n> Add a new function configureMediaDevices() used to configure the\n> media links and pads for all known bridge/mux entities in the media\n> graph.\n>\n> No functional change, this simply moves existing code into a new\n> function in prepartion for further changes in a subsequent commit.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>   .../pipeline/rpi/common/pipeline_base.cpp     | 84 ++++++++++---------\n>   1 file changed, 46 insertions(+), 38 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> index eafe94427dbc..219bd81cc63a 100644\n> --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> @@ -85,6 +85,51 @@ std::optional<ColorSpace> findValidColorSpace(const ColorSpace &colourSpace)\n>   \treturn std::nullopt;\n>   }\n>   \n> +int configureMediaDevices(std::vector<std::pair<std::unique_ptr<V4L2Subdevice>, MediaLink *>> &bridgeDevices,\n> +\t\t\t  V4L2SubdeviceFormat *sensorFormat)\n> +{\n> +\tint ret = 0;\n> +\n> +\t/* Setup the Video Mux/Bridge entities. */\n> +\tfor (auto &[device, link] : bridgeDevices) {\n> +\t\t/*\n> +\t\t * Start by disabling all the sink pad links on the devices in the\n> +\t\t * cascade, with the exception of the link connecting the device.\n> +\t\t */\n> +\t\tfor (const MediaPad *p : device->entity()->pads()) {\n> +\t\t\tif (!(p->flags() & MEDIA_PAD_FL_SINK))\n> +\t\t\t\tcontinue;\n> +\n> +\t\t\tfor (MediaLink *l : p->links()) {\n> +\t\t\t\tif (l != link)\n> +\t\t\t\t\tl->setEnabled(false);\n> +\t\t\t}\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Next, enable the entity -> entity links, and setup the pad format.\n> +\t\t *\n> +\t\t * \\todo Some bridge devices may chainge the media bus code, so we\n\nIn this code move, the spell error can be corrected,\n\ns/chainge/change\n\nReviewed-by: Umang Jain <uajain@igalia.com>\n\n\n> +\t\t * ought to read the source pad format and propagate it to the sink pad.\n> +\t\t */\n> +\t\tlink->setEnabled(true);\n> +\t\tconst MediaPad *sinkPad = link->sink();\n> +\t\tret = device->setFormat(sinkPad->index(), sensorFormat);\n> +\t\tif (ret) {\n> +\t\t\tLOG(RPI, Error) << \"Failed to set format on \" << device->entity()->name()\n> +\t\t\t\t\t<< \" pad \" << sinkPad->index()\n> +\t\t\t\t\t<< \" with format  \" << *sensorFormat\n> +\t\t\t\t\t<< \": \" << ret;\n> +\t\t\treturn ret;\n> +\t\t}\n> +\n> +\t\tLOG(RPI, Debug) << \"Configured media link on device \" << device->entity()->name()\n> +\t\t\t\t<< \" on pad \" << sinkPad->index();\n> +\t}\n> +\n> +\treturn ret;\n> +}\n> +\n>   } /* namespace */\n>   \n>   /*\n> @@ -589,44 +634,7 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)\n>   \n>   \tdata->controlInfo_ = ControlInfoMap(std::move(ctrlMap), result.controlInfo.idmap());\n>   \n> -\t/* Setup the Video Mux/Bridge entities. */\n> -\tfor (auto &[device, link] : data->bridgeDevices_) {\n> -\t\t/*\n> -\t\t * Start by disabling all the sink pad links on the devices in the\n> -\t\t * cascade, with the exception of the link connecting the device.\n> -\t\t */\n> -\t\tfor (const MediaPad *p : device->entity()->pads()) {\n> -\t\t\tif (!(p->flags() & MEDIA_PAD_FL_SINK))\n> -\t\t\t\tcontinue;\n> -\n> -\t\t\tfor (MediaLink *l : p->links()) {\n> -\t\t\t\tif (l != link)\n> -\t\t\t\t\tl->setEnabled(false);\n> -\t\t\t}\n> -\t\t}\n> -\n> -\t\t/*\n> -\t\t * Next, enable the entity -> entity links, and setup the pad format.\n> -\t\t *\n> -\t\t * \\todo Some bridge devices may chainge the media bus code, so we\n> -\t\t * ought to read the source pad format and propagate it to the sink pad.\n> -\t\t */\n> -\t\tlink->setEnabled(true);\n> -\t\tconst MediaPad *sinkPad = link->sink();\n> -\t\tret = device->setFormat(sinkPad->index(), sensorFormat);\n> -\t\tif (ret) {\n> -\t\t\tLOG(RPI, Error) << \"Failed to set format on \" << device->entity()->name()\n> -\t\t\t\t\t<< \" pad \" << sinkPad->index()\n> -\t\t\t\t\t<< \" with format  \" << *sensorFormat\n> -\t\t\t\t\t<< \": \" << ret;\n> -\t\t\treturn ret;\n> -\t\t}\n> -\n> -\t\tLOG(RPI, Debug) << \"Configured media link on device \" << device->entity()->name()\n> -\t\t\t\t<< \" on pad \" << sinkPad->index();\n> -\t}\n> -\n> -\treturn 0;\n> +\treturn configureMediaDevices(data->bridgeDevices_, sensorFormat);\n>   }\n>   \n>   int PipelineHandlerBase::exportFrameBuffers([[maybe_unused]] Camera *camera, libcamera::Stream *stream,","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id F2C64BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Jun 2025 06:55:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ED6C968DF3;\n\tThu, 26 Jun 2025 08:55:22 +0200 (CEST)","from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 543B361529\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Jun 2025 08:55:22 +0200 (CEST)","from [49.36.69.141] (helo=[192.168.29.108])\n\tby fanzine2.igalia.com with esmtpsa \n\t(Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128)\n\t(Exim) id 1uUgW1-008s93-DI; Thu, 26 Jun 2025 08:55:21 +0200"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=igalia.com header.i=@igalia.com\n\theader.b=\"fOnwCyZ/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com;\n\ts=20170329;\n\th=Content-Transfer-Encoding:Content-Type:In-Reply-To:From:\n\tReferences:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:\n\tContent-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:\n\tResent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:\n\tList-Subscribe:List-Post:List-Owner:List-Archive;\n\tbh=BBlAe4rRmWnmMG3LxpuPjOmJOer4QKvmcZi2mAq+200=;\n\tb=fOnwCyZ/Y9RFHnqBsB+Wg4d3si\n\th63b/GOv8wdVJzQJ8ejMno3U0bllMVO6jRh40KYbfcBfnT82bXg97cpz9Uz0WNwHhUflHp3mMXsVS\n\t3/FjrgBwA0XSUtgOSdFSNKJek1aV1iPAyFzFWZrLTsZjU8rifyYxU9ZCw2bXbTn/a00B9ck7l75/8\n\tKRMY/QtEyKLRHo3U331Gs0UrS99e/sS4rZJiBluvJqZvgJhqmWmZfoPBy4BVqn/RqJJA2AjlWBcsm\n\tTcf/2k6SA7eBVcZHFZLguFNB52sS/iNx5dHsybvkv9+8NL74uiRXhiNyhVfSfYHbPFidJjt8fXp3M\n\tyQz5naLA==;","Message-ID":"<b8c87aea-f689-49e1-88cc-f9e1e45e7cbe@igalia.com>","Date":"Thu, 26 Jun 2025 12:25:25 +0530","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1 2/3] pipeline: rpi: Move media device configuration\n\tinto its own function","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"dave.stevenson@raspberrypi.com","References":"<20250625084212.858487-1-naush@raspberrypi.com>\n\t<20250625084212.858487-3-naush@raspberrypi.com>","Content-Language":"en-US","From":"Umang Jain <uajain@igalia.com>","In-Reply-To":"<20250625084212.858487-3-naush@raspberrypi.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":34660,"web_url":"https://patchwork.libcamera.org/comment/34660/","msgid":"<20250626125605.GN8738@pendragon.ideasonboard.com>","date":"2025-06-26T12:56:05","subject":"Re: [PATCH v1 2/3] pipeline: rpi: Move media device configuration\n\tinto its own function","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Jun 25, 2025 at 09:41:17AM +0100, Naushir Patuck wrote:\n> Add a new function configureMediaDevices() used to configure the\n> media links and pads for all known bridge/mux entities in the media\n> graph.\n> \n> No functional change, this simply moves existing code into a new\n> function in prepartion for further changes in a subsequent commit.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  .../pipeline/rpi/common/pipeline_base.cpp     | 84 ++++++++++---------\n>  1 file changed, 46 insertions(+), 38 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> index eafe94427dbc..219bd81cc63a 100644\n> --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> @@ -85,6 +85,51 @@ std::optional<ColorSpace> findValidColorSpace(const ColorSpace &colourSpace)\n>  \treturn std::nullopt;\n>  }\n>  \n> +int configureMediaDevices(std::vector<std::pair<std::unique_ptr<V4L2Subdevice>, MediaLink *>> &bridgeDevices,\n\nThe vector should be const, it's not modified by this function.\n\n> +\t\t\t  V4L2SubdeviceFormat *sensorFormat)\n> +{\n> +\tint ret = 0;\n> +\n> +\t/* Setup the Video Mux/Bridge entities. */\n> +\tfor (auto &[device, link] : bridgeDevices) {\n> +\t\t/*\n> +\t\t * Start by disabling all the sink pad links on the devices in the\n> +\t\t * cascade, with the exception of the link connecting the device.\n> +\t\t */\n> +\t\tfor (const MediaPad *p : device->entity()->pads()) {\n> +\t\t\tif (!(p->flags() & MEDIA_PAD_FL_SINK))\n> +\t\t\t\tcontinue;\n> +\n> +\t\t\tfor (MediaLink *l : p->links()) {\n> +\t\t\t\tif (l != link)\n> +\t\t\t\t\tl->setEnabled(false);\n> +\t\t\t}\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Next, enable the entity -> entity links, and setup the pad format.\n> +\t\t *\n> +\t\t * \\todo Some bridge devices may chainge the media bus code, so we\n> +\t\t * ought to read the source pad format and propagate it to the sink pad.\n> +\t\t */\n> +\t\tlink->setEnabled(true);\n> +\t\tconst MediaPad *sinkPad = link->sink();\n> +\t\tret = device->setFormat(sinkPad->index(), sensorFormat);\n> +\t\tif (ret) {\n> +\t\t\tLOG(RPI, Error) << \"Failed to set format on \" << device->entity()->name()\n> +\t\t\t\t\t<< \" pad \" << sinkPad->index()\n> +\t\t\t\t\t<< \" with format  \" << *sensorFormat\n> +\t\t\t\t\t<< \": \" << ret;\n> +\t\t\treturn ret;\n> +\t\t}\n> +\n> +\t\tLOG(RPI, Debug) << \"Configured media link on device \" << device->entity()->name()\n> +\t\t\t\t<< \" on pad \" << sinkPad->index();\n> +\t}\n> +\n> +\treturn ret;\n> +}\n> +\n>  } /* namespace */\n>  \n>  /*\n> @@ -589,44 +634,7 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)\n>  \n>  \tdata->controlInfo_ = ControlInfoMap(std::move(ctrlMap), result.controlInfo.idmap());\n>  \n> -\t/* Setup the Video Mux/Bridge entities. */\n> -\tfor (auto &[device, link] : data->bridgeDevices_) {\n> -\t\t/*\n> -\t\t * Start by disabling all the sink pad links on the devices in the\n> -\t\t * cascade, with the exception of the link connecting the device.\n> -\t\t */\n> -\t\tfor (const MediaPad *p : device->entity()->pads()) {\n> -\t\t\tif (!(p->flags() & MEDIA_PAD_FL_SINK))\n> -\t\t\t\tcontinue;\n> -\n> -\t\t\tfor (MediaLink *l : p->links()) {\n> -\t\t\t\tif (l != link)\n> -\t\t\t\t\tl->setEnabled(false);\n> -\t\t\t}\n> -\t\t}\n> -\n> -\t\t/*\n> -\t\t * Next, enable the entity -> entity links, and setup the pad format.\n> -\t\t *\n> -\t\t * \\todo Some bridge devices may chainge the media bus code, so we\n> -\t\t * ought to read the source pad format and propagate it to the sink pad.\n> -\t\t */\n> -\t\tlink->setEnabled(true);\n> -\t\tconst MediaPad *sinkPad = link->sink();\n> -\t\tret = device->setFormat(sinkPad->index(), sensorFormat);\n> -\t\tif (ret) {\n> -\t\t\tLOG(RPI, Error) << \"Failed to set format on \" << device->entity()->name()\n> -\t\t\t\t\t<< \" pad \" << sinkPad->index()\n> -\t\t\t\t\t<< \" with format  \" << *sensorFormat\n> -\t\t\t\t\t<< \": \" << ret;\n> -\t\t\treturn ret;\n> -\t\t}\n> -\n> -\t\tLOG(RPI, Debug) << \"Configured media link on device \" << device->entity()->name()\n> -\t\t\t\t<< \" on pad \" << sinkPad->index();\n> -\t}\n> -\n> -\treturn 0;\n> +\treturn configureMediaDevices(data->bridgeDevices_, sensorFormat);\n>  }\n>  \n>  int PipelineHandlerBase::exportFrameBuffers([[maybe_unused]] Camera *camera, libcamera::Stream *stream,","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9EAA9BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Jun 2025 12:56:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1F77768DF6;\n\tThu, 26 Jun 2025 14:56:33 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 390E768DE8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Jun 2025 14:56:31 +0200 (CEST)","from pendragon.ideasonboard.com (85-76-34-12-nat.elisa-mobile.fi\n\t[85.76.34.12])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id BAFC6743;\n\tThu, 26 Jun 2025 14:56:11 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"swP7Atum\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750942572;\n\tbh=Gup1S62WaJdYYxM8hoJ23c5GTM/7vl0G1h1MYRwGfIQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=swP7AtumYDkxafpOJCFsxz/LChZpxSRPgWBVmr3dDW4JRU8o1H02hNW5+3eLEvE/4\n\tzRURBWm7E04GwPs8WEb51AJj+t69HVEr/M0sJyuodFK93awjaySPQhTZ4btbCdr2y4\n\tFLz5x/r/yXMiMHeixk5dpJl4GBdH/PXeOH+7w7u4=","Date":"Thu, 26 Jun 2025 15:56:05 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org, dave.stevenson@raspberrypi.com","Subject":"Re: [PATCH v1 2/3] pipeline: rpi: Move media device configuration\n\tinto its own function","Message-ID":"<20250626125605.GN8738@pendragon.ideasonboard.com>","References":"<20250625084212.858487-1-naush@raspberrypi.com>\n\t<20250625084212.858487-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250625084212.858487-3-naush@raspberrypi.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]