From patchwork Fri Mar 6 18:46:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 26266 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 7154FBE086 for ; Fri, 6 Mar 2026 18:47:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 31C686262B; Fri, 6 Mar 2026 19:47:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=jetm.me header.i=@jetm.me header.b="C6pPgd7p"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="4LEMtSuH"; dkim-atps=neutral Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3BDC06261B for ; Fri, 6 Mar 2026 19:47:19 +0100 (CET) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 165337A017D; Fri, 6 Mar 2026 13:47:18 -0500 (EST) Received: from phl-imap-07 ([10.202.2.97]) by phl-compute-02.internal (MEProxy); Fri, 06 Mar 2026 13:47:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetm.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm3; t=1772822837; x=1772909237; bh=hLxHLP8gPJ Lt36Kww9pSlI+0w+VzQDEef+WKmStdja4=; b=C6pPgd7pKR1NMaIMC+B/znCs/J f9g0ccSX4LIGirLNpQNm/JRFYf4MRWQXku8Pdq9f9LfdprCHq+yC8Cqvz2JiM9Rp ProGDd6/6RIXO3wxR/d3wxD1Ocrj+2UZ4MauejEMIcmsup1Ytkp8rhke51zu+XmW 4NSK6qj2IkkrrpE0XZYFWguQgvXTugWVAedSFKrzyN1vJp56D/oKNP1esMP3IkhI g/HkQTBg1JojDsQ3UBG71mG6tsbdX5G6LW9y1Xga8z0zB0zLp/14vFN5sNtQnNFW uv798IjVqizRzESDyNecAKHRAPLK9nDB5xQhlDp2+OT0Bq79E3VVTscmHQGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1772822837; x=1772909237; bh=hLxHLP8gPJLt36Kww9pSlI+0w+Vz QDEef+WKmStdja4=; b=4LEMtSuHF/cqPr46fnl3AJpkYf2r15LYwP8EA761lFbG BVzVpBUz8e4URUXJLBlD6R6QBCe2iLcmv0+yDVF1UqetMmluWKLoG9b4yaQ+NBnd svAzQcXZ45dMY3rVrpNoEFAS/G7C6mJyRaA1F9qkYq2OcpGWnimaw3gp0wet8Fdw 1yBWcHWisF3NvpnrinIiyzcHF1x5JUiZw53FjnzSPDzlczEu7LaE5bEMMDG04iEl odxys9f1Xf3JaUs5WYjC5PErCGYvGmg0rRpfbngHn6FV1J0CD9kOKE/AvqhtQKOS V3Mjytnn8QVYzYVJdQJC8C3e6I2O4Vqb2gHiLlv4Kw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvjedttdegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepoffhufffkfggtgfgvfevofesthejredtredtjeenucfhrhhomheplfgrvhhivghr ucfvihgruceofhhlohhsshesjhgvthhmrdhmvgeqnecuggftrfgrthhtvghrnhepjeegve fffeekhfegieeggfetveefgefgudeggfettddvtdffieevffdtgeeuueeunecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepfhhlohhsshesjhgvth hmrdhmvgdpnhgspghrtghpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthht oheprhhosggvrhhtrdhmrgguvghrsegtohhllhgrsghorhgrrdgtohhmpdhrtghpthhtoh epsggrrhhnrggsrghsrdhpohgtiigvsehiuggvrghsohhnsghorghrugdrtghomhdprhgt phhtthhopehkihgvrhgrnhdrsghinhhghhgrmhesihguvggrshhonhgsohgrrhgurdgtoh hmpdhrtghpthhtohepfhhlohhsshesjhgvthhmrdhmvgdprhgtphhtthhopehlihgstggr mhgvrhgrqdguvghvvghlsehlihhsthhsrdhlihgstggrmhgvrhgrrdhorhhgpdhrtghpth htohepmhiirghmrgiirghlsehrvgguhhgrthdrtghomh X-ME-Proxy: Feedback-ID: i9dde48b3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id AB4451EA006C; Fri, 6 Mar 2026 13:47:17 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface From: Javier Tia Subject: [PATCH v4 0/3] Simple pipeline: proportional AGC, AWB stats fix, OV2740 black level Date: Fri, 06 Mar 2026 12:46:39 -0600 Message-Id: <20260306-agc-proportional-v4-0-e87c7e0d837a@jetm.me> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAAAAAAAC/x2MQQqAIBAAvxJ7TljMgvpKdNBaayFU1ohA+nvSc WBmCmQSpgxTU0Do5swxVDBtA+thw06Kt8qgUQ/YYa/svqokMUW5qmpP5axG58feG3RQsyTk+fm X8/K+H6/2CbViAAAA X-Change-ID: 20260305-agc-proportional-ba20bf95f40b To: libcamera-devel@lists.libcamera.org Cc: Javier Tia , Milan Zamazal , =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , Robert Mader , Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2541; i=floss@jetm.me; h=from:subject:message-id; bh=WlJEsjwNWEqS2BvPQLYFYX6sOgyDGxGY5Atx4B3RIz0=; b=owEB7QES/pANAwAKAbXuwwuoZ3cfAcsmYgBpqyEP1JRZu6xvXNASNWlGfZlrbaOW9h5moThWZ FBIrB6sM0mJAbMEAAEKAB0WIQSbE7ILzw7eI0VKk8m17sMLqGd3HwUCaashDwAKCRC17sMLqGd3 HzrCDACSerUVQJqshsarS7wFoh0qqhLoIL+YNIb8eZ2hR5mcRw/TzUbwtqTmOxGsCoePQmTAB9P /c3S3tNV28z+oQ446I8BO7/m2phdCy8jWYnyT46bUkAKjfVMPel7O8k9pFje0voVPfmqSS0Dwxs PleO7wJo6LL3R92tSVRD8/uz4psLnwsUEQHY0HeUqVspjce3Y1qXdvwqjbR6YY00xgpPGiXV2mj 3y9qngdvwtfZy7ywVlf0y42vMt3JF58niR1svYkVkMTYyVsBEJZ6B0Qjnr6wmQ2QXqQIHdLeJAp jeTfJDglrm8RLZWTEcRJg/OGy28uHk7zvvWozlxIy2pX/Y5fzgRU/RWcGi7eprvM/1/7/e1Rh8z po9FTJaqGDL9sc4R/9tPLYa8cM3pR13mmCU3RwQSr0maN5DZd+auJzBmvx/TT0ANnPbdEQZwbnq d+tgf50GTstTQ4gM7EgecSEcUgocZm8C9BPkSl7gM5i6/5zjOEMS/Amf5Ah3GdAu7naII= X-Developer-Key: i=floss@jetm.me; a=openpgp; fpr=9B13B20BCF0EDE23454A93C9B5EEC30BA867771F 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 OV2740 black level to the sensor helper. 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). 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 the OV2740 black level (4096, i.e. 0x40 at 10-bit) to CameraSensorHelperOv2740, following the established pattern used by OV5675, IMX219, and other sensors. Changes since v3: - Patch 1: Removed kExpMaxStep and the std::clamp - the proportional gain is applied directly, since the maximum error of ~2.5 already bounds the step to ~10%. (Barnabas) - Patch 2: Replaced per-case sumShift_ assignments with sumShift_ = bayerFormat.bitDepth - 8. (Barnabas) - Patch 3: No changes. Changes since v2: - Dropped the OV2740 tuning file patch (identical to uncalibrated.yaml without a CCM). A follow-up with calibrated CCMs is planned. - Rebased onto current master. Signed-off-by: Javier Tia --- Javier Tia (3): ipa: simple: agc: Replace bang-bang controller with proportional libcamera: software_isp: Normalize statistics sums to 8-bit ipa: libipa: camera_sensor_helper: Add OV2740 black level .../libcamera/internal/software_isp/swstats_cpu.h | 1 + src/ipa/libipa/camera_sensor_helper.cpp | 2 + src/ipa/simple/algorithms/agc.cpp | 65 ++++++++++++++-------- src/libcamera/software_isp/swstats_cpu.cpp | 7 +++ 4 files changed, 51 insertions(+), 24 deletions(-) --- base-commit: 14ba4d168085dd27aed9bcb043996d6a5f28867e change-id: 20260305-agc-proportional-ba20bf95f40b Best regards,