From patchwork Tue Jun 17 08:29:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 23583 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 E3B4EBDE6B for ; Tue, 17 Jun 2025 08:30:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E27E168DCB; Tue, 17 Jun 2025 10:30:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="mx7WvGC3"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 690FD68DB4 for ; Tue, 17 Jun 2025 10:30:01 +0200 (CEST) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-450dd065828so43267575e9.2 for ; Tue, 17 Jun 2025 01:30:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1750149000; x=1750753800; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=oh8rnBTXDkhTjRbHGK7YAMTrH1bifSn/C8fKn4E14P4=; b=mx7WvGC3e+5UcBJw+LxbcVYK7SYeHGBW2BUg79MmMsfu+1b2Yb1FTbJ9TH12zb7P6k QNIVjbSeU3CX/IUA5rjYYBp3PUWP0HIf/Q+9hoJ35tRGOPcuhQ7nFWIx7o7XK/TcZsWd JsHpfs9oN5uLZtmfZk9N9e6qR/ugZ2WEDx/Hh2NSl+tSjsYBRH5LsFNqAI7JyBDP+h2v BI/VSj0QytV72DY3LYKxkoDW3dKv2hjATgI5fyYaPUM25e8jiy1L0hbn9xFBmfe2+RqF kr0aHw3VmrtaWNSyDm9r3hz359vO1joLCoacuRh7teKv/wkVM9G+k2ilI+V4lBekcrJ0 aHDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750149000; x=1750753800; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oh8rnBTXDkhTjRbHGK7YAMTrH1bifSn/C8fKn4E14P4=; b=LVtc6GCeExvL4CiTHRkVdf9VCOFHI8PvOewp8CrjMiz1voU8/l9YacxsLHPthztsKT 82dfk4yv1Qcynn+OiehaKFWediwHOUxaTNzzbSG9PhLXBNxE5dFQ9LmAK71V+skqA1Tp zBea+mG6R9+kMNPEt8JE63lP6SD2oncfUp39AJdEQonmVGreH/Itv4l4b0MDsBm0k9Xj rH6wUmmfXcavmAQ8FhPnrehkzESH3S86gH7TEVd7tCCJ0Stji9icGO+D2JCCIwm0Gznr t9UOwWnDyxwNK10+EZTTS6m6PeB75uKOJyeT3s1b6ARfwuJPyRkchxnCI+cl+YnRDZmT /AVQ== X-Gm-Message-State: AOJu0Yw6iipE5PZYH2kNibaaFlmR3wp3rUrA9GqcU4CXbP+MNNExOHTx 7GqEureUNtw71bUk1nRhOseZZQOJZDkAq1po1h/unc4oFIfKtdlzSA5fFhjP3CRozykJPISoZlj a/hoi X-Gm-Gg: ASbGnctNK6BWKtaLiT+c5W7yvJgfol+TGCZYv1pRjGqTXGceoOytZVnKa0N5QutRWqf gfrRdC2hlkWx0qL5tntFdJo0AM5hmP4yT8wWHCPlz4bQUBiDkN43o4aIktbx19ltw2zm7SRVuuS v5E76JPY2gm3UPUMU9k1hE3ZpHk2u6TqFGqCujb3YBHOg8N0UEGBVtiAScpYuvqEfNl26Ytb5DQ GcwFJ+dDD8bkJKH6aAm+A3+y38N8XFuxyOcj7OK4MzSh6aFcCX619aLPQ9C4Dculmtcdr3TnmhO 8dHu6qPHN46eqbovaoxmlcVZOcNTP1NVAtrFAJuIiIrfTnxTcEvFEQD+fpvWL7NMKr5TibMmmCR +Mz9sXQ0IHlc/HHTi/A== X-Google-Smtp-Source: AGHT+IF9K6uSPABP4+MDkHLgEO47KZaRfWOeVoxYdR66n40BC5Q6fwwGqp79nAWjJv0hPlgt4mm21g== X-Received: by 2002:a05:600c:630f:b0:440:9b1a:cd78 with SMTP id 5b1f17b1804b1-4533ca8b32fmr145007235e9.10.1750149000341; Tue, 17 Jun 2025 01:30:00 -0700 (PDT) Received: from raspberrypi.pitowers.org ([2a00:1098:3142:1f:ffc9:aff6:7f7f:893b]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532e259108sm166062955e9.32.2025.06.17.01.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jun 2025 01:29:59 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [PATCH 0/7] Raspberry Pi AEC/AGC update Date: Tue, 17 Jun 2025 09:29:48 +0100 Message-Id: <20250617082956.5699-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.39.5 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 everyone Here's a patch set that originated way back at the end of 2023! I remember thinking "oh, I'll send these patches once Pi 5 support has been merged", thinking it would only be a few weeks. How young and foolish I was! Anyway, it was so long ago now, that I felt rather like I was reviewing a patch set from another person - "past David", I suppose. The first 3 patches are small technical or cosmetic improvements, not of any particularly great consequence. Each is standalone. I think I'm happy that past David seemed to know what he was doing. The remaining 4 patches are the important ones. Our AEC/AGC has always had a problem because the digital gain was set in its prepare() method. The catch is that if we're running at high framerates, we frequently skip the IPAs altogether, meaning the digital gain that is required - because it's making up for a deficit in exposure - doesn't get applied. This causes some sometimes very obvious "winks". In these 4 last patches, calculation of the digital gain is moved out of prepare() to process(), meaning it's always available. And the IPA code is refactored slightly so that the digital gain is always applied, even when the rest of AEC/AGC is skipped. I hope it makes reasonable sense - there is some fiddly stuff going on here. Hats off to past David! Thanks! Present-day David David Plowman (7): ipa: rpi: agc: Change handling of colour gains less than 1 ipa: rpi: agc: Make the maximum digital gain configurable ipa: rpi: agc: Rename "analogue gain" to "gain" where appropriate ipa: rpi: Advance the delay context counter even when IPAs don't run ipa: rpi: agc: Calculate digital gain in process() ipa: rpi: Update digital gain handling in IPA base and derived classes ipa: rpi: agc: Remove digital gain from AgcPrepareStatus src/ipa/rpi/common/ipa_base.cpp | 72 ++++--- src/ipa/rpi/common/ipa_base.h | 6 +- src/ipa/rpi/controller/agc_algorithm.h | 2 +- src/ipa/rpi/controller/agc_status.h | 4 +- src/ipa/rpi/controller/rpi/agc.cpp | 6 +- src/ipa/rpi/controller/rpi/agc.h | 4 +- src/ipa/rpi/controller/rpi/agc_channel.cpp | 236 +++++++++------------ src/ipa/rpi/controller/rpi/agc_channel.h | 6 +- src/ipa/rpi/pisp/pisp.cpp | 81 ++++--- src/ipa/rpi/vc4/vc4.cpp | 42 +++- 10 files changed, 248 insertions(+), 211 deletions(-)