From patchwork Thu Mar 4 15:31:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 11498 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 63FBABD80C for ; Thu, 4 Mar 2021 15:31:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 01BEA68A98; Thu, 4 Mar 2021 16:31:27 +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="M3uR0Vbw"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A6E4602ED for ; Thu, 4 Mar 2021 16:31:25 +0100 (CET) Received: by mail-wm1-x32c.google.com with SMTP id k66so10112810wmf.1 for ; Thu, 04 Mar 2021 07:31:25 -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=Cdk9CfEFsqBeO5H/wJtNdPeCQxTmsiOJvmejofZe9Jo=; b=M3uR0Vbww4/+/CS/eG5kqje2+IhsAmcHwKWDmNrsl9cSt0g9FiPRwhexPLfXQBeZuo gnF7iQPrrfKrTYx8hHa4A+COlNWgVkGW9lKEZyjPhFVYEiXUH20V2IxPK2nRTbJHhnVU y5kpSbM9QtSWoF2tT4dPUurC+zf9fjmSX5PpDxFQne3fY0vMF7PQBGxEMhPKyQWnByU5 ZMHgNw7+lKZLmhpCKv1nmiCR05iZIPz/YvBM4TJD31QYGsngRZgOFdzZBBdQhOBW7XJm iM3MVf4wFDgdmymbmug6h7Dza7sJp2YHAmyeUgzluZ4IzYH9pf/CQGLlC5bfHU52R3WD gk+A== 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=Cdk9CfEFsqBeO5H/wJtNdPeCQxTmsiOJvmejofZe9Jo=; b=Fi5LU/lKpbB/3Fp8PTMTi/Clg/K2GuSZOXhhM9BMdAg+cjWURUcQwbFow8G+L0wOEU UVKSnUdGz78gQ4FU8ww3hHK/RL1bqfv5al7OermRd+ses14MC81HXQa45p2gDUXI6ild hLrpbVtHkry+mhp+2bCZqNjC2QcIu2UGt63k28LL+GnCdrWRpGgEe9NBPNU2XBRAtiZx kTgUC4L+eurqMNs8qX727b9gV/LZZLuOgZDPz9Xvn8Fk8WjxXxW0R4HbGZvXUrujx6S0 tN8qwbxC/IQihyQLlg49x+UdMX9BmMx3WTwG2fgtrpVuY01otzI2quq1xQmGdv5R8Py3 m5WA== X-Gm-Message-State: AOAM532fNMWVHtJGppaXF+MCUSOK+ZJ5faWlQVGYtR3V9frf51Jf8UPv KGYfzlVCVc8hCATPECZVU+xcrkpvacdMYg== X-Google-Smtp-Source: ABdhPJz35it7fFxGdK/m0uAISnqGj7fDPFfkuFP3hEh9ZdJ1rLo9jSMRyxtuq+f4h0uUJ9Xanpbi6A== X-Received: by 2002:a05:600c:2204:: with SMTP id z4mr4662920wml.31.1614871884693; Thu, 04 Mar 2021 07:31:24 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id f7sm20306129wrm.36.2021.03.04.07.31.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 07:31:24 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 4 Mar 2021 15:31:19 +0000 Message-Id: <20210304153120.1904-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210304153120.1904-1-david.plowman@raspberrypi.com> References: <20210304153120.1904-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] ipa: raspberrypi: Make CamHelpers return the frame delay for vblanking 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" For some sensors (e.g. imx477) we need to update the vblanking on the frame before the exposure. For this reason the GetDelays method must also return the number of frame delays for the vblanking control. Signed-off-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/cam_helper.cpp | 4 +++- src/ipa/raspberrypi/cam_helper.hpp | 9 ++++++--- src/ipa/raspberrypi/cam_helper_imx477.cpp | 7 +++++-- src/ipa/raspberrypi/cam_helper_ov5647.cpp | 7 +++++-- src/ipa/raspberrypi/raspberrypi.cpp | 6 +++--- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 2837fcce..0ae0baa0 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -95,7 +95,8 @@ void CamHelper::SetCameraMode(const CameraMode &mode) initialized_ = true; } -void CamHelper::GetDelays(int &exposure_delay, int &gain_delay) const +void CamHelper::GetDelays(int &exposure_delay, int &gain_delay, + int &vblank_delay) const { /* * These values are correct for many sensors. Other sensors will @@ -103,6 +104,7 @@ void CamHelper::GetDelays(int &exposure_delay, int &gain_delay) const */ exposure_delay = 2; gain_delay = 1; + vblank_delay = 2; } bool CamHelper::SensorEmbeddedDataPresent() const diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp index 14d70112..8c5659ed 100644 --- a/src/ipa/raspberrypi/cam_helper.hpp +++ b/src/ipa/raspberrypi/cam_helper.hpp @@ -28,8 +28,10 @@ namespace RPiController { // exposure time, and to convert between the sensor's gain codes and actual // gains. // -// A method to return the number of frames of delay between updating exposure -// and analogue gain and the changes taking effect. For many sensors these +// A method to return the number of frames of delay between updating exposure, +// analogue gain and vblanking, and for the changes to take effect. For many +// sensors these take the values 2, 1 and 2 respectively, but sensors that are +// different will need to over-ride the default method provided. // take the values 2 and 1 respectively, but sensors that are different will // need to over-ride the default method provided. // @@ -72,7 +74,8 @@ public: double maxFrameDuration) const; virtual uint32_t GainCode(double gain) const = 0; virtual double Gain(uint32_t gain_code) const = 0; - virtual void GetDelays(int &exposure_delay, int &gain_delay) const; + virtual void GetDelays(int &exposure_delay, int &gain_delay, + int &vblank_delay) const; virtual bool SensorEmbeddedDataPresent() const; virtual unsigned int HideFramesStartup() const; virtual unsigned int HideFramesModeSwitch() const; diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 419f8e77..73a5ca7d 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -37,7 +37,8 @@ public: CamHelperImx477(); uint32_t GainCode(double gain) const override; double Gain(uint32_t gain_code) const override; - void GetDelays(int &exposure_delay, int &gain_delay) const override; + void GetDelays(int &exposure_delay, int &gain_delay, + int &vblank_delay) const override; bool SensorEmbeddedDataPresent() const override; private: @@ -63,10 +64,12 @@ double CamHelperImx477::Gain(uint32_t gain_code) const return 1024.0 / (1024 - gain_code); } -void CamHelperImx477::GetDelays(int &exposure_delay, int &gain_delay) const +void CamHelperImx477::GetDelays(int &exposure_delay, int &gain_delay, + int &vblank_delay) const { exposure_delay = 2; gain_delay = 2; + vblank_delay = 3; } bool CamHelperImx477::SensorEmbeddedDataPresent() const diff --git a/src/ipa/raspberrypi/cam_helper_ov5647.cpp b/src/ipa/raspberrypi/cam_helper_ov5647.cpp index 75486e90..12be6bf9 100644 --- a/src/ipa/raspberrypi/cam_helper_ov5647.cpp +++ b/src/ipa/raspberrypi/cam_helper_ov5647.cpp @@ -17,7 +17,8 @@ public: CamHelperOv5647(); uint32_t GainCode(double gain) const override; double Gain(uint32_t gain_code) const override; - void GetDelays(int &exposure_delay, int &gain_delay) const override; + void GetDelays(int &exposure_delay, int &gain_delay, + int &vblank_delay) const override; unsigned int HideFramesStartup() const override; unsigned int HideFramesModeSwitch() const override; unsigned int MistrustFramesStartup() const override; @@ -51,7 +52,8 @@ double CamHelperOv5647::Gain(uint32_t gain_code) const return static_cast(gain_code) / 16.0; } -void CamHelperOv5647::GetDelays(int &exposure_delay, int &gain_delay) const +void CamHelperOv5647::GetDelays(int &exposure_delay, int &gain_delay, + int &vblank_delay) const { /* * We run this sensor in a mode where the gain delay is bumped up to @@ -59,6 +61,7 @@ void CamHelperOv5647::GetDelays(int &exposure_delay, int &gain_delay) const */ exposure_delay = 2; gain_delay = 2; + vblank_delay = 2; } unsigned int CamHelperOv5647::HideFramesStartup() const diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 6348d071..741bff4c 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -342,14 +342,14 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, * Pass out the sensor config to the pipeline handler in order * to setup the staggered writer class. */ - int gainDelay, exposureDelay, sensorMetadata; - helper_->GetDelays(exposureDelay, gainDelay); + int gainDelay, exposureDelay, vblankDelay, sensorMetadata; + helper_->GetDelays(exposureDelay, gainDelay, vblankDelay); sensorMetadata = helper_->SensorEmbeddedDataPresent(); result->params |= ipa::RPi::ConfigSensorParams; result->sensorConfig.gainDelay = gainDelay; result->sensorConfig.exposureDelay = exposureDelay; - result->sensorConfig.vblank = exposureDelay; + result->sensorConfig.vblank = vblankDelay; result->sensorConfig.sensorMetadata = sensorMetadata; }