From patchwork Thu Mar 2 13:54:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18332 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 35DD8BE080 for ; Thu, 2 Mar 2023 13:54:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DCE61626DE; Thu, 2 Mar 2023 14:54:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1677765273; bh=AzybjmvGnBPwvzyZhnNV47vkseJ3oOqdbm1re0zZiQk=; h=To:Date:In-Reply-To:References:List-Id:List-Post:From:Cc: List-Subscribe:List-Unsubscribe:List-Archive:Reply-To:List-Help: Subject:From; b=xrCNhrljiPszq8n2dhCJe2tuecH/Rv/JEFY+pBvSy7qYCCeSRiVPOy+6q74BOUU4c l2N4X/tG7dpeiR+kgapSh7txe5ifN9mKt4c3mo0OWNa/p6f9xtzaN2ISqcXK3ivUi4 XA07adT+yge8ffs+lHBU17J6tNiXWXWSBcMSuzXLTO3oyerD51ioj1hcfdMj8hqC6O WQtsoUk9pKbcNnB0zqbwAcS0VccV7+Twbb2K5IrSpBLtcZUroK1T9BjzYSHaRpeY7l E5j655HfJXXi3iBoKTEKHRLslu3uo90Xsu/jYQSCW+UC4WvNvwibfwv0Kz6L8NQjL8 eXZrKHNg7sMbA== To: libcamera-devel@lists.libcamera.org Date: Thu, 2 Mar 2023 13:54:27 +0000 In-Reply-To: <20230302135429.23821-1-naush@raspberrypi.com> References: <20230302135429.23821-1-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 Cc: Jacopo Mondi 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 v2 1/3] pipeline: ipa: raspberrypi: Change Unicam timeout handling Content-Disposition: inline Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add an explicit helper function setCameraTimeout() in the pipeline handler to set the Unicam timeout value. This function is signalled from the IPA to set up an appropriate timeout. This replaces the maxSensorFrameLengthMs value parameter returned back from IPARPi::start(). Adjust the timeout to be 5x the maximum frame duration reported by the IPA. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/raspberrypi.mojom | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 2 +- .../pipeline/raspberrypi/raspberrypi.cpp | 24 ++++++++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 8e78f167f179..80e0126618c8 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -49,7 +49,6 @@ struct IPAConfigResult { struct StartConfig { libcamera.ControlList controls; int32 dropFrameCount; - uint32 maxSensorFrameLengthMs; }; interface IPARPiInterface { @@ -132,4 +131,5 @@ interface IPARPiEventInterface { setIspControls(libcamera.ControlList controls); setDelayedControls(libcamera.ControlList controls, uint32 delayContext); setLensControls(libcamera.ControlList controls); + setCameraTimeout(uint32 maxFrameLengthMs); }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 9b08ae4ca622..f6826bf27fe1 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -341,7 +341,7 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) startConfig->dropFrameCount = dropFrameCount_; const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.maxLineLength; - startConfig->maxSensorFrameLengthMs = maxSensorFrameDuration.get(); + setCameraTimeout.emit(maxSensorFrameDuration.get()); firstStart_ = false; lastRunTimestamp_ = 0; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 841209548350..3d04842a2440 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -212,6 +212,7 @@ public: void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls, uint32_t delayContext); void setLensControls(const ControlList &controls); + void setCameraTimeout(uint32_t maxExposureTimeMs); void setSensorControls(ControlList &controls); void unicamTimeout(); @@ -1166,14 +1167,6 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) } } - /* - * Set the dequeue timeout to the larger of 2x the maximum possible - * frame duration or 1 second. - */ - utils::Duration timeout = - std::max(1s, 2 * startConfig.maxSensorFrameLengthMs * 1ms); - data->unicam_[Unicam::Image].dev()->setDequeueTimeout(timeout); - return 0; } @@ -1645,6 +1638,7 @@ int RPiCameraData::loadIPA(ipa::RPi::IPAInitResult *result) ipa_->setIspControls.connect(this, &RPiCameraData::setIspControls); ipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls); ipa_->setLensControls.connect(this, &RPiCameraData::setLensControls); + ipa_->setCameraTimeout.connect(this, &RPiCameraData::setCameraTimeout); /* * The configuration (tuning file) is made from the sensor name unless @@ -1957,6 +1951,20 @@ 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); + + LOG(RPI, Debug) << "Setting Unicam timeout to " << timeout; + unicam_[Unicam::Image].dev()->setDequeueTimeout(timeout); +} + void RPiCameraData::setSensorControls(ControlList &controls) { /*