Skip to content
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
Binary file modified config/linux/ipu75xa/gcss/OV08X40_KAFE799.IPU75XA.bin
Binary file not shown.
Binary file modified config/linux/ipu75xa/gcss/OV13B10_09B13.IPU75XA.bin
Binary file not shown.
Binary file modified config/linux/ipu7x/gcss/IMX471_AAJH5-D.IPU7X.bin
Binary file not shown.
Binary file modified config/linux/ipu7x/gcss/OV02C10_MSHW0550.IPU7X.bin
Binary file not shown.
Binary file modified config/linux/ipu7x/gcss/OV02E10_CBG202N3.IPU7X.bin
Binary file not shown.
Binary file modified config/linux/ipu7x/gcss/OV05C10_BBG501N3.IPU7X.bin
Binary file not shown.
Binary file modified config/linux/ipu7x/gcss/OV08X40_BBG802N3_LNL.IPU7X.bin
Binary file not shown.
Binary file modified config/linux/ipu7x/gcss/OV13B10_09B13.IPU7X.bin
Binary file not shown.
Binary file modified config/linux/ipu7x/gcss/S5K3J1_GRBG_NONPDAF.IPU7X.bin
Binary file not shown.
207 changes: 182 additions & 25 deletions modules/ipu_desc/ipu75xa/FragmentsConfigurator.cpp

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions modules/ipu_desc/ipu75xa/FragmentsConfigurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
class Ipu8FragmentsConfigurator
{
public:

static const int32_t VANISH_MIN = 16;
static const int32_t MIN_STRIPE_WIDTH_BEFORE_TNR = 128;
static const int32_t MIN_STRIPE_WIDTH_AFTER_TNR = 64;
static const int32_t UPSCALER_MAX_OUTPUT_WIDTH = 4672;
Ipu8FragmentsConfigurator(IStaticGraphConfig* staticGraph, OuterNode* node, uint32_t upscalerWidthGranularity);

StaticGraphStatus configureFragments();
StaticGraphStatus configureFragments(std::vector<SmurfKernelInfo*>& smurfKernels);

private:
// Stripe Actions - each filter will perform one action according to its role
Expand All @@ -46,11 +46,15 @@ class Ipu8FragmentsConfigurator
StaticGraphStatus configFragmentsOutput(StaticGraphRunKernel* runKernel, StaticGraphFragmentDesc* kernelFragments, uint32_t prevKernelUuid, StaticGraphFragmentDesc* prevKernelFragments);
StaticGraphStatus configFragmentsTnrScaler(StaticGraphRunKernel* runKernel, StaticGraphFragmentDesc* kernelFragments, uint32_t prevKernelUuid, StaticGraphFragmentDesc* prevKernelFragments);
StaticGraphStatus configFragmentsTnrFeeder(StaticGraphRunKernel* runKernel, StaticGraphFragmentDesc* kernelFragments, GraphResolutionConfiguratorKernelRole kernelRole);
StaticGraphStatus configFragmentsSmurf(StaticGraphRunKernel* runKernel, StaticGraphFragmentDesc* kernelFragments, uint32_t prevKernelUuid, StaticGraphFragmentDesc* prevKernelFragments,
std::vector<SmurfKernelInfo*>& smurfKernels);
StaticGraphStatus configFragmentsSmurfFeeder(StaticGraphRunKernel* runKernel, StaticGraphFragmentDesc* kernelFragments);

void copyFragments(StaticGraphRunKernel* runKernel, StaticGraphFragmentDesc* prevKernelFragments, uint32_t prevKernelUuid, StaticGraphFragmentDesc* kernelFragments);
StaticGraphStatus copyFragments(StaticGraphRunKernel* runKernel, StaticGraphFragmentDesc* prevKernelFragments, uint32_t prevKernelUuid, StaticGraphFragmentDesc* kernelFragments);
void vanishStripe(uint8_t stripe, uint32_t runKerenlUuid, StaticGraphFragmentDesc* kernelFragments, VanishOption vanishOption);
uint32_t getPlaneStartAddress(uint32_t sumOfPrevWidths, FormatType formatType, uint8_t plane);
uint16_t alignToFormatRestrictions(uint16_t size, FormatType bufferFormat);
bool validateDownscalerOutputWidth(StaticGraphFragmentDesc* stripe, uint16_t addition, int32_t stripeIndex, double scaleFactor, StaticGraphRunKernel* runKernel);

OuterNode* _node = nullptr;
IStaticGraphConfig* _staticGraph = nullptr;
Expand All @@ -61,5 +65,5 @@ class Ipu8FragmentsConfigurator

// Save TNR resolutions for feeder configurations
StaticGraphFragmentDesc* _tnrScalerFragments = nullptr;
uint32_t _tnrScalerUuid = 0;
StaticGraphRunKernel* _tnrScalerRunKernel = nullptr;
};
105 changes: 74 additions & 31 deletions modules/ipu_desc/ipu75xa/GraphResolutionConfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@ StaticGraphStatus GraphResolutionConfigurator::updateRunKernelUpScaler(StaticGra
uint32_t& upscalerActualInputWidth, uint32_t& upscalerActualInputHeight,
uint32_t& upscalerActualOutputWidth, uint32_t& upscalerActualOutputHeight)
{
static const int SCALE_PREC = 16;
const uint32_t ia_pal_isp_upscaler_1_0__scaling_ratio__min = 4096;

const uint32_t max_upscaling = (1 << SCALE_PREC) / ia_pal_isp_upscaler_1_0__scaling_ratio__min;
Expand Down Expand Up @@ -1166,14 +1165,6 @@ Ipu8GraphResolutionConfigurator::Ipu8GraphResolutionConfigurator(IStaticGraphCon
_originalCropOfOutput = _outputRunKernel->resolution_info->input_crop;
}

_widthIn2OutScale = static_cast<double>(_outputRunKernel->resolution_history->input_width
- _outputRunKernel->resolution_history->input_crop.left - _outputRunKernel->resolution_history->input_crop.right) /
_outputRunKernel->resolution_history->output_width;

_heightIn2OutScale = static_cast<double>(_outputRunKernel->resolution_history->input_height
- _outputRunKernel->resolution_history->input_crop.top - _outputRunKernel->resolution_history->input_crop.bottom) /
_outputRunKernel->resolution_history->output_height;

SensorMode* sensorMode = nullptr;
_staticGraph->getSensorMode(&sensorMode);
if (sensorMode == nullptr)
Expand All @@ -1193,10 +1184,14 @@ Ipu8GraphResolutionConfigurator::Ipu8GraphResolutionConfigurator(IStaticGraphCon
}

#if SUPPORT_FRAGMENTS == 1

initIsFragments();

if (_node != nullptr && _node->GetNumberOfFragments() > 1)
{
_fragmentsConfigurator = new Ipu8FragmentsConfigurator(_staticGraph, _node, _upscalerStepW);
}

#endif
}

