From patchwork Thu Nov 26 12:32:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10503 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 0BD21BE176 for ; Thu, 26 Nov 2020 12:32:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2FFB96345C; Thu, 26 Nov 2020 13:32:14 +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="Btkl4vDc"; dkim-atps=neutral Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9150B63449 for ; Thu, 26 Nov 2020 13:32:12 +0100 (CET) Received: by mail-ej1-x634.google.com with SMTP id hb22so2455538ejb.12 for ; Thu, 26 Nov 2020 04:32:12 -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=9ktpT+D5PLVk79s3FjnYeYZukjakGS97umiZNbnJkx0=; b=Btkl4vDcI6JOks2CM6S3Qx1ZyT3QlAVFQcp6ULmSiJ4Ct1HiM1qOc7Yfa2pIZgjdBX m/AX3ajcJhV/BI1qZh+nQWTFFV+q2E5aBJOzIXRx6rixnpWypktbP3we1jj6aaV3MW+R 9QyWD6Uc1eAsMEjUrwEcG71O8I9E6Mv1wSTJoEXJ2op5m6u7Dbjd7LSw1b88vQVwiNNa hg29rLiazOZp3e7JxOeqrB0Z/BsPymhPGhLmv0rSHrfhh+aC/gYbT5iJeuqWghKezzK5 8UgrNxUyjFAT7vXF2am6H1jkyB65qC6fphw9XBA+02GvlFBRuQjCIqn32FX1K5nHQHWU IZDw== 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=9ktpT+D5PLVk79s3FjnYeYZukjakGS97umiZNbnJkx0=; b=lpHy2nN7h9r3hwYE+x3S9Z3EtRjlKPRAfMsyrck1zAdXyE1q1EAqslIjE2DdPgH6wk NCvrsoqJs8BETvnDMLTod5kNKn4GFqgd+ZOxu0OccqOpe9aAlJbnLtfrfS3tikxNwpMx qTbKcPmvdXND/e0TXqwvbf2XBmP8XPON6wkm1LGBZWcuEe3lq3XHrFpmzRlbUvMiMBxw Q18p0wasq8wrKAB0nmFpTYE0dQPUlxRRVm0uFc9zi6NpOQMNqtEnjutOlzRsi9a4tb/O //NW837p8itFL3fO5YAJWnWMOAB2aN/NI59kdhnd/uJbWSHB+hiBHXb4AwP0XCtVG2Am 7B/Q== X-Gm-Message-State: AOAM5300gW0X7wiBEc7romGqn22Uxoh/n7+3Jz9bpoMalBu9JaG3YT10 +CsdZulNkWwns9ZNqlh1bZ+BoyB0rCb/zAqe X-Google-Smtp-Source: ABdhPJzWA8rUT6x4cxsFrRQ8SpWaC0V0QzKMfUkoH0r4Jg1G3p7HXigk+e6s3AUaIu4urRpUPG8Ziw== X-Received: by 2002:a17:906:170e:: with SMTP id c14mr2413082eje.117.1606393931960; Thu, 26 Nov 2020 04:32:11 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id u5sm3064354edp.5.2020.11.26.04.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 04:32:11 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 26 Nov 2020 12:32:01 +0000 Message-Id: <20201126123203.19105-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201126123203.19105-1-david.plowman@raspberrypi.com> References: <20201126123203.19105-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] 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 --- src/ipa/raspberrypi/controller/rpi/agc.cpp | 24 ++++++++++++++++++++++ src/ipa/raspberrypi/controller/rpi/agc.hpp | 5 +++++ 2 files changed, 29 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..8a1a20e6 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp @@ -70,6 +70,11 @@ 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; + void Pause(); + void Resume(); + unsigned int GetFrameDrops() const override; void SetEv(double ev) override; void SetFlickerPeriod(double flicker_period) override; void SetFixedShutter(double fixed_shutter) override; // microseconds