[{"id":14950,"web_url":"https://patchwork.libcamera.org/comment/14950/","msgid":"<YBu3mFAt8hYJtliM@oden.dyn.berto.se>","date":"2021-02-04T09:00:08","subject":"Re: [libcamera-devel] [PATCH] libcamera: ipu3: Fix RAW sizes\n\tselection","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your work.\n\nOn 2021-02-03 12:23:16 +0100, Jacopo Mondi wrote:\n> Commit 7208e70211a6 (\"libcamera: ipu3: Always use sensor full frame size\")\n> changed the CIO2 configuration procedure to always select the full\n> sensor resolution to work around an ImgU configuration issue, as\n> reported in the todo item introduced in said commit.\n> \n> When capturing a RAW stream only and the ImgU is not involved, the CIO2\n> has to be configured with the requested stream size to avoid adjusting\n> the stream to the sensor resolution.\n> \n> As an example, capturing a raw frame smaller than the sensor resolution\n> with this patch applied results in the stream configuration to be\n> correctly assigned.\n> \n> $ cam -c1 -swidth=1056,height=784,role=raw\n> ipu3.cpp:207 CIO2 configuration: 1056x784-SGRBG10_IPU3\n> ipu3.cpp:222 Validating stream: 1056x784-SGRBG10_IPU3\n> ipu3.cpp:233 Assigned 1056x784-SGRBG10_IPU3 to the raw stream\n> \n> Without this patch the same operation results in the stream resolution\n> to be adjusted to the sensor resolution.\n> \n> $ cam -c1 -swidth=1056,height=784,role=raw\n> ipu3.cpp:201 CIO2 configuration: 4224x3136-SGRBG10_IPU3\n> ipu3.cpp:216 Validating stream: 1056x784-SGRBG10_IPU3\n> ipu3.cpp:227 Assigned 4224x3136-SGRBG10_IPU3 to the raw stream\n> ipu3.cpp:297 Stream 0 configuration adjusted to 4224x3136-SGRBG10_IPU3\n> Camera configuration adjusted\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 15 +++++++++++----\n>  1 file changed, 11 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index db0d6b91be70..d73dd50e2f1d 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -162,12 +162,14 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n>  \tunsigned int rawCount = 0;\n>  \tunsigned int yuvCount = 0;\n>  \tSize maxYuvSize;\n> +\tSize maxRawSize;\n>  \n>  \tfor (const StreamConfiguration &cfg : config_) {\n>  \t\tconst PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat);\n>  \n>  \t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) {\n>  \t\t\trawCount++;\n> +\t\t\tmaxRawSize.expandTo(cfg.size);\n>  \t\t} else {\n>  \t\t\tyuvCount++;\n>  \t\t\tmaxYuvSize.expandTo(cfg.size);\n> @@ -190,11 +192,16 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n>  \t * commit message of the patch that introduced this comment for more\n>  \t * failure examples).\n>  \t *\n> -\t * Until the sensor frame size calculation criteria are clarified,\n> -\t * always use the largest possible one which guarantees better results\n> -\t * at the expense of the frame rate and CSI-2 bus bandwidth.\n> +\t * Until the sensor frame size calculation criteria are clarified, when\n> +\t * capturing from ImgU always use the largest possible size which\n> +\t * guarantees better results at the expense of the frame rate and CSI-2\n> +\t * bus bandwidth. When only a raw stream is requested use the requested\n> +\t * size instead, as the ImgU is not involved.\n>  \t */\n> -\tcio2Configuration_ = data_->cio2_.generateConfiguration({});\n> +\tif (!yuvCount)\n> +\t\tcio2Configuration_ = data_->cio2_.generateConfiguration(maxRawSize);\n> +\telse\n> +\t\tcio2Configuration_ = data_->cio2_.generateConfiguration({});\n>  \tif (!cio2Configuration_.pixelFormat.isValid())\n>  \t\treturn Invalid;\n>  \n> -- \n> 2.30.0\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 55C66BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Feb 2021 09:00:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A90A7613FB;\n\tThu,  4 Feb 2021 10:00:11 +0100 (CET)","from mail-lj1-x229.google.com (mail-lj1-x229.google.com\n\t[IPv6:2a00:1450:4864:20::229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 46BD260107\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Feb 2021 10:00:10 +0100 (CET)","by mail-lj1-x229.google.com with SMTP id u4so2475602ljh.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 04 Feb 2021 01:00:10 -0800 (PST)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tx69sm525523lff.226.2021.02.04.01.00.08\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 04 Feb 2021 01:00:09 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"h1a/YhFE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=0vGYBzkXU5VPfgCosfZzGE42PNI1/b38sgJFpa0YgaM=;\n\tb=h1a/YhFE6QIkb68hozn4nG+Zinp9BT1aBWYymv4adwYw3lCq8jjVwBiGNN0JmIL70E\n\t+6pFpIamoEkrQedWTBNrJuSHFthoAmI0Hp3xNZ6yUtrZmFg24DP2pc8J+lo/R2/e4RDr\n\tXQiiT2DDH5BIEOoIj7EEzQ/vTCay3UBW30aM1u7NHc4Em1Avb00ymoD5tYUFLYz9sK/1\n\tmb32urlTFPCN9viwGxr1oRPmKMsIGweOBNGoA5FYS20F6kofHnd0oYssalwuw5DSHwek\n\t6ggwYkhSiqM7vf/YL+9p2flmnj57IGSOrtlKhLmrxAwE/ArRgH3oNDZ3vrCpxyFHR3I+\n\t9Xkw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=0vGYBzkXU5VPfgCosfZzGE42PNI1/b38sgJFpa0YgaM=;\n\tb=RbZRbYju1Ke8oWEbrOWAVzkMqAbzwUTH+6w6YCcoW3EbV2KnkfMT9we4uv2chsw6ZP\n\tI6FzSDIz+6Rh8WQHu9FBknOvqLlXrEGfJRD8KkMdsqsGdd+M32lvMBo+w4jjWgZExyjq\n\tOLIx4z8JkkW3PHUTiFqPJyk92MPhLVTNLvNiuEtLHwjnFSk2xWRK53Stpp1SyG5nMKs2\n\t06wNRgcKCaNLaaeuXNzU3zwSv4S1BJkPEfrIhq3FC5pX2ibXVqZBFKDbb106X+P4RM+x\n\tqeAYVQR9jMwSeKI88mVpiW6JvsmGRLmp/M1N4ksLb6b8/13UtYRNHnGZWbq/cCVML7y/\n\tgK1A==","X-Gm-Message-State":"AOAM531qSZcSZvDtNDPsFecmakrJ+p38etg6J+Gueu21IbWREE8sSnRi\n\tR9mgvuH64kDBWATm8LMUAJld0PQlc6J4fuN8","X-Google-Smtp-Source":"ABdhPJxYG6k0/9cbJXOpcYQRNupJldBX5nIUFxInNjgneE+BDG2gZ2fl3UvEZWOxYkXCIrgr9ok1EQ==","X-Received":"by 2002:a2e:9252:: with SMTP id\n\tv18mr4336692ljg.352.1612429209732; \n\tThu, 04 Feb 2021 01:00:09 -0800 (PST)","Date":"Thu, 4 Feb 2021 10:00:08 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YBu3mFAt8hYJtliM@oden.dyn.berto.se>","References":"<20210203112316.150393-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210203112316.150393-1-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: ipu3: Fix RAW sizes\n\tselection","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15015,"web_url":"https://patchwork.libcamera.org/comment/15015/","msgid":"<YBx/nF6EXvshxjYn@pendragon.ideasonboard.com>","date":"2021-02-04T23:13:32","subject":"Re: [libcamera-devel] [PATCH] libcamera: ipu3: Fix RAW sizes\n\tselection","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Wed, Feb 03, 2021 at 12:23:16PM +0100, Jacopo Mondi wrote:\n> Commit 7208e70211a6 (\"libcamera: ipu3: Always use sensor full frame size\")\n> changed the CIO2 configuration procedure to always select the full\n> sensor resolution to work around an ImgU configuration issue, as\n> reported in the todo item introduced in said commit.\n> \n> When capturing a RAW stream only and the ImgU is not involved, the CIO2\n> has to be configured with the requested stream size to avoid adjusting\n> the stream to the sensor resolution.\n> \n> As an example, capturing a raw frame smaller than the sensor resolution\n> with this patch applied results in the stream configuration to be\n> correctly assigned.\n> \n> $ cam -c1 -swidth=1056,height=784,role=raw\n> ipu3.cpp:207 CIO2 configuration: 1056x784-SGRBG10_IPU3\n> ipu3.cpp:222 Validating stream: 1056x784-SGRBG10_IPU3\n> ipu3.cpp:233 Assigned 1056x784-SGRBG10_IPU3 to the raw stream\n> \n> Without this patch the same operation results in the stream resolution\n> to be adjusted to the sensor resolution.\n> \n> $ cam -c1 -swidth=1056,height=784,role=raw\n> ipu3.cpp:201 CIO2 configuration: 4224x3136-SGRBG10_IPU3\n> ipu3.cpp:216 Validating stream: 1056x784-SGRBG10_IPU3\n> ipu3.cpp:227 Assigned 4224x3136-SGRBG10_IPU3 to the raw stream\n> ipu3.cpp:297 Stream 0 configuration adjusted to 4224x3136-SGRBG10_IPU3\n> Camera configuration adjusted\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 15 +++++++++++----\n>  1 file changed, 11 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index db0d6b91be70..d73dd50e2f1d 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -162,12 +162,14 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n>  \tunsigned int rawCount = 0;\n>  \tunsigned int yuvCount = 0;\n>  \tSize maxYuvSize;\n> +\tSize maxRawSize;\n>  \n>  \tfor (const StreamConfiguration &cfg : config_) {\n>  \t\tconst PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat);\n>  \n>  \t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) {\n>  \t\t\trawCount++;\n> +\t\t\tmaxRawSize.expandTo(cfg.size);\n\nGiven that we can't have more than one raw stream you could also write\n\n\t\t\tmaxRawSize = cfg.size;\n\nand possibly event rename the variable to rawSize. Up to you.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  \t\t} else {\n>  \t\t\tyuvCount++;\n>  \t\t\tmaxYuvSize.expandTo(cfg.size);\n> @@ -190,11 +192,16 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n>  \t * commit message of the patch that introduced this comment for more\n>  \t * failure examples).\n>  \t *\n> -\t * Until the sensor frame size calculation criteria are clarified,\n> -\t * always use the largest possible one which guarantees better results\n> -\t * at the expense of the frame rate and CSI-2 bus bandwidth.\n> +\t * Until the sensor frame size calculation criteria are clarified, when\n> +\t * capturing from ImgU always use the largest possible size which\n> +\t * guarantees better results at the expense of the frame rate and CSI-2\n> +\t * bus bandwidth. When only a raw stream is requested use the requested\n> +\t * size instead, as the ImgU is not involved.\n>  \t */\n> -\tcio2Configuration_ = data_->cio2_.generateConfiguration({});\n> +\tif (!yuvCount)\n> +\t\tcio2Configuration_ = data_->cio2_.generateConfiguration(maxRawSize);\n> +\telse\n> +\t\tcio2Configuration_ = data_->cio2_.generateConfiguration({});\n>  \tif (!cio2Configuration_.pixelFormat.isValid())\n>  \t\treturn Invalid;\n>","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 BE763BD162\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Feb 2021 23:13:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 410F061497;\n\tFri,  5 Feb 2021 00:13:57 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B8E76613D4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Feb 2021 00:13:55 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 28ADB2C1;\n\tFri,  5 Feb 2021 00:13:55 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"l4hZtXoC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1612480435;\n\tbh=+Njs4EeCFAitXafntwNebWqid8PQUAbbc/bDAljl02k=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=l4hZtXoCyv5kQ329ics8gfRZEkmE7hLYp04gH9Ot97jI0CIGep2qT2iE4Vq+MdkzO\n\tcz1ekzTLr+UfQBooYU5GOg0xD8EXxTcEWTDHL98yXWi4E2IYXfFFcEooE3Nz8ExN/m\n\tVJx2+FyYZ/KyGcroNF0jRGq+ZsSwr7dLOoQ/u4/A=","Date":"Fri, 5 Feb 2021 01:13:32 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YBx/nF6EXvshxjYn@pendragon.ideasonboard.com>","References":"<20210203112316.150393-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210203112316.150393-1-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: ipu3: Fix RAW sizes\n\tselection","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]