diff options
author | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2024-05-31 12:20:34 +0200 |
---|---|---|
committer | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2024-06-20 18:22:17 +0200 |
commit | 4acc8e35cff7548eba9fb1e4be4052d5340a9254 (patch) | |
tree | 91a9ca3ee7c882b710c4bbc2bbb0d1db22709ddb /src/ipa/rkisp1/algorithms/agc.cpp | |
parent | e689b2f0c9fef525364ba518054297558086a051 (diff) |
ipa: rkisp1: Use the extensible parameters formatimx8mp/extensible-format
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Diffstat (limited to 'src/ipa/rkisp1/algorithms/agc.cpp')
-rw-r--r-- | src/ipa/rkisp1/algorithms/agc.cpp | 73 |
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, |