[{"id":25982,"web_url":"https://patchwork.libcamera.org/comment/25982/","msgid":"<Y4oGLWFspebNAWMA@pendragon.ideasonboard.com>","date":"2022-12-02T14:05:33","subject":"Re: [libcamera-devel] [PATCH v2 07/10] pipeline: raspberrypi: Add a\n\tparameter to disable startup drop frames","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Tue, Nov 29, 2022 at 01:45:31PM +0000, Naushir Patuck via libcamera-devel wrote:\n> Add a new pipeline config parameter \"disable_startup_frame_drops\" to disable\n> any startup drop frames, overriding the IPA request.\n> \n> When this parameter is set, it allows the pipeline handler to run with no\n> internally allocated Unicam buffers (\"min_unicam_buffers\").\n> \n> Add a validation to ensure if \"disable_startup_frame_drops\" is false, at least\n> one internal Unicam buffer is allocated, possibly overriding the\n> \"min_unicam_buffers\" parameter.\n\nIs this meant to support applications that want to capture all frames,\nor only as a side effect of the memory allocation optimizations to lower\nmemory consumption ? In the latter case, as mentioned in the review of\n06/10, I don't think this would be required.\n\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  .../pipeline/raspberrypi/data/default.json    |  7 +++++--\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 19 ++++++++++++++++++-\n>  2 files changed, 23 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/data/default.json b/src/libcamera/pipeline/raspberrypi/data/default.json\n> index a7ea735c87f4..707414bcc5c5 100644\n> --- a/src/libcamera/pipeline/raspberrypi/data/default.json\n> +++ b/src/libcamera/pipeline/raspberrypi/data/default.json\n> @@ -5,7 +5,7 @@\n>          \"pipeline_handler\":\n>          {\n>                  # The minimum number of internal buffers to be allocated for Unicam.\n> -                # This value must be greater than 0, but less than or equal to min_total_unicam_buffers.\n> +                # This value must less than or equal to min_total_unicam_buffers.\n>                  \"min_unicam_buffers\": 2,\n>  \n>                  # The minimum total (internal + external) buffer count used for Unicam.\n> @@ -15,6 +15,9 @@\n>                  \"min_total_unicam_buffers\": 4,\n>                  \n>                  # The number of internal buffers used for ISP Output0.\n> -                \"num_output0_buffers\": 1\n> +                \"num_output0_buffers\": 1,\n> +\n> +                # Override any request from the IPA to drop a number of startup frames.\n> +                \"disable_startup_frame_drops\": false\n>          }\n>  }\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 742521927780..ef49d32037af 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -312,6 +312,11 @@ public:\n>  \t\t * stream.\n>  \t\t */\n>  \t\tunsigned int numOutput0Buffers;\n> +\t\t/*\n> +\t\t * Override any request from the IPA to drop a number of startup\n> +\t\t * frames.\n> +\t\t */\n> +\t\tbool disableStartupFrameDrops;\n>  \t};\n>  \n>  \tConfig config_;\n> @@ -1058,7 +1063,7 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)\n>  \t\tdata->setSensorControls(startConfig.controls);\n>  \n>  \t/* Configure the number of dropped frames required on startup. */\n> -\tdata->dropFrameCount_ = startConfig.dropFrameCount;\n> +\tdata->dropFrameCount_ = data->config_.disableStartupFrameDrops ? 0 : startConfig.dropFrameCount;\n>  \n>  \tfor (auto const stream : data->streams_)\n>  \t\tstream->resetBuffers();\n> @@ -1451,6 +1456,7 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data)\n>  \t\t.minUnicamBuffers = 2,\n>  \t\t.minTotalUnicamBuffers = 4,\n>  \t\t.numOutput0Buffers = 1,\n> +\t\t.disableStartupFrameDrops = false,\n>  \t};\n>  \n>  \tchar const *configFromEnv = utils::secure_getenv(\"LIBCAMERA_RPI_CONFIG_FILE\");\n> @@ -1485,6 +1491,8 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data)\n>  \t\tphConfig[\"min_total_unicam_buffers\"].get<unsigned int>(config.minTotalUnicamBuffers);\n>  \tconfig.numOutput0Buffers =\n>  \t\tphConfig[\"num_output0_buffers\"].get<unsigned int>(config.numOutput0Buffers);\n> +\tconfig.disableStartupFrameDrops =\n> +\t\tphConfig[\"disable_startup_frame_drops\"].get<bool>(config.disableStartupFrameDrops);\n>  \n>  \tif (config.minTotalUnicamBuffers < config.minUnicamBuffers) {\n>  \t\tLOG(RPI, Error) << \"Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers!\";\n> @@ -1569,6 +1577,15 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n>  \t\t\t */\n>  \t\t\tnumBuffers = std::max<int>(data->config_.minUnicamBuffers,\n>  \t\t\t\t\t\t   minBuffers - numRawBuffers);\n> +\n> +\t\t\tif (numBuffers == 0 && data->dropFrameCount_) {\n> +\t\t\t\tLOG(RPI, Warning)\n> +\t\t\t\t\t<< \"Configured with no Unicam buffers,\"\n> +\t\t\t\t\t   \" but the IPA requested startup frame drops.\"\n> +\t\t\t\t\t   \" Increasing to one buffer.\";\n> +\t\t\t\tnumBuffers = 1;\n> +\t\t\t}\n> +\n>  \t\t\tdata->numUnicamBuffers = numBuffers;\n>  \t\t} else if (stream == &data->isp_[Isp::Input]) {\n>  \t\t\t/*","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 809B8BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Dec 2022 14:05:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E65546333F;\n\tFri,  2 Dec 2022 15:05:36 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8FB5260483\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Dec 2022 15:05:35 +0100 (CET)","from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0119F6E0;\n\tFri,  2 Dec 2022 15:05:34 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669989936;\n\tbh=qy3yDvqkV8gzSktwsgtI6NphqY0qvWkJ9j81zsmppw0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=reQGIQ2wl0jbsRxNEIui9vHnQij/ubz19sgsR/SL3sx0S+m6ZZ3TOx6+Oq9JYasMJ\n\tOPSDkfbYT14oKDWWFOJlLaFHyZIDRXBsi+m4KZyExnPTfsUCH2qgJIoQOp77BTJRra\n\th0k1qdpdN//kuoWBjLLrrDvfeae09Axsmb/MVSZtlxHJBtOkQYD3hTfgr6+av7JcHm\n\tmubvN6Hhi6Hw8nFTHWiE5GrkubWt/Apv3mWEsh7ZqF3/oAukCkDSpOkr3ED1dK54iN\n\tybvN2nTLxapWtpoZRvmVUrqra4E+il0giCygiLGgX4ujAr5rJjjt1PnIU9H3yrmvlk\n\tR4APq2nLr5w/g==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669989935;\n\tbh=qy3yDvqkV8gzSktwsgtI6NphqY0qvWkJ9j81zsmppw0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=fTzEdmNDW18q2GrhxDWOEf/HgI3xeCni1K6mQkwrh4+Y6l6S+6vhRONGK3As/Ag5S\n\t0MG2l9areiXIxyvQIEO1ASQMwtFH1HxhAMULl1Cx2D5oUoFBh35xUW0pOVK0+gAGm5\n\tNm0yiYiKHziIqHyO83BseRDpoCmdEN6ypWw3zkYY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"fTzEdmND\"; dkim-atps=neutral","Date":"Fri, 2 Dec 2022 16:05:33 +0200","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<Y4oGLWFspebNAWMA@pendragon.ideasonboard.com>","References":"<20221129134534.2933-1-naush@raspberrypi.com>\n\t<20221129134534.2933-8-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20221129134534.2933-8-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2 07/10] pipeline: raspberrypi: Add a\n\tparameter to disable startup drop frames","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]