From patchwork Sat Feb 27 18:01:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Fricke X-Patchwork-Id: 11407 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 D0F6FBD1F1 for ; Sat, 27 Feb 2021 18:01:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9F50068A72; Sat, 27 Feb 2021 19:01:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=posteo.net header.i=@posteo.net header.b="FXU1rH4a"; dkim-atps=neutral Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DD7A9689DD for ; Sat, 27 Feb 2021 19:01:34 +0100 (CET) Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id C5B0F16005F for ; Sat, 27 Feb 2021 19:01:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1614448893; bh=8v2dIIDAZbzD4uZU41prjpTu5QO8fG+lZXMxMpGLkic=; h=From:To:Cc:Subject:Date:From; b=FXU1rH4aY8d+PL/BzScjFmT9plBDpegviOuPwxoMYE/9Z/Xv0yEpMwkE3sSiFzH8k j1Hcfjm+oK3050PLC3qBkiRLr2Ir3FdtToLkAH/oUQSQS6uuGug09nWgEiB2UhITw4 LDZKX/KNxsXMnpWV8DZ6dKWd+dR7Hvcb6kJj2g2ADTuid5CCotuu4xqsy8MLt8i5Y6 O84aEXIKJaxmBQldBIdaMoCATKGtMzGs4JXrPbwRkNuEbx9rV97L4kmkl3HcEwEdDR hnx7kaCHRM2nHGMl5LWlFJANrnAhsmLl1ZHkGuxzOgl5nyJanTe+YP2v8lluuCoC9C WfDHO5/F9xONw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DnvV42mxZz9rxS; Sat, 27 Feb 2021 19:01:32 +0100 (CET) From: Sebastian Fricke To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Feb 2021 19:01:25 +0100 Message-Id: <20210227180126.37591-2-sebastian.fricke@posteo.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210227180126.37591-1-sebastian.fricke@posteo.net> References: <20210227180126.37591-1-sebastian.fricke@posteo.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 1/2] pipeline: rkisp1: Share the ISP subdevice 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" Share the ISP subdevice between the RkISP1CameraData and the PipelineHandlerRkISP1 class. This enables other classes like RkISP1CameraConfiguration to get access to the device. Signed-off-by: Sebastian Fricke --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 538c0139..50eaa6a4 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -90,6 +90,7 @@ public: Stream mainPathStream_; Stream selfPathStream_; std::unique_ptr sensor_; + std::shared_ptr isp_; std::unique_ptr delayedCtrls_; unsigned int frame_; std::vector ipaBuffers_; @@ -172,7 +173,7 @@ private: int freeBuffers(Camera *camera); MediaDevice *media_; - std::unique_ptr isp_; + std::shared_ptr isp_; std::unique_ptr param_; std::unique_ptr stat_; @@ -930,6 +931,8 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) if (ret) return ret; + data->isp_ = isp_; + /* Initialize the camera properties. */ data->properties_ = data->sensor_->properties(); From patchwork Sat Feb 27 18:01:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Fricke X-Patchwork-Id: 11408 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 309BFBD1F1 for ; Sat, 27 Feb 2021 18:01:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EBE3A68A76; Sat, 27 Feb 2021 19:01:37 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=posteo.net header.i=@posteo.net header.b="eO1BRFMe"; dkim-atps=neutral Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 783C0689DD for ; Sat, 27 Feb 2021 19:01:36 +0100 (CET) Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 0ADE92400FD for ; Sat, 27 Feb 2021 19:01:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1614448896; bh=OVEmYbcSn1D6efYgH+rT+khm0GMY05L8pv3e3bhRKsI=; h=From:To:Cc:Subject:Date:From; b=eO1BRFMeFM5yo5gBUXdmDbnnaVYdnB+c1+GxYNphDcTvvGE3F1DBJQZDR+oxzTXGh sViK+jAEtnMAm0Gv8tNa7NUi4WnCvOgjkQ+g3kDrJXXfbguZof5qjtGWRTJCQQVrt9 UoSqmDTpxo23zVXKB6S9ttonNVUkM9gKpRhsADdVgatP/INFNHfXymDLg6y6eH7Wvl 2gNoRYVi2alw/3vH7rmbFalIGBNSIdCRGUjFTKsuAQQj5sAxJZ9COXgPHG1ZwQxw0d 2NhAaO3eblONRsj/kfXhYamDVqLv4SoIrYuqPE9dvIzs24PNfgngnWHi8KQUFrRPDC Wmj1bQGQMR+Xw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DnvV722x8z9rxB; Sat, 27 Feb 2021 19:01:35 +0100 (CET) From: Sebastian Fricke To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Feb 2021 19:01:26 +0100 Message-Id: <20210227180126.37591-3-sebastian.fricke@posteo.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210227180126.37591-1-sebastian.fricke@posteo.net> References: <20210227180126.37591-1-sebastian.fricke@posteo.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 2/2] pipeline: rkisp1: Fix sensor ISP format mismatch 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" This patch fixes a mismatch of image formats during the pipeline creation of the RkISP1. The mismatch happens because the current code does not check if the configured format exceeds the maximum viable resolution of the ISP. Make sure to use a sensor format resolution that is smaller or equal to the maximum allowed resolution for the RkISP1. The maximum resolution is defined within the `rkisp1-common.h` file as: define RKISP1_ISP_MAX_WIDTH 4032 define RKISP1_ISP_MAX_HEIGHT 3024 Enumerate the frame-sizes of the ISP entity and compare the maximum with the configured resolution. This means that some camera sensors can never operate with their maximum resolution, for example on my OV13850 camera sensor, there are two possible resolutions: 4224x3136 & 2112x1568, the first of those two will never be picked as it surpasses the maximum of the ISP. Signed-off-by: Sebastian Fricke --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 35 +++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 50eaa6a4..56a406c1 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -474,10 +474,37 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate() return Invalid; } - /* Select the sensor format. */ - Size maxSize; + /* Get the ISP resolution limits */ + V4L2Subdevice::Formats ispFormats = data_->isp_->formats(0); + if (ispFormats.empty()) { + LOG(RkISP1, Error) << "Unable to fetch ISP formats."; + return Invalid; + } + /* + * The maximum resolution is identical for all media bus codes on + * the RkISP1 isp entity. Therefore take the first available resolution. + */ + Size ispMaximum = ispFormats.begin()->second[0].max; + + /* + * Select the sensor format, use either the best fit to the configured + * format or a specific sensor format, when getFormat would choose a + * resolution that surpasses the ISP maximum. + */ + Size maxSensorSize; + for (const Size &size : sensor->sizes()) { + if (size.width > ispMaximum.width || + size.height > ispMaximum.height) + continue; + maxSensorSize = std::max(maxSensorSize, size); + } + Size maxConfigSize; for (const StreamConfiguration &cfg : config_) - maxSize = std::max(maxSize, cfg.size); + maxConfigSize = std::max(maxConfigSize, cfg.size); + + if (maxConfigSize.height <= maxSensorSize.height && + maxConfigSize.width <= maxSensorSize.width) + maxSensorSize = maxConfigSize; sensorFormat_ = sensor->getFormat({ MEDIA_BUS_FMT_SBGGR12_1X12, MEDIA_BUS_FMT_SGBRG12_1X12, @@ -491,7 +518,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate() MEDIA_BUS_FMT_SGBRG8_1X8, MEDIA_BUS_FMT_SGRBG8_1X8, MEDIA_BUS_FMT_SRGGB8_1X8 }, - maxSize); + maxSensorSize); if (sensorFormat_.size.isNull()) sensorFormat_.size = sensor->resolution();