Patch Detail
Show a patch.
GET /api/1.1/patches/22342/?format=api
{ "id": 22342, "url": "https://patchwork.libcamera.org/api/1.1/patches/22342/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22342/", "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": "<20241216094933.198027-3-paul.elder@ideasonboard.com>", "date": "2024-12-16T09:49:33", "name": "[v2,2/2] ipa: rkisp1: Add Lux algorithm module", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "af405f9b2511036d2df3874f3e70db637b98e9b7", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22342/mbox/", "series": [ { "id": 4893, "url": "https://patchwork.libcamera.org/api/1.1/series/4893/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4893", "date": "2024-12-16T09:49:31", "name": "ipa: rkisp1: Add lux estimation", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4893/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22342/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22342/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 3B3B6C32F9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 16 Dec 2024 09:49:52 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D40C767F4B;\n\tMon, 16 Dec 2024 10:49:51 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EB1F567F37\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Dec 2024 10:49:47 +0100 (CET)", "from neptunite.flets-east.jp (unknown\n\t[IPv6:2404:7a81:160:2100:c11a:e451:861f:3d32])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 25B0713C;\n\tMon, 16 Dec 2024 10:49:09 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"b66yOzdm\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1734342551;\n\tbh=3X1l0S7FU7rnri+PjbJnCb/fhBaoVVV92NksVAM+Vag=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=b66yOzdm/x9LtN0mM/eD6Ozv7G7p/zNhYN7uGFVf8MAZTOXXXVjsMETcm2CSl1heD\n\t7xKCBJLPJNVc5rYk27OZYiT6DNL3d+mOXc6+s9IbTHyuqHyiC2meo/k2xH2a7A301G\n\teCj7k6XeZnXBly78+sBDk+Ls1Eb0PMGkFETVP374=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org, laurent.pinchart@ideasonboard.com, \n\tstefan.klug@ideasonboard.com", "Cc": "Paul Elder <paul.elder@ideasonboard.com>", "Subject": "[PATCH v2 2/2] ipa: rkisp1: Add Lux algorithm module", "Date": "Mon, 16 Dec 2024 18:49:33 +0900", "Message-Id": "<20241216094933.198027-3-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.39.2", "In-Reply-To": "<20241216094933.198027-1-paul.elder@ideasonboard.com>", "References": "<20241216094933.198027-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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": "Add a lux algorithm module to rkisp1 IPA for estimating the lux level of\nan image. This is reported in metadata, as well as saved in the frame\ncontext so that other algorithms (mainly AGC) can use its value. It does\nnot set any controls.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v2:\n- fix bitrot\n- fixes corresponding to changes in the previous patch\n---\n src/ipa/rkisp1/algorithms/lux.cpp | 76 +++++++++++++++++++++++++++\n src/ipa/rkisp1/algorithms/lux.h | 39 ++++++++++++++\n src/ipa/rkisp1/algorithms/meson.build | 1 +\n src/ipa/rkisp1/ipa_context.h | 1 +\n 4 files changed, 117 insertions(+)\n create mode 100644 src/ipa/rkisp1/algorithms/lux.cpp\n create mode 100644 src/ipa/rkisp1/algorithms/lux.h", "diff": "diff --git a/src/ipa/rkisp1/algorithms/lux.cpp b/src/ipa/rkisp1/algorithms/lux.cpp\nnew file mode 100644\nindex 000000000000..333167b15f64\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/lux.cpp\n@@ -0,0 +1,76 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Ideas On Board\n+ *\n+ * lux.cpp - RkISP1 Lux control\n+ */\n+\n+#include \"lux.h\"\n+\n+#include <algorithm>\n+#include <cmath>\n+\n+#include <libcamera/base/log.h>\n+\n+#include <libcamera/control_ids.h>\n+\n+#include \"libcamera/internal/yaml_parser.h\"\n+\n+#include \"libipa/histogram.h\"\n+#include \"libipa/lux.h\"\n+\n+/**\n+ * \\file lux.h\n+ */\n+\n+namespace libcamera {\n+\n+namespace ipa::rkisp1::algorithms {\n+\n+/**\n+ * \\class Lux\n+ * \\brief RkISP1 Lux control\n+ *\n+ * The Lux algorithm is responsible for estimating the lux level of the image.\n+ * It doesn't take or generate any controls, but it provides a lux level for\n+ * other algorithms (such as AGC) to use.\n+ */\n+\n+LOG_DEFINE_CATEGORY(RkISP1Lux)\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::init\n+ */\n+int Lux::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)\n+{\n+\tlux_.setBinSize(65535);\n+\treturn lux_.readYaml(tuningData);\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::process\n+ */\n+void Lux::process(IPAContext &context,\n+\t\t [[maybe_unused]] const uint32_t frame,\n+\t\t IPAFrameContext &frameContext,\n+\t\t const rkisp1_stat_buffer *stats,\n+\t\t ControlList &metadata)\n+{\n+\tutils::Duration exposureTime = context.configuration.sensor.lineDuration\n+\t\t\t\t * frameContext.sensor.exposure;\n+\tdouble gain = frameContext.sensor.gain;\n+\n+\tconst rkisp1_cif_isp_stat *params = &stats->params;\n+\tHistogram yHist({ params->hist.hist_bins, context.hw->numHistogramBins },\n+\t\t\t[](uint32_t x) { return x >> 4; });\n+\n+\tdouble lux = lux_.estimateLux(exposureTime, gain, 1.0, yHist);\n+\tframeContext.agc.lux = lux;\n+\tmetadata.set(controls::Lux, lux);\n+}\n+\n+REGISTER_IPA_ALGORITHM(Lux, \"Lux\")\n+\n+} /* namespace ipa::rkisp1::algorithms */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/rkisp1/algorithms/lux.h b/src/ipa/rkisp1/algorithms/lux.h\nnew file mode 100644\nindex 000000000000..ea98c29120eb\n--- /dev/null\n+++ b/src/ipa/rkisp1/algorithms/lux.h\n@@ -0,0 +1,39 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Ideas On Board\n+ *\n+ * lux.h - RkISP1 Lux control\n+ */\n+\n+#pragma once\n+\n+#include <sys/types.h>\n+\n+#include \"libcamera/internal/yaml_parser.h\"\n+\n+#include \"libipa/lux.h\"\n+\n+#include \"algorithm.h\"\n+\n+namespace libcamera {\n+\n+namespace ipa::rkisp1::algorithms {\n+\n+class Lux : public Algorithm\n+{\n+public:\n+\tLux() = default;\n+\t~Lux() = default;\n+\n+\tint init(IPAContext &context, const YamlObject &tuningData) override;\n+\tvoid process(IPAContext &context, const uint32_t frame,\n+\t\t IPAFrameContext &frameContext,\n+\t\t const rkisp1_stat_buffer *stats,\n+\t\t ControlList &metadata) override;\n+\n+private:\n+\tipa::Lux lux_;\n+};\n+\n+} /* namespace ipa::rkisp1::algorithms */\n+} /* namespace libcamera */\ndiff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build\nindex 1734a6675f78..c66b0b70b82f 100644\n--- a/src/ipa/rkisp1/algorithms/meson.build\n+++ b/src/ipa/rkisp1/algorithms/meson.build\n@@ -12,4 +12,5 @@ rkisp1_ipa_algorithms = files([\n 'goc.cpp',\n 'gsl.cpp',\n 'lsc.cpp',\n+ 'lux.cpp',\n ])\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex deb8c196f1b8..e7bdc51bfa4c 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -130,6 +130,7 @@ struct IPAFrameContext : public FrameContext {\n \t\tcontrols::AeMeteringModeEnum meteringMode;\n \t\tutils::Duration maxFrameDuration;\n \t\tbool updateMetering;\n+\t\tdouble lux;\n \t} agc;\n \n \tstruct {\n", "prefixes": [ "v2", "2/2" ] }