{"id":16620,"url":"https://patchwork.libcamera.org/api/1.1/patches/16620/?format=json","web_url":"https://patchwork.libcamera.org/patch/16620/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20220713113443.220318-1-paul.elder@ideasonboard.com>","date":"2022-07-13T11:34:43","name":"[libcamera-devel,v2] pipeline: rkisp1: Support media graph with separate CSI RX","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"58a26d6d2c191d0f4376726562454b67abd061a0","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16620/mbox/","series":[{"id":3279,"url":"https://patchwork.libcamera.org/api/1.1/series/3279/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3279","date":"2022-07-13T11:34:43","name":"[libcamera-devel,v2] pipeline: rkisp1: Support media graph with separate CSI RX","version":2,"mbox":"https://patchwork.libcamera.org/series/3279/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16620/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16620/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 67FE6BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 13 Jul 2022 11:34:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B056263312;\n\tWed, 13 Jul 2022 13:34:56 +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 493FC6274E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Jul 2022 13:34:55 +0200 (CEST)","from pyrite.rasen.tech (softbank036240121080.bbtec.net\n\t[36.240.121.80])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B1C68305;\n\tWed, 13 Jul 2022 13:34:53 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657712096;\n\tbh=smlNI44OIeYNb6B6UJPoXxfWW7EDOrwJfC6ahwSKTxo=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=MAN9IeNVjM9k78YTMggkDcchdDcMBmFlw+27e62GXDWrRI2YNw3a5yC11lHiP8GzE\n\tZ6Z8OQjHI37+Vr4qyXng7hXzdgR62hlrVGfzUwKgZfjD4x0Z29YA92W5YKnZld4IGZ\n\tPjB3GJFfnDHvhzNXmPy2cVbJTapqbdslhuUX5LnpngUeABbHk0kp6BP/PlJ7e6IdY6\n\thQOwJ6usg8/ADuKBwbgwGEjJ2zaCPgu1Pz5sfoD2Mu2TVLJBFrOwoSpey/Rd4yFo0v\n\tJ5nrqfVu3ZGXEiFN0Vatv6aFWHebSKKq5hV0UHxKK2mRhBcCmIeHlIPomioAWI8OeW\n\tDMw/z4oY397Ww==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1657712094;\n\tbh=smlNI44OIeYNb6B6UJPoXxfWW7EDOrwJfC6ahwSKTxo=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=X6/yRAaYZQ41RH5Zf4CEM1hOdYPG4GzheYt4rD3pXFpFA5+qPIDzNaTTnrDMGne0n\n\tbVrWxeOTH6UMW48notbmCNVjFeCLoCb3uo5uHP+xxq2rh+sxLSqODXrS6lD7w0r3jS\n\tmaRyxaAsF+B0M3hbQAMwwfoUGjiE5aXV9NUX8vFw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"X6/yRAaY\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 13 Jul 2022 20:34:43 +0900","Message-Id":"<20220713113443.220318-1-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.30.2","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2] pipeline: rkisp1: Support media graph\n\twith separate CSI RX","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Paul Elder <paul.elder@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The rkisp1 hardware supports both a CSI-2 input and a parallel input,\nwhere the sensor is connected directly to the ISP. On RK3399, the CSI-2\nreceiver is internal, but on the i.MX8MP, the CSI-2 receiver is a\nseparate IP core, connected to the parallel input of the ISP, and gets\nexposed to userspace as a V4L2 subdev. To prepare for this, handle an\noptional CSI-2 receiver subdev in the pipeline.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v2:\n- clean up logic of determining pads/prescence of the CSI-2 receiver\n  subdev\n- upgrade the changelog\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 42 ++++++++++++++++++++----\n 1 file changed, 35 insertions(+), 7 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 3dc0850c..2b0ead5d 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -178,6 +178,7 @@ private:\n \tstd::unique_ptr<V4L2Subdevice> isp_;\n \tstd::unique_ptr<V4L2VideoDevice> param_;\n \tstd::unique_ptr<V4L2VideoDevice> stat_;\n+\tstd::unique_ptr<V4L2Subdevice> csi_;\n \n \tRkISP1MainPath mainPath_;\n \tRkISP1SelfPath selfPath_;\n@@ -188,6 +189,8 @@ private:\n \tstd::queue<FrameBuffer *> availableStatBuffers_;\n \n \tCamera *activeCamera_;\n+\n+\tconst MediaPad *ispSink_;\n };\n \n RkISP1Frames::RkISP1Frames(PipelineHandler *pipe)\n@@ -599,6 +602,12 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n \n \tLOG(RkISP1, Debug) << \"Sensor configured with \" << format;\n \n+\tif (csi_) {\n+\t\tret = csi_->setFormat(0, &format);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t}\n+\n \tret = isp_->setFormat(0, &format);\n \tif (ret < 0)\n \t\treturn ret;\n@@ -900,8 +909,7 @@ int PipelineHandlerRkISP1::initLinks(Camera *camera,\n \t * Configure the sensor links: enable the link corresponding to this\n \t * camera.\n \t */\n-\tconst MediaPad *pad = isp_->entity()->getPadByIndex(0);\n-\tfor (MediaLink *link : pad->links()) {\n+\tfor (MediaLink *link : ispSink_->links()) {\n \t\tif (link->source()->entity() != sensor->entity())\n \t\t\tcontinue;\n \n@@ -915,6 +923,14 @@ int PipelineHandlerRkISP1::initLinks(Camera *camera,\n \t\t\treturn ret;\n \t}\n \n+\tif (csi_) {\n+\t\tMediaLink *link = isp_->entity()->getPadByIndex(0)->links().at(0);\n+\n+\t\tret = link->setEnabled(true);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t}\n+\n \tfor (const StreamConfiguration &cfg : config) {\n \t\tif (cfg.stream() == &data->mainPathStream_)\n \t\t\tret = data->mainPath_->setEnabled(true);\n@@ -1013,6 +1029,22 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)\n \tif (isp_->open() < 0)\n \t\treturn false;\n \n+\t/* Locate and open the optional CSI-2 receiver. */\n+\tispSink_ = isp_->entity()->getPadByIndex(0);\n+\tif (!ispSink_ || ispSink_->links().empty())\n+\t\treturn false;\n+\n+\tpad = ispSink_->links().at(0)->source();\n+\tif (pad->entity()->function() == MEDIA_ENT_F_VID_IF_BRIDGE) {\n+\t\tcsi_ = std::make_unique<V4L2Subdevice>(pad->entity());\n+\t\tif (!csi_ || csi_->open() < 0)\n+\t\t\treturn false;\n+\n+\t\tispSink_ = csi_->entity()->getPadByIndex(0);\n+\t\tif (!ispSink_)\n+\t\t\treturn false;\n+\t}\n+\n \t/* Locate and open the stats and params video nodes. */\n \tstat_ = V4L2VideoDevice::fromEntityName(media_, \"rkisp1_stats\");\n \tif (stat_->open() < 0)\n@@ -1038,12 +1070,8 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)\n \t * Enumerate all sensors connected to the ISP and create one\n \t * camera instance for each of them.\n \t */\n-\tpad = isp_->entity()->getPadByIndex(0);\n-\tif (!pad)\n-\t\treturn false;\n-\n \tbool registered = false;\n-\tfor (MediaLink *link : pad->links()) {\n+\tfor (MediaLink *link : ispSink_->links()) {\n \t\tif (!createCamera(link->source()->entity()))\n \t\t\tregistered = true;\n \t}\n","prefixes":["libcamera-devel","v2"]}