mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 23:39:44 +03:00
ipa: rkisp1: Store hardware parameters in IPA context
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
This commit is contained in:
parent
971c4904ff
commit
528dc21b09
5 changed files with 57 additions and 51 deletions
|
@ -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<uint8_t> weights{ params->meas.hst_config.hist_weight, numHistBins_ };
|
||||
Span<uint8_t> 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<const uint8_t> ae{ params->ae.exp_mean, numCells_ };
|
||||
Span<const uint32_t> hist{ params->hist.hist_bins, numHistBins_ };
|
||||
Span<const uint8_t> ae{ params->ae.exp_mean, context.hw->numAeCells };
|
||||
Span<const uint32_t> hist{
|
||||
params->hist.hist_bins,
|
||||
context.hw->numHistogramBins
|
||||
};
|
||||
|
||||
double iqMean = measureBrightness(hist);
|
||||
double iqMeanGain = kEvGainTarget * hist.size() / iqMean;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue