{"id":19266,"url":"https://patchwork.libcamera.org/api/1.1/patches/19266/?format=json","web_url":"https://patchwork.libcamera.org/patch/19266/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20231204001013.404720-5-andrey.konovalov@linaro.org>","date":"2023-12-04T00:10:10","name":"[libcamera-devel,RFC,4/7] libcamera: ipa: add Soft IPA","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"6216e9408c2713968de98d53a7230d4d74a41d6c","submitter":{"id":25,"url":"https://patchwork.libcamera.org/api/1.1/people/25/?format=json","name":"Andrey Konovalov","email":"andrey.konovalov@linaro.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19266/mbox/","series":[{"id":4096,"url":"https://patchwork.libcamera.org/api/1.1/series/4096/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4096","date":"2023-12-04T00:10:06","name":"libcamera: introduce Software ISP and Software IPA","version":1,"mbox":"https://patchwork.libcamera.org/series/4096/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19266/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19266/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 1ED62C322E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  4 Dec 2023 00:10:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BDC14629DA;\n\tMon,  4 Dec 2023 01:10:48 +0100 (CET)","from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com\n\t[IPv6:2a00:1450:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C51B7629CE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  4 Dec 2023 01:10:46 +0100 (CET)","by mail-wr1-x42a.google.com with SMTP id\n\tffacd0b85a97d-3332ad5b3e3so2595480f8f.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 03 Dec 2023 16:10:46 -0800 (PST)","from Lat-5310.. ([87.116.165.212]) by smtp.gmail.com with ESMTPSA\n\tid\n\tu29-20020adfa19d000000b003332db7d91dsm8835997wru.39.2023.12.03.16.10.45\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 03 Dec 2023 16:10:46 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1701648648;\n\tbh=TH/uA5CaxgtfBx74YKHme0Y3mbcInfDdz+cHB5vzdpI=;\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:Cc:\n\tFrom;\n\tb=JObBKND85HLbsUyVOQLmb9IFijvOmpzfxARHuN0euHUDIXhZBVXZQZ9ltr+FVr920\n\t0+D79OWb/w7NEQSqlJWQBcB6YOq1Gdk2zzhAOyTOqarQRIPJVnHaYR4jKkEVF7cN8J\n\tjlQUj2AKG7Z5CwpSzvR/ZOGkx2YduVQKEbC0t69ZiwtqSv9ie9QT8G03aoDEaeFX8p\n\toCdGzp1WMPZx0wy1zFByCJLmkeAEuCa2ROrSAxGO/ZwddfbYqbmjlmxAYuW3ccSHPN\n\th0n8wFP63id9klejMYQh0MzXi9g9M3ADDZyqUexIttVw0S8YFva6PZUZyxSNNmZ/So\n\tssVHBtQOJ/tQg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1701648646; x=1702253446;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=I05whO6yD/81OplpogdCagQbY76H+d64aUOxjzpYx3I=;\n\tb=VtyaEUw41yJnGnWBKKOn52AB46pUVpsL053y+XtSh2aiyIc+YfJ3XOnTXnjkrK7sLA\n\t/wzapK22w5KMbecK5OTzBC/jtyP6os37VCCII7N2hdpc2mh1JBMVmZwim7ncK5Dj992X\n\tPc21/fHoy+qkjvOUTDNxf7ojwrtLpefKNmzytO2u4o2wfc7oKDucAYd8uV+FGz4rm9b3\n\te2yrUaP6Xd9VtCzDiMgw49x80/zqoialNVBEeEtsnFQ6uBlBMLQlhAoSyKfxboISCERp\n\tv85rNp1l1UsFcTPmRz83Et29GLntbX7zHmy4rU77snljmMpPaQz/SHbP/FcnvL+UXMEX\n\tiBUg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=linaro.org\n\theader.i=@linaro.org header.b=\"VtyaEUw4\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1701648646; x=1702253446;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=I05whO6yD/81OplpogdCagQbY76H+d64aUOxjzpYx3I=;\n\tb=CweaKPGj4+8vD3DcV+OP5iRlwVzdbtRBbqfmJRvpN6hdDzFXejRO1Fa1oee2rOuBJT\n\tRyzRSlO15rimmsh1xjQ3YgK35YzvAKeU56liktD/PXy4Zj6vwfjvdWaM4myLBauebpXC\n\tqWix1JU41+fzqoKpVpr6VneNdupLgG+2RCN7WwJ2u7RKCNGoFea0ltFeNzH4D/+SzC7c\n\t9Z9yinyPqYx35ioYELbdhQ4aw51LWJKaQDFAevyTOq06Xi4BDPvV0jWbauWreGt1uUsZ\n\t04A640y76iFKem+u6t1M656WbFsp34/vKg7jeMqMkuIre4La9uxh5ueQ6LCqTCdjKuM0\n\t8yFw==","X-Gm-Message-State":"AOJu0Ywyw7kg16TE5kWOZvEJ6dwuenN/gadMa/FKFOhy2DRn7sgwz2Qy\n\t/PRg1FEzJ1QXG4rDF48HotMqqNA9lsT3/TdbaRo=","X-Google-Smtp-Source":"AGHT+IFKSb1MpVQS82/j3nc49GV7icqpt4l8esiYXmiIliACWxjhOX7YKKDxg+fU855wM+DMeM13iQ==","X-Received":"by 2002:a05:6000:c43:b0:333:4f67:774a with SMTP id\n\tdo3-20020a0560000c4300b003334f67774amr21377wrb.65.1701648646548; \n\tSun, 03 Dec 2023 16:10:46 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","Date":"Mon,  4 Dec 2023 03:10:10 +0300","Message-Id":"<20231204001013.404720-5-andrey.konovalov@linaro.org>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20231204001013.404720-1-andrey.konovalov@linaro.org>","References":"<20231204001013.404720-1-andrey.konovalov@linaro.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH 4/7] libcamera: ipa: add Soft IPA","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":"Andrey Konovalov via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Andrey Konovalov <andrey.konovalov@linaro.org>","Cc":"mripard@redhat.com, g.martti@gmail.com, t.langendam@gmail.com,\n\tsrinivas.kandagatla@linaro.org, bryan.odonoghue@linaro.org,\n\tadmin@dennisbonke.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n---\n include/libcamera/ipa/meson.build      |   1 +\n include/libcamera/ipa/soft.mojom       |  27 ++++\n meson_options.txt                      |   3 +-\n src/ipa/simple/common/meson.build      |  17 ++\n src/ipa/simple/common/soft_base.cpp    |  66 ++++++++\n src/ipa/simple/common/soft_base.h      |  47 ++++++\n src/ipa/simple/linaro/data/meson.build |   8 +\n src/ipa/simple/linaro/data/soft.conf   |   3 +\n src/ipa/simple/linaro/meson.build      |  26 +++\n src/ipa/simple/linaro/soft_linaro.cpp  | 210 +++++++++++++++++++++++++\n src/ipa/simple/meson.build             |  12 ++\n 11 files changed, 419 insertions(+), 1 deletion(-)\n create mode 100644 include/libcamera/ipa/soft.mojom\n create mode 100644 src/ipa/simple/common/meson.build\n create mode 100644 src/ipa/simple/common/soft_base.cpp\n create mode 100644 src/ipa/simple/common/soft_base.h\n create mode 100644 src/ipa/simple/linaro/data/meson.build\n create mode 100644 src/ipa/simple/linaro/data/soft.conf\n create mode 100644 src/ipa/simple/linaro/meson.build\n create mode 100644 src/ipa/simple/linaro/soft_linaro.cpp\n create mode 100644 src/ipa/simple/meson.build","diff":"diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build\nindex f3b4881c..aaee5cbf 100644\n--- a/include/libcamera/ipa/meson.build\n+++ b/include/libcamera/ipa/meson.build\n@@ -65,6 +65,7 @@ pipeline_ipa_mojom_mapping = {\n     'ipu3': 'ipu3.mojom',\n     'rkisp1': 'rkisp1.mojom',\n     'rpi/vc4': 'raspberrypi.mojom',\n+    'simple/linaro': 'soft.mojom',\n     'vimc': 'vimc.mojom',\n }\n \ndiff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom\nnew file mode 100644\nindex 00000000..c3449188\n--- /dev/null\n+++ b/include/libcamera/ipa/soft.mojom\n@@ -0,0 +1,27 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+\n+/*\n+ * \\todo Document the interface and remove the related EXCLUDE_PATTERNS entry.\n+ * \\todo Add a way to tell SoftIPA the list of params SoftISP accepts?\n+ */\n+\n+module ipa.soft;\n+\n+import \"include/libcamera/ipa/core.mojom\";\n+\n+interface IPASoftInterface {\n+\tinit(libcamera.IPASettings settings,\n+\t     libcamera.SharedFD fdStats,\n+\t     libcamera.ControlInfoMap sensorCtrlInfoMap)\n+\t\t=> (int32 ret);\n+\tstart() => (int32 ret);\n+\tstop();\n+\tconfigure(libcamera.ControlInfoMap sensorCtrlInfoMap)\n+\t\t=> (int32 ret);\n+\n+\t[async] processStats(libcamera.ControlList sensorControls);\n+};\n+\n+interface IPASoftEventInterface {\n+\tsetSensorControls(libcamera.ControlList sensorControls);\n+};\ndiff --git a/meson_options.txt b/meson_options.txt\nindex fad928af..2fb51ff4 100644\n--- a/meson_options.txt\n+++ b/meson_options.txt\n@@ -27,7 +27,7 @@ option('gstreamer',\n \n option('ipas',\n         type : 'array',\n-        choices : ['ipu3', 'rkisp1', 'rpi/vc4', 'vimc'],\n+        choices : ['ipu3', 'rkisp1', 'rpi/vc4', 'simple/linaro', 'vimc'],\n         description : 'Select which IPA modules to build')\n \n option('lc-compliance',\n@@ -46,6 +46,7 @@ option('pipelines',\n             'rkisp1',\n             'rpi/vc4',\n             'simple',\n+            'simple/linaro',\n             'uvcvideo',\n             'vimc'\n         ],\ndiff --git a/src/ipa/simple/common/meson.build b/src/ipa/simple/common/meson.build\nnew file mode 100644\nindex 00000000..023e617b\n--- /dev/null\n+++ b/src/ipa/simple/common/meson.build\n@@ -0,0 +1,17 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+soft_ipa_common_sources = files([\n+    'soft_base.cpp',\n+])\n+\n+soft_ipa_common_includes = [\n+    include_directories('..'),\n+]\n+\n+soft_ipa_common_deps = [\n+    libcamera_private,\n+]\n+\n+soft_ipa_common_lib = static_library('soft_ipa_common', soft_ipa_common_sources,\n+                                     include_directories : soft_ipa_common_includes,\n+                                     dependencies : soft_ipa_common_deps)\ndiff --git a/src/ipa/simple/common/soft_base.cpp b/src/ipa/simple/common/soft_base.cpp\nnew file mode 100644\nindex 00000000..7bd9b8de\n--- /dev/null\n+++ b/src/ipa/simple/common/soft_base.cpp\n@@ -0,0 +1,66 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Linaro Ltd\n+ *\n+ * soft-base.cpp - Software IPA base class\n+ */\n+\n+#include \"soft_base.h\"\n+\n+#include <sys/mman.h>\n+\n+#include <libcamera/base/file.h>\n+#include <libcamera/base/log.h>\n+\n+#include <libcamera/control_ids.h>\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(IPASoft)\n+\n+namespace ipa::soft {\n+\n+IPASoftBase::IPASoftBase()\n+{\n+}\n+\n+IPASoftBase::~IPASoftBase()\n+{\n+}\n+\n+int IPASoftBase::init([[maybe_unused]] const IPASettings &settings,\n+\t\t      const SharedFD &fdStats,\n+\t\t      const ControlInfoMap &sensorInfoMap)\n+{\n+\tfdStats_ = std::move(fdStats);\n+\tif (!fdStats_.isValid()) {\n+\t\tLOG(IPASoft, Error) << \"Invalid Statistics handle\";\n+\t\treturn -ENODEV;\n+\t}\n+\n+\treturn platformInit(sensorInfoMap);\n+}\n+\n+int IPASoftBase::configure(const ControlInfoMap &sensorInfoMap)\n+{\n+\treturn platformConfigure(sensorInfoMap);\n+}\n+\n+int IPASoftBase::start()\n+{\n+\treturn platformStart();\n+}\n+\n+void IPASoftBase::stop()\n+{\n+\treturn platformStop();\n+}\n+\n+void IPASoftBase::processStats(const ControlList &sensorControls)\n+{\n+\treturn platformProcessStats(sensorControls);\n+}\n+\n+} /* namespace ipa::soft */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/simple/common/soft_base.h b/src/ipa/simple/common/soft_base.h\nnew file mode 100644\nindex 00000000..bff53713\n--- /dev/null\n+++ b/src/ipa/simple/common/soft_base.h\n@@ -0,0 +1,47 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Linaro Ltd\n+ *\n+ * soft-base.h - Software IPA base class\n+ */\n+#pragma once\n+\n+#include <libcamera/base/shared_fd.h>\n+#include <libcamera/controls.h>\n+\n+#include <libcamera/ipa/soft_ipa_interface.h>\n+\n+namespace libcamera {\n+\n+namespace ipa::soft {\n+\n+class IPASoftBase : public ipa::soft::IPASoftInterface\n+{\n+public:\n+\tIPASoftBase();\n+\t~IPASoftBase();\n+\n+\tint init(const IPASettings &settings,\n+\t\t const SharedFD &fdStats,\n+\t\t const ControlInfoMap &sensorInfoMap) override;\n+\tint configure(const ControlInfoMap &sensorInfoMap) override;\n+\n+\tint start() override;\n+\tvoid stop() override;\n+\n+\tvoid processStats(const ControlList &sensorControls) override;\n+\n+protected:\n+\tSharedFD fdStats_;\n+\n+private:\n+\tvirtual int platformInit(const ControlInfoMap &sensorInfoMap) = 0;\n+\tvirtual int platformConfigure(const ControlInfoMap &sensorInfoMap) = 0;\n+\tvirtual int platformStart() = 0;\n+\tvirtual void platformStop() = 0;\n+\tvirtual void platformProcessStats(const ControlList &sensorControls) = 0;\n+};\n+\n+} /* namespace ipa::soft */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/simple/linaro/data/meson.build b/src/ipa/simple/linaro/data/meson.build\nnew file mode 100644\nindex 00000000..f3464375\n--- /dev/null\n+++ b/src/ipa/simple/linaro/data/meson.build\n@@ -0,0 +1,8 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+conf_files = files([\n+    'soft.conf',\n+])\n+\n+install_data(conf_files,\n+             install_dir : ipa_data_dir / 'soft')\ndiff --git a/src/ipa/simple/linaro/data/soft.conf b/src/ipa/simple/linaro/data/soft.conf\nnew file mode 100644\nindex 00000000..0c70e7c0\n--- /dev/null\n+++ b/src/ipa/simple/linaro/data/soft.conf\n@@ -0,0 +1,3 @@\n+# SPDX-License-Identifier: LGPL-2.1-or-later\n+#\n+# Dummy configuration file for the soft IPA.\ndiff --git a/src/ipa/simple/linaro/meson.build b/src/ipa/simple/linaro/meson.build\nnew file mode 100644\nindex 00000000..97bf5d6f\n--- /dev/null\n+++ b/src/ipa/simple/linaro/meson.build\n@@ -0,0 +1,26 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+ipa_name = 'ipa_soft_linaro'\n+\n+mod = shared_module(ipa_name,\n+                    ['soft_linaro.cpp', libcamera_generated_ipa_headers],\n+                    name_prefix : '',\n+                    include_directories : [ipa_includes, libipa_includes, '..'],\n+                    dependencies : libcamera_private,\n+                    link_with : libipa,\n+                    link_whole : soft_ipa_common_lib,\n+                    install : true,\n+                    install_dir : ipa_install_dir)\n+\n+if ipa_sign_module\n+    custom_target(ipa_name + '.so.sign',\n+                  input : mod,\n+                  output : ipa_name + '.so.sign',\n+                  command : [ipa_sign, ipa_priv_key, '@INPUT@', '@OUTPUT@'],\n+                  install : false,\n+                  build_by_default : true)\n+endif\n+\n+subdir('data')\n+\n+ipa_names += ipa_name\ndiff --git a/src/ipa/simple/linaro/soft_linaro.cpp b/src/ipa/simple/linaro/soft_linaro.cpp\nnew file mode 100644\nindex 00000000..0b2e83bf\n--- /dev/null\n+++ b/src/ipa/simple/linaro/soft_linaro.cpp\n@@ -0,0 +1,210 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Linaro Ltd\n+ *\n+ * soft.cpp - Software Image Processing Algorithm module\n+ */\n+\n+#include <sys/mman.h>\n+\n+#include <libcamera/base/file.h>\n+#include <libcamera/base/log.h>\n+\n+#include <libcamera/control_ids.h>\n+\n+#include <libcamera/ipa/ipa_interface.h>\n+#include <libcamera/ipa/ipa_module_info.h>\n+\n+#include \"libcamera/internal/camera_sensor.h\"\n+#include \"libcamera/internal/software_isp/statistics-linaro.h\"\n+\n+#include \"common/soft_base.h\"\n+\n+namespace libcamera {\n+\n+LOG_DECLARE_CATEGORY(IPASoft)\n+\n+namespace ipa::soft {\n+\n+class IPASoftLinaro final : public IPASoftBase\n+{\n+public:\n+\tIPASoftLinaro()\n+\t\t: IPASoftBase(), ignore_updates_(0)\n+\t{\n+\t}\n+\n+\t~IPASoftLinaro()\n+\t{\n+\t\tif (stats_)\n+\t\t\tmunmap(stats_, sizeof(SwIspStats));\n+\t}\n+\n+\tint platformInit(const ControlInfoMap &sensorInfoMap) override;\n+\tint platformConfigure(const ControlInfoMap &sensorInfoMap) override;\n+\tint platformStart() override;\n+\tvoid platformStop() override;\n+\tvoid platformProcessStats(const ControlList &sensorControls) override;\n+\n+private:\n+\tvoid update_exposure(double ev_adjustment);\n+\n+\tSwIspStats *stats_;\n+\tint exposure_min_, exposure_max_;\n+\tint again_min_, again_max_;\n+\tint again_, exposure_;\n+\tint ignore_updates_;\n+};\n+\n+int IPASoftLinaro::platformInit(const ControlInfoMap &sensorInfoMap)\n+{\n+\tstats_ = static_cast<SwIspStats *>(mmap(nullptr, sizeof(SwIspStats),\n+\t\t\t\t\t\tPROT_READ | PROT_WRITE, MAP_SHARED,\n+\t\t\t\t\t\tfdStats_.get(), 0));\n+\tif (!stats_) {\n+\t\tLOG(IPASoft, Error) << \"Unable to map Statistics\";\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tif (sensorInfoMap.find(V4L2_CID_EXPOSURE) == sensorInfoMap.end()) {\n+\t\tLOG(IPASoft, Error) << \"Don't have exposure control\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (sensorInfoMap.find(V4L2_CID_ANALOGUE_GAIN) == sensorInfoMap.end()) {\n+\t\tLOG(IPASoft, Error) << \"Don't have gain control\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int IPASoftLinaro::platformConfigure(const ControlInfoMap &sensorInfoMap)\n+{\n+\tconst ControlInfo &exposure_info = sensorInfoMap.find(V4L2_CID_EXPOSURE)->second;\n+\tconst ControlInfo &gain_info = sensorInfoMap.find(V4L2_CID_ANALOGUE_GAIN)->second;\n+\n+\texposure_min_ = exposure_info.min().get<int>();\n+\tif (!exposure_min_) {\n+\t\tLOG(IPASoft, Warning) << \"Minimum exposure is zero, that can't be linear\";\n+\t\texposure_min_ = 1;\n+\t}\n+\texposure_max_ = exposure_info.max().get<int>();\n+\tagain_min_ = gain_info.min().get<int>();\n+\tif (!again_min_) {\n+\t\tLOG(IPASoft, Warning) << \"Minimum gain is zero, that can't be linear\";\n+\t\tagain_min_ = 100;\n+\t}\n+\tagain_max_ = gain_info.max().get<int>();\n+\n+\tLOG(IPASoft, Info) << \"Exposure \" << exposure_min_ << \"-\" << exposure_max_\n+\t\t\t   << \", gain \" << again_min_ << \"-\" << again_max_;\n+\n+\treturn 0;\n+}\n+\n+int IPASoftLinaro::platformStart()\n+{\n+\treturn 0;\n+}\n+\n+void IPASoftLinaro::platformStop()\n+{\n+}\n+\n+void IPASoftLinaro::platformProcessStats(const ControlList &sensorControls)\n+{\n+\tdouble ev_adjustment = 0.0;\n+\tControlList ctrls(sensorControls);\n+\n+\t/*\n+\t * Use 2 frames delay to make sure that the exposure and the gain set\n+\t * have applied to the camera sensor\n+\t */\n+\tif (ignore_updates_ > 0) {\n+\t\tLOG(IPASoft, Debug) << \"Skipping exposure update: \"\n+\t\t\t\t    << ignore_updates_;\n+\t\t--ignore_updates_;\n+\t\treturn;\n+\t}\n+\n+\tif (stats_->bright_ratio < 0.01)\n+\t\tev_adjustment = 1.1;\n+\tif (stats_->too_bright_ratio > 0.04)\n+\t\tev_adjustment = 0.9;\n+\n+\tif (ev_adjustment != 0.0) {\n+\t\t/* sanity check */\n+\t\tif (!sensorControls.contains(V4L2_CID_EXPOSURE) ||\n+\t\t    !sensorControls.contains(V4L2_CID_ANALOGUE_GAIN)) {\n+\t\t\tLOG(IPASoft, Error) << \"Control(s) missing\";\n+\t\t\treturn;\n+\t\t}\n+\n+\t\texposure_ = ctrls.get(V4L2_CID_EXPOSURE).get<int>();\n+\t\tagain_ = ctrls.get(V4L2_CID_ANALOGUE_GAIN).get<int>();\n+\n+\t\tupdate_exposure(ev_adjustment);\n+\n+\t\tctrls.set(V4L2_CID_EXPOSURE, exposure_);\n+\t\tctrls.set(V4L2_CID_ANALOGUE_GAIN, again_);\n+\n+\t\tignore_updates_ = 2;\n+\n+\t\tsetSensorControls.emit(ctrls);\n+\t}\n+}\n+\n+void IPASoftLinaro::update_exposure(double ev_adjustment)\n+{\n+\tdouble exp = (double)exposure_;\n+\tdouble gain = (double)again_;\n+\tdouble ev = ev_adjustment * exp * gain;\n+\n+\t/*\n+\t * Try to use the minimal possible analogue gain.\n+\t * The exposure can be any value from exposure_min_ to exposure_max_,\n+\t * and normally this should keep the frame rate intact.\n+\t */\n+\n+\texp = ev / again_min_;\n+\tif (exp > exposure_max_)\n+\t\texposure_ = exposure_max_;\n+\telse if (exp < exposure_min_)\n+\t\texposure_ = exposure_min_;\n+\telse\n+\t\texposure_ = (int)exp;\n+\n+\tgain = ev / exposure_;\n+\tif (gain > again_max_)\n+\t\tagain_ = again_max_;\n+\telse if (gain < again_min_)\n+\t\tagain_ = again_min_;\n+\telse\n+\t\tagain_ = (int)gain;\n+\n+\tLOG(IPASoft, Debug) << \"Desired EV = \" << ev\n+\t\t\t    << \", real EV = \" << (double)again_ * exposure_;\n+}\n+\n+} /* namespace ipa::soft */\n+\n+/*\n+ * External IPA module interface\n+ */\n+extern \"C\" {\n+const struct IPAModuleInfo ipaModuleInfo = {\n+\tIPA_MODULE_API_VERSION,\n+\t0,\n+\t\"SimplePipelineHandler\",\n+\t\"soft/linaro\",\n+};\n+\n+IPAInterface *ipaCreate()\n+{\n+\treturn new ipa::soft::IPASoftLinaro();\n+}\n+\n+} /* extern \"C\" */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/simple/meson.build b/src/ipa/simple/meson.build\nnew file mode 100644\nindex 00000000..14be5dc2\n--- /dev/null\n+++ b/src/ipa/simple/meson.build\n@@ -0,0 +1,12 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+subdir('common')\n+\n+foreach pipeline : pipelines\n+    pipeline = pipeline.split('/')\n+    if pipeline.length() < 2 or pipeline[0] != 'simple'\n+        continue\n+    endif\n+\n+    subdir(pipeline[1])\n+endforeach\n","prefixes":["libcamera-devel","RFC","4/7"]}