From patchwork Mon Jun 28 20:22:50 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: 12737 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 DE526C321F for ; Mon, 28 Jun 2021 20:23:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 11FC7684DF; Mon, 28 Jun 2021 22:23:04 +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="E+AhN7OK"; 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 2C82360508 for ; Mon, 28 Jun 2021 22:23:00 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:c3ad:78d0:405e:fc33]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BF575E1A; Mon, 28 Jun 2021 22:22:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1624911779; bh=xkdDA1ZOoupVOv9QCvdpZOzjk0vdTtZMgVmltEckeRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E+AhN7OKSh4n3qHi+lYvPn3rbxS0TnIXDFuEKOzrvogrMyxMD4c7BX8ut186F8+bU 3a8CybOvYwz63Wnx5XIYrPisKIxm60tYgObEJtNBPSZvfToAgTZF/nvBVLrM61Ctgi +/dkCrbVOvRYo+bJ96z3+HwC2mZ7hI5DvFlhIg1s= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Mon, 28 Jun 2021 22:22:50 +0200 Message-Id: <20210628202255.138874-3-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628202255.138874-1-jeanmichel.hautbois@ideasonboard.com> References: <20210628202255.138874-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/7] ipa: libipa: Create a common ISP header to store the structure types 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" Each ISP may use the same AWB or AGC algorithms. In order to avoid duplicated code, create a header with the main structures used for now. Signed-off-by: Jean-Michel Hautbois --- src/ipa/ipu3/ipu3_agc.h | 1 + src/ipa/ipu3/ipu3_awb.h | 30 +---------- src/ipa/libipa/isp.h | 110 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 29 deletions(-) create mode 100644 src/ipa/libipa/isp.h diff --git a/src/ipa/ipu3/ipu3_agc.h b/src/ipa/ipu3/ipu3_agc.h index 3deca3ae..6ca9af8e 100644 --- a/src/ipa/ipu3/ipu3_agc.h +++ b/src/ipa/ipu3/ipu3_agc.h @@ -17,6 +17,7 @@ #include #include "libipa/algorithm.h" +#include "libipa/isp.h" namespace libcamera { diff --git a/src/ipa/ipu3/ipu3_awb.h b/src/ipa/ipu3/ipu3_awb.h index 122cf68c..6ae111fd 100644 --- a/src/ipa/ipu3/ipu3_awb.h +++ b/src/ipa/ipu3/ipu3_awb.h @@ -14,6 +14,7 @@ #include #include "libipa/algorithm.h" +#include "libipa/isp.h" namespace libcamera { @@ -42,35 +43,6 @@ public: unsigned char padding[3]; } __attribute__((packed)); - /* \todo Make these three structs available to all the ISPs ? */ - struct RGB { - RGB(double _R = 0, double _G = 0, double _B = 0) - : R(_R), G(_G), B(_B) - { - } - double R, G, B; - RGB &operator+=(RGB const &other) - { - R += other.R, G += other.G, B += other.B; - return *this; - } - }; - - struct IspStatsRegion { - unsigned int counted; - unsigned int uncounted; - unsigned long long rSum; - unsigned long long gSum; - unsigned long long bSum; - }; - - struct AwbStatus { - double temperatureK; - double redGain; - double greenGain; - double blueGain; - }; - private: void generateZones(std::vector &zones); void generateAwbStats(const ipu3_uapi_stats_3a *stats); diff --git a/src/ipa/libipa/isp.h b/src/ipa/libipa/isp.h new file mode 100644 index 00000000..a15803d6 --- /dev/null +++ b/src/ipa/libipa/isp.h @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Ideas On Board + * + * isp.h - ISP statistics interface + */ +#ifndef __LIBCAMERA_IPA_LIBIPA_ISP_H__ +#define __LIBCAMERA_IPA_LIBIPA_ISP_H__ + +namespace libcamera { + +namespace ipa { +/** + * \struct RGB + * \brief RGB + * + * \fn RGB::RGB + * \brief Construct a RGB structure + * \param[in] _R Red value to set, defaults to 0 + * \param[in] _G Green value to set, defaults to 0 + * \param[in] _B Blue value to set, defaults to 0 + * + * \var RGB::R + * \brief Red value of the RGB structure + * + * \var RGB::G + * \brief Green value of the RGB structure + * + * \var RGB::B + * \brief Blue value of the RGB structure + * + * \fn RGB &RGB::operator+=(RGB const &other) + * \brief Add each RGB value to another RGB structure + * \param[in] other An RGB structure + * \return An RGB structure containing the added R, G and B values + */ +struct RGB { + RGB(double _R = 0, double _G = 0, double _B = 0) + : R(_R), G(_G), B(_B) + { + } + double R, G, B; + RGB &operator+=(RGB const &other) + { + R += other.R, G += other.G, B += other.B; + return *this; + } +}; + +/** + * \struct IspStatsRegion + * \brief RGB statistics for a given region + * + * The IspStatsRegion structure is intended to abstract the ISP specific + * statistics and use an agnostic algorithm to compute AWB. + * + * \var IspStatsRegion::counted + * \brief Number of pixels used to calculate the sums + * + * \var IspStatsRegion::uncounted + * \brief Remaining number of pixels in the region + * + * \var IspStatsRegion::rSum + * \brief Sum of the red values in the region + * + * \var IspStatsRegion::gSum + * \brief Sum of the green values in the region + * + * \var IspStatsRegion::bSum + * \brief Sum of the blue values in the region + */ +struct IspStatsRegion { + unsigned int counted; + unsigned int uncounted; + unsigned long long rSum; + unsigned long long gSum; + unsigned long long bSum; +}; + +/** + * \struct AwbStatus + * \brief AWB parameters calculated + * + * The AwbStatus structure is intended to store the AWB + * parameters calculated by the algorithm + * + * \var AwbStatus::temperatureK + * \brief Color temperature calculated + * + * \var AwbStatus::redGain + * \brief Gain calculated for the red channel + * + * \var AwbStatus::greenGain + * \brief Gain calculated for the green channel + * + * \var AwbStatus::blueGain + * \brief Gain calculated for the blue channel + */ +struct AwbStatus { + double temperatureK; + double redGain; + double greenGain; + double blueGain; +}; + +} /* namespace ipa */ + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPA_LIBIPA_ISP_H__ */