From patchwork Fri Mar 25 10:34:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 15557 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 08C9BC0F1B for ; Fri, 25 Mar 2022 10:34:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B9172604DA; Fri, 25 Mar 2022 11:34:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648204466; bh=CWCgDwq3yshEtyjzPFYlN0WK59H01hX8UnTa8DWZ010=; 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=CW5Fz4cPC/YyJHW0qixsQjnV3YjRQWWNm8QOxZJ9FgFqJuzRdlAdQJWyZafs6R1JE X7uQ+eRG0RIc56/ioF9BQFh092rqIeQnVoLvJcnAGK8++REB+OPV5FqJ1c8yPRkt+9 dyqIMnhbhVRO9i1Iv7v7gciK02WlB9RthPjWE+IUume/6OReEz1hOEVIjwF/dx80t1 arQlNCNIP3SXnJ6fda+wfZVUAGUEsLhC/hD9NDOIjyFtyNpfJ4YWL2tslUohc6wpuA sTw4OZMoafwP7RiApTjiIrnnHnpNN5uxEwfg0+7lAicraOMxriN/Auq0mX8hPac5c8 lcezqWJQ3DyVw== 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 C874E604C4 for ; Fri, 25 Mar 2022 11:34:24 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jVg4vWKE"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [103.86.18.118]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4F6986F3; Fri, 25 Mar 2022 11:34:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1648204464; bh=CWCgDwq3yshEtyjzPFYlN0WK59H01hX8UnTa8DWZ010=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jVg4vWKEN9+5gzGfXtUQqFK0t9z1kwh62sAJRbBnk8GwJhYLAlG7FKxNCCRwhMvsP s1MtydqAOkl+whdTfyA8T4rHSb6MlMEXe3MwczTShTQL0FLhH3W7R1bb6lplGDJQZx bqllCP8Lse0CW7JTFXTW7SESBYMkmcTzYIy20wT8= To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Mar 2022 16:04:08 +0530 Message-Id: <20220325103410.38580-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220325103410.38580-1-umang.jain@ideasonboard.com> References: <20220325103410.38580-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 Reviewed-by: Laurent Pinchart --- 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 1ea2c898..a8cc2f6c 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -169,11 +169,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_; @@ -194,10 +190,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 @@ -434,32 +432,12 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, */ sensorCtrls_ = configInfo.sensorControls; - const auto itExp = sensorCtrls_.find(V4L2_CID_EXPOSURE); - if (itExp == sensorCtrls_.end()) { - LOG(IPAIPU3, Error) << "Can't find exposure control"; - return -EINVAL; - } - - const auto itGain = sensorCtrls_.find(V4L2_CID_ANALOGUE_GAIN); - if (itGain == sensorCtrls_.end()) { - LOG(IPAIPU3, Error) << "Can't find gain control"; - return -EINVAL; - } - const auto itVBlank = sensorCtrls_.find(V4L2_CID_VBLANK); if (itVBlank == sensorCtrls_.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 Fri Mar 25 10:34:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 15558 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 60589C0F1B for ; Fri, 25 Mar 2022 10:34:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2822F604C5; Fri, 25 Mar 2022 11:34:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648204470; bh=Wr0qqpZRxyYRcwAYfgEzODdEgXoXRNHhujzeiiT8daI=; 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=lu7LLcmzQXRX27rS4kTYE8x+85TukFLZsfyqtRocptxqrNq2dbz9sb5d3LshVETol 4taXRYmHAhsq0tyf/T9Se8rkk4ZqlyjG2zbh1boGKy6Yk1dA7fMkMVRhd2mzlXKW65 xDGAJ54JHiL4rNiKXCz8bGZytB6mVVbS03fGwKlRHrr+p7gszjF5GfG2hySP34VI0Q sBhA9Ibe3aC7yoPxrlsqbcJguuZPrGl+lvwmO+PIQ1zMTqyleOHZ/a571GAZf+a5pY m1S0Y+yMyM5Q6lYug1m1W/KHy9RHAWiFa4hurph3jhKtbYkEXD+hyIFz2TEYXAI+hf T+cOe+NgAGHqQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AA6C3604C4 for ; Fri, 25 Mar 2022 11:34:28 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BDM6Duxa"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [103.86.18.118]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1BF126F3; Fri, 25 Mar 2022 11:34:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1648204468; bh=Wr0qqpZRxyYRcwAYfgEzODdEgXoXRNHhujzeiiT8daI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BDM6Duxa3r0NxC8lXprUyN/59L25KcslUbrN3HjRgtYZ1UEkYHwSsKvhi6bKw3tFV jizpbswbQGQpUnTprjh62+CUJAPCfET4lGW3pnsZt89PH9qULxqdGnkglBgPd7ZvPG AkpS1KRNrTcPzLfmdItGhPEYPEr7DaaiI+GblvLY= To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Mar 2022 16:04:09 +0530 Message-Id: <20220325103410.38580-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220325103410.38580-1-umang.jain@ideasonboard.com> References: <20220325103410.38580-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 IPASessionConfiguration structure as it is a default static value not expected to change for a session. Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/ipu3/ipa_context.cpp | 3 +++ src/ipa/ipu3/ipa_context.h | 1 + src/ipa/ipu3/ipu3.cpp | 29 +++++++++-------------------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp index 1b59c918..b1570dde 100644 --- a/src/ipa/ipu3/ipa_context.cpp +++ b/src/ipa/ipu3/ipa_context.cpp @@ -115,6 +115,9 @@ 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 */ /** diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h index 6b7a512e..103498ef 100644 --- a/src/ipa/ipu3/ipa_context.h +++ b/src/ipa/ipu3/ipa_context.h @@ -37,6 +37,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 a8cc2f6c..3717d893 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -166,11 +166,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_; @@ -187,15 +182,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 @@ -432,14 +428,6 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, */ sensorCtrls_ = configInfo.sensorControls; - const auto itVBlank = sensorCtrls_.find(V4L2_CID_VBLANK); - if (itVBlank == sensorCtrls_.end()) { - LOG(IPAIPU3, Error) << "Can't find VBLANK control"; - return -EINVAL; - } - - defVBlank_ = itVBlank->second.def().get(); - calculateBdsGrid(configInfo.bdsOutputSize); /* Clean frameContext at each reconfiguration. */ @@ -605,6 +593,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_) @@ -613,7 +602,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); @@ -649,12 +638,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(sensorCtrls_); - 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; ControlList lensCtrls(lensCtrls_); From patchwork Fri Mar 25 10:34:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 15559 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 CB008C0F1B for ; Fri, 25 Mar 2022 10:34:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8165E604C5; Fri, 25 Mar 2022 11:34:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648204473; bh=Yjq93TnpMJ/VWF6HKYm4wDofkiMB1do4fXOKAREtYlI=; 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=hFjiQE6kc6l2oBQiwQIbbS1dBex+wZwIiGO4USWJlkMj1FQHXBpRoRZhvG0CVVjWh JrToSMjsWdKvYs3pMDyzwFWElKx5vZLnUcOD/q0bBBwtQlrshIsaxxcaHSlQDarFDb qV1EORgmy1H/myrBqABI3AeBctACYN2AAAR944w6dp4iHoIMmBHCimGsRugptDzGmg 3fHSTUZT8uJ8hocMggQsJYlDlI4hSeYlrpZl3Hm9jUR4TESU7PJzgH0n2gsIgE7v5K ku6IHEqtFPONcbkeyBfYHqZn8A+PWoYcvHHoZ/gQm0dyQkogwMS4gy/Co3LpAbbyt6 EujF0ED4Hv+BQ== 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 B78EC604C4 for ; Fri, 25 Mar 2022 11:34:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cWqg+n9z"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [103.86.18.118]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DC99D6F3; Fri, 25 Mar 2022 11:34:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1648204471; bh=Yjq93TnpMJ/VWF6HKYm4wDofkiMB1do4fXOKAREtYlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cWqg+n9zLGPHYyCIVJ+arDocFKtrrfEflBKE0nWX1Z/GG14p4DoMSw6jPzjZ6si8o qGhFIScSutLrzBoiRH3c2Of2aIKOWMgTclljZMCqtjQqQ0pgKwYAZpTr1lAJ163d+n e9c5JNcFfm2UzQ66Rv0DUZ/gx66pzIMSaWAgn8vk= To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Mar 2022 16:04:10 +0530 Message-Id: <20220325103410.38580-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220325103410.38580-1-umang.jain@ideasonboard.com> References: <20220325103410.38580-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 3/3] ipa: ipu3: Ensure controls exists in before they are queried 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 validation check for sensor controls validateSensorControls() before they are queried in IPAIPU3::updateSessionConfiguration(). Fail the IPAIPU3::configure() if the required sensor controls are not found. Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/ipu3/ipu3.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 3717d893..50b52d8b 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -155,6 +155,7 @@ private: void parseStatistics(unsigned int frame, int64_t frameTimestamp, const ipu3_uapi_stats_3a *stats); + bool validateSensorControls(); void setControls(unsigned int frame); void calculateBdsGrid(const Size &bdsOutputSize); @@ -268,6 +269,28 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo, *ipaControls = ControlInfoMap(std::move(controls), controls::controls); } +/** + * \brief Validate that the sensor controls mandatory for the IPA exists + */ +bool IPAIPU3::validateSensorControls() +{ + static const uint32_t ctrls[] = { + V4L2_CID_ANALOGUE_GAIN, + V4L2_CID_EXPOSURE, + V4L2_CID_VBLANK, + }; + + for (auto c : ctrls) { + if (sensorCtrls_.find(c) == sensorCtrls_.end()) { + LOG(IPAIPU3, Error) << "Unable to find sensor control " + << utils::hex(c); + return false; + } + } + + return true; +} + /** * \brief Initialize the IPA module and its controls * @@ -433,6 +456,11 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, /* Clean frameContext at each reconfiguration. */ context_.frameContext = {}; + if (!validateSensorControls()) { + LOG(IPAIPU3, Error) << "Sensor control validation failed."; + return -EINVAL; + } + /* Update the camera controls using the new sensor settings. */ updateControls(sensorInfo_, sensorCtrls_, ipaControls);