[libcamera-devel] [PATCH 2/2] ipa: ipu3: Remove ipa::ipu3::algorithms::Ipu3AwbCell
Jean-Michel Hautbois
jeanmichel.hautbois at ideasonboard.com
Thu Sep 2 12:07:32 CEST 2021
As intel-ipu3.h now has a defined AWB layout, use that one instead of
the ipa::ipu3::algorithms::Ipu3AwbCell.
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois at ideasonboard.com>
---
src/ipa/ipu3/algorithms/agc.cpp | 7 ++++---
src/ipa/ipu3/algorithms/awb.cpp | 10 +++++-----
src/ipa/ipu3/algorithms/awb.h | 10 ----------
3 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp
index 5ff50f4a..288ce7f0 100644
--- a/src/ipa/ipu3/algorithms/agc.cpp
+++ b/src/ipa/ipu3/algorithms/agc.cpp
@@ -96,9 +96,10 @@ void Agc::processBrightness(const ipu3_uapi_stats_3a *stats,
* We observed a bit shift which makes the value 160 to be 32 in the stats grid.
* Use the one passed at init time.
*/
- if (stats->awb_raw_buffer.meta_data[i + 4 + j * grid.width] == 0) {
- uint8_t Gr = stats->awb_raw_buffer.meta_data[i + 0 + j * grid.width];
- uint8_t Gb = stats->awb_raw_buffer.meta_data[i + 3 + j * grid.width];
+ const ipu3_uapi_awb_set_item *currentCell = reinterpret_cast<ipu3_uapi_awb_set_item *>(const_cast<uint8_t *>(&stats->awb_raw_buffer.meta_data[i + 4 + j * grid.width]));
+ if (currentCell->sat_ratio == 0) {
+ uint8_t Gr = currentCell->Gr_avg;
+ uint8_t Gb = currentCell->Gb_avg;
hist[(Gr + Gb) / 2]++;
count++;
}
diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp
index ea567f96..d97724fa 100644
--- a/src/ipa/ipu3/algorithms/awb.cpp
+++ b/src/ipa/ipu3/algorithms/awb.cpp
@@ -207,14 +207,14 @@ void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats,
cellPosition *= 8;
/* Cast the initial IPU3 structure to simplify the reading */
- Ipu3AwbCell *currentCell = reinterpret_cast<Ipu3AwbCell *>(const_cast<uint8_t *>(&stats->awb_raw_buffer.meta_data[cellPosition]));
- if (currentCell->satRatio == 0) {
+ const ipu3_uapi_awb_set_item *currentCell = reinterpret_cast<ipu3_uapi_awb_set_item *>(const_cast<uint8_t *>(&stats->awb_raw_buffer.meta_data[cellPosition]));
+ if (currentCell->sat_ratio == 0) {
/* The cell is not saturated, use the current cell */
awbStats_[awbRegionPosition].counted++;
- uint32_t greenValue = currentCell->greenRedAvg + currentCell->greenBlueAvg;
+ uint32_t greenValue = currentCell->Gr_avg + currentCell->Gb_avg;
awbStats_[awbRegionPosition].sum.green += greenValue / 2;
- awbStats_[awbRegionPosition].sum.red += currentCell->redAvg;
- awbStats_[awbRegionPosition].sum.blue += currentCell->blueAvg;
+ awbStats_[awbRegionPosition].sum.red += currentCell->R_avg;
+ awbStats_[awbRegionPosition].sum.blue += currentCell->B_avg;
}
}
}
diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h
index 23f3e872..a9320b4c 100644
--- a/src/ipa/ipu3/algorithms/awb.h
+++ b/src/ipa/ipu3/algorithms/awb.h
@@ -23,16 +23,6 @@ namespace ipa::ipu3::algorithms {
static constexpr uint32_t kAwbStatsSizeX = 16;
static constexpr uint32_t kAwbStatsSizeY = 12;
-/* \todo Move the cell layout into intel-ipu3.h kernel header */
-struct Ipu3AwbCell {
- unsigned char greenRedAvg;
- unsigned char redAvg;
- unsigned char blueAvg;
- unsigned char greenBlueAvg;
- unsigned char satRatio;
- unsigned char padding[3];
-} __attribute__((packed));
-
struct Accumulator {
unsigned int counted;
unsigned int total;
--
2.30.2
More information about the libcamera-devel
mailing list