From patchwork Tue Mar 21 17:20:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18423 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 3D0EAC3260 for ; Tue, 21 Mar 2023 17:20:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F30BE62713; Tue, 21 Mar 2023 18:20:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679419214; bh=lBbYlayk8S/W6icFP8NLeG4EOj+Cu3jQutb7rTAiHRk=; 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=h2sAZjWVIieePxhhz2+5TrV2GaHoTOjMdplXbHeXFzB54JfHMbY2nDUR/bHee4g5b Uol7lEW2PBsLz44fuvlS8jSjoAauak9IjG6mlodjgWThy3gPwFqGwQqmSHPxlKlWuI 8L8Tz7KEXQvkVDZaKFB0SMj38o3XkXrTksWXbICO2rtJy+mK4bTXA3a2ubSMttqpZA lVOBj5t/r+JZ13dBoLS7p3LVXxTedMxvNqAOkNvukLMpzHA1ccjz6XMOm9O2ipbSId xNudx9kiht2+WoxyshRH431rudH9lCneGMV/aXiqn5n8oaZv04rGzWyanfkRjLxtUi ks0SGUrNbh+zg== 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 A248661ED1 for ; Tue, 21 Mar 2023 18:20:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ZRDi0amk"; dkim-atps=neutral Received: from uno.homenet.telecomitalia.it (host-87-18-61-243.retail.telecomitalia.it [87.18.61.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C904A496; Tue, 21 Mar 2023 18:20:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1679419212; bh=lBbYlayk8S/W6icFP8NLeG4EOj+Cu3jQutb7rTAiHRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZRDi0amkqbPHqfd0PSTLxcNmr3DRHJDDPh7yp6160lFYhaandtbUcitjgDvo4xi4b WldxjTQ6cunsr9UByCkJbmumtO2Gge/JiIGAp+4UGgam/03CU20tdVTsZLmkC+yPAz x6aIKSy6q2t/A7fVHUgTq6vHvurCah4jsEpnlJ7U= To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Mar 2023 18:20:01 +0100 Message-Id: <20230321172004.176852-2-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230321172004.176852-1-jacopo.mondi@ideasonboard.com> References: <20230321172004.176852-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 8a30fe061d04..fd331168af80 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; @@ -681,12 +674,11 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, RkISP1Path *path; - if (useMainPath) { + if (mainPathAvailable) { path = data->mainPath_; mainPathAvailable = false; } else { path = data->selfPath_; - selfPathAvailable = false; } StreamConfiguration cfg = From patchwork Tue Mar 21 17:20:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18424 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 6D631C0F1B for ; Tue, 21 Mar 2023 17:20:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3458C62719; Tue, 21 Mar 2023 18:20:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679419216; bh=gfpR6WY5VdmZ4+VagB9ZikFbjj76SIiQWSxCcO0Y60Y=; 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=plVBMcPF7c3jGmUp37J8RtpcQcaI1xw+gWTFFs+wBO3Nfs141gB9KEERpV7LvxRSe kqCmWU/CChieqtCH6Jxx0HmEdT2BpcakzBOZS5o0DZDNc+yuqJkjhq9bUDAM4ip1N3 BFMJfpCVzHDoy9Ii9Dbaknorgj5g9X9+1X0/E8W0lSSfyr7azH4PNCBjOckM3zUkOc fUjLze4yYOJPPJfAHz4UbPhNVF5BTTuEk0Vovf+hkBnn4McVEZcCnEAjDW4CO05bh9 0sqExol1vGd5OHNor+RVc+XzgiZVOZrP/yNGsUFp4H2asd3GtrpiuA9hpb4wwEc1Tn x7a94UdEQnjmw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F9606270F for ; Tue, 21 Mar 2023 18:20:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="co6/vtgF"; dkim-atps=neutral Received: from uno.homenet.telecomitalia.it (host-87-18-61-243.retail.telecomitalia.it [87.18.61.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AB1CA80A; Tue, 21 Mar 2023 18:20:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1679419213; bh=gfpR6WY5VdmZ4+VagB9ZikFbjj76SIiQWSxCcO0Y60Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=co6/vtgFmiZLbLdWK6XbkVKj6Z0xQI7R3ZgOG5n9s9V6tfk8FF1ujXhi1xIrH9iv4 TLXgUcts2BgotMlLqLFOEk+mBwcvJHSWkxFPs4GZhQ0nX0Duc6pD4nMHXSstN5j/Uq nMa93nP5f3wnSTPo19pouZns9hdVGi0e/OlceWhE= To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Mar 2023 18:20:02 +0100 Message-Id: <20230321172004.176852-3-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230321172004.176852-1-jacopo.mondi@ideasonboard.com> References: <20230321172004.176852-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 --- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index 5079b268c464..5547cc32b6ca 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -314,7 +314,10 @@ 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 */ + Size ispCrop = inputFormat.size.boundedToAspectRatio(config.size) + .alignedUpTo(2, 2); + Rectangle rect(ispCrop); ret = resizer_->setSelection(0, V4L2_SEL_TGT_CROP, &rect); if (ret < 0) return ret; From patchwork Tue Mar 21 17:20:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18425 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 2E6F5C329C for ; Tue, 21 Mar 2023 17:20:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C62066271E; Tue, 21 Mar 2023 18:20:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679419217; bh=+NIqEIfsq6j/ZMOL7KzBIuZmUaw/ieFiCyln2kkNznI=; 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=prn/N/go+HLEQ1XeLOP1f36qMKExgJSEcq83wIYdBXC1UxmR+RGnr8zTyf6ADMQZX nvS1Zj9BKd5mnlXP12ET+Upx48Igg0Pu8iXNyBtW3s321qO2ZQ5EYjKqb9tTtLaP4T sMxy+8OuXJXQpB4CDqjwDCRWKp665ccXK8J8D5ciJ08TH/F+fQ56GlhBCmYc9TLyMt iaxArJyDsHgHwqK7lHmQr6hEL/dJqwkaYRGvruvsWvbg9ZE/ceurHiP9kePYTtpIBd OkB5HO7BULabXFQcQYXjClURLIOBPDNPhysTYjthL+EjicFfhCTMYNECdbCHXUV1tP sqkdxSXy6Abcw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6F18261ED1 for ; Tue, 21 Mar 2023 18:20:14 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="dLJdQTar"; dkim-atps=neutral Received: from uno.homenet.telecomitalia.it (host-87-18-61-243.retail.telecomitalia.it [87.18.61.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 46FD0DA8; Tue, 21 Mar 2023 18:20:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1679419213; bh=+NIqEIfsq6j/ZMOL7KzBIuZmUaw/ieFiCyln2kkNznI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dLJdQTarH+bNOpNKkFMOc3AZsxIxK4yi3oIsBBu++Et3pxeXL4VllrWN3JuUe5MZs dO2Wc2ZWeJ6Dmfx3/AUq4w/UUq1qXu+xcw3yn0QiTe5SLWkALrW7Xm4gn29WTFusx3 bgSpCIREilbC83E+/wheDjo9MBp7HqaPwDx3iUew= To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Mar 2023 18:20:03 +0100 Message-Id: <20230321172004.176852-4-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230321172004.176852-1-jacopo.mondi@ideasonboard.com> References: <20230321172004.176852-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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: Jacopo Mondi , libcamera@luigi311.com 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 | 10 ++++++++-- src/libcamera/pipeline/rkisp1/rkisp1_path.h | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index fd331168af80..5ae25a244408 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: @@ -682,7 +692,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 5547cc32b6ca..cca593b84260 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -127,15 +127,21 @@ 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 +195,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 Mar 21 17:20:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18426 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 06D28C329D for ; Tue, 21 Mar 2023 17:20:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 850166270F; Tue, 21 Mar 2023 18:20:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679419218; bh=SvlGingAbuAk31teNuj37mbGpJeg0IqJ0mjlriIz96k=; 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=CimfvsJtBPQnMmH0+ekXxk2idiLzRnTb1ZRRnWepi1H4fyVVUXRPJEJoDGqhvsjwH SddSugu1QrVQSAOYT/MePZWDfejxEWDVVw+89BHpoNFjfnQ2MzPQgNcEJoeR2fTQA3 lHMXa35a8iADs6inEZaBRHqLKlGGpRkmVstQ19EB77mcnG99SfMRWizPCz2UgnveEf prjb7iPBmMrNt2E/vo8kJzgmW0ic7N3bp1fZFHT7xZ/PatT3QGQTQSSPqxFuogbh95 becnVYpF3yCIQgzWFNYoQxMxJz5CJS/3TTTstw23hOB0Ob3OONQXCsnR1DVp7xY9YR lDY4597JzH0IQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CBC6D62718 for ; Tue, 21 Mar 2023 18:20:14 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TUikQCqH"; dkim-atps=neutral Received: from uno.homenet.telecomitalia.it (host-87-18-61-243.retail.telecomitalia.it [87.18.61.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 17ED61207; Tue, 21 Mar 2023 18:20:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1679419214; bh=SvlGingAbuAk31teNuj37mbGpJeg0IqJ0mjlriIz96k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUikQCqHsBDrRN+3G3XEscG/1OheljUEK2a51pPSEJruFws16B0vkbGttFZ9fS8Q1 b2jR+53xgCNZtJKnGZRXY3lurBTXl4FfDi3MZAkGco0vlYLYCtMEGhVj3p+YB+fINz jZkw4YLpxov6UsCrhqSVg9g0V+Yy58uAV5MNXB68= To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Mar 2023 18:20:04 +0100 Message-Id: <20230321172004.176852-5-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230321172004.176852-1-jacopo.mondi@ideasonboard.com> References: <20230321172004.176852-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 --- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index cca593b84260..8d606de7880f 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -150,18 +150,33 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, 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 > maxResolution_) + continue; + + streamFormats[format].push_back({ rawSize, rawSize }); + } /* * Store the raw format with the highest bits per pixel for