From patchwork Thu Sep 25 22:17:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 24462 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 C07B3BDB1C for ; Thu, 25 Sep 2025 22:17:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2F1666B5F3; Fri, 26 Sep 2025 00:17:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="uRT5Tm56"; dkim-atps=neutral Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 86D8169367 for ; Fri, 26 Sep 2025 00:17:12 +0200 (CEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 53D8361286 for ; Thu, 25 Sep 2025 22:17:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A3F9C4CEF0; Thu, 25 Sep 2025 22:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758838631; bh=geaAGomfoU3nVXua/rvmm8NuY1XnVf8ntSt8C9rtvuk=; h=From:To:Cc:Subject:Date:From; b=uRT5Tm56kNDvezbNhkp4Dmrl9WDsqKmCVPZ83lveYj01u5BnddAKe7swW+/LmoKK2 8/RFwyK+JyFR+IQXjW/wWaNObdVLxK8F4KV2rG9uuaBnX4FgYiWJEAy8pwxDXuJpXT vDwTmNTgt3lTsLtywd/9AC+F9wflhUWqvtlbWs+AlIjo8orKIEtlQpxKIO96dusPCX LdtO3IbI06nSwwQqUxkxADee8Z9/eIZXiItE8BdHyLEyygUmUSsFCcl98eT2QKKw8u VQVud5SJvCR85mao1xgIxtCQNjJdZ+vKnnFoNIuf+m9HmliLkNXN0KCtZpSH7ntAid 7Q+rcCjcwV8eA== From: Hans de Goede To: libcamera-devel@lists.libcamera.org Cc: Hans de Goede Subject: [PATCH v2 0/6] ipa: software_isp: AGC: Fox AGC oscillation bug Date: Fri, 26 Sep 2025 00:17:02 +0200 Message-ID: <20250925221708.7471-1-hansg@kernel.org> X-Mailer: git-send-email 2.51.0 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" Hi All, Due to a combination of not having correct control-delay information for various sensors as well as the generic nature of the simple-pipeline + software-ISP meaning that any pipeline delays are unknown it is impossible to get reliable control-delay values. Wrong control-delay values can lead to pretty bad oscilation. See the v1 cover-letter for more details. This series fixes some unrelated issues in the softIPA AGC algorithm and in the last 2 patches addresses the oscillation issue. Note this v2 takes a new approach to fixing the oscilation by only generating statistics for every 4th frame and having the IPA only run its algorithms when there actually are statistics. This saves CPU time, while at the same time avoiding the oscillation issue. Changes in v2: - Skip running IPA algorithms when there are no statistics - Only generate statistics for every 4th frame Note the speed of the AGC algorithm converges on the desired brightness level is unchanged compared to v1 since in v1 the AGC algorithm would skip 3 frames after every gain/exposure change. Regards, Hans Hans de Goede (6): ipa: software_isp: Fix context_.configuration.agc.againMin init ipa: software_isp: AGC: Do not lower gain below 1.0 ipa: software_isp: AGC: Raise exposure or gain not both at the same time ipa: software_isp: AGC: Only use integers for exposure calculations libcamera: software_isp: Add valid flag to struct SwIspStats libcamera: software_isp: Run sw-statistics once every 4th frame .../internal/software_isp/swisp_stats.h | 4 +++ src/ipa/simple/algorithms/agc.cpp | 26 ++++++++++--------- src/ipa/simple/algorithms/awb.cpp | 3 +++ src/ipa/simple/algorithms/blc.cpp | 3 +++ src/ipa/simple/ipa_context.h | 2 +- src/ipa/simple/soft_simple.cpp | 10 ++++++- src/libcamera/software_isp/debayer_cpu.cpp | 25 +++++++++++------- src/libcamera/software_isp/debayer_cpu.h | 4 +-- src/libcamera/software_isp/swstats_cpu.cpp | 9 ++++++- src/libcamera/software_isp/swstats_cpu.h | 5 +++- 10 files changed, 63 insertions(+), 28 deletions(-)