Patch Detail
Show a patch.
GET /api/patches/17380/?format=api
{ "id": 17380, "url": "https://patchwork.libcamera.org/api/patches/17380/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17380/", "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": "<20220919063743.2753465-1-paul.elder@ideasonboard.com>", "date": "2022-09-19T06:37:43", "name": "[libcamera-devel] ipa: rkisp1: Add support for manual gain and exposure", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "fa435095472bbfdf51c647f6660c0f2f11f73e62", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17380/mbox/", "series": [ { "id": 3491, "url": "https://patchwork.libcamera.org/api/series/3491/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3491", "date": "2022-09-19T06:37:43", "name": "[libcamera-devel] ipa: rkisp1: Add support for manual gain and exposure", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3491/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17380/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17380/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 B018FC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Sep 2022 06:38:03 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CFEFB6218F;\n\tMon, 19 Sep 2022 08:38:02 +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 88D4561F7F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Sep 2022 08:38:01 +0200 (CEST)", "from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BECC1576;\n\tMon, 19 Sep 2022 08:37:59 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1663569482;\n\tbh=QEPntbNVxZeIcZqVh46/F0FG1ma7qQs0PgS84+nsScY=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=oi/XD00NA4pe/UQD/7w1jwWdc5WBTOwzgl+A+Sb4vxmE3u0qYbUKGzYs5v3KUcC9u\n\t4y6COG6TIPupw7eeXrpZIYyGnqzudZSPsgMHvujbOYewkAgNCTA0gK4IaZ4NBk+nN5\n\tKCtdh+Ykd5X3nB10BHCduTmhA1HxUtd0x39bTzEWMPf1EIS3suMK+8cT/GcdrFJQNe\n\tvYzBDheR3/fopo5O2B3dYIIqmHozya68EjSqktNZ9K49fkwgBaiQ4+rfiBMOcSXVdG\n\tGcMY9zOJJuoanuJtTteUmClDYYRvNmHZEspAwNou7ThkRsM0rzVDlZ0RHgWzd2VpSF\n\t7C8EZeV+JvavA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1663569481;\n\tbh=QEPntbNVxZeIcZqVh46/F0FG1ma7qQs0PgS84+nsScY=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=T9+kpL9dvO9Hbd2PXG7ofc3cHA4zWs2MbheqoU2cj7GdEkQUhnn03AwRO/jz/L/6x\n\t2Kjk+g33SpSKGLvV2ixRecD2oVXNNw+1AV0Zn8GM10Bf3/7qTnWnDlAcd0Kb65WghB\n\t4Y7D/aoQIPA9GjzTOuFc1W8bedMp6n++typHTyBo=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"T9+kpL9d\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 19 Sep 2022 15:37:43 +0900", "Message-Id": "<20220919063743.2753465-1-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.30.2", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] ipa: rkisp1: Add support for manual gain\n\tand exposure", "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": "Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Paul Elder <paul.elder@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add support for manual gain and exposure in the rkisp1 IPA.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nThis patch depends on v4 of the series: \"ipa: Frame context queue, IPU3\n& RkISP consolidation, and RkISP1 improvements\"\n---\n src/ipa/rkisp1/algorithms/agc.cpp | 59 +++++++++++++++++++++++++++----\n src/ipa/rkisp1/algorithms/agc.h | 4 +++\n src/ipa/rkisp1/ipa_context.h | 13 +++++--\n src/ipa/rkisp1/rkisp1.cpp | 3 ++\n 4 files changed, 71 insertions(+), 8 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex bc764142..d26b35ed 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -14,6 +14,7 @@\n #include <libcamera/base/log.h>\n #include <libcamera/base/utils.h>\n \n+#include <libcamera/control_ids.h>\n #include <libcamera/ipa/core_ipa_interface.h>\n \n #include \"libipa/histogram.h\"\n@@ -73,8 +74,11 @@ Agc::Agc()\n int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n {\n \t/* Configure the default exposure and gain. */\n-\tcontext.activeState.agc.gain = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain);\n-\tcontext.activeState.agc.exposure = 10ms / context.configuration.sensor.lineDuration;\n+\tcontext.activeState.agc.automatic.gain = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain);\n+\tcontext.activeState.agc.automatic.exposure = 10ms / context.configuration.sensor.lineDuration;\n+\tcontext.activeState.agc.manual.gain = context.activeState.agc.automatic.gain;\n+\tcontext.activeState.agc.manual.exposure = context.activeState.agc.automatic.exposure;\n+\tcontext.activeState.agc.autoEnabled = true;\n \n \t/*\n \t * According to the RkISP1 documentation:\n@@ -221,8 +225,8 @@ void Agc::computeExposure(IPAContext &context, RkISP1FrameContext &frameContext,\n \t\t\t << stepGain;\n \n \t/* Update the estimated exposure and gain. */\n-\tactiveState.agc.exposure = shutterTime / configuration.sensor.lineDuration;\n-\tactiveState.agc.gain = stepGain;\n+\tactiveState.agc.automatic.exposure = shutterTime / configuration.sensor.lineDuration;\n+\tactiveState.agc.automatic.gain = stepGain;\n }\n \n /**\n@@ -331,8 +335,10 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n void Agc::prepare(IPAContext &context, const uint32_t frame,\n \t\t RkISP1FrameContext &frameContext, rkisp1_params_cfg *params)\n {\n-\tframeContext.agc.exposure = context.activeState.agc.exposure;\n-\tframeContext.agc.gain = context.activeState.agc.gain;\n+\tif (frameContext.agc.autoEnabled) {\n+\t\tframeContext.agc.exposure = context.activeState.agc.automatic.exposure;\n+\t\tframeContext.agc.gain = context.activeState.agc.automatic.gain;\n+\t}\n \n \tif (frame > 0)\n \t\treturn;\n@@ -365,6 +371,47 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,\n \tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_HST;\n }\n \n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::queueRequest\n+ */\n+void Agc::queueRequest(IPAContext &context,\n+\t\t [[maybe_unused]] const uint32_t frame,\n+\t\t RkISP1FrameContext &frameContext,\n+\t\t const ControlList &controls)\n+{\n+\tauto &agc = context.activeState.agc;\n+\n+\tconst auto &agcEnable = controls.get(controls::AeEnable);\n+\tif (agcEnable && *agcEnable != agc.autoEnabled) {\n+\t\tagc.autoEnabled = *agcEnable;\n+\n+\t\tLOG(RkISP1Agc, Debug)\n+\t\t\t<< (*agcEnable ? \"Enabling\" : \"Disabling\") << \" AGC\";\n+\t}\n+\n+\tconst auto &exposure = controls.get(controls::ExposureTime);\n+\tif (exposure && !agc.autoEnabled) {\n+\t\tagc.manual.exposure = *exposure;\n+\n+\t\tLOG(RkISP1Agc, Debug)\n+\t\t\t<< \"Set exposure to: \" << agc.manual.exposure;\n+\t}\n+\n+\tconst auto &gain = controls.get(controls::AnalogueGain);\n+\tif (gain && !agc.autoEnabled) {\n+\t\tagc.manual.gain = *gain;\n+\n+\t\tLOG(RkISP1Agc, Debug) << \"Set gain to: \" << agc.manual.gain;\n+\t}\n+\n+\tframeContext.agc.autoEnabled = agc.autoEnabled;\n+\n+\tif (!frameContext.agc.autoEnabled) {\n+\t\tframeContext.agc.exposure = agc.manual.exposure;\n+\t\tframeContext.agc.gain = agc.manual.gain;\n+\t}\n+}\n+\n REGISTER_IPA_ALGORITHM(Agc, \"Agc\")\n \n } /* namespace ipa::rkisp1::algorithms */\ndiff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h\nindex d6c6fb13..e624f101 100644\n--- a/src/ipa/rkisp1/algorithms/agc.h\n+++ b/src/ipa/rkisp1/algorithms/agc.h\n@@ -32,6 +32,10 @@ public:\n \tvoid process(IPAContext &context, const uint32_t frame,\n \t\t RkISP1FrameContext &frameContext,\n \t\t const rkisp1_stat_buffer *stats) override;\n+\tvoid queueRequest(IPAContext &context,\n+\t\t\t const uint32_t frame,\n+\t\t\t RkISP1FrameContext &frameContext,\n+\t\t\t const ControlList &controls) override;\n \n private:\n \tvoid computeExposure(IPAContext &Context, RkISP1FrameContext &frameContext,\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex d0bc9090..df72ec87 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -50,8 +50,16 @@ struct IPASessionConfiguration {\n \n struct IPAActiveState {\n \tstruct {\n-\t\tuint32_t exposure;\n-\t\tdouble gain;\n+\t\tstruct {\n+\t\t\tuint32_t exposure;\n+\t\t\tdouble gain;\n+\t\t} manual;\n+\t\tstruct {\n+\t\t\tuint32_t exposure;\n+\t\t\tdouble gain;\n+\t\t} automatic;\n+\n+\t\tbool autoEnabled;\n \t} agc;\n \n \tstruct {\n@@ -92,6 +100,7 @@ struct RkISP1FrameContext : public FrameContext {\n \tstruct {\n \t\tuint32_t exposure;\n \t\tdouble gain;\n+\t\tbool autoEnabled;\n \t} agc;\n \n \tstruct {\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 75370ac8..0092d0a1 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -92,8 +92,11 @@ private:\n namespace {\n \n /* List of controls handled by the RkISP1 IPA */\n+/* \\todo Report more accurate limits for exposure and gain */\n const ControlInfoMap::Map rkisp1Controls{\n \t{ &controls::AeEnable, ControlInfo(false, true) },\n+\t{ &controls::ExposureTime, ControlInfo(0, 66666) },\n+\t{ &controls::AnalogueGain, ControlInfo(1.0f, 16.0f) },\n \t{ &controls::AwbEnable, ControlInfo(false, true) },\n \t{ &controls::ColourGains, ControlInfo(0.0f, 3.996f, 1.0f) },\n \t{ &controls::Brightness, ControlInfo(-1.0f, 0.993f) },\n", "prefixes": [ "libcamera-devel" ] }