From patchwork Fri Mar 11 13:37:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 15443 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 70851BF415 for ; Fri, 11 Mar 2022 13:37:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D36A2632E2; Fri, 11 Mar 2022 14:37:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1647005840; bh=l+5xh2l8LOEdfvnBv2rdbsky+XwfMeyyWARuHaYlYOY=; 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=n1cAMj4nvfRU+YZdXJ4IdCrC5y1Bzgot+Lpb4OlGoZJmv8mH2hbA7qGAFEZeafi5d 0zuAwp1rVu7q4yHko84XKhdKaMq7st6usbAkkiG6XNG1csMg2/cqSFvogL88nTZJCg qChwhCnSUQs6140FYrFy4SNROTgv/HoUqWG4zF3HSWqXv/S+ARtSyIWg9krhxaJUWv wkP2u39hXprWPCx5Iyw02aCyra5IYcKRukOrWv+qtjU3gUskC9RRVN0A1Qv1uB9f2n aVexY4bu5cdTRqJfBo4pdHmT2yHbqEWJBu9mP/yhdDqIvUvh8vZtJG1Vb/0g17roJI XAUagf/oNoWLw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 58799604E8 for ; Fri, 11 Mar 2022 14:37:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="kHbqggkf"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [103.251.226.65]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6759F482; Fri, 11 Mar 2022 14:37:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1647005838; bh=l+5xh2l8LOEdfvnBv2rdbsky+XwfMeyyWARuHaYlYOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kHbqggkfstEsygTQrQlLAtPl1PxQq7w3On4Adv+H1B6/idwR76gD942p4jlyiL9XF 1tp2OSTkirtivMqZmNu6SGmZz8+3L8pckILVGvNshAXGJzZmWyiHnwSWIrRb7ze6kp Vik/vI9ze8F/dmaBmlC1/l+kwdS/EVdMjv63UFPc= To: libcamera-devel@lists.libcamera.org Date: Fri, 11 Mar 2022 19:07:05 +0530 Message-Id: <20220311133705.511853-1-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220224151113.109858-5-jeanmichel.hautbois@ideasonboard.com> References: <20220224151113.109858-5-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [[PATCH v4.1 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: , 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" From: Jean-Michel Hautbois The gain values are coded as u3.13 fixed point values, ie they can not be more than 8. Clamp the values in order to avoid any off limits value which could make the IPU3 behave in a weird manner. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham Signed-off-by: Umang Jain Reviewed-by: Umang Jain --- 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..87a6cc7a 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 ranging [0, 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;