From patchwork Wed Apr 1 07:16:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Isaac Scott X-Patchwork-Id: 26403 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 64C92BDCBD for ; Wed, 1 Apr 2026 07:18:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 18D5B62D4C; Wed, 1 Apr 2026 09:18:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HSHJbU5i"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AC11262781 for ; Wed, 1 Apr 2026 09:18:00 +0200 (CEST) Received: from t16.localdomain (cpc90716-aztw32-2-0-cust408.18-1.cable.virginm.net [86.26.101.153]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D0449225; Wed, 1 Apr 2026 09:16:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775027797; bh=Z8tqtxBLOWCVDirCxHV5FAYROED+uEV+llTM+QAeE+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HSHJbU5irh4Cwi3AtPokH1hiF/hJMGuH/lx7rd95f8KmKFvqKTfkJUzzf9Fl7pDY6 agRf2rcXkruXgT4PS7SA9EzF2UJA4YtPM/38XYK9qBkCT4aD35SFYykBngXzsZ+hCd 0m6tHbJMIbboLTI1w0uBn4RZL1nEEvviSEsbinGc= From: Isaac Scott To: libcamera-devel@lists.libcamera.org Cc: Isaac Scott 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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Allow users of the rkisp1 pipeline handler to adjust the level of funk in their streams to their heart's content. No non-funky changes intended by this patch. Signed-off-by: Isaac "Moog Modular" Scott --- src/ipa/rkisp1/algorithms/awb.cpp | 25 +++++++++++++++++++++++++ src/ipa/rkisp1/ipa_context.h | 4 ++++ src/libcamera/control_ids_core.yaml | 17 +++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index f83da545b..749add143 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -9,6 +9,7 @@ #include #include +#include #include @@ -94,6 +95,8 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData) cmap[&controls::ColourGains] = ControlInfo(0.0f, 3.996f, Span{ { 1.0f, 1.0f } }); + cmap[&controls::DiscoMode] = ControlInfo(false, true, false); + cmap[&controls::Funk] = ControlInfo(0, 10, 0); if (!tuningData.contains("algorithm")) LOG(RkISP1Awb, Info) << "No AWB algorithm specified." @@ -175,6 +178,19 @@ void Awb::queueRequest(IPAContext &context, frameContext.awb.autoEnabled = awb.autoEnabled; + const auto &discoModeRockin = controls.get(controls::DiscoMode); + if (discoModeRockin && (*discoModeRockin == true) != awb.discoMode) { + awb.discoMode = *discoModeRockin; + } + + const auto &funkRequired = controls.get(controls::Funk); + if (funkRequired) { + awb.funkMagnitude = *funkRequired; + } + + frameContext.awb.discoMode = awb.discoMode; + frameContext.awb.funkMagnitude = awb.funkMagnitude; + if (awb.autoEnabled) return; @@ -227,6 +243,12 @@ void Awb::prepare(IPAContext &context, const uint32_t frame, auto gainConfig = params->block(); gainConfig.setEnabled(true); + if (frameContext.awb.discoMode) { + float funk = static_cast(frameContext.awb.funkMagnitude) * 3.0f + 1.0f; + frameContext.awb.gains.r() = (sin(funk * (frame % 100) / 100) + 1.0f); + frameContext.awb.gains.b() = (cos(funk * (frame % 100) / 100) + 1.0f); + } + gainConfig->gain_green_b = std::clamp(256 * frameContext.awb.gains.g(), 0, 0x3ff); gainConfig->gain_blue = std::clamp(256 * frameContext.awb.gains.b(), 0, 0x3ff); gainConfig->gain_red = std::clamp(256 * frameContext.awb.gains.r(), 0, 0x3ff); @@ -300,6 +322,9 @@ void Awb::process(IPAContext &context, }); metadata.set(controls::ColourTemperature, frameContext.awb.temperatureK); + metadata.set(controls::DiscoMode, frameContext.awb.discoMode); + metadata.set(controls::Funk, frameContext.awb.funkMagnitude); + if (!stats || !(stats->meas_type & RKISP1_CIF_ISP_STAT_AWB)) { LOG(RkISP1Awb, Error) << "AWB data is missing in statistics"; return; diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index e61391bb1..48e567a95 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -110,6 +110,8 @@ struct IPAActiveState { AwbState automatic; bool autoEnabled; + bool discoMode; + unsigned int funkMagnitude; } awb; struct { @@ -178,6 +180,8 @@ struct IPAFrameContext : public FrameContext { RGB gains; bool autoEnabled; unsigned int temperatureK; + bool discoMode; + unsigned int funkMagnitude; } awb; struct { diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml index 89991d03d..7a25aad45 100644 --- a/src/libcamera/control_ids_core.yaml +++ b/src/libcamera/control_ids_core.yaml @@ -1376,4 +1376,21 @@ controls: The nominal range is [-180, 180], where 0° leaves hues unchanged and the range wraps around continuously, with 180° == -180°. + - DiscoMode: + type: bool + direction: inout + description: | + Enable / disable the feeling of being in your favourite discotheque, + stabilising and pushing the boundaries of funk to maximal levels. + + The DiscoMode control can be fine-tuned to the user's desired level + of funk, depending on whether they prefer a gentle or aggressive + vibe in their streams. + + - Funk: + type: int32_t + direction: inout + description: | + Adjust the funk intensity level, from 0 (enough to do a relaxed two-step) + to 10 (maximal, earth-shattering, weapons-grade funk). ...