Patch Detail
Show a patch.
GET /api/patches/19831/?format=api
{ "id": 19831, "url": "https://patchwork.libcamera.org/api/patches/19831/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19831/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20240404084657.353464-12-mzamazal@redhat.com>", "date": "2024-04-04T08:46:48", "name": "[v7,11/18] libcamera: introduce SoftwareIsp", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "98793ea06613d970103a4febfc2db84f5cbf4ad4", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19831/mbox/", "series": [ { "id": 4246, "url": "https://patchwork.libcamera.org/api/series/4246/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4246", "date": "2024-04-04T08:46:37", "name": "libcamera: introduce Software ISP and Software IPA", "version": 7, "mbox": "https://patchwork.libcamera.org/series/4246/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19831/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19831/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 300F0C32C9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 4 Apr 2024 08:47:51 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E59AF63386;\n\tThu, 4 Apr 2024 10:47:50 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 31AC663385\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 4 Apr 2024 10:47:49 +0200 (CEST)", "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-321-paG9RLkgMsGqSozG3Tgdyw-1; Thu, 04 Apr 2024 04:47:44 -0400", "from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5])\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 4CD09185A784;\n\tThu, 4 Apr 2024 08:47:44 +0000 (UTC)", "from nuthatch.brq.redhat.com (unknown [10.43.17.39])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id CE29B8173;\n\tThu, 4 Apr 2024 08:47:42 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"NddUzmE1\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1712220468;\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=IHKzkEzYB490e3b0R65TsvvZzpyynTns19WNL4O0Ulc=;\n\tb=NddUzmE1MOHu0wRTTmP8LpmAm68jFfEbXRACAgidEBnGdb1ieiZtTA5ODbmCX26wumlD71\n\t3+YZSG6Wo1H/Qe2i7Y7tzQb1RFwGmHraQ57LDDyLoPs4MPEP/JLRXcEozzXbbrDfPfSJGK\n\tkH4nCmIG6DaePbjqSH9gnXgdVhpVtdM=", "X-MC-Unique": "paG9RLkgMsGqSozG3Tgdyw-1", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Andrey Konovalov <andrey.konovalov@linaro.org>,\n\tAndrei Konovalov <andrey.konovalov.ynk@gmail.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tMaxime Ripard <mripard@redhat.com>, Milan Zamazal <mzamazal@redhat.com>, \n\tPavel Machek <pavel@ucw.cz>, Hans de Goede <hdegoede@redhat.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tDennis Bonke <admin@dennisbonke.com>", "Subject": "[PATCH v7 11/18] libcamera: introduce SoftwareIsp", "Date": "Thu, 4 Apr 2024 10:46:48 +0200", "Message-ID": "<20240404084657.353464-12-mzamazal@redhat.com>", "In-Reply-To": "<20240404084657.353464-1-mzamazal@redhat.com>", "References": "<20240404084657.353464-1-mzamazal@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.5", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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": "From: Andrey Konovalov <andrey.konovalov@linaro.org>\n\nDoxygen documentation by Dennis Bonke.\n\nTested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s\nTested-by: Pavel Machek <pavel@ucw.cz>\nReviewed-by: Pavel Machek <pavel@ucw.cz>\nCo-developed-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>\n---\n .../internal/software_isp/meson.build | 1 +\n .../internal/software_isp/software_isp.h | 99 +++++\n src/libcamera/software_isp/meson.build | 1 +\n src/libcamera/software_isp/software_isp.cpp | 357 ++++++++++++++++++\n 4 files changed, 458 insertions(+)\n create mode 100644 include/libcamera/internal/software_isp/software_isp.h\n create mode 100644 src/libcamera/software_isp/software_isp.cpp", "diff": "diff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build\nindex a620e16d..508ddddc 100644\n--- a/include/libcamera/internal/software_isp/meson.build\n+++ b/include/libcamera/internal/software_isp/meson.build\n@@ -2,5 +2,6 @@\n \n libcamera_internal_headers += files([\n 'debayer_params.h',\n+ 'software_isp.h',\n 'swisp_stats.h',\n ])\ndiff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h\nnew file mode 100644\nindex 00000000..6a57308e\n--- /dev/null\n+++ b/include/libcamera/internal/software_isp/software_isp.h\n@@ -0,0 +1,99 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Linaro Ltd\n+ *\n+ * software_isp.h - Simple software ISP implementation\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+#include <libcamera/base/thread.h>\n+\n+#include <libcamera/geometry.h>\n+#include <libcamera/pixel_format.h>\n+\n+#include <libcamera/ipa/soft_ipa_interface.h>\n+#include <libcamera/ipa/soft_ipa_proxy.h>\n+\n+#include \"libcamera/internal/camera_sensor.h\"\n+#include \"libcamera/internal/dma_heaps.h\"\n+#include \"libcamera/internal/pipeline_handler.h\"\n+#include \"libcamera/internal/shared_mem_object.h\"\n+#include \"libcamera/internal/software_isp/debayer_params.h\"\n+\n+namespace libcamera {\n+\n+class DebayerCpu;\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 CameraSensor *sensor);\n+\t~SoftwareIsp();\n+\n+\tint loadConfiguration([[maybe_unused]] const std::string &filename) { return 0; }\n+\n+\tbool isValid() const;\n+\n+\tstd::vector<PixelFormat> formats(PixelFormat input);\n+\n+\tSizeRange sizes(PixelFormat inputFormat, const Size &inputSize);\n+\n+\tstd::tuple<unsigned int, unsigned int>\n+\tstrideAndFrameSize(const PixelFormat &outputFormat, const Size &size);\n+\n+\tint configure(const StreamConfiguration &inputCfg,\n+\t\t const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs,\n+\t\t const ControlInfoMap &sensorControls);\n+\n+\tint exportBuffers(unsigned int output, unsigned int count,\n+\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n+\n+\tvoid processStats(const ControlList &sensorControls);\n+\n+\tint start();\n+\tvoid stop();\n+\n+\tint queueBuffers(FrameBuffer *input,\n+\t\t\t const std::map<unsigned int, FrameBuffer *> &outputs);\n+\n+\tvoid process(FrameBuffer *input, FrameBuffer *output);\n+\n+\tSignal<FrameBuffer *> inputBufferReady;\n+\tSignal<FrameBuffer *> outputBufferReady;\n+\tSignal<> ispStatsReady;\n+\tSignal<const ControlList &> setSensorControls;\n+\n+private:\n+\tvoid saveIspParams(int dummy);\n+\tvoid setSensorCtrls(const ControlList &sensorControls);\n+\tvoid statsReady();\n+\tvoid inputReady(FrameBuffer *input);\n+\tvoid outputReady(FrameBuffer *output);\n+\n+\tstd::unique_ptr<DebayerCpu> debayer_;\n+\tThread ispWorkerThread_;\n+\tSharedMemObject<DebayerParams> sharedParams_;\n+\tDebayerParams debayerParams_;\n+\tDmaHeap dmaHeap_;\n+\n+\tstd::unique_ptr<ipa::soft::IPAProxySoft> ipa_;\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build\nindex b63f077f..f7c66e28 100644\n--- a/src/libcamera/software_isp/meson.build\n+++ b/src/libcamera/software_isp/meson.build\n@@ -10,5 +10,6 @@ endif\n libcamera_sources += files([\n 'debayer.cpp',\n 'debayer_cpu.cpp',\n+ 'software_isp.cpp',\n 'swstats_cpu.cpp',\n ])\ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nnew file mode 100644\nindex 00000000..8be375be\n--- /dev/null\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -0,0 +1,357 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Linaro Ltd\n+ *\n+ * software_isp.cpp - Simple software ISP implementation\n+ */\n+\n+#include \"libcamera/internal/software_isp/software_isp.h\"\n+\n+#include <sys/mman.h>\n+#include <sys/types.h>\n+#include <unistd.h>\n+\n+#include <libcamera/formats.h>\n+#include <libcamera/stream.h>\n+\n+#include \"libcamera/internal/bayer_format.h\"\n+#include \"libcamera/internal/framebuffer.h\"\n+#include \"libcamera/internal/ipa_manager.h\"\n+#include \"libcamera/internal/mapped_framebuffer.h\"\n+\n+#include \"debayer_cpu.h\"\n+\n+/**\n+ * \\file software_isp.cpp\n+ * \\brief Simple software ISP implementation\n+ */\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(SoftwareIsp)\n+\n+/**\n+ * \\class SoftwareIsp\n+ * \\brief Class for the Software ISP\n+ */\n+\n+/**\n+ * \\var SoftwareIsp::inputBufferReady\n+ * \\brief A signal emitted when the input frame buffer completes\n+ */\n+\n+/**\n+ * \\var SoftwareIsp::outputBufferReady\n+ * \\brief A signal emitted when the output frame buffer completes\n+ */\n+\n+/**\n+ * \\var SoftwareIsp::ispStatsReady\n+ * \\brief A signal emitted when the statistics for IPA are ready\n+ */\n+\n+/**\n+ * \\var SoftwareIsp::setSensorControls\n+ * \\brief A signal emitted when the values to write to the sensor controls are\n+ * ready\n+ */\n+\n+/**\n+ * \\brief Constructs SoftwareIsp object\n+ * \\param[in] pipe The pipeline handler in use\n+ * \\param[in] sensor Pointer to the CameraSensor instance owned by the pipeline\n+ * handler\n+ */\n+SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor)\n+\t: debayerParams_{ DebayerParams::kGain10, DebayerParams::kGain10,\n+\t\t\t DebayerParams::kGain10, 0.5f },\n+\t dmaHeap_(DmaHeap::DmaHeapFlag::Cma | DmaHeap::DmaHeapFlag::System)\n+{\n+\tif (!dmaHeap_.isValid()) {\n+\t\tLOG(SoftwareIsp, Error) << \"Failed to create DmaHeap object\";\n+\t\treturn;\n+\t}\n+\n+\tsharedParams_ = SharedMemObject<DebayerParams>(\"softIsp_params\");\n+\tif (!sharedParams_) {\n+\t\tLOG(SoftwareIsp, Error) << \"Failed to create shared memory for parameters\";\n+\t\treturn;\n+\t}\n+\n+\tauto stats = std::make_unique<SwStatsCpu>();\n+\tif (!stats->isValid()) {\n+\t\tLOG(SoftwareIsp, Error) << \"Failed to create SwStatsCpu object\";\n+\t\treturn;\n+\t}\n+\tstats->statsReady.connect(this, &SoftwareIsp::statsReady);\n+\n+\tdebayer_ = std::make_unique<DebayerCpu>(std::move(stats));\n+\tdebayer_->inputBufferReady.connect(this, &SoftwareIsp::inputReady);\n+\tdebayer_->outputBufferReady.connect(this, &SoftwareIsp::outputReady);\n+\n+\tipa_ = IPAManager::createIPA<ipa::soft::IPAProxySoft>(pipe, 0, 0);\n+\tif (!ipa_) {\n+\t\tLOG(SoftwareIsp, Error)\n+\t\t\t<< \"Creating IPA for software ISP failed\";\n+\t\tdebayer_.reset();\n+\t\treturn;\n+\t}\n+\n+\t/*\n+\t * The API tuning file is made from the sensor name. If the tuning file\n+\t * isn't found, fall back to the 'uncalibrated' file.\n+\t */\n+\tstd::string ipaTuningFile = ipa_->configurationFile(sensor->model() + \".yaml\");\n+\tif (ipaTuningFile.empty())\n+\t\tipaTuningFile = ipa_->configurationFile(\"uncalibrated.yaml\");\n+\n+\tint ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() },\n+\t\t\t debayer_->getStatsFD(),\n+\t\t\t sharedParams_.fd(),\n+\t\t\t sensor->controls());\n+\tif (ret) {\n+\t\tLOG(SoftwareIsp, Error) << \"IPA init failed\";\n+\t\tdebayer_.reset();\n+\t\treturn;\n+\t}\n+\n+\tipa_->setIspParams.connect(this, &SoftwareIsp::saveIspParams);\n+\tipa_->setSensorControls.connect(this, &SoftwareIsp::setSensorCtrls);\n+\n+\tdebayer_->moveToThread(&ispWorkerThread_);\n+}\n+\n+SoftwareIsp::~SoftwareIsp()\n+{\n+\t/* make sure to destroy the DebayerCpu before the ispWorkerThread_ is gone */\n+\tdebayer_.reset();\n+}\n+\n+/**\n+ * \\fn int SoftwareIsp::loadConfiguration([[maybe_unused]] const std::string &filename)\n+ * \\brief Load a configuration from a file\n+ * \\param[in] filename The file to load the configuration data from\n+ *\n+ * Currently is a stub doing nothing and always returning \"success\".\n+ *\n+ * \\return 0 on success\n+ */\n+\n+/**\n+ * \\brief Process the statistics gathered\n+ * \\param[in] sensorControls The sensor controls\n+ *\n+ * Requests the IPA to calculate new parameters for ISP and new control\n+ * values for the sensor.\n+ */\n+void SoftwareIsp::processStats(const ControlList &sensorControls)\n+{\n+\tASSERT(ipa_);\n+\tipa_->processStats(sensorControls);\n+}\n+\n+/**\n+ * \\brief Check the validity of Software Isp object\n+ * \\return True if Software Isp is valid, false otherwise\n+ */\n+bool SoftwareIsp::isValid() const\n+{\n+\treturn !!debayer_;\n+}\n+\n+/**\n+ * \\brief Get the output formats supported for the given input format\n+ * \\param[in] inputFormat The input format\n+ * \\return All the supported output formats or an empty vector if there are none\n+ */\n+std::vector<PixelFormat> SoftwareIsp::formats(PixelFormat inputFormat)\n+{\n+\tASSERT(debayer_);\n+\n+\treturn debayer_->formats(inputFormat);\n+}\n+\n+/**\n+ * \\brief Get the supported output sizes for the given input format and size\n+ * \\param[in] inputFormat The input format\n+ * \\param[in] inputSize The input frame size\n+ * \\return The valid size range or an empty range if there are none\n+ */\n+SizeRange SoftwareIsp::sizes(PixelFormat inputFormat, const Size &inputSize)\n+{\n+\tASSERT(debayer_);\n+\n+\treturn debayer_->sizes(inputFormat, inputSize);\n+}\n+\n+/**\n+ * Get the output stride and the frame size in bytes for the given output format and size\n+ * \\param[in] outputFormat The output format\n+ * \\param[in] size The output size (width and height in pixels)\n+ * \\return A tuple of the stride and the frame size in bytes, or a tuple of 0,0\n+ * if there is no valid output config\n+ */\n+std::tuple<unsigned int, unsigned int>\n+SoftwareIsp::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size)\n+{\n+\tASSERT(debayer_);\n+\n+\treturn debayer_->strideAndFrameSize(outputFormat, size);\n+}\n+\n+/**\n+ * \\brief Configure the SoftwareIsp object according to the passed in parameters\n+ * \\param[in] inputCfg The input configuration\n+ * \\param[in] outputCfgs The output configurations\n+ * \\param[in] sensorControls ControlInfoMap of the controls supported by the sensor\n+ * \\return 0 on success, a negative errno on failure\n+ */\n+int SoftwareIsp::configure(const StreamConfiguration &inputCfg,\n+\t\t\t const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs,\n+\t\t\t const ControlInfoMap &sensorControls)\n+{\n+\tASSERT(ipa_ && debayer_);\n+\n+\tint ret = ipa_->configure(sensorControls);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\treturn debayer_->configure(inputCfg, outputCfgs);\n+}\n+\n+/**\n+ * \\brief Export the buffers from the Software ISP\n+ * \\param[in] output Output stream index exporting the buffers\n+ * \\param[in] count Number of buffers to allocate\n+ * \\param[out] buffers Vector to store the allocated buffers\n+ * \\return The number of allocated buffers on success or a negative error code\n+ * otherwise\n+ */\n+int SoftwareIsp::exportBuffers(unsigned int output, unsigned int count,\n+\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n+{\n+\tASSERT(debayer_ != nullptr);\n+\n+\t/* single output for now */\n+\tif (output >= 1)\n+\t\treturn -EINVAL;\n+\n+\tfor (unsigned int i = 0; i < count; i++) {\n+\t\tconst std::string name = \"frame-\" + std::to_string(i);\n+\t\tconst size_t frameSize = debayer_->frameSize();\n+\n+\t\tFrameBuffer::Plane outPlane;\n+\t\toutPlane.fd = SharedFD(dmaHeap_.alloc(name.c_str(), frameSize));\n+\t\tif (!outPlane.fd.isValid()) {\n+\t\t\tLOG(SoftwareIsp, Error)\n+\t\t\t\t<< \"failed to allocate a dma_buf\";\n+\t\t\treturn -ENOMEM;\n+\t\t}\n+\t\toutPlane.offset = 0;\n+\t\toutPlane.length = frameSize;\n+\n+\t\tstd::vector<FrameBuffer::Plane> planes{ outPlane };\n+\t\tbuffers->emplace_back(std::make_unique<FrameBuffer>(std::move(planes)));\n+\t}\n+\n+\treturn count;\n+}\n+\n+/**\n+ * \\brief Queue buffers to Software ISP\n+ * \\param[in] input The input framebuffer\n+ * \\param[in] outputs The container holding the output stream indexes and\n+ * their respective frame buffer outputs\n+ * \\return 0 on success, a negative errno on failure\n+ */\n+int SoftwareIsp::queueBuffers(FrameBuffer *input,\n+\t\t\t const std::map<unsigned int, FrameBuffer *> &outputs)\n+{\n+\tunsigned int mask = 0;\n+\n+\t/*\n+\t * Validate the outputs as a sanity check: at least one output is\n+\t * required, all outputs must reference a valid stream and no two\n+\t * outputs can reference the same stream.\n+\t */\n+\tif (outputs.empty())\n+\t\treturn -EINVAL;\n+\n+\tfor (auto [index, buffer] : outputs) {\n+\t\tif (!buffer)\n+\t\t\treturn -EINVAL;\n+\t\tif (index >= 1) /* only single stream atm */\n+\t\t\treturn -EINVAL;\n+\t\tif (mask & (1 << index))\n+\t\t\treturn -EINVAL;\n+\n+\t\tmask |= 1 << index;\n+\t}\n+\n+\tprocess(input, outputs.at(0));\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Starts the Software ISP streaming operation\n+ * \\return 0 on success, any other value indicates an error\n+ */\n+int SoftwareIsp::start()\n+{\n+\tint ret = ipa_->start();\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tispWorkerThread_.start();\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Stops the Software ISP streaming operation\n+ */\n+void SoftwareIsp::stop()\n+{\n+\tispWorkerThread_.exit();\n+\tispWorkerThread_.wait();\n+\n+\tipa_->stop();\n+}\n+\n+/**\n+ * \\brief Passes the input framebuffer to the ISP worker to process\n+ * \\param[in] input The input framebuffer\n+ * \\param[out] output The framebuffer to write the processed frame to\n+ */\n+void SoftwareIsp::process(FrameBuffer *input, FrameBuffer *output)\n+{\n+\tdebayer_->invokeMethod(&DebayerCpu::process,\n+\t\t\t ConnectionTypeQueued, input, output, debayerParams_);\n+}\n+\n+void SoftwareIsp::saveIspParams([[maybe_unused]] int dummy)\n+{\n+\tdebayerParams_ = *sharedParams_;\n+}\n+\n+void SoftwareIsp::setSensorCtrls(const ControlList &sensorControls)\n+{\n+\tsetSensorControls.emit(sensorControls);\n+}\n+\n+void SoftwareIsp::statsReady()\n+{\n+\tispStatsReady.emit();\n+}\n+\n+void SoftwareIsp::inputReady(FrameBuffer *input)\n+{\n+\tinputBufferReady.emit(input);\n+}\n+\n+void SoftwareIsp::outputReady(FrameBuffer *output)\n+{\n+\toutputBufferReady.emit(output);\n+}\n+\n+} /* namespace libcamera */\n", "prefixes": [ "v7", "11/18" ] }