From patchwork Sat Jun 20 23:00:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 26996 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 A20B5C3302 for ; Sat, 20 Jun 2026 23:00:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7E3F8656ED; Sun, 21 Jun 2026 01:00:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mZRMYwfr"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A906D62899 for ; Sun, 21 Jun 2026 01:00:35 +0200 (CEST) Received: from [192.168.0.240] (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 68D5D268; Sun, 21 Jun 2026 00:59:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1781996398; bh=GEfoEN3ghhPlv/gvooYO+ub6IZZjZR4W2vbpoEOPL00=; h=From:Subject:Date:To:Cc:From; b=mZRMYwfrzz+03ZZTYLDqNPir/Wq8mlmK2dZqC9MZ6Gv1rj99qbOFVjtV2F5/xR4Z3 FY0mCyXK0dGV8PnD34Z1XJz+WANCd+LloO2VAOl+wQBJ6DwxGK3HiwI1vx26pbw1zy i0SpZUhkLLkwphTVnmOjkuXqZzxnbhgRkPDDFm+Q= From: Kieran Bingham Subject: [PATCH 0/7] softisp: Fix Saturation and Black level handling Date: Sun, 21 Jun 2026 00:00:27 +0100 Message-Id: <20260621-kbingham-awb-saturation-v1-0-b91ea59c6cfb@ideasonboard.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAAAAAAAC/x3MTQ5AMBBA4avIrE1SFQ2uIhZTBhNR0vpLxN01l m/xvQcCe+EAdfKA51OCrC5GlibQTeRGRuljg1baKKMVzlbcONGCdFkMtB+e9mgwr1gb22e2KBV EvXke5P7PTfu+HxnFz6hpAAAA X-Change-ID: 20260620-kbingham-awb-saturation-39e26bd1b580 To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Laurent Pinchart , Milan Zamazal , Bryan O'Donoghue X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1781996434; l=2584; i=kieran.bingham@ideasonboard.com; s=20260204; h=from:subject:message-id; bh=GEfoEN3ghhPlv/gvooYO+ub6IZZjZR4W2vbpoEOPL00=; b=XydkjB7VP9I4PgKUq48vz39eLOvvv79xidsU40zG0lCokSPBUXANP9QR7NtWbhdcJWvHgHOvp uKSPz9ZZpb6CPxUhpAB0kQ5ldyTLn9AxyA2ptvuIEmi4SIIXgt1kixY X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=IOxS2C6nWHNjLfkDR71Iesk904i6wJDfEERqV7hDBdY= 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" These patches have floated around in various forms and versions, but this series aims to collate the main parts of fixing black level and saturation bugs in the SoftISP for both GPU ISP and CPU ISP. This is predominantly fixed by splitting the AWB gains out of the CCM which has previously been 'combined'. Combining means we do not correctly saturate at the sensor levels when applying gains. So now we cna do that and clamp accordingly. To get there, I've added a new clamp operation to the Vector class (and fixed up one usage of that in the rkisp1 ... yeah - I'm trying not to go down rabbit holes, and focus on saturation but adding a clamp was a previous review request ...) I've made use of Milan's existing Black Level Correction fixes, and picked up and applied all previous review comments and refactoring to get here. So far - this is tested on my x13s laptop (with an arbitrary tuning file to make sure the CCM is tested) for both GPU and CPU ISP.... Please test if you can and I'm really keen to merge these so that both Jacopo's and Bryan's work can be rebased on top. Signed-off-by: Kieran Bingham --- Kieran Bingham (4): libcamera: vector: Add clamp operation ipa: rkisp1: awb: Utilise clamp function softisp: Split AWB from Combined Matrix shaders: bayer: Use native matrix multiplication Milan Zamazal (3): ipa: simple: Limit the black level value libcamera: software_isp: Fix black level application in GPU ISP libcamera: software_isp: Fix black level handling in CPU ISP include/libcamera/internal/vector.h | 8 ++++ src/ipa/rkisp1/algorithms/awb.cpp | 2 +- src/ipa/simple/algorithms/awb.cpp | 16 ++------ src/ipa/simple/algorithms/blc.cpp | 7 ++-- src/ipa/simple/ipa_context.h | 5 +-- src/libcamera/shaders/bayer_1x_packed.frag | 51 +++++------------------- src/libcamera/shaders/bayer_unpacked.frag | 51 +++++------------------- src/libcamera/software_isp/debayer_cpu.cpp | 64 ++++++++++++++---------------- src/libcamera/software_isp/debayer_egl.cpp | 18 +++------ src/libcamera/software_isp/debayer_egl.h | 3 ++ src/libcamera/vector.cpp | 8 ++++ test/vector.cpp | 1 + 12 files changed, 83 insertions(+), 151 deletions(-) --- base-commit: 84e1336956a78f7b416f8bd2abf747d93ad64260 change-id: 20260620-kbingham-awb-saturation-39e26bd1b580 Best regards,