Show a patch.

GET /api/1.1/patches/19396/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 19396,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/19396/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19396/",
    "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": "<20240113142218.28063-7-hdegoede@redhat.com>",
    "date": "2024-01-13T14:22:06",
    "name": "[libcamera-devel,v2,06/18] libcamera: introduce SoftwareIsp class",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "5c8652805303ae1967764a4b87cd0fe1b4b0594c",
    "submitter": {
        "id": 102,
        "url": "https://patchwork.libcamera.org/api/1.1/people/102/?format=api",
        "name": "Hans de Goede",
        "email": "hdegoede@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19396/mbox/",
    "series": [
        {
            "id": 4142,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4142/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4142",
            "date": "2024-01-13T14:22:00",
            "name": "[libcamera-devel,v2,01/18] libcamera: pipeline: simple: fix size adjustment in validate()",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/4142/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19396/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19396/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 0FADEBEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 13 Jan 2024 14:22:49 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A230862916;\n\tSat, 13 Jan 2024 15:22:48 +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 208C6628B7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Jan 2024 15:22:47 +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-48-7SqzoaRpN-m28jq56Qcz2Q-1; Sat, 13 Jan 2024 09:22:40 -0500",
            "from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1])\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 65436185A781;\n\tSat, 13 Jan 2024 14:22:40 +0000 (UTC)",
            "from localhost.localdomain (unknown [10.39.192.58])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 5AF153C25;\n\tSat, 13 Jan 2024 14:22:38 +0000 (UTC)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1705155768;\n\tbh=XVWTF2bafeSJX8cYS3jYzTVWSXfazy4QST85a1l8y2c=;\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=CZxbIw80EG0GdACQxdf842zWipJ+hUT/7RtCtBHQXxjSVEoPZcxx20VUptRqLSk9U\n\taeOThVqa1S5aDR2q3YM06zdqPjNecW58sGuQN6u/kpL6+KnHGjZ6gAxtc2uCkNLcd2\n\txSFcGSNsfcHbM2KUH3JwYMhqBXRdysCXaSD24JoNcov7YozYyzKgGLep4Tq34K/5X2\n\tPX6rNy2s2xeqD6BxNI0g+qbXskoy6quGM/yTih1JwN62c4U2EWWF4oAHFSb7fw7met\n\t27ufzshapmp7sdSWe6RbS6dV9eFO7fklZitGN+s2Duh+P/aH8MdLu0RxT/NK/ZtyZG\n\ttTSxxu7sRc6Eg==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1705155766;\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=bojsjgIBeZItXfqcOq45Tyix7akDejRV5UNJPVRdwiA=;\n\tb=VFdnqJ5wl7ni95zpeuSRZNIdKiX+5IB4VO46PguZ8D1ii9cxzdOLrnMS7K9tiH80jPr4RV\n\tfYPZ8TpG+ChmHwhuScRYjlK0tYvMlUJf2HjOQpV4I1f38s3vfrgbB9lDxn2ZgonAotniG+\n\tO9HHfdsgte6C/U7cpMz3AMGLjIu+sRI="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"VFdnqJ5w\"; \n\tdkim-atps=neutral",
        "X-MC-Unique": "7SqzoaRpN-m28jq56Qcz2Q-1",
        "To": "libcamera-devel@lists.libcamera.org,\n\tAndrey Konovalov <andrey.konovalov.ynk@gmail.com>",
        "Date": "Sat, 13 Jan 2024 15:22:06 +0100",
        "Message-ID": "<20240113142218.28063-7-hdegoede@redhat.com>",
        "In-Reply-To": "<20240113142218.28063-1-hdegoede@redhat.com>",
        "References": "<20240113142218.28063-1-hdegoede@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.1",
        "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 v2 06/18] 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\tPavel Machek <pavel@ucw.cz>,\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\nDoxygen documentation by Dennis Bonke.\n\nCo-authored-by: Dennis Bonke <admin@dennisbonke.com>\nSigned-off-by: Dennis Bonke <admin@dennisbonke.com>\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\nTested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s\nTested-by: Pavel Machek <pavel@ucw.cz>\n---\n include/libcamera/internal/meson.build    |   1 +\n include/libcamera/internal/software_isp.h | 231 ++++++++++++++++++++++\n src/libcamera/meson.build                 |   1 +\n src/libcamera/software_isp.cpp            |  62 ++++++\n 4 files changed, 295 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 5807dfd9..1325941d 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -40,6 +40,7 @@ libcamera_internal_headers = files([\n     'pub_key.h',\n     'request.h',\n     'shared_mem_object.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..42ff48ec\n--- /dev/null\n+++ b/include/libcamera/internal/software_isp.h\n@@ -0,0 +1,231 @@\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+/**\n+ * \\brief Base class for the Software ISP.\n+ *\n+ * Base class of the SoftwareIsp interface.\n+ */\n+class SoftwareIsp\n+{\n+public:\n+\t/**\n+\t * \\brief Constructor for the SoftwareIsp object.\n+\t * \\param[in] pipe The pipeline handler in use.\n+\t * \\param[in] sensorControls The sensor controls.\n+\t */\n+\tSoftwareIsp(PipelineHandler *pipe, const ControlInfoMap &sensorControls);\n+\tvirtual ~SoftwareIsp();\n+\n+\t/**\n+\t * \\brief Load a configuration from a file.\n+\t * \\param[in] filename The file to load from.\n+\t *\n+\t * \\return 0 on success.\n+\t */\n+\tvirtual int loadConfiguration(const std::string &filename) = 0;\n+\n+\t/**\n+\t * \\brief Gets if there is a valid debayer object.\n+\t *\n+\t * \\returns true if there is, false otherwise.\n+\t */\n+\tvirtual bool isValid() const = 0;\n+\n+\t/**\n+\t * \\brief Get the supported output formats.\n+\t * \\param[in] input The input format.\n+\t *\n+\t * \\return all supported output formats or an empty vector if there are none.\n+\t */\n+\tvirtual std::vector<PixelFormat> formats(PixelFormat input) = 0;\n+\n+\t/**\n+\t * \\brief Get the supported output sizes for the given input format and size.\n+\t * \\param[in] inputFormat The input format.\n+\t * \\param[in] inputSize The input size.\n+\t *\n+\t * \\return The valid size ranges or an empty range if there are none.\n+\t */\n+\tvirtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;\n+\n+\t/**\n+\t * \\brief Get the stride and the frame size.\n+\t * \\param[in] pixelFormat The output format.\n+\t * \\param[in] size The output size.\n+\t *\n+\t * \\return a tuple of the stride and the frame size, or a tuple with 0,0 if there is no valid output config.\n+\t */\n+\tvirtual std::tuple<unsigned int, unsigned int>\n+\tstrideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) = 0;\n+\n+\t/**\n+\t * \\brief Configure the SwIspSimple object according to the passed in parameters.\n+\t * \\param[in] inputCfg The input configuration.\n+\t * \\param[in] outputCfgs The output configurations.\n+\t * \\param[in] sensorControls The sensor controls.\n+\t *\n+\t * \\return 0 on success, a negative errno on failure.\n+\t */\n+\tvirtual int configure(const StreamConfiguration &inputCfg,\n+\t\t\t      const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs,\n+\t\t\t      const ControlInfoMap &sensorControls) = 0;\n+\n+\t/**\n+\t * \\brief Exports the buffers for use in processing.\n+\t * \\param[in] output The number of outputs requested.\n+\t * \\param[in] count The number of planes.\n+\t * \\param[out] buffers The exported buffers.\n+\t *\n+\t * \\return count when successful, a negative return value if an error occurred.\n+\t */\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+\t/**\n+\t * \\brief Starts the Software ISP worker.\n+\t *\n+\t * \\return 0 on success, any other value indicates an error.\n+\t */\n+\tvirtual int start() = 0;\n+\n+\t/**\n+\t * \\brief Stops the Software ISP worker.\n+\t */\n+\tvirtual void stop() = 0;\n+\n+\t/**\n+\t * \\brief Queues buffers for processing.\n+\t * \\param[in] input The input framebuffer.\n+\t * \\param[in] outputs The output framebuffers.\n+\t *\n+\t * \\return 0 on success, a negative errno on failure\n+\t */\n+\tvirtual int queueBuffers(FrameBuffer *input,\n+\t\t\t\t const std::map<unsigned int, FrameBuffer *> &outputs) = 0;\n+\n+\t/**\n+\t * \\brief Process the statistics gathered.\n+\t * \\param[in] sensorControls The sensor controls.\n+\t */\n+\tvirtual void processStats(const ControlList &sensorControls) = 0; // rather merge with queueBuffers()?\n+\n+\t/**\n+\t * \\brief Get the signal for when the sensor controls are set.\n+\t *\n+\t * \\return The control list of the sensor controls.\n+\t */\n+\tvirtual Signal<const ControlList &> &getSignalSetSensorControls() = 0;\n+\n+\t/**\n+\t * \\brief Signals that the input buffer is ready.\n+\t */\n+\tSignal<FrameBuffer *> inputBufferReady;\n+\t/**\n+\t * \\brief Signals that the output buffer is ready.\n+\t */\n+\tSignal<FrameBuffer *> outputBufferReady;\n+\n+\t/**\n+\t * \\brief Signals that the ISP stats are ready.\n+\t *\n+\t * The int parameter isn't actually used.\n+\t */\n+\tSignal<int> ispStatsReady;\n+};\n+\n+/**\n+ * \\brief Base class for the Software ISP Factory.\n+ *\n+ * Base class of the SoftwareIsp Factory.\n+ */\n+class SoftwareIspFactoryBase\n+{\n+public:\n+\tSoftwareIspFactoryBase();\n+\tvirtual ~SoftwareIspFactoryBase() = default;\n+\n+\t/**\n+\t * \\brief Creates a SoftwareIsp object.\n+\t * \\param[in] pipe The pipeline handler in use.\n+\t * \\param[in] sensorControls The sensor controls.\n+\t *\n+\t * \\return An unique pointer to the created SoftwareIsp object.\n+\t */\n+\tstatic std::unique_ptr<SoftwareIsp> create(PipelineHandler *pipe,\n+\t\t\t\t\t\t   const ControlInfoMap &sensorControls);\n+\t/**\n+\t * \\brief Gives back a pointer to the factory.\n+\t *\n+\t * \\return A static pointer to the factory instance.\n+\t */\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+/**\n+ * \\brief Implementation for the Software ISP Factory.\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+\t/**\n+\t * \\brief Creates an instance of a SoftwareIsp object.\n+\t * \\param[in] pipe The pipeline handler in use.\n+\t * \\param[in] sensorControls The sensor controls.\n+\t *\n+\t * \\return An unique pointer to the created SoftwareIsp object.\n+\t */\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 3c5e43df..86494663 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -41,6 +41,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",
        "v2",
        "06/18"
    ]
}