1 /* Copyright (c) 2022, Intel Corporation 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a 4 * copy of this software and associated documentation files (the "Software"), 5 * to deal in the Software without restriction, including without limitation 6 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 * and/or sell copies of the Software, and to permit persons to whom the 8 * Software is furnished to do so, subject to the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included 11 * in all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 17 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19 * OTHER DEALINGS IN THE SOFTWARE. 20 */ 21 //! 22 //! \file vp_render_sfc_base_legacy.h 23 //! \brief The header file of the base class of SFC rendering component 24 //! \details The SFC renderer supports Scaling, IEF, CSC/ColorFill and Rotation. 25 //! It's responsible for setting up HW states and generating the SFC 26 //! commands. 27 //! 28 29 #ifndef __VP_RENDER_SFC_BASE_LEGACY_H__ 30 #define __VP_RENDER_SFC_BASE_LEGACY_H__ 31 32 #include "vp_render_sfc_base.h" 33 #include "mhw_sfc_g12_X.h" 34 35 namespace vp { 36 37 class VpIef; 38 39 class SfcRenderBaseLegacy : public SfcRenderBase 40 { 41 42 public: 43 SfcRenderBaseLegacy(VP_MHWINTERFACE &vpMhwinterface, PVpAllocator &allocator, bool disbaleSfcDithering); 44 virtual ~SfcRenderBaseLegacy(); 45 46 //! 47 //! \brief Initialize the object 48 //! \return MOS_STATUS 49 //! 50 virtual MOS_STATUS Init() override; 51 52 virtual MOS_STATUS Init(VIDEO_PARAMS &videoParams) override; 53 54 //! 55 //! \brief Setup CSC parameters of the SFC State 56 //! \param [in,out] pSfcStateParams 57 //! Pointer to SFC_STATE params 58 //! \param [out] pIEFStateParams 59 //! Pointer to MHW IEF state params 60 //! \return void 61 //! 62 virtual MOS_STATUS SetIefStateCscParams( 63 PMHW_SFC_STATE_PARAMS sfcStateParams, 64 PMHW_SFC_IEF_STATE_PARAMS pIEFStateParams); 65 66 //! 67 //! \brief Setup parameters related to SFC_IEF State 68 //! \details Setup the IEF and CSC params of the SFC_IEF State 69 //! \param [in,out] sfcStateParams 70 //! Pointer to SFC_STATE params 71 //! \param [in] inputSurface 72 //! Pointer to Input Surface 73 //! \return void 74 //! 75 virtual MOS_STATUS SetIefStateParams( 76 PMHW_SFC_STATE_PARAMS sfcStateParams); 77 78 //! 79 //! \brief Setup parameters related to SFC_AVS State 80 //! \details Setup the 8x8 table of SFC sampler 81 //! \return MOS_STATUS 82 //! 83 virtual MOS_STATUS SetAvsStateParams() override; 84 85 //! 86 //! \brief Send SFC pipe commands 87 //! \details Register the surfaces and send the commands needed by SFC pipe 88 //! \param [in] pRenderData 89 //! Pointer to Vebox Render data 90 //! \param [in,out] pCmdBuffer 91 //! Pointer to command buffer 92 //! \return MOS_STATUS_SUCCESS if successful, otherwise failed 93 //! 94 virtual MOS_STATUS SendSfcCmd( 95 bool bOutputToMemory, 96 PMOS_COMMAND_BUFFER pCmdBuffer) override; 97 98 //! 99 //! \brief Setup SFC states and parameters 100 //! \details Setup SFC states and parameters including SFC State, AVS 101 //! and IEF parameters 102 //! \param [in] targetSurface 103 //! Pointer to Output Surface 104 //! \return Return MOS_STATUS_SUCCESS if successful, otherwise failed 105 //! 106 virtual MOS_STATUS SetupSfcState(PVP_SURFACE targetSurface) override; 107 108 //! 109 //! \brief check whether SFC Write have offset which may hit compresed write limitation 110 //! \details check whether SFC Write have offset which may hit compresed write limitation 111 //! \param [in] targetSurface 112 //! Pointer to targetSurface 113 //! \return the output pipe compression state 114 //! 115 virtual bool IsSFCUncompressedWriteNeeded(PVP_SURFACE targetSurface) override; 116 117 //! 118 //! \brief Set scaling parameters 119 //! \details Set scaling parameters 120 //! \param [in] scalingParams 121 //! Scaling parameters 122 //! \return MOS_STATUS_SUCCESS if successful, otherwise failed 123 //! 124 virtual MOS_STATUS SetScalingParams(PSFC_SCALING_PARAMS scalingParams) override; 125 126 //! 127 //! \brief Set csc parameters 128 //! \details Set csc parameters 129 //! \param [in] cscParams 130 //! Csc parameters 131 //! \return MOS_STATUS_SUCCESS if successful, otherwise failed 132 //! 133 virtual MOS_STATUS SetCSCParams(PSFC_CSC_PARAMS cscParams) override; 134 135 //! 136 //! \brief Set rotation and mirror parameters 137 //! \details Set rotation and mirror parameters 138 //! \param [in] rotMirParams 139 //! rotation and mirror parameters 140 //! \return MOS_STATUS_SUCCESS if successful, otherwise failed 141 //! 142 virtual MOS_STATUS SetRotMirParams(PSFC_ROT_MIR_PARAMS rotMirParams) override; 143 144 //! 145 //! \brief Set mmc parameters 146 //! \details Set mmc parameters 147 //! \param [in] renderTarget 148 //! render target surface 149 //! \param [in] isFormalMmcSupported 150 //! Is format supported by mmc 151 //! \param [in] isMmcEnabled 152 //! Is mmc enabled 153 //! \return MOS_STATUS_SUCCESS if successful, otherwise failed 154 //! 155 virtual MOS_STATUS SetMmcParams(PMOS_SURFACE renderTarget, bool isFormatMmcSupported, bool isMmcEnabled) override; 156 157 virtual MOS_STATUS UpdateIefParams(PVPHAL_IEF_PARAMS iefParams) override; 158 virtual MOS_STATUS UpdateCscParams(FeatureParamCsc &cscParams) override; 159 IsCSC()160 bool IsCSC() { return m_renderDataLegacy.bCSC; } IsScaling()161 bool IsScaling() { return m_renderDataLegacy.bScaling; } 162 163 //! 164 //! \brief Get Sfc's input format 165 //! \return MOS_FORMAT 166 //! GetInputFormat()167 MOS_FORMAT GetInputFormat() 168 { 169 return m_renderDataLegacy.SfcInputFormat; 170 } 171 GetIefParams()172 PVPHAL_IEF_PARAMS GetIefParams() 173 { 174 return m_renderDataLegacy.pIefParams; 175 } 176 177 protected: 178 179 //! 180 //! \brief Set SFC input chroma subsampling 181 //! \details Set SFC input chroma subsampling according to 182 //! pipe mode 183 //! \param [out] sfcStateParams 184 //! Pointer to SFC state params 185 //! \return MOS_STATUS 186 //! 187 virtual MOS_STATUS SetSfcStateInputChromaSubSampling( 188 PMHW_SFC_STATE_PARAMS sfcStateParams); 189 190 //! 191 //! \brief Set SFC input ordering mode 192 //! \details SFC input ordering mode according to 193 //! pipe mode 194 //! \param [out] sfcStateParams 195 //! Pointer to SFC state params 196 //! \return MOS_STATUS 197 //! 198 virtual MOS_STATUS SetSfcStateInputOrderingMode( 199 PMHW_SFC_STATE_PARAMS sfcStateParams); 200 virtual MOS_STATUS SetSfcStateInputOrderingModeJpeg( 201 PMHW_SFC_STATE_PARAMS sfcStateParams); 202 virtual MOS_STATUS SetSfcStateInputOrderingModeVdbox( 203 PMHW_SFC_STATE_PARAMS sfcStateParams); 204 virtual MOS_STATUS SetSfcStateInputOrderingModeHcp( 205 PMHW_SFC_STATE_PARAMS sfcStateParams) = 0; 206 207 //! 208 //! \brief Setup ColorFill parameters 209 //! \details Setup ColorFill parameters 210 //! \param [in] sfcStateParams 211 //! Pointer to SFC_STATE params 212 //! \return void 213 void SetColorFillParams( 214 PMHW_SFC_STATE_PARAMS pSfcStateParams); 215 216 //! 217 //! \brief Setup Rotation and Mirrow params 218 //! \details Setup Rotation and Mirrow params 219 //! \param [in,out] sfcStateParams 220 //! Pointer to SFC_STATE params 221 //! \return void 222 //! 223 void SetRotationAndMirrowParams( 224 PMHW_SFC_STATE_PARAMS pSfcStateParams); 225 226 //! 227 //! \brief Setup Chromasting params 228 //! \details Setup Chromasting params 229 //! \param [in,out] sfcStateParams 230 //! Pointer to SFC_STATE params 231 //! \return void 232 //! 233 void SetChromasitingParams( 234 PMHW_SFC_STATE_PARAMS pSfcStateParams); 235 236 //! 237 //! \brief Setup Bypass X & Y AdaptiveFilter params 238 //! \details Setup Bypass X & Y AdaptiveFilter params 239 //! \param [in,out] sfcStateParams 240 //! Pointer to SFC_STATE params 241 //! \return void 242 //! 243 void SetXYAdaptiveFilter( 244 PMHW_SFC_STATE_PARAMS pSfcStateParams); 245 246 //! 247 //! \brief Setup RGB Adaptive params 248 //! \details Setup RGB Adaptive params 249 //! \param [in,out] sfcStateParams 250 //! Pointer to SFC_STATE params 251 //! \return void 252 //! 253 void SetRGBAdaptive( 254 PMHW_SFC_STATE_PARAMS pSfcStateParams); 255 256 //! 257 //! \brief Get Avs line buffer size 258 //! \details Get Avs line buffer size according to height of input surface 259 //! \param [in] lineTiledBuffer 260 //! ture if avs line tile buffer, otherwise, avs line buffer. 261 //! \param [in] b8tapChromafiltering 262 //! ture if 8-tap UV, otherwise, 4-tap UV. 263 //! \param [in] width 264 //! The width of input surface 265 //! \param [in] height 266 //! The height of input surface 267 //! \return uint32_t 268 //! 269 uint32_t GetAvsLineBufferSize(bool lineTiledBuffer, bool b8tapChromafiltering, uint32_t width, uint32_t height); 270 271 //! 272 //! \brief Get Ief line buffer size 273 //! \details Get Ief line buffer size according to height of scaled surface 274 //! \param [in] lineTiledBuffer 275 //! ture if ief line tile buffer, otherwise, ief line buffer. 276 //! \param [in] heightOutput 277 //! The height of output surface 278 //! \return uint32_t 279 //! 280 uint32_t GetIefLineBufferSize(bool lineTiledBuffer, uint32_t heightOutput); 281 282 //! 283 //! \brief Get Sfd line buffer size 284 //! \details Get Sfd line buffer size according to height of scaled surface 285 //! \param [in] lineTiledBuffer 286 //! ture if sdf line tile buffer, otherwise, sdf line buffer. 287 //! \param [in] formatOutput 288 //! format of output surface. 289 //! \param [in] widthOutput 290 //! The width of input surface 291 //! \param [in] heightOutput 292 //! The height of input surface 293 //! \return uint32_t 294 //! 295 virtual uint32_t GetSfdLineBufferSize(bool lineTiledBuffer, MOS_FORMAT formatOutput, uint32_t widthOutput, uint32_t heightOutput) override; 296 297 //! 298 //! \brief Allocate Resources for SFC Pipe 299 //! \details Allocate the AVS and IEF line buffer surfaces for SFC 300 //! \return Return MOS_STATUS_SUCCESS if successful, otherwise failed 301 //! 302 virtual MOS_STATUS AllocateResources() override; 303 304 virtual MOS_STATUS AddSfcLock( 305 PMOS_COMMAND_BUFFER pCmdBuffer, 306 PMHW_SFC_LOCK_PARAMS pSfcLockParams); 307 308 virtual MOS_STATUS AddSfcState( 309 PMOS_COMMAND_BUFFER pCmdBuffer, 310 PMHW_SFC_STATE_PARAMS pSfcState, 311 PMHW_SFC_OUT_SURFACE_PARAMS pOutSurface); 312 313 virtual MOS_STATUS AddSfcAvsState( 314 PMOS_COMMAND_BUFFER pCmdBuffer, 315 PMHW_SFC_AVS_STATE pSfcAvsStateParams); 316 317 virtual MOS_STATUS AddSfcIefState( 318 PMOS_COMMAND_BUFFER pCmdBuffer, 319 PMHW_SFC_IEF_STATE_PARAMS pSfcIefStateParams); 320 321 virtual MOS_STATUS AddSfcAvsLumaTable( 322 PMOS_COMMAND_BUFFER pCmdBuffer, 323 PMHW_SFC_AVS_LUMA_TABLE pLumaTable); 324 325 virtual MOS_STATUS AddSfcAvsChromaTable( 326 PMOS_COMMAND_BUFFER pCmdBuffer, 327 PMHW_SFC_AVS_CHROMA_TABLE pChromaTable); 328 329 virtual MOS_STATUS AddSfcFrameStart( 330 PMOS_COMMAND_BUFFER pCmdBuffer, 331 uint8_t sfcPipeMode) override; 332 333 virtual MOS_STATUS SetSfcAVSScalingMode( 334 MHW_SCALING_MODE ScalingMode) override; 335 336 virtual MOS_STATUS SetSfcSamplerTable( 337 PMHW_SFC_AVS_LUMA_TABLE pLumaTable, 338 PMHW_SFC_AVS_CHROMA_TABLE pChromaTable, 339 PMHW_AVS_PARAMS pAvsParams, 340 MOS_FORMAT SrcFormat, 341 float fScaleX, 342 float fScaleY, 343 uint32_t dwChromaSiting, 344 bool bUse8x8Filter, 345 float fHPStrength, 346 float fLanczosT); 347 348 protected: 349 350 PMHW_SFC_STATE_PARAMS m_sfcStateParamsLegacy = nullptr; //!< Pointer to sfc state parameters 351 352 MHW_SFC_IEF_STATE_PARAMS m_IefStateParamsLegacy = {}; //!< IEF Params state 353 // HW intface to access MHW 354 PMHW_SFC_INTERFACE m_sfcInterface = nullptr; 355 PMHW_MI_INTERFACE m_miInterface = nullptr; 356 357 VP_SFC_RENDER_DATA_LEGACY m_renderDataLegacy = {}; //!< Transient Render data populated for every BLT call 358 VPHAL_SFC_AVS_STATE_LEGACY m_avsStateLegacy = {}; //!< AVS State and Coeff. table 359 360 MEDIA_CLASS_DEFINE_END(vp__SfcRenderBaseLegacy) 361 }; 362 363 } 364 #endif // !__VP_RENDER_SFC_BASE_LEGACY_H__ 365