{"id":18307,"url":"https://patchwork.libcamera.org/api/1.1/patches/18307/?format=json","web_url":"https://patchwork.libcamera.org/patch/18307/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<mailman.25.1677238402.25031.libcamera-devel@lists.libcamera.org>","date":"2023-02-24T11:33:15","name":"[libcamera-devel] pipeline: raspberrypi: Add a Unicam timeout override config options","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"cdea718292550a8e640280e35d46a042d2bce4d4","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18307/mbox/","series":[{"id":3768,"url":"https://patchwork.libcamera.org/api/1.1/series/3768/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3768","date":"2023-02-24T11:33:15","name":"[libcamera-devel] pipeline: raspberrypi: Add a Unicam timeout override config options","version":1,"mbox":"https://patchwork.libcamera.org/series/3768/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18307/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18307/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 73124BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Feb 2023 11:33:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CE40562668;\n\tFri, 24 Feb 2023 12:33:22 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1677238402;\n\tbh=lirPRQ4NRUpHX1eLLC8mLG5TVKmUI3H5Ik9OEa3iljw=;\n\th=To:Date:In-Reply-To:References:List-Id:List-Post:From:\n\tList-Subscribe:List-Unsubscribe:List-Archive:Reply-To:List-Help:\n\tSubject:From;\n\tb=j1ipgsBI7zyxZgl6WYAUzxxz6IKWVBt/35tKpipLB5xeWckKWOpB1VSHCjSchJnIp\n\t1P0T0HR7/HWViBfK8458CfojwXKoVme2SckNB/Th7FJ0u/ttuDbTJzXjTlLS+8c2FT\n\trLv1UnX9cHo/WdWglH3HVqZbktotPjIMwMnp5/Bt4mvP7X2YMvyc/AS/J2FJf2N9Ys\n\tJZuZgiMKxxSHj1sRKyXgM/feXQkxfrU5Vm2TS9JT/vmGTDqYb2K/g1QRf7I4yBS4RY\n\tUdI8TXpl7mSo17pFiRzfZqlq0VA3wx85PBo2q6q0zNKcBxzqxP+mXq+HMS+vSw+uFC\n\tVkYmlw4RNgqCA==","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 24 Feb 2023 11:33:15 +0000","In-Reply-To":"<20230223124957.11084-4-naush@raspberrypi.com>","References":"<20230223124957.11084-4-naush@raspberrypi.com>","MIME-Version":"1.0","Message-ID":"<mailman.25.1677238402.25031.libcamera-devel@lists.libcamera.org>","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Precedence":"list","X-Mailman-Version":"2.1.29","X-BeenThere":"libcamera-devel@lists.libcamera.org","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","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/>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","Subject":"[libcamera-devel] [PATCH] pipeline: raspberrypi: Add a Unicam\n\ttimeout override config options","Content-Type":"message/rfc822","Content-Disposition":"inline","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a new parameter to the pipeline handler config file named\n\"unicam_timeout_value_ms\" to allow users to override the automatically\ncomputed Unicam timeout value.\n\nThis value is given in milliseconds, and setting a value of 0 (the\ndefault value) disables the override.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/raspberrypi/data/example.yaml    | 11 ++++++-\n .../pipeline/raspberrypi/raspberrypi.cpp      | 29 ++++++++++++++-----\n 2 files changed, 32 insertions(+), 8 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml\nindex ad5f2344384f..5d4ca997b7a0 100644\n--- a/src/libcamera/pipeline/raspberrypi/data/example.yaml\n+++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml\n@@ -32,6 +32,15 @@\n                 # Override any request from the IPA to drop a number of startup\n                 # frames.\n                 #\n-                # \"disable_startup_frame_drops\": false\n+                # \"disable_startup_frame_drops\": false,\n+\n+                # Custom timeout value (in ms) for Unicam to use. This overrides\n+                # the value computed by the pipeline handler based on frame\n+                # durations.\n+                #\n+                # Set this value to 0 to use the pipeline handler computed\n+                # timeout value.\n+                #\n+                # \"unicam_timeout_value_ms\": 0\n         }\n }\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 3d04842a2440..5239ec09fd5a 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -319,6 +319,11 @@ public:\n \t\t * frames.\n \t\t */\n \t\tbool disableStartupFrameDrops;\n+\t\t/*\n+\t\t * Override the Unicam timeout value calculated by the IPA based\n+\t\t * on frame durations.\n+\t\t */\n+\t\tunsigned int unicamTimeoutValue;\n \t};\n \n \tConfig config_;\n@@ -1158,6 +1163,9 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)\n \n \tdata->state_ = RPiCameraData::State::Idle;\n \n+\tif (data->config_.unicamTimeoutValue)\n+\t\tdata->setCameraTimeout(data->config_.unicamTimeoutValue);\n+\n \t/* Start all streams. */\n \tfor (auto const stream : data->streams_) {\n \t\tret = stream->dev()->streamOn();\n@@ -1715,6 +1723,7 @@ int RPiCameraData::loadPipelineConfiguration()\n \t\t.minUnicamBuffers = 2,\n \t\t.minTotalUnicamBuffers = 4,\n \t\t.disableStartupFrameDrops = false,\n+\t\t.unicamTimeoutValue = 0,\n \t};\n \n \tchar const *configFromEnv = utils::secure_getenv(\"LIBCAMERA_RPI_CONFIG_FILE\");\n@@ -1750,6 +1759,8 @@ int RPiCameraData::loadPipelineConfiguration()\n \t\tphConfig[\"min_total_unicam_buffers\"].get<unsigned int>(config_.minTotalUnicamBuffers);\n \tconfig_.disableStartupFrameDrops =\n \t\tphConfig[\"disable_startup_frame_drops\"].get<bool>(config_.disableStartupFrameDrops);\n+\tconfig_.unicamTimeoutValue =\n+\t\tphConfig[\"unicam_timeout_value_ms\"].get<unsigned int>(config_.unicamTimeoutValue);\n \n \tif (config_.minTotalUnicamBuffers < config_.minUnicamBuffers) {\n \t\tLOG(RPI, Error) << \"Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers\";\n@@ -1953,13 +1964,17 @@ void RPiCameraData::setLensControls(const ControlList &controls)\n \n void RPiCameraData::setCameraTimeout(uint32_t maxFrameLengthMs)\n {\n-\t/*\n-\t * Set the dequeue timeout to the larger of 5x the maximum reported\n-\t * frame length advertised by the IPA over a number of frames. Allow\n-\t * a minimum timeout value of 1s.\n-\t */\n-\tutils::Duration timeout =\n-\t\tstd::max<utils::Duration>(1s, 5 * maxFrameLengthMs * 1ms);\n+\tutils::Duration timeout;\n+\n+\tif (!config_.unicamTimeoutValue) {\n+\t\t/*\n+\t\t * Set the dequeue timeout to the larger of 5x the maximum reported\n+\t\t * frame length advertised by the IPA over a number of frames. Allow\n+\t\t * a minimum timeout value of 1s.\n+\t\t */\n+\t\ttimeout = std::max<utils::Duration>(1s, 5 * maxFrameLengthMs * 1ms);\n+\t} else\n+\t\ttimeout = config_.unicamTimeoutValue * 1ms;\n \n \tLOG(RPI, Debug) << \"Setting Unicam timeout to \" << timeout;\n \tunicam_[Unicam::Image].dev()->setDequeueTimeout(timeout);\n","prefixes":["libcamera-devel"]}