From patchwork Wed Jul 13 11:34:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 16620 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 67FE6BE173 for ; Wed, 13 Jul 2022 11:34:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B056263312; Wed, 13 Jul 2022 13:34:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657712096; bh=smlNI44OIeYNb6B6UJPoXxfWW7EDOrwJfC6ahwSKTxo=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=MAN9IeNVjM9k78YTMggkDcchdDcMBmFlw+27e62GXDWrRI2YNw3a5yC11lHiP8GzE Z6Z8OQjHI37+Vr4qyXng7hXzdgR62hlrVGfzUwKgZfjD4x0Z29YA92W5YKnZld4IGZ PjB3GJFfnDHvhzNXmPy2cVbJTapqbdslhuUX5LnpngUeABbHk0kp6BP/PlJ7e6IdY6 hQOwJ6usg8/ADuKBwbgwGEjJ2zaCPgu1Pz5sfoD2Mu2TVLJBFrOwoSpey/Rd4yFo0v J5nrqfVu3ZGXEiFN0Vatv6aFWHebSKKq5hV0UHxKK2mRhBcCmIeHlIPomioAWI8OeW DMw/z4oY397Ww== 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 493FC6274E for ; Wed, 13 Jul 2022 13:34:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="X6/yRAaY"; dkim-atps=neutral Received: from pyrite.rasen.tech (softbank036240121080.bbtec.net [36.240.121.80]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B1C68305; Wed, 13 Jul 2022 13:34:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1657712094; bh=smlNI44OIeYNb6B6UJPoXxfWW7EDOrwJfC6ahwSKTxo=; h=From:To:Cc:Subject:Date:From; b=X6/yRAaYZQ41RH5Zf4CEM1hOdYPG4GzheYt4rD3pXFpFA5+qPIDzNaTTnrDMGne0n bVrWxeOTH6UMW48notbmCNVjFeCLoCb3uo5uHP+xxq2rh+sxLSqODXrS6lD7w0r3jS maRyxaAsF+B0M3hbQAMwwfoUGjiE5aXV9NUX8vFw= 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 Subject: [libcamera-devel] [PATCH v2] pipeline: rkisp1: Support media graph with separate CSI RX 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The rkisp1 hardware supports both a CSI-2 input and a parallel input, where the sensor is connected directly to the ISP. On RK3399, the CSI-2 receiver is internal, but on the i.MX8MP, the CSI-2 receiver is a separate IP core, connected to the parallel input of the ISP, and gets exposed to userspace as a V4L2 subdev. To prepare for this, handle an optional CSI-2 receiver subdev in the pipeline. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Tested-by: Jacopo Mondi --- Changes in v2: - clean up logic of determining pads/prescence of the CSI-2 receiver subdev - upgrade the changelog --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 42 ++++++++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 3dc0850c..2b0ead5d 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -178,6 +178,7 @@ private: std::unique_ptr isp_; std::unique_ptr param_; std::unique_ptr stat_; + std::unique_ptr csi_; RkISP1MainPath mainPath_; RkISP1SelfPath selfPath_; @@ -188,6 +189,8 @@ private: std::queue availableStatBuffers_; Camera *activeCamera_; + + const MediaPad *ispSink_; }; RkISP1Frames::RkISP1Frames(PipelineHandler *pipe) @@ -599,6 +602,12 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) LOG(RkISP1, Debug) << "Sensor configured with " << format; + if (csi_) { + ret = csi_->setFormat(0, &format); + if (ret < 0) + return ret; + } + ret = isp_->setFormat(0, &format); if (ret < 0) return ret; @@ -900,8 +909,7 @@ int PipelineHandlerRkISP1::initLinks(Camera *camera, * Configure the sensor links: enable the link corresponding to this * camera. */ - const MediaPad *pad = isp_->entity()->getPadByIndex(0); - for (MediaLink *link : pad->links()) { + for (MediaLink *link : ispSink_->links()) { if (link->source()->entity() != sensor->entity()) continue; @@ -915,6 +923,14 @@ int PipelineHandlerRkISP1::initLinks(Camera *camera, return ret; } + if (csi_) { + MediaLink *link = isp_->entity()->getPadByIndex(0)->links().at(0); + + ret = link->setEnabled(true); + if (ret < 0) + return ret; + } + for (const StreamConfiguration &cfg : config) { if (cfg.stream() == &data->mainPathStream_) ret = data->mainPath_->setEnabled(true); @@ -1013,6 +1029,22 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator) if (isp_->open() < 0) return false; + /* Locate and open the optional CSI-2 receiver. */ + ispSink_ = isp_->entity()->getPadByIndex(0); + if (!ispSink_ || ispSink_->links().empty()) + return false; + + pad = ispSink_->links().at(0)->source(); + if (pad->entity()->function() == MEDIA_ENT_F_VID_IF_BRIDGE) { + csi_ = std::make_unique(pad->entity()); + if (!csi_ || csi_->open() < 0) + return false; + + ispSink_ = csi_->entity()->getPadByIndex(0); + if (!ispSink_) + return false; + } + /* Locate and open the stats and params video nodes. */ stat_ = V4L2VideoDevice::fromEntityName(media_, "rkisp1_stats"); if (stat_->open() < 0) @@ -1038,12 +1070,8 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator) * Enumerate all sensors connected to the ISP and create one * camera instance for each of them. */ - pad = isp_->entity()->getPadByIndex(0); - if (!pad) - return false; - bool registered = false; - for (MediaLink *link : pad->links()) { + for (MediaLink *link : ispSink_->links()) { if (!createCamera(link->source()->entity())) registered = true; }