From patchwork Mon Mar 8 22:39:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 11522 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 65F15BD1F1 for ; Mon, 8 Mar 2021 22:39:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 21E2768A92; Mon, 8 Mar 2021 23:39:48 +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="X6/6KZFl"; 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 329B168A92 for ; Mon, 8 Mar 2021 23:39:46 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id j2so13132801wrx.9 for ; Mon, 08 Mar 2021 14:39:46 -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=6cpGSK6jVuNXhIB+3pAc3OxbV7hDqDDnMJI2a0EMvhA=; b=X6/6KZFlLZojPbFlT+nkiMttNwc0Oq3GiLzAc6FUZH7nPUIAWIspO0eujzlRlviEV4 QWJBXkAvn8ENdZW7bBDv47ByFpSJ22kUFlctpTBF+9UBH4gt21X+ya7n4md3BCn2+JsI 7zcxm+xgi75sBSQA35rgTNpizVHUYDCGNPnHwJ/hDDj6Cw6lYqSBV00xNJ/Ym0LrC6Qe UwnrejU1poATNh3P450qTjXkwRVSO6h9EKDXEHVwKuIqrLfAvNeQSez4MWidUGWGtTiv pydhF9Na/eNiRiYyy6DHhiZw1FkBEkviGCB8Xr1RBIuBttoo8o2C2WW9ux0c4qs4h+4f x2DA== 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=6cpGSK6jVuNXhIB+3pAc3OxbV7hDqDDnMJI2a0EMvhA=; b=LttiFN9tuAXoX195xmkp4owCRwDABqYpp4IgumcFoGmu74UFNcr5T/hTWhrTEuhkeL Zs/arWnY+C+pdAQtSrlhIHQqrSEBbcyBbtgeFtz6Gtv4gqqLKaKpncpNPIY4LKXnVqeB hfpvvoW8fq+GwiwKtTDwDBSk4rnq21Jl2mpdZNgcFUUvT5u8O2kdN/1DJFPMdvtC6Q7K 8GMOj7iGuZusuW6kTtalffTIZoFfPwrNe9aObvNtmugj/lNBghbxtZe0dDzodZjrAxkS ScEWRvaPwJKUAXv8M8GqjyByBMUBMTknDnYhSsaHGN0FeL6H/Bee96NNbjVtSO8yFXPg Yr+Q== X-Gm-Message-State: AOAM531oQLd2mPTdTp7goyTY2elIkyHN/upDE1G2YDNcn8w5FHbR6q83 9kAnZohjcbwYg3086n0CBQjFHvzsntVtBg== X-Google-Smtp-Source: ABdhPJzQvn1Mla0NAasRRN1r3IbKR3QnLeUjQj4w3MS8FoYievxT3hPM6tkEMquRTuztwIByfOQk9A== X-Received: by 2002:adf:c186:: with SMTP id x6mr25583284wre.253.1615243185665; Mon, 08 Mar 2021 14:39:45 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id f17sm19811322wru.31.2021.03.08.14.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 14:39:45 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Mar 2021 22:39:37 +0000 Message-Id: <20210308223939.2088-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210308223939.2088-1-david.plowman@raspberrypi.com> References: <20210308223939.2088-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] 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 --- src/ipa/raspberrypi/cam_helper.cpp | 4 +++- src/ipa/raspberrypi/cam_helper.hpp | 11 ++++++----- 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(+), 13 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..1b2d6eec 100644 --- a/src/ipa/raspberrypi/cam_helper.hpp +++ b/src/ipa/raspberrypi/cam_helper.hpp @@ -28,10 +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 -// take the values 2 and 1 respectively, but sensors that are different will -// need to over-ride the default method provided. +// 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. // // A method to query if the sensor outputs embedded data that can be parsed. // @@ -72,7 +72,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; }