Patch Detail
Show a patch.
GET /api/patches/17854/?format=api
{ "id": 17854, "url": "https://patchwork.libcamera.org/api/patches/17854/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17854/", "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": "<20221124025133.17875-4-laurent.pinchart@ideasonboard.com>", "date": "2022-11-24T02:51:27", "name": "[libcamera-devel,v4,3/9] ipa: rkisp1: Support raw capture in IPA operations", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "ab8f87c9b6bd88ba63f0b948906929623e4e709d", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17854/mbox/", "series": [ { "id": 3634, "url": "https://patchwork.libcamera.org/api/series/3634/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3634", "date": "2022-11-24T02:51:24", "name": "Add Bayer format support for RkISP1", "version": 4, "mbox": "https://patchwork.libcamera.org/series/3634/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17854/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17854/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 9528CBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Nov 2022 02:51:57 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2E0046331A;\n\tThu, 24 Nov 2022 03:51:57 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 74B3863316\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 03:51:54 +0100 (CET)", "from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E31837FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 03:51:53 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669258317;\n\tbh=rLVvinFiJ0iEgC2rv4fnV9rCavXASkwU+sf8AON4LRw=;\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:\n\tFrom;\n\tb=D+atPvl1bcCUW/bQq3eWUDUk1EBAOeMQiViHTfU31ImaeqKsOa3cfezIa32ivwvnA\n\tSdwjO5KWjcE4Oqi3Lqql8rQjebMgvRktFVzjhL3Ac4IqQ41B+ksnyaPEs8Vbs6IdnJ\n\tewN3TmL1H2+2x93r4oLuLAc8X268PAhMd0Zuo8s4A1/cUCGCQqwsVGlfzvNTht79p7\n\tNkmnOkbX/nwqeiSuKpdA0vM+VgGdHyZtx27fLqioEtYYCoB+wDQaBGHxV31e/05Ggb\n\tdh+Zl3rpq7KWBtbWqi14mSUJLNHWWBLN6gAMUBabj/prtRlNyabUcdQ3fLAppQsVfB\n\thpE9rU09wiesw==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669258314;\n\tbh=rLVvinFiJ0iEgC2rv4fnV9rCavXASkwU+sf8AON4LRw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=vAtQi8MMzuu0tma3Pi954H7i/YkTd6jKIMnUIuEikLSHkDQ/Bhi2k1vh9RhZQqezl\n\ta0zhWt4tw00p/3gb2nxI8yDZY5SyIm4Z3nzK1wU3Gk2Mf5KyHX48QiOk/nBOTELj3v\n\tgnSPI5wPIOa8HG+7xtgp5OebPq0KcDz0mTkKoKV8=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"vAtQi8MM\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 24 Nov 2022 04:51:27 +0200", "Message-Id": "<20221124025133.17875-4-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.37.4", "In-Reply-To": "<20221124025133.17875-1-laurent.pinchart@ideasonboard.com>", "References": "<20221124025133.17875-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 3/9] ipa: rkisp1: Support raw capture\n\tin IPA operations", "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": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The RkISP1 can capture raw frames by bypassing the ISP. In that mode,\nthe ISP will not produce statistics nor consume parameters. Most\nalgorithms will thus be unable to run, with one exception: the AGC will\nstill be able to configure the sensor exposure time and analog gain in\nmanual mode.\n\nTo prepare for this, add the ability to disable algorithms for the\nduration of the capture session based on the camera configuration.\nIndividual algorithms report whether they support raw formats at\nconstruction time, and the IPA module disables algorithms in configure()\nbased on the stream configurations.\n\nDisabled algorithms are skipped during the capture session in the\nprocessStatsBuffer() operation. As the ISP doesn't produce statistics,\ndon't try to access the stats buffer. There is no need for similar logic\nin fillParamsBuffer() as that operation won't be called for raw capture.\n\nAll algorithms report not supporting raw capture by default. Raw support\nin AGC will be added separately.\n\nThe feature is implemented in the RkISP1 module without any support from\nlibipa at this point to avoid designing a generic API based on a single\nuser. This may be changed in the future.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nChanges since v3:\n\n- Initialize stats to nullptr by default\n---\n src/ipa/rkisp1/algorithms/algorithm.h | 12 +++++++-\n src/ipa/rkisp1/ipa_context.cpp | 5 ++++\n src/ipa/rkisp1/ipa_context.h | 2 ++\n src/ipa/rkisp1/rkisp1.cpp | 40 +++++++++++++++++++++++----\n 4 files changed, 52 insertions(+), 7 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/algorithms/algorithm.h b/src/ipa/rkisp1/algorithms/algorithm.h\nindex c3212cff76fe..9454c9a1fc06 100644\n--- a/src/ipa/rkisp1/algorithms/algorithm.h\n+++ b/src/ipa/rkisp1/algorithms/algorithm.h\n@@ -15,7 +15,17 @@ namespace libcamera {\n \n namespace ipa::rkisp1 {\n \n-using Algorithm = libcamera::ipa::Algorithm<Module>;\n+class Algorithm : public libcamera::ipa::Algorithm<Module>\n+{\n+public:\n+\tAlgorithm()\n+\t\t: disabled_(false), supportsRaw_(false)\n+\t{\n+\t}\n+\n+\tbool disabled_;\n+\tbool supportsRaw_;\n+};\n \n } /* namespace ipa::rkisp1 */\n \ndiff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\nindex 7a987497bd03..9bbf368432fa 100644\n--- a/src/ipa/rkisp1/ipa_context.cpp\n+++ b/src/ipa/rkisp1/ipa_context.cpp\n@@ -89,6 +89,11 @@ namespace libcamera::ipa::rkisp1 {\n * \\brief Sensor output resolution\n */\n \n+/**\n+ * \\var IPASessionConfiguration::raw\n+ * \\brief Indicates if the camera is configured to capture raw frames\n+ */\n+\n /**\n * \\struct IPAActiveState\n * \\brief Active state for algorithms\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex bb60ab9eab72..3e47ac663c58 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -48,6 +48,8 @@ struct IPASessionConfiguration {\n \tstruct {\n \t\trkisp1_cif_isp_version revision;\n \t} hw;\n+\n+\tbool raw;\n };\n \n struct IPAActiveState {\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 9265d3c9f53c..6ac29df8ec8d 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -24,6 +24,7 @@\n #include <libcamera/ipa/rkisp1_ipa_interface.h>\n #include <libcamera/request.h>\n \n+#include \"libcamera/internal/formats.h\"\n #include \"libcamera/internal/mapped_framebuffer.h\"\n #include \"libcamera/internal/yaml_parser.h\"\n \n@@ -207,7 +208,7 @@ void IPARkISP1::stop()\n }\n \n int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,\n-\t\t\t [[maybe_unused]] const std::map<uint32_t, IPAStream> &streamConfig,\n+\t\t\t const std::map<uint32_t, IPAStream> &streamConfig,\n \t\t\t ControlInfoMap *ipaControls)\n {\n \tsensorControls_ = ipaConfig.sensorControls;\n@@ -255,7 +256,21 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,\n \tcontext_.configuration.sensor.minAnalogueGain = camHelper_->gain(minGain);\n \tcontext_.configuration.sensor.maxAnalogueGain = camHelper_->gain(maxGain);\n \n-\tfor (auto const &algo : algorithms()) {\n+\tcontext_.configuration.raw = std::any_of(streamConfig.begin(), streamConfig.end(),\n+\t\t[](auto &cfg) -> bool {\n+\t\t\tPixelFormat pixelFormat{ cfg.second.pixelFormat };\n+\t\t\tconst PixelFormatInfo &format = PixelFormatInfo::info(pixelFormat);\n+\t\t\treturn format.colourEncoding == PixelFormatInfo::ColourEncodingRAW;\n+\t\t});\n+\n+\tfor (auto const &a : algorithms()) {\n+\t\tAlgorithm *algo = static_cast<Algorithm *>(a.get());\n+\n+\t\t/* Disable algorithms that don't support raw formats. */\n+\t\talgo->disabled_ = context_.configuration.raw && !algo->supportsRaw_;\n+\t\tif (algo->disabled_)\n+\t\t\tcontinue;\n+\n \t\tint ret = algo->configure(context_, info);\n \t\tif (ret)\n \t\t\treturn ret;\n@@ -298,8 +313,12 @@ void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls)\n {\n \tIPAFrameContext &frameContext = context_.frameContexts.alloc(frame);\n \n-\tfor (auto const &algo : algorithms())\n+\tfor (auto const &a : algorithms()) {\n+\t\tAlgorithm *algo = static_cast<Algorithm *>(a.get());\n+\t\tif (algo->disabled_)\n+\t\t\tcontinue;\n \t\talgo->queueRequest(context_, frame, frameContext, controls);\n+\t}\n }\n \n void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)\n@@ -324,8 +343,13 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId\n {\n \tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n \n-\tconst rkisp1_stat_buffer *stats =\n-\t\treinterpret_cast<rkisp1_stat_buffer *>(\n+\t/*\n+\t * In raw capture mode, the ISP is bypassed and no statistics buffer is\n+\t * provided.\n+\t */\n+\tconst rkisp1_stat_buffer *stats = nullptr;\n+\tif (!context_.configuration.raw)\n+\t\tstats = reinterpret_cast<rkisp1_stat_buffer *>(\n \t\t\tmappedBuffers_.at(bufferId).planes()[0].data());\n \n \tframeContext.sensor.exposure =\n@@ -335,8 +359,12 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId\n \n \tControlList metadata(controls::controls);\n \n-\tfor (auto const &algo : algorithms())\n+\tfor (auto const &a : algorithms()) {\n+\t\tAlgorithm *algo = static_cast<Algorithm *>(a.get());\n+\t\tif (algo->disabled_)\n+\t\t\tcontinue;\n \t\talgo->process(context_, frame, frameContext, stats, metadata);\n+\t}\n \n \tsetControls(frame);\n \n", "prefixes": [ "libcamera-devel", "v4", "3/9" ] }