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 GetFeatureRegistered()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 87 MOS_STATUS UpdateExecuteEngineCapsForHDR(SwFilterPipe &swFilterPipe, VP_EngineEntry &engineCapsCombinedAllPipes); 88 MOS_STATUS UpdateExecuteEngineCapsForCrossPipeFeatures(SwFilterPipe &swFilterPipe, VP_EngineEntry &engineCapsCombinedAllPipes); 89 MOS_STATUS BuildExecutionEngines(SwFilterPipe &swFilterPipe, bool isInputPipe, uint32_t index, VP_EngineEntry &engineCapsCombinedAllPipes); 90 MOS_STATUS GetHwFilterParam(SwFilterPipe& subSwFilterPipe, HW_FILTER_PARAMS& params); 91 MOS_STATUS ReleaseHwFilterParam(HW_FILTER_PARAMS ¶ms); 92 MOS_STATUS InitExecuteCaps(VP_EXECUTE_CAPS &caps, VP_EngineEntry &engineCapsInputPipe, VP_EngineEntry &engineCapsOutputPipe); 93 MOS_STATUS GetExecuteCaps(SwFilterPipe& subSwFilterPipe, HW_FILTER_PARAMS& params); 94 MOS_STATUS Update3DLutoutputColorAndFormat(FeatureParamCsc *cscParams, FeatureParamHdr *hdrParams, MOS_FORMAT Format, VPHAL_CSPACE CSpace); 95 MOS_STATUS GetCSCExecutionCapsHdr(SwFilter *hdr, SwFilter *csc); 96 MOS_STATUS GetCSCExecutionCapsDi(SwFilter* feature); 97 MOS_STATUS GetCSCExecutionCapsBT2020ToRGB(SwFilter *cgc, SwFilter *csc); 98 MOS_STATUS GetCSCExecutionCaps(SwFilter* feature, bool isCamPipeWithBayerInput); 99 bool IsSfcSupported(MOS_FORMAT format); 100 MOS_STATUS GetScalingExecutionCaps(SwFilter* feature, bool isDIEnabled); 101 MOS_STATUS GetScalingExecutionCaps(SwFilter *feature, bool isHdrEnabled, bool isDIEnabled); 102 MOS_STATUS GetScalingExecutionCapsHdr(SwFilter *feature); 103 bool IsSfcRotationSupported(FeatureParamRotMir *rotationParams); 104 MOS_STATUS GetRotationExecutionCaps(SwFilter* feature); 105 virtual MOS_STATUS GetDenoiseExecutionCaps(SwFilter* feature); 106 MOS_STATUS GetSteExecutionCaps(SwFilter* feature); 107 MOS_STATUS GetTccExecutionCaps(SwFilter* feature); 108 MOS_STATUS GetProcampExecutionCaps(SwFilter* feature); 109 MOS_STATUS GetHdrExecutionCaps(SwFilter *feature); 110 MOS_STATUS GetExecutionCaps(SwFilter* feature); 111 MOS_STATUS GetDeinterlaceExecutionCaps(SwFilter* feature, bool is2PassScalingNeeded); 112 MOS_STATUS GetColorFillExecutionCaps(SwFilter* feature); 113 MOS_STATUS GetAlphaExecutionCaps(SwFilter* feature); 114 MOS_STATUS GetLumakeyExecutionCaps(SwFilter* feature); 115 MOS_STATUS GetBlendingExecutionCaps(SwFilter* feature); 116 MOS_STATUS GetCgcExecutionCaps(SwFilter* feature); 117 118 MOS_STATUS BuildExecuteCaps(SwFilterPipe& featurePipe, VP_EXECUTE_CAPS &caps, VP_EngineEntry &engineCapsInputPipe, VP_EngineEntry &engineCapsOutputPipe, 119 bool &isSingleSubPipe, uint32_t &selectedPipeIndex); 120 MOS_STATUS BypassVeboxFeatures(SwFilterSubPipe *featureSubPipe, VP_EngineEntry &engineCaps); 121 MOS_STATUS GetInputPipeEngineCaps(SwFilterPipe& featurePipe, VP_EngineEntry &engineCapsInputPipe, 122 SwFilterSubPipe *&singlePipeSelected, bool &isSingleSubPipe, uint32_t &selectedPipeIndex); 123 124 // inputPipeSelected != nullptr for single input pipe case, otherwise, it's multi-input pipe case. 125 MOS_STATUS GetOutputPipeEngineCaps(SwFilterPipe& featurePipe, VP_EngineEntry &engineCaps, SwFilterSubPipe *inputPipeSelected); 126 127 MOS_STATUS UpdateFeatureTypeWithEngine(std::vector<int> &layerIndexes, SwFilterPipe& featurePipe, VP_EXECUTE_CAPS& caps, 128 bool isolatedFeatureSelected, bool outputPipeNeeded); 129 MOS_STATUS UpdateFeatureTypeWithEngineSingleLayer(SwFilterSubPipe *featureSubPipe, VP_EXECUTE_CAPS& caps, bool isolatedFeatureSelected); 130 virtual MOS_STATUS LayerSelectForProcess(std::vector<int> &layerIndexes, SwFilterPipe& featurePipe, bool isSingleSubPipe, uint32_t pipeIndex, VP_EXECUTE_CAPS& caps); 131 132 MOS_STATUS UpdateFeaturePipe(SwFilterPipe &featurePipe, uint32_t pipeIndex, SwFilterPipe &executedFilters, uint32_t executePipeIndex, 133 bool isInputPipe, VP_EXECUTE_CAPS& caps); 134 135 MOS_STATUS UpdateFeaturePipeSingleLayer(SwFilterPipe &featurePipe, uint32_t pipeIndex, SwFilterPipe &executedFilters, uint32_t executePipeIndex, VP_EXECUTE_CAPS& caps); 136 MOS_STATUS UpdateFeatureOutputPipe(std::vector<int> &layerIndexes, SwFilterPipe &featurePipe, SwFilterPipe &executedFilters, VP_EXECUTE_CAPS& caps); 137 MOS_STATUS BuildFilters(SwFilterPipe& subSwFilterPipe, HW_FILTER_PARAMS& params); 138 MOS_STATUS BuildExecuteFilter(SwFilterPipe& swFilterPipe, std::vector<int> &layerIndexes, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params); 139 MOS_STATUS BuildExecuteHwFilter(VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params); 140 MOS_STATUS SetupExecuteFilter(SwFilterPipe& featurePipe, std::vector<int> &layerIndexes, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params); 141 MOS_STATUS SetupFilterResource(SwFilterPipe& featurePipe, std::vector<int> &layerIndexes, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params); 142 143 bool IsDemosaicValidOutputFormat(MOS_FORMAT format); 144 bool IsAlphaSettingSupportedBySfc(MOS_FORMAT formatInput, MOS_FORMAT formatOutput, PVPHAL_ALPHA_PARAMS compAlpha); 145 bool IsAlphaSettingSupportedByVebox(MOS_FORMAT formatInput, MOS_FORMAT formatOutput, PVPHAL_ALPHA_PARAMS compAlpha); 146 bool IsIsolateFeatureOutputPipeNeeded(SwFilterSubPipe *featureSubPipe, SwFilter *swFilter); 147 148 virtual MOS_STATUS AddFiltersBasedOnCaps( 149 SwFilterPipe& featurePipe, 150 uint32_t pipeIndex, 151 VP_EXECUTE_CAPS& caps, 152 SwFilterPipe& executedFilters, 153 uint32_t executedPipeIndex); 154 MOS_STATUS AddNewFilterOnVebox( 155 SwFilterPipe& featurePipe, 156 uint32_t pipeIndex, 157 VP_EXECUTE_CAPS& caps, 158 SwFilterPipe& executedFilters, 159 uint32_t executedPipeIndex, 160 FeatureType featureType); 161 virtual MOS_STATUS GetCscParamsOnCaps(PVP_SURFACE surfInput, PVP_SURFACE surfOutput, VP_EXECUTE_CAPS &caps, FeatureParamCsc &cscParams); 162 virtual MOS_STATUS GetDnParamsOnCaps(PVP_SURFACE surfInput, PVP_SURFACE surfOutput, VP_EXECUTE_CAPS &caps, FeatureParamDenoise &dnParams); 163 164 MOS_STATUS AssignExecuteResource(VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params); 165 166 virtual bool IsExcludedFeatureForHdr(FeatureType feature); 167 168 virtual MOS_STATUS FilterFeatureCombination(SwFilterPipe &pipe, bool isInputPipe, uint32_t index, VP_EngineEntry &engineCapsCombined, VP_EngineEntry &engineCapsCombinedAllPipes); 169 virtual MOS_STATUS FilterFeatureCombinationForHDRKernel(SwFilterSubPipe *pipe); 170 MOS_STATUS AddCommonFilters(SwFilterSubPipe &swFilterSubPipe, VP_SURFACE *input, VP_SURFACE *outputs); 171 IsVeboxSecurePathEnabled(SwFilterPipe & subSwFilterPipe,VP_EXECUTE_CAPS & caps)172 virtual bool IsVeboxSecurePathEnabled(SwFilterPipe& subSwFilterPipe, VP_EXECUTE_CAPS& caps) 173 { 174 return false; 175 } 176 UpdateSecureExecuteResource(SwFilterPipe & featurePipe,VP_EXECUTE_CAPS & caps,HW_FILTER_PARAMS & params)177 virtual MOS_STATUS UpdateSecureExecuteResource(SwFilterPipe& featurePipe, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params) 178 { 179 return MOS_STATUS_SUCCESS; 180 } 181 IsSecureResourceNeeded(VP_EXECUTE_CAPS & caps)182 virtual bool IsSecureResourceNeeded(VP_EXECUTE_CAPS& caps) 183 { 184 VP_FUNC_CALL(); 185 186 return false; 187 } Is3DLutKernelSupported()188 virtual bool Is3DLutKernelSupported() 189 { 190 return true; 191 } 192 IsHDR33LutSizeSupported()193 virtual bool IsHDR33LutSizeSupported() 194 { 195 return m_hwCaps.m_rules.isHDR33LutSizeEnabled; 196 } 197 198 std::map<FeatureType, PolicyFeatureHandler*> m_VeboxSfcFeatureHandlers; 199 std::map<FeatureType, PolicyFeatureHandler*> m_RenderFeatureHandlers; 200 std::vector<FeatureType> m_featurePool; 201 202 VpInterface &m_vpInterface; 203 VP_HW_CAPS m_hwCaps = {}; 204 bool m_initialized = false; 205 206 // HDR 3DLut Parameters 207 uint32_t m_savedMaxDLL = 1000; 208 uint32_t m_savedMaxCLL = 4000; 209 VPHAL_HDR_MODE m_savedHdrMode = VPHAL_HDR_MODE_NONE; 210 211 //! 212 //! \brief Check whether Alpha Supported 213 //! \details Check whether Alpha Supported. 214 //! \param scalingParams 215 //! [in] Params of Scaling 216 //! \return bool 217 //! Return true if enabled, otherwise failed 218 //! 219 virtual bool IsColorfillEnabled(FeatureParamScaling *scalingParams); 220 //! 221 //! \brief Check whether Colorfill Supported 222 //! \details Check whether Colorfill Supported. 223 //! \param scalingParams 224 //! [in] Params of Scaling 225 //! \return bool 226 //! Return true if enabled, otherwise failed 227 //! 228 virtual bool IsAlphaEnabled(FeatureParamScaling *scalingParams); 229 IsHDRfilterExist(SwFilterSubPipe * inputPipe)230 virtual bool IsHDRfilterExist(SwFilterSubPipe *inputPipe) 231 { 232 if (inputPipe) 233 { 234 SwFilter *feature = (SwFilter *)inputPipe->GetSwFilter(FeatureType(FeatureTypeHdr)); 235 return feature != nullptr; 236 } 237 return false; 238 } 239 240 void PrintFeatureExecutionCaps(const char *name, VP_EngineEntry &engineCaps); 241 242 MEDIA_CLASS_DEFINE_END(vp__Policy) 243 }; 244 245 } 246 #endif // !__POLICY_H__