From patchwork Fri Jul 25 10:33:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 23963 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 0FC66C3237 for ; Fri, 25 Jul 2025 10:34:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 34396690E0; Fri, 25 Jul 2025 12:34:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Exg3aeMp"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 03BBF690C5 for ; Fri, 25 Jul 2025 12:34:01 +0200 (CEST) Received: from [192.168.0.172] (mob-5-90-139-29.net.vodafone.it [5.90.139.29]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2F9B4EFE; Fri, 25 Jul 2025 12:33:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1753439601; bh=Q6wYIQe29ouJXmG8lgb1hJm9s1RxN6DJrcd0SCbO3Uc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Exg3aeMp/9vitan42hCMrUk9Qc8nVh/VaRPbnGw6XjHy26EdvkKFcPMEMiKMbeStc 6lo0Px8cgU+bdakvvEbxBKHNhgs6Khxg1BrNkHTV4/jS7fOrPv+IZ95R6CaZ7H0UmU 28V1Z5OPB4hnNv/T4PkaX+aQ1V1OF5rQYaiLM8HU= From: Jacopo Mondi Date: Fri, 25 Jul 2025 12:33:54 +0200 Subject: [PATCH DNI 9/9] : rpi/pisp: Set format and bind ISP subdev MIME-Version: 1.0 Message-Id: <20250725-multicontext-v1-9-ea558291e101@ideasonboard.com> References: <20250725-multicontext-v1-0-ea558291e101@ideasonboard.com> In-Reply-To: <20250725-multicontext-v1-0-ea558291e101@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4124; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=Q6wYIQe29ouJXmG8lgb1hJm9s1RxN6DJrcd0SCbO3Uc=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBog12UXwJsF/KeG8Soae8cZ181GrwtSG8RkA/3x sRTKerlwBaJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaINdlAAKCRByNAaPFqFW PCFdD/48df13uHSXgoSjPY6vTtZrTHTSrO8/L6q4rAqO4agTIoqvjXyJAp5UGYybB3C2DSw+KAM /slhPrRHy0eAYPtywm+HwIURKlLwU/qdaxXoDSpve7CtvAQFBey/z9OhrUdBqCoPGunZgWiGXla vYhA1pcgMeMAk9mFqH8C/atCbjM6xQeDjj+rh83UVWBo/rZmmk/KISdaa2+IoQxFj7OQFGWyuOf p+kviEhnHDBpJduN7JLNyIWsnznrWfp3sT97tZd6sAkSEXvvW9Z/QHrczIEb0Ory5ns9EDG/Okt ALM8cBb7EailDU19L/3p71ZeCJumkzCCAooFVVPVX5VIg7tbZMmlW0nRI+qZ/VWqj8BzbZPp7lu OH2hSZWQzMvCUpF5jlBf6q8nQ5eybcEY7DydgYdJJhqle/Slr3WaI9GiTxXnEs90nM05oRUbxDW fK6TXwuQdnSvo3toGKIPlU3T9icU7bSMwq42PATnyMQj8GzNl6hssBLud5jPyt3t4Mzw3+WJ+Ym /4TROXUlCy8TmWlLSP5F9eGWiTXEM+Ju9RRMLWP7uF4kFqFIykcUvgvTLE44j83+TWOkEMpA93o v4NwjsvYMlvfiG5ZiL53l38A9gPw6qDe9PI/1fY9TF3ed8slmsxbaVZtbhsgEb93ENrsniBnBYE DYJF61RapDQMK5Q== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" The in-review patch series that introduces multi-context support in the Linux kernel also modifies the RaspberryPi BE driver to expose the ISP subdevice to userspace. In order to have this libcamera series tested with the kernel series, set format on the ISP subdev to pass link validation and also bind the ISP subdev to the media device context. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/rpi/pisp/pisp.cpp | 49 +++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index 49a97415c67f0c7c36b3c0b8bd597c278af16838..ea693da42e66cd4a2ea1770856fe3c4aa8f7d396 100644 --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp @@ -780,6 +780,7 @@ public: std::unique_ptr csi2Subdev_; std::unique_ptr feSubdev_; + std::unique_ptr ispSubdev_; std::vector tdnBuffers_; std::vector stitchBuffers_; @@ -1136,8 +1137,14 @@ int PipelineHandlerPiSP::platformRegister(std::unique_ptr &came data->csi2Subdev_ = std::make_unique(cfe->getEntityByName("csi2")); data->feSubdev_ = std::make_unique(cfe->getEntityByName("pisp-fe")); + data->ispSubdev_ = std::make_unique(isp->getEntityByName("pispbe")); data->csi2Subdev_->open(); data->feSubdev_->open(); + if (data->ispSubdev_->open()) { + /* Depends on an out-of-tree patch. */ + LOG(RPI, Error) << "Make sure to have V4L2_SUBDEV_FL_HAS_DEVNODE in the pispbe driver"; + return -EINVAL; + } /* * Open all CFE and ISP streams. The exception is the embedded data @@ -1177,6 +1184,7 @@ int PipelineHandlerPiSP::platformRegister(std::unique_ptr &came data->bindDevice(data->isp_[Isp::TdnOutput].dev()); data->bindDevice(data->isp_[Isp::StitchInput].dev()); data->bindDevice(data->isp_[Isp::StitchOutput].dev()); + data->bindDevice(data->ispSubdev_.get()); /* Write up all the IPA connections. */ data->ipa_->prepareIspComplete.connect(data, &PiSPCameraData::prepareIspComplete); @@ -2188,6 +2196,10 @@ int PiSPCameraData::configureEntities(V4L2SubdeviceFormat sensorFormat, constexpr unsigned int feVideo1SourcePad = 3; constexpr unsigned int feStatsSourcePad = 4; + constexpr unsigned int ispInputPad = 0; + constexpr unsigned int ispOutput0Pad = 3; + constexpr unsigned int ispOutput1Pad = 4; + const MediaEntity *csi2 = csi2Subdev_->entity(); const MediaEntity *fe = feSubdev_->entity(); @@ -2253,8 +2265,43 @@ int PiSPCameraData::configureEntities(V4L2SubdeviceFormat sensorFormat, feFormat.code = bayerToMbusCode(feOutputBayer); ret = feSubdev_->setFormat(feVideo0SourcePad, &feFormat); + if (ret) + return ret; - return ret; + /* Apply format on the ISP subdev pad #0 (matches the input image size). */ + V4L2DeviceFormat ispVdevFormat; + isp_[Isp::Input].dev()->getFormat(&ispVdevFormat); + + V4L2SubdeviceFormat ispSubdevFormat; + ispSubdevFormat.code = MEDIA_BUS_FMT_FIXED; + ispSubdevFormat.size = ispVdevFormat.size; + ret = ispSubdev_->setFormat(ispInputPad, &ispSubdevFormat); + if (ret) + return ret; + + /* Apply format on the ISP subdev pads connected to active inputs. */ + pisp_be_global_config global; + be_->GetGlobal(global); + unsigned int beEnabled = global.rgb_enables; + + if (beEnabled & PISP_BE_RGB_ENABLE_OUTPUT0) { + isp_[Isp::Output0].dev()->getFormat(&ispVdevFormat); + + ispSubdevFormat.size = ispVdevFormat.size; + ret = ispSubdev_->setFormat(ispOutput0Pad, &ispSubdevFormat); + if (ret) + return ret; + } + if (beEnabled & PISP_BE_RGB_ENABLE_OUTPUT1) { + isp_[Isp::Output1].dev()->getFormat(&ispVdevFormat); + + ispSubdevFormat.size = ispVdevFormat.size; + ret = ispSubdev_->setFormat(ispOutput1Pad, &ispSubdevFormat); + if (ret) + return ret; + } + + return 0; } void PiSPCameraData::prepareCfe()