From patchwork Mon Feb 7 07:16:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kate Hsuan X-Patchwork-Id: 15333 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 76FE9BF415 for ; Mon, 7 Feb 2022 07:18:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B119B61030; Mon, 7 Feb 2022 08:18:11 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="PmXz9icQ"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 97D7260E6E for ; Mon, 7 Feb 2022 08:18:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644218288; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HjSIuFVZV7v8Y34QUeDaMb0K8aZZlAe1/0mqd9QYVbA=; b=PmXz9icQsAJ5jL0UmWql276VwU3geh0okwzP2cG8aUn5mTBLJ64upGLZPYYw/ktSZd1fRB Lc0RgaUGyzMvicFoM2+BEkT1ByFzXQYZm9op3LGZx1BKvECR/dDeYtY7U3wMvTj7IBE9l+ VVcb/Kjfj97nZsQg8BlmVGJqMHdZfV4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-518-gfiEa6jDPq60RX6dwrUXLQ-1; Mon, 07 Feb 2022 02:18:06 -0500 X-MC-Unique: gfiEa6jDPq60RX6dwrUXLQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB07E1006AA3 for ; Mon, 7 Feb 2022 07:18:05 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.39.192.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 447C47AB6B; Mon, 7 Feb 2022 07:17:52 +0000 (UTC) From: Kate Hsuan To: libcamera devel Date: Mon, 7 Feb 2022 15:16:06 +0800 Message-Id: <20220207071606.18564-1-hpa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hpa@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [libcamera-devel] [RFC v6] ipa: ipu3: af: Auto focus for dw9719 Surface Go2 VCM 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" Since VCM for surface Go 2 (dw9719) had been successfully driven, this Af module can be used to control the VCM and determine the focus value based on the IPU3 AF state. Based on the values from the IPU3 AF buffer, the variance of each focus step is determined and a greedy approach is used to find the maximum variance of the AF state and an appropriate focus value. The grid configuration is implemented as a context. Also, the grid parameter- AF_MIN_BLOCK_WIDTH is set to 4 (default is 3) since if the default value is used, x_start (x_start > 640) will be at an incorrect location of the image (rightmost of the sensor). Signed-off-by: Kate Hsuan Tested-by: Jean-Michel Hautbois --- src/ipa/ipu3/algorithms/af.cpp | 375 ++++++++++++++++++++++++++++ src/ipa/ipu3/algorithms/af.h | 78 ++++++ src/ipa/ipu3/algorithms/meson.build | 3 +- src/ipa/ipu3/ipa_context.cpp | 24 ++ src/ipa/ipu3/ipa_context.h | 10 + src/ipa/ipu3/ipu3.cpp | 36 +++ 6 files changed, 525 insertions(+), 1 deletion(-) create mode 100644 src/ipa/ipu3/algorithms/af.cpp create mode 100644 src/ipa/ipu3/algorithms/af.h diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp new file mode 100644 index 00000000..f67ab8a9 --- /dev/null +++ b/src/ipa/ipu3/algorithms/af.cpp @@ -0,0 +1,375 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Red Hat + * + * af.cpp - IPU3 auto focus algorithm + */ + +#include "af.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include "libipa/histogram.h" + +/** + * \file af.h + */ + +/** + * \var AF_MIN_GRID_WIDTH + * \brief the minimum width of AF grid. + * The minimum grid horizontal dimensions, in number of grid blocks(cells). +*/ + +/** + * \var AF_MIN_GRID_HEIGHT + * \brief the minimum height of AF grid. + * The minimum grid vertical dimensions, in number of grid blocks(cells). +*/ + +/** + * \var AF_MAX_GRID_WIDTH + * \brief the maximum width of AF grid. + * The maximum grid horizontal dimensions, in number of grid blocks(cells). +*/ + +/** + * \var AF_MAX_GRID_HEIGHT + * \brief the maximum height of AF grid. + * The maximum grid vertical dimensions, in number of grid blocks(cells). +*/ + +/** + * \var AF_MIN_BLOCK_WIDTH + * \brief the minimum block size of the width. + */ + +/** + * \var AF_MIN_BLOCK_HEIGHT + * \brief the minimum block size of the height. + */ + +/** + * \def AF_MAX_BLOCK_WIDTH + * \brief the maximum block size of the width. + */ + +/** + * \var AF_MAX_BLOCK_HEIGHT + * \brief the maximum block size of the height. + */ + +/** + * \var AF_DEFAULT_HEIGHT_PER_SLICE + * \brief The default number of blocks in vertical axis per slice. + */ + +namespace libcamera { + +using namespace std::literals::chrono_literals; + +namespace ipa::ipu3::algorithms { + +/** + * \class Af + * \brief An auto-focus algorithm based on IPU3 statistics + * + * This algorithm is used to determine the position of the lens and get a + * focused image. The IPU3 AF processing block computes the statistics, + * composed by high pass and low pass filtered value and stores in a AF buffer. + * Typically, for a focused image, it has relative high contrast than a + * blurred image, i.e. an out of focus image. Therefore, if an image with the + * highest contrast can be found from the AF scan, the lens' position is the + * best step of the focus. + * + */ + +LOG_DEFINE_CATEGORY(IPU3Af) + +/** + * Maximum focus steps of the VCM control + * \todo should be obtained from the VCM driver + */ +static constexpr uint32_t maxFocusSteps = 1023; + +/* minimum focus step for searching appropriate focus */ +static constexpr uint32_t coarseSearchStep = 30; +static constexpr uint32_t fineSearchStep = 1; + +/* max ratio of variance change, 0.0 < maxChange < 1.0 */ +static constexpr double maxChange = 0.5; + +/* the numbers of frame to be ignored, before performing focus scan. */ +static constexpr uint32_t ignoreFrame = 10; + +/* fine scan range 0 < findRange < 1 */ +static constexpr double findRange = 0.05; + +/* settings for IPU3 AF filter */ +static struct ipu3_uapi_af_filter_config afFilterConfigDefault = { + .y1_coeff_0 = { 0, 1, 3, 7 }, + .y1_coeff_1 = { 11, 13, 1, 2 }, + .y1_coeff_2 = { 8, 19, 34, 242 }, + .y1_sign_vec = 0x7fdffbfe, + .y2_coeff_0 = { 0, 1, 6, 6 }, + .y2_coeff_1 = { 13, 25, 3, 0 }, + .y2_coeff_2 = { 25, 3, 177, 254 }, + .y2_sign_vec = 0x4e53ca72, + .y_calc = { 8, 8, 8, 8 }, + .nf = { 0, 9, 0, 9, 0 }, +}; + +Af::Af() + : focus_(0), goodFocus_(0), currentVariance_(0.0), previousVariance_(0.0), + coarseComplete_(false), fineComplete_(false) +{ + maxStep_ = maxFocusSteps; +} + +Af::~Af() +{ +} + +/** + * \copydoc libcamera::ipa::Algorithm::prepare + */ +void Af::prepare(IPAContext &context, ipu3_uapi_params *params) +{ + const struct ipu3_uapi_grid_config &grid = context.configuration.af.afGrid; + params->acc_param.af.grid_cfg = grid; + params->acc_param.af.filter_config = afFilterConfigDefault; + + /* enable AF processing block */ + params->use.acc_af = 1; +} + +/** + * \brief Configure the Af given a configInfo + * \param[in] context The shared IPA context + * \param[in] configInfo The IPA configuration data + * + * \return 0 + */ +int Af::configure(IPAContext &context, [[maybe_unused]] const IPAConfigInfo &configInfo) +{ + /* determined focus value i.e. current focus value */ + context.frameContext.af.focus = 0; + /* maximum variance of the AF statistics */ + context.frameContext.af.maxVariance = 0; + /* the stable AF value flag. if it is true, the AF should be in a stable state. */ + context.frameContext.af.stable = false; + + return 0; +} + +/** + * \brief AF coarse scan + * + * Find a near focused image using a coarse step. The step is determined by coarseSearchStep. + * + * \param[in] context The shared IPA context + * + */ +void Af::afCoarseScan(IPAContext &context) +{ + if (coarseComplete_ == true) + return; + + if (afScan(context, coarseSearchStep)) { + coarseComplete_ = true; + context.frameContext.af.maxVariance = 0; + focus_ = context.frameContext.af.focus - (context.frameContext.af.focus * findRange); + context.frameContext.af.focus = focus_; + previousVariance_ = 0; + maxStep_ = std::clamp(static_cast(focus_ + (focus_ * findRange)), 0U, maxFocusSteps); + } +} + +/** + * \brief AF fine scan + * + * Find an optimum lens position with moving 1 step for each search. + * + * \param[in] context The shared IPA context + * + */ +void Af::afFineScan(IPAContext &context) +{ + if (coarseComplete_ != true) + return; + + if (afScan(context, fineSearchStep)) { + context.frameContext.af.stable = true; + fineComplete_ = true; + } +} + +/** + * \brief AF reset + * + * Reset all the parameter to start over the AF process. + * + * \param[in] context The shared IPA context + * + */ +void Af::afReset(IPAContext &context) +{ + context.frameContext.af.maxVariance = 0; + context.frameContext.af.focus = 0; + focus_ = 0; + context.frameContext.af.stable = false; + ignoreCounter_ = ignoreFrame; + previousVariance_ = 0.0; + coarseComplete_ = false; + fineComplete_ = false; + maxStep_ = maxFocusSteps; +} + +/** + * \brief AF scan + * \param[in] context The shared IPA context + * + * This fuction compares the previous and current variance. It always pick the largest variance to + * replace the previous one. If it finds the decending variance values, it returns immediately. + * + * \return True, if it finds a AF value. + */ +bool Af::afScan(IPAContext &context, int min_step) +{ + /* find the maximum variance during the AF scan through + always picking the maximum variance */ + if (currentVariance_ > context.frameContext.af.maxVariance) { + context.frameContext.af.maxVariance = currentVariance_; + goodFocus_ = focus_; + } + + if (focus_ > maxStep_) { + /* if reach the max step, move lens to the position and set "focus stable". */ + context.frameContext.af.focus = goodFocus_; + return true; + } else { + /* check negative direction of the variance development. */ + if ((currentVariance_ - context.frameContext.af.maxVariance) > -(context.frameContext.af.maxVariance * 0.15)) { + focus_ += min_step; + context.frameContext.af.focus = focus_; + } else { + context.frameContext.af.focus = goodFocus_; + previousVariance_ = currentVariance_; + return true; + } + } + LOG(IPU3Af, Debug) << "Variance previous: " + << previousVariance_ + << " current: " + << currentVariance_ + << " Diff: " + << (currentVariance_ - context.frameContext.af.maxVariance); + previousVariance_ = currentVariance_; + LOG(IPU3Af, Debug) << "Focus searching max variance is: " + << context.frameContext.af.maxVariance + << " Focus step is " + << goodFocus_ + << " Current scan is " + << focus_; + return false; +} + +/** + * \brief Determine the max contrast image and lens position. y_table is the + * statistic data from IPU3 and is composed of low pass and high pass filtered + * value. High pass filtered value also represents the sharpness of the image. + * Based on this, if the image with highest variance of the high pass filtered + * value (contrast) during the AF scan, the position of the lens should be the + * best focus. + * \param[in] context The shared IPA context. + * \param[in] stats The statistic buffer of 3A from the IPU3. + */ +void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats) +{ + uint32_t total = 0; + double mean; + uint64_t var_sum = 0; + y_table_item_t y_item[IPU3_UAPI_AF_Y_TABLE_MAX_SIZE / sizeof(y_table_item_t)]; + uint32_t z = 0; + + memcpy(y_item, stats->af_raw_buffer.y_table, IPU3_UAPI_AF_Y_TABLE_MAX_SIZE); + + /* Evaluate the AF buffer length */ + afRawBufferLen_ = context.configuration.af.afGrid.width * + context.configuration.af.afGrid.height; + + /** + * Calculate the mean and the variance AF statistics, since IPU3 only determine the AF value + * for a given grid. + * For coarse: y1 are used. + * For fine: y2 results are used. + */ + if (coarseComplete_) { + for (z = 0; z < afRawBufferLen_; z++) { + total = total + y_item[z].y2_avg; + } + mean = total / afRawBufferLen_; + + for (z = 0; z < afRawBufferLen_; z++) { + var_sum = var_sum + ((y_item[z].y2_avg - mean) * (y_item[z].y2_avg - mean)); + } + } else { + for (z = 0; z < afRawBufferLen_; z++) { + total = total + y_item[z].y1_avg; + } + mean = total / afRawBufferLen_; + + for (z = 0; z < afRawBufferLen_; z++) { + var_sum = var_sum + ((y_item[z].y1_avg - mean) * (y_item[z].y1_avg - mean)); + } + } + + /* Determine the average variance of the frame. */ + currentVariance_ = static_cast(var_sum) / static_cast(afRawBufferLen_); + LOG(IPU3Af, Debug) << "variance: " << currentVariance_; + + if (context.frameContext.af.stable == true) { + const uint32_t diff_var = std::abs(currentVariance_ - context.frameContext.af.maxVariance); + const double var_ratio = diff_var / context.frameContext.af.maxVariance; + LOG(IPU3Af, Debug) << "Rate of variance change: " + << var_ratio + << " current focus step: " + << context.frameContext.af.focus; + /** + * If the change ratio of contrast is more than maxChange (out of focus), + * trigger AF again. + */ + if (var_ratio > maxChange) { + if (ignoreCounter_ == 0) { + afReset(context); + } else + ignoreCounter_--; + } else + ignoreCounter_ = ignoreFrame; + } else { + if (ignoreCounter_ != 0) + ignoreCounter_--; + else { + afCoarseScan(context); + afFineScan(context); + } + } +} + +} /* namespace ipa::ipu3::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/ipu3/algorithms/af.h b/src/ipa/ipu3/algorithms/af.h new file mode 100644 index 00000000..981bf3a2 --- /dev/null +++ b/src/ipa/ipu3/algorithms/af.h @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Red Hat + * + * af.h - IPU3 Af algorithm + */ +#ifndef __LIBCAMERA_IPU3_ALGORITHMS_AF_H__ +#define __LIBCAMERA_IPU3_ALGORITHMS_AF_H__ + +#include + +#include + +#include + +#include "algorithm.h" + +/* static variables from repo of chromium */ +static constexpr uint8_t AF_MIN_GRID_WIDTH = 16; +static constexpr uint8_t AF_MIN_GRID_HEIGHT = 16; +static constexpr uint8_t AF_MAX_GRID_WIDTH = 32; +static constexpr uint8_t AF_MAX_GRID_HEIGHT = 24; +static constexpr uint16_t AF_MIN_BLOCK_WIDTH = 4; +static constexpr uint16_t AF_MIN_BLOCK_HEIGHT = 3; +static constexpr uint16_t AF_MAX_BLOCK_WIDTH = 6; +static constexpr uint16_t AF_MAX_BLOCK_HEIGHT = 6; +static constexpr uint16_t AF_DEFAULT_HEIGHT_PER_SLICE = 2; + +namespace libcamera { + +namespace ipa::ipu3::algorithms { + +class Af : public Algorithm +{ + /* The format of y_table. From ipu3-ipa repo */ + typedef struct __attribute__((packed)) y_table_item { + uint16_t y1_avg; + uint16_t y2_avg; + } y_table_item_t; +public: + Af(); + ~Af(); + + void prepare(IPAContext &context, ipu3_uapi_params *params) override; + int configure(IPAContext &context, const IPAConfigInfo &configInfo) override; + void process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override; + +private: + void afCoarseScan(IPAContext &context); + void afFineScan(IPAContext &context); + bool afScan(IPAContext &context, int min_step); + void afReset(IPAContext &context); + + /* Used for focus scan. */ + uint32_t focus_; + /* Focus good */ + uint32_t goodFocus_; + /* Recent AF statistic variance. */ + double currentVariance_; + /* The frames to be ignore before starting measuring. */ + uint32_t ignoreCounter_; + /* previous variance. it is used to determine the gradient */ + double previousVariance_; + /* Max scan steps of each pass of AF scaning */ + uint32_t maxStep_; + /* coarse scan stable. Complete low pass search (coarse) scan) */ + bool coarseComplete_; + /* fine scan stable. Complete high pass scan (fine scan) */ + bool fineComplete_; + /* Raw buffer length */ + uint32_t afRawBufferLen_; +}; + +} /* namespace ipa::ipu3::algorithms */ + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_IPU3_ALGORITHMS_AF_H__ */ diff --git a/src/ipa/ipu3/algorithms/meson.build b/src/ipa/ipu3/algorithms/meson.build index 4db6ae1d..e1099169 100644 --- a/src/ipa/ipu3/algorithms/meson.build +++ b/src/ipa/ipu3/algorithms/meson.build @@ -1,8 +1,9 @@ # SPDX-License-Identifier: CC0-1.0 ipu3_ipa_algorithms = files([ + 'af.cpp', 'agc.cpp', 'awb.cpp', 'blc.cpp', - 'tone_mapping.cpp', + 'tone_mapping.cpp' ]) diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp index 86794ac1..ecb2b90a 100644 --- a/src/ipa/ipu3/ipa_context.cpp +++ b/src/ipa/ipu3/ipa_context.cpp @@ -67,6 +67,30 @@ namespace libcamera::ipa::ipu3 { * * \var IPASessionConfiguration::grid.stride * \brief Number of cells on one line including the ImgU padding + * + */ + +/** + * \var IPASessionConfiguration::af + * \brief AF grid configuration of the IPA + * + * \var IPASessionConfiguration::af.afGrid + * + */ + +/** + * \var IPAFrameContext::af + * \brief Context for the Automatic Focus algorithm + * + * \struct IPAFrameContext::af + * \var IPAFrameContext::af.focus + * \brief Current position of the lens + * + * \var IPAFrameContext::af.maxVariance + * \brief The maximum variance of the current image. + * + * \var IPAFrameContext::af.stable + * \brief is the image focused? */ /** diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h index c6dc0814..60ad3194 100644 --- a/src/ipa/ipu3/ipa_context.h +++ b/src/ipa/ipu3/ipa_context.h @@ -25,6 +25,10 @@ struct IPASessionConfiguration { uint32_t stride; } grid; + struct { + ipu3_uapi_grid_config afGrid; + } af; + struct { utils::Duration minShutterSpeed; utils::Duration maxShutterSpeed; @@ -34,6 +38,12 @@ struct IPASessionConfiguration { }; struct IPAFrameContext { + struct { + uint32_t focus; + double maxVariance; + bool stable; + } af; + struct { uint32_t exposure; double gain; diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 3d307708..2d23f8f8 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -30,6 +30,7 @@ #include "libcamera/internal/mapped_framebuffer.h" +#include "algorithms/af.h" #include "algorithms/agc.h" #include "algorithms/algorithm.h" #include "algorithms/awb.h" @@ -157,6 +158,7 @@ private: void setControls(unsigned int frame); void calculateBdsGrid(const Size &bdsOutputSize); + void initAfGrid(const Size &bdsOutputSize); std::map buffers_; @@ -294,6 +296,7 @@ int IPAIPU3::init(const IPASettings &settings, } /* Construct our Algorithms */ + algorithms_.push_back(std::make_unique()); algorithms_.push_back(std::make_unique()); algorithms_.push_back(std::make_unique()); algorithms_.push_back(std::make_unique()); @@ -395,6 +398,37 @@ void IPAIPU3::calculateBdsGrid(const Size &bdsOutputSize) << (int)bdsGrid.height << " << " << (int)bdsGrid.block_height_log2 << ")"; } +/** + * \brief Configure the IPU3 AF grid + * + * This function gives the default values for the AF grid configuration. + * All the parameters are set to the minimum acceptable values. + * + * \param bdsOutputSize The BDS output size + */ +void IPAIPU3::initAfGrid(const Size &bdsOutputSize) +{ + struct ipu3_uapi_grid_config &grid = context_.configuration.af.afGrid; + grid.width = AF_MIN_GRID_WIDTH; + grid.height = AF_MIN_GRID_HEIGHT; + grid.block_width_log2 = AF_MIN_BLOCK_WIDTH; + grid.block_height_log2 = AF_MIN_BLOCK_HEIGHT; + grid.height_per_slice = AF_DEFAULT_HEIGHT_PER_SLICE; + grid.block_width_log2 = AF_MIN_BLOCK_WIDTH; + grid.block_height_log2 = AF_MIN_BLOCK_HEIGHT; + + /* x_start and y start are default to BDS center */ + grid.x_start = (bdsOutputSize.width / 2) - + (((grid.width << grid.block_width_log2) / 2)); + grid.y_start = (bdsOutputSize.height / 2) - + (((grid.height << grid.block_height_log2) / 2)); + + /* 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; +} + /** * \brief Configure the IPU3 IPA * \param[in] configInfo The IPA configuration data, received from the pipeline @@ -461,6 +495,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, lineDuration_ = sensorInfo_.lineLength * 1.0s / sensorInfo_.pixelRate; + initAfGrid(configInfo.bdsOutputSize); + /* Update the camera controls using the new sensor settings. */ updateControls(sensorInfo_, ctrls_, ipaControls);