From patchwork Tue Feb 21 16:45: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: 18290 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 7F569C3259 for ; Tue, 21 Feb 2023 16:45:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1295062652; Tue, 21 Feb 2023 17:45:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1676997923; bh=+1iyV2gHAn7SrlN9e6NHWLjBt6ZCa0hB+kgYjP2c0ps=; 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=lC2uTB5RZ1HJAFA+tZ2RqrG8iLTwOVYqiPc8qMYsjLtoFSxZBHN8iR1V2V+5C/LZg 9tk94cVYRNpy2sYzdzaxvi7SFmKVtsAw9yRWW8yVg4aYqqrVoRxqKUp0VZsPzWHFYx nG/zxoRg7sd94zp5RlvVHTpSxY3Yd25nX54W3K0w46KugqD3d0Sv6c/yj//jz0fugO z3odP0/IkShq2azEaVdfsBkpF52Q8bEax/Fw31tq6bDT1QGPGhMd/TZBoZvhvqAED2 ppGdcFG0OxuECZ4fmvRaXRwdvFdpr2ePh1DKa4xkddjogNOPESZ8GX4EHiuXY+A8NX hbNOfdbiqcwHA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D8A362636 for ; Tue, 21 Feb 2023 17:45:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="q/ymOWpf"; dkim-atps=neutral Received: from uno.homenet.telecomitalia.it (host-87-16-53-160.retail.telecomitalia.it [87.16.53.160]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E7CEE59D; Tue, 21 Feb 2023 17:45:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1676997921; bh=+1iyV2gHAn7SrlN9e6NHWLjBt6ZCa0hB+kgYjP2c0ps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q/ymOWpfexzYV0HYRJ49bs5c/qrV1Bi3ezKd8oi9aZ6Y4DnZUPgOHB2DB/+dOLDxW sY9awR7+KqIUIGmmuo7XIRxGRVbVrDmiLZMHEfTm9IgfTPznMVF+Q/Tl6I6Zax46hJ XzeSoYCt8zcuTH1ahmd/GzfTO5b4/fF1hQsY1rYk= To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Feb 2023 17:45:02 +0100 Message-Id: <20230221164504.120738-2-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230221164504.120738-1-jacopo.mondi@ideasonboard.com> References: <20230221164504.120738-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] 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 --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 8a30fe061d04..569fb8ecb629 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -630,23 +630,19 @@ 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; + bool useMainPath = mainPathAvailable; 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 +652,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 +664,6 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, return nullptr; } - useMainPath = true; colorSpace = ColorSpace::Raw; break; @@ -686,7 +680,6 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, mainPathAvailable = false; } else { path = data->selfPath_; - selfPathAvailable = false; } StreamConfiguration cfg = From patchwork Tue Feb 21 16:45: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: 18291 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 319D0C329C for ; Tue, 21 Feb 2023 16:45:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BDE576264F; Tue, 21 Feb 2023 17:45:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1676997923; bh=DE4uJKwHklOI3CV+no2FP/CyUn1FJ22M7cSuTnjQW3I=; 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=x4n0wy2VVKLvfTiyNTTQSUITq/SJA8uJ9Jzfx4mcI6uMbyyF2TLthuRlfzUCTI++V uOpX7lab7Zzx45orHOcNYHx3PB+d09jbNmnIkPtJsoy8e56ZpGWL8Kt8Dw6Sc71cvU BtqNAmP+bCRaDPQXWAXj6O5hZlDBaNoqlClvmw+csP4qelRt2vzMS9sq/G6gM7UF3C M9Y40o45evJ8Asfr4N6V/GUb1QzKs87KTXSXe5BFsjNzma6JoioqZCvvf+3x+3tzqs fJGi8NG+PL5ls6S4l1ky0WF8Oz4gkUyOr3afkwMPvvpiaOdrsvajPdx2c/sn9+lVeT 958MBo5Nti/3A== 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 2EE5862636 for ; Tue, 21 Feb 2023 17:45:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nsVxWrUy"; dkim-atps=neutral Received: from uno.homenet.telecomitalia.it (host-87-16-53-160.retail.telecomitalia.it [87.16.53.160]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7F6446E0; Tue, 21 Feb 2023 17:45:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1676997921; bh=DE4uJKwHklOI3CV+no2FP/CyUn1FJ22M7cSuTnjQW3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nsVxWrUy1weexsOBz6G2n9UwUY5QTzGA5P49McbV9lRMSzPGCNGGVjS08eM6qNjZ8 BRdsPVc+g6EMDsxLWYrpZ4XM4eXVEEd65mXVdaUbLr4j1JlhWVKP3PNeNCBHHKO1kV d7LR860TE41aKSBNr6oPoh2BMqt6kHmx1e+xZabk= To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Feb 2023 17:45:03 +0100 Message-Id: <20230221164504.120738-3-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230221164504.120738-1-jacopo.mondi@ideasonboard.com> References: <20230221164504.120738-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] 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 --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 12 +++++++++++- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 11 ++++++----- src/libcamera/pipeline/rkisp1/rkisp1_path.h | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 569fb8ecb629..05a7ba03b2d2 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()); @@ -634,12 +636,15 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, for (const StreamRole role : roles) { bool useMainPath = mainPathAvailable; + 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: @@ -649,12 +654,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: @@ -665,6 +674,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, } colorSpace = ColorSpace::Raw; + size = data->sensor_->resolution(); break; default: @@ -683,7 +693,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 5079b268c464..9bfb4068779f 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -127,14 +127,14 @@ void RkISP1Path::populateFormats() } StreamConfiguration -RkISP1Path::generateConfiguration(const CameraSensor *sensor, StreamRole role) +RkISP1Path::generateConfiguration(const CameraSensor *sensor, + const Size &resolution, + StreamRole role) { const std::vector &mbusCodes = sensor->mbusCodes(); - const Size &resolution = sensor->resolution(); - + Size minResolution = minResolution_.expandedToAspectRatio(resolution); Size maxResolution = maxResolution_.boundedToAspectRatio(resolution) .boundedTo(resolution); - Size minResolution = minResolution_.expandedToAspectRatio(resolution); /* Create the list of supported stream formats. */ std::map> streamFormats; @@ -155,7 +155,8 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, StreamRole role) mbusCodes.end()) continue; - streamFormats[format] = { { resolution, resolution } }; + streamFormats[format] = { { sensor->resolution(), + sensor->resolution() } }; /* * Store the raw format with the highest bits per pixel for 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 Feb 21 16:45: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: 18292 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 9E92FC329D for ; Tue, 21 Feb 2023 16:45:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3432862656; Tue, 21 Feb 2023 17:45:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1676997925; bh=xMSBikLF+V4AF0eVUPM2TQhcjRD1TgaaxnkoKUwYyNw=; 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=0pNtrFemVto4yCS0kzwlMGC0uXJiYyaFvyw0v033bC06bBE9cPK83k2Aw5xhkIAvs AaHxQh5z4hxCq5lsc+nk08DdwkH9YhFi3Wi8cpMn/HUN+rS61yZfZldwiMYPeF5YC/ JAJz86s0/lugPFFuQQypoW0oNwbegzHNr95h7dMGIXR+VEUKZ4ELOyJKPN45mLXW9w TDaE8rJT761U7C1pVaN4gRdYmLS5isjyG3MgIvA9DMWcFdV9dGrK9Jtjv+Xn95oY0l BtUAMy4w5LdwIVyAk+fdpXWXGvlNaUiDzAG5PK5/zwymizS4CgY4VpvrjbsYI6i9EP M7O2rzLQoYyyw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D1F866264C for ; Tue, 21 Feb 2023 17:45:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vYBYBLLo"; dkim-atps=neutral Received: from uno.homenet.telecomitalia.it (host-87-16-53-160.retail.telecomitalia.it [87.16.53.160]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 25F0980A; Tue, 21 Feb 2023 17:45:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1676997922; bh=xMSBikLF+V4AF0eVUPM2TQhcjRD1TgaaxnkoKUwYyNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vYBYBLLoiDyeHxK5AbvuVsfkRmBX/tE2I4axRe2qoAM2U/JI0Kden7KeW/vUojePO Xvr1tTcp+UWx/qpEZWEx9z671dZPNFdJ6G/KTxRsNi9WHCH+WrhPxeieUnhb97Na+c va5fs91+pFNKxeZTUjNfWg0rqzHf4gbRTS7a79vU= To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Feb 2023 17:45:04 +0100 Message-Id: <20230221164504.120738-4-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230221164504.120738-1-jacopo.mondi@ideasonboard.com> References: <20230221164504.120738-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] libcamera: rkisp1: Reserve main path for StillCapture 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 main output path can produce images in higher resolution and should be reserved for the StillCapture role when a configuration is generated. Before this change if StillCapture was not requested first it got assigned to the self-path and thus down-scaled to 1920x1920. With this change, StillCapture can be asked last and it would take precedence over other streams for the usage of the main path. $ cam -c1 --stream role=viewfinder --stream role=still Camera camera.cpp:969 streams configuration: (0) 1920x1080-NV12 (1) 4208x3120-NV12 Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 05a7ba03b2d2..23ff859e3835 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -626,6 +626,16 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, if (roles.empty()) return config; + /* If still capture is requested, reserve the main path for it. */ + bool reserveMainPath = false; + for (const StreamRole role : roles) { + if (role != StreamRole::StillCapture) + continue; + + reserveMainPath = true; + break; + } + /* * As the ISP can't output different color spaces for the main and self * path, pick a sensible default color space based on the role of the @@ -644,6 +654,9 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, if (!colorSpace) colorSpace = ColorSpace::Sycc; + /* Unlock usage of main path which was reserved. */ + reserveMainPath = false; + size = data->sensor_->resolution(); break; @@ -685,7 +698,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera, RkISP1Path *path; - if (useMainPath) { + if (useMainPath && !reserveMainPath) { path = data->mainPath_; mainPathAvailable = false; } else {