{"id":19306,"url":"https://patchwork.libcamera.org/api/1.1/patches/19306/?format=json","web_url":"https://patchwork.libcamera.org/patch/19306/","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":"<20231212115046.102726-2-andrey.konovalov@linaro.org>","date":"2023-12-12T11:50:40","name":"[libcamera-devel,RFC,v2,1/7] libcamera: introduce SoftwareIsp class","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"b580cb11d12609b152b3ce7462a0687ba3f2abf9","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/19306/mbox/","series":[{"id":4114,"url":"https://patchwork.libcamera.org/api/1.1/series/4114/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4114","date":"2023-12-12T11:50:39","name":"libcamera: introduce Software ISP and Software IPA","version":2,"mbox":"https://patchwork.libcamera.org/series/4114/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19306/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19306/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 D2A6DBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 12 Dec 2023 11:51:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 881D362B2E;\n\tTue, 12 Dec 2023 12:51:20 +0100 (CET)","from mail-ed1-x534.google.com (mail-ed1-x534.google.com\n\t[IPv6:2a00:1450:4864:20::534])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E02F6629E1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Dec 2023 12:51:18 +0100 (CET)","by mail-ed1-x534.google.com with SMTP id\n\t4fb4d7f45d1cf-54c79968ffbso7341146a12.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Dec 2023 03:51:18 -0800 (PST)","from Lat-5310.. ([87.116.161.153]) by smtp.gmail.com with ESMTPSA\n\tid\n\ttx17-20020a1709078e9100b00a1b75e0e061sm6213188ejc.130.2023.12.12.03.51.17\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 12 Dec 2023 03:51:18 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1702381880;\n\tbh=+DHVvdlkAeBB23ioXjBk7DxfCC50ZttBLeVX6IWs+w4=;\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=h5OsJ5x9PJ02HZyOVbS41o1Xtj6Ed7mkdTd3vUKzxJosgtF/ndKKesUmVf5z5lthb\n\tffNg38PdcST7tiYIAhlaeGyDutvj7lijKs5jiizdnh0dnzoFr9thW5eCI8UA6RQGwC\n\tieHOt39I4kbCRA+dM61113hGb/kWcIbub7GbAK2O0vKncYD/zCS+2ZQBkQLIMU3w1O\n\tx7zbho0qfPspOueT1dQTly/aUjJmdqtLpeTkulR260coQXygcepp3wP226bXbUyg1D\n\tn23tKQ0KufCBMzEkbyh4bagLKjcRWTjRUer8+ruNApTGLijkDswlmKZwizIN/gVaRs\n\tZexloDROffbig==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1702381878; x=1702986678;\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=uIstvMk8lbSTkr39GEaKHG4p3SI0k5/yPhecGjI4+ac=;\n\tb=rcI/l7CIqt7LKlj0CbiPb18puU1srndB4JIzeZ+Fyx0CpNBiFMXrHOIJEl+vWzmh1D\n\tziiukPj7kdmSFvgFTI1p4Ova27w5ZcQLBYi9csJsojgR9f7HlJoO5yYTdNZa9noEtl4l\n\toLMUhRoWGTTDc3+Q3eKcLz5ty+gnXqKPjy/m/+7dfH4YhZPbt6W3JeLxAEnm5XTpl7FS\n\tGD3o/1NrbNqHPSVYiJlSu4vmCFCzUbpypJXGX26WzJyIi+wnsVO8JWs+BTrAvPBtIE5/\n\thPsb8G26+/PUaxtZ6Is85WOcCVHyJyR+pf5fbj/SQY5WwAeb0LO1l2orFSBc/GHSUTRX\n\t93rQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=linaro.org\n\theader.i=@linaro.org header.b=\"rcI/l7CI\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1702381878; x=1702986678;\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=uIstvMk8lbSTkr39GEaKHG4p3SI0k5/yPhecGjI4+ac=;\n\tb=SyXKpI/7ZbRvFPhYeE4ulKUXS6XGfjGOalvloVUzMC4+5/e5ikAmzCGEMirbcP0eIA\n\tBZbjVfA9+2a5hztIn7YVfKY7ib7K00FV8IM+/zqcWmr71M6ws8HBN6jUjysxJUz7FMMY\n\tbPg1Cv4uWG2SnOiWHluuGT9MzyVG/Rusqq5lu3UyoNQsG43zvbHSPb1dkI1rlXnzDujP\n\trG0lss13izG0DYm6FAhM2DyHCmzd7T1Dd4vEA3VTMfKDioy5fOj3ANmZZK+CLWZ/nkW5\n\tJVXhu3Jd8sjfoTemzaLks99JBJqxwf2GpiFLwkuw3huKMNDzGbGziWmISahtMXvug3Vj\n\tIu6w==","X-Gm-Message-State":"AOJu0YzPbDyyLnaz7qLWCqSqi5S1LvxB7FzTCpoyHgyJx/UDEdHVSDiP\n\tSxG3hrP/EQcCD82mcAGs+ohcnfVPgPN8aQtpQjI=","X-Google-Smtp-Source":"AGHT+IGVqvwTNKFDvnw/9QVhpxsIXLRCjPG7DqRB5s5IXKdwv++pAsPzcsLA2EofB9EOXF/UhS57kQ==","X-Received":"by 2002:a17:906:3f13:b0:a1e:7683:4da4 with SMTP id\n\tc19-20020a1709063f1300b00a1e76834da4mr2495514ejj.11.1702381878410; \n\tTue, 12 Dec 2023 03:51:18 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 12 Dec 2023 14:50:40 +0300","Message-Id":"<20231212115046.102726-2-andrey.konovalov@linaro.org>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20231212115046.102726-1-andrey.konovalov@linaro.org>","References":"<20231212115046.102726-1-andrey.konovalov@linaro.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH v2 1/7] libcamera: introduce\n\tSoftwareIsp class","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, pavel@ucw.cz,\n\tbryan.odonoghue@linaro.org, admin@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/internal/meson.build    |   1 +\n include/libcamera/internal/software_isp.h | 106 ++++++++++++++++++++++\n src/libcamera/meson.build                 |   1 +\n src/libcamera/software_isp.cpp            |  62 +++++++++++++\n 4 files changed, 170 insertions(+)\n create mode 100644 include/libcamera/internal/software_isp.h\n create mode 100644 src/libcamera/software_isp.cpp","diff":"diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex 7f1f3440..0f725cfd 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -38,6 +38,7 @@ libcamera_internal_headers = files([\n     'process.h',\n     'pub_key.h',\n     'request.h',\n+    'software_isp.h',\n     'source_paths.h',\n     'sysfs.h',\n     'v4l2_device.h',\ndiff --git a/include/libcamera/internal/software_isp.h b/include/libcamera/internal/software_isp.h\nnew file mode 100644\nindex 00000000..14511017\n--- /dev/null\n+++ b/include/libcamera/internal/software_isp.h\n@@ -0,0 +1,106 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Linaro Ltd\n+ *\n+ * software_isp.h - Interface for a software implementation of an ISP\n+ */\n+\n+#pragma once\n+\n+#include <functional>\n+#include <initializer_list>\n+#include <map>\n+#include <memory>\n+#include <string>\n+#include <tuple>\n+#include <vector>\n+\n+#include <libcamera/base/class.h>\n+#include <libcamera/base/signal.h>\n+\n+#include <libcamera/geometry.h>\n+\n+#include \"libcamera/internal/pipeline_handler.h\"\n+\n+namespace libcamera {\n+\n+class FrameBuffer;\n+class PixelFormat;\n+struct StreamConfiguration;\n+\n+class SoftwareIsp\n+{\n+public:\n+\tSoftwareIsp(PipelineHandler *pipe, const ControlInfoMap &sensorControls);\n+\tvirtual ~SoftwareIsp();\n+\n+\tvirtual int loadConfiguration(const std::string &filename) = 0;\n+\n+\tvirtual bool isValid() const = 0;\n+\n+\tvirtual std::vector<PixelFormat> formats(PixelFormat input) = 0;\n+\tvirtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;\n+\n+\tvirtual std::tuple<unsigned int, unsigned int>\n+\tstrideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) = 0;\n+\n+\tvirtual int configure(const StreamConfiguration &inputCfg,\n+\t\t\t      const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs) = 0;\n+\tvirtual int exportBuffers(unsigned int output, unsigned int count,\n+\t\t\t\t  std::vector<std::unique_ptr<FrameBuffer>> *buffers) = 0;\n+\n+\tvirtual int start() = 0;\n+\tvirtual void stop() = 0;\n+\n+\tvirtual int queueBuffers(FrameBuffer *input,\n+\t\t\t\t const std::map<unsigned int, FrameBuffer *> &outputs) = 0;\n+\n+\tvirtual void processStats(const ControlList &sensorControls) = 0; // rather merge with queueBuffers()?\n+\n+\tvirtual Signal<const ControlList &> &getSignalSetSensorControls() = 0;\n+\n+\tSignal<FrameBuffer *> inputBufferReady;\n+\tSignal<FrameBuffer *> outputBufferReady;\n+\n+\t/* The int parameter isn't actually used */\n+\tSignal<int> ispStatsReady;\n+};\n+\n+class SoftwareIspFactoryBase\n+{\n+public:\n+\tSoftwareIspFactoryBase();\n+\tvirtual ~SoftwareIspFactoryBase() = default;\n+\n+\tstatic std::unique_ptr<SoftwareIsp> create(PipelineHandler *pipe,\n+\t\t\t\t\t\t   const ControlInfoMap &sensorControls);\n+\tstatic SoftwareIspFactoryBase *&factory();\n+\n+private:\n+\tLIBCAMERA_DISABLE_COPY_AND_MOVE(SoftwareIspFactoryBase)\n+\n+\tstatic void registerType(SoftwareIspFactoryBase *factory);\n+\tvirtual std::unique_ptr<SoftwareIsp> createInstance(PipelineHandler *pipe,\n+\t\t\t\t\t\t\t    const ControlInfoMap &sensorControls) const = 0;\n+};\n+\n+template<typename _SoftwareIsp>\n+class SoftwareIspFactory : public SoftwareIspFactoryBase\n+{\n+public:\n+\tSoftwareIspFactory()\n+\t\t: SoftwareIspFactoryBase()\n+\t{\n+\t}\n+\n+\tstd::unique_ptr<SoftwareIsp> createInstance(PipelineHandler *pipe,\n+\t\t\t\t\t\t    const ControlInfoMap &sensorControls) const override\n+\t{\n+\t\treturn std::make_unique<_SoftwareIsp>(pipe, sensorControls);\n+\t}\n+};\n+\n+#define REGISTER_SOFTWAREISP(softwareIsp) \\\n+\tstatic SoftwareIspFactory<softwareIsp> global_##softwareIsp##Factory;\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 45f63e93..b3606969 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -40,6 +40,7 @@ libcamera_sources = files([\n     'process.cpp',\n     'pub_key.cpp',\n     'request.cpp',\n+    'software_isp.cpp',\n     'source_paths.cpp',\n     'stream.cpp',\n     'sysfs.cpp',\ndiff --git a/src/libcamera/software_isp.cpp b/src/libcamera/software_isp.cpp\nnew file mode 100644\nindex 00000000..2ff97d70\n--- /dev/null\n+++ b/src/libcamera/software_isp.cpp\n@@ -0,0 +1,62 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Linaro Ltd\n+ *\n+ * software_isp.cpp - Interface for a software implementation of an ISP\n+ */\n+\n+#include \"libcamera/internal/software_isp.h\"\n+\n+#include <libcamera/base/log.h>\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(SoftwareIsp)\n+\n+SoftwareIsp::SoftwareIsp([[maybe_unused]] PipelineHandler *pipe,\n+\t\t\t [[maybe_unused]] const ControlInfoMap &sensorControls)\n+{\n+}\n+\n+SoftwareIsp::~SoftwareIsp()\n+{\n+}\n+\n+/* SoftwareIspFactoryBase */\n+\n+SoftwareIspFactoryBase::SoftwareIspFactoryBase()\n+{\n+\tregisterType(this);\n+}\n+\n+void SoftwareIspFactoryBase::registerType(SoftwareIspFactoryBase *factory)\n+{\n+\tSoftwareIspFactoryBase *&registered =\n+\t\tSoftwareIspFactoryBase::factory();\n+\n+\tASSERT(!registered && factory);\n+\tregistered = factory;\n+}\n+\n+SoftwareIspFactoryBase *&SoftwareIspFactoryBase::factory()\n+{\n+\tstatic SoftwareIspFactoryBase *factory;\n+\treturn factory;\n+}\n+\n+std::unique_ptr<SoftwareIsp>\n+SoftwareIspFactoryBase::create(PipelineHandler *pipe,\n+\t\t\t       const ControlInfoMap &sensorControls)\n+{\n+\tSoftwareIspFactoryBase *factory = SoftwareIspFactoryBase::factory();\n+\tif (!factory)\n+\t\treturn nullptr;\n+\n+\tstd::unique_ptr<SoftwareIsp> swIsp = factory->createInstance(pipe, sensorControls);\n+\tif (swIsp->isValid())\n+\t\treturn swIsp;\n+\n+\treturn nullptr;\n+}\n+\n+} /* namespace libcamera */\n","prefixes":["libcamera-devel","RFC","v2","1/7"]}