Patch Detail
Show a patch.
GET /api/1.1/patches/12485/?format=api
{ "id": 12485, "url": "https://patchwork.libcamera.org/api/1.1/patches/12485/?format=api", "web_url": "https://patchwork.libcamera.org/patch/12485/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20210602102326.106549-3-umang.jain@ideasonboard.com>", "date": "2021-06-02T10:23:24", "name": "[libcamera-devel,2/4] ipa: ipu3: Calculate line duration from IPACameraSensorInfo", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "e6bbb11502eaca18dc88092c2a1d6f016ff0e5ee", "submitter": { "id": 86, "url": "https://patchwork.libcamera.org/api/1.1/people/86/?format=api", "name": "Umang Jain", "email": "umang.jain@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/12485/mbox/", "series": [ { "id": 2100, "url": "https://patchwork.libcamera.org/api/1.1/series/2100/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2100", "date": "2021-06-02T10:23:22", "name": "IPAIPU3 drive-by improvements", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2100/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/12485/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/12485/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 6D9CDC3208\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 2 Jun 2021 10:23:42 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2BC86602AF;\n\tWed, 2 Jun 2021 12:23:42 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B7ACD68929\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 2 Jun 2021 12:23:40 +0200 (CEST)", "from perceval.ideasonboard.com (unknown [103.251.226.189])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B0E9D4A5;\n\tWed, 2 Jun 2021 12:23:39 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"UtLH6N0U\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1622629420;\n\tbh=to6cSYtIicTZXif4Qk/X4aVwAAdccqAhk7IL9SAGETY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=UtLH6N0UkvxzvMn+b7HayF1/7RTv8VF0Dgb0UCLXEaSlmZnFP7IyxPMFwV0HbCIPe\n\tfY4kIvrQG7HXLxxssHCloBrIWr4ElWmUrit3LjCAnsIrWjHEYoqj3pN6xo2+6IN1dM\n\t8Br44+/FqgYpffN72hhxnz/QHDQgum2TeEdIGzMk=", "From": "Umang Jain <umang.jain@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 2 Jun 2021 15:53:24 +0530", "Message-Id": "<20210602102326.106549-3-umang.jain@ideasonboard.com>", "X-Mailer": "git-send-email 2.31.1", "In-Reply-To": "<20210602102326.106549-1-umang.jain@ideasonboard.com>", "References": "<20210602102326.106549-1-umang.jain@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/4] ipa: ipu3: Calculate line duration\n\tfrom IPACameraSensorInfo", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "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/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Squash \\todo by calculating line duration from IPACameraSensorInfo,\nnow passed in, to IPU3Agc::initialise().\n\nSince line duration is now calculated from real values, store it as a\nprivate member in IPU3Agc class. As a further step, replace the\nassociated global constant, kMaxExposureTime, with a private IPU3Agc\nclass member as well, and assign its value correspondingly in\nIPU3Agc::initialise(), similar to previous precedence.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/ipa/ipu3/ipu3.cpp | 2 +-\n src/ipa/ipu3/ipu3_agc.cpp | 22 +++++++++++-----------\n src/ipa/ipu3/ipu3_agc.h | 7 ++++++-\n 3 files changed, 18 insertions(+), 13 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 700a5660..2496b0a0 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -174,7 +174,7 @@ void IPAIPU3::configure(const IPAConfigInfo &configInfo)\n \tawbAlgo_->initialise(params_, configInfo.bdsOutputSize, bdsGrid_);\n \n \tagcAlgo_ = std::make_unique<IPU3Agc>();\n-\tagcAlgo_->initialise(bdsGrid_);\n+\tagcAlgo_->initialise(bdsGrid_, configInfo.sensorInfo);\n }\n \n void IPAIPU3::mapBuffers(const std::vector<IPABuffer> &buffers)\ndiff --git a/src/ipa/ipu3/ipu3_agc.cpp b/src/ipa/ipu3/ipu3_agc.cpp\nindex 8bae423f..ccd01371 100644\n--- a/src/ipa/ipu3/ipu3_agc.cpp\n+++ b/src/ipa/ipu3/ipu3_agc.cpp\n@@ -39,11 +39,6 @@ static constexpr uint32_t kMaxGain = kMaxISO / 100;\n static constexpr uint32_t kMinExposure = 1;\n static constexpr uint32_t kMaxExposure = 1976;\n \n-/* \\todo those should be got from IPACameraSensorInfo ! */\n-/* line duration in microseconds */\n-static constexpr double kLineDuration = 16.8;\n-static constexpr double kMaxExposureTime = kMaxExposure * kLineDuration;\n-\n /* Histogram constants */\n static constexpr uint32_t knumHistogramBins = 256;\n static constexpr double kEvGainTarget = 0.5;\n@@ -54,14 +49,19 @@ static constexpr uint8_t kCellSize = 8;\n IPU3Agc::IPU3Agc()\n \t: frameCount_(0), lastFrame_(0), converged_(false),\n \t updateControls_(false), iqMean_(0.0), gamma_(1.0),\n+\t lineDuration_(0.0), maxExposureTime_(0.0),\n \t prevExposure_(0.0), prevExposureNoDg_(0.0),\n \t currentExposure_(0.0), currentExposureNoDg_(0.0)\n {\n }\n \n-void IPU3Agc::initialise(struct ipu3_uapi_grid_config &bdsGrid)\n+void IPU3Agc::initialise(struct ipu3_uapi_grid_config &bdsGrid, const IPACameraSensorInfo &sensorInfo)\n {\n \taeGrid_ = bdsGrid;\n+\n+\t/* line duration in microseconds */\n+\tlineDuration_ = sensorInfo.lineLength / static_cast<double>(sensorInfo.pixelRate / 1000000);\n+\tmaxExposureTime_ = kMaxExposure * lineDuration_;\n }\n \n void IPU3Agc::processBrightness(const ipu3_uapi_stats_3a *stats)\n@@ -160,13 +160,13 @@ void IPU3Agc::lockExposureGain(uint32_t &exposure, uint32_t &gain)\n \t\tdouble newGain = kEvGainTarget * knumHistogramBins / iqMean_;\n \n \t\t/* extracted from Rpi::Agc::computeTargetExposure */\n-\t\tdouble currentShutter = exposure * kLineDuration;\n+\t\tdouble currentShutter = exposure * lineDuration_;\n \t\tcurrentExposureNoDg_ = currentShutter * gain;\n \t\tLOG(IPU3Agc, Debug) << \"Actual total exposure \" << currentExposureNoDg_\n \t\t\t\t << \" Shutter speed \" << currentShutter\n \t\t\t\t << \" Gain \" << gain;\n \t\tcurrentExposure_ = currentExposureNoDg_ * newGain;\n-\t\tdouble maxTotalExposure = kMaxExposureTime * kMaxGain;\n+\t\tdouble maxTotalExposure = maxExposureTime_ * kMaxGain;\n \t\tcurrentExposure_ = std::min(currentExposure_, maxTotalExposure);\n \t\tLOG(IPU3Agc, Debug) << \"Target total exposure \" << currentExposure_;\n \n@@ -174,18 +174,18 @@ void IPU3Agc::lockExposureGain(uint32_t &exposure, uint32_t &gain)\n \t\tfilterExposure();\n \n \t\tdouble newExposure = 0.0;\n-\t\tif (currentShutter < kMaxExposureTime) {\n+\t\tif (currentShutter < maxExposureTime_) {\n \t\t\texposure = std::clamp(static_cast<uint32_t>(exposure * currentExposure_ / currentExposureNoDg_), kMinExposure, kMaxExposure);\n \t\t\tnewExposure = currentExposure_ / exposure;\n \t\t\tgain = std::clamp(static_cast<uint32_t>(gain * currentExposure_ / newExposure), kMinGain, kMaxGain);\n \t\t\tupdateControls_ = true;\n-\t\t} else if (currentShutter >= kMaxExposureTime) {\n+\t\t} else if (currentShutter >= maxExposureTime_) {\n \t\t\tgain = std::clamp(static_cast<uint32_t>(gain * currentExposure_ / currentExposureNoDg_), kMinGain, kMaxGain);\n \t\t\tnewExposure = currentExposure_ / gain;\n \t\t\texposure = std::clamp(static_cast<uint32_t>(exposure * currentExposure_ / newExposure), kMinExposure, kMaxExposure);\n \t\t\tupdateControls_ = true;\n \t\t}\n-\t\tLOG(IPU3Agc, Debug) << \"Adjust exposure \" << exposure * kLineDuration << \" and gain \" << gain;\n+\t\tLOG(IPU3Agc, Debug) << \"Adjust exposure \" << exposure * lineDuration_ << \" and gain \" << gain;\n \t}\n \tlastFrame_ = frameCount_;\n }\ndiff --git a/src/ipa/ipu3/ipu3_agc.h b/src/ipa/ipu3/ipu3_agc.h\nindex bfdf45d1..ae557bdd 100644\n--- a/src/ipa/ipu3/ipu3_agc.h\n+++ b/src/ipa/ipu3/ipu3_agc.h\n@@ -12,6 +12,8 @@\n \n #include <linux/intel-ipu3.h>\n \n+#include <libcamera/ipa/ipu3_ipa_interface.h>\n+\n #include <libcamera/geometry.h>\n \n #include \"libipa/algorithm.h\"\n@@ -26,7 +28,7 @@ public:\n \tIPU3Agc();\n \t~IPU3Agc() = default;\n \n-\tvoid initialise(struct ipu3_uapi_grid_config &bdsGrid);\n+\tvoid initialise(struct ipu3_uapi_grid_config &bdsGrid, const IPACameraSensorInfo &sensorInfo);\n \tvoid process(const ipu3_uapi_stats_3a *stats, uint32_t &exposure, uint32_t &gain);\n \tbool converged() { return converged_; }\n \tbool updateControls() { return updateControls_; }\n@@ -49,6 +51,9 @@ private:\n \tdouble iqMean_;\n \tdouble gamma_;\n \n+\tdouble lineDuration_;\n+\tdouble maxExposureTime_;\n+\n \tdouble prevExposure_;\n \tdouble prevExposureNoDg_;\n \tdouble currentExposure_;\n", "prefixes": [ "libcamera-devel", "2/4" ] }