Patch Detail
Show a patch.
GET /api/1.1/patches/14223/?format=api
{ "id": 14223, "url": "https://patchwork.libcamera.org/api/1.1/patches/14223/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14223/", "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": "<20211021164401.110033-3-jeanmichel.hautbois@ideasonboard.com>", "date": "2021-10-21T16:43:49", "name": "[libcamera-devel,v3,02/14] ipa: ipu3: set frameContext before controls", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "b10167bbad068a05834f0705e1846deb5ad11ca3", "submitter": { "id": 75, "url": "https://patchwork.libcamera.org/api/1.1/people/75/?format=api", "name": "Jean-Michel Hautbois", "email": "jeanmichel.hautbois@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/14223/mbox/", "series": [ { "id": 2646, "url": "https://patchwork.libcamera.org/api/1.1/series/2646/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2646", "date": "2021-10-21T16:43:47", "name": "ipa: ipu3: Fix AGC bugs", "version": 3, "mbox": "https://patchwork.libcamera.org/series/2646/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14223/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14223/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 CC34ABF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Oct 2021 16:44:13 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B004B68F71;\n\tThu, 21 Oct 2021 18:44:08 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C96B768F57\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Oct 2021 18:44:05 +0200 (CEST)", "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:f9d:5926:ad90:4996])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 72F311BF9;\n\tThu, 21 Oct 2021 18:44:05 +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=\"XvhZj5qJ\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634834645;\n\tbh=WLcW3EpAUw6mRn12xBZYoxaEM+cAJa/igT+LGrJx8M8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=XvhZj5qJX5oA2GD1Bg0fBPozr5zVFzHJuhtTIopTRj9ZOJsUVDxVi+jw3h8tlehVO\n\tsCqVpFRpBS048CHgfkZNESJP/G2l/HU/ItiA+lZaunZf5VwZk/uFSExEYMKOqzVdFZ\n\tzuO51OgGXPslZnpU0BcWF16zZgSKKIqEWCovofic=", "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 21 Oct 2021 18:43:49 +0200", "Message-Id": "<20211021164401.110033-3-jeanmichel.hautbois@ideasonboard.com>", "X-Mailer": "git-send-email 2.32.0", "In-Reply-To": "<20211021164401.110033-1-jeanmichel.hautbois@ideasonboard.com>", "References": "<20211021164401.110033-1-jeanmichel.hautbois@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 02/14] ipa: ipu3: set frameContext\n\tbefore controls", "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": "The AGC frame context needs to be initialised correctly for the first\niteration. Until now, the IPA uses the minimum exposure and gain values\nand caches those in local variables.\n\nIn order to give the sensor limits to AGC, create a new structure in\nIPASessionConfiguration. Store the exposure in time (and not line\nduration) and the analogue gain after CameraSensorHelper conversion.\n\nSet the gain and exposure appropriately to the current values known to\nthe IPA and remove the setting of exposure and gain in IPAIPU3 as those\nare now fully controlled by IPU3Agc.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/agc.cpp | 8 ++++-\n src/ipa/ipu3/ipa_context.h | 9 +++++\n src/ipa/ipu3/ipu3.cpp | 64 +++++++++++++++++++++++++++++----\n 3 files changed, 73 insertions(+), 8 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\nindex 970ec424..828e822c 100644\n--- a/src/ipa/ipu3/algorithms/agc.cpp\n+++ b/src/ipa/ipu3/algorithms/agc.cpp\n@@ -60,7 +60,13 @@ int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n \n \tlineDuration_ = configInfo.sensorInfo.lineLength * 1.0s\n \t\t / configInfo.sensorInfo.pixelRate;\n-\tmaxExposureTime_ = kMaxExposure * lineDuration_;\n+\tmaxExposureTime_ = context.configuration.agc.maxShutterSpeed;\n+\n+\t/* Configure the default exposure and gain. */\n+\tcontext.frameContext.agc.gain =\n+\t\tcontext.configuration.agc.minAnalogueGain;\n+\tcontext.frameContext.agc.exposure =\n+\t\tcontext.configuration.agc.minShutterSpeed / lineDuration_;\n \n \treturn 0;\n }\ndiff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h\nindex 5bab684c..847c03fe 100644\n--- a/src/ipa/ipu3/ipa_context.h\n+++ b/src/ipa/ipu3/ipa_context.h\n@@ -10,6 +10,8 @@\n \n #include <linux/intel-ipu3.h>\n \n+#include <libcamera/base/utils.h>\n+\n #include <libcamera/geometry.h>\n \n namespace libcamera {\n@@ -22,6 +24,13 @@ struct IPASessionConfiguration {\n \t\tSize bdsOutputSize;\n \t\tuint32_t stride;\n \t} grid;\n+\n+\tstruct {\n+\t\tutils::Duration minShutterSpeed;\n+\t\tutils::Duration maxShutterSpeed;\n+\t\tdouble minAnalogueGain;\n+\t\tdouble maxAnalogueGain;\n+\t} agc;\n };\n \n struct IPAFrameContext {\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 388f1902..65d3fd2c 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -97,6 +97,23 @@\n * \\brief Number of cells on one line including the ImgU padding\n */\n \n+/**\n+ * \\struct IPASessionConfiguration::agc\n+ * \\brief AGC parameters configuration of the IPA\n+ *\n+ * \\var IPASessionConfiguration::agc::minShutterSpeed\n+ * \\brief Minimum shutter speed supported with the configured sensor\n+ *\n+ * \\var IPASessionConfiguration::grid::maxShutterSpeed\n+ * \\brief Maximum shutter speed supported with the configured sensor\n+ *\n+ * \\var IPASessionConfiguration::grid::minAnalogueGain\n+ * \\brief Minimum analogue gain supported with the configured sensor\n+ *\n+ * \\var IPASessionConfiguration::grid::maxAnalogueGain\n+ * \\brief Maximum analogue gain supported with the configured sensor\n+ */\n+\n /**\n * \\struct IPAFrameContext::agc\n * \\brief Context for the Automatic Gain Control algorithm\n@@ -158,6 +175,8 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(IPAIPU3)\n \n+using namespace std::literals::chrono_literals;\n+\n namespace ipa::ipu3 {\n \n class IPAIPU3 : public IPAIPU3Interface\n@@ -182,6 +201,8 @@ private:\n \tvoid updateControls(const IPACameraSensorInfo &sensorInfo,\n \t\t\t const ControlInfoMap &sensorControls,\n \t\t\t ControlInfoMap *ipaControls);\n+\tvoid updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n+\t\t\t\t\tconst ControlInfoMap &sensorControls);\n \tvoid processControls(unsigned int frame, const ControlList &controls);\n \tvoid fillParams(unsigned int frame, ipu3_uapi_params *params);\n \tvoid parseStatistics(unsigned int frame,\n@@ -216,6 +237,36 @@ private:\n \tstruct IPAContext context_;\n };\n \n+/*\n+ * Compute IPASessionConfiguration using the sensor information and the sensor\n+ * v4l2 controls.\n+ */\n+void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n+\t\t\t\t\t const ControlInfoMap &sensorControls)\n+{\n+\tconst ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n+\tint32_t minExposure = v4l2Exposure.min().get<int32_t>();\n+\tint32_t maxExposure = v4l2Exposure.max().get<int32_t>();\n+\n+\tutils::Duration lineDuration = sensorInfo.lineLength * 1.0s\n+\t\t\t\t / sensorInfo.pixelRate;\n+\n+\tconst ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;\n+\tint32_t minGain = v4l2Gain.min().get<int32_t>();\n+\tint32_t maxGain = v4l2Gain.max().get<int32_t>();\n+\n+\t/*\n+\t * When the AGC computes the new exposure values for a frame, it needs\n+\t * to know the limits for shutter speed and analogue gain.\n+\t * As it depends on the sensor, update it with the controls.\n+\t *\n+\t * \\todo take VBLANK into account for maximum shutter speed\n+\t */\n+\tcontext_.configuration.agc.minShutterSpeed = minExposure * lineDuration;\n+\tcontext_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration;\n+\tcontext_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n+\tcontext_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n+}\n \n /*\n * Compute camera controls using the sensor information and the sensor\n@@ -436,15 +487,18 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n \n \tcalculateBdsGrid(configInfo.bdsOutputSize);\n \n+\t/* Update the camera controls using the new sensor settings. */\n+\tupdateControls(sensorInfo_, ctrls_, ipaControls);\n+\n+\t/* Update the IPASessionConfiguration using the sensor settings. */\n+\tupdateSessionConfiguration(sensorInfo_, ctrls_);\n+\n \tfor (auto const &algo : algorithms_) {\n \t\tint ret = algo->configure(context_, configInfo);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\n \n-\t/* Update the camera controls using the new sensor settings. */\n-\tupdateControls(sensorInfo_, ctrls_, ipaControls);\n-\n \treturn 0;\n }\n \n@@ -543,10 +597,6 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n {\n \tControlList ctrls(controls::controls);\n \n-\t/* \\todo These fields should not be written by the IPAIPU3 layer */\n-\tcontext_.frameContext.agc.gain = camHelper_->gain(gain_);\n-\tcontext_.frameContext.agc.exposure = exposure_;\n-\n \tfor (auto const &algo : algorithms_)\n \t\talgo->process(context_, stats);\n \n", "prefixes": [ "libcamera-devel", "v3", "02/14" ] }