{"id":18352,"url":"https://patchwork.libcamera.org/api/patches/18352/?format=json","web_url":"https://patchwork.libcamera.org/patch/18352/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20230307114804.42291-3-jacopo.mondi@ideasonboard.com>","date":"2023-03-07T11:48:02","name":"[libcamera-devel,v3,2/4] libcamera: rkisp1: Assign sizes to roles","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"72af9d35c23c338d7dffbe20e0001cfb9b1e6422","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18352/mbox/","series":[{"id":3792,"url":"https://patchwork.libcamera.org/api/series/3792/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3792","date":"2023-03-07T11:48:00","name":"libcamera: rkisp1: Fix generateConfiguration","version":3,"mbox":"https://patchwork.libcamera.org/series/3792/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18352/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18352/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5F176C3262\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Mar 2023 11:48:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AF1AA626BB;\n\tTue,  7 Mar 2023 12:48:23 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 95E25626B4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Mar 2023 12:48:20 +0100 (CET)","from uno.homenet.telecomitalia.it\n\t(host-79-47-54-87.retail.telecomitalia.it [79.47.54.87])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B0EC89A8;\n\tTue,  7 Mar 2023 12:48:19 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1678189703;\n\tbh=tEJ/Ku6ALYwkf5j6tOc7gxeM/+0Fa2jQJ7p3FxLaXk4=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=QBTDTTnPCPsohiZXixp5bU4iASDmj8jbuQAJljnszX8weqEa4N7lcX/EOnkCbDCDr\n\toFE8mFtKEl2R1NbOJ5bzaM9T8UyuQh3Nbt4r7MLLfOE+wW4F+ls+AP/bKctNBD6HvY\n\tOE+rFyMDMEgQvPddTQQeMGF844Mgy9TeqCirgBL/4/6BcAB+ROwh9LMWmkP+06F4F5\n\tSAI9deQpvByZAoodC83OQsevYVXy0j7bub+PSYm/SaAeCJuNwfT5A8b/X5DuLq48H7\n\traYpbgnQQ5NmJl8habObQnuZK0G37PF/8VjifRbRDJRkrh4MmzGt3/lg5OWGGhpujf\n\tKmOJLg7q8n74Q==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1678189700;\n\tbh=tEJ/Ku6ALYwkf5j6tOc7gxeM/+0Fa2jQJ7p3FxLaXk4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Y2dXDfQfSjCiIyUCCeGgw0fRgqedHvPRMkE6rkfATV3xU5xmk6LbYAx9YYmbbEY2R\n\toX9+hhKCQCT+tXZSGTpAcHD5qxPxGjEAvWmrtJc6VveVLB2BQ+H3RiT0kntk+/0qzj\n\tc+nb5TCDVlGIL+4zLwy6CPPcY4FKBGwdhjFJpJwY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Y2dXDfQf\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  7 Mar 2023 12:48:02 +0100","Message-Id":"<20230307114804.42291-3-jacopo.mondi@ideasonboard.com>","X-Mailer":"git-send-email 2.39.0","In-Reply-To":"<20230307114804.42291-1-jacopo.mondi@ideasonboard.com>","References":"<20230307114804.42291-1-jacopo.mondi@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 2/4] libcamera: rkisp1: Assign sizes to\n\troles","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>, libcamera@luigi311.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Currently each RkISP1 path (main and self) generate a configuration\nby bounding the sensor's resolution to their respective maximum output\naspect ratio and size.\n\n\tSize maxResolution = maxResolution_.boundedToAspectRatio(resolution)\n\t\t\t\t\t   .boundedTo(resolution);\n\nIn the case of self path, whose maximum size is 1920x1920, the generated\nconfiguration could get assigned unusual sizes, as the result of the\nabove operation\n\nAs an example, with the imx258 sensor whose resolution is 4208x3118, the\nresulting size for the Viewfinder use case is an unusual 1920x1423.\n\nFix this by assigning to each role a desired output size:\n- Use the sensor's resolution for StillCapture and Raw\n- Use 1080p for Viewfinder and VideoRecording\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      | 12 +++++++++++-\n src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 10 ++++++++--\n src/libcamera/pipeline/rkisp1/rkisp1_path.h   |  1 +\n 3 files changed, 20 insertions(+), 3 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex ebc9bef8688a..60ab7380034c 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -164,6 +164,8 @@ public:\n \tbool match(DeviceEnumerator *enumerator) override;\n \n private:\n+\tstatic constexpr Size kRkISP1PreviewSize = { 1920, 1080 };\n+\n \tRkISP1CameraData *cameraData(Camera *camera)\n \t{\n \t\treturn static_cast<RkISP1CameraData *>(camera->_d());\n@@ -651,12 +653,15 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,\n \n \tfor (const StreamRole role : roles) {\n \t\tbool useMainPath = mainPathAvailable;\n+\t\tSize size;\n \n \t\tswitch (role) {\n \t\tcase StreamRole::StillCapture:\n \t\t\t/* JPEG encoders typically expect sYCC. */\n \t\t\tif (!colorSpace)\n \t\t\t\tcolorSpace = ColorSpace::Sycc;\n+\n+\t\t\tsize = data->sensor_->resolution();\n \t\t\tbreak;\n \n \t\tcase StreamRole::Viewfinder:\n@@ -666,12 +671,16 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,\n \t\t\t */\n \t\t\tif (!colorSpace)\n \t\t\t\tcolorSpace = ColorSpace::Sycc;\n+\n+\t\t\tsize = kRkISP1PreviewSize;\n \t\t\tbreak;\n \n \t\tcase StreamRole::VideoRecording:\n \t\t\t/* Rec. 709 is a good default for HD video recording. */\n \t\t\tif (!colorSpace)\n \t\t\t\tcolorSpace = ColorSpace::Rec709;\n+\n+\t\t\tsize = kRkISP1PreviewSize;\n \t\t\tbreak;\n \n \t\tcase StreamRole::Raw:\n@@ -682,6 +691,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,\n \t\t\t}\n \n \t\t\tcolorSpace = ColorSpace::Raw;\n+\t\t\tsize = data->sensor_->resolution();\n \t\t\tbreak;\n \n \t\tdefault:\n@@ -700,7 +710,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,\n \t\t}\n \n \t\tStreamConfiguration cfg =\n-\t\t\tpath->generateConfiguration(data->sensor_.get(), role);\n+\t\t\tpath->generateConfiguration(data->sensor_.get(), size, role);\n \t\tif (!cfg.pixelFormat.isValid())\n \t\t\treturn nullptr;\n \ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\nindex 5079b268c464..a27ac6fc35cb 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n@@ -127,15 +127,21 @@ void RkISP1Path::populateFormats()\n }\n \n StreamConfiguration\n-RkISP1Path::generateConfiguration(const CameraSensor *sensor, StreamRole role)\n+RkISP1Path::generateConfiguration(const CameraSensor *sensor,\n+\t\t\t\t  const Size &size,\n+\t\t\t\t  StreamRole role)\n {\n \tconst std::vector<unsigned int> &mbusCodes = sensor->mbusCodes();\n \tconst Size &resolution = sensor->resolution();\n \n+\t/* Min and max resolutions to populate the available stream formats. */\n \tSize maxResolution = maxResolution_.boundedToAspectRatio(resolution)\n \t\t\t\t\t   .boundedTo(resolution);\n \tSize minResolution = minResolution_.expandedToAspectRatio(resolution);\n \n+\t/* The desired stream size, bound to the max resolution. */\n+\tSize streamSize = size.boundedTo(maxResolution);\n+\n \t/* Create the list of supported stream formats. */\n \tstd::map<PixelFormat, std::vector<SizeRange>> streamFormats;\n \tunsigned int rawBitsPerPixel = 0;\n@@ -189,7 +195,7 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, StreamRole role)\n \tStreamFormats formats(streamFormats);\n \tStreamConfiguration cfg(formats);\n \tcfg.pixelFormat = format;\n-\tcfg.size = maxResolution;\n+\tcfg.size = streamSize;\n \tcfg.bufferCount = RKISP1_BUFFER_COUNT;\n \n \treturn cfg;\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\nindex bdf3f95b95e1..cd77957ee4a6 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n@@ -41,6 +41,7 @@ public:\n \tbool isEnabled() const { return link_->flags() & MEDIA_LNK_FL_ENABLED; }\n \n \tStreamConfiguration generateConfiguration(const CameraSensor *sensor,\n+\t\t\t\t\t\t  const Size &resolution,\n \t\t\t\t\t\t  StreamRole role);\n \tCameraConfiguration::Status validate(const CameraSensor *sensor,\n \t\t\t\t\t     StreamConfiguration *cfg);\n","prefixes":["libcamera-devel","v3","2/4"]}