From patchwork Mon Nov 16 16:49:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10429 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 CC02EBE082 for ; Mon, 16 Nov 2020 16:49:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3B319632C7; Mon, 16 Nov 2020 17:49:26 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="qRizhGUr"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 31770632C6 for ; Mon, 16 Nov 2020 17:49:24 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id b6so19422298wrt.4 for ; Mon, 16 Nov 2020 08:49:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uFYiUjN/HID7GcpXCxF0e+/BP8r8o1fnU+IpSLLopdU=; b=qRizhGUrEPLcXx3IjsbkGRBoInQQHuslH5XQygZdcZDZ/uUoHrNoHwbqAii2gqqifL Na2TsWotYWXCwxQq+GdkHAMzMyQ5agkBYyylyw1B6A7OMj6FE0/jqydEGK38w25Wsz9A Nhed6AEE5V2Ha8qQR8LM0FpbDc/RaiO/vigjsy4+FDG6dnB5ZumnOrBcqCN9pdDpubYh Bkjozm1uV4dvKqPh4QeUnNC2Rsom/+Eytk9TgJMY9iOVI6qPyL4Kv3aVOSpyzYlrk8jl 9gE4eOJddFQLOWdy2P18R8tPnfwDRIlHl8BflW0nYCnkdoEN2EDzHt1QUuJpCXyFZySA HtEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uFYiUjN/HID7GcpXCxF0e+/BP8r8o1fnU+IpSLLopdU=; b=ChdkEoxUHp/RXBe7Hwz+jljt0Peca0RRvXlevvj0TuLdvMeu38S8Q7mcETrXhi/na7 dW2soUAF+Z3ZwsxF9wyDsxtPyiSVrcWVnZ52I506x6r8MSt1RjLswFNm1phE5ViLnJZT 6ks4vvnMt331k5RT+AE0Mx/q1QFmYYX/5Ox3nBDMf93yLHDymHA4/fSQMbPvxU9WVFgN 646dxtl3JOKj3qtv5+3A3maD8NGX9mkbOx26LdYHsxlFVm19sTA/unuio2iH1qIzpyKL pLZTjAxqt+wQI3HraROIuTIGfTMq50CC7o7W8/1hGDPDBmSrNYnLD+2nqSV4wiyXUTAN yVhg== X-Gm-Message-State: AOAM533nk8mmApWnSEo1xq7WSKXYadbrkQOh9pxAwW5qTPaFXAYJ5v8O Kpcngur8aT2ixiu18kcyfALpVBVuZMuprg== X-Google-Smtp-Source: ABdhPJy0ICQ2Gt4zqwiW3JUKnPFQd/MkdHDuCZAmDxvwSF0ZPYXDWQtXB/SaLC3Vn8I/F6Jxlyg7mQ== X-Received: by 2002:adf:d84e:: with SMTP id k14mr9517571wrl.34.1605545363448; Mon, 16 Nov 2020 08:49:23 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id q16sm23716973wrn.13.2020.11.16.08.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Nov 2020 08:49:22 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 16 Nov 2020 16:49:08 +0000 Message-Id: <20201116164918.2055-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 00/10] Raspberry Pi AGC 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 Some time ago I had said I was doing some maintanence on the Raspberry Pi AGC algorithm, so here it all is (finally). Some of the changes are just for tidying, but others do also make it work better (even correctly). Some of the changes are in particular designed to go with Naush's patch set that allows exposure/gain to be set before the camera starts, though they all function in their own right too. These are the last substantial set of changes I have before we can publish our libcamera apps, though I think Naush still has more. (I am doing work on some of the other algorithms, but these are not on the critical path and can be added later.) Let me summarise all the individual patches here: #1. Replace Raspberry Pi debug with libcamera debug. #2. Code simplification. A number of copies and mutexes are unnecessary on the libcamera/vc4 platform. Not really a functional change though it does happen to fix a bug (where the AeLocked status was never correctly passed out in the AgcStatus). #3. Function renamed to be clearer! #4. An improvement in the way average Y values are calculated. This does actually change the AGC behaviour, making it less fiercely centre-weighted. #5. Code that fetches the AwbStatus from the metadata is factored out, so that we don't keep doing it all over the place. No functional difference. #6. An update to the AWB so that it gives us its up-to-date values when a camera mode switch happens. There's actually quite a lot of tidying to do to the AWB, but I'd like to save that for when I have more substantial changes there (and don't worry, they will come!). #7. This passes out correct gain/exposure values when the camera changes mode (or starts). This is the one most important to Naush. #8. Clear up some uninitialised variables. This is Tomi's patch from a little while back. #9. A small improvement to the gain update calculation. It's worth working a little harder with the statistics that we have to save having to wait for more frames. #10. Improvements to the "AE locked" logic. Previously it could fail ever to "lock" in some circumstances; now it will always do so once the AGC is steady. Sorry there's quite such a lot of stuff here. Please let me know if it might be better broken up into a few smaller patch sets. Thanks and best regards David David Plowman (10): libcamera: ipa: raspberrypi: agc: Use libcamera debug libcamera: ipa: raspberrypi: agc: Remove unnecessary locking libcamera: ipa: raspberrypi: agc: Rename method to divideUpExposure libcamera: ipa: raspberrypi: agc: Improve centre-weighted luminance calucation libcamera: ipa: raspberrypi: agc: Fetch AWB status only once libcamera: ipa: raspberrypi: awb: Add SwitchMode method to output AWB status libcamera: ipa: raspberrypi: agc: Report fixed exposure/gain values during SwitchMode libcamera: src: ipa: raspberrypi: agc: Fix uninitialised members in status_ libcamera: src: ipa: raspberrypi: agc: Improve gain update calculation for partly saturated images libcamera: src: ipa: raspberrypi: agc: Improve AE locked logic src/ipa/raspberrypi/controller/rpi/agc.cpp | 393 ++++++++++++--------- src/ipa/raspberrypi/controller/rpi/agc.hpp | 17 +- src/ipa/raspberrypi/controller/rpi/awb.cpp | 14 + src/ipa/raspberrypi/controller/rpi/awb.hpp | 1 + 4 files changed, 248 insertions(+), 177 deletions(-) Tested-by: Naushir Patuck Acked-by: Kieran Bingham