From patchwork Sat Mar 5 17:28:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 15418 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 4A4EBBE08A for ; Sat, 5 Mar 2022 17:29:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 145B9604EC; Sat, 5 Mar 2022 18:29:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1646501342; bh=cmk4/aGKEaCsrPPNDH155tU13FFBaGemNq5J2Iro72Q=; 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=mqlS0j0TDN8C/MUmERJ57CtLfjEzKZFIAGV5PGaZZApi3jyykT5Ykf60E9jBtaEYu ViaFB+GojdgRfbWVDDGOGByYKIDh6fTdyxCx5jSr0kZ4uxydwv7qrNQGkc4vnTPtI7 yjCxTfjB6lqCzfsDNsx93jiLQHRxKA6SKmsA5nkYqI0sHRnSXamwB+2aO948KTKbvZ /A19uSOO74JPS1FuDD1Gbnh/GRjXL7kSwxNpYl+fVzpbO7J4bisfV3QKjl57CqtiLp IQIcNIxhzrBmVxByg8ceU34+XtmdfGu4P32zWgp3WW0ADXUVsKC/G758xL9GgU5pTG bMvh8D76T6pjQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 28DC0604EC for ; Sat, 5 Mar 2022 18:29:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IN29b5aY"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [103.251.226.47]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 97E30486; Sat, 5 Mar 2022 18:28:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1646501339; bh=cmk4/aGKEaCsrPPNDH155tU13FFBaGemNq5J2Iro72Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IN29b5aY5Ma6NabEu2HgUPX8fmSFWmGDZsduli1X4F6qP4qEl7Sgge7nzK8fuWEZD jap5AUxlpfkqDsCLq591+gjOhCX/F6u39ZJcm76I0/eTfwckA2tP1JLkDWCGgQjtP2 6fAmzVA4ZjTVRDyGeVSaYjSvN38KTHGK1hlql8Uc= To: libcamera-devel@lists.libcamera.org Date: Sat, 5 Mar 2022 22:58:47 +0530 Message-Id: <20220305172849.1022923-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305172849.1022923-1-umang.jain@ideasonboard.com> References: <20220305172849.1022923-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] ipa: ipu3: Consolidate querying of exposure and gain limits 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The exposure and gain limits are required for AGC configuration handled in IPAIPU3::updateSessionConfiguration(), which is happening already. Therefore the max/min private members in IPAIPU3 class for exposure/gain serve no use except setting initial values of exposure_ and gain_ members. Drop the max/min private members from IPAIPU3 class and set initial gain_ and exposure_ in IPAIPU3::updateSessionConfiguration(). Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham --- src/ipa/ipu3/ipu3.cpp | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 17324616..4b6852a7 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -167,11 +167,7 @@ private: /* Camera sensor controls. */ uint32_t defVBlank_; uint32_t exposure_; - uint32_t minExposure_; - uint32_t maxExposure_; uint32_t gain_; - uint32_t minGain_; - uint32_t maxGain_; /* Interface to the Camera Helper */ std::unique_ptr camHelper_; @@ -192,10 +188,12 @@ void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls) const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second; int32_t minExposure = v4l2Exposure.min().get(); int32_t maxExposure = v4l2Exposure.max().get(); + exposure_ = minExposure; const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second; int32_t minGain = v4l2Gain.min().get(); int32_t maxGain = v4l2Gain.max().get(); + gain_ = minGain; /* * When the AGC computes the new exposure values for a frame, it needs @@ -429,32 +427,12 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, */ ctrls_ = configInfo.sensorControls; - const auto itExp = ctrls_.find(V4L2_CID_EXPOSURE); - if (itExp == ctrls_.end()) { - LOG(IPAIPU3, Error) << "Can't find exposure control"; - return -EINVAL; - } - - const auto itGain = ctrls_.find(V4L2_CID_ANALOGUE_GAIN); - if (itGain == ctrls_.end()) { - LOG(IPAIPU3, Error) << "Can't find gain control"; - return -EINVAL; - } - const auto itVBlank = ctrls_.find(V4L2_CID_VBLANK); if (itVBlank == ctrls_.end()) { LOG(IPAIPU3, Error) << "Can't find VBLANK control"; return -EINVAL; } - minExposure_ = itExp->second.min().get(); - maxExposure_ = itExp->second.max().get(); - exposure_ = minExposure_; - - minGain_ = itGain->second.min().get(); - maxGain_ = itGain->second.max().get(); - gain_ = minGain_; - defVBlank_ = itVBlank->second.def().get(); calculateBdsGrid(configInfo.bdsOutputSize); From patchwork Sat Mar 5 17:28:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 15419 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 B0277BE08A for ; Sat, 5 Mar 2022 17:29:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7BA1D6118B; Sat, 5 Mar 2022 18:29:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1646501344; bh=adS21eA+3hCQ1yBQ9m8vrCb0Dl95vsLSMAXalXLLTY8=; 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=CDV1q1VuIbJGtFJdXWs4t37ZMBI+V3x8Myj7HIFduXG7Jl4HTdiU4FnXqUGLsS0Eo TFdYqK50cm+2KwXn0GpbDY6VA4TlpGfFIZEWdjBEgKhMGueTZ6JZalhelBCyFN2g9p 2n63MSD5p3OV9efxTGobLPv4DTFbWh2IE4NVVF/NWpS2ICmpRGEPjCKhiiT7FiK1Bf yHI0gP8WDVfrGmfko0NIwNnDj532iiqIVVFrJKVEaIp2w9X6mTHpv/Zmo3MP3VBvTI dDBmLNEuA/djNSGknmMOzGJkFxuUipjCXflC6a9ruOd+/udtinSwfjupIMKCUEgsID ohhPc/FhI9fWA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 811FF604EA for ; Sat, 5 Mar 2022 18:29:02 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="i7X8OeXo"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [103.251.226.47]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2D7AE488; Sat, 5 Mar 2022 18:29:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1646501342; bh=adS21eA+3hCQ1yBQ9m8vrCb0Dl95vsLSMAXalXLLTY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i7X8OeXo5KpzJSo8KJkMbqzFcGRij3fjICO7/a3XjN8YerB+eAwp7j5xpi3/7oVNF CvDcCjrZiPX3DF2dJkSdW3dqKWbIXk8eyz6jXvw7+PvU5GaODVncEQsw99ZsUzCVt/ dic8LBpHyYNUvFgMe8JztiNGlalGLN5dyjQkb5EU= To: libcamera-devel@lists.libcamera.org Date: Sat, 5 Mar 2022 22:58:48 +0530 Message-Id: <20220305172849.1022923-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305172849.1022923-1-umang.jain@ideasonboard.com> References: <20220305172849.1022923-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/3] ipa: ipu3: Drop sensor controls private members from IPAIPU3 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Drop exposure, gain private members from IPAIPU3 because the values are handled directly via IPAFrameContext. Move the default vblank value from IPAIPU3 to IPASessionContext structure as it is a default static value not expected to change for a session. Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham --- src/ipa/ipu3/ipa_context.h | 1 + src/ipa/ipu3/ipu3.cpp | 29 +++++++++-------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h index e7c49828..d993359a 100644 --- a/src/ipa/ipu3/ipa_context.h +++ b/src/ipa/ipu3/ipa_context.h @@ -33,6 +33,7 @@ struct IPASessionConfiguration { } agc; struct { + int32_t defVBlank; utils::Duration lineDuration; } sensor; }; diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 4b6852a7..0df358ba 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -164,11 +164,6 @@ private: IPACameraSensorInfo sensorInfo_; - /* Camera sensor controls. */ - uint32_t defVBlank_; - uint32_t exposure_; - uint32_t gain_; - /* Interface to the Camera Helper */ std::unique_ptr camHelper_; @@ -185,15 +180,16 @@ private: */ void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls) { + const ControlInfo vBlank = sensorControls.find(V4L2_CID_VBLANK)->second; + context_.configuration.sensor.defVBlank = vBlank.def().get(); + const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second; int32_t minExposure = v4l2Exposure.min().get(); int32_t maxExposure = v4l2Exposure.max().get(); - exposure_ = minExposure; const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second; int32_t minGain = v4l2Gain.min().get(); int32_t maxGain = v4l2Gain.max().get(); - gain_ = minGain; /* * When the AGC computes the new exposure values for a frame, it needs @@ -427,14 +423,6 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, */ ctrls_ = configInfo.sensorControls; - const auto itVBlank = ctrls_.find(V4L2_CID_VBLANK); - if (itVBlank == ctrls_.end()) { - LOG(IPAIPU3, Error) << "Can't find VBLANK control"; - return -EINVAL; - } - - defVBlank_ = itVBlank->second.def().get(); - calculateBdsGrid(configInfo.bdsOutputSize); /* Clean frameContext at each reconfiguration. */ @@ -600,6 +588,7 @@ void IPAIPU3::parseStatistics(unsigned int frame, const ipu3_uapi_stats_3a *stats) { double lineDuration = context_.configuration.sensor.lineDuration.get(); + int32_t vBlank = context_.configuration.sensor.defVBlank; ControlList ctrls(controls::controls); for (auto const &algo : algorithms_) @@ -608,7 +597,7 @@ void IPAIPU3::parseStatistics(unsigned int frame, setControls(frame); /* \todo Use VBlank value calculated from each frame exposure. */ - int64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height) * lineDuration; + int64_t frameDuration = (vBlank + sensorInfo_.outputSize.height) * lineDuration; ctrls.set(controls::FrameDuration, frameDuration); ctrls.set(controls::AnalogueGain, context_.frameContext.sensor.gain); @@ -644,12 +633,12 @@ void IPAIPU3::setControls(unsigned int frame) IPU3Action op; op.op = ActionSetSensorControls; - exposure_ = context_.frameContext.agc.exposure; - gain_ = camHelper_->gainCode(context_.frameContext.agc.gain); + int32_t exposure = context_.frameContext.agc.exposure; + int32_t gain = camHelper_->gainCode(context_.frameContext.agc.gain); ControlList ctrls(ctrls_); - ctrls.set(V4L2_CID_EXPOSURE, static_cast(exposure_)); - ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain_)); + ctrls.set(V4L2_CID_EXPOSURE, exposure); + ctrls.set(V4L2_CID_ANALOGUE_GAIN, gain); op.sensorControls = ctrls; queueFrameAction.emit(frame, op); From patchwork Sat Mar 5 17:28:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 15420 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 2D29ABE08A for ; Sat, 5 Mar 2022 17:29:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E29156118E; Sat, 5 Mar 2022 18:29:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1646501345; bh=Dra6j4U9wXK1bxGWxix8iPA+iBh2aObdr9gHvtZO8yQ=; 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=k/P+F6sYbtaKrKeAYdGJP+Lgu9jRcQb8NjrKwPK50FtHZynyRLIeH2gCbdouO1T4+ 7jXESkZU+3IsmvJfcTmoW2+5+zdbkptvAVwi+2cPuQfaAmYpghaeBcCMdmnrPoGmqM BfSXNK02QBLVEE0e48PCVKm1Fu1voM9ncd6jTYfWa5loN1+AhWfUxvFVIKpD6Rx28y znxTJly1DzxQZQ9O8838lFoDOdD5tyCKLHd6eMQoxy39V6td0QZMjTArJDAPQ1jISI DOZ7gDqzy8q7l5oxYGFbuMo2PVnPybbGa2zsMiGd0hKQlFaE/+KGLeY8QV8RJiJ0t3 P4/8vuz2pDpdg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A4EC061190 for ; Sat, 5 Mar 2022 18:29:04 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="oeaboy7r"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [103.251.226.47]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 51F1F486; Sat, 5 Mar 2022 18:29:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1646501344; bh=Dra6j4U9wXK1bxGWxix8iPA+iBh2aObdr9gHvtZO8yQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oeaboy7rDCcmiw9C9s6wSSRmEl1RmfUzu6u7MkiXjKb06T1wO7wf7BUA0XbG6MTd7 S6L7JAs0sw5t8BZLvDIZiWmY0cbvxnawWoYMKRbBIKSaxuHO4Ss/Z0fPd8+czg3Qcv WgvO/ZsRxe+/8h6kryZojqCszJaps+aqehjFA8p8= To: libcamera-devel@lists.libcamera.org Date: Sat, 5 Mar 2022 22:58:49 +0530 Message-Id: <20220305172849.1022923-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305172849.1022923-1-umang.jain@ideasonboard.com> References: <20220305172849.1022923-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] ipa: ipu3: Ensure controls exists in updateSessionConfiguration() 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a control-not-found error checking for the controls being queried in IPAIPU3::updateSessionConfiguration(). Signed-off-by: Umang Jain --- src/ipa/ipu3/ipu3.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 0df358ba..583d6b9a 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -180,16 +180,31 @@ private: */ void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls) { - const ControlInfo vBlank = sensorControls.find(V4L2_CID_VBLANK)->second; - context_.configuration.sensor.defVBlank = vBlank.def().get(); + const auto itVBlank = sensorControls.find(V4L2_CID_VBLANK); + if (itVBlank == sensorControls.end()) { + LOG(IPAIPU3, Error) << "Can't find vblank control"; + return; + } - const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second; - int32_t minExposure = v4l2Exposure.min().get(); - int32_t maxExposure = v4l2Exposure.max().get(); + context_.configuration.sensor.defVBlank = itVBlank->second.def().get(); + + const auto itExp = sensorControls.find(V4L2_CID_EXPOSURE); + if (itExp == sensorControls.end()) { + LOG(IPAIPU3, Error) << "Can't find exposure control"; + return; + } + + int32_t minExposure = itExp->second.min().get(); + int32_t maxExposure = itExp->second.max().get(); + + const auto itGain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN); + if (itGain == sensorControls.end()) { + LOG(IPAIPU3, Error) << "Can't find analogue gain control"; + return; + } - const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second; - int32_t minGain = v4l2Gain.min().get(); - int32_t maxGain = v4l2Gain.max().get(); + int32_t minGain = itGain->second.min().get(); + int32_t maxGain = itGain->second.max().get(); /* * When the AGC computes the new exposure values for a frame, it needs