From patchwork Tue Dec 1 17:55:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10537 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 1884EBE176 for ; Tue, 1 Dec 2020 17:55:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D5E736350A; Tue, 1 Dec 2020 18:55:46 +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="fZSvx52u"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6807F6350A for ; Tue, 1 Dec 2020 18:55:44 +0100 (CET) Received: by mail-wr1-x42d.google.com with SMTP id z7so4043290wrn.3 for ; Tue, 01 Dec 2020 09:55:44 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=ER5bp6kWDKmeBDzRb8dI93yLVd9KdrJ8QDJlGEaxezc=; b=fZSvx52uB9pqb/XnYob+ag5ahp0eghmMjs4bPf5Byo8u2uh2VbFRG+ZXGjIlUoxEmb uYSW8Th4dln0Np15/GoiO340/p0krsWRVlu/SjMo2NSkvCC8waiB1hPX7zRQp3T+6VjW m994FhKlhceUYL/U+yc7MeoFtdnAO67EFTjiB0Jjdr4gbbN17bpN1X20f9jXtUKIzq+v vhoNbcvYBM2LzbA4e7IW0NWNWAEq04o7W2qILu8eZMHk0TjGuMxehnpZHpfB/YGV9O84 shUDpoTHBDqkDQx1oesOj6eH6mgJVFCRLpT1zTHfNQMsqdUYa0aSmOlOyd5BCHwDMWm0 gSYQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ER5bp6kWDKmeBDzRb8dI93yLVd9KdrJ8QDJlGEaxezc=; b=Ecoz9EytAnUMuRutfcTP/4/yvTiKZexNFxN/S/gACKXkD2FxvIJ6lIuni/OAB0o/8Y e0j45FrNx5FBAmvMjtFoXOrqAEpcv+KxWnNiODsZ5/vEyiSkGjadifGv5Bm9JGIlOdZy d2wy20XsCHp8hC/drVyQKYWVlsfldKphgtFwMdSf1q6wANQPkXH68UOPUGohseaHsyMl GXy0GoJKUaxufnU7lTh1AnThnYXWd8N8Y+7XKaBmXhsLnBAQfNBHdPk5b8zLe0/HUw0N uC+/mdHcwD7nPXV6cQUzHVjSKJw8RDnUlue/gOTt95eZUeRW3c0vNGTJk0ktuHbVAh8W VA7Q== X-Gm-Message-State: AOAM532FEylYHAogP6OvcqeHPj9TbkZQVcAl9GeL9ysaN0AOMkFVV/5/ ehbnWPTnz0/DjRKkkRqlfBqjihy7DDUyJ38z X-Google-Smtp-Source: ABdhPJyoqVz4YuTJA0WBYYlneTzJd6/OIIlExvj3WpfxAUA4OY6KxvjveAaIml6JSoic2AEUPHClpg== X-Received: by 2002:a5d:67c5:: with SMTP id n5mr5426810wrw.179.1606845343900; Tue, 01 Dec 2020 09:55:43 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id l3sm438561wrr.89.2020.12.01.09.55.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 09:55:43 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 1 Dec 2020 17:55:33 +0000 Message-Id: <20201201175536.11093-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201201175536.11093-1-david.plowman@raspberrypi.com> References: <20201201175536.11093-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 2/5] src: ipa: raspberrypi: agc: Make AGC handle Pause/Resume for itself 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" AGC, when paused, sets the last exposure/gain it wrote to be its "fixed" values and will therefore continue to return them. When resumed, we clear them so that both will float again. This approach is better because AGC can be paused and we can subsequently change (for example) the exposure and the gain won't float again. Signed-off-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/rpi/agc.cpp | 24 ++++++++++++++++++++++ src/ipa/raspberrypi/controller/rpi/agc.hpp | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index 30a1c1c1..9da18c31 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -184,6 +184,26 @@ void Agc::Read(boost::property_tree::ptree const ¶ms) exposure_mode_ = &config_.exposure_modes[exposure_mode_name_]; constraint_mode_name_ = config_.default_constraint_mode; constraint_mode_ = &config_.constraint_modes[constraint_mode_name_]; + // Set up the "last shutter/gain" values, in case AGC starts "disabled". + status_.shutter_time = config_.default_exposure_time; + status_.analogue_gain = config_.default_analogue_gain; +} + +bool Agc::IsPaused() const +{ + return false; +} + +void Agc::Pause() +{ + fixed_shutter_ = status_.shutter_time; + fixed_analogue_gain_ = status_.analogue_gain; +} + +void Agc::Resume() +{ + fixed_shutter_ = 0; + fixed_analogue_gain_ = 0; } void Agc::SetEv(double ev) @@ -199,11 +219,15 @@ void Agc::SetFlickerPeriod(double flicker_period) void Agc::SetFixedShutter(double fixed_shutter) { fixed_shutter_ = fixed_shutter; + // Set this in case someone calls Pause() straight after. + status_.shutter_time = fixed_shutter; } void Agc::SetFixedAnalogueGain(double fixed_analogue_gain) { fixed_analogue_gain_ = fixed_analogue_gain; + // Set this in case someone calls Pause() straight after. + status_.analogue_gain = fixed_analogue_gain; } void Agc::SetMeteringMode(std::string const &metering_mode_name) diff --git a/src/ipa/raspberrypi/controller/rpi/agc.hpp b/src/ipa/raspberrypi/controller/rpi/agc.hpp index 47ebb324..95db1812 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp @@ -70,6 +70,10 @@ public: Agc(Controller *controller); char const *Name() const override; void Read(boost::property_tree::ptree const ¶ms) override; + // AGC handles "pausing" for itself. + bool IsPaused() const override; + void Pause() override; + void Resume() override; void SetEv(double ev) override; void SetFlickerPeriod(double flicker_period) override; void SetFixedShutter(double fixed_shutter) override; // microseconds