From patchwork Wed Dec 2 11:52:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10545 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 0E282BE177 for ; Wed, 2 Dec 2020 11:53:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CED17635B3; Wed, 2 Dec 2020 12:53:03 +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="TpHGzGwG"; dkim-atps=neutral Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1AA5E635AB for ; Wed, 2 Dec 2020 12:53:02 +0100 (CET) Received: by mail-wr1-x441.google.com with SMTP id u12so3593229wrt.0 for ; Wed, 02 Dec 2020 03:53:02 -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=a8CEGHnRSlkm553eVUvpub/RWAwm0vCjsHV2IRyer0k=; b=TpHGzGwGndEwTowvI0z/KCDUKWDf4atPN9NVb1Iv71ka74n7QQ9C7GRqhjX+H3XSdZ 5b0TU8wH6W7FPKAdZkqyBjS5AUZBNAEbqwMml032v6hsCDtX9DyjQXMSJuRNHaITFzod TkrYenrnQD5xMSw08R5b/x6I5BJYZ+ozHPtpqU6xmpDDWvbErh2gSg/23Adism1PJ/a/ jAgZN5RBlh+is9TSFZ5eEMIQPuNFQhnr8NzwBonHgEaX0uMRHOfJl6pIvuDaQb2n2zeb SIpELUKF6SAXeVv6ByCF9Ti5f0lYSdL2WKYmDkMNG+up7RxE3t4Z5lXnCOyqE/Lt6Nx7 Aagg== 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=a8CEGHnRSlkm553eVUvpub/RWAwm0vCjsHV2IRyer0k=; b=QbwJJyjfkiKawwb6RuEZLSo03NDRdrXALLYVDRAxQ81pKcyGSyawZgIj1ku1EOJFca VLKzV5JqZ853Yjk4Jjs83qAf8uDIpMXY0Kfo7hyys4sIIxseEnZkjgTA3M/ejix6zK8W aKOtv3Y7CPyAINK13EtZ6RavbbIY+vozN6p35WW1Ke2O77ntMGYwBQiDahJ06s/a6KCq p8qQMieDPWuHQwKy7ZryM1/pFAmLnZYBcJaVaSwCo89A03gQlmY1lFTILgIlFahUMK+l Egbo/daMqQDZezWQ5v6v/WJTPjnmsjVTsmfK82YDiA/vpLTxjjzAY2UsD0u0+3NYmpXB XWnQ== X-Gm-Message-State: AOAM532ItTRCe2kEAQK+B8Krhw5MiPJOCRbkdEgTYshmB/6HJYedeyT2 TKFGqPGhULGMY3FcJdlYQaq7btGzMVMLoX0v X-Google-Smtp-Source: ABdhPJyR17/r8sBDKJ9MEwCGSoZ2QdkcK7BkHPPoDUk6yR8fADbWS4HfwQLmZJm2U4OcFhwVuLChmA== X-Received: by 2002:adf:bd84:: with SMTP id l4mr3065040wrh.41.1606909981612; Wed, 02 Dec 2020 03:53:01 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id n189sm1739215wmf.20.2020.12.02.03.53.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:53:00 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Wed, 2 Dec 2020 11:52:52 +0000 Message-Id: <20201202115253.14705-5-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201202115253.14705-1-david.plowman@raspberrypi.com> References: <20201202115253.14705-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] src: ipa: raspberrypi: Move initial frame drop decision to 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" Previously the CamHelper was returning the number of frames to drop (on account of AGC converging). This wasn't really appropriate, it's better for the AGC to do it, which now also knows when exposure and gain have been explicitly set and therefore fewer (or no) frame drops are necessary at all. The CamHelper::HideFramesStartup method should now just be returning the number of frames to hide because they're bad/invalid in some way, not worrying about the AGC. For many sensors, the correct value for this is zero. Signed-off-by: David Plowman --- src/ipa/raspberrypi/cam_helper.cpp | 6 +++--- src/ipa/raspberrypi/raspberrypi.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index c8ac3232..6efa0d7f 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -82,10 +82,10 @@ bool CamHelper::SensorEmbeddedDataPresent() const unsigned int CamHelper::HideFramesStartup() const { /* - * By default, hide 6 frames completely at start-up while AGC etc. sort - * themselves out (converge). + * The number of frames when a camera first starts that shouldn't be + * displayed as they are invalid in some way. */ - return 6; + return 0; } unsigned int CamHelper::HideFramesModeSwitch() const diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 0300b8d9..ddabdb31 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -192,6 +192,14 @@ int IPARPi::start(const IPAOperationData &ipaConfig, IPAOperationData *result) unsigned int dropFrame = 0; if (firstStart_) { dropFrame = helper_->HideFramesStartup(); + + /* The AGC algorithm may want us to drop more frames. */ + RPiController::AgcAlgorithm *agc = dynamic_cast( + controller_.GetAlgorithm("agc")); + if (agc) + dropFrame = std::max(dropFrame, agc->GetDropFrames()); + LOG(IPARPI, Debug) << "Drop " << dropFrame << " frames on startup"; + mistrustCount_ = helper_->MistrustFramesStartup(); } else { dropFrame = helper_->HideFramesModeSwitch();