Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove MergeConfig() and SetOutputAXI() #20

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 0 additions & 85 deletions src/libpisp/backend/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,71 +14,6 @@

using namespace libpisp;

namespace
{

struct config_param
{
uint32_t dirty_flags_bayer;
uint32_t dirty_flags_rgb;
uint32_t dirty_flags_extra;
std::size_t offset;
std::size_t size;
};

const config_param config_map[] = {
// *_dirty_flag_extra types
{ 0, 0, PISP_BE_DIRTY_GLOBAL, offsetof(pisp_be_config, global), sizeof(pisp_be_global_config) },
{ 0, 0, PISP_BE_DIRTY_SH_FC_COMBINE, offsetof(pisp_be_config, sh_fc_combine), sizeof(pisp_be_sh_fc_combine_config) },
{ 0, 0, PISP_BE_DIRTY_CROP, offsetof(pisp_be_config, crop), sizeof(pisp_be_crop_config) },

// *_dirty_flags_bayer types
{ PISP_BE_BAYER_ENABLE_DECOMPRESS, 0, 0, offsetof(pisp_be_config, decompress), sizeof(pisp_decompress_config) },
{ PISP_BE_BAYER_ENABLE_DPC, 0, 0, offsetof(pisp_be_config, dpc), sizeof(pisp_be_dpc_config) },
{ PISP_BE_BAYER_ENABLE_GEQ, 0, 0, offsetof(pisp_be_config, geq), sizeof(pisp_be_geq_config) },
{ PISP_BE_BAYER_ENABLE_TDN_INPUT, 0, 0, offsetof(pisp_be_config, tdn_input_format), sizeof(pisp_image_format_config) },
{ PISP_BE_BAYER_ENABLE_TDN_DECOMPRESS, 0, 0, offsetof(pisp_be_config, tdn_decompress), sizeof(pisp_decompress_config) },
{ PISP_BE_BAYER_ENABLE_TDN, 0, 0, offsetof(pisp_be_config, tdn), sizeof(pisp_be_tdn_config) },
{ PISP_BE_BAYER_ENABLE_TDN_COMPRESS, 0, 0, offsetof(pisp_be_config, tdn_compress), sizeof(pisp_compress_config) },
{ PISP_BE_BAYER_ENABLE_TDN_OUTPUT, 0, 0, offsetof(pisp_be_config, tdn_output_format), sizeof(pisp_image_format_config) },
{ PISP_BE_BAYER_ENABLE_SDN, 0, 0, offsetof(pisp_be_config, sdn), sizeof(pisp_be_sdn_config) },
{ PISP_BE_BAYER_ENABLE_BLC, 0, 0, offsetof(pisp_be_config, blc), sizeof(pisp_bla_config) },
{ PISP_BE_BAYER_ENABLE_STITCH_COMPRESS, 0, 0, offsetof(pisp_be_config, stitch_compress), sizeof(pisp_compress_config) },
{ PISP_BE_BAYER_ENABLE_STITCH_OUTPUT, 0, 0, offsetof(pisp_be_config, stitch_output_format), sizeof(pisp_image_format_config) },
{ PISP_BE_BAYER_ENABLE_STITCH_INPUT, 0, 0, offsetof(pisp_be_config, stitch_input_format), sizeof(pisp_image_format_config) },
{ PISP_BE_BAYER_ENABLE_STITCH_DECOMPRESS, 0, 0, offsetof(pisp_be_config, stitch_decompress), sizeof(pisp_decompress_config) },
{ PISP_BE_BAYER_ENABLE_STITCH, 0, 0, offsetof(pisp_be_config, stitch), sizeof(pisp_be_stitch_config) },
{ PISP_BE_BAYER_ENABLE_LSC, 0, 0, offsetof(pisp_be_config, lsc), sizeof(pisp_be_lsc_config) },
{ PISP_BE_BAYER_ENABLE_WBG, 0, 0, offsetof(pisp_be_config, wbg), sizeof(pisp_wbg_config) },
{ PISP_BE_BAYER_ENABLE_CDN, 0, 0, offsetof(pisp_be_config, cdn), sizeof(pisp_be_cdn_config) },
{ PISP_BE_BAYER_ENABLE_CAC, 0, 0, offsetof(pisp_be_config, cac), sizeof(pisp_be_cac_config) },
{ PISP_BE_BAYER_ENABLE_DEBIN, 0, 0, offsetof(pisp_be_config, debin), sizeof(pisp_be_debin_config) },
{ PISP_BE_BAYER_ENABLE_TONEMAP, 0, 0, offsetof(pisp_be_config, tonemap), sizeof(pisp_be_tonemap_config) },
{ PISP_BE_BAYER_ENABLE_DEMOSAIC, 0, 0, offsetof(pisp_be_config, demosaic), sizeof(pisp_be_demosaic_config) },

// *_dirty_flags_rgb types
{ PISP_BE_RGB_ENABLE_CCM, 0, 0, offsetof(pisp_be_config, ccm), sizeof(pisp_be_ccm_config) },
{ PISP_BE_RGB_ENABLE_SAT_CONTROL, 0, 0, offsetof(pisp_be_config, sat_control), sizeof(pisp_be_sat_control_config) },
{ PISP_BE_RGB_ENABLE_YCBCR, 0, 0, offsetof(pisp_be_config, ycbcr), sizeof(pisp_be_ccm_config) },
{ PISP_BE_RGB_ENABLE_SHARPEN, 0, 0, offsetof(pisp_be_config, sharpen), sizeof(pisp_be_sharpen_config) },
{ PISP_BE_RGB_ENABLE_FALSE_COLOUR, 0, 0, offsetof(pisp_be_config, false_colour), sizeof(pisp_be_false_colour_config) },
{ PISP_BE_RGB_ENABLE_YCBCR_INVERSE, 0, 0, offsetof(pisp_be_config, ycbcr_inverse), sizeof(pisp_be_ccm_config) },
{ PISP_BE_RGB_ENABLE_GAMMA, 0, 0, offsetof(pisp_be_config, gamma), sizeof(pisp_be_gamma_config) },
// Output 0
{ PISP_BE_RGB_ENABLE_CSC0, 0, 0, offsetof(pisp_be_config, csc), sizeof(pisp_be_ccm_config) },
{ PISP_BE_RGB_ENABLE_DOWNSCALE0, 0, 0, offsetof(pisp_be_config, downscale), sizeof(pisp_be_downscale_config) },
{ PISP_BE_RGB_ENABLE_RESAMPLE0, 0, 0, offsetof(pisp_be_config, resample), sizeof(pisp_be_resample_config) },
{ PISP_BE_RGB_ENABLE_OUTPUT0, 0, 0, offsetof(pisp_be_config, output_format), sizeof(pisp_be_output_format_config) },
{ PISP_BE_RGB_ENABLE_HOG, 0, 0, offsetof(pisp_be_config, hog), sizeof(pisp_be_hog_config) },
// Output 1
{ PISP_BE_RGB_ENABLE_CSC1, 0, 0, offsetof(pisp_be_config, csc) + sizeof(pisp_be_ccm_config), sizeof(pisp_be_ccm_config) },
{ PISP_BE_RGB_ENABLE_DOWNSCALE1, 0, 0, offsetof(pisp_be_config, downscale) + sizeof(pisp_be_downscale_config), sizeof(pisp_be_downscale_config) },
{ PISP_BE_RGB_ENABLE_RESAMPLE1, 0, 0, offsetof(pisp_be_config, resample) + sizeof(pisp_be_resample_config), sizeof(pisp_be_resample_config) },
{ PISP_BE_RGB_ENABLE_OUTPUT1, 0, 0, offsetof(pisp_be_config, output_format) + sizeof(pisp_be_output_format_config), sizeof(pisp_be_output_format_config) },
};

} // namespace