Expand All @@ -1211,6 +1206,13 @@ Ipu8GraphResolutionConfigurator::~Ipu8GraphResolutionConfigurator()
delete _fragmentsConfigurator;
_fragmentsConfigurator = nullptr;
}

for (auto& smurfInfo : _smurfKernels)
{
delete smurfInfo;
}
_smurfKernels.clear();

#endif
}

Expand Down Expand Up @@ -1330,14 +1332,50 @@ StaticGraphStatus Ipu8GraphResolutionConfigurator::initKernelsForUpdate()
if (initRunKernel(smurfUuid.first, runKernel) == StaticGraphStatus::SG_OK &&
initRunKernel(smurfUuid.second, deviceRunKernel) == StaticGraphStatus::SG_OK)
{
std::pair<StaticGraphRunKernel*, StaticGraphRunKernel*> runKernelPair = std::make_pair(runKernel, deviceRunKernel);
_smurfKernels.push_back(runKernelPair);
SmurfKernelInfo* smurfInfo = new SmurfKernelInfo();
smurfInfo->_smurfRunKernel = runKernel;
smurfInfo->_deviceRunKernel = deviceRunKernel;
smurfInfo->_originalDeviceCropHistory = deviceRunKernel->resolution_history->input_crop;
smurfInfo->_originalSmurfOutputCrop = runKernel->resolution_info->output_crop;

_smurfKernels.push_back(smurfInfo);
}
}

return StaticGraphStatus::SG_OK;
}

