Patch Detail
Show a patch.
GET /api/1.1/patches/21041/?format=api
{ "id": 21041, "url": "https://patchwork.libcamera.org/api/1.1/patches/21041/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21041/", "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": "<20240827014044.24673-10-laurent.pinchart@ideasonboard.com>", "date": "2024-08-27T01:40:43", "name": "[v4,9/9] ipa: rkisp1: blc: Add support for BLS in compand", "commit_ref": "9020c2eec9de5d9b5bc1016b26e714b1c0206441", "pull_url": null, "state": "accepted", "archived": false, "hash": "9fd5fa03beb8ca7579e588e5d7b93c3dbbeeefaf", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/21041/mbox/", "series": [ { "id": 4544, "url": "https://patchwork.libcamera.org/api/1.1/series/4544/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4544", "date": "2024-08-27T01:40:34", "name": "rkisp1: Support BLS on i.MX8MP", "version": 4, "mbox": "https://patchwork.libcamera.org/series/4544/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21041/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21041/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 E6145C32D8\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Aug 2024 01:41:12 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 733E363439;\n\tTue, 27 Aug 2024 03:41:12 +0200 (CEST)", "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 3962B61E4F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Aug 2024 03:41:02 +0200 (CEST)", "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5D6621583;\n\tTue, 27 Aug 2024 03:39:55 +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=\"P4CGnhaF\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1724722795;\n\tbh=SQid8fA6gluHknPa2Oqd0f7G0vhc3KABTHpb6YoeIio=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=P4CGnhaF9ehHfQxuDu7IYkeTlwjzx2H4ENQFsmVdC/1DWdPsrEdBhsp3crqYBUqcX\n\tnspr3xwCiOys1lY/NByRQ/CJqfF83562QPdlQ3H638a4/SAreALZk9LhFRXvNtYqG6\n\t1+ky7HVilSaWErWAi608iI/4wt4gIJWTdpvgnTgE=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Paul Elder <paul.elder@ideasonboard.com>", "Subject": "[PATCH v4 9/9] ipa: rkisp1: blc: Add support for BLS in compand", "Date": "Tue, 27 Aug 2024 04:40:43 +0300", "Message-ID": "<20240827014044.24673-10-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.44.2", "In-Reply-To": "<20240827014044.24673-1-laurent.pinchart@ideasonboard.com>", "References": "<20240827014044.24673-1-laurent.pinchart@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": "From: Paul Elder <paul.elder@ideasonboard.com>\n\nExtend the RkISP1 BLC algorithm to use the ISP 'companding' block for\nversions of the ISP (such as the one on the i.MX8MP) that lack the\ndedicated BLS block but implement BLS as part of the companding block.\n\nAs access to the companding block requires the extensible parameters\nformat, disable BLC when using the legacy parameters format on i.MX8MP\nto avoid crashes at runtime with older kernels.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\nChanges since v3:\n\n- Disable BLC on i.MX8MP if using the legacy parameters format\n---\n src/ipa/rkisp1/algorithms/blc.cpp | 57 ++++++++++++++++++++++++-------\n src/ipa/rkisp1/algorithms/blc.h | 5 ++-\n 2 files changed, 48 insertions(+), 14 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp\nindex c93f7ead62cf..98cb7145e164 100644\n--- a/src/ipa/rkisp1/algorithms/blc.cpp\n+++ b/src/ipa/rkisp1/algorithms/blc.cpp\n@@ -7,6 +7,8 @@\n \n #include \"blc.h\"\n \n+#include <linux/videodev2.h>\n+\n #include <libcamera/base/log.h>\n \n #include <libcamera/control_ids.h>\n@@ -38,7 +40,6 @@ namespace ipa::rkisp1::algorithms {\n LOG_DEFINE_CATEGORY(RkISP1Blc)\n \n BlackLevelCorrection::BlackLevelCorrection()\n-\t: tuningParameters_(false)\n {\n \t/*\n \t * This is a bit of a hack. In raw mode no black level correction\n@@ -96,8 +97,6 @@ int BlackLevelCorrection::init(IPAContext &context, const YamlObject &tuningData\n \t\tblackLevelBlue_ = *blackLevel;\n \t}\n \n-\ttuningParameters_ = true;\n-\n \tLOG(RkISP1Blc, Debug)\n \t\t<< \"Black levels: red \" << blackLevelRed_\n \t\t<< \", green (red) \" << blackLevelGreenR_\n@@ -107,10 +106,27 @@ int BlackLevelCorrection::init(IPAContext &context, const YamlObject &tuningData\n \treturn 0;\n }\n \n+int BlackLevelCorrection::configure(IPAContext &context,\n+\t\t\t\t [[maybe_unused]] const IPACameraSensorInfo &configInfo)\n+{\n+\t/*\n+\t * BLC on ISP versions that include the companding block requires usage\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+\n+\tif (!supported_)\n+\t\tLOG(RkISP1Blc, Warning)\n+\t\t\t<< \"BLC in companding block requires extensible parameters\";\n+\n+\treturn 0;\n+}\n+\n /**\n * \\copydoc libcamera::ipa::Algorithm::prepare\n */\n-void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,\n+void BlackLevelCorrection::prepare(IPAContext &context,\n \t\t\t\t const uint32_t frame,\n \t\t\t\t [[maybe_unused]] IPAFrameContext &frameContext,\n \t\t\t\t RkISP1Params *params)\n@@ -121,18 +137,33 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,\n \tif (frame > 0)\n \t\treturn;\n \n-\tif (!tuningParameters_)\n+\tif (!supported_)\n \t\treturn;\n \n-\tauto config = params->block<BlockType::Bls>();\n-\tconfig.setEnabled(true);\n+\tif (context.hw->compand) {\n+\t\tauto config = params->block<BlockType::CompandBls>();\n+\t\tconfig.setEnabled(true);\n \n-\tconfig->enable_auto = 0;\n-\t/* The rkisp1 uses 12bit based black levels. Scale down accordingly. */\n-\tconfig->fixed_val.r = blackLevelRed_ >> 4;\n-\tconfig->fixed_val.gr = blackLevelGreenR_ >> 4;\n-\tconfig->fixed_val.gb = blackLevelGreenB_ >> 4;\n-\tconfig->fixed_val.b = blackLevelBlue_ >> 4;\n+\t\t/*\n+\t\t * Scale up to the 20-bit black levels used by the companding\n+\t\t * block.\n+\t\t */\n+\t\tconfig->r = blackLevelRed_ << 4;\n+\t\tconfig->gr = blackLevelGreenR_ << 4;\n+\t\tconfig->gb = blackLevelGreenB_ << 4;\n+\t\tconfig->b = blackLevelBlue_ << 4;\n+\t} else {\n+\t\tauto config = params->block<BlockType::Bls>();\n+\t\tconfig.setEnabled(true);\n+\n+\t\tconfig->enable_auto = 0;\n+\n+\t\t/* Scale down to the 12-bit black levels used by the BLS block. */\n+\t\tconfig->fixed_val.r = blackLevelRed_ >> 4;\n+\t\tconfig->fixed_val.gr = blackLevelGreenR_ >> 4;\n+\t\tconfig->fixed_val.gb = blackLevelGreenB_ >> 4;\n+\t\tconfig->fixed_val.b = blackLevelBlue_ >> 4;\n+\t}\n }\n \n /**\ndiff --git a/src/ipa/rkisp1/algorithms/blc.h b/src/ipa/rkisp1/algorithms/blc.h\nindex 372f6f7d00cc..f797ae44d639 100644\n--- a/src/ipa/rkisp1/algorithms/blc.h\n+++ b/src/ipa/rkisp1/algorithms/blc.h\n@@ -20,6 +20,8 @@ public:\n \t~BlackLevelCorrection() = default;\n \n \tint init(IPAContext &context, const YamlObject &tuningData) override;\n+\tint configure(IPAContext &context,\n+\t\t const IPACameraSensorInfo &configInfo) override;\n \tvoid prepare(IPAContext &context, const uint32_t frame,\n \t\t IPAFrameContext &frameContext,\n \t\t RkISP1Params *params) override;\n@@ -29,7 +31,8 @@ public:\n \t\t ControlList &metadata) override;\n \n private:\n-\tbool tuningParameters_;\n+\tbool supported_;\n+\n \tint16_t blackLevelRed_;\n \tint16_t blackLevelGreenR_;\n \tint16_t blackLevelGreenB_;\n", "prefixes": [ "v4", "9/9" ] }