summaryrefslogtreecommitdiff
path: root/src/ipa/rkisp1/algorithms/agc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipa/rkisp1/algorithms/agc.cpp')
-rw-r--r--src/ipa/rkisp1/algorithms/agc.cpp73
1 files changed, 47 insertions, 26 deletions
diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
index 50e0690f..e2e47453 100644
--- a/src/ipa/rkisp1/algorithms/agc.cpp
+++ b/src/ipa/rkisp1/algorithms/agc.cpp
@@ -149,11 +149,49 @@ void Agc::queueRequest(IPAContext &context,
}
}
+void Agc::prepareAecMeas(IPAContext &context,
+ rkisp1_ext_params_aec_config *aec)
+{
+ aec->header.type = RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS;
+ aec->header.enable = RKISP1_EXT_PARAMS_BLOCK_ENABLE;
+ aec->header.size = sizeof(rkisp1_ext_params_aec_config);
+
+ /* Configure the measurement window. */
+ aec->aec_config.meas_window = context.configuration.agc.measureWindow;
+ /* Use a continuous method for measure. */
+ aec->aec_config.autostop = RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0;
+ /* Estimate Y as (R + G + B) x (85/256). */
+ aec->aec_config.mode = RKISP1_CIF_ISP_EXP_MEASURING_MODE_1;
+}
+
+void Agc::prepareHistMeas(IPAContext &context,
+ rkisp1_ext_params_hst_config *hst)
+{
+ hst->header.type = RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS;
+ hst->header.enable = RKISP1_EXT_PARAMS_BLOCK_ENABLE;
+ hst->header.size = sizeof(rkisp1_ext_params_hst_config);
+
+ hst->hst_config.meas_window = context.configuration.agc.measureWindow;
+
+ /* Produce the luminance histogram. */
+ hst->hst_config.mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM;
+
+ /* Set an average weighted histogram. */
+ Span<uint8_t> weights{
+ hst->hst_config.hist_weight,
+ context.hw->numHistogramWeights
+ };
+ std::fill(weights.begin(), weights.end(), 1);
+
+ /* Step size can't be less than 3. */
+ hst->hst_config.histogram_predivider = 4;
+}
+
/**
* \copydoc libcamera::ipa::Algorithm::prepare
*/
void Agc::prepare(IPAContext &context, const uint32_t frame,
- IPAFrameContext &frameContext, rkisp1_params_cfg *params)
+ IPAFrameContext &frameContext, rkisp1_ext_params_block_header *hdr)
{
if (frameContext.agc.autoEnabled) {
frameContext.agc.exposure = context.activeState.agc.automatic.exposure;
@@ -163,35 +201,18 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,
if (frame > 0)
return;
- /* Configure the measurement window. */
- params->meas.aec_config.meas_window = context.configuration.agc.measureWindow;
- /* Use a continuous method for measure. */
- params->meas.aec_config.autostop = RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0;
- /* Estimate Y as (R + G + B) x (85/256). */
- params->meas.aec_config.mode = RKISP1_CIF_ISP_EXP_MEASURING_MODE_1;
+ struct rkisp1_ext_params_aec_config *aec =
+ reinterpret_cast<rkisp1_ext_params_aec_config *>(hdr);
- params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AEC;
- params->module_ens |= RKISP1_CIF_ISP_MODULE_AEC;
- params->module_en_update |= RKISP1_CIF_ISP_MODULE_AEC;
+ prepareAecMeas(context, aec);
/* Configure histogram. */
- params->meas.hst_config.meas_window = context.configuration.agc.measureWindow;
- /* 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,
- context.hw->numHistogramWeights
- };
- std::fill(weights.begin(), weights.end(), 1);
- /* Step size can't be less than 3. */
- params->meas.hst_config.histogram_predivider = 4;
+ char *hst_hdr = reinterpret_cast<char *>(hdr);
+ struct rkisp1_ext_params_hst_config *hst =
+ reinterpret_cast<rkisp1_ext_params_hst_config *>
+ (hst_hdr + sizeof(rkisp1_ext_params_aec_config));
- /* Update the configuration for histogram. */
- params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_HST;
- /* Enable the histogram measure unit. */
- params->module_ens |= RKISP1_CIF_ISP_MODULE_HST;
- params->module_en_update |= RKISP1_CIF_ISP_MODULE_HST;
+ prepareHistMeas(context, hst);
}
void Agc::fillMetadata(IPAContext &context, IPAFrameContext &frameContext,