From patchwork Wed Mar 4 23:00:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 26256 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 43082BE086 for ; Wed, 4 Mar 2026 23:25:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DDA7B625AC; Thu, 5 Mar 2026 00:25:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=jetm.me header.i=@jetm.me header.b="nsKPcw2/"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="4GuM2MzH"; dkim-atps=neutral Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 55E83623A8 for ; Thu, 5 Mar 2026 00:25:20 +0100 (CET) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 74ABE7A008A for ; Wed, 4 Mar 2026 18:25:19 -0500 (EST) Received: from phl-imap-07 ([10.202.2.97]) by phl-compute-02.internal (MEProxy); Wed, 04 Mar 2026 18:25:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetm.me; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1772666719; x=1772753119; bh=0HOobFkO4RlgGbOTtJj+b0Jvgtp+sjNz++DHCtu97Sg=; b= nsKPcw2/md2GV/PTNAOrKg0vr8YsgaKmFKIUZJ6+jFyJgD4niL1tsnLFXTJWLOcf SFdmA+gp5TVqPXb8QkNy/hw7cPRhWJm+Q6t1pVhnEbRw7YW5uL0+or+NUgtlrzc9 Jf8ryIVZ4UFZp2RV0RTfCGufWYeKR3lmLgQf+8KySzw40vV6VbiMzF69ZN5+ug+s +bdOZedKeXaZnJ1oU96KPks5/vH46t2BdUGOgxWy7YsP4l9BDxe3xugMczpq+3vp LqEB3MMQsDsgnx0jr5IB3aXtcOqtJk++C/WXv5AQP87Jb/CVYWl6bCLRdmNfyBfW BZWSczLSYLQ15BhVoxFB6g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1772666719; x=1772753119; bh=0 HOobFkO4RlgGbOTtJj+b0Jvgtp+sjNz++DHCtu97Sg=; b=4GuM2MzHNt5bJ7WP+ /qnJIFEzOSV76n5BHi13AwOtZJn2Ut4lF90kmk08RSPgQ6jKRAdiHXW/MISeswZt e7CARJbifWGg/l+/nBDcLp27CK3Kxiw24NQO03UUyMOTuVJBY4d/O/kacJ3x1V8/ V75Ok0wpUDBoeERGnZ/6RPFvs6sodD5+UKlLvGwxAzppZUacKWhinq6yn8BqDCcr cXM4dSdZygv5TP2XtQeyFpzcy8Mvundc+cpmwOfJo8FQGeuTDqYHEJkk3sK3FNTH USLD/yfAw2htq/EvEFubbeG2YWi9ObIf+uWUWd0FSAQG4qK5IkbWvdnVBOXCjC7Y +26Sw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvieegkeduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgopfhokfffucdluddtmdenucfjughrpefotggggffhvf ffufgjfhesthektddtredtjeenucfhrhhomheplfgrvhhivghrucfvihgruceofhhlohhs shesjhgvthhmrdhmvgeqnecuggftrfgrthhtvghrnhepteetvdeklefgledtjefhhfdtle dvhfffgfeuieelgeeigfekgffhleeghfefhfejnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomhepfhhlohhsshesjhgvthhmrdhmvgdpnhgspghrtg hpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheplhhisggtrghmvghr rgdquggvvhgvlheslhhishhtshdrlhhisggtrghmvghrrgdrohhrgh X-ME-Proxy: Feedback-ID: i9dde48b3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 335E61EA006B; Wed, 4 Mar 2026 18:25:19 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 From: Javier Tia To: libcamera-devel@lists.libcamera.org Date: Wed, 04 Mar 2026 17:00:56 -0600 Subject: [PATCH v2 0/4] Simple pipeline: proportional AGC, AWB stats fix, OV2740 tuning In-Reply-To: 20260225221859.600869-1-floss@jetm.me References: 20260225221859.600869-1-floss@jetm.me Message-Id: <20260304232519.335E61EA006B@mailuser.phl.internal> 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" This series fixes AGC oscillation and an AWB statistics bug in the Simple pipeline, and adds the first sensor-specific tuning file for the SoftISP. Patch 1 replaces the fixed 10% bang-bang step in the AGC with a proportional controller where step size scales with the MSV error. This eliminates the brightness flicker observed on sensors with non-trivial control latency (tested on OV2740 behind Intel IPU6/IVSC). Unchanged from v1. Patch 2 fixes a bit-depth mismatch in the statistics gathering. The SWSTATS_ACCUMULATE_LINE_STATS() macro divides the luminance value for the histogram to normalize it to 8-bit range, but does not apply the same normalization to the RGB sums. For 10-bit and 12-bit unpacked Bayer formats, the sums are accumulated at native bit depth while the AWB subtracts an 8-bit black level, under-correcting by 4x or 16x respectively. This skews the AWB grey world gains, producing a visible color cast (~9% green on the OV2740 with BLC=16). The fix right-shifts the RGB sums in finishFrame() to normalize them to 8-bit scale, matching the histogram and the 8-bit BLC used by AWB. Patch 3 adds an OV2740 tuning file. With the AWB fix from patch 2, no CCM is needed - AWB grey world convergence gives R/G ~ 0.98 and B/G ~ 0.99 under 6500K lighting. Patch 4 adds the OV2740 black level (4096, i.e. 0x40 at 10-bit) to CameraSensorHelperOv2740, following the established pattern used by OV5675, IMX219, and other sensors. This is the canonical location for sensor calibration data and is used across all pipeline handlers. Changes since v1: - Patch 2: New. Fixes the AWB/BLC bit-depth mismatch for >8-bit sensors, eliminating the green cast without needing a CCM. - Patch 3 (was patch 2 in v1): Removed CCM - no longer needed with the AWB fix. Removed explicit blackLevel from the tuning file; the value is now provided by CameraSensorHelperOv2740 (patch 4) as suggested by Robert Mader. - Patch 4 (was patch 3 in v1): Unchanged. Tested on ThinkPad X1 Carbon Gen 10 (Alder Lake, OV2740, IPU6 ISYS, CachyOS kernel 6.19.3, libcamera 0.7.0). Test results (converged frames, 6500K lighting, no CCM): With AWB fix (v2): R/G=0.984 B/G=0.985 (~1.5% residual) Without fix (v1): R/G=0.910 B/G=0.904 (~9% green cast) BLC=0 control: R/G=1.000 B/G=1.001 (proves the mismatch) Javier Tia (4): ipa: simple: agc: Replace bang-bang controller with proportional libcamera: software_isp: Normalize statistics sums to 8-bit ipa: simple: data: Add OV2740 tuning file ipa: libipa: camera_sensor_helper: Add OV2740 black level .../internal/software_isp/swstats_cpu.h | 1 + src/ipa/libipa/camera_sensor_helper.cpp | 2 + src/ipa/simple/algorithms/agc.cpp | 73 +++++++++++++------ src/ipa/simple/data/meson.build | 1 + src/ipa/simple/data/ov2740.yaml | 13 ++++ src/libcamera/software_isp/swstats_cpu.cpp | 9 +++ 6 files changed, 75 insertions(+), 24 deletions(-) create mode 100644 src/ipa/simple/data/ov2740.yaml