From patchwork Wed Jun 22 07:46:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 16305 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 012A9BE173 for ; Wed, 22 Jun 2022 07:46:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B81F865638; Wed, 22 Jun 2022 09:46:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655884011; bh=fV1AJwjhaFKE7IKzeFvb+D25cB5RN/IqeKd0PVMJ5So=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=S8j/KpMRNBm85YtagFCZJSiGy4THVc7SPYbTFUg1Q3e1V+g49VLtOQ0QgHlhaIPeS 7XrNLkSu1cZRNCIl9m1Bohj6Y1sXDV2vsYG8Kk4BpdR+GXaKfyrKjXT32OdASQEigf EFJcDj7D0MplMbWqr3LSJ3E6o81tR4KGO19FXU1szq5Fbl7UlOsINmIW8azQYOpMVI f4p1Xi8+qkCXSWDKx8VsvGguR9TeMTPoZ2PU5ZwKAoEbJRrx7f9qkMgrd7TjFGu/5F 09CXYxa7BUGwnpjVBW+HhAoEiHN208s2RJxtJXsPY1JsNZVPgyRa0TuV8A0xlLye+Y Qel+YNPbLxzQw== 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 A64096559A for ; Wed, 22 Jun 2022 09:46:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qhTEP8+c"; dkim-atps=neutral Received: from pyrite.rasen.tech (softbank036240125119.bbtec.net [36.240.125.119]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 58A51DD; Wed, 22 Jun 2022 09:46:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655884009; bh=fV1AJwjhaFKE7IKzeFvb+D25cB5RN/IqeKd0PVMJ5So=; h=From:To:Cc:Subject:Date:From; b=qhTEP8+c9ynzNru47Y2ZmqSmHVVQmiZYQ7PC1dpWSePdZy8sRSi12A5DOoqL+wVps 6HzLlpTzUrtqkGY8v2KTsCRqEKlwZ5Gzi+6B+4CtNryvKdyz/UXoqzxsCTsAtW8W6k AEp0MTRjRpLUGGiQH6B/z1/EDKm5VB5xG5Kev5uI= To: libcamera-devel@lists.libcamera.org Date: Wed, 22 Jun 2022 16:46:38 +0900 Message-Id: <20220622074638.144636-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] 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 a parallel interface, where the sensor would be connected directly, as well as a CSI receiver. Although at the moment the rkisp1 driver doesn't expose the CSI receiver as a separate subdev, this patch allows the rkisp1 pipeline handler to continue working even in the event that it eventually does. Signed-off-by: Paul Elder --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 35 ++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 43b76e14..a233c961 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_; @@ -591,6 +592,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; @@ -892,7 +899,7 @@ int PipelineHandlerRkISP1::initLinks(Camera *camera, * Configure the sensor links: enable the link corresponding to this * camera. */ - const MediaPad *pad = isp_->entity()->getPadByIndex(0); + const MediaPad *pad = (csi_ ? csi_ : isp_)->entity()->getPadByIndex(0); for (MediaLink *link : pad->links()) { if (link->source()->entity() != sensor->entity()) continue; @@ -907,6 +914,18 @@ int PipelineHandlerRkISP1::initLinks(Camera *camera, return ret; } + if (csi_) { + const MediaPad *ispPad = isp_->entity()->getPadByIndex(0); + for (MediaLink *link : ispPad->links()) { + if (link->source()->entity() != csi_->entity()) + continue; + + ret = link->setEnabled(true); + if (ret < 0) + return ret; + } + } + for (const StreamConfiguration &cfg : config) { if (cfg.stream() == &data->mainPathStream_) ret = data->mainPath_->setEnabled(true); @@ -1005,6 +1024,18 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator) if (isp_->open() < 0) return false; + pad = isp_->entity()->getPadByIndex(0); + if (!pad || pad->links().size() != 1) + return false; + + csi_ = std::make_unique(pad->links().at(0)->source()->entity()); + if (!csi_ || csi_->open() < 0) + return false; + + /* If the media device has no 1th pad, it's the sensor */ + if (!csi_->entity()->getPadByIndex(1)) + csi_ = nullptr; + /* Locate and open the stats and params video nodes. */ stat_ = V4L2VideoDevice::fromEntityName(media_, "rkisp1_stats"); if (stat_->open() < 0) @@ -1030,7 +1061,7 @@ 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); + pad = (csi_ ? csi_ : isp_)->entity()->getPadByIndex(0); if (!pad) return false;