From patchwork Thu Feb 24 15:11:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 15388 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 0275EC3262 for ; Thu, 24 Feb 2022 15:11:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8DA9561179; Thu, 24 Feb 2022 16:11:23 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eVVKGZ4Z"; dkim-atps=neutral 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 7B0F361154 for ; Thu, 24 Feb 2022 16:11:19 +0100 (CET) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:ce74:6df2:4b76:b230]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3B899484; Thu, 24 Feb 2022 16:11:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1645715479; bh=pVNrn3LsHd9D01TInDIdRr6NOWngi+kM+wrAXqd7XOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eVVKGZ4ZDupWfxvYIZnpZ3iSC//0lJeDSoBBK55IX9shVBpTdE1A0+ZCgEVzKmVam Z4gyLRn6eoNs99HrhrtyFJKWoGORTPyzAChF/i/9odd7/MXu2mV77bwaIiO3hatFLp EIxMSZS/AofkgSwcgh4QkSmp+UlVTQywY9p35p7g= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Feb 2022 16:11:13 +0100 Message-Id: <20220224151113.109858-5-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220224151113.109858-1-jeanmichel.hautbois@ideasonboard.com> References: <20220224151113.109858-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 4/4] ipa: ipu3: awb: Clamp gain values 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" The gain values are coded as u3.13 fixed point values, ie they can not be more than 8. Clampt the values in order to avoid any off limits value which could make the IPU3 behave weirdly. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham --- src/ipa/ipu3/algorithms/awb.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp index 1dc27fc9..dc25be81 100644 --- a/src/ipa/ipu3/algorithms/awb.cpp +++ b/src/ipa/ipu3/algorithms/awb.cpp @@ -353,6 +353,14 @@ void Awb::awbGreyWorld() /* Color temperature is not relevant in Grey world but still useful to estimate it :-) */ asyncResults_.temperatureK = estimateCCT(sumRed.R, sumRed.G, sumBlue.B); + + /* + * Gain values are unsigned integer value, range 0 to 8 with 13 bit + * fractional part. + */ + redGain = std::clamp(redGain, 0.0, 65535.0 / 8192); + blueGain = std::clamp(blueGain, 0.0, 65535.0 / 8192); + asyncResults_.redGain = redGain; /* Hardcode the green gain to 1.0. */ asyncResults_.greenGain = 1.0;