Patch Detail
Show a patch.
GET /api/patches/18302/?format=api
{ "id": 18302, "url": "https://patchwork.libcamera.org/api/patches/18302/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18302/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<mailman.14.1677156593.25031.libcamera-devel@lists.libcamera.org>", "date": "2023-02-23T12:49:56", "name": "[libcamera-devel,v1,2/3] ipa: raspberrypi: Better heruistics for calculating Unicam timeout", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "9c04b4260ae312ad1f21aa5ce72caf5025577eb6", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18302/mbox/", "series": [ { "id": 3764, "url": "https://patchwork.libcamera.org/api/series/3764/?format=api", "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/18302/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18302/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 746ADC3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Feb 2023 12:49:55 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C4FB56265E;\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=zeJASNYiblWKKexCvMJ+Ho4CHyPrKUIqI2hvFNBfeuQ=;\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=jbZkbsMbSAnphqPwiMCcO3CCtZhDwLNWCmi9lujgUZ9fJX9MnAGlKesHEgxjbDNvs\n\tNcmz7G/gfiq9bRznAYRmw9wPyRQGPL9EA9aRC9bllbzXriHjgqvoDSiPRyOCOcXgL9\n\t7SNnjFldH2Prjl5OIFqKtMEvNMWKLUKNW+NHBAZLyBLpHAGUcoWcDP/NWT/SLjlEu+\n\tiBPq1P1AfqHwqjN4p+7r5rLpNgNezeuxEJTsZ5ssWTxZ3Qqvz1X6ya0J6p+HvaO6MW\n\t6nXLNH1ydiuhmZTrdF2DxhayguOSa6ojYXtjodPsWgnzzvsYiLySLskorCq5Fcyt80\n\ttb+nGIoWDb9Aw==", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 23 Feb 2023 12:49:56 +0000", "In-Reply-To": "<20230223124957.11084-1-naush@raspberrypi.com>", "References": "<20230223124957.11084-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Message-ID": "<mailman.14.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 2/3] ipa: raspberrypi: Better\n\theruistics for calculating Unicam timeout", "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": "The existing mechanism of setting a timeout value simply uses the\nmaximum possible frame length advertised by the sensor mode. This can be\nproblematic when, for example, the IMX477 sensor can use a frame length\nof over 600 seconds. However, for typical usage the frame length will\nnever go over several 100s of milliseconds, making the timeout very\nimpractical.\n\nStore a list of the last 10 frame length values requested by the AGC. On\nstartup, and at the end of every frame, take the maximum frame length\nvalue from this list and return that to the pipeline handler through the\nsetCameraTimeoutValue() signal. This allows the timeout value to better\ntrack the actual sensor usage.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/raspberrypi.cpp | 33 +++++++++++++++++++++++++++--\n 1 file changed, 31 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex f6826bf27fe1..b8fe0c002a13 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -8,6 +8,7 @@\n #include <algorithm>\n #include <array>\n #include <cstring>\n+#include <deque>\n #include <fcntl.h>\n #include <math.h>\n #include <stdint.h>\n@@ -64,6 +65,9 @@ using utils::Duration;\n /* Number of metadata objects available in the context list. */\n constexpr unsigned int numMetadataContexts = 16;\n \n+/* Number of frame length times to hold in the queue. */\n+constexpr unsigned int FrameLengthsQueueSize = 10;\n+\n /* Configure the sensor with these values initially. */\n constexpr double defaultAnalogueGain = 1.0;\n constexpr Duration defaultExposureTime = 20.0ms;\n@@ -155,6 +159,7 @@ private:\n \tvoid fillDeviceStatus(const ControlList &sensorControls, unsigned int ipaContext);\n \tRPiController::StatisticsPtr fillStatistics(bcm2835_isp_stats *stats) const;\n \tvoid processStats(unsigned int bufferId, unsigned int ipaContext);\n+\tvoid setCameraTimeoutValue();\n \tvoid applyFrameDurations(Duration minFrameDuration, Duration maxFrameDuration);\n \tvoid applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls);\n \tvoid applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls);\n@@ -220,6 +225,9 @@ private:\n \n \t/* Maximum gain code for the sensor. */\n \tuint32_t maxSensorGainCode_;\n+\n+\t/* Track the frame length times over FrameLengthsQueueSize frames. */\n+\tstd::deque<Duration> frameLengths_;\n };\n \n int IPARPi::init(const IPASettings &settings, bool lensPresent, IPAInitResult *result)\n@@ -294,6 +302,7 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig)\n \t\tControlList ctrls(sensorCtrls_);\n \t\tapplyAGC(&agcStatus, ctrls);\n \t\tstartConfig->controls = std::move(ctrls);\n+\t\tsetCameraTimeoutValue();\n \t}\n \n \t/*\n@@ -340,8 +349,6 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig)\n \t}\n \n \tstartConfig->dropFrameCount = dropFrameCount_;\n-\tconst Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.maxLineLength;\n-\tsetCameraTimeout.emit(maxSensorFrameDuration.get<std::milli>());\n \n \tfirstStart_ = false;\n \tlastRunTimestamp_ = 0;\n@@ -1434,9 +1441,20 @@ void IPARPi::processStats(unsigned int bufferId, unsigned int ipaContext)\n \t\tapplyAGC(&agcStatus, ctrls);\n \n \t\tsetDelayedControls.emit(ctrls, ipaContext);\n+\t\tsetCameraTimeoutValue();\n \t}\n }\n \n+void IPARPi::setCameraTimeoutValue()\n+{\n+\t/*\n+\t * Take the maximum value of the exposure queue as the camera timeout\n+\t * value to pass back to the pipe line handler.\n+\t */\n+\tauto max = std::max_element(frameLengths_.begin(), frameLengths_.end());\n+\tsetCameraTimeout.emit(max->get<std::milli>());\n+}\n+\n void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls)\n {\n \tLOG(IPARPI, Debug) << \"Applying WB R: \" << awbStatus->gainR << \" B: \"\n@@ -1522,6 +1540,17 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)\n \t */\n \tif (mode_.minLineLength != mode_.maxLineLength)\n \t\tctrls.set(V4L2_CID_HBLANK, static_cast<int32_t>(hblank));\n+\n+\t/*\n+\t * Store the frame length times in a circular queue, up-to FrameLengthsQueueSize\n+\t * elements. This will be used to advertise a camera timeout value to the\n+\t * pipeline handler.\n+\t */\n+\tif (frameLengths_.size() == FrameLengthsQueueSize)\n+\t\tframeLengths_.pop_front();\n+\n+\tframeLengths_.push_back(helper_->exposure(vblank + mode_.height,\n+\t\t\t\t\t\t helper_->hblankToLineLength(hblank)));\n }\n \n void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls)\n", "prefixes": [ "libcamera-devel", "v1", "2/3" ] }