mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-19 18:35:07 +03:00
ipa: rkisp1: Use the new ISP parameters abstraction
Use the new ISP parameters abstraction class RkISP1Params to access the ISP parameters in the IPA algorithms. The class replaces the pointer to the rkisp1_params_cfg structure passed to the algorithms' prepare() function, and is used to access individual parameters blocks. 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
9cacf4e420
commit
9861678f23
24 changed files with 163 additions and 193 deletions
|
@ -281,7 +281,7 @@ void Agc::queueRequest(IPAContext &context,
|
||||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||||
*/
|
*/
|
||||||
void Agc::prepare(IPAContext &context, const uint32_t frame,
|
void Agc::prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext, rkisp1_params_cfg *params)
|
IPAFrameContext &frameContext, RkISP1Params *params)
|
||||||
{
|
{
|
||||||
if (frameContext.agc.autoEnabled) {
|
if (frameContext.agc.autoEnabled) {
|
||||||
frameContext.agc.exposure = context.activeState.agc.automatic.exposure;
|
frameContext.agc.exposure = context.activeState.agc.automatic.exposure;
|
||||||
|
@ -291,41 +291,39 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,
|
||||||
if (frame > 0 && !frameContext.agc.updateMetering)
|
if (frame > 0 && !frameContext.agc.updateMetering)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Configure the measurement window. */
|
/*
|
||||||
params->meas.aec_config.meas_window = context.configuration.agc.measureWindow;
|
* Configure the AEC measurements. Set the window, measure
|
||||||
/* Use a continuous method for measure. */
|
* continuously, and estimate Y as (R + G + B) x (85/256).
|
||||||
params->meas.aec_config.autostop = RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0;
|
*/
|
||||||
/* Estimate Y as (R + G + B) x (85/256). */
|
auto aecConfig = params->block<BlockType::Aec>();
|
||||||
params->meas.aec_config.mode = RKISP1_CIF_ISP_EXP_MEASURING_MODE_1;
|
aecConfig.setEnabled(true);
|
||||||
|
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AEC;
|
aecConfig->meas_window = context.configuration.agc.measureWindow;
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_AEC;
|
aecConfig->autostop = RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0;
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_AEC;
|
aecConfig->mode = RKISP1_CIF_ISP_EXP_MEASURING_MODE_1;
|
||||||
|
|
||||||
/* Configure histogram. */
|
/*
|
||||||
params->meas.hst_config.meas_window = context.configuration.agc.measureWindow;
|
* Configure the histogram measurement. Set the window, produce a
|
||||||
/* Produce the luminance histogram. */
|
* luminance histogram, and set the weights and predivider.
|
||||||
params->meas.hst_config.mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM;
|
*/
|
||||||
|
auto hstConfig = params->block<BlockType::Hst>();
|
||||||
|
hstConfig.setEnabled(true);
|
||||||
|
|
||||||
|
hstConfig->meas_window = context.configuration.agc.measureWindow;
|
||||||
|
hstConfig->mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM;
|
||||||
|
|
||||||
/* Set an average weighted histogram. */
|
|
||||||
Span<uint8_t> weights{
|
Span<uint8_t> weights{
|
||||||
params->meas.hst_config.hist_weight,
|
hstConfig->hist_weight,
|
||||||
context.hw->numHistogramWeights
|
context.hw->numHistogramWeights
|
||||||
};
|
};
|
||||||
std::vector<uint8_t> &modeWeights = meteringModes_.at(frameContext.agc.meteringMode);
|
std::vector<uint8_t> &modeWeights = meteringModes_.at(frameContext.agc.meteringMode);
|
||||||
std::copy(modeWeights.begin(), modeWeights.end(), weights.begin());
|
std::copy(modeWeights.begin(), modeWeights.end(), weights.begin());
|
||||||
|
|
||||||
struct rkisp1_cif_isp_window window = params->meas.hst_config.meas_window;
|
struct rkisp1_cif_isp_window window = hstConfig->meas_window;
|
||||||
Size windowSize = { window.h_size, window.v_size };
|
Size windowSize = { window.h_size, window.v_size };
|
||||||
params->meas.hst_config.histogram_predivider =
|
hstConfig->histogram_predivider =
|
||||||
computeHistogramPredivider(windowSize,
|
computeHistogramPredivider(windowSize,
|
||||||
static_cast<rkisp1_cif_isp_histogram_mode>(params->meas.hst_config.mode));
|
static_cast<rkisp1_cif_isp_histogram_mode>(hstConfig->mode));
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Agc::fillMetadata(IPAContext &context, IPAFrameContext &frameContext,
|
void Agc::fillMetadata(IPAContext &context, IPAFrameContext &frameContext,
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
const ControlList &controls) override;
|
const ControlList &controls) override;
|
||||||
void prepare(IPAContext &context, const uint32_t frame,
|
void prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params) override;
|
RkISP1Params *params) override;
|
||||||
void process(IPAContext &context, const uint32_t frame,
|
void process(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
const rkisp1_stat_buffer *stats,
|
const rkisp1_stat_buffer *stats,
|
||||||
|
|
|
@ -108,7 +108,7 @@ void Awb::queueRequest(IPAContext &context,
|
||||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||||
*/
|
*/
|
||||||
void Awb::prepare(IPAContext &context, const uint32_t frame,
|
void Awb::prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext, rkisp1_params_cfg *params)
|
IPAFrameContext &frameContext, RkISP1Params *params)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* This is the latest time we can read the active state. This is the
|
* This is the latest time we can read the active state. This is the
|
||||||
|
@ -120,33 +120,30 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,
|
||||||
frameContext.awb.gains.blue = context.activeState.awb.gains.automatic.blue;
|
frameContext.awb.gains.blue = context.activeState.awb.gains.automatic.blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
params->others.awb_gain_config.gain_green_b =
|
auto gainConfig = params->block<BlockType::AwbGain>();
|
||||||
std::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);
|
gainConfig.setEnabled(true);
|
||||||
params->others.awb_gain_config.gain_blue =
|
|
||||||
std::clamp<int>(256 * frameContext.awb.gains.blue, 0, 0x3ff);
|
|
||||||
params->others.awb_gain_config.gain_red =
|
|
||||||
std::clamp<int>(256 * frameContext.awb.gains.red, 0, 0x3ff);
|
|
||||||
params->others.awb_gain_config.gain_green_r =
|
|
||||||
std::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);
|
|
||||||
|
|
||||||
/* Update the gains. */
|
gainConfig->gain_green_b = std::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AWB_GAIN;
|
gainConfig->gain_blue = std::clamp<int>(256 * frameContext.awb.gains.blue, 0, 0x3ff);
|
||||||
|
gainConfig->gain_red = std::clamp<int>(256 * frameContext.awb.gains.red, 0, 0x3ff);
|
||||||
|
gainConfig->gain_green_r = std::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);
|
||||||
|
|
||||||
/* If we have already set the AWB measurement parameters, return. */
|
/* If we have already set the AWB measurement parameters, return. */
|
||||||
if (frame > 0)
|
if (frame > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rkisp1_cif_isp_awb_meas_config &awb_config = params->meas.awb_meas_config;
|
auto awbConfig = params->block<BlockType::Awb>();
|
||||||
|
awbConfig.setEnabled(true);
|
||||||
|
|
||||||
/* Configure the measure window for AWB. */
|
/* Configure the measure window for AWB. */
|
||||||
awb_config.awb_wnd = context.configuration.awb.measureWindow;
|
awbConfig->awb_wnd = context.configuration.awb.measureWindow;
|
||||||
|
|
||||||
/* Number of frames to use to estimate the means (0 means 1 frame). */
|
/* Number of frames to use to estimate the means (0 means 1 frame). */
|
||||||
awb_config.frames = 0;
|
awbConfig->frames = 0;
|
||||||
|
|
||||||
/* Select RGB or YCbCr means measurement. */
|
/* Select RGB or YCbCr means measurement. */
|
||||||
if (rgbMode_) {
|
if (rgbMode_) {
|
||||||
awb_config.awb_mode = RKISP1_CIF_ISP_AWB_MODE_RGB;
|
awbConfig->awb_mode = RKISP1_CIF_ISP_AWB_MODE_RGB;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For RGB-based measurements, pixels are selected with maximum
|
* For RGB-based measurements, pixels are selected with maximum
|
||||||
|
@ -154,19 +151,19 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,
|
||||||
* awb_ref_cr, awb_min_y and awb_ref_cb respectively. The other
|
* awb_ref_cr, awb_min_y and awb_ref_cb respectively. The other
|
||||||
* values are not used, set them to 0.
|
* values are not used, set them to 0.
|
||||||
*/
|
*/
|
||||||
awb_config.awb_ref_cr = 250;
|
awbConfig->awb_ref_cr = 250;
|
||||||
awb_config.min_y = 250;
|
awbConfig->min_y = 250;
|
||||||
awb_config.awb_ref_cb = 250;
|
awbConfig->awb_ref_cb = 250;
|
||||||
|
|
||||||
awb_config.max_y = 0;
|
awbConfig->max_y = 0;
|
||||||
awb_config.min_c = 0;
|
awbConfig->min_c = 0;
|
||||||
awb_config.max_csum = 0;
|
awbConfig->max_csum = 0;
|
||||||
} else {
|
} else {
|
||||||
awb_config.awb_mode = RKISP1_CIF_ISP_AWB_MODE_YCBCR;
|
awbConfig->awb_mode = RKISP1_CIF_ISP_AWB_MODE_YCBCR;
|
||||||
|
|
||||||
/* Set the reference Cr and Cb (AWB target) to white. */
|
/* Set the reference Cr and Cb (AWB target) to white. */
|
||||||
awb_config.awb_ref_cb = 128;
|
awbConfig->awb_ref_cb = 128;
|
||||||
awb_config.awb_ref_cr = 128;
|
awbConfig->awb_ref_cr = 128;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Filter out pixels based on luminance and chrominance values.
|
* Filter out pixels based on luminance and chrominance values.
|
||||||
|
@ -174,20 +171,11 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,
|
||||||
* range, while the acceptable chroma values are specified with
|
* range, while the acceptable chroma values are specified with
|
||||||
* a minimum of 16 and a maximum Cb+Cr sum of 250.
|
* a minimum of 16 and a maximum Cb+Cr sum of 250.
|
||||||
*/
|
*/
|
||||||
awb_config.min_y = 16;
|
awbConfig->min_y = 16;
|
||||||
awb_config.max_y = 250;
|
awbConfig->max_y = 250;
|
||||||
awb_config.min_c = 16;
|
awbConfig->min_c = 16;
|
||||||
awb_config.max_csum = 250;
|
awbConfig->max_csum = 250;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable the AWB gains. */
|
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_AWB_GAIN;
|
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_AWB_GAIN;
|
|
||||||
|
|
||||||
/* Update the AWB measurement parameters and enable the AWB module. */
|
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AWB;
|
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_AWB;
|
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_AWB;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Awb::estimateCCT(double red, double green, double blue)
|
uint32_t Awb::estimateCCT(double red, double green, double blue)
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
const ControlList &controls) override;
|
const ControlList &controls) override;
|
||||||
void prepare(IPAContext &context, const uint32_t frame,
|
void prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params) override;
|
RkISP1Params *params) override;
|
||||||
void process(IPAContext &context, const uint32_t frame,
|
void process(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
const rkisp1_stat_buffer *stats,
|
const rkisp1_stat_buffer *stats,
|
||||||
|
|
|
@ -113,7 +113,7 @@ int BlackLevelCorrection::init(IPAContext &context, const YamlObject &tuningData
|
||||||
void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
|
void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
|
||||||
const uint32_t frame,
|
const uint32_t frame,
|
||||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params)
|
RkISP1Params *params)
|
||||||
{
|
{
|
||||||
if (context.configuration.raw)
|
if (context.configuration.raw)
|
||||||
return;
|
return;
|
||||||
|
@ -124,16 +124,15 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
|
||||||
if (!tuningParameters_)
|
if (!tuningParameters_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
params->others.bls_config.enable_auto = 0;
|
auto config = params->block<BlockType::Bls>();
|
||||||
/* The rkisp1 uses 12bit based black levels. Scale down accordingly. */
|
config.setEnabled(true);
|
||||||
params->others.bls_config.fixed_val.r = blackLevelRed_ >> 4;
|
|
||||||
params->others.bls_config.fixed_val.gr = blackLevelGreenR_ >> 4;
|
|
||||||
params->others.bls_config.fixed_val.gb = blackLevelGreenB_ >> 4;
|
|
||||||
params->others.bls_config.fixed_val.b = blackLevelBlue_ >> 4;
|
|
||||||
|
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_BLS;
|
config->enable_auto = 0;
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_BLS;
|
/* The rkisp1 uses 12bit based black levels. Scale down accordingly. */
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_BLS;
|
config->fixed_val.r = blackLevelRed_ >> 4;
|
||||||
|
config->fixed_val.gr = blackLevelGreenR_ >> 4;
|
||||||
|
config->fixed_val.gb = blackLevelGreenB_ >> 4;
|
||||||
|
config->fixed_val.b = blackLevelBlue_ >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,11 +22,12 @@ public:
|
||||||
int init(IPAContext &context, const YamlObject &tuningData) override;
|
int init(IPAContext &context, const YamlObject &tuningData) override;
|
||||||
void prepare(IPAContext &context, const uint32_t frame,
|
void prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params) override;
|
RkISP1Params *params) override;
|
||||||
void process(IPAContext &context, const uint32_t frame,
|
void process(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
const rkisp1_stat_buffer *stats,
|
const rkisp1_stat_buffer *stats,
|
||||||
ControlList &metadata) override;
|
ControlList &metadata) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool tuningParameters_;
|
bool tuningParameters_;
|
||||||
int16_t blackLevelRed_;
|
int16_t blackLevelRed_;
|
||||||
|
|
|
@ -71,12 +71,10 @@ int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ccm::setParameters(rkisp1_params_cfg *params,
|
void Ccm::setParameters(struct rkisp1_cif_isp_ctk_config &config,
|
||||||
const Matrix<float, 3, 3> &matrix,
|
const Matrix<float, 3, 3> &matrix,
|
||||||
const Matrix<int16_t, 3, 1> &offsets)
|
const Matrix<int16_t, 3, 1> &offsets)
|
||||||
{
|
{
|
||||||
struct rkisp1_cif_isp_ctk_config &config = params->others.ctk_config;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 4 bit integer and 7 bit fractional, ranging from -8 (0x400) to
|
* 4 bit integer and 7 bit fractional, ranging from -8 (0x400) to
|
||||||
* +7.992 (0x3ff)
|
* +7.992 (0x3ff)
|
||||||
|
@ -92,18 +90,13 @@ void Ccm::setParameters(rkisp1_params_cfg *params,
|
||||||
|
|
||||||
LOG(RkISP1Ccm, Debug) << "Setting matrix " << matrix;
|
LOG(RkISP1Ccm, Debug) << "Setting matrix " << matrix;
|
||||||
LOG(RkISP1Ccm, Debug) << "Setting offsets " << offsets;
|
LOG(RkISP1Ccm, Debug) << "Setting offsets " << offsets;
|
||||||
|
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_CTK;
|
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_CTK;
|
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_CTK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||||
*/
|
*/
|
||||||
void Ccm::prepare(IPAContext &context, const uint32_t frame,
|
void Ccm::prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext, RkISP1Params *params)
|
||||||
rkisp1_params_cfg *params)
|
|
||||||
{
|
{
|
||||||
uint32_t ct = context.activeState.awb.temperatureK;
|
uint32_t ct = context.activeState.awb.temperatureK;
|
||||||
|
|
||||||
|
@ -123,7 +116,9 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame,
|
||||||
context.activeState.ccm.ccm = ccm;
|
context.activeState.ccm.ccm = ccm;
|
||||||
frameContext.ccm.ccm = ccm;
|
frameContext.ccm.ccm = ccm;
|
||||||
|
|
||||||
setParameters(params, ccm, offsets);
|
auto config = params->block<BlockType::Ctk>();
|
||||||
|
config.setEnabled(true);
|
||||||
|
setParameters(*config, ccm, offsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
int init(IPAContext &context, const YamlObject &tuningData) override;
|
int init(IPAContext &context, const YamlObject &tuningData) override;
|
||||||
void prepare(IPAContext &context, const uint32_t frame,
|
void prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params) override;
|
RkISP1Params *params) override;
|
||||||
void process(IPAContext &context, const uint32_t frame,
|
void process(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
const rkisp1_stat_buffer *stats,
|
const rkisp1_stat_buffer *stats,
|
||||||
|
@ -35,7 +35,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void parseYaml(const YamlObject &tuningData);
|
void parseYaml(const YamlObject &tuningData);
|
||||||
void setParameters(rkisp1_params_cfg *params,
|
void setParameters(struct rkisp1_cif_isp_ctk_config &config,
|
||||||
const Matrix<float, 3, 3> &matrix,
|
const Matrix<float, 3, 3> &matrix,
|
||||||
const Matrix<int16_t, 3, 1> &offsets);
|
const Matrix<int16_t, 3, 1> &offsets);
|
||||||
|
|
||||||
|
|
|
@ -140,19 +140,17 @@ void ColorProcessing::queueRequest(IPAContext &context,
|
||||||
void ColorProcessing::prepare([[maybe_unused]] IPAContext &context,
|
void ColorProcessing::prepare([[maybe_unused]] IPAContext &context,
|
||||||
[[maybe_unused]] const uint32_t frame,
|
[[maybe_unused]] const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params)
|
RkISP1Params *params)
|
||||||
{
|
{
|
||||||
/* Check if the algorithm configuration has been updated. */
|
/* Check if the algorithm configuration has been updated. */
|
||||||
if (!frameContext.cproc.update)
|
if (!frameContext.cproc.update)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
params->others.cproc_config.brightness = frameContext.cproc.brightness;
|
auto config = params->block<BlockType::Cproc>();
|
||||||
params->others.cproc_config.contrast = frameContext.cproc.contrast;
|
config.setEnabled(true);
|
||||||
params->others.cproc_config.sat = frameContext.cproc.saturation;
|
config->brightness = frameContext.cproc.brightness;
|
||||||
|
config->contrast = frameContext.cproc.contrast;
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_CPROC;
|
config->sat = frameContext.cproc.saturation;
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_CPROC;
|
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_CPROC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_IPA_ALGORITHM(ColorProcessing, "ColorProcessing")
|
REGISTER_IPA_ALGORITHM(ColorProcessing, "ColorProcessing")
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
const ControlList &controls) override;
|
const ControlList &controls) override;
|
||||||
void prepare(IPAContext &context, const uint32_t frame,
|
void prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params) override;
|
RkISP1Params *params) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ipa::rkisp1::algorithms */
|
} /* namespace ipa::rkisp1::algorithms */
|
||||||
|
|
|
@ -232,16 +232,14 @@ int DefectPixelClusterCorrection::init([[maybe_unused]] IPAContext &context,
|
||||||
void DefectPixelClusterCorrection::prepare([[maybe_unused]] IPAContext &context,
|
void DefectPixelClusterCorrection::prepare([[maybe_unused]] IPAContext &context,
|
||||||
const uint32_t frame,
|
const uint32_t frame,
|
||||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params)
|
RkISP1Params *params)
|
||||||
{
|
{
|
||||||
if (frame > 0)
|
if (frame > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
params->others.dpcc_config = config_;
|
auto config = params->block<BlockType::Dpcc>();
|
||||||
|
config.setEnabled(true);
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_DPCC;
|
*config = config_;
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_DPCC;
|
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_DPCC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_IPA_ALGORITHM(DefectPixelClusterCorrection, "DefectPixelClusterCorrection")
|
REGISTER_IPA_ALGORITHM(DefectPixelClusterCorrection, "DefectPixelClusterCorrection")
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
int init(IPAContext &context, const YamlObject &tuningData) override;
|
int init(IPAContext &context, const YamlObject &tuningData) override;
|
||||||
void prepare(IPAContext &context, const uint32_t frame,
|
void prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params) override;
|
RkISP1Params *params) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rkisp1_cif_isp_dpcc_config config_;
|
rkisp1_cif_isp_dpcc_config config_;
|
||||||
|
|
|
@ -215,15 +215,21 @@ void Dpf::queueRequest(IPAContext &context,
|
||||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||||
*/
|
*/
|
||||||
void Dpf::prepare(IPAContext &context, const uint32_t frame,
|
void Dpf::prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext, rkisp1_params_cfg *params)
|
IPAFrameContext &frameContext, RkISP1Params *params)
|
||||||
{
|
{
|
||||||
if (frame == 0) {
|
if (!frameContext.dpf.update && frame > 0)
|
||||||
params->others.dpf_config = config_;
|
return;
|
||||||
params->others.dpf_strength_config = strengthConfig_;
|
|
||||||
|
auto config = params->block<BlockType::Dpf>();
|
||||||
|
config.setEnabled(frameContext.dpf.denoise);
|
||||||
|
|
||||||
|
if (frameContext.dpf.denoise) {
|
||||||
|
*config = config_;
|
||||||
|
|
||||||
const auto &awb = context.configuration.awb;
|
const auto &awb = context.configuration.awb;
|
||||||
const auto &lsc = context.configuration.lsc;
|
const auto &lsc = context.configuration.lsc;
|
||||||
auto &mode = params->others.dpf_config.gain.mode;
|
|
||||||
|
auto &mode = config->gain.mode;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The DPF needs to take into account the total amount of
|
* The DPF needs to take into account the total amount of
|
||||||
|
@ -241,15 +247,12 @@ void Dpf::prepare(IPAContext &context, const uint32_t frame,
|
||||||
mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS;
|
mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS;
|
||||||
else
|
else
|
||||||
mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED;
|
mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED;
|
||||||
|
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_DPF |
|
|
||||||
RKISP1_CIF_ISP_MODULE_DPF_STRENGTH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frameContext.dpf.update) {
|
if (frame == 0) {
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_DPF;
|
auto strengthConfig = params->block<BlockType::DpfStrength>();
|
||||||
if (frameContext.dpf.denoise)
|
strengthConfig.setEnabled(true);
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_DPF;
|
*strengthConfig = strengthConfig_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
const ControlList &controls) override;
|
const ControlList &controls) override;
|
||||||
void prepare(IPAContext &context, const uint32_t frame,
|
void prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params) override;
|
RkISP1Params *params) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct rkisp1_cif_isp_dpf_config config_;
|
struct rkisp1_cif_isp_dpf_config config_;
|
||||||
|
|
|
@ -104,7 +104,7 @@ void Filter::queueRequest(IPAContext &context,
|
||||||
*/
|
*/
|
||||||
void Filter::prepare([[maybe_unused]] IPAContext &context,
|
void Filter::prepare([[maybe_unused]] IPAContext &context,
|
||||||
[[maybe_unused]] const uint32_t frame,
|
[[maybe_unused]] const uint32_t frame,
|
||||||
IPAFrameContext &frameContext, rkisp1_params_cfg *params)
|
IPAFrameContext &frameContext, RkISP1Params *params)
|
||||||
{
|
{
|
||||||
/* Check if the algorithm configuration has been updated. */
|
/* Check if the algorithm configuration has been updated. */
|
||||||
if (!frameContext.filter.update)
|
if (!frameContext.filter.update)
|
||||||
|
@ -160,23 +160,25 @@ void Filter::prepare([[maybe_unused]] IPAContext &context,
|
||||||
|
|
||||||
uint8_t denoise = frameContext.filter.denoise;
|
uint8_t denoise = frameContext.filter.denoise;
|
||||||
uint8_t sharpness = frameContext.filter.sharpness;
|
uint8_t sharpness = frameContext.filter.sharpness;
|
||||||
auto &flt_config = params->others.flt_config;
|
|
||||||
|
|
||||||
flt_config.fac_sh0 = filt_fac_sh0[sharpness];
|
auto config = params->block<BlockType::Flt>();
|
||||||
flt_config.fac_sh1 = filt_fac_sh1[sharpness];
|
config.setEnabled(true);
|
||||||
flt_config.fac_mid = filt_fac_mid[sharpness];
|
|
||||||
flt_config.fac_bl0 = filt_fac_bl0[sharpness];
|
|
||||||
flt_config.fac_bl1 = filt_fac_bl1[sharpness];
|
|
||||||
|
|
||||||
flt_config.lum_weight = kFiltLumWeightDefault;
|
config->fac_sh0 = filt_fac_sh0[sharpness];
|
||||||
flt_config.mode = kFiltModeDefault;
|
config->fac_sh1 = filt_fac_sh1[sharpness];
|
||||||
flt_config.thresh_sh0 = filt_thresh_sh0[denoise];
|
config->fac_mid = filt_fac_mid[sharpness];
|
||||||
flt_config.thresh_sh1 = filt_thresh_sh1[denoise];
|
config->fac_bl0 = filt_fac_bl0[sharpness];
|
||||||
flt_config.thresh_bl0 = filt_thresh_bl0[denoise];
|
config->fac_bl1 = filt_fac_bl1[sharpness];
|
||||||
flt_config.thresh_bl1 = filt_thresh_bl1[denoise];
|
|
||||||
flt_config.grn_stage1 = stage1_select[denoise];
|
config->lum_weight = kFiltLumWeightDefault;
|
||||||
flt_config.chr_v_mode = filt_chr_v_mode[denoise];
|
config->mode = kFiltModeDefault;
|
||||||
flt_config.chr_h_mode = filt_chr_h_mode[denoise];
|
config->thresh_sh0 = filt_thresh_sh0[denoise];
|
||||||
|
config->thresh_sh1 = filt_thresh_sh1[denoise];
|
||||||
|
config->thresh_bl0 = filt_thresh_bl0[denoise];
|
||||||
|
config->thresh_bl1 = filt_thresh_bl1[denoise];
|
||||||
|
config->grn_stage1 = stage1_select[denoise];
|
||||||
|
config->chr_v_mode = filt_chr_v_mode[denoise];
|
||||||
|
config->chr_h_mode = filt_chr_h_mode[denoise];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Combined high denoising and high sharpening requires some
|
* Combined high denoising and high sharpening requires some
|
||||||
|
@ -186,27 +188,23 @@ void Filter::prepare([[maybe_unused]] IPAContext &context,
|
||||||
*/
|
*/
|
||||||
if (denoise == 9) {
|
if (denoise == 9) {
|
||||||
if (sharpness > 3)
|
if (sharpness > 3)
|
||||||
flt_config.grn_stage1 = 2;
|
config->grn_stage1 = 2;
|
||||||
} else if (denoise == 10) {
|
} else if (denoise == 10) {
|
||||||
if (sharpness > 5)
|
if (sharpness > 5)
|
||||||
flt_config.grn_stage1 = 2;
|
config->grn_stage1 = 2;
|
||||||
else if (sharpness > 3)
|
else if (sharpness > 3)
|
||||||
flt_config.grn_stage1 = 1;
|
config->grn_stage1 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (denoise > 7) {
|
if (denoise > 7) {
|
||||||
if (sharpness > 7) {
|
if (sharpness > 7) {
|
||||||
flt_config.fac_bl0 /= 2;
|
config->fac_bl0 /= 2;
|
||||||
flt_config.fac_bl1 /= 4;
|
config->fac_bl1 /= 4;
|
||||||
} else if (sharpness > 4) {
|
} else if (sharpness > 4) {
|
||||||
flt_config.fac_bl0 = flt_config.fac_bl0 * 3 / 4;
|
config->fac_bl0 = config->fac_bl0 * 3 / 4;
|
||||||
flt_config.fac_bl1 /= 2;
|
config->fac_bl1 /= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_FLT;
|
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_FLT;
|
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_FLT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_IPA_ALGORITHM(Filter, "Filter")
|
REGISTER_IPA_ALGORITHM(Filter, "Filter")
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
const ControlList &controls) override;
|
const ControlList &controls) override;
|
||||||
void prepare(IPAContext &context, const uint32_t frame,
|
void prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params) override;
|
RkISP1Params *params) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ipa::rkisp1::algorithms */
|
} /* namespace ipa::rkisp1::algorithms */
|
||||||
|
|
|
@ -99,11 +99,14 @@ void GammaOutCorrection::queueRequest(IPAContext &context, const uint32_t frame,
|
||||||
void GammaOutCorrection::prepare(IPAContext &context,
|
void GammaOutCorrection::prepare(IPAContext &context,
|
||||||
[[maybe_unused]] const uint32_t frame,
|
[[maybe_unused]] const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params)
|
RkISP1Params *params)
|
||||||
{
|
{
|
||||||
ASSERT(context.hw->numGammaOutSamples ==
|
ASSERT(context.hw->numGammaOutSamples ==
|
||||||
RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10);
|
RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10);
|
||||||
|
|
||||||
|
if (!frameContext.goc.update)
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The logarithmic segments as specified in the reference.
|
* The logarithmic segments as specified in the reference.
|
||||||
* Plus an additional 0 to make the loop easier
|
* Plus an additional 0 to make the loop easier
|
||||||
|
@ -112,10 +115,11 @@ void GammaOutCorrection::prepare(IPAContext &context,
|
||||||
64, 64, 64, 64, 128, 128, 128, 128, 256,
|
64, 64, 64, 64, 128, 128, 128, 128, 256,
|
||||||
256, 256, 512, 512, 512, 512, 512, 0
|
256, 256, 512, 512, 512, 512, 512, 0
|
||||||
};
|
};
|
||||||
__u16 *gamma_y = params->others.goc_config.gamma_y;
|
|
||||||
|
|
||||||
if (!frameContext.goc.update)
|
auto config = params->block<BlockType::Goc>();
|
||||||
return;
|
config.setEnabled(true);
|
||||||
|
|
||||||
|
__u16 *gamma_y = config->gamma_y;
|
||||||
|
|
||||||
unsigned x = 0;
|
unsigned x = 0;
|
||||||
for (const auto [i, size] : utils::enumerate(segments)) {
|
for (const auto [i, size] : utils::enumerate(segments)) {
|
||||||
|
@ -123,10 +127,7 @@ void GammaOutCorrection::prepare(IPAContext &context,
|
||||||
x += size;
|
x += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
params->others.goc_config.mode = RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC;
|
config->mode = RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC;
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_GOC;
|
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_GOC;
|
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_GOC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
const ControlList &controls) override;
|
const ControlList &controls) override;
|
||||||
void prepare(IPAContext &context, const uint32_t frame,
|
void prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params) override;
|
RkISP1Params *params) override;
|
||||||
void process(IPAContext &context, const uint32_t frame,
|
void process(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
const rkisp1_stat_buffer *stats,
|
const rkisp1_stat_buffer *stats,
|
||||||
|
|
|
@ -119,24 +119,20 @@ int GammaSensorLinearization::init([[maybe_unused]] IPAContext &context,
|
||||||
void GammaSensorLinearization::prepare([[maybe_unused]] IPAContext &context,
|
void GammaSensorLinearization::prepare([[maybe_unused]] IPAContext &context,
|
||||||
const uint32_t frame,
|
const uint32_t frame,
|
||||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params)
|
RkISP1Params *params)
|
||||||
{
|
{
|
||||||
if (frame > 0)
|
if (frame > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
params->others.sdg_config.xa_pnts.gamma_dx0 = gammaDx_[0];
|
auto config = params->block<BlockType::Sdg>();
|
||||||
params->others.sdg_config.xa_pnts.gamma_dx1 = gammaDx_[1];
|
config.setEnabled(true);
|
||||||
|
|
||||||
std::copy(curveYr_.begin(), curveYr_.end(),
|
config->xa_pnts.gamma_dx0 = gammaDx_[0];
|
||||||
params->others.sdg_config.curve_r.gamma_y);
|
config->xa_pnts.gamma_dx1 = gammaDx_[1];
|
||||||
std::copy(curveYg_.begin(), curveYg_.end(),
|
|
||||||
params->others.sdg_config.curve_g.gamma_y);
|
|
||||||
std::copy(curveYb_.begin(), curveYb_.end(),
|
|
||||||
params->others.sdg_config.curve_b.gamma_y);
|
|
||||||
|
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_SDG;
|
std::copy(curveYr_.begin(), curveYr_.end(), config->curve_r.gamma_y);
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_SDG;
|
std::copy(curveYg_.begin(), curveYg_.end(), config->curve_g.gamma_y);
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_SDG;
|
std::copy(curveYb_.begin(), curveYb_.end(), config->curve_b.gamma_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_IPA_ALGORITHM(GammaSensorLinearization, "GammaSensorLinearization")
|
REGISTER_IPA_ALGORITHM(GammaSensorLinearization, "GammaSensorLinearization")
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
int init(IPAContext &context, const YamlObject &tuningData) override;
|
int init(IPAContext &context, const YamlObject &tuningData) override;
|
||||||
void prepare(IPAContext &context, const uint32_t frame,
|
void prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params) override;
|
RkISP1Params *params) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t gammaDx_[2];
|
uint32_t gammaDx_[2];
|
||||||
|
|
|
@ -185,18 +185,12 @@ int LensShadingCorrection::configure(IPAContext &context,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LensShadingCorrection::setParameters(rkisp1_params_cfg *params)
|
void LensShadingCorrection::setParameters(rkisp1_cif_isp_lsc_config &config)
|
||||||
{
|
{
|
||||||
struct rkisp1_cif_isp_lsc_config &config = params->others.lsc_config;
|
|
||||||
|
|
||||||
memcpy(config.x_grad_tbl, xGrad_, sizeof(config.x_grad_tbl));
|
memcpy(config.x_grad_tbl, xGrad_, sizeof(config.x_grad_tbl));
|
||||||
memcpy(config.y_grad_tbl, yGrad_, sizeof(config.y_grad_tbl));
|
memcpy(config.y_grad_tbl, yGrad_, sizeof(config.y_grad_tbl));
|
||||||
memcpy(config.x_size_tbl, xSizes_, sizeof(config.x_size_tbl));
|
memcpy(config.x_size_tbl, xSizes_, sizeof(config.x_size_tbl));
|
||||||
memcpy(config.y_size_tbl, ySizes_, sizeof(config.y_size_tbl));
|
memcpy(config.y_size_tbl, ySizes_, sizeof(config.y_size_tbl));
|
||||||
|
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_LSC;
|
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_LSC;
|
|
||||||
params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_LSC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LensShadingCorrection::copyTable(rkisp1_cif_isp_lsc_config &config,
|
void LensShadingCorrection::copyTable(rkisp1_cif_isp_lsc_config &config,
|
||||||
|
@ -248,10 +242,8 @@ void LensShadingCorrection::interpolateTable(rkisp1_cif_isp_lsc_config &config,
|
||||||
void LensShadingCorrection::prepare(IPAContext &context,
|
void LensShadingCorrection::prepare(IPAContext &context,
|
||||||
const uint32_t frame,
|
const uint32_t frame,
|
||||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params)
|
RkISP1Params *params)
|
||||||
{
|
{
|
||||||
struct rkisp1_cif_isp_lsc_config &config = params->others.lsc_config;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is only one set, the configuration has already been done
|
* If there is only one set, the configuration has already been done
|
||||||
* for first frame.
|
* for first frame.
|
||||||
|
@ -264,8 +256,11 @@ void LensShadingCorrection::prepare(IPAContext &context,
|
||||||
* never be relevant.
|
* never be relevant.
|
||||||
*/
|
*/
|
||||||
if (sets_.size() == 1) {
|
if (sets_.size() == 1) {
|
||||||
setParameters(params);
|
auto config = params->block<BlockType::Lsc>();
|
||||||
copyTable(config, sets_.cbegin()->second);
|
config.setEnabled(true);
|
||||||
|
|
||||||
|
setParameters(*config);
|
||||||
|
copyTable(*config, sets_.cbegin()->second);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,13 +289,15 @@ void LensShadingCorrection::prepare(IPAContext &context,
|
||||||
(lastCt_.adjusted <= ct && ct <= lastCt_.original))
|
(lastCt_.adjusted <= ct && ct <= lastCt_.original))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setParameters(params);
|
auto config = params->block<BlockType::Lsc>();
|
||||||
|
config.setEnabled(true);
|
||||||
|
setParameters(*config);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The color temperature matches exactly one of the available LSC tables.
|
* The color temperature matches exactly one of the available LSC tables.
|
||||||
*/
|
*/
|
||||||
if (sets_.count(ct)) {
|
if (sets_.count(ct)) {
|
||||||
copyTable(config, sets_[ct]);
|
copyTable(*config, sets_[ct]);
|
||||||
lastCt_ = { ct, ct };
|
lastCt_ = { ct, ct };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +316,7 @@ void LensShadingCorrection::prepare(IPAContext &context,
|
||||||
if (diff0 < threshold || diff1 < threshold) {
|
if (diff0 < threshold || diff1 < threshold) {
|
||||||
const Components &set = diff0 < diff1 ? set0 : set1;
|
const Components &set = diff0 < diff1 ? set0 : set1;
|
||||||
LOG(RkISP1Lsc, Debug) << "using LSC table for " << set.ct;
|
LOG(RkISP1Lsc, Debug) << "using LSC table for " << set.ct;
|
||||||
copyTable(config, set);
|
copyTable(*config, set);
|
||||||
lastCt_ = { ct, set.ct };
|
lastCt_ = { ct, set.ct };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +328,7 @@ void LensShadingCorrection::prepare(IPAContext &context,
|
||||||
LOG(RkISP1Lsc, Debug)
|
LOG(RkISP1Lsc, Debug)
|
||||||
<< "ct is " << ct << ", interpolating between "
|
<< "ct is " << ct << ", interpolating between "
|
||||||
<< ct0 << " and " << ct1;
|
<< ct0 << " and " << ct1;
|
||||||
interpolateTable(config, set0, set1, ct);
|
interpolateTable(*config, set0, set1, ct);
|
||||||
lastCt_ = { ct, ct };
|
lastCt_ = { ct, ct };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;
|
int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;
|
||||||
void prepare(IPAContext &context, const uint32_t frame,
|
void prepare(IPAContext &context, const uint32_t frame,
|
||||||
IPAFrameContext &frameContext,
|
IPAFrameContext &frameContext,
|
||||||
rkisp1_params_cfg *params) override;
|
RkISP1Params *params) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Components {
|
struct Components {
|
||||||
|
@ -36,7 +36,7 @@ private:
|
||||||
std::vector<uint16_t> b;
|
std::vector<uint16_t> b;
|
||||||
};
|
};
|
||||||
|
|
||||||
void setParameters(rkisp1_params_cfg *params);
|
void setParameters(rkisp1_cif_isp_lsc_config &config);
|
||||||
void copyTable(rkisp1_cif_isp_lsc_config &config, const Components &set0);
|
void copyTable(rkisp1_cif_isp_lsc_config &config, const Components &set0);
|
||||||
void interpolateTable(rkisp1_cif_isp_lsc_config &config,
|
void interpolateTable(rkisp1_cif_isp_lsc_config &config,
|
||||||
const Components &set0, const Components &set1,
|
const Components &set0, const Components &set1,
|
||||||
|
|
|
@ -14,13 +14,14 @@
|
||||||
#include <libipa/module.h>
|
#include <libipa/module.h>
|
||||||
|
|
||||||
#include "ipa_context.h"
|
#include "ipa_context.h"
|
||||||
|
#include "params.h"
|
||||||
|
|
||||||
namespace libcamera {
|
namespace libcamera {
|
||||||
|
|
||||||
namespace ipa::rkisp1 {
|
namespace ipa::rkisp1 {
|
||||||
|
|
||||||
using Module = ipa::Module<IPAContext, IPAFrameContext, IPACameraSensorInfo,
|
using Module = ipa::Module<IPAContext, IPAFrameContext, IPACameraSensorInfo,
|
||||||
rkisp1_params_cfg, rkisp1_stat_buffer>;
|
RkISP1Params, rkisp1_stat_buffer>;
|
||||||
|
|
||||||
} /* namespace ipa::rkisp1 */
|
} /* namespace ipa::rkisp1 */
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "algorithms/algorithm.h"
|
#include "algorithms/algorithm.h"
|
||||||
|
|
||||||
#include "ipa_context.h"
|
#include "ipa_context.h"
|
||||||
|
#include "params.h"
|
||||||
|
|
||||||
namespace libcamera {
|
namespace libcamera {
|
||||||
|
|
||||||
|
@ -322,17 +323,13 @@ void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
|
||||||
{
|
{
|
||||||
IPAFrameContext &frameContext = context_.frameContexts.get(frame);
|
IPAFrameContext &frameContext = context_.frameContexts.get(frame);
|
||||||
|
|
||||||
rkisp1_params_cfg *params =
|
RkISP1Params params(context_.configuration.paramFormat,
|
||||||
reinterpret_cast<rkisp1_params_cfg *>(
|
mappedBuffers_.at(bufferId).planes()[0]);
|
||||||
mappedBuffers_.at(bufferId).planes()[0].data());
|
|
||||||
|
|
||||||
/* Prepare parameters buffer. */
|
|
||||||
memset(params, 0, sizeof(*params));
|
|
||||||
|
|
||||||
for (auto const &algo : algorithms())
|
for (auto const &algo : algorithms())
|
||||||
algo->prepare(context_, frame, frameContext, params);
|
algo->prepare(context_, frame, frameContext, ¶ms);
|
||||||
|
|
||||||
paramsBufferReady.emit(frame, sizeof(*params));
|
paramsBufferReady.emit(frame, params.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId,
|
void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue