| 1 |
/* |
| 2 |
* Copyright (c) 2019-2023, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
|
| 23 |
//! |
| 24 |
//! \file policy.h |
| 25 |
//! \brief Defines the common interface for vp features manager |
| 26 |
//! \details The policy is further sub-divided by vp type |
| 27 |
//! this file is for the base interface which is shared by all components. |
| 28 |
//! |
| 29 |
#ifndef __POLICY_H__ |
| 30 |
#define __POLICY_H__ |
| 31 |
|
| 32 |
#include "media_feature_manager.h" |
| 33 |
#include "vp_utils.h" |
| 34 |
#include "vp_pipeline_common.h" |
| 35 |
#include "vp_allocator.h" |
| 36 |
#include "vp_feature_caps.h" |
| 37 |
|
| 38 |
#include "hw_filter.h" |
| 39 |
#include "sw_filter_pipe.h" |
| 40 |
#include "vp_resource_manager.h" |
| 41 |
#include <map> |
| 42 |
|
| 43 |
namespace vp |
| 44 |
{ |
| 45 |
#define ENGINE_MUST_MASK(supported) (supported & 0x02) |
| 46 |
#define ENGINE_SUPPORT_MASK(supported) (supported & 0x3) |
| 47 |
#define ENGINE_MUST(supported) (supported << 1) |
| 48 |
#define FEATURE_TYPE_EXECUTE(feature, engine) FeatureType##feature##On##engine |
| 49 |
|
| 50 |
class VpInterface; |
| 51 |
|
| 52 |
class Policy |
| 53 |
{ |
| 54 |
public: |
| 55 |
Policy(VpInterface &vpInterface); |
| 56 |
virtual ~Policy(); |
| 57 |
MOS_STATUS CreateHwFilter(SwFilterPipe &subSwFilterPipe, HwFilter *&pFilter); |
| 58 |
MOS_STATUS Initialize(); |
| 59 |
//! |
| 60 |
//! \brief Check whether VEBOX-SFC Format Supported |
| 61 |
//! \details Check whether VEBOX-SFC Format Supported. |
| 62 |
//! \param inputFormat |
| 63 |
//! [in] Format of Input Frame |
| 64 |
//! \param outputFormat |
| 65 |
//! [in] Format of Output Frame |
| 66 |
//! \return bool |
| 67 |
//! Return true if supported, otherwise failed |
| 68 |
//! |
| 69 |
bool IsVeboxSfcFormatSupported(MOS_FORMAT formatInput, MOS_FORMAT formatOutput); |
| 70 |
|
| 71 |
std::vector<FeatureType> &GetFeatureRegistered() |
| 72 |
{ |
| 73 |
return m_featurePool; |
| 74 |
} |
| 75 |
|
| 76 |
virtual MOS_STATUS UpdateVpHwCapsBasedOnSku(VP_HW_CAPS &vpHwCaps); |
| 77 |
|
| 78 |
protected: |
| 79 |
virtual MOS_STATUS RegisterFeatures(); |
| 80 |
virtual void UnregisterFeatures(); |
| 81 |
virtual MOS_STATUS RegisterFcFeatures(); |
| 82 |
virtual MOS_STATUS GetExecutionCapsForSingleFeature(FeatureType featureType, SwFilterSubPipe& swFilterPipe, VP_EngineEntry& engineCapsCombined); |
| 83 |
virtual MOS_STATUS UpdateExeCaps(SwFilter* feature, VP_EXECUTE_CAPS& caps, EngineType Type); |
| 84 |
virtual MOS_STATUS UpdateCGCMode(SwFilter* feature, VP_EXECUTE_CAPS& caps, EngineType Type); |
| 85 |
virtual MOS_STATUS BuildVeboxSecureFilters(SwFilterPipe& featurePipe, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params); |
| 86 |
virtual MOS_STATUS GetExecutionCapsForAiSwFilterSubPipe(SwFilterAiBase *swAiFilter, VP_EngineEntry &engineCapsCombined); |
| 87 |
|
| 88 |
MOS_STATUS UpdateExecuteEngineCapsForHDR(SwFilterPipe &swFilterPipe, VP_EngineEntry &engineCapsCombinedAllPipes); |
| 89 |
MOS_STATUS UpdateExecuteEngineCapsForCrossPipeFeatures(SwFilterPipe &swFilterPipe, VP_EngineEntry &engineCapsCombinedAllPipes); |
| 90 |
MOS_STATUS BuildExecutionEngines(SwFilterPipe &swFilterPipe, bool isInputPipe, uint32_t index, bool isAiPipe, VP_EngineEntry &engineCapsCombinedAllPipes); |
| 91 |
MOS_STATUS GetHwFilterParam(SwFilterPipe& subSwFilterPipe, HW_FILTER_PARAMS& params); |
| 92 |
MOS_STATUS ReleaseHwFilterParam(HW_FILTER_PARAMS ¶ms); |
| 93 |
MOS_STATUS InitExecuteCaps(VP_EXECUTE_CAPS &caps, VP_EngineEntry &engineCapsInputPipe, VP_EngineEntry &engineCapsOutputPipe); |
| 94 |
MOS_STATUS GetExecuteCaps(SwFilterPipe& subSwFilterPipe, HW_FILTER_PARAMS& params); |
| 95 |
MOS_STATUS Update3DLutoutputColorAndFormat(FeatureParamCsc *cscParams, FeatureParamHdr *hdrParams, MOS_FORMAT Format, VPHAL_CSPACE CSpace); |
| 96 |
MOS_STATUS GetCSCExecutionCapsHdr(SwFilter *hdr, SwFilter *csc); |
| 97 |
MOS_STATUS GetCSCExecutionCapsDi(SwFilter* feature); |
| 98 |
MOS_STATUS GetCSCExecutionCapsBT2020ToRGB(SwFilter *cgc, SwFilter *csc); |
| 99 |
MOS_STATUS GetCSCExecutionCaps(SwFilter* feature, bool isCamPipeWithBayerInput); |
| 100 |
bool IsSfcSupported(MOS_FORMAT format); |
| 101 |
MOS_STATUS GetScalingExecutionCaps(SwFilter* feature, bool isDIEnabled); |
| 102 |
MOS_STATUS GetScalingExecutionCaps(SwFilter *feature, bool isHdrEnabled, bool isDIEnabled); |
| 103 |
MOS_STATUS GetScalingExecutionCapsHdr(SwFilter *feature); |
| 104 |
bool IsSfcRotationSupported(FeatureParamRotMir *rotationParams); |
| 105 |
MOS_STATUS GetRotationExecutionCaps(SwFilter* feature); |
| 106 |
virtual MOS_STATUS GetDenoiseExecutionCaps(SwFilter* feature); |
| 107 |
MOS_STATUS GetSteExecutionCaps(SwFilter* feature); |
| 108 |
MOS_STATUS GetTccExecutionCaps(SwFilter* feature); |
| 109 |
MOS_STATUS GetProcampExecutionCaps(SwFilter* feature); |
| 110 |
MOS_STATUS GetHdrExecutionCaps(SwFilter *feature); |
| 111 |
MOS_STATUS GetExecutionCaps(SwFilter* feature); |
| 112 |
MOS_STATUS GetDeinterlaceExecutionCaps(SwFilter* feature, bool is2PassScalingNeeded); |
| 113 |
MOS_STATUS GetColorFillExecutionCaps(SwFilter* feature); |
| 114 |
MOS_STATUS GetAlphaExecutionCaps(SwFilter* feature); |
| 115 |
MOS_STATUS GetLumakeyExecutionCaps(SwFilter* feature); |
| 116 |
MOS_STATUS GetBlendingExecutionCaps(SwFilter* feature); |
| 117 |
MOS_STATUS GetCgcExecutionCaps(SwFilter* feature); |
| 118 |
|
| 119 |
MOS_STATUS BuildExecuteCaps(SwFilterPipe& featurePipe, VP_EXECUTE_CAPS &caps, VP_EngineEntry &engineCapsInputPipe, VP_EngineEntry &engineCapsOutputPipe, |
| 120 |
bool &isSingleSubPipe, uint32_t &selectedPipeIndex); |
| 121 |
MOS_STATUS BypassVeboxFeatures(SwFilterSubPipe *featureSubPipe, VP_EngineEntry &engineCaps); |
| 122 |
MOS_STATUS GetInputPipeEngineCaps(SwFilterPipe& featurePipe, VP_EngineEntry &engineCapsInputPipe, |
| 123 |
SwFilterSubPipe *&singlePipeSelected, bool &isSingleSubPipe, uint32_t &selectedPipeIndex); |
| 124 |
|
| 125 |
// inputPipeSelected != nullptr for single input pipe case, otherwise, it's multi-input pipe case. |
| 126 |
MOS_STATUS GetOutputPipeEngineCaps(SwFilterPipe& featurePipe, VP_EngineEntry &engineCaps, SwFilterSubPipe *inputPipeSelected); |
| 127 |
|
| 128 |
MOS_STATUS UpdateFeatureTypeWithEngine(std::vector<int> &layerIndexes, SwFilterPipe& featurePipe, VP_EXECUTE_CAPS& caps, |
| 129 |
bool isolatedFeatureSelected, bool outputPipeNeeded); |
| 130 |
MOS_STATUS UpdateFeatureTypeWithEngineSingleLayer(SwFilterSubPipe *featureSubPipe, VP_EXECUTE_CAPS& caps, bool isolatedFeatureSelected); |
| 131 |
virtual MOS_STATUS LayerSelectForProcess(std::vector<int> &layerIndexes, SwFilterPipe& featurePipe, bool isSingleSubPipe, uint32_t pipeIndex, VP_EXECUTE_CAPS& caps); |
| 132 |
|
| 133 |
MOS_STATUS UpdateFeaturePipe(SwFilterPipe &featurePipe, uint32_t pipeIndex, SwFilterPipe &executedFilters, uint32_t executePipeIndex, |
| 134 |
bool isInputPipe, VP_EXECUTE_CAPS& caps); |
| 135 |
|
| 136 |
MOS_STATUS UpdateFeaturePipeSingleLayer(SwFilterPipe &featurePipe, uint32_t pipeIndex, SwFilterPipe &executedFilters, uint32_t executePipeIndex, VP_EXECUTE_CAPS& caps); |
| 137 |
MOS_STATUS UpdateFeatureOutputPipe(std::vector<int> &layerIndexes, SwFilterPipe &featurePipe, SwFilterPipe &executedFilters, VP_EXECUTE_CAPS& caps); |
| 138 |
MOS_STATUS BuildFilters(SwFilterPipe& subSwFilterPipe, HW_FILTER_PARAMS& params); |
| 139 |
MOS_STATUS BuildExecuteFilter(SwFilterPipe& swFilterPipe, std::vector<int> &layerIndexes, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params); |
| 140 |
MOS_STATUS BuildExecuteHwFilter(VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params); |
| 141 |
MOS_STATUS SetupExecuteFilter(SwFilterPipe& featurePipe, std::vector<int> &layerIndexes, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params); |
| 142 |
MOS_STATUS SetupFilterResource(SwFilterPipe& featurePipe, std::vector<int> &layerIndexes, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params); |
| 143 |
MOS_STATUS AddInputSurfaceForSingleLayer(SwFilterPipe &featurePipe, uint32_t pipeIndex, SwFilterPipe &executedFilters, uint32_t &executePipeIndex, VP_EXECUTE_CAPS &caps); |
| 144 |
|
| 145 |
bool IsDemosaicValidOutputFormat(MOS_FORMAT format); |
| 146 |
bool IsAlphaSettingSupportedBySfc(MOS_FORMAT formatInput, MOS_FORMAT formatOutput, PVPHAL_ALPHA_PARAMS compAlpha); |
| 147 |
bool IsAlphaSettingSupportedByVebox(MOS_FORMAT formatInput, MOS_FORMAT formatOutput, PVPHAL_ALPHA_PARAMS compAlpha); |
| 148 |
bool IsIsolateFeatureOutputPipeNeeded(SwFilterSubPipe *featureSubPipe, SwFilter *swFilter); |
| 149 |
|
| 150 |
virtual MOS_STATUS AddFiltersBasedOnCaps( |
| 151 |
SwFilterPipe& featurePipe, |
| 152 |
uint32_t pipeIndex, |
| 153 |
VP_EXECUTE_CAPS& caps, |
| 154 |
SwFilterPipe& executedFilters, |
| 155 |
uint32_t executedPipeIndex); |
| 156 |
MOS_STATUS AddNewFilterOnVebox( |
| 157 |
SwFilterPipe& featurePipe, |
| 158 |
uint32_t pipeIndex, |
| 159 |
VP_EXECUTE_CAPS& caps, |
| 160 |
SwFilterPipe& executedFilters, |
| 161 |
uint32_t executedPipeIndex, |
| 162 |
FeatureType featureType); |
| 163 |
virtual MOS_STATUS GetCscParamsOnCaps(PVP_SURFACE surfInput, PVP_SURFACE surfOutput, VP_EXECUTE_CAPS &caps, FeatureParamCsc &cscParams); |
| 164 |
virtual MOS_STATUS GetDnParamsOnCaps(PVP_SURFACE surfInput, PVP_SURFACE surfOutput, VP_EXECUTE_CAPS &caps, FeatureParamDenoise &dnParams); |
| 165 |
|
| 166 |
MOS_STATUS AssignExecuteResource(VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params); |
| 167 |
|
| 168 |
virtual bool IsExcludedFeatureForHdr(FeatureType feature); |
| 169 |
|
| 170 |
virtual MOS_STATUS FilterFeatureCombination(SwFilterPipe &pipe, bool isInputPipe, uint32_t index, VP_EngineEntry &engineCapsCombined, VP_EngineEntry &engineCapsCombinedAllPipes); |
| 171 |
virtual MOS_STATUS FilterFeatureCombinationForHDRKernel(SwFilterSubPipe *pipe); |
| 172 |
MOS_STATUS AddCommonFilters(SwFilterSubPipe &swFilterSubPipe, VP_SURFACE *input, VP_SURFACE *outputs); |
| 173 |
|
| 174 |
virtual bool IsVeboxSecurePathEnabled(SwFilterPipe& subSwFilterPipe, VP_EXECUTE_CAPS& caps) |
| 175 |
{ |
| 176 |
return false; |
| 177 |
} |
| 178 |
|
| 179 |
virtual MOS_STATUS UpdateSecureExecuteResource(SwFilterPipe& featurePipe, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params) |
| 180 |
{ |
| 181 |
return MOS_STATUS_SUCCESS; |
| 182 |
} |
| 183 |
|
| 184 |
virtual bool IsSecureResourceNeeded(VP_EXECUTE_CAPS& caps) |
| 185 |
{ |
| 186 |
VP_FUNC_CALL(); |
| 187 |
|
| 188 |
return false; |
| 189 |
} |
| 190 |
virtual bool Is3DLutKernelSupported() |
| 191 |
{ |
| 192 |
return true; |
| 193 |
} |
| 194 |
|
| 195 |
virtual bool IsHDR33LutSizeSupported() |
| 196 |
{ |
| 197 |
return m_hwCaps.m_rules.isHDR33LutSizeEnabled; |
| 198 |
} |
| 199 |
|
| 200 |
std::map<FeatureType, PolicyFeatureHandler*> m_VeboxSfcFeatureHandlers; |
| 201 |
std::map<FeatureType, PolicyFeatureHandler*> m_RenderFeatureHandlers; |
| 202 |
std::map<FeatureType, PolicyFeatureHandler *> m_NpuFeatureHandlers; |
| 203 |
std::vector<FeatureType> m_featurePool; |
| 204 |
|
| 205 |
VpInterface &m_vpInterface; |
| 206 |
VP_HW_CAPS m_hwCaps = {}; |
| 207 |
bool m_initialized = false; |
| 208 |
|
| 209 |
// HDR 3DLut Parameters |
| 210 |
uint32_t m_savedMaxDLL = 1000; |
| 211 |
uint32_t m_savedMaxCLL = 4000; |
| 212 |
VPHAL_HDR_MODE m_savedHdrMode = VPHAL_HDR_MODE_NONE; |
| 213 |
|
| 214 |
//! |
| 215 |
//! \brief Check whether Alpha Supported |
| 216 |
//! \details Check whether Alpha Supported. |
| 217 |
//! \param scalingParams |
| 218 |
//! [in] Params of Scaling |
| 219 |
//! \return bool |
| 220 |
//! Return true if enabled, otherwise failed |
| 221 |
//! |
| 222 |
virtual bool IsColorfillEnabled(FeatureParamScaling *scalingParams); |
| 223 |
//! |
| 224 |
//! \brief Check whether Colorfill Supported |
| 225 |
//! \details Check whether Colorfill Supported. |
| 226 |
//! \param scalingParams |
| 227 |
//! [in] Params of Scaling |
| 228 |
//! \return bool |
| 229 |
//! Return true if enabled, otherwise failed |
| 230 |
//! |
| 231 |
virtual bool IsAlphaEnabled(FeatureParamScaling *scalingParams); |
| 232 |
|
| 233 |
virtual bool IsHDRfilterExist(SwFilterSubPipe *inputPipe) |
| 234 |
{ |
| 235 |
if (inputPipe) |
| 236 |
{ |
| 237 |
SwFilter *feature = (SwFilter *)inputPipe->GetSwFilter(FeatureType(FeatureTypeHdr)); |
| 238 |
return feature != nullptr; |
| 239 |
} |
| 240 |
return false; |
| 241 |
} |
| 242 |
|
| 243 |
void PrintFeatureExecutionCaps(const char *name, VP_EngineEntry &engineCaps); |
| 244 |
|
| 245 |
MEDIA_CLASS_DEFINE_END(vp__Policy) |
| 246 |
}; |
| 247 |
|
| 248 |
} |
| 249 |
#endif // !__POLICY_H__ |