{"id":23963,"url":"https://patchwork.libcamera.org/api/patches/23963/?format=json","web_url":"https://patchwork.libcamera.org/patch/23963/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250725-multicontext-v1-9-ea558291e101@ideasonboard.com>","date":"2025-07-25T10:33:54","name":"[DNI,9/9] : rpi/pisp: Set format and bind ISP subdev","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7246634088e8cd075dd758469746863c843a39b9","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23963/mbox/","series":[{"id":5329,"url":"https://patchwork.libcamera.org/api/series/5329/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5329","date":"2025-07-25T10:33:45","name":"libcamera: Support for multi-context operations","version":1,"mbox":"https://patchwork.libcamera.org/series/5329/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23963/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23963/checks/","tags":{},"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 0FC66C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Jul 2025 10:34:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 34396690E0;\n\tFri, 25 Jul 2025 12:34:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 03BBF690C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jul 2025 12:34:01 +0200 (CEST)","from [192.168.0.172] (mob-5-90-139-29.net.vodafone.it\n\t[5.90.139.29])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2F9B4EFE;\n\tFri, 25 Jul 2025 12:33:21 +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=\"Exg3aeMp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753439601;\n\tbh=Q6wYIQe29ouJXmG8lgb1hJm9s1RxN6DJrcd0SCbO3Uc=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=Exg3aeMp/9vitan42hCMrUk9Qc8nVh/VaRPbnGw6XjHy26EdvkKFcPMEMiKMbeStc\n\t6lo0Px8cgU+bdakvvEbxBKHNhgs6Khxg1BrNkHTV4/jS7fOrPv+IZ95R6CaZ7H0UmU\n\t28V1Z5OPB4hnNv/T4PkaX+aQ1V1OF5rQYaiLM8HU=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","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","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","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 <jacopo.mondi@ideasonboard.com>","X-Mailer":"b4 0.14.2","X-Developer-Signature":"v=1; a=openpgp-sha256; l=4124;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=Q6wYIQe29ouJXmG8lgb1hJm9s1RxN6DJrcd0SCbO3Uc=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBog12UXwJsF/KeG8Soae8cZ181GrwtSG8RkA/3x\n\tsRTKerlwBaJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaINdlAAKCRByNAaPFqFW\n\tPCFdD/48df13uHSXgoSjPY6vTtZrTHTSrO8/L6q4rAqO4agTIoqvjXyJAp5UGYybB3C2DSw+KAM\n\t/slhPrRHy0eAYPtywm+HwIURKlLwU/qdaxXoDSpve7CtvAQFBey/z9OhrUdBqCoPGunZgWiGXla\n\tvYhA1pcgMeMAk9mFqH8C/atCbjM6xQeDjj+rh83UVWBo/rZmmk/KISdaa2+IoQxFj7OQFGWyuOf\n\tp+kviEhnHDBpJduN7JLNyIWsnznrWfp3sT97tZd6sAkSEXvvW9Z/QHrczIEb0Ory5ns9EDG/Okt\n\tALM8cBb7EailDU19L/3p71ZeCJumkzCCAooFVVPVX5VIg7tbZMmlW0nRI+qZ/VWqj8BzbZPp7lu\n\tOH2hSZWQzMvCUpF5jlBf6q8nQ5eybcEY7DydgYdJJhqle/Slr3WaI9GiTxXnEs90nM05oRUbxDW\n\tfK6TXwuQdnSvo3toGKIPlU3T9icU7bSMwq42PATnyMQj8GzNl6hssBLud5jPyt3t4Mzw3+WJ+Ym\n\t/4TROXUlCy8TmWlLSP5F9eGWiTXEM+Ju9RRMLWP7uF4kFqFIykcUvgvTLE44j83+TWOkEMpA93o\n\tv4NwjsvYMlvfiG5ZiL53l38A9gPw6qDe9PI/1fY9TF3ed8slmsxbaVZtbhsgEb93ENrsniBnBYE\n\tDYJF61RapDQMK5Q==","X-Developer-Key":"i=jacopo.mondi@ideasonboard.com; a=openpgp;\n\tfpr=72392EDC88144A65C701EA9BA5826A2587AD026B","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>"},"content":"The in-review patch series that introduces multi-context support\nin the Linux kernel also modifies the RaspberryPi BE driver to\nexpose the ISP subdevice to userspace.\n\nIn order to have this libcamera series tested with the kernel\nseries, set format on the ISP subdev to pass link validation and\nalso bind the ISP subdev to the media device context.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/libcamera/pipeline/rpi/pisp/pisp.cpp | 49 +++++++++++++++++++++++++++++++-\n 1 file changed, 48 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\nindex 49a97415c67f0c7c36b3c0b8bd597c278af16838..ea693da42e66cd4a2ea1770856fe3c4aa8f7d396 100644\n--- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n+++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n@@ -780,6 +780,7 @@ public:\n \n \tstd::unique_ptr<V4L2Subdevice> csi2Subdev_;\n \tstd::unique_ptr<V4L2Subdevice> feSubdev_;\n+\tstd::unique_ptr<V4L2Subdevice> ispSubdev_;\n \n \tstd::vector<FrameBuffer *> tdnBuffers_;\n \tstd::vector<FrameBuffer *> stitchBuffers_;\n@@ -1136,8 +1137,14 @@ int PipelineHandlerPiSP::platformRegister(std::unique_ptr<RPi::CameraData> &came\n \n \tdata->csi2Subdev_ = std::make_unique<V4L2Subdevice>(cfe->getEntityByName(\"csi2\"));\n \tdata->feSubdev_ = std::make_unique<V4L2Subdevice>(cfe->getEntityByName(\"pisp-fe\"));\n+\tdata->ispSubdev_ = std::make_unique<V4L2Subdevice>(isp->getEntityByName(\"pispbe\"));\n \tdata->csi2Subdev_->open();\n \tdata->feSubdev_->open();\n+\tif (data->ispSubdev_->open()) {\n+\t\t/* Depends on an out-of-tree patch. */\n+\t\tLOG(RPI, Error) << \"Make sure to have V4L2_SUBDEV_FL_HAS_DEVNODE in the pispbe driver\";\n+\t\treturn -EINVAL;\n+\t}\n \n \t/*\n \t * Open all CFE and ISP streams. The exception is the embedded data\n@@ -1177,6 +1184,7 @@ int PipelineHandlerPiSP::platformRegister(std::unique_ptr<RPi::CameraData> &came\n \tdata->bindDevice(data->isp_[Isp::TdnOutput].dev());\n \tdata->bindDevice(data->isp_[Isp::StitchInput].dev());\n \tdata->bindDevice(data->isp_[Isp::StitchOutput].dev());\n+\tdata->bindDevice(data->ispSubdev_.get());\n \n \t/* Write up all the IPA connections. */\n \tdata->ipa_->prepareIspComplete.connect(data, &PiSPCameraData::prepareIspComplete);\n@@ -2188,6 +2196,10 @@ int PiSPCameraData::configureEntities(V4L2SubdeviceFormat sensorFormat,\n \tconstexpr unsigned int feVideo1SourcePad = 3;\n \tconstexpr unsigned int feStatsSourcePad = 4;\n \n+\tconstexpr unsigned int ispInputPad = 0;\n+\tconstexpr unsigned int ispOutput0Pad = 3;\n+\tconstexpr unsigned int ispOutput1Pad = 4;\n+\n \tconst MediaEntity *csi2 = csi2Subdev_->entity();\n \tconst MediaEntity *fe = feSubdev_->entity();\n \n@@ -2253,8 +2265,43 @@ int PiSPCameraData::configureEntities(V4L2SubdeviceFormat sensorFormat,\n \n \tfeFormat.code = bayerToMbusCode(feOutputBayer);\n \tret = feSubdev_->setFormat(feVideo0SourcePad, &feFormat);\n+\tif (ret)\n+\t\treturn ret;\n \n-\treturn ret;\n+\t/* Apply format on the ISP subdev pad #0 (matches the input image size). */\n+\tV4L2DeviceFormat ispVdevFormat;\n+\tisp_[Isp::Input].dev()->getFormat(&ispVdevFormat);\n+\n+\tV4L2SubdeviceFormat ispSubdevFormat;\n+\tispSubdevFormat.code = MEDIA_BUS_FMT_FIXED;\n+\tispSubdevFormat.size = ispVdevFormat.size;\n+\tret = ispSubdev_->setFormat(ispInputPad, &ispSubdevFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* Apply format on the ISP subdev pads connected to active inputs. */\n+\tpisp_be_global_config global;\n+\tbe_->GetGlobal(global);\n+\tunsigned int beEnabled = global.rgb_enables;\n+\n+\tif (beEnabled & PISP_BE_RGB_ENABLE_OUTPUT0) {\n+\t\tisp_[Isp::Output0].dev()->getFormat(&ispVdevFormat);\n+\n+\t\tispSubdevFormat.size = ispVdevFormat.size;\n+\t\tret = ispSubdev_->setFormat(ispOutput0Pad, &ispSubdevFormat);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\tif (beEnabled & PISP_BE_RGB_ENABLE_OUTPUT1) {\n+\t\tisp_[Isp::Output1].dev()->getFormat(&ispVdevFormat);\n+\n+\t\tispSubdevFormat.size = ispVdevFormat.size;\n+\t\tret = ispSubdev_->setFormat(ispOutput1Pad, &ispSubdevFormat);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n }\n \n void PiSPCameraData::prepareCfe()\n","prefixes":["DNI","9/9"]}