summaryrefslogtreecommitdiff
path: root/src/ipa/ipu3
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2022-03-15 16:11:34 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2022-04-09 21:00:47 +0200
commit3067203325a8bd7831e24c71fdc4322cde03c715 (patch)
tree7cdbac7435617759271e91f60d3643bf12791c40 /src/ipa/ipu3
parent50dc051fc62bfd5367c55d99384c4c99f0c03bdd (diff)
ipa: ipu3: af: Use geometry classes to perform grid centering
Use our geometry classes for Rectangle, Size and Point to identify the region of interest for the autofocus, and center it on the BDS output. This will facilitate custom ROI being passed in through controls at a later time. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Tested-by: Kate Hsuan <hpa@redhat.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/ipu3')
-rw-r--r--src/ipa/ipu3/algorithms/af.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp
index 2902f2d5..b96078f5 100644
--- a/src/ipa/ipu3/algorithms/af.cpp
+++ b/src/ipa/ipu3/algorithms/af.cpp
@@ -160,16 +160,23 @@ int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)
grid.height_per_slice = kAfDefaultHeightPerSlice;
- /* x_start and y start are default to BDS center */
- grid.x_start = (configInfo.bdsOutputSize.width / 2) -
- (((grid.width << grid.block_width_log2) / 2));
- grid.y_start = (configInfo.bdsOutputSize.height / 2) -
- (((grid.height << grid.block_height_log2) / 2));
+ /* Position the AF grid in the center of the BDS output. */
+ Rectangle bds(configInfo.bdsOutputSize);
+ Size gridSize(grid.width << grid.block_width_log2,
+ grid.height << grid.block_height_log2);
+
+ /*
+ * \todo - Support request metadata
+ * - Set the ROI based on any input controls in the request
+ * - Return the AF ROI as metadata in the Request
+ */
+ Rectangle roi = gridSize.centeredTo(bds.center());
+ Point start = roi.topLeft();
/* x_start and y_start should be even */
- grid.x_start = (grid.x_start / 2) * 2;
- grid.y_start = (grid.y_start / 2) * 2;
- grid.y_start = grid.y_start | IPU3_UAPI_GRID_Y_START_EN;
+ grid.x_start = utils::alignDown(start.x, 2);
+ grid.y_start = utils::alignDown(start.y, 2);
+ grid.y_start |= IPU3_UAPI_GRID_Y_START_EN;
/* Initial max focus step */
maxStep_ = kMaxFocusSteps;