From patchwork Tue Jun 6 10:33:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18709 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 1A0FCC3200 for ; Tue, 6 Jun 2023 10:33:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0E1286289E; Tue, 6 Jun 2023 12:33:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1686047634; bh=29CLqUIJtUNbeJst7Mv1Xb+oxR7fwUW9vEEbTbKj7fI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=jDS0oRcQGxkCafHBJDB30iExXQfxFmYQk86YVjKzKygptdyPpwz9DEwUSeHGb+VW1 21sUEtxkvTJAPM4FFu4oqhHYLjSDp2hZfiEMVhswremSSLlVcwaE966wE+M5oUmzNS N0S7mQyYgHqSYzhySgj0iISbjz93dzCwoBunhBtod9kilNTtLqA4s+e3tDoApTv3VS MJpDPOrhifIJLLs3sVXLF9tpL2pKC+E2qqIKnZU7SzHbCqACmGdwPI8c7PNMScFsRO gpel5BMih+/z4CBSAbB3Eum5OHDHNEy/S82zgi3CYqe4pUwpAeCUE05bhaWwCQKnfg zbEZs8wZJCqNA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5F3BD62722 for ; Tue, 6 Jun 2023 12:33:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PT3hoogW"; dkim-atps=neutral Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D74B76B5; Tue, 6 Jun 2023 12:33:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1686047607; bh=29CLqUIJtUNbeJst7Mv1Xb+oxR7fwUW9vEEbTbKj7fI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PT3hoogWDpE+y/I89kIRm2n8FT1H0bJBJxMjiF23+OVUuZya7GBY7MjdlIB86JJv9 Ud+ALtwEfoFd+FEoeGFprTHsrJXVJe+q6FMneNCcQp+xSVFgYfSmdfHtkY+3g9tJ7j jFg5OzgStlf2XwwbGPJGrhXjLRoSe3iwgRWMBPSI= To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Jun 2023 12:33:33 +0200 Message-Id: <20230606103336.17782-2-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606103336.17782-1-jacopo.mondi@ideasonboard.com> References: <20230606103336.17782-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 1/4] libcamera: rkisp1: Generate config using main path 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: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi , libcamera@luigi311.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The generateConfiguration() implementation in the Rockchip RkISP1 pipeline handler uses by default the self path (if available) for the Viewfinder and VideoRecording StreamRoles. The validate() implementation, at the contrary, prefers using the main path, when available, for all streams. As the self-path is limited in output resolution to 1920x1920, generating a configuration using the self path limits the maximum stream size to 1920x1920, while higher resolutions can be obtained by using the main path. Align the generateConfiguration() implementation to the validate() one by using the main path by default if available. Bug: https://bugs.libcamera.org/show_bug.cgi?id=180 Reported-by: libcamera@luigi311.com Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 8a30fe061d04..78c4a6dd60a4 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -630,23 +630,18 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, * first stream and use it for all streams. */ std::optional colorSpace; - bool mainPathAvailable = true; - bool selfPathAvailable = data->selfPath_; for (const StreamRole role : roles) { - bool useMainPath; switch (role) { case StreamRole::StillCapture: - useMainPath = mainPathAvailable; /* JPEG encoders typically expect sYCC. */ if (!colorSpace) colorSpace = ColorSpace::Sycc; break; case StreamRole::Viewfinder: - useMainPath = !selfPathAvailable; /* * sYCC is the YCbCr encoding of sRGB, which is commonly * used by displays. @@ -656,7 +651,6 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, break; case StreamRole::VideoRecording: - useMainPath = !selfPathAvailable; /* Rec. 709 is a good default for HD video recording. */ if (!colorSpace) colorSpace = ColorSpace::Rec709; @@ -669,7 +663,6 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, return nullptr; } - useMainPath = true; colorSpace = ColorSpace::Raw; break; @@ -679,14 +672,21 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, return nullptr; } + /* + * Prefer the main path if available, as it supports higher + * resolutions. + * + * \todo Using the main path unconditionally hides support for + * RGB (only available on the self path) in the streams formats + * exposed to applications. This likely calls for a better API + * to expose streams capabilities. + */ RkISP1Path *path; - - if (useMainPath) { + if (mainPathAvailable) { path = data->mainPath_; mainPathAvailable = false; } else { path = data->selfPath_; - selfPathAvailable = false; } StreamConfiguration cfg = From patchwork Tue Jun 6 10:33:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18710 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 EC227C328F for ; Tue, 6 Jun 2023 10:33:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CF0C46289A; Tue, 6 Jun 2023 12:33:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1686047634; bh=UUdgzZH/1qvNoEwm+TL4mobgxIZ/Ya5LcSZ8En1dbus=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=DSPRTwwQxymJBkcMBitXKJGpzCMMOafqcEJqmOmF+ZEAW5qFaIq2SFr4ySj+x8bz8 /wE+G++wOearZEDBuZtEVneqPp/zQggNA8A7JYGCMPU+2Ytz/dyOpyKbjjgQ7D3Fy7 udPImgdZrs9dgn/OUSM5c3byhJNMtO3JadG6VNJ0dzcf6DrZaOHBXflbREl3dVFswV wIlN7JdmfYdf9xDMQypj5h9nXDTNT/3H2fuYUvJqKoQahoFSRbn9iAodRuzr62d5Xe CyuPT/c8HDmM4tGdOFMGxdVx6CBgRADris40RFv56ZVhgkNrDEdZiIkBNJagIXfQHo rWlUUAW2bJSUw== 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 DA19062722 for ; Tue, 6 Jun 2023 12:33:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="YXufvZSJ"; dkim-atps=neutral Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 692497EC; Tue, 6 Jun 2023 12:33:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1686047607; bh=UUdgzZH/1qvNoEwm+TL4mobgxIZ/Ya5LcSZ8En1dbus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YXufvZSJ/NQBb2r50VnOD5NiDWTelvDBXQMdJBz5ZRTtxobKLh5786wOcMYTsgdN8 JYiGHM+w2/4ZDy5LHUyYFBHDmcPAEmpskc9iGEtRonqMnPI9QuGnf4DtGr4u2P1KGg 8K2u14zS5Y31Qg4MRk8c2xWbdFq2YFVvptZ9Dhb8= To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Jun 2023 12:33:34 +0200 Message-Id: <20230606103336.17782-3-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606103336.17782-1-jacopo.mondi@ideasonboard.com> References: <20230606103336.17782-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 2/4] libcamera: rkisp1: Crop on ISP before downscaling 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: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi , libcamera@luigi311.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Crop on the resizer sink pad before downscaling to the aspect ratio of the desired output size. Cropping the input frame to the output aspect ratio allows to maintain the correct picture proportions, as otherwise downscaling would change the image geometry. Signed-off-by: Jacopo Mondi Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart Tested-by: Umang Jain --- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index 5079b268c464..0f728cea72b7 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -314,7 +314,18 @@ int RkISP1Path::configure(const StreamConfiguration &config, if (ret < 0) return ret; - Rectangle rect(0, 0, ispFormat.size); + /* + * Crop on the resizer input to maintain FOV before downscaling. + * + * \todo The alignment to a multiple of 2 pixels is required but may + * change the aspect ratio very slightly. A more advanced algorithm to + * compute the resizer input crop rectangle is needed, and it should + * also take into account the need to crop away the edge pixels affected + * by the ISP processing blocks. + */ + Size ispCrop = inputFormat.size.boundedToAspectRatio(config.size) + .alignedUpTo(2, 2); + Rectangle rect = ispCrop.centeredTo(Rectangle(inputFormat.size).center()); ret = resizer_->setSelection(0, V4L2_SEL_TGT_CROP, &rect); if (ret < 0) return ret; From patchwork Tue Jun 6 10:33:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18711 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 B1E64C3200 for ; Tue, 6 Jun 2023 10:33:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 619A56289F; Tue, 6 Jun 2023 12:33:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1686047637; bh=ByJY033FLZ+91hcSRYxrJLCpI+DPcX3IxL8lWJmdFSg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=OUuGMHP71op3tBPq90XiC7T0e/1GSWVc3resJfWqOvtqR7i4ZA6aDLxuavEWHyyuz 7pQkDuX+PakYFYZkrAUx0df+8ONn/1cqyLqatu6niR6J2x0Ep/QwF6exFBMInGvbe7 rpbZkZHBOOKH7a7FYmJjAIodmRxchFH8fEXq81tH+RJvHCDrZyZETdIc/u9DbEcwkg OUOuRUeiFOfWpLDhz1n1p7XuGn2o8d1XHWhBXz0MlxgTQJXPHcgJSqPX1eerj4uG9n 98yoe9Uunr1oXaojmcgXbjRMnNt3YzruhKS8Z85CIq/2DLsDg52Kowl5wwny4YNjc1 b5EJAyY0c0VTw== 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 B78C662894 for ; Tue, 6 Jun 2023 12:33:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="CA8C7s08"; dkim-atps=neutral Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E150B838; Tue, 6 Jun 2023 12:33:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1686047608; bh=ByJY033FLZ+91hcSRYxrJLCpI+DPcX3IxL8lWJmdFSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CA8C7s08P3ScF1C1OynGNVfDwBklxdQYIMRcji0xKDPWRlq3o4zgUFQERgQ9ybDC9 Kv9UuUcburfM8CY2Rwr/kRrs6BYZ2F/B4/ebEVtXbjWmZPpK+P0Vr3Pq1EArlHR5/D H50Fk7U0EFctF/RWsF/vKP1fkghDqy/E+jbOiozE= To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Jun 2023 12:33:35 +0200 Message-Id: <20230606103336.17782-4-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606103336.17782-1-jacopo.mondi@ideasonboard.com> References: <20230606103336.17782-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 3/4] libcamera: rkisp1: Assign sizes to roles 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: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: libcamera@luigi311.com, Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Currently each RkISP1 path (main and self) generate a configuration by bounding the sensor's resolution to their respective maximum output aspect ratio and size. Size maxResolution = maxResolution_.boundedToAspectRatio(resolution) .boundedTo(resolution); In the case of self path, whose maximum size is 1920x1920, the generated configuration could get assigned unusual sizes, as the result of the above operation. As an example, with the imx258 sensor whose resolution is 4208x3118, the resulting size for the Viewfinder use case is an unusual 1920x1423. Fix this by assigning to each role a desired output size: - Use the sensor's resolution for StillCapture and Raw - Use 1080p for Viewfinder and VideoRecording Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 12 +++++++++++- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 9 +++++++-- src/libcamera/pipeline/rkisp1/rkisp1_path.h | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 78c4a6dd60a4..91a3c60757e1 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -162,6 +162,8 @@ public: bool match(DeviceEnumerator *enumerator) override; private: + static constexpr Size kRkISP1PreviewSize = { 1920, 1080 }; + RkISP1CameraData *cameraData(Camera *camera) { return static_cast(camera->_d()); @@ -633,12 +635,15 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, bool mainPathAvailable = true; for (const StreamRole role : roles) { + Size size; switch (role) { case StreamRole::StillCapture: /* JPEG encoders typically expect sYCC. */ if (!colorSpace) colorSpace = ColorSpace::Sycc; + + size = data->sensor_->resolution(); break; case StreamRole::Viewfinder: @@ -648,12 +653,16 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, */ if (!colorSpace) colorSpace = ColorSpace::Sycc; + + size = kRkISP1PreviewSize; break; case StreamRole::VideoRecording: /* Rec. 709 is a good default for HD video recording. */ if (!colorSpace) colorSpace = ColorSpace::Rec709; + + size = kRkISP1PreviewSize; break; case StreamRole::Raw: @@ -664,6 +673,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, } colorSpace = ColorSpace::Raw; + size = data->sensor_->resolution(); break; default: @@ -690,7 +700,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, } StreamConfiguration cfg = - path->generateConfiguration(data->sensor_.get(), role); + path->generateConfiguration(data->sensor_.get(), size, role); if (!cfg.pixelFormat.isValid()) return nullptr; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index 0f728cea72b7..89fb6596b0be 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -127,15 +127,20 @@ void RkISP1Path::populateFormats() } StreamConfiguration -RkISP1Path::generateConfiguration(const CameraSensor *sensor, StreamRole role) +RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size, + StreamRole role) { const std::vector &mbusCodes = sensor->mbusCodes(); const Size &resolution = sensor->resolution(); + /* Min and max resolutions to populate the available stream formats. */ Size maxResolution = maxResolution_.boundedToAspectRatio(resolution) .boundedTo(resolution); Size minResolution = minResolution_.expandedToAspectRatio(resolution); + /* The desired stream size, bound to the max resolution. */ + Size streamSize = size.boundedTo(maxResolution); + /* Create the list of supported stream formats. */ std::map> streamFormats; unsigned int rawBitsPerPixel = 0; @@ -189,7 +194,7 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, StreamRole role) StreamFormats formats(streamFormats); StreamConfiguration cfg(formats); cfg.pixelFormat = format; - cfg.size = maxResolution; + cfg.size = streamSize; cfg.bufferCount = RKISP1_BUFFER_COUNT; return cfg; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h index bdf3f95b95e1..cd77957ee4a6 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h @@ -41,6 +41,7 @@ public: bool isEnabled() const { return link_->flags() & MEDIA_LNK_FL_ENABLED; } StreamConfiguration generateConfiguration(const CameraSensor *sensor, + const Size &resolution, StreamRole role); CameraConfiguration::Status validate(const CameraSensor *sensor, StreamConfiguration *cfg); From patchwork Tue Jun 6 10:33:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18712 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 ADDA1C32AA for ; Tue, 6 Jun 2023 10:33:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 438306289B; Tue, 6 Jun 2023 12:33:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1686047638; bh=996YIff6sc44emvGZn/JSjG5uaRBA99VXNCAIIBveF0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=VUhLiWlBhu7rWvLxyvUSbZWG+N9xS3QEEhX75o1Eky3PgDCQ+WdQrsM5wuR898//E eUra4gLC2xlkUsDRbrter1QK0eUa4pFz6hpJtjHM/Ztt2axh3z9lwrPbdtYfYrt/z7 dLYjJ8msyOFQzLEUbTN6isfMHLAQH+atUxcBkX89qkh3BDPE+/AV/mjjnmbF3MFBA5 kzhB1eFUyltbKTLxFmDILX48cdE/MZwFvN0hlyY77BhcJzcjUUZCOzlXMfYcJ9EfLg TGRjLDIdBMIe+CGBaEbxGOI1JcuBd/LyviVYp+mNVmMsxcsweHBGecW/E2HMmrMvjO Qb3enBRCkgEFw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D9F46289F for ; Tue, 6 Jun 2023 12:33:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="N+ly4Je1"; dkim-atps=neutral Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9159DA38; Tue, 6 Jun 2023 12:33:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1686047608; bh=996YIff6sc44emvGZn/JSjG5uaRBA99VXNCAIIBveF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N+ly4Je1myDyCbj8UdS+m0IvSxZwaHyWguCgfd6fkQhw7R+/BV43ReHpjTXJjMjrD 9ZMg7YPPBmB7M0YK7ZhpK/LU5FbX0FOR1ew5dzDvnjoSI7RfeI1Xup9MYoyM/e+FMr RFtpdOvRp/ZxZqqcR/9FS6FC9NlHlDurEYeYjlMI= To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Jun 2023 12:33:36 +0200 Message-Id: <20230606103336.17782-5-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606103336.17782-1-jacopo.mondi@ideasonboard.com> References: <20230606103336.17782-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 4/4] libcamera: rkisp1: Fix enumeration of RAW formats 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: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi , libcamera@luigi311.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The current implementation enumerates a single RAW format (the sensor's resolution) and does that regardless of what role the CameraConfiguration has been generated for. Fix this by: - Enumerate RAW StreamFormats only when the requested role is StreamRole::Raw - Add all the sensor's provided resolutions that fit the video device output maximum size Before this patch, a single RAW size was enumerated in stream formats * Pixelformat: SRGGB10 (4208x3120)-(4208x3120)/(+1,+1) - 4208x3120 With this patch applied all sensor's supported resolutions are enumerated but only when the stream role RAW is explicitly requested * Pixelformat: SRGGB10 (1048x780)-(4208x3120)/(+0,+0) - 1048x780 - 2104x1560 - 4032x3024 - 4208x3120 Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index 89fb6596b0be..b62b645cae24 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -149,18 +149,34 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size, for (const auto &format : streamFormats_) { const PixelFormatInfo &info = PixelFormatInfo::info(format); + /* Populate stream formats for non-RAW configurations. */ if (info.colourEncoding != PixelFormatInfo::ColourEncodingRAW) { + if (role == StreamRole::Raw) + continue; + streamFormats[format] = { { minResolution, maxResolution } }; continue; } - /* Skip raw formats not supported by the sensor. */ + /* Skip RAW formats for non-raw roles. */ + if (role != StreamRole::Raw) + continue; + + /* Populate stream formats for RAW configurations. */ uint32_t mbusCode = formatToMediaBus.at(format); if (std::find(mbusCodes.begin(), mbusCodes.end(), mbusCode) == mbusCodes.end()) + /* Skip formats not supported by sensor. */ continue; - streamFormats[format] = { { resolution, resolution } }; + /* Add all the RAW sizes the sensor can produce for this code. */ + for (const auto &rawSize : sensor->sizes(mbusCode)) { + if (rawSize.width > maxResolution_.width || + rawSize.height > maxResolution_.height) + continue; + + streamFormats[format].push_back({ rawSize, rawSize }); + } /* * Store the raw format with the highest bits per pixel for