From 09a221eb47128146c5f7f88ff3f71cb8bcfe3228 Mon Sep 17 00:00:00 2001 From: Jean-Michel Hautbois Date: Wed, 22 Sep 2021 23:29:42 +0200 Subject: ipa: ipu3: Replace ipa::ipu3::algorithms::Ipu3AwbCell The intel-ipu3.h public interface from the kernel does not define how to parse the statistics for a cell. This had to be identified by a process of reverse engineering, and later identifying the structures from [0] leading to our custom definition of struct Ipu3AwbCell. [0] https://chromium.googlesource.com/chromiumos/platform/arc-camera/+/refs/heads/master/hal/intel/include/ia_imaging/awb_public.h To improve the kernel interface, a proposal has been made to the linux-kernel [1] to incorporate the memory layout for each cell into the intel-ipu3 header directly. [1] https://lore.kernel.org/linux-media/20211005202019.253353-1-jeanmichel.hautbois@ideasonboard.com/ Update our local copy of the intel-ipu3.h to match the proposal and change the AGC and AWB algorithms to reference that structure directly, allowing us to remove the deprecated custom Ipu3AwbCell definition. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/ipu3/algorithms/awb.cpp | 41 +++++++---------------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) (limited to 'src/ipa/ipu3/algorithms/awb.cpp') diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp index 3cff9aa4..e2b18336 100644 --- a/src/ipa/ipu3/algorithms/awb.cpp +++ b/src/ipa/ipu3/algorithms/awb.cpp @@ -108,32 +108,6 @@ static constexpr uint32_t kMinGreenLevelInZone = 32; * \brief Gain calculated for the blue channel */ -/** - * \struct Ipu3AwbCell - * \brief Memory layout for each cell in AWB metadata - * - * The Ipu3AwbCell structure is used to get individual values - * such as red average or saturation ratio in a particular cell. - * - * \var Ipu3AwbCell::greenRedAvg - * \brief Green average for red lines in the cell - * - * \var Ipu3AwbCell::redAvg - * \brief Red average in the cell - * - * \var Ipu3AwbCell::blueAvg - * \brief blue average in the cell - * - * \var Ipu3AwbCell::greenBlueAvg - * \brief Green average for blue lines - * - * \var Ipu3AwbCell::satRatio - * \brief Saturation ratio in the cell - * - * \var Ipu3AwbCell::padding - * \brief array of unused bytes for padding - */ - /* Default settings for Bayer noise reduction replicated from the Kernel */ static const struct ipu3_uapi_bnr_static_config imguCssBnrDefaults = { .wb_gains = { 16, 16, 16, 16 }, @@ -247,25 +221,24 @@ void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats) */ for (unsigned int cellY = 0; cellY < kAwbStatsSizeY * cellsPerZoneY_; cellY++) { for (unsigned int cellX = 0; cellX < kAwbStatsSizeX * cellsPerZoneX_; cellX++) { - uint32_t cellPosition = (cellY * stride_ + cellX) - * sizeof(Ipu3AwbCell); + uint32_t cellPosition = cellY * stride_ + cellX; uint32_t zoneX = cellX / cellsPerZoneX_; uint32_t zoneY = cellY / cellsPerZoneY_; uint32_t awbZonePosition = zoneY * kAwbStatsSizeX + zoneX; /* Cast the initial IPU3 structure to simplify the reading */ - const Ipu3AwbCell *currentCell = - reinterpret_cast( + const ipu3_uapi_awb_set_item *currentCell = + reinterpret_cast( &stats->awb_raw_buffer.meta_data[cellPosition] ); - if (currentCell->satRatio == 0) { + if (currentCell->sat_ratio == 0) { /* The cell is not saturated, use the current cell */ awbStats_[awbZonePosition].counted++; - uint32_t greenValue = currentCell->greenRedAvg + currentCell->greenBlueAvg; + uint32_t greenValue = currentCell->Gr_avg + currentCell->Gb_avg; awbStats_[awbZonePosition].sum.green += greenValue / 2; - awbStats_[awbZonePosition].sum.red += currentCell->redAvg; - awbStats_[awbZonePosition].sum.blue += currentCell->blueAvg; + awbStats_[awbZonePosition].sum.red += currentCell->R_avg; + awbStats_[awbZonePosition].sum.blue += currentCell->B_avg; } } } -- cgit v1.2.1