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);