StaticGraphStatus Ipu8GraphResolutionConfigurator::initIsFragments()
{
_isFragments = false;

if (_downscalerRunKernel == nullptr)
{
return StaticGraphStatus::SG_ERROR;
}

#ifdef STATIC_GRAPH_USE_IA_LEGACY_TYPES
if (_downscalerRunKernel->system_api.size != ((GRA_ROUND_UP(sizeof(SystemApiRecordHeader), 4)) + (sizeof(StaticGraphKernelSystemApiB2iDs1_1))))
{
// TODO log error
return StaticGraphStatus::SG_ERROR;
}
#endif

auto systemApiHeader = static_cast<SystemApiRecordHeader*>(_downscalerRunKernel->system_api.data);
if (systemApiHeader->systemApiUuid != GraphResolutionConfiguratorHelper::getRunKernelDownscalerSystemApiUuid())
{
// TODO log error
return StaticGraphStatus::SG_ERROR;
}

StaticGraphKernelSystemApiB2iDs1_1* systemApi = reinterpret_cast<StaticGraphKernelSystemApiB2iDs1_1*>
(static_cast<int8_t*>(_downscalerRunKernel->system_api.data) + GRA_ROUND_UP(sizeof(SystemApiRecordHeader), 4));

_isFragments = systemApi->is_striping;
return StaticGraphStatus::SG_OK;
}

