{"id":18301,"url":"https://patchwork.libcamera.org/api/patches/18301/?format=json","web_url":"https://patchwork.libcamera.org/patch/18301/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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.13.1677156593.25031.libcamera-devel@lists.libcamera.org>","date":"2023-02-23T12:49:55","name":"[libcamera-devel,v1,1/3] pipeline: ipa: raspberrypi: Change Unicam timeout handling","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ccebaec06f94ca86e8a2c04526a9ce7e7194e6d5","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18301/mbox/","series":[{"id":3764,"url":"https://patchwork.libcamera.org/api/series/3764/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3764","date":"2023-02-23T12:49:54","name":"Raspberry Pi: Improving camera timeouts","version":1,"mbox":"https://patchwork.libcamera.org/series/3764/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18301/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18301/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 8B750BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Feb 2023 12:49:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 434F262664;\n\tThu, 23 Feb 2023 13:49:54 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1677156594;\n\tbh=Hz5iKLvqiO0511yMEmOYV3Z8axE5pG9HcE8xd6SXhho=;\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=r4p7StYYEntuq/mrxR3jSmuU8JCO8gL191J9ba+Coa/i7bnYcq6dwsC7mFHLxed1L\n\ti5um2S0efFpZXCmKdZ2djnw29IVs9+96pzUckPShyfSiNKR/6u/Ny28XNrwlZNXuxO\n\t/UFsUO1nsmq+sPWugFN3qRQomNgXQxlg584K8MJ0zmuDjawJMETVRaIcVIaRm9hN1y\n\tuhsRbMZm4sI7vd26Ev5ks3Nl9uIsYnXuE8cvswRYzndySnTck/FeBasFmGIU+cmpDN\n\tlQVdizz4/zGDoIPDScK33IYaG3dVaxykmZg4bWIQEPru5MWxqLarrYleWTJDSesbIk\n\tZNmOXtQKP69hA==","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 23 Feb 2023 12:49:55 +0000","In-Reply-To":"<20230223124957.11084-1-naush@raspberrypi.com>","References":"<20230223124957.11084-1-naush@raspberrypi.com>","MIME-Version":"1.0","Message-ID":"<mailman.13.1677156593.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 v1 1/3] pipeline: ipa: raspberrypi: Change\n\tUnicam timeout handling","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 an explicit helper function setCameraTimeout() in the pipeline\nhandler to set the Unicam timeout value. This function is signalled from\nthe IPA to set up an appropriate timeout. This replaces the\nmaxSensorFrameLengthMs value parameter returned back from\nIPARPi::start().\n\nAdjust the timeout to be 5x the maximum frame duration reported by the\nIPA.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n include/libcamera/ipa/raspberrypi.mojom       |  2 +-\n src/ipa/raspberrypi/raspberrypi.cpp           |  2 +-\n .../pipeline/raspberrypi/raspberrypi.cpp      | 24 ++++++++++++-------\n 3 files changed, 18 insertions(+), 10 deletions(-)","diff":"diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom\nindex 8e78f167f179..80e0126618c8 100644\n--- a/include/libcamera/ipa/raspberrypi.mojom\n+++ b/include/libcamera/ipa/raspberrypi.mojom\n@@ -49,7 +49,6 @@ struct IPAConfigResult {\n struct StartConfig {\n \tlibcamera.ControlList controls;\n \tint32 dropFrameCount;\n-\tuint32 maxSensorFrameLengthMs;\n };\n \n interface IPARPiInterface {\n@@ -132,4 +131,5 @@ interface IPARPiEventInterface {\n \tsetIspControls(libcamera.ControlList controls);\n \tsetDelayedControls(libcamera.ControlList controls, uint32 delayContext);\n \tsetLensControls(libcamera.ControlList controls);\n+\tsetCameraTimeout(uint32 maxFrameLengthMs);\n };\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 9b08ae4ca622..f6826bf27fe1 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -341,7 +341,7 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig)\n \n \tstartConfig->dropFrameCount = dropFrameCount_;\n \tconst Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.maxLineLength;\n-\tstartConfig->maxSensorFrameLengthMs = maxSensorFrameDuration.get<std::milli>();\n+\tsetCameraTimeout.emit(maxSensorFrameDuration.get<std::milli>());\n \n \tfirstStart_ = false;\n \tlastRunTimestamp_ = 0;\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 841209548350..3d04842a2440 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -212,6 +212,7 @@ public:\n \tvoid setIspControls(const ControlList &controls);\n \tvoid setDelayedControls(const ControlList &controls, uint32_t delayContext);\n \tvoid setLensControls(const ControlList &controls);\n+\tvoid setCameraTimeout(uint32_t maxExposureTimeMs);\n \tvoid setSensorControls(ControlList &controls);\n \tvoid unicamTimeout();\n \n@@ -1166,14 +1167,6 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)\n \t\t}\n \t}\n \n-\t/*\n-\t * Set the dequeue timeout to the larger of 2x the maximum possible\n-\t * frame duration or 1 second.\n-\t */\n-\tutils::Duration timeout =\n-\t\tstd::max<utils::Duration>(1s, 2 * startConfig.maxSensorFrameLengthMs * 1ms);\n-\tdata->unicam_[Unicam::Image].dev()->setDequeueTimeout(timeout);\n-\n \treturn 0;\n }\n \n@@ -1645,6 +1638,7 @@ int RPiCameraData::loadIPA(ipa::RPi::IPAInitResult *result)\n \tipa_->setIspControls.connect(this, &RPiCameraData::setIspControls);\n \tipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls);\n \tipa_->setLensControls.connect(this, &RPiCameraData::setLensControls);\n+\tipa_->setCameraTimeout.connect(this, &RPiCameraData::setCameraTimeout);\n \n \t/*\n \t * The configuration (tuning file) is made from the sensor name unless\n@@ -1957,6 +1951,20 @@ void RPiCameraData::setLensControls(const ControlList &controls)\n \t}\n }\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+\n+\tLOG(RPI, Debug) << \"Setting Unicam timeout to \" << timeout;\n+\tunicam_[Unicam::Image].dev()->setDequeueTimeout(timeout);\n+}\n+\n void RPiCameraData::setSensorControls(ControlList &controls)\n {\n \t/*\n","prefixes":["libcamera-devel","v1","1/3"]}