From patchwork Sun Feb 18 16:49:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19506 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 B13D5C3261 for ; Sun, 18 Feb 2024 16:49:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4BD8C6280B; Sun, 18 Feb 2024 17:49:08 +0100 (CET) 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="CgvWHKxa"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6CDF162805 for ; Sun, 18 Feb 2024 17:49:06 +0100 (CET) Received: from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi [89.27.53.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 755D3975; Sun, 18 Feb 2024 17:49:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1708274940; bh=ekL3UFx/W8KHH4sICYYS0S9s/wuLgXxMVSzzEZkPxAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CgvWHKxaJjbwICQESEV8PJVzD63AYIIGZtojiMuJ0QqmPUXo+msDo3Q9UPUDHaYLQ lhixDtoPHF/vH/oPQoPF+DFBz4Swpo6t8jDr1dUlsXr8pruxEmwp+AaaSYnK7cO745 CZO7CyJLfshzZbE+Bp/lyBlWDc2sPIClwfLt6MRI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v3 1/5] ipa: rkisp1: agc: Wrap variable length C arrays in spans Date: Sun, 18 Feb 2024 18:49:04 +0200 Message-ID: <20240218164908.15921-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240218164908.15921-1-laurent.pinchart@ideasonboard.com> References: <20240218164908.15921-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The RkISP1 statistics structure contains multiple arrays whose length varies depending on the hardware revision. Accessing those arrays is error-prone, wrap them in spans at the top level to reduce risks of out-of-bound accesses. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Stefan Klug --- src/ipa/rkisp1/algorithms/agc.cpp | 27 +++++++++++++-------------- src/ipa/rkisp1/algorithms/agc.h | 5 +++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index e5aeb3426eff..f83a9ba1686a 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -186,8 +186,8 @@ void Agc::prepare(IPAContext &context, const uint32_t frame, /* Produce the luminance histogram. */ params->meas.hst_config.mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM; /* Set an average weighted histogram. */ - for (unsigned int histBin = 0; histBin < numHistBins_; histBin++) - params->meas.hst_config.hist_weight[histBin] = 1; + Span weights{ params->meas.hst_config.hist_weight, numHistBins_ }; + std::fill(weights.begin(), weights.end(), 1); /* Step size can't be less than 3. */ params->meas.hst_config.histogram_predivider = 4; @@ -318,7 +318,7 @@ void Agc::computeExposure(IPAContext &context, IPAFrameContext &frameContext, /** * \brief Estimate the relative luminance of the frame with a given gain - * \param[in] ae The RkISP1 statistics and ISP results + * \param[in] expMeans The mean luminance values, from the RkISP1 statistics * \param[in] gain The gain to apply to the frame * * This function estimates the average relative luminance of the frame that @@ -342,28 +342,27 @@ void Agc::computeExposure(IPAContext &context, IPAFrameContext &frameContext, * * \return The relative luminance */ -double Agc::estimateLuminance(const rkisp1_cif_isp_ae_stat *ae, - double gain) +double Agc::estimateLuminance(Span expMeans, double gain) { double ySum = 0.0; /* Sum the averages, saturated to 255. */ - for (unsigned int aeCell = 0; aeCell < numCells_; aeCell++) - ySum += std::min(ae->exp_mean[aeCell] * gain, 255.0); + for (uint8_t expMean : expMeans) + ySum += std::min(expMean * gain, 255.0); /* \todo Weight with the AWB gains */ - return ySum / numCells_ / 255; + return ySum / expMeans.size() / 255; } /** * \brief Estimate the mean value of the top 2% of the histogram - * \param[in] hist The histogram statistics computed by the ImgU + * \param[in] hist The histogram statistics computed by the RkISP1 * \return The mean value of the top 2% of the histogram */ -double Agc::measureBrightness(const rkisp1_cif_isp_hist_stat *hist) const +double Agc::measureBrightness(Span hist) const { - Histogram histogram{ Span(hist->hist_bins, numHistBins_) }; + Histogram histogram{ hist }; /* Estimate the quantile mean of the top 2% of the histogram. */ return histogram.interQuantileMean(0.98, 1.0); } @@ -415,11 +414,11 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, const rkisp1_cif_isp_stat *params = &stats->params; ASSERT(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP); - const rkisp1_cif_isp_ae_stat *ae = ¶ms->ae; - const rkisp1_cif_isp_hist_stat *hist = ¶ms->hist; + Span ae{ params->ae.exp_mean, numCells_ }; + Span hist{ params->hist.hist_bins, numHistBins_ }; double iqMean = measureBrightness(hist); - double iqMeanGain = kEvGainTarget * numHistBins_ / iqMean; + double iqMeanGain = kEvGainTarget * hist.size() / iqMean; /* * Estimate the gain needed to achieve a relative luminance target. To diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h index 8a22263741b6..ce8594f393ab 100644 --- a/src/ipa/rkisp1/algorithms/agc.h +++ b/src/ipa/rkisp1/algorithms/agc.h @@ -9,6 +9,7 @@ #include +#include #include #include @@ -42,8 +43,8 @@ private: void computeExposure(IPAContext &Context, IPAFrameContext &frameContext, double yGain, double iqMeanGain); utils::Duration filterExposure(utils::Duration exposureValue); - double estimateLuminance(const rkisp1_cif_isp_ae_stat *ae, double gain); - double measureBrightness(const rkisp1_cif_isp_hist_stat *hist) const; + double estimateLuminance(Span expMeans, double gain); + double measureBrightness(Span hist) const; void fillMetadata(IPAContext &context, IPAFrameContext &frameContext, ControlList &metadata); From patchwork Sun Feb 18 16:49:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19507 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 329F7BF415 for ; Sun, 18 Feb 2024 16:49:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E7F7862811; Sun, 18 Feb 2024 17:49:10 +0100 (CET) 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="mEiEle7+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 31ABD62806 for ; Sun, 18 Feb 2024 17:49:09 +0100 (CET) Received: from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi [89.27.53.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CD28D18A2; Sun, 18 Feb 2024 17:49:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1708274942; bh=8GD33Hd/J+ExySh7bmlvv+a70wTUsR/zgvb6BPVhBQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mEiEle7+XxsbJz93Aqjf5xtQ+ogQS5i8xpT5Dkvbt2ZY19mgeuOytkz0SSDxG/Brx iwNhMkjvs7uZwKL7aH1vTAqRdJBtQa5F9aNNU/ZkNy0dKynn2xBc3Um9Kno/Rnjr1q r30c86SmcGW93CJmYtqqG3+CxSuuqej2m4XIQmiI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v3 2/5] ipa: rkisp1: Store hardware parameters in IPA context Date: Sun, 18 Feb 2024 18:49:05 +0200 Message-ID: <20240218164908.15921-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240218164908.15921-1-laurent.pinchart@ideasonboard.com> References: <20240218164908.15921-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" Versions of the ISP differ in the processing blocks they include, as well as in the implementation of some of those blocks. In particular, they have different numbers of histogram bins oe AE statistics cells. The algorithms take these differences into account by checking the ISP version reported by the driver. These checks are currently scattered in multiple places. Centralize them in the IPARkISP1::init() function, and store the version-dependent hardware parameters in the IPA context, accessible by all algorithms. While at it, drop the IPASessionConfiguration::hw member that stores the revision number, unused by the algorithms. It can be added back laer to the IPAHwSettings structure if needed. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Stefan Klug --- src/ipa/rkisp1/algorithms/agc.cpp | 27 +++++++++-------------- src/ipa/rkisp1/algorithms/agc.h | 3 --- src/ipa/rkisp1/ipa_context.cpp | 30 +++++++++++++++++++------- src/ipa/rkisp1/ipa_context.h | 12 +++++++---- src/ipa/rkisp1/rkisp1.cpp | 36 +++++++++++++++---------------- 5 files changed, 57 insertions(+), 51 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index f83a9ba1686a..da705b14754c 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -59,7 +59,7 @@ static constexpr double kEvGainTarget = 0.5; static constexpr double kRelativeLuminanceTarget = 0.4; Agc::Agc() - : frameCount_(0), numCells_(0), numHistBins_(0), filteredExposure_(0s) + : frameCount_(0), filteredExposure_(0s) { supportsRaw_ = true; } @@ -81,19 +81,6 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) context.activeState.agc.manual.exposure = context.activeState.agc.automatic.exposure; context.activeState.agc.autoEnabled = !context.configuration.raw; - /* - * According to the RkISP1 documentation: - * - versions < V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, - * - versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. - */ - if (context.configuration.hw.revision < RKISP1_V12) { - numCells_ = RKISP1_CIF_ISP_AE_MEAN_MAX_V10; - numHistBins_ = RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10; - } else { - numCells_ = RKISP1_CIF_ISP_AE_MEAN_MAX_V12; - numHistBins_ = RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12; - } - /* * Define the measurement window for AGC as a centered rectangle * covering 3/4 of the image width and height. @@ -186,7 +173,10 @@ void Agc::prepare(IPAContext &context, const uint32_t frame, /* Produce the luminance histogram. */ params->meas.hst_config.mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM; /* Set an average weighted histogram. */ - Span weights{ params->meas.hst_config.hist_weight, numHistBins_ }; + Span weights{ + params->meas.hst_config.hist_weight, + context.hw->numHistogramBins + }; std::fill(weights.begin(), weights.end(), 1); /* Step size can't be less than 3. */ params->meas.hst_config.histogram_predivider = 4; @@ -414,8 +404,11 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, const rkisp1_cif_isp_stat *params = &stats->params; ASSERT(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP); - Span ae{ params->ae.exp_mean, numCells_ }; - Span hist{ params->hist.hist_bins, numHistBins_ }; + Span ae{ params->ae.exp_mean, context.hw->numAeCells }; + Span hist{ + params->hist.hist_bins, + context.hw->numHistogramBins + }; double iqMean = measureBrightness(hist); double iqMeanGain = kEvGainTarget * hist.size() / iqMean; diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h index ce8594f393ab..fb82a33fc1bf 100644 --- a/src/ipa/rkisp1/algorithms/agc.h +++ b/src/ipa/rkisp1/algorithms/agc.h @@ -50,9 +50,6 @@ private: uint64_t frameCount_; - uint32_t numCells_; - uint32_t numHistBins_; - utils::Duration filteredExposure_; }; diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 9bbf368432fa..070834fa682d 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -14,6 +14,25 @@ namespace libcamera::ipa::rkisp1 { +/** + * \struct IPAHwSettings + * \brief RkISP1 version-specific hardware parameters + */ + +/** + * \var IPAHwSettings::numAeCells + * \brief Number of cells in the AE exposure means grid + * + * \var IPAHwSettings::numHistogramBins + * \brief Number of bins in the histogram + * + * \var IPAHwSettings::numHistogramWeights + * \brief Number of weights in the histogram grid + * + * \var IPAHwSettings::numGammaOutSamples + * \brief Number of samples in the gamma out table + */ + /** * \struct IPASessionConfiguration * \brief Session configuration for the IPA module @@ -32,14 +51,6 @@ namespace libcamera::ipa::rkisp1 { * \brief AGC measure window */ -/** - * \var IPASessionConfiguration::hw - * \brief RkISP1-specific hardware information - * - * \var IPASessionConfiguration::hw.revision - * \brief Hardware revision of the ISP - */ - /** * \var IPASessionConfiguration::awb * \brief AWB parameters configuration of the IPA @@ -337,6 +348,9 @@ namespace libcamera::ipa::rkisp1 { * \struct IPAContext * \brief Global IPA context data shared between all algorithms * + * \var IPAContext::hw + * \brief RkISP1 version-specific hardware parameters + * * \var IPAContext::configuration * \brief The IPA session configuration, immutable during the session * diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index b9b2065328d6..10d8f38cad5d 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -20,6 +20,13 @@ namespace libcamera { namespace ipa::rkisp1 { +struct IPAHwSettings { + unsigned int numAeCells; + unsigned int numHistogramBins; + unsigned int numHistogramWeights; + unsigned int numGammaOutSamples; +}; + struct IPASessionConfiguration { struct { struct rkisp1_cif_isp_window measureWindow; @@ -45,10 +52,6 @@ struct IPASessionConfiguration { Size size; } sensor; - struct { - rkisp1_cif_isp_version revision; - } hw; - bool raw; }; @@ -143,6 +146,7 @@ struct IPAFrameContext : public FrameContext { }; struct IPAContext { + const IPAHwSettings *hw; IPASessionConfiguration configuration; IPAActiveState activeState; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 6544c925ba25..44401af8910d 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -81,12 +81,6 @@ private: ControlInfoMap sensorControls_; - /* revision-specific data */ - rkisp1_cif_isp_version hwRevision_; - unsigned int hwHistBinNMax_; - unsigned int hwGammaOutMaxSamples_; - unsigned int hwHistogramWeightGridsSize_; - /* Interface to the Camera Helper */ std::unique_ptr camHelper_; @@ -96,6 +90,20 @@ private: namespace { +const IPAHwSettings ipaHwSettingsV10{ + RKISP1_CIF_ISP_AE_MEAN_MAX_V10, + RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10, + RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10, + RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10, +}; + +const IPAHwSettings ipaHwSettingsV12{ + RKISP1_CIF_ISP_AE_MEAN_MAX_V12, + RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12, + RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12, + RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12, +}; + /* List of controls handled by the RkISP1 IPA */ const ControlInfoMap::Map rkisp1Controls{ { &controls::AeEnable, ControlInfo(false, true) }, @@ -111,7 +119,7 @@ const ControlInfoMap::Map rkisp1Controls{ } /* namespace */ IPARkISP1::IPARkISP1() - : context_({ {}, {}, { kMaxFrameContexts } }) + : context_({ {}, {}, {}, { kMaxFrameContexts } }) { } @@ -128,14 +136,10 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, /* \todo Add support for other revisions */ switch (hwRevision) { case RKISP1_V10: - hwHistBinNMax_ = RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10; - hwGammaOutMaxSamples_ = RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10; - hwHistogramWeightGridsSize_ = RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10; + context_.hw = &ipaHwSettingsV10; break; case RKISP1_V12: - hwHistBinNMax_ = RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12; - hwGammaOutMaxSamples_ = RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12; - hwHistogramWeightGridsSize_ = RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12; + context_.hw = &ipaHwSettingsV12; break; default: LOG(IPARkISP1, Error) @@ -146,9 +150,6 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, LOG(IPARkISP1, Debug) << "Hardware revision is " << hwRevision; - /* Cache the value to set it in configure. */ - hwRevision_ = static_cast(hwRevision); - camHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel); if (!camHelper_) { LOG(IPARkISP1, Error) @@ -232,9 +233,6 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, context_.activeState = {}; context_.frameContexts.clear(); - /* Set the hardware revision for the algorithms. */ - context_.configuration.hw.revision = hwRevision_; - const IPACameraSensorInfo &info = ipaConfig.sensorInfo; const ControlInfo vBlank = sensorControls_.find(V4L2_CID_VBLANK)->second; context_.configuration.sensor.defVBlank = vBlank.def().get(); From patchwork Sun Feb 18 16:49:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19508 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 866FCC3261 for ; Sun, 18 Feb 2024 16:49:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 522F562802; Sun, 18 Feb 2024 17:49:12 +0100 (CET) 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="P5LCI3GM"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 96D9A62806 for ; Sun, 18 Feb 2024 17:49:10 +0100 (CET) Received: from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi [89.27.53.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9D0312298; Sun, 18 Feb 2024 17:49:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1708274944; bh=l5G8RaEuhsqyRYO0i7tXbSaP9wpcsJG9l9IPc0lQSPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P5LCI3GM0a/h6B1ofbg1pzy8wxaamYGqhIYY+RqXr5mf2NgSeGrq/RoeOew+M4Q2E GU3bpNFiej+87Mb/f8+t81K2uYaxlHVI265glPyO6gXEhbaaHPu9GUDZWpjFH+d4iA L8Q9hxdTx54SjDj7P0KPrSb27tvR4WFm87NnhoDM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v3 3/5] ipa: rkisp1: Fix histogram weights configuration Date: Sun, 18 Feb 2024 18:49:06 +0200 Message-ID: <20240218164908.15921-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240218164908.15921-1-laurent.pinchart@ideasonboard.com> References: <20240218164908.15921-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The histogram weights are initialized to hardcoded 1's for each histogram grid cell. The code uses the wrong variable for the grid size, resulting in some weights having a 0 value. Fix it. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Stefan Klug --- src/ipa/rkisp1/algorithms/agc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index da705b14754c..47a6f7b26744 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -175,7 +175,7 @@ void Agc::prepare(IPAContext &context, const uint32_t frame, /* Set an average weighted histogram. */ Span weights{ params->meas.hst_config.hist_weight, - context.hw->numHistogramBins + context.hw->numHistogramWeights }; std::fill(weights.begin(), weights.end(), 1); /* Step size can't be less than 3. */ From patchwork Sun Feb 18 16:49:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19509 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 0E67EBF415 for ; Sun, 18 Feb 2024 16:49:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C77CE62816; Sun, 18 Feb 2024 17:49:13 +0100 (CET) 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="T5R4Qyd7"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ECB0F62802 for ; Sun, 18 Feb 2024 17:49:11 +0100 (CET) Received: from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi [89.27.53.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 042651ABC; Sun, 18 Feb 2024 17:49:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1708274946; bh=KiC9bqjOF4oj0Zh0z+6IYqSgvOBbpakbALtWIQmbxFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T5R4Qyd7gHzshVeaM5HDJJhlQcHrX9Oh+Okg/gytHv8ncg9y3sEC9cua6JIDgwDuv 6wuJLu98kMsSPBTFhTSMkQfeoEKHA9oXBO1aAEZEVdnQ7uVTZgmfQ1TSj75KOrQeT3 iuFIxYcScCtqPIBhm+/eHL4LNOtc4PzgvYRuugMo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v3 4/5] include: linux: Add RKISP1_V_IMX8MP version Date: Sun, 18 Feb 2024 18:49:07 +0200 Message-ID: <20240218164908.15921-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240218164908.15921-1-laurent.pinchart@ideasonboard.com> References: <20240218164908.15921-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" From: Paul Elder Patches have been posted to the linux-media@vger.kernel.org mailing list to add i.MX8MP support to the rkisp1 driver ([1]). As no changes are expected to the userspace API in future versions of the series, add the RKISP1_V_IMX8MP version manually to the rkisp1-config.h header already. Once the patches get merged in the kernel, the changes will trickle down to libcamera with the next kernel headers update. [1] https://lore.kernel.org/linux-media/20240216095458.2919694-1-paul.elder@ideasonboard.com/ Signed-off-by: Paul Elder Signed-off-by: Laurent Pinchart Reviewed-by: Stefan Klug --- include/linux/rkisp1-config.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/rkisp1-config.h b/include/linux/rkisp1-config.h index ec7cde8cd2e3..2d1c448a6ab8 100644 --- a/include/linux/rkisp1-config.h +++ b/include/linux/rkisp1-config.h @@ -4,8 +4,8 @@ * Copyright (C) 2017 Rockchip Electronics Co., Ltd. */ -#ifndef _RKISP1_CONFIG_H -#define _RKISP1_CONFIG_H +#ifndef _UAPI_RKISP1_CONFIG_H +#define _UAPI_RKISP1_CONFIG_H #include @@ -179,12 +179,14 @@ * @RKISP1_V11: declared in the original vendor code, but not used * @RKISP1_V12: used at least in rk3326 and px30 * @RKISP1_V13: used at least in rk1808 + * @RKISP1_V_IMX8MP: used in at least imx8mp */ enum rkisp1_cif_isp_version { RKISP1_V10 = 10, RKISP1_V11, RKISP1_V12, RKISP1_V13, + RKISP1_V_IMX8MP, }; enum rkisp1_cif_isp_histogram_mode { @@ -992,4 +994,4 @@ struct rkisp1_stat_buffer { struct rkisp1_cif_isp_stat params; }; -#endif /* _RKISP1_CONFIG_H */ +#endif /* _UAPI_RKISP1_CONFIG_H */ From patchwork Sun Feb 18 16:49:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19510 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 E561FBF415 for ; Sun, 18 Feb 2024 16:49:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AB5846280A; Sun, 18 Feb 2024 17:49:16 +0100 (CET) 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="UNVcjVhy"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B25262810 for ; Sun, 18 Feb 2024 17:49:13 +0100 (CET) Received: from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi [89.27.53.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 679191BA7; Sun, 18 Feb 2024 17:49:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1708274947; bh=+yIY1P1W0yakAIboYibuia3Ld7k+3jLg5vRVF8xpDaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UNVcjVhyQgblu/UXJPJY0d/rmhhYYomialTQN6nokU4p3goD/GKocgqWCbcUg75rD FzKrvd2ggTDtUFFmZB5ABZwIbL76BZVSXcwZ6bjxANcMIEsSXT0n081IMSDwg3xwv0 OWUJZ+sFX27zxOmzl4p/FbddZ9T3Pm4WwOQXER4s= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v3 5/5] ipa: rkisp1: Support the i.MX8MP ISP version Date: Sun, 18 Feb 2024 18:49:08 +0200 Message-ID: <20240218164908.15921-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240218164908.15921-1-laurent.pinchart@ideasonboard.com> References: <20240218164908.15921-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" From: Paul Elder Handle the RKISP1_V_IMX8MP version in the rkisp1 IPA. This enables basic support of the i.MX8MP, excluding the processing blocks specific to the new ISP version. Those will be supported later. Signed-off-by: Paul Elder Signed-off-by: Laurent Pinchart Reviewed-by: Stefan Klug --- src/ipa/rkisp1/rkisp1.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 44401af8910d..9dc5f53cb091 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -136,6 +136,7 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, /* \todo Add support for other revisions */ switch (hwRevision) { case RKISP1_V10: + case RKISP1_V_IMX8MP: context_.hw = &ipaHwSettingsV10; break; case RKISP1_V12: