Patch Detail
Show a patch.
GET /api/patches/25827/?format=api
{ "id": 25827, "url": "https://patchwork.libcamera.org/api/patches/25827/?format=api", "web_url": "https://patchwork.libcamera.org/patch/25827/", "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": "<20260118202953.1554892-3-rui.wang@ideasonboard.com>", "date": "2026-01-18T20:29:51", "name": "[v1,2/4] pa: rkisp1: algorithms: filter: Add helper fun and sharpness presets", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "e1a87f4b702a9f3c735042bf8517763f86f7a078", "submitter": { "id": 241, "url": "https://patchwork.libcamera.org/api/people/241/?format=api", "name": "Rui Wang", "email": "rui.wang@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/25827/mbox/", "series": [ { "id": 5712, "url": "https://patchwork.libcamera.org/api/series/5712/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5712", "date": "2026-01-18T20:29:49", "name": "Filter algorithm refactoring and mode switching", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5712/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/25827/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/25827/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 93910BDCBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 18 Jan 2026 20:30:49 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4F4C861FC1;\n\tSun, 18 Jan 2026 21:30:49 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A144B61FB9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 18 Jan 2026 21:30:47 +0100 (CET)", "from rui-Precision-7560.local (unknown [209.216.103.65])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 65CCF1BA;\n\tSun, 18 Jan 2026 21:30:17 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"BCFtaLs7\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768768217;\n\tbh=EN+gD+60+RQ71IAR2RSCziVEWdBfA3CuEyD0y+lE4Qc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=BCFtaLs7LIjP+v40pOGmtlUyXsLfzgjXbFuCI+lWBI99in8Na2OEpmRCg75gfsCLm\n\tLnTQV9kC/EOrhs/iI7CLzrthu3BLOamw3WcRqjIhIfwSFDmB4TXtmVFWXFem/hmY/s\n\tzr9QstmpAJyL9T9y4wj1cz5vIzVOiY3AxZ9isxoE=", "From": "Rui Wang <rui.wang@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Rui Wang <rui.wang@ideasonboard.com>", "Subject": "[PATCH v1 2/4] pa: rkisp1: algorithms: filter: Add helper fun and\n\tsharpness presets", "Date": "Sun, 18 Jan 2026 15:29:51 -0500", "Message-ID": "<20260118202953.1554892-3-rui.wang@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260118202953.1554892-1-rui.wang@ideasonboard.com>", "References": "<20260118202953.1554892-1-rui.wang@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": "Refactor the Filter algorithm to improve code organization and prepare\nfor future sharpness control implementation.\n\nAdd helper functions to separate concerns:\n- prepareDisabledMode(): Handle filter disable state\n- prepareEnabledMode(): Handle filter enable state with logging\n- logConfig(): Provide detailed filter configuration logging\n\nIntroduce sharpness preset table (kSharpnessPresets) with 11 levels\n(0-10) defining sharpness factor combinations. These presets will be\nused in future commits to implement user-controllable sharpness levels.\n\nMove class documentation to follow the anonymous namespace for better\ncode organization and consistency with other algorithms.\n\nNo functional changes in this commit.\n\nSigned-off-by: Rui Wang <rui.wang@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/filter.cpp | 85 +++++++++++++++++++++++-----\n src/ipa/rkisp1/algorithms/filter.h | 7 +++\n 2 files changed, 79 insertions(+), 13 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/algorithms/filter.cpp b/src/ipa/rkisp1/algorithms/filter.cpp\nindex 321e4122..eb4049fd 100644\n--- a/src/ipa/rkisp1/algorithms/filter.cpp\n+++ b/src/ipa/rkisp1/algorithms/filter.cpp\n@@ -27,19 +27,6 @@ namespace libcamera {\n \n namespace ipa::rkisp1::algorithms {\n \n-/**\n- * \\class Filter\n- * \\brief RkISP1 Filter control\n- *\n- * Denoise and Sharpness filters will be applied by RkISP1 during the\n- * demosaicing step. The denoise filter is responsible for removing noise from\n- * the image, while the sharpness filter will enhance its acutance.\n- *\n- * \\todo In current version the denoise and sharpness control is based on user\n- * controls. In a future version it should be controlled automatically by the\n- * algorithm.\n- */\n-\n LOG_DEFINE_CATEGORY(RkISP1Filter)\n \n namespace {\n@@ -67,8 +54,44 @@ std::string modeName(int32_t mode)\n \n \treturn \"ReductionUnknown\";\n }\n+\n+struct SharpnessPreset {\n+\tuint32_t fac_sh0;\n+\tuint32_t fac_sh1;\n+\tuint32_t fac_mid;\n+\tuint32_t fac_bl0;\n+\tuint32_t fac_bl1;\n+};\n+\n+/*\n+ * Sharpness presets\n+ * The presets are based on the following table.\n+ */\n+static constexpr SharpnessPreset kSharpnessPresets[] = {\n+\t{ 0x04, 0x04, 0x04, 0x02, 0x00 }, /* Level 0 */\n+\t{ 0x07, 0x08, 0x06, 0x02, 0x00 }, /* Level 1 */\n+\t{ 0x0a, 0x0c, 0x08, 0x04, 0x00 }, /* Level 2 */\n+\t{ 0x0c, 0x10, 0x0a, 0x06, 0x02 }, /* Level 3 */\n+\t{ 0x10, 0x16, 0x0c, 0x08, 0x04 }, /* Level 4 */\n+\t{ 0x14, 0x1b, 0x10, 0x0a, 0x04 }, /* Level 5 */\n+\t{ 0x1a, 0x20, 0x13, 0x0c, 0x06 }, /* Level 6 */\n+\t{ 0x1e, 0x26, 0x17, 0x10, 0x08 }, /* Level 7 */\n+\t{ 0x24, 0x2c, 0x1d, 0x15, 0x0d }, /* Level 8 */\n+\t{ 0x2a, 0x30, 0x22, 0x1a, 0x14 }, /* Level 9 */\n+\t{ 0x30, 0x3f, 0x28, 0x24, 0x20 }, /* Level 10 */\n+};\n } /* namespace */\n \n+\n+/**\n+ * \\class Filter\n+ * \\brief RkISP1 Filter control\n+ *\n+ * Denoise and Sharpness filters will be applied by RkISP1 during the\n+ * demosaicing step. The denoise filter is responsible for removing noise from\n+ * the image, while the sharpness filter will enhance its acutance.\n+ */\n+\n Filter::Filter()\n \t: noiseReductionModes_({}),\n \t activeMode_(noiseReductionModes_.end())\n@@ -365,6 +388,42 @@ void Filter::prepare([[maybe_unused]] IPAContext &context,\n \t}\n }\n \n+void Filter::prepareDisabledMode(RkISP1Params *params)\n+{\n+\tauto config = params->block<BlockType::Flt>();\n+\tconfig.setEnabled(false);\n+}\n+\n+void Filter::prepareEnabledMode(const uint32_t frame,\n+\t\t\t\tIPAFrameContext &frameContext,\n+\t\t\t\tRkISP1Params *params)\n+{\n+\tauto config = params->block<BlockType::Flt>();\n+\tconfig.setEnabled(true);\n+\n+\tif (frameContext.filter.update || frame == 0)\n+\t\tlogConfig(*config);\n+}\n+\n+void Filter::logConfig(const struct rkisp1_cif_isp_flt_config &config)\n+{\n+\tLOG(RkISP1Filter, Debug)\n+\t\t<< \"Filter config: mode=\" << config.mode\n+\t\t<< \" lum_weight=\" << config.lum_weight\n+\t\t<< \" grn_stage1=\" << (int)config.grn_stage1\n+\t\t<< \" chr_h_mode=\" << (int)config.chr_h_mode\n+\t\t<< \" chr_v_mode=\" << (int)config.chr_v_mode\n+\t\t<< \" thresh_bl0=\" << config.thresh_bl0\n+\t\t<< \" thresh_bl1=\" << config.thresh_bl1\n+\t\t<< \" thresh_sh0=\" << config.thresh_sh0\n+\t\t<< \" thresh_sh1=\" << config.thresh_sh1\n+\t\t<< \" fac_sh1=\" << config.fac_sh1\n+\t\t<< \" fac_sh0=\" << config.fac_sh0\n+\t\t<< \" fac_mid=\" << config.fac_mid\n+\t\t<< \" fac_bl0=\" << config.fac_bl0\n+\t\t<< \" fac_bl1=\" << config.fac_bl1;\n+}\n+\n REGISTER_IPA_ALGORITHM(Filter, \"Filter\")\n \n } /* namespace ipa::rkisp1::algorithms */\ndiff --git a/src/ipa/rkisp1/algorithms/filter.h b/src/ipa/rkisp1/algorithms/filter.h\nindex 3860adfd..19cf76d0 100644\n--- a/src/ipa/rkisp1/algorithms/filter.h\n+++ b/src/ipa/rkisp1/algorithms/filter.h\n@@ -40,6 +40,13 @@ private:\n \t\t\t struct rkisp1_cif_isp_flt_config &config);\n \n \tbool loadConfig(int32_t mode);\n+\n+\tvoid logConfig(const struct rkisp1_cif_isp_flt_config &config);\n+\tvoid prepareDisabledMode(RkISP1Params *params);\n+\tvoid prepareEnabledMode(const uint32_t frame,\n+\t\t\t\tIPAFrameContext &frameContext,\n+\t\t\t\tRkISP1Params *params);\n+\n \tstd::vector<ModeConfig> noiseReductionModes_;\n \tstd::vector<ModeConfig>::const_iterator activeMode_;\n };\n", "prefixes": [ "v1", "2/4" ] }