From patchwork Mon Jun 27 16:27:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16393 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 C67BEBD808 for ; Mon, 27 Jun 2022 16:28:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7C62265659; Mon, 27 Jun 2022 18:28:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656347282; bh=G5D9fOHWCM9PZClxjpkw4/6UIxce7BP82fLdpzG/XbE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WytnHA9OjvJRq08/lbM2ZWuRaG6sOmS2kpOusVhJ/ag3IH1pqMx3+eyBAxCPNQ2L3 bzVs8FEQ8wtBAJceDj5POVQW2o81YlQSRt6T+UubSCfmrihQ10QyfeHUa5CLYkiPP1 OJel7IhwHizfkb486NtWZoQyvwfI4FcozSJkuPmlVb8RwdEC992v2Bobx0rnjs2wEL y6O51fyoDjyBDaKEqjHRJsJfwPn/LB6s89SlZwuR9scadMFFG7TQz8Wx+KgTwx7wk/ YVhykYoXrZ7ozWAS2QyVRpV9w5M4xL7UQTWXYig4rrJK8ddNMqv5yaEsF0eY7wERiv EL/1NXbQ3PsPQ== Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7752C65648 for ; Mon, 27 Jun 2022 18:27:52 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id BA53720004; Mon, 27 Jun 2022 16:27:51 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Jun 2022 18:27:29 +0200 Message-Id: <20220627162732.33160-13-jacopo@jmondi.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627162732.33160-1-jacopo@jmondi.org> References: <20220627162732.33160-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 12/15] libcamera: ipa: Use the current VBLANK value 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The IPU3 IPA module uses the default value from the V4L2_CID_VBLANK control to compute the total frame size in processStatsBuffer(). Most drivers update the VBLANK control limits when a new format is applied and assign to the default the current control value. As this is not required by the API specification, and the VBLANK default value can be different than its current value, use the actual control value as now available from the IPACameraSensorInfo structure. Signed-off-by: Jacopo Mondi --- src/ipa/ipu3/ipa_context.cpp | 4 ++-- src/ipa/ipu3/ipa_context.h | 2 +- src/ipa/ipu3/ipu3.cpp | 15 ++++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp index 13cdb835ef7f..06fdf2a1efc7 100644 --- a/src/ipa/ipu3/ipa_context.cpp +++ b/src/ipa/ipu3/ipa_context.cpp @@ -126,8 +126,8 @@ namespace libcamera::ipa::ipu3 { * \var IPASessionConfiguration::sensor.lineDuration * \brief Line duration in microseconds * - * \var IPASessionConfiguration::sensor.defVBlank - * \brief The default vblank value of the sensor + * \var IPASessionConfiguration::sensor.vBlank + * \brief The vertical blanking expressed in number of lines */ /** diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h index 42e11141d3a1..a5b878ab7792 100644 --- a/src/ipa/ipu3/ipa_context.h +++ b/src/ipa/ipu3/ipa_context.h @@ -43,7 +43,7 @@ struct IPASessionConfiguration { } agc; struct { - int32_t defVBlank; + int32_t vBlank; utils::Duration lineDuration; } sensor; }; diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 7e8bf0feee8a..3efbc84c4ef1 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -149,7 +149,7 @@ public: const uint32_t bufferId, const ControlList &sensorControls) override; private: - void updateSessionConfiguration(const ControlInfoMap &sensorControls); + void updateSessionConfiguration(const IPAConfigInfo &info); bool validateSensorControls(); @@ -177,10 +177,12 @@ private: * \brief Compute IPASessionConfiguration using the sensor information and the * sensor V4L2 controls */ -void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls) +void IPAIPU3::updateSessionConfiguration(const IPAConfigInfo &info) { - const ControlInfo vBlank = sensorControls.find(V4L2_CID_VBLANK)->second; - context_.configuration.sensor.defVBlank = vBlank.def().get(); + const IPACameraSensorInfo &sensorInfo = info.sensorInfo; + context_.configuration.sensor.vBlank = sensorInfo.vblank; + + const ControlInfoMap &sensorControls = info.sensorControls; const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second; int32_t minExposure = v4l2Exposure.min().get(); @@ -391,7 +393,7 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo) } /* Update the IPASessionConfiguration using the sensor settings. */ - updateSessionConfiguration(sensorCtrls_); + updateSessionConfiguration(configInfo); for (auto const &algo : algorithms_) { int ret = algo->configure(context_, configInfo); @@ -501,7 +503,7 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, frameContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get()); double lineDuration = context_.configuration.sensor.lineDuration.get(); - int32_t vBlank = context_.configuration.sensor.defVBlank; + int32_t vBlank = context_.configuration.sensor.vBlank; ControlList ctrls(controls::controls); for (auto const &algo : algorithms_) @@ -509,7 +511,6 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, setControls(frame); - /* \todo Use VBlank value calculated from each frame exposure. */ int64_t frameDuration = (vBlank + sensorInfo_.outputSize.height) * lineDuration; ctrls.set(controls::FrameDuration, frameDuration);