Patch Detail
Show a patch.
GET /api/patches/24403/?format=api
{ "id": 24403, "url": "https://patchwork.libcamera.org/api/patches/24403/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24403/", "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": "<20250918144333.108695-15-stefan.klug@ideasonboard.com>", "date": "2025-09-18T14:43:23", "name": "[v4,14/19] pipeline: rkisp1: Query kernel for available params blocks", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "bb886f1e280a8693e17e63124845fad71df1b6ef", "submitter": { "id": 184, "url": "https://patchwork.libcamera.org/api/people/184/?format=api", "name": "Stefan Klug", "email": "stefan.klug@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24403/mbox/", "series": [ { "id": 5449, "url": "https://patchwork.libcamera.org/api/series/5449/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5449", "date": "2025-09-18T14:43:09", "name": "Implement WDR algorithm", "version": 4, "mbox": "https://patchwork.libcamera.org/series/5449/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24403/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24403/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 15D41C32C2\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Sep 2025 14:44:31 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3FC4B69393;\n\tThu, 18 Sep 2025 16:44:30 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A6F8169381\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Sep 2025 16:44:26 +0200 (CEST)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:ace3:d2c2:5eff:9cc5])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 0077211A0; \n\tThu, 18 Sep 2025 16:43:06 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"veNbwoCi\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1758206587;\n\tbh=scmlFwdbIe+fIqe2Sj6Wfh2X/yfx+QY8OGc0XOMkJis=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=veNbwoCibS/owqCfRzgfQF9Ok5orgLMjWUVun6vFYODDb/K0FVpYjqBVOs5LjwGdh\n\tF6idvBtA+js1Vljg/Q45bzcPY8QpEDjXZ+tN9kUhy3DJVkTjBqYfmnSaXt+aHFpGXL\n\trGP4TEYbAtNej7nOHfdW+3MbQBvJ/Ecw747Ci0l4=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>", "Subject": "[PATCH v4 14/19] pipeline: rkisp1: Query kernel for available params\n\tblocks", "Date": "Thu, 18 Sep 2025 16:43:23 +0200", "Message-ID": "<20250918144333.108695-15-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.48.1", "In-Reply-To": "<20250918144333.108695-1-stefan.klug@ideasonboard.com>", "References": "<20250918144333.108695-1-stefan.klug@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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": "Query the params device for RKISP1_CID_SUPPORTED_PARAMS_BLOCKS and\ninject the information into the IPA hardware context for use by the\nalgorithms.\n\nTo be able to modify the hardware configuration at runtime, replace the\npointer with an instance and create a copy of the static hardware\nspecific data.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\n\nChanges in v4:\n- Keep the static data const and create a copy of the configuration to\n be able to modify it.\n\nChanges in v3:\n- Removed unnecessary log statement\n- Collected tags\n- Added case for getControls() failing internally\n---\n include/libcamera/ipa/rkisp1.mojom | 2 +-\n src/ipa/rkisp1/algorithms/agc.cpp | 10 ++++----\n src/ipa/rkisp1/algorithms/blc.cpp | 4 ++--\n src/ipa/rkisp1/algorithms/compress.cpp | 2 +-\n src/ipa/rkisp1/algorithms/goc.cpp | 4 ++--\n src/ipa/rkisp1/algorithms/lux.cpp | 2 +-\n src/ipa/rkisp1/ipa_context.h | 5 ++--\n src/ipa/rkisp1/rkisp1.cpp | 12 +++++++---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 29 ++++++++++++++++++++----\n 9 files changed, 49 insertions(+), 21 deletions(-)", "diff": "diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom\nindex 043ad27ea199..068e898848c4 100644\n--- a/include/libcamera/ipa/rkisp1.mojom\n+++ b/include/libcamera/ipa/rkisp1.mojom\n@@ -16,7 +16,7 @@ struct IPAConfigInfo {\n \n interface IPARkISP1Interface {\n \tinit(libcamera.IPASettings settings,\n-\t uint32 hwRevision,\n+\t uint32 hwRevision, uint32 supportedBlocks,\n \t libcamera.IPACameraSensorInfo sensorInfo,\n \t libcamera.ControlInfoMap sensorControls)\n \t\t=> (int32 ret, libcamera.ControlInfoMap ipaControls);\ndiff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 174d810edc65..d0337fd0027f 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -56,7 +56,7 @@ int Agc::parseMeteringModes(IPAContext &context, const YamlObject &tuningData)\n \n \t\tstd::vector<uint8_t> weights =\n \t\t\tvalue.getList<uint8_t>().value_or(std::vector<uint8_t>{});\n-\t\tif (weights.size() != context.hw->numHistogramWeights) {\n+\t\tif (weights.size() != context.hw.numHistogramWeights) {\n \t\t\tLOG(RkISP1Agc, Warning)\n \t\t\t\t<< \"Failed to read metering mode'\" << key << \"'\";\n \t\t\tcontinue;\n@@ -68,7 +68,7 @@ int Agc::parseMeteringModes(IPAContext &context, const YamlObject &tuningData)\n \tif (meteringModes_.empty()) {\n \t\tLOG(RkISP1Agc, Warning)\n \t\t\t<< \"No metering modes read from tuning file; defaulting to matrix\";\n-\t\tstd::vector<uint8_t> weights(context.hw->numHistogramWeights, 1);\n+\t\tstd::vector<uint8_t> weights(context.hw.numHistogramWeights, 1);\n \n \t\tmeteringModes_[controls::MeteringMatrix] = weights;\n \t}\n@@ -418,7 +418,7 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,\n \n \tSpan<uint8_t> weights{\n \t\thstConfig->hist_weight,\n-\t\tcontext.hw->numHistogramWeights\n+\t\tcontext.hw.numHistogramWeights\n \t};\n \tstd::vector<uint8_t> &modeWeights = meteringModes_.at(frameContext.agc.meteringMode);\n \tstd::copy(modeWeights.begin(), modeWeights.end(), weights.begin());\n@@ -556,9 +556,9 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \tconst rkisp1_cif_isp_stat *params = &stats->params;\n \n \t/* The lower 4 bits are fractional and meant to be discarded. */\n-\tHistogram hist({ params->hist.hist_bins, context.hw->numHistogramBins },\n+\tHistogram hist({ params->hist.hist_bins, context.hw.numHistogramBins },\n \t\t [](uint32_t x) { return x >> 4; });\n-\texpMeans_ = { params->ae.exp_mean, context.hw->numAeCells };\n+\texpMeans_ = { params->ae.exp_mean, context.hw.numAeCells };\n \tstd::vector<uint8_t> &modeWeights = meteringModes_.at(frameContext.agc.meteringMode);\n \tweights_ = { modeWeights.data(), modeWeights.size() };\n \ndiff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp\nindex 98cb7145e164..32fc44ffff92 100644\n--- a/src/ipa/rkisp1/algorithms/blc.cpp\n+++ b/src/ipa/rkisp1/algorithms/blc.cpp\n@@ -114,7 +114,7 @@ int BlackLevelCorrection::configure(IPAContext &context,\n \t * of the extensible parameters format.\n \t */\n \tsupported_ = context.configuration.paramFormat == V4L2_META_FMT_RK_ISP1_EXT_PARAMS ||\n-\t\t !context.hw->compand;\n+\t\t !context.hw.compand;\n \n \tif (!supported_)\n \t\tLOG(RkISP1Blc, Warning)\n@@ -140,7 +140,7 @@ void BlackLevelCorrection::prepare(IPAContext &context,\n \tif (!supported_)\n \t\treturn;\n \n-\tif (context.hw->compand) {\n+\tif (context.hw.compand) {\n \t\tauto config = params->block<BlockType::CompandBls>();\n \t\tconfig.setEnabled(true);\n \ndiff --git a/src/ipa/rkisp1/algorithms/compress.cpp b/src/ipa/rkisp1/algorithms/compress.cpp\nindex c31d71bd50d5..a45b651d94ef 100644\n--- a/src/ipa/rkisp1/algorithms/compress.cpp\n+++ b/src/ipa/rkisp1/algorithms/compress.cpp\n@@ -53,7 +53,7 @@ int Compress::configure(IPAContext &context,\n \t\t\t[[maybe_unused]] const IPACameraSensorInfo &configInfo)\n {\n \tif (context.configuration.paramFormat != V4L2_META_FMT_RK_ISP1_EXT_PARAMS ||\n-\t !context.hw->compand) {\n+\t !context.hw.compand) {\n \t\tLOG(RkISP1Compress, Warning)\n \t\t\t<< \"Compression is not supported by the hardware or kernel.\";\n \t\treturn 0;\ndiff --git a/src/ipa/rkisp1/algorithms/goc.cpp b/src/ipa/rkisp1/algorithms/goc.cpp\nindex a9493678dba7..a0e7030fe5db 100644\n--- a/src/ipa/rkisp1/algorithms/goc.cpp\n+++ b/src/ipa/rkisp1/algorithms/goc.cpp\n@@ -50,7 +50,7 @@ const float kDefaultGamma = 2.2f;\n */\n int GammaOutCorrection::init(IPAContext &context, const YamlObject &tuningData)\n {\n-\tif (context.hw->numGammaOutSamples !=\n+\tif (context.hw.numGammaOutSamples !=\n \t RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10) {\n \t\tLOG(RkISP1Gamma, Error)\n \t\t\t<< \"Gamma is not implemented for RkISP1 V12\";\n@@ -101,7 +101,7 @@ void GammaOutCorrection::prepare(IPAContext &context,\n \t\t\t\t IPAFrameContext &frameContext,\n \t\t\t\t RkISP1Params *params)\n {\n-\tASSERT(context.hw->numGammaOutSamples ==\n+\tASSERT(context.hw.numGammaOutSamples ==\n \t RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10);\n \n \tif (!frameContext.goc.update)\ndiff --git a/src/ipa/rkisp1/algorithms/lux.cpp b/src/ipa/rkisp1/algorithms/lux.cpp\nindex dd05f18d5e94..e8da69810008 100644\n--- a/src/ipa/rkisp1/algorithms/lux.cpp\n+++ b/src/ipa/rkisp1/algorithms/lux.cpp\n@@ -61,7 +61,7 @@ void Lux::process(IPAContext &context,\n \n \t/* \\todo Deduplicate the histogram calculation from AGC */\n \tconst rkisp1_cif_isp_stat *params = &stats->params;\n-\tHistogram yHist({ params->hist.hist_bins, context.hw->numHistogramBins },\n+\tHistogram yHist({ params->hist.hist_bins, context.hw.numHistogramBins },\n \t\t\t[](uint32_t x) { return x >> 4; });\n \n \tdouble lux = lux_.estimateLux(exposureTime, gain, 1.0, yHist);\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex 35d25d555e65..67427c01ac68 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -36,6 +36,7 @@ struct IPAHwSettings {\n \tunsigned int numHistogramBins;\n \tunsigned int numHistogramWeights;\n \tunsigned int numGammaOutSamples;\n+\tuint32_t supportedBlocks;\n \tbool compand;\n };\n \n@@ -201,11 +202,11 @@ struct IPAFrameContext : public FrameContext {\n \n struct IPAContext {\n \tIPAContext(unsigned int frameContextSize)\n-\t\t: hw(nullptr), frameContexts(frameContextSize)\n+\t\t: frameContexts(frameContextSize)\n \t{\n \t}\n \n-\tconst IPAHwSettings *hw;\n+\tIPAHwSettings hw;\n \tIPACameraSensorInfo sensorInfo;\n \tIPASessionConfiguration configuration;\n \tIPAActiveState activeState;\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex cf66d5553dcd..fa22bfc34904 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -52,6 +52,7 @@ public:\n \tIPARkISP1();\n \n \tint init(const IPASettings &settings, unsigned int hwRevision,\n+\t\t uint32_t supportedBlocks,\n \t\t const IPACameraSensorInfo &sensorInfo,\n \t\t const ControlInfoMap &sensorControls,\n \t\t ControlInfoMap *ipaControls) override;\n@@ -94,6 +95,7 @@ const IPAHwSettings ipaHwSettingsV10{\n \tRKISP1_CIF_ISP_HIST_BIN_N_MAX_V10,\n \tRKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10,\n \tRKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10,\n+\t0,\n \tfalse,\n };\n \n@@ -102,6 +104,7 @@ const IPAHwSettings ipaHwSettingsIMX8MP{\n \tRKISP1_CIF_ISP_HIST_BIN_N_MAX_V10,\n \tRKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10,\n \tRKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10,\n+\t0,\n \ttrue,\n };\n \n@@ -110,6 +113,7 @@ const IPAHwSettings ipaHwSettingsV12{\n \tRKISP1_CIF_ISP_HIST_BIN_N_MAX_V12,\n \tRKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12,\n \tRKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12,\n+\t0,\n \tfalse,\n };\n \n@@ -132,6 +136,7 @@ std::string IPARkISP1::logPrefix() const\n }\n \n int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,\n+\t\t uint32_t supportedBlocks,\n \t\t const IPACameraSensorInfo &sensorInfo,\n \t\t const ControlInfoMap &sensorControls,\n \t\t ControlInfoMap *ipaControls)\n@@ -139,13 +144,13 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,\n \t/* \\todo Add support for other revisions */\n \tswitch (hwRevision) {\n \tcase RKISP1_V10:\n-\t\tcontext_.hw = &ipaHwSettingsV10;\n+\t\tcontext_.hw = ipaHwSettingsV10;\n \t\tbreak;\n \tcase RKISP1_V_IMX8MP:\n-\t\tcontext_.hw = &ipaHwSettingsIMX8MP;\n+\t\tcontext_.hw = ipaHwSettingsIMX8MP;\n \t\tbreak;\n \tcase RKISP1_V12:\n-\t\tcontext_.hw = &ipaHwSettingsV12;\n+\t\tcontext_.hw = ipaHwSettingsV12;\n \t\tbreak;\n \tdefault:\n \t\tLOG(IPARkISP1, Error)\n@@ -153,6 +158,7 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,\n \t\t\t<< \" is currently not supported\";\n \t\treturn -ENODEV;\n \t}\n+\tcontext_.hw.supportedBlocks = supportedBlocks;\n \n \tLOG(IPARkISP1, Debug) << \"Hardware revision is \" << hwRevision;\n \ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex a91a443aeaf7..ecd13831539f 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -100,7 +100,7 @@ public:\n \n \tPipelineHandlerRkISP1 *pipe();\n \tconst PipelineHandlerRkISP1 *pipe() const;\n-\tint loadIPA(unsigned int hwRevision);\n+\tint loadIPA(unsigned int hwRevision, uint32_t supportedBlocks);\n \n \tStream mainPathStream_;\n \tStream selfPathStream_;\n@@ -383,7 +383,7 @@ const PipelineHandlerRkISP1 *RkISP1CameraData::pipe() const\n \treturn static_cast<const PipelineHandlerRkISP1 *>(Camera::Private::pipe());\n }\n \n-int RkISP1CameraData::loadIPA(unsigned int hwRevision)\n+int RkISP1CameraData::loadIPA(unsigned int hwRevision, uint32_t supportedBlocks)\n {\n \tipa_ = IPAManager::createIPA<ipa::rkisp1::IPAProxyRkISP1>(pipe(), 1, 1);\n \tif (!ipa_)\n@@ -405,7 +405,8 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision)\n \t}\n \n \tret = ipa_->init({ ipaTuningFile, sensor_->model() }, hwRevision,\n-\t\t\t sensorInfo, sensor_->controls(), &ipaControls_);\n+\t\t\t supportedBlocks, sensorInfo, sensor_->controls(),\n+\t\t\t &ipaControls_);\n \tif (ret < 0) {\n \t\tLOG(RkISP1, Error) << \"IPA initialization failure\";\n \t\treturn ret;\n@@ -1313,6 +1314,12 @@ int PipelineHandlerRkISP1::updateControls(RkISP1CameraData *data)\n \treturn 0;\n }\n \n+/*\n+ * By default we assume all the blocks that were included in the first\n+ * extensible parameters series are available. That is the lower 20bits.\n+ */\n+const uint32_t kDefaultExtParamsBlocks = 0xfffff;\n+\n int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)\n {\n \tint ret;\n@@ -1350,7 +1357,21 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)\n \tisp_->frameStart.connect(data->delayedCtrls_.get(),\n \t\t\t\t &DelayedControls::applyControls);\n \n-\tret = data->loadIPA(media_->hwRevision());\n+\tuint32_t supportedBlocks = kDefaultExtParamsBlocks;\n+\n+\tauto &controls = param_->controls();\n+\tif (controls.find(RKISP1_CID_SUPPORTED_PARAMS_BLOCKS) != controls.end()) {\n+\t\tauto list = param_->getControls({ { RKISP1_CID_SUPPORTED_PARAMS_BLOCKS } });\n+\t\tif (!list.empty())\n+\t\t\tsupportedBlocks = static_cast<uint32_t>(\n+\t\t\t\tlist.get(RKISP1_CID_SUPPORTED_PARAMS_BLOCKS)\n+\t\t\t\t\t.get<int32_t>());\n+\t} else {\n+\t\tLOG(RkISP1, Error)\n+\t\t\t<< \"Failed to query supported params blocks. Falling back to defaults.\";\n+\t}\n+\n+\tret = data->loadIPA(media_->hwRevision(), supportedBlocks);\n \tif (ret)\n \t\treturn ret;\n \n", "prefixes": [ "v4", "14/19" ] }