{"id":19316,"url":"https://patchwork.libcamera.org/api/1.1/patches/19316/?format=json","web_url":"https://patchwork.libcamera.org/patch/19316/","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":"<20231214121350.206015-2-hdegoede@redhat.com>","date":"2023-12-14T12:13:39","name":"[libcamera-devel,01/11] libcamera: introduce SoftwareIsp class","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"2ad30b05035c98b2cfd16c8bc90c2d465a091e6a","submitter":{"id":102,"url":"https://patchwork.libcamera.org/api/1.1/people/102/?format=json","name":"Hans de Goede","email":"hdegoede@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19316/mbox/","series":[{"id":4117,"url":"https://patchwork.libcamera.org/api/1.1/series/4117/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4117","date":"2023-12-14T12:13:38","name":"libcamera: introduce Software ISP and Software IPA","version":1,"mbox":"https://patchwork.libcamera.org/series/4117/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19316/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19316/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 F2C2DBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Dec 2023 12:13:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ADA5C62B3E;\n\tThu, 14 Dec 2023 13:13:59 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C5B261D97\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Dec 2023 13:13:58 +0100 (CET)","from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n\t[66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-644-OkcUAu_-MFWkLPgsDDzZGA-1; Thu, 14 Dec 2023 07:13:54 -0500","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mimecast-mx02.redhat.com (Postfix) with ESMTPS id 944BD85A58A;\n\tThu, 14 Dec 2023 12:13:53 +0000 (UTC)","from shalem.redhat.com (unknown [10.39.194.72])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 4E36D1121306;\n\tThu, 14 Dec 2023 12:13:52 +0000 (UTC)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1702556039;\n\tbh=9lAdjEGb84KrawF6VpzD8e4nEnFR/pZ0hxGDAoDEsKc=;\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=yd63Nl3NoBRn7xIF3U14KxCoKZ2hiSQ2LgmNG3pUcMBp8SwJUuFcul4hBrlrXDxdQ\n\tuS7sN6oDZgZHXmN2bMs6FxOQo0zk0hcbMIGyesG7sVIOcwOgY0yDFGYA1yjMwpQuuw\n\t17bMVd/EFOp/eWE8JB9HFDBITJ7iSIzOKV8YqEOhvHkhDH9Mo7uEgqxpLdmbHpQm6Q\n\tPKnUDJ4XIXuMU1+odwPFepzjEcWPAkZWrc04k7aWVuLacqwe6UtFoRVJyS+X6sntfu\n\t16LVGTY9hHUXWcqPhy6cK9jR+tvigT5OBhAiigQQUG9fB6eHCiWOw5jl+Un+iQezNx\n\t9RUpkWywn4dpw==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1702556037;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=W1QTcMYwG8Wi8q3OEBBjijsdZNeRjmeL4rPymXzB/3A=;\n\tb=cuQGl5T7nklwwqEL+Cc47TD+3IQ3QX000S5OkxVxD1VR3U6+rfSNXW+QdSpPWrU27o5CHb\n\tE75WIFGD4PgX/QKRX86RyV+Qew76HT/9Vxcv1oAC6qW5yAUwdHqWXD6pRFhXwMIdID4KV0\n\t3RaHDiUzlqxOx/hTv98RYnqsmJVO9zk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"cuQGl5T7\"; \n\tdkim-atps=neutral","X-MC-Unique":"OkcUAu_-MFWkLPgsDDzZGA-1","To":"libcamera-devel@lists.libcamera.org,\n\tAndrey Konovalov <andrey.konovalov@linaro.org>","Date":"Thu, 14 Dec 2023 13:13:39 +0100","Message-ID":"<20231214121350.206015-2-hdegoede@redhat.com>","In-Reply-To":"<20231214121350.206015-1-hdegoede@redhat.com>","References":"<20231214121350.206015-1-hdegoede@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.11.54.3","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain; charset=\"US-ASCII\"; x-default=true","Subject":"[libcamera-devel] [PATCH 01/11] libcamera: introduce SoftwareIsp\n\tclass","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":"Hans de Goede via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Hans de Goede <hdegoede@redhat.com>","Cc":"Maxime Ripard <mripard@redhat.com>, g.martti@gmail.com,\n\tt.langendam@gmail.com, srinivas.kandagatla@linaro.org,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>, admin@dennisbonke.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Andrey Konovalov <andrey.konovalov@linaro.org>\n\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n---\n include/libcamera/internal/meson.build    |   1 +\n include/libcamera/internal/software_isp.h | 109 ++++++++++++++++++++++\n src/libcamera/meson.build                 |   1 +\n src/libcamera/software_isp.cpp            |  62 ++++++++++++\n 4 files changed, 173 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..49cf7968\n--- /dev/null\n+++ b/include/libcamera/internal/software_isp.h\n@@ -0,0 +1,109 @@\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/log.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+LOG_DECLARE_CATEGORY(SoftwareIsp)\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","01/11"]}