From patchwork Fri Nov 19 10:25:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 14644 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 52C42BDB13 for ; Fri, 19 Nov 2021 10:26:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 027046037A; Fri, 19 Nov 2021 11:26:13 +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="JxO3yNp+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4531160233 for ; Fri, 19 Nov 2021 11:26:10 +0100 (CET) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:db30:8e54:a96:9838]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E32F71974; Fri, 19 Nov 2021 11:26:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1637317570; bh=SSb3qYmndLEnttp29l6Fr35d5hdTWH76Sr0H6uo5QPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JxO3yNp+R5FEliqFVcHbJ9AeOBtl/noRww9YfQJeO6ScNpdDutg8XAHqW1Weq6YbG l4x59z/L8YpKxuFbCVq93RkNBbN29oH9+Pu6J+toZQh90RN/oLwYxBnWnVN+xctJei kLPpFGmdG4hcwMnAv8FP7iSlW0/oUJwOKwki0UCA= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Fri, 19 Nov 2021 11:25:58 +0100 Message-Id: <20211119102559.56522-2-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211119102559.56522-1-jeanmichel.hautbois@ideasonboard.com> References: <20211119102559.56522-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libipa: Round gain code before returning the value 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" We can have the case where the gain is very close to 1, as coded in double, and after gainCode() returns, the value as an uint32_t is 0. In order to avoid that, always round the value halfway cases away from zero before returning. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham --- src/ipa/libipa/camera_sensor_helper.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp index 0b0eb503..67cf6913 100644 --- a/src/ipa/libipa/camera_sensor_helper.cpp +++ b/src/ipa/libipa/camera_sensor_helper.cpp @@ -7,6 +7,8 @@ */ #include "camera_sensor_helper.h" +#include + #include /** @@ -61,8 +63,8 @@ uint32_t CameraSensorHelper::gainCode(double gain) const ASSERT(analogueGainConstants_.m0 == 0 || analogueGainConstants_.m1 == 0); ASSERT(analogueGainConstants_.type == AnalogueGainLinear); - return (analogueGainConstants_.c0 - analogueGainConstants_.c1 * gain) / - (analogueGainConstants_.m1 * gain - analogueGainConstants_.m0); + return std::round((analogueGainConstants_.c0 - analogueGainConstants_.c1 * gain) / + (analogueGainConstants_.m1 * gain - analogueGainConstants_.m0)); } /** From patchwork Fri Nov 19 10:25:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 14645 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 81277C324F for ; Fri, 19 Nov 2021 10:26:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EEB1160378; Fri, 19 Nov 2021 11:26:13 +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="NiEQn8Nu"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BC796036F for ; Fri, 19 Nov 2021 11:26:10 +0100 (CET) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:db30:8e54:a96:9838]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 18F411AE6; Fri, 19 Nov 2021 11:26:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1637317570; bh=V0WsY6iM3tw7RlE1W95bNVv/cl9cGY0dd60oxVDed/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NiEQn8NuCpF9zzmqBCBk3wjiveqPVK2JzKzP3a1ur5rRjlVZwYFpEG7+6hHw1oHdP bAL3uSFmOBLnfwvS3MpIkW10dFuWhTIMwPVrCMctAS4LBwk33k0w+5f7DasHgBIomK I8xGgXVR4m3nw8ARTl7QHzMwecFxiO687JYfp7/4= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Fri, 19 Nov 2021 11:25:59 +0100 Message-Id: <20211119102559.56522-3-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211119102559.56522-1-jeanmichel.hautbois@ideasonboard.com> References: <20211119102559.56522-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libipa: Correct IMX219 in CameraSensorHelper 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 equation is badly reported in the CameraSensorHelper, as m1 and c0 are inverted. Correct it to have a proper gain calculation. Signed-off-by: Jean-Michel Hautbois Acked-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/libipa/camera_sensor_helper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp index 67cf6913..5e22f9c3 100644 --- a/src/ipa/libipa/camera_sensor_helper.cpp +++ b/src/ipa/libipa/camera_sensor_helper.cpp @@ -292,7 +292,7 @@ class CameraSensorHelperImx219 : public CameraSensorHelper public: CameraSensorHelperImx219() { - analogueGainConstants_ = { AnalogueGainLinear, 0, -1, 256, 256 }; + analogueGainConstants_ = { AnalogueGainLinear, 0, 256, -1, 256 }; } }; REGISTER_CAMERA_SENSOR_HELPER("imx219", CameraSensorHelperImx219)