Patch Detail
Show a patch.
GET /api/1.1/patches/17171/?format=api
{ "id": 17171, "url": "https://patchwork.libcamera.org/api/1.1/patches/17171/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17171/", "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": "<20220818094410.1671-17-jacopo@jmondi.org>", "date": "2022-08-18T09:44:09", "name": "[libcamera-devel,v3,16/17] ipa: ipu3: Store configuration data in context", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "a00b6caa52ac8585be3a4edb11be7020c9f82e12", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17171/mbox/", "series": [ { "id": 3426, "url": "https://patchwork.libcamera.org/api/1.1/series/3426/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3426", "date": "2022-08-18T09:43:53", "name": "libcamera: Align IPU3 and RKISP1 interfaces", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3426/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17171/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17171/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 D1ACAC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Aug 2022 09:44:45 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 83F6361FA5;\n\tThu, 18 Aug 2022 11:44:45 +0200 (CEST)", "from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A1ACA61FD3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Aug 2022 11:44:39 +0200 (CEST)", "(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id D3313FF802;\n\tThu, 18 Aug 2022 09:44:38 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660815885;\n\tbh=pbJvaxzfAzsk5G/K0+kuggQbpVvmu2trmNSewJgtmkE=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=22lzGsWEGTuKoVgH2XxbyrblOtZRH5vkjzrj5VsIDzZIMggySrsQxWr/q2QGUto1j\n\tZ8vwTgOIha/bTeIu/siC+wJiRL11STSfs6RZKkevGVbCc3a6mKTeMQ1CTeKUv1Zzcm\n\tAyATE8dxNQob9jLqNnA4D0Vynon4EZXMnRxvZJpKOoOgkIFr3K3YScB6hDjbMD006l\n\t4JRUfASunssDP9gq2Ak2F0E7wI5EVCKIjVG4/4DoFdkNpxij/TgZBh9q7AhCTM05bU\n\tmtYUHq3vGxb712hwpxXwrJGWtEoQYyszn/V/JZdrkXZyBPeovev19Mh4tfw0DhOcvK\n\tIS5GrTg9r0oHg==", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 18 Aug 2022 11:44:09 +0200", "Message-Id": "<20220818094410.1671-17-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.37.2", "In-Reply-To": "<20220818094410.1671-1-jacopo@jmondi.org>", "References": "<20220818094410.1671-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 16/17] ipa: ipu3: Store configuration\n\tdata in context", "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>", "From": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Jacopo Mondi <jacopo@jmondi.org>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The IPU3 IPA module stores per-configuration session data, such as the\nsensor and lens controls and the sensor information, in class member\nvariables.\n\nAs the IPAContext structure has exactly a place for session-specific\nconfiguration data, move those information in the context_ and remove\nthem from the class.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/ipa/ipu3/ipa_context.cpp | 15 ++++++++++\n src/ipa/ipu3/ipa_context.h | 6 ++++\n src/ipa/ipu3/ipu3.cpp | 54 ++++++++++++++++--------------------\n 3 files changed, 45 insertions(+), 30 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp\nindex 536d76ecd63b..3c6f470e7f25 100644\n--- a/src/ipa/ipu3/ipa_context.cpp\n+++ b/src/ipa/ipu3/ipa_context.cpp\n@@ -114,6 +114,21 @@ namespace libcamera::ipa::ipu3 {\n * \\brief The default vblank value of the sensor\n */\n \n+/**\n+ * \\var IPASessionConfiguration::sensorCtrls\n+ * \\brief The list of V4L2 sensor controls limits\n+ */\n+\n+/**\n+ * \\var IPASessionConfiguration::lensCtrls\n+ * \\brief The list of V4L2 lens controls limits\n+ */\n+\n+/**\n+ * \\var IPASessionConfiguration::sensorInfo\n+ * \\brief The sensor configuration for the streaming session\n+ */\n+\n /**\n * \\var IPAActiveState::agc\n * \\brief Context for the Automatic Gain Control algorithm\ndiff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h\nindex c4aa4c3f4f6a..2629d0db9f9a 100644\n--- a/src/ipa/ipu3/ipa_context.h\n+++ b/src/ipa/ipu3/ipa_context.h\n@@ -15,6 +15,8 @@\n #include <libcamera/controls.h>\n #include <libcamera/geometry.h>\n \n+#include <libcamera/ipa/core_ipa_interface.h>\n+\n #include <libipa/fc_queue.h>\n \n namespace libcamera {\n@@ -43,6 +45,10 @@ struct IPASessionConfiguration {\n \t\tint32_t defVBlank;\n \t\tutils::Duration lineDuration;\n \t} sensor;\n+\n+\tControlInfoMap sensorCtrls;\n+\tControlInfoMap lensCtrls;\n+\tIPACameraSensorInfo sensorInfo;\n };\n \n struct IPAActiveState {\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex dd9d21e4df52..6d40f3d0cd9e 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -172,11 +172,6 @@ private:\n \n \tstd::map<unsigned int, MappedFrameBuffer> buffers_;\n \n-\tControlInfoMap sensorCtrls_;\n-\tControlInfoMap lensCtrls_;\n-\n-\tIPACameraSensorInfo sensorInfo_;\n-\n \t/* Interface to the Camera Helper */\n \tstd::unique_ptr<CameraSensorHelper> camHelper_;\n \n@@ -209,7 +204,7 @@ int IPAIPU3::init(const IPASettings &settings,\n \t\treturn -ENODEV;\n \t}\n \n-\t/* Clean context */\n+\t/* Clean context. */\n \tcontext_.configuration = {};\n \n \t/* Load the tuning data file. */\n@@ -379,7 +374,6 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n \t\t\t ControlInfoMap *ipaControls)\n {\n \tControlInfoMap::Map controls{};\n-\tdouble lineDuration = context_.configuration.sensor.lineDuration.get<std::micro>();\n \n \t/*\n \t * Compute exposure time limits by using line length and pixel rate\n@@ -388,6 +382,7 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n \t * microseconds.\n \t */\n \tconst ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n+\tdouble lineDuration = sensorInfo.lineLength / sensorInfo.pixelRate;\n \tint32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n \tint32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n \tint32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n@@ -431,9 +426,22 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n */\n void IPAIPU3::updateSessionConfiguration(const IPAConfigInfo &configInfo)\n {\n-\tconst IPACameraSensorInfo &sensorInfo = configInfo.sensorInfo;\n-\tconst ControlInfoMap &sensorControls = configInfo.sensorControls;\n+\t/* Clear and intialize the IPA context before the streaming session. */\n+\tcontext_.frameContexts.clear();\n+\tcontext_ = {};\n+\n+\tcontext_.configuration.sensorCtrls = configInfo.sensorControls;\n+\tcontext_.configuration.lensCtrls = configInfo.lensControls;\n+\tcontext_.configuration.sensorInfo = configInfo.sensorInfo;\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+\tconst ControlInfoMap &sensorControls = configInfo.sensorControls;\n \tconst ControlInfo vBlank = sensorControls.find(V4L2_CID_VBLANK)->second;\n \tcontext_.configuration.sensor.defVBlank = vBlank.def().get<int32_t>();\n \n@@ -445,19 +453,8 @@ void IPAIPU3::updateSessionConfiguration(const IPAConfigInfo &configInfo)\n \tint32_t minGain = v4l2Gain.min().get<int32_t>();\n \tint32_t maxGain = v4l2Gain.max().get<int32_t>();\n \n-\t/* Clear the IPA context before the streaming session. */\n-\tcontext_.frameContexts.clear();\n-\tcontext_ = {};\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.sensor.lineDuration = sensorInfo.lineLength * 1.0s\n-\t\t\t\t\t\t / sensorInfo.pixelRate;\n+\tcontext_.configuration.sensor.lineDuration = configInfo.sensorInfo.lineLength * 1.0s\n+\t\t\t\t\t\t / configInfo.sensorInfo.pixelRate;\n \tcontext_.configuration.agc.minShutterSpeed = minExposure * context_.configuration.sensor.lineDuration;\n \tcontext_.configuration.agc.maxShutterSpeed = maxExposure * context_.configuration.sensor.lineDuration;\n \tcontext_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n@@ -487,14 +484,10 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n \t\treturn -EINVAL;\n \t}\n \n-\tsensorCtrls_ = configInfo.sensorControls;\n-\tsensorInfo_ = configInfo.sensorInfo;\n-\tlensCtrls_ = configInfo.lensControls;\n-\n \tcalculateBdsGrid(configInfo.bdsOutputSize);\n \n \t/* Update the camera controls using the new sensor settings. */\n-\tupdateControls(sensorInfo_, sensorCtrls_, ipaControls);\n+\tupdateControls(configInfo.sensorInfo, configInfo.sensorControls, ipaControls);\n \n \t/* Update the IPASessionConfiguration using the sensor settings. */\n \tupdateSessionConfiguration(configInfo);\n@@ -618,7 +611,8 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,\n \tsetControls(frame);\n \n \t/* \\todo Use VBlank value calculated from each frame exposure. */\n-\tint64_t frameDuration = (vBlank + sensorInfo_.outputSize.height) * lineDuration;\n+\tconst IPACameraSensorInfo &sensorInfo = context_.configuration.sensorInfo;\n+\tint64_t frameDuration = (vBlank + sensorInfo.outputSize.height) * lineDuration;\n \tctrls.set(controls::FrameDuration, frameDuration);\n \n \tctrls.set(controls::AnalogueGain, frameContext.sensor.gain);\n@@ -667,11 +661,11 @@ void IPAIPU3::setControls(unsigned int frame)\n \tint32_t exposure = context_.activeState.agc.exposure;\n \tint32_t gain = camHelper_->gainCode(context_.activeState.agc.gain);\n \n-\tControlList ctrls(sensorCtrls_);\n+\tControlList ctrls(context_.configuration.sensorCtrls);\n \tctrls.set(V4L2_CID_EXPOSURE, exposure);\n \tctrls.set(V4L2_CID_ANALOGUE_GAIN, gain);\n \n-\tControlList lensCtrls(lensCtrls_);\n+\tControlList lensCtrls(context_.configuration.lensCtrls);\n \tlensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE,\n \t\t static_cast<int32_t>(context_.activeState.af.focus));\n \n", "prefixes": [ "libcamera-devel", "v3", "16/17" ] }