From patchwork Mon Jun 3 22:48:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20196 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 53DDBBDE6B for ; Mon, 3 Jun 2024 22:49:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2F018634CA; Tue, 4 Jun 2024 00:49:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RCjOx77m"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 13D8A61A45 for ; Tue, 4 Jun 2024 00:49:12 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 87B82AB5 for ; Tue, 4 Jun 2024 00:49:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1717454944; bh=euANdLCjLP/csBD1TI4Xr8k1niasdQRatSAAv8A/USY=; h=From:To:Subject:Date:From; b=RCjOx77m3IdpgFY6PJFlatDJN0cfzAEYPQnziY3JGDP2v9AM0AOc+yqmnh9y2wJCF rZIuyQpoTjryKwoCfiPLPM/qS7tjEjfEzhjPbW04WxSyrGlG4sF3/fo18JyLcQsx1J 7a9rc3Gt8GUOwE/159FcAJpyzbNnphoCpXItjlPE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH] libcamera: libipa: camera_sensor: define AR0521 helper functions inline Date: Tue, 4 Jun 2024 01:48:55 +0300 Message-ID: <20240603224855.25011-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 MIME-Version: 1.0 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" All CameraSensorHelper subclasses define their member functions inline, except for the CameraSensorHelperAr0521 class. Inline the gainCode() and gain() functions to match the other classes. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/ipa/libipa/camera_sensor_helper.cpp | 36 +++++++++++-------------- 1 file changed, 16 insertions(+), 20 deletions(-) base-commit: 6cd17515ffeb67fb38ffcc4d57aadf9732b54800 diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp index 2cd61fccfbb9..782ff9904e81 100644 --- a/src/ipa/libipa/camera_sensor_helper.cpp +++ b/src/ipa/libipa/camera_sensor_helper.cpp @@ -369,30 +369,26 @@ static constexpr double expGainDb(double step) class CameraSensorHelperAr0521 : public CameraSensorHelper { public: - uint32_t gainCode(double gain) const override; - double gain(uint32_t gainCode) const override; + uint32_t gainCode(double gain) const override + { + gain = std::clamp(gain, 1.0, 15.5); + unsigned int coarse = std::log2(gain); + unsigned int fine = (gain / (1 << coarse) - 1) * kStep_; + + return (coarse << 4) | (fine & 0xf); + } + + double gain(uint32_t gainCode) const override + { + unsigned int coarse = gainCode >> 4; + unsigned int fine = gainCode & 0xf; + + return (1 << coarse) * (1 + fine / kStep_); + } private: static constexpr double kStep_ = 16; }; - -uint32_t CameraSensorHelperAr0521::gainCode(double gain) const -{ - gain = std::clamp(gain, 1.0, 15.5); - unsigned int coarse = std::log2(gain); - unsigned int fine = (gain / (1 << coarse) - 1) * kStep_; - - return (coarse << 4) | (fine & 0xf); -} - -double CameraSensorHelperAr0521::gain(uint32_t gainCode) const -{ - unsigned int coarse = gainCode >> 4; - unsigned int fine = gainCode & 0xf; - - return (1 << coarse) * (1 + fine / kStep_); -} - REGISTER_CAMERA_SENSOR_HELPER("ar0521", CameraSensorHelperAr0521) class CameraSensorHelperImx219 : public CameraSensorHelper