From patchwork Mon Jun 28 20:22:51 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: 12738 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 AC442C321F for ; Mon, 28 Jun 2021 20:23:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2546E684DA; Mon, 28 Jun 2021 22:23:05 +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="PQ5knaXr"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4B4E66028C 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 EFC9B26FE; 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=1624911780; bh=Z1+aTxtelZoqMZmGab2uUv6Y2wd+AI/zZc5WyJunc8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PQ5knaXrwVmGGoqvbAhC4+ruYb+B5oJf2Hw5WABufXOQ2I5EsIiE4tKg6PgjVgxW4 TsV62sGoGvs+Otz8YYOCicSP0I90DY1DOBbk2vwXJ0Y262i6uTv5ZrA2JhDCaevFQ1 LhmmsB9nxoBzES2I5HJT9Ye5sWI9t6b7F82N8T6k= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Mon, 28 Jun 2021 22:22:51 +0200 Message-Id: <20210628202255.138874-4-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 3/7] ipa: ipu3: Use a common IPU3 header for the constants 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" Every constants used can be needed by both AWB and AGC (for the moment). Use a common header to simplify their usage. Signed-off-by: Jean-Michel Hautbois --- src/ipa/ipu3/ipu3_agc.h | 2 ++ src/ipa/ipu3/ipu3_awb.h | 11 ++------- src/ipa/ipu3/ipu3_common.h | 49 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 src/ipa/ipu3/ipu3_common.h diff --git a/src/ipa/ipu3/ipu3_agc.h b/src/ipa/ipu3/ipu3_agc.h index 6ca9af8e..774c8385 100644 --- a/src/ipa/ipu3/ipu3_agc.h +++ b/src/ipa/ipu3/ipu3_agc.h @@ -7,6 +7,8 @@ #ifndef __LIBCAMERA_IPU3_AGC_H__ #define __LIBCAMERA_IPU3_AGC_H__ +#include "ipu3_common.h" + #include #include diff --git a/src/ipa/ipu3/ipu3_awb.h b/src/ipa/ipu3/ipu3_awb.h index 6ae111fd..f4100f4a 100644 --- a/src/ipa/ipu3/ipu3_awb.h +++ b/src/ipa/ipu3/ipu3_awb.h @@ -7,6 +7,8 @@ #ifndef __LIBCAMERA_IPU3_AWB_H__ #define __LIBCAMERA_IPU3_AWB_H__ +#include "ipu3_common.h" + #include #include @@ -34,15 +36,6 @@ public: void calculateWBGains(const ipu3_uapi_stats_3a *stats); void updateWbParameters(ipu3_uapi_params ¶ms, double agcGamma); - struct Ipu3AwbCell { - unsigned char greenRedAvg; - unsigned char redAvg; - unsigned char blueAvg; - unsigned char greenBlueAvg; - unsigned char satRatio; - unsigned char padding[3]; - } __attribute__((packed)); - private: void generateZones(std::vector &zones); void generateAwbStats(const ipu3_uapi_stats_3a *stats); diff --git a/src/ipa/ipu3/ipu3_common.h b/src/ipa/ipu3/ipu3_common.h new file mode 100644 index 00000000..38ef49ce --- /dev/null +++ b/src/ipa/ipu3/ipu3_common.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Ideas On Board + * + * isp.h - ISP statistics interface + */ +#ifndef __LIBCAMERA_IPA_IPU3_COMMON_H__ +#define __LIBCAMERA_IPA_IPU3_COMMON_H__ + +#include + +namespace libcamera { + +namespace ipa { + +/* Region size for the statistics generation algorithm */ +static constexpr uint32_t kAwbStatsSizeX = 16; +static constexpr uint32_t kAwbStatsSizeY = 12; +static constexpr uint32_t kAwbStatsSize = kAwbStatsSizeX * kAwbStatsSizeY + 1; + +static constexpr uint32_t kAgcStatsSizeX = 7; +static constexpr uint32_t kAgcStatsSizeY = 5; +static constexpr uint32_t kAgcStatsSize = kAgcStatsSizeX * kAgcStatsSizeY + 1; +static constexpr uint32_t kNumAgcWeightedZones = 15; +static constexpr double kCenteredWeights[kNumAgcWeightedZones] = { 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0 }; +static constexpr uint32_t kAgcStatsRegions[kAgcStatsSize] = { + 11, 9, 9, 9, 9, 9, 12, + 7, 5, 3, 3, 3, 6, 8, + 7, 5, 1, 0, 2, 6, 8, + 7, 5, 4, 4, 4, 6, 8, + 13, 10, 10, 10, 10, 10, 14 +}; + +static constexpr uint32_t kMinGreenLevelInZone = 16; + +struct Ipu3AwbCell { + unsigned char greenRedAvg; + unsigned char redAvg; + unsigned char blueAvg; + unsigned char greenBlueAvg; + unsigned char satRatio; + unsigned char padding[3]; +} __attribute__((packed)); + +} /* namespace ipa */ + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPA_IPU3_COMMON_H__ */