BackEnd::BackEnd(Config const &config, PiSPVariant const &variant)
: config_(config), variant_(variant), retile_(true), finalise_tiling_(true)
{
Expand Down Expand Up @@ -475,26 +410,6 @@ void BackEnd::GetOutputFormat(unsigned int i, pisp_be_output_format_config &outp
output_format = be_config_.output_format[i];
}

void BackEnd::MergeConfig(const pisp_be_config &config)
{
for (auto const &param : config_map)
{
if ((param.dirty_flags_bayer & config.dirty_flags_bayer) || (param.dirty_flags_rgb & config.dirty_flags_rgb) ||
(param.dirty_flags_extra & config.dirty_flags_extra))
{
const uint8_t *src = reinterpret_cast<const uint8_t *>(&config) + param.offset;
uint8_t *dest = reinterpret_cast<uint8_t *>(&be_config_) + param.offset;

memcpy(dest, src, param.size);
be_config_.dirty_flags_bayer |= param.dirty_flags_bayer;
be_config_.dirty_flags_rgb |= param.dirty_flags_rgb;
be_config_.dirty_flags_extra |= param.dirty_flags_extra;
// Force a retile for now. This could become more granular.
retile_ = true;
}
}
}

void BackEnd::SetSmartResize(unsigned int i, BackEnd::SmartResize const &smart_resize)
{
PISP_ASSERT(i < variant_.BackEndNumBranches(0));
Expand Down
1 change: 0 additions & 1 deletion src/libpisp/backend/backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class BackEnd
void InitialiseSharpen(pisp_be_sharpen_config &sharpen, pisp_be_sh_fc_combine_config &shfc);

void Prepare(pisp_be_tiles_config *config);
void MergeConfig(const pisp_be_config &config);

bool ComputeOutputImageFormat(unsigned int i, pisp_image_format_config &output_format,
pisp_image_format_config const &input_format) const;
Expand Down
2 changes: 1 addition & 1 deletion src/libpisp/backend/backend_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const std::vector<config_block> be_config {
{
{ "grid_step_x", offsetof(pisp_be_lsc_config, grid_step_x), sizeof(uint16_t), 1 },
{ "grid_step_y", offsetof(pisp_be_lsc_config, grid_step_y), sizeof(uint16_t), 1 },
{ "lut_packed", offsetof(pisp_be_lsc_config, lut_packed), sizeof(uint16_t), PISP_ARRAY_SIZE(pisp_be_lsc_config, lut_packed) },
{ "lut_packed", offsetof(pisp_be_lsc_config, lut_packed), sizeof(uint32_t), PISP_ARRAY_SIZE(pisp_be_lsc_config, lut_packed) },
}
},
{
Expand Down
71 changes: 6 additions & 65 deletions src/libpisp/frontend/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,6 @@ using namespace libpisp;
namespace
{

struct config_param
{
uint32_t dirty_flag;
uint32_t dirty_flag_extra;
std::size_t offset;
std::size_t size;
};

const config_param config_map[] = {
// *_dirty_flag_extra types
{ 0, PISP_FE_DIRTY_GLOBAL, offsetof(pisp_fe_config, global), sizeof(pisp_fe_global_config) },
{ 0, PISP_FE_DIRTY_FLOATING, offsetof(pisp_fe_config, floating_stats), sizeof(pisp_fe_floating_stats_config) },
{ 0, PISP_FE_DIRTY_OUTPUT_AXI, offsetof(pisp_fe_config, output_axi), sizeof(pisp_fe_output_axi_config) },
// *_dirty_flag types
{ PISP_FE_ENABLE_INPUT, 0, offsetof(pisp_fe_config, input), sizeof(pisp_fe_input_config) },
{ PISP_FE_ENABLE_DECOMPRESS, 0, offsetof(pisp_fe_config, decompress), sizeof(pisp_decompress_config) },
{ PISP_FE_ENABLE_DECOMPAND, 0, offsetof(pisp_fe_config, decompand), sizeof(pisp_fe_decompand_config) },
{ PISP_FE_ENABLE_BLA, 0, offsetof(pisp_fe_config, bla), sizeof(pisp_bla_config) },
{ PISP_FE_ENABLE_DPC, 0, offsetof(pisp_fe_config, dpc), sizeof(pisp_fe_dpc_config) },
{ PISP_FE_ENABLE_STATS_CROP, 0, offsetof(pisp_fe_config, stats_crop), sizeof(pisp_fe_crop_config) },
{ PISP_FE_ENABLE_BLC, 0, offsetof(pisp_fe_config, blc), sizeof(pisp_bla_config) },
{ PISP_FE_ENABLE_CDAF_STATS, 0, offsetof(pisp_fe_config, cdaf_stats), sizeof(pisp_fe_cdaf_stats_config) },
{ PISP_FE_ENABLE_AWB_STATS, 0, offsetof(pisp_fe_config, awb_stats), sizeof(pisp_fe_awb_stats_config) },
{ PISP_FE_ENABLE_RGBY, 0, offsetof(pisp_fe_config, rgby), sizeof(pisp_fe_rgby_config) },
{ PISP_FE_ENABLE_LSC, 0, offsetof(pisp_fe_config, lsc), sizeof(pisp_fe_lsc_config) },
{ PISP_FE_ENABLE_AGC_STATS, 0, offsetof(pisp_fe_config, agc_stats), sizeof(pisp_agc_statistics) },
{ PISP_FE_ENABLE_CROP0, 0, offsetof(pisp_fe_config, ch[0].crop), sizeof(pisp_fe_crop_config) },
{ PISP_FE_ENABLE_DOWNSCALE0, 0, offsetof(pisp_fe_config, ch[0].downscale), sizeof(pisp_fe_downscale_config) },
{ PISP_FE_ENABLE_COMPRESS0, 0, offsetof(pisp_fe_config, ch[0].compress), sizeof(pisp_compress_config) },
{ PISP_FE_ENABLE_OUTPUT0, 0, offsetof(pisp_fe_config, ch[0].output), sizeof(pisp_fe_output_config) },
{ PISP_FE_ENABLE_CROP1, 0, offsetof(pisp_fe_config, ch[1].crop), sizeof(pisp_fe_crop_config) },
{ PISP_FE_ENABLE_DOWNSCALE1, 0, offsetof(pisp_fe_config, ch[1].downscale), sizeof(pisp_fe_downscale_config) },
{ PISP_FE_ENABLE_COMPRESS1, 0, offsetof(pisp_fe_config, ch[1].compress), sizeof(pisp_compress_config) },
{ PISP_FE_ENABLE_OUTPUT1, 0, offsetof(pisp_fe_config, ch[1].output), sizeof(pisp_fe_output_config) },
};

inline uint32_t block_enable(uint32_t block, unsigned int branch)
{
return block << (4 * branch);
Expand Down Expand Up @@ -219,13 +183,12 @@ FrontEnd::FrontEnd(bool streaming, PiSPVariant const &variant, int align) : vari
}
else
{
pisp_fe_output_axi_config output_axi;
output_axi.maxlen_flags = 0xaf;
output_axi.cache_prot = 0x32;
output_axi.qos = 0x8410;
output_axi.thresh = 0x0140;
output_axi.throttle = 0x4100;
SetOutputAXI(output_axi);
fe_config_.output_axi.maxlen_flags = 0xaf;
fe_config_.output_axi.cache_prot = 0x32;
fe_config_.output_axi.qos = 0x8410;
fe_config_.output_axi.thresh = 0x0140;
fe_config_.output_axi.throttle = 0x4100;
fe_config_.dirty_flags_extra |= PISP_FE_DIRTY_OUTPUT_AXI;
}

pisp_fe_global_config global;
Expand Down Expand Up @@ -395,28 +358,6 @@ void FrontEnd::SetOutputBuffer(unsigned int output_num, pisp_fe_output_buffer_co
// Assume these always get written.
}

void FrontEnd::SetOutputAXI(pisp_fe_output_axi_config const &output_axi)
{
fe_config_.output_axi = output_axi;
fe_config_.dirty_flags_extra |= PISP_FE_DIRTY_OUTPUT_AXI;
}

void FrontEnd::MergeConfig(const pisp_fe_config &config)
{
for (auto const &param : config_map)
{
if ((param.dirty_flag & config.dirty_flags) || (param.dirty_flag_extra & config.dirty_flags_extra))
{
const uint8_t *src = reinterpret_cast<const uint8_t *>(&config) + param.offset;
uint8_t *dest = reinterpret_cast<uint8_t *>(&fe_config_) + param.offset;

memcpy(dest, src, param.size);
fe_config_.dirty_flags |= param.dirty_flag;
fe_config_.dirty_flags_extra |= param.dirty_flag_extra;
}
}
}

void FrontEnd::Prepare(pisp_fe_config *config)
{
// Only finalise blocks that are dirty *and* enabled.
Expand Down
2 changes: 0 additions & 2 deletions src/libpisp/frontend/frontend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class FrontEnd
void SetOutputFormat(unsigned int output_num, pisp_image_format_config const &output_format);
void SetOutputBuffer(unsigned int output_num, pisp_fe_output_buffer_config const &output_buffer);
void SetOutputIntrLines(unsigned int output_num, int lines);
void SetOutputAXI(pisp_fe_output_axi_config const &output_axi);
naushir marked this conversation as resolved.
Show resolved Hide resolved
void MergeConfig(const pisp_fe_config &config);
void Prepare(pisp_fe_config *config);

void lock()
Expand Down
Loading