From patchwork Fri Feb 24 11:33:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18307 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 73124BDCBF for ; Fri, 24 Feb 2023 11:33:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CE40562668; Fri, 24 Feb 2023 12:33:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1677238402; bh=lirPRQ4NRUpHX1eLLC8mLG5TVKmUI3H5Ik9OEa3iljw=; h=To:Date:In-Reply-To:References:List-Id:List-Post:From: List-Subscribe:List-Unsubscribe:List-Archive:Reply-To:List-Help: Subject:From; b=j1ipgsBI7zyxZgl6WYAUzxxz6IKWVBt/35tKpipLB5xeWckKWOpB1VSHCjSchJnIp 1P0T0HR7/HWViBfK8458CfojwXKoVme2SckNB/Th7FJ0u/ttuDbTJzXjTlLS+8c2FT rLv1UnX9cHo/WdWglH3HVqZbktotPjIMwMnp5/Bt4mvP7X2YMvyc/AS/J2FJf2N9Ys JZuZgiMKxxSHj1sRKyXgM/feXQkxfrU5Vm2TS9JT/vmGTDqYb2K/g1QRf7I4yBS4RY UdI8TXpl7mSo17pFiRzfZqlq0VA3wx85PBo2q6q0zNKcBxzqxP+mXq+HMS+vSw+uFC VkYmlw4RNgqCA== 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: List-Id: List-Post: X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Precedence: list X-Mailman-Version: 2.1.29 X-BeenThere: libcamera-devel@lists.libcamera.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Naushir Patuck List-Help: Subject: [libcamera-devel] [PATCH] pipeline: raspberrypi: Add a Unicam timeout override config options Content-Disposition: inline Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a new parameter to the pipeline handler config file named "unicam_timeout_value_ms" to allow users to override the automatically computed Unicam timeout value. This value is given in milliseconds, and setting a value of 0 (the default value) disables the override. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/example.yaml | 11 ++++++- .../pipeline/raspberrypi/raspberrypi.cpp | 29 ++++++++++++++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml index ad5f2344384f..5d4ca997b7a0 100644 --- a/src/libcamera/pipeline/raspberrypi/data/example.yaml +++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml @@ -32,6 +32,15 @@ # Override any request from the IPA to drop a number of startup # frames. # - # "disable_startup_frame_drops": false + # "disable_startup_frame_drops": false, + + # Custom timeout value (in ms) for Unicam to use. This overrides + # the value computed by the pipeline handler based on frame + # durations. + # + # Set this value to 0 to use the pipeline handler computed + # timeout value. + # + # "unicam_timeout_value_ms": 0 } } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 3d04842a2440..5239ec09fd5a 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -319,6 +319,11 @@ public: * frames. */ bool disableStartupFrameDrops; + /* + * Override the Unicam timeout value calculated by the IPA based + * on frame durations. + */ + unsigned int unicamTimeoutValue; }; Config config_; @@ -1158,6 +1163,9 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) data->state_ = RPiCameraData::State::Idle; + if (data->config_.unicamTimeoutValue) + data->setCameraTimeout(data->config_.unicamTimeoutValue); + /* Start all streams. */ for (auto const stream : data->streams_) { ret = stream->dev()->streamOn(); @@ -1715,6 +1723,7 @@ int RPiCameraData::loadPipelineConfiguration() .minUnicamBuffers = 2, .minTotalUnicamBuffers = 4, .disableStartupFrameDrops = false, + .unicamTimeoutValue = 0, }; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); @@ -1750,6 +1759,8 @@ int RPiCameraData::loadPipelineConfiguration() phConfig["min_total_unicam_buffers"].get(config_.minTotalUnicamBuffers); config_.disableStartupFrameDrops = phConfig["disable_startup_frame_drops"].get(config_.disableStartupFrameDrops); + config_.unicamTimeoutValue = + phConfig["unicam_timeout_value_ms"].get(config_.unicamTimeoutValue); if (config_.minTotalUnicamBuffers < config_.minUnicamBuffers) { LOG(RPI, Error) << "Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers"; @@ -1953,13 +1964,17 @@ void RPiCameraData::setLensControls(const ControlList &controls) void RPiCameraData::setCameraTimeout(uint32_t maxFrameLengthMs) { - /* - * Set the dequeue timeout to the larger of 5x the maximum reported - * frame length advertised by the IPA over a number of frames. Allow - * a minimum timeout value of 1s. - */ - utils::Duration timeout = - std::max(1s, 5 * maxFrameLengthMs * 1ms); + utils::Duration timeout; + + if (!config_.unicamTimeoutValue) { + /* + * Set the dequeue timeout to the larger of 5x the maximum reported + * frame length advertised by the IPA over a number of frames. Allow + * a minimum timeout value of 1s. + */ + timeout = std::max(1s, 5 * maxFrameLengthMs * 1ms); + } else + timeout = config_.unicamTimeoutValue * 1ms; LOG(RPI, Debug) << "Setting Unicam timeout to " << timeout; unicam_[Unicam::Image].dev()->setDequeueTimeout(timeout);