{"id":26403,"url":"https://patchwork.libcamera.org/api/patches/26403/?format=json","web_url":"https://patchwork.libcamera.org/patch/26403/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260401071650.116344-4-isaac.scott@ideasonboard.com>","date":"2026-04-01T07:16:39","name":"[1/2] rkisp1: Add disco mode","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"55072202e81f3fa16d0a13d921953f4f14f6e1fc","submitter":{"id":215,"url":"https://patchwork.libcamera.org/api/people/215/?format=json","name":"Isaac Scott","email":"isaac.scott@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26403/mbox/","series":[{"id":5862,"url":"https://patchwork.libcamera.org/api/series/5862/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5862","date":"2026-04-01T07:16:37","name":"Add Disco Mode to the rkisp1 pipeline handler","version":1,"mbox":"https://patchwork.libcamera.org/series/5862/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26403/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26403/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 64C92BDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Apr 2026 07:18:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 18D5B62D4C;\n\tWed,  1 Apr 2026 09:18:02 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AC11262781\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Apr 2026 09:18:00 +0200 (CEST)","from t16.localdomain\n\t(cpc90716-aztw32-2-0-cust408.18-1.cable.virginm.net [86.26.101.153])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D0449225;\n\tWed,  1 Apr 2026 09:16:37 +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=\"HSHJbU5i\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1775027797;\n\tbh=Z8tqtxBLOWCVDirCxHV5FAYROED+uEV+llTM+QAeE+w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=HSHJbU5irh4Cwi3AtPokH1hiF/hJMGuH/lx7rd95f8KmKFvqKTfkJUzzf9Fl7pDY6\n\tagRf2rcXkruXgT4PS7SA9EzF2UJA4YtPM/38XYK9qBkCT4aD35SFYykBngXzsZ+hCd\n\t0m6tHbJMIbboLTI1w0uBn4RZL1nEEvviSEsbinGc=","From":"Isaac Scott <isaac.scott@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Isaac Scott <isaac.scott@ideasonboard.com>","Subject":"[PATCH 1/2] rkisp1: Add disco mode","Date":"Wed,  1 Apr 2026 08:16:39 +0100","Message-ID":"<20260401071650.116344-4-isaac.scott@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260401071650.116344-2-isaac.scott@ideasonboard.com>","References":"<20260401071650.116344-2-isaac.scott@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","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":"Allow users of the rkisp1 pipeline handler to adjust the level of funk\nin their streams to their heart's content.\n\nNo non-funky changes intended by this patch.\n\nSigned-off-by: Isaac \"Moog Modular\" Scott <isaac.scott@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/awb.cpp   | 25 +++++++++++++++++++++++++\n src/ipa/rkisp1/ipa_context.h        |  4 ++++\n src/libcamera/control_ids_core.yaml | 17 +++++++++++++++++\n 3 files changed, 46 insertions(+)","diff":"diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex f83da545b..749add143 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -9,6 +9,7 @@\n \n #include <algorithm>\n #include <ios>\n+#include <math.h>\n \n #include <libcamera/base/log.h>\n \n@@ -94,6 +95,8 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData)\n \n \tcmap[&controls::ColourGains] = ControlInfo(0.0f, 3.996f,\n \t\t\t\t\t\t   Span<const float, 2>{ { 1.0f, 1.0f } });\n+\tcmap[&controls::DiscoMode] = ControlInfo(false, true, false);\n+\tcmap[&controls::Funk] = ControlInfo(0, 10, 0);\n \n \tif (!tuningData.contains(\"algorithm\"))\n \t\tLOG(RkISP1Awb, Info) << \"No AWB algorithm specified.\"\n@@ -175,6 +178,19 @@ void Awb::queueRequest(IPAContext &context,\n \n \tframeContext.awb.autoEnabled = awb.autoEnabled;\n \n+\tconst auto &discoModeRockin = controls.get(controls::DiscoMode);\n+\tif (discoModeRockin && (*discoModeRockin == true) != awb.discoMode) {\n+\t\tawb.discoMode = *discoModeRockin;\n+\t}\n+\n+\tconst auto &funkRequired = controls.get(controls::Funk);\n+\tif (funkRequired) {\n+\t\tawb.funkMagnitude = *funkRequired;\n+\t}\n+\n+\tframeContext.awb.discoMode = awb.discoMode;\n+\tframeContext.awb.funkMagnitude = awb.funkMagnitude;\n+\n \tif (awb.autoEnabled)\n \t\treturn;\n \n@@ -227,6 +243,12 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n \tauto gainConfig = params->block<BlockType::AwbGain>();\n \tgainConfig.setEnabled(true);\n \n+\tif (frameContext.awb.discoMode) {\n+\t\tfloat funk = static_cast<float>(frameContext.awb.funkMagnitude) * 3.0f + 1.0f;\n+\t\tframeContext.awb.gains.r() = (sin(funk * (frame % 100) / 100) + 1.0f);\n+\t\tframeContext.awb.gains.b() = (cos(funk * (frame % 100) / 100) + 1.0f);\n+\t}\n+\n \tgainConfig->gain_green_b = std::clamp<int>(256 * frameContext.awb.gains.g(), 0, 0x3ff);\n \tgainConfig->gain_blue = std::clamp<int>(256 * frameContext.awb.gains.b(), 0, 0x3ff);\n \tgainConfig->gain_red = std::clamp<int>(256 * frameContext.awb.gains.r(), 0, 0x3ff);\n@@ -300,6 +322,9 @@ void Awb::process(IPAContext &context,\n \t\t});\n \tmetadata.set(controls::ColourTemperature, frameContext.awb.temperatureK);\n \n+\tmetadata.set(controls::DiscoMode, frameContext.awb.discoMode);\n+\tmetadata.set(controls::Funk, frameContext.awb.funkMagnitude);\n+\n \tif (!stats || !(stats->meas_type & RKISP1_CIF_ISP_STAT_AWB)) {\n \t\tLOG(RkISP1Awb, Error) << \"AWB data is missing in statistics\";\n \t\treturn;\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex e61391bb1..48e567a95 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -110,6 +110,8 @@ struct IPAActiveState {\n \t\tAwbState automatic;\n \n \t\tbool autoEnabled;\n+\t\tbool discoMode;\n+\t\tunsigned int funkMagnitude;\n \t} awb;\n \n \tstruct {\n@@ -178,6 +180,8 @@ struct IPAFrameContext : public FrameContext {\n \t\tRGB<double> gains;\n \t\tbool autoEnabled;\n \t\tunsigned int temperatureK;\n+\t\tbool discoMode;\n+\t\tunsigned int funkMagnitude;\n \t} awb;\n \n \tstruct {\ndiff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml\nindex 89991d03d..7a25aad45 100644\n--- a/src/libcamera/control_ids_core.yaml\n+++ b/src/libcamera/control_ids_core.yaml\n@@ -1376,4 +1376,21 @@ controls:\n         The nominal range is [-180, 180], where 0° leaves hues unchanged and the\n         range wraps around continuously, with 180° == -180°.\n \n+  - DiscoMode:\n+      type: bool\n+      direction: inout\n+      description: |\n+        Enable / disable the feeling of being in your favourite discotheque,\n+        stabilising and pushing the boundaries of funk to maximal levels.\n+\n+        The DiscoMode control can be fine-tuned to the user's desired level\n+        of funk, depending on whether they prefer a gentle or aggressive\n+        vibe in their streams.\n+\n+  - Funk:\n+      type: int32_t\n+      direction: inout\n+      description: |\n+        Adjust the funk intensity level, from 0 (enough to do a relaxed two-step)\n+        to 10 (maximal, earth-shattering, weapons-grade funk).\n ...\n","prefixes":["1/2"]}