From patchwork Fri Jul 9 15:07:23 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: 12892 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 63CFCC3224 for ; Fri, 9 Jul 2021 15:07:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 10AEA6851C; Fri, 9 Jul 2021 17:07:29 +0200 (CEST) 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="IHp4xBT2"; 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 BC993605AC for ; Fri, 9 Jul 2021 17:07:27 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:d47a:9456:f481:a0f8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 336FCE7; Fri, 9 Jul 2021 17:07:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1625843247; bh=1VNo+PUq2GpdYOx4oX7ByeLYwmzswg/wTGt0tC0Qsck=; h=From:To:Cc:Subject:Date:From; b=IHp4xBT2GSc4n+e3xJMZ1FTsdQXNWRmg+wn4xcwqDSzZnPmaJYHBJhJ0sOQCSfYbB HPc1j1p4usDkZoyRz0wmzwxw2TJIHr5lC+P+hyOEzXSajXH4X0fXPBfvk3nkus9hwF a9iGizU+Y6FhgAoMncpG6nHNfOhAmJDXL0Sdj4ew= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 17:07:23 +0200 Message-Id: <20210709150723.55966-1-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] ipa: libipa: Fixups in CameraSensorHelpers 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" A few lines needed to be wrapped under 80 lines. Remove some unneeded documentation and minor typos. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/libipa/camera_sensor_helper.cpp | 80 +++++++++++++------------ src/ipa/libipa/camera_sensor_helper.h | 32 +++++----- 2 files changed, 59 insertions(+), 53 deletions(-) diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp index 23335ed6..84d8ccf7 100644 --- a/src/ipa/libipa/camera_sensor_helper.cpp +++ b/src/ipa/libipa/camera_sensor_helper.cpp @@ -2,11 +2,12 @@ /* * Copyright (C) 2021, Google Inc. * - * camera_sensor_helper.cpp - Helper class that performs sensor-specific parameter computations + * camera_sensor_helper.cpp - Helper class that performs sensor-specific + * parameter computations */ #include "camera_sensor_helper.h" -#include "libcamera/base/log.h" +#include /** * \file camera_sensor_helper.h @@ -29,17 +30,18 @@ namespace ipa { /** * \class CameraSensorHelper - * \brief Base class for computing sensor tuning parameters using sensor-specific constants + * \brief Base class for computing sensor tuning parameters using + * sensor-specific constants * - * Instances derived from CameraSensorHelper class are sensor specific. + * Instances derived from CameraSensorHelper class are sensor-specific. * Each supported sensor will have an associated base class defined. */ /** * \brief Construct a CameraSensorHelper instance * - * CameraSensorHelper derived class instances shall never be constructed manually - * but always through the CameraSensorHelperFactory::create() method. + * CameraSensorHelper derived class instances shall never be constructed + * manually but always through the CameraSensorHelperFactory::create() method. */ /** @@ -52,11 +54,11 @@ namespace ipa { * The parameters come from the MIPI Alliance Camera Specification for * Camera Command Set (CCS). * - * \return The gain code to pass to V4l2 + * \return The gain code to pass to V4L2 */ uint32_t CameraSensorHelper::gainCode(double gain) const { - ASSERT((analogueGainConstants_.m0 == 0) || (analogueGainConstants_.m1 == 0)); + ASSERT(analogueGainConstants_.m0 == 0 || analogueGainConstants_.m1 == 0); ASSERT(analogueGainConstants_.type == AnalogueGainLinear); return (analogueGainConstants_.c0 - analogueGainConstants_.c1 * gain) / @@ -64,8 +66,8 @@ uint32_t CameraSensorHelper::gainCode(double gain) const } /** - * \brief Compute the real gain from the V4l2 subdev control gain code - * \param[in] gainCode The V4l2 subdev control gain + * \brief Compute the real gain from the V4L2 subdev control gain code + * \param[in] gainCode The V4L2 subdev control gain * * This function aims to abstract the calculation of the gain letting the IPA * use the real gain for its estimations. It is the counterpart of the function @@ -78,7 +80,7 @@ uint32_t CameraSensorHelper::gainCode(double gain) const */ double CameraSensorHelper::gain(uint32_t gainCode) const { - ASSERT((analogueGainConstants_.m0 == 0) || (analogueGainConstants_.m1 == 0)); + ASSERT(analogueGainConstants_.m0 == 0 || analogueGainConstants_.m1 == 0); ASSERT(analogueGainConstants_.type == AnalogueGainLinear); return (analogueGainConstants_.m0 * static_cast(gainCode) + analogueGainConstants_.c0) / @@ -90,7 +92,7 @@ double CameraSensorHelper::gain(uint32_t gainCode) const * \brief The gain calculation modes as defined by the MIPI CCS * * Describes the image sensor analogue gain capabilities. - * Two modes are possible, depending on the sensor: Global and Alternate. + * Two modes are possible, depending on the sensor: Linear and Exponential. */ /** @@ -114,11 +116,12 @@ double CameraSensorHelper::gain(uint32_t gainCode) const /** * \var CameraSensorHelper::AnalogueGainExponential - * \brief Gain is computed using exponential gain estimation (introduced in CCS v1.1) + * \brief Gain is computed using exponential gain estimation + * (introduced in CCS v1.1) * * Starting with CCS v1.1, Alternate Global Analogue Gain is also available. - * If the image sensor supports it, then the global analogue gain can be controlled - * by linear and exponential gain formula: + * If the image sensor supports it, then the global analogue gain can be + * controlled by linear and exponential gain formula: * * \f$gain = analogLinearGainGlobal * 2^{analogExponentialGainGlobal}\f$ * \todo not implemented in libipa @@ -194,11 +197,13 @@ CameraSensorHelperFactory::CameraSensorHelperFactory(const std::string name) } /** - * \brief Create an instance of the CameraSensorHelper corresponding to the factory + * \brief Create an instance of the CameraSensorHelper corresponding to + * a named factory * \param[in] name Name of the factory * * \return A unique pointer to a new instance of the CameraSensorHelper subclass - * corresponding to the factory + * corresponding to the named factory or a null pointer if no such factory + * exists */ std::unique_ptr CameraSensorHelperFactory::create(const std::string &name) { @@ -220,33 +225,36 @@ std::unique_ptr CameraSensorHelperFactory::create(const std: * \brief Add a camera sensor helper class to the registry * \param[in] factory Factory to use to construct the camera sensor helper * - * The caller is responsible to guarantee the uniqueness of the camera sensor helper - * name. + * The caller is responsible to guarantee the uniqueness of the camera sensor + * helper name. */ void CameraSensorHelperFactory::registerType(CameraSensorHelperFactory *factory) { - std::vector &factories = CameraSensorHelperFactory::factories(); + std::vector &factories = + CameraSensorHelperFactory::factories(); factories.push_back(factory); } /** * \brief Retrieve the list of all camera sensor helper factories - * - * The static factories map is defined inside the function to ensures it gets - * initialized on first use, without any dependency on link order. - * * \return The list of camera sensor helper factories */ std::vector &CameraSensorHelperFactory::factories() { + /* + * The static factories map is defined inside the function to ensure + * it gets initialized on first use, without any dependency on link + * order. + */ static std::vector factories; return factories; } /** * \fn CameraSensorHelperFactory::createInstance() - * \brief Create an instance of the CameraSensorHelper corresponding to the factory + * \brief Create an instance of the CameraSensorHelper corresponding to the + * factory * * This virtual function is implemented by the REGISTER_CAMERA_SENSOR_HELPER() * macro. It creates a camera sensor helper instance associated with the camera @@ -267,14 +275,16 @@ std::vector &CameraSensorHelperFactory::factories() * \param[in] name Sensor model name used to register the class * \param[in] helper Class name of CameraSensorHelper derived class to register * - * Register a CameraSensorHelper subclass with the factory and make it available to - * try and match devices. + * Register a CameraSensorHelper subclass with the factory and make it available + * to try and match sensors. */ -/** - * \class CameraSensorHelperImx219 - * \brief Create and give helpers for the imx219 sensor +/* ----------------------------------------------------------------------------- + * Sensor-specific subclasses */ + +#ifndef __DOXYGEN__ + class CameraSensorHelperImx219 : public CameraSensorHelper { public: @@ -285,10 +295,6 @@ public: }; REGISTER_CAMERA_SENSOR_HELPER("imx219", CameraSensorHelperImx219) -/** - * \class CameraSensorHelperOv5670 - * \brief Create and give helpers for the ov5670 sensor - */ class CameraSensorHelperOv5670 : public CameraSensorHelper { public: @@ -299,10 +305,6 @@ public: }; REGISTER_CAMERA_SENSOR_HELPER("ov5670", CameraSensorHelperOv5670) -/** - * \class CameraSensorHelperOv5693 - * \brief Create and give helpers for the ov5693 sensor - */ class CameraSensorHelperOv5693 : public CameraSensorHelper { public: @@ -313,6 +315,8 @@ public: }; REGISTER_CAMERA_SENSOR_HELPER("ov5693", CameraSensorHelperOv5693) +#endif /* __DOXYGEN__ */ + } /* namespace ipa */ } /* namespace libcamera */ diff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h index 1c47e8d5..a7e4ab3b 100644 --- a/src/ipa/libipa/camera_sensor_helper.h +++ b/src/ipa/libipa/camera_sensor_helper.h @@ -30,8 +30,8 @@ public: protected: enum AnalogueGainType { - AnalogueGainLinear = 0, - AnalogueGainExponential = 2, + AnalogueGainLinear, + AnalogueGainExponential, }; struct AnalogueGainConstants { @@ -60,24 +60,26 @@ public: static std::vector &factories(); protected: - LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraSensorHelperFactory) virtual CameraSensorHelper *createInstance() = 0; +private: + LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraSensorHelperFactory) + std::string name_; }; -#define REGISTER_CAMERA_SENSOR_HELPER(name, helper) \ -class helper##Factory final : public CameraSensorHelperFactory \ -{ \ -public: \ - helper##Factory() : CameraSensorHelperFactory(name) {} \ - \ -private: \ - CameraSensorHelper *createInstance() \ - { \ - return new helper(); \ - } \ -}; \ +#define REGISTER_CAMERA_SENSOR_HELPER(name, helper) \ +class helper##Factory final : public CameraSensorHelperFactory \ +{ \ +public: \ + helper##Factory() : CameraSensorHelperFactory(name) {} \ + \ +private: \ + CameraSensorHelper *createInstance() \ + { \ + return new helper(); \ + } \ +}; \ static helper##Factory global_##helper##Factory; } /* namespace ipa */