StaticGraphStatus Ipu8GraphResolutionConfigurator::updateStaticGraphConfig(const RegionOfInterest& roi, bool isCenteredZoom)
{
if (_staticGraph == nullptr)
Expand Down Expand Up @@ -1504,9 +1542,9 @@ StaticGraphStatus Ipu8GraphResolutionConfigurator::updateRunKernelOfScalers(Reso

// After resolution history was updated, re-configure SAP devices to get the correct FOV
// We do not change the sap feeders configuration, only update the crop & scale of smurfs
for (auto& runKernelForUpdate : _smurfKernels)
for (auto& smurfInfo : _smurfKernels)
{
if (updateRunKernelSmurf(runKernelForUpdate.first, runKernelForUpdate.second) != StaticGraphStatus::SG_OK)
if (updateRunKernelSmurf(smurfInfo) != StaticGraphStatus::SG_OK)
{
ret = StaticGraphStatus::SG_ERROR;
}
Expand All @@ -1517,10 +1555,10 @@ StaticGraphStatus Ipu8GraphResolutionConfigurator::updateRunKernelOfScalers(Reso
ret = SanityCheck();
}

if (_fragmentsConfigurator != nullptr)
if (ret == StaticGraphStatus::SG_OK && _fragmentsConfigurator != nullptr)
{
// Configure fragments according to the new zoomed run kernels information
_fragmentsConfigurator->configureFragments();
ret = _fragmentsConfigurator->configureFragments(_smurfKernels);
}

return ret;
Expand All @@ -1530,7 +1568,7 @@ StaticGraphStatus Ipu8GraphResolutionConfigurator::updateRunKernelDownScaler(Sta
{
StaticGraphStatus ret = StaticGraphStatus::SG_OK;

if (_fragmentsConfigurator == nullptr)
if (_isFragments == false)
{
// No fragments, crop to ROI and downscale to output resolution
runKernel->resolution_info->output_width = outputWidth;
Expand Down Expand Up @@ -1763,34 +1801,39 @@ StaticGraphStatus Ipu8GraphResolutionConfigurator::updateRunKernelUpScaler(Stati
return ret;
}

StaticGraphStatus Ipu8GraphResolutionConfigurator::updateRunKernelSmurf(StaticGraphRunKernel* smurfRunKernel, StaticGraphRunKernel* deviceRunKernel)
StaticGraphStatus Ipu8GraphResolutionConfigurator::updateRunKernelSmurf(SmurfKernelInfo* smurfInfo)
{
StaticGraphStatus ret = StaticGraphStatus::SG_OK;

auto resInfo = smurfRunKernel->resolution_info;
auto resInfo = smurfInfo->_smurfRunKernel->resolution_info;
if (resInfo->input_width == 0 || resInfo->input_height == 0)
{
return StaticGraphStatus::SG_OK;
}

// We need to reach new history for device, without the crop already done by feeder.
// The hist of the smurf is the crop already being done by feeder, mutliplied by segmap factor (without smurf factor which changes)
StaticGraphKernelResCrop smurfNewCrop;
smurfNewCrop.left = deviceRunKernel->resolution_history->input_crop.left - smurfRunKernel->resolution_history->input_crop.left;
smurfNewCrop.right = deviceRunKernel->resolution_history->input_crop.right - smurfRunKernel->resolution_history->input_crop.right;
smurfNewCrop.top = deviceRunKernel->resolution_history->input_crop.top - smurfRunKernel->resolution_history->input_crop.top;
smurfNewCrop.bottom = deviceRunKernel->resolution_history->input_crop.bottom - smurfRunKernel->resolution_history->input_crop.bottom;
// We need to update smurf's output crop according to device's new crop history
StaticGraphKernelRes* deviceResHist = smurfInfo->_deviceRunKernel->resolution_history;
StaticGraphKernelResCrop newCrop;
newCrop.left = deviceResHist->input_crop.left - smurfInfo->_originalDeviceCropHistory.left;
newCrop.right = deviceResHist->input_crop.right - smurfInfo->_originalDeviceCropHistory.right;
newCrop.top = deviceResHist->input_crop.top - smurfInfo->_originalDeviceCropHistory.top;
newCrop.bottom = deviceResHist->input_crop.bottom - smurfInfo->_originalDeviceCropHistory.bottom;

// Now calculate how much is left for the smurf to crop
// Translate from history units to device units
double newInputToDeviceFactor = static_cast<double>(deviceRunKernel->resolution_history->input_width - deviceRunKernel->resolution_history->input_crop.left - deviceRunKernel->resolution_history->input_crop.right) /
deviceRunKernel->resolution_history->output_width;
double newInputToDeviceFactor = static_cast<double>(deviceResHist->input_width - deviceResHist->input_crop.left - deviceResHist->input_crop.right) /
deviceResHist->output_width;

// Now translate from history units to smurf output (device)
smurfRunKernel->resolution_info->output_crop.left = static_cast<int32_t>(smurfNewCrop.left / newInputToDeviceFactor);
smurfRunKernel->resolution_info->output_crop.right = static_cast<int32_t>(smurfNewCrop.right / newInputToDeviceFactor);
smurfRunKernel->resolution_info->output_crop.top = static_cast<int32_t>(smurfNewCrop.top / newInputToDeviceFactor);
smurfRunKernel->resolution_info->output_crop.bottom = static_cast<int32_t>(smurfNewCrop.bottom / newInputToDeviceFactor);
newCrop.left = static_cast<int32_t>(newCrop.left / newInputToDeviceFactor);
newCrop.right = static_cast<int32_t>(newCrop.right / newInputToDeviceFactor);
newCrop.top = static_cast<int32_t>(newCrop.top / newInputToDeviceFactor);
newCrop.bottom = static_cast<int32_t>(newCrop.bottom / newInputToDeviceFactor);

smurfInfo->_smurfRunKernel->resolution_info->output_crop.left = smurfInfo->_originalSmurfOutputCrop.left + newCrop.left;
smurfInfo->_smurfRunKernel->resolution_info->output_crop.right = smurfInfo->_originalSmurfOutputCrop.right + newCrop.right;
smurfInfo->_smurfRunKernel->resolution_info->output_crop.top = smurfInfo->_originalSmurfOutputCrop.top + newCrop.top;
smurfInfo->_smurfRunKernel->resolution_info->output_crop.bottom = smurfInfo->_originalSmurfOutputCrop.bottom + newCrop.bottom;

return ret;
}
Expand Down
19 changes: 17 additions & 2 deletions modules/ipu_desc/ipu75xa/GraphResolutionConfigurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ enum class GraphResolutionConfiguratorKernelRole : uint8_t
TnrScaler,
TnrFeederFull,
TnrFeederSmall,
Smurf,
SmurfFeeder,
None
};

Expand Down Expand Up @@ -122,6 +124,8 @@ class GraphResolutionConfigurator
StaticGraphStatus undoSensorCropandScale(SensorRoi& sensor_roi);
StaticGraphStatus sensorCropOrScaleExist(bool& sensor_crop_or_scale_exist);
StaticGraphStatus undoSensorScaleRipAngle(int32_t& rip_angle);

static const int SCALE_PREC = 16;
protected:
StaticGraphStatus updateRunKernelPassThrough(StaticGraphRunKernel* runKernel, uint32_t width, uint32_t height);
StaticGraphStatus updateRunKernelResolutionHistory(StaticGraphRunKernel* runKernel, StaticGraphRunKernel* prevRunKernel, bool updateResolution = true);
Expand Down Expand Up @@ -172,6 +176,15 @@ class GraphResolutionConfigurator

class Ipu8FragmentsConfigurator;

class SmurfKernelInfo
{
public:
StaticGraphRunKernel* _smurfRunKernel;
StaticGraphRunKernel* _deviceRunKernel;
StaticGraphKernelResCrop _originalDeviceCropHistory = { 0,0,0,0 };
StaticGraphKernelResCrop _originalSmurfOutputCrop = { 0,0,0,0 };
};

class Ipu8GraphResolutionConfigurator : public GraphResolutionConfigurator
{
public:
Expand All @@ -191,6 +204,7 @@ class Ipu8GraphResolutionConfigurator : public GraphResolutionConfigurator
StaticGraphStatus initRunKernel(uint32_t kernelUuid, StaticGraphRunKernel*& runKernel);
StaticGraphStatus initOutputRunKernel();
StaticGraphStatus initKernelsForUpdate();
StaticGraphStatus initIsFragments();

// Calculate ROI in dimensions of pipe downscaler input.
StaticGraphStatus getDownscalerInputRoi(const RegionOfInterest& userRoi, ResolutionRoi& pipeInputRoi);
Expand All @@ -201,7 +215,7 @@ class Ipu8GraphResolutionConfigurator : public GraphResolutionConfigurator
StaticGraphStatus updateRunKernelUpScaler(StaticGraphRunKernel* runKernel, ResolutionRoi& roi, StaticGraphKernelResCrop& cropperKernelCrop, uint32_t outputWidth, uint32_t outputHeight);
StaticGraphStatus updateRunKernelCropper(StaticGraphRunKernel* runKernel, ResolutionRoi& roi, uint32_t inputWidth, uint32_t inputHeight,
uint32_t outputWidth, uint32_t outputHeight, StaticGraphKernelResCrop& downscalerCropHist);
StaticGraphStatus updateRunKernelSmurf(StaticGraphRunKernel* smurfRunKernel, StaticGraphRunKernel* deviceRunKernel);
StaticGraphStatus updateRunKernelSmurf(SmurfKernelInfo* smurfInfo);

StaticGraphStatus SanityCheck();
StaticGraphStatus SanityCheckCrop(StaticGraphKernelResCrop* crop);
Expand All @@ -220,9 +234,10 @@ class Ipu8GraphResolutionConfigurator : public GraphResolutionConfigurator
StaticGraphRunKernel* _outputRunKernel;
std::vector<StaticGraphRunKernel*> _kernelsForUpdateAfterCropper;
std::vector<StaticGraphRunKernel*> _kernelsForUpdateAfterUpscaler;
std::vector<std::pair<StaticGraphRunKernel*, StaticGraphRunKernel*>> _smurfKernels;
std::vector<SmurfKernelInfo*> _smurfKernels;

// For striping
OuterNode* _node = nullptr;
Ipu8FragmentsConfigurator* _fragmentsConfigurator = nullptr;
bool _isFragments = false;
};
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,8 @@ uint32_t GraphResolutionConfiguratorHelper::getRunKernelIoBufferSystemApiUuid()
return 47358;
}

uint32_t GraphResolutionConfiguratorHelper::getRunKernelDownscalerSystemApiUuid()
{
return 2102;
}

Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ class GraphResolutionConfiguratorHelper
static uint32_t getRunKernelUuidOfOutput(HwSink hwSink, int32_t graphId, GraphLink** links);
static StaticGraphStatus getRunKernelUuidForResHistoryUpdate(std::vector<uint32_t>& kernelUuids);
static uint32_t getRunKernelIoBufferSystemApiUuid();
static uint32_t getRunKernelDownscalerSystemApiUuid();
static GraphResolutionConfiguratorKernelRole getKernelRole(uint32_t kernelUuid);
};
Loading