1 /* 2 * Copyright (c) 2015-2020, 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 //! \file mhw_vebox_g12_X.h 24 //! \brief Defines functions for constructing vebox commands on Gen12-based platforms 25 26 #ifndef __MHW_VEBOX_G12_X_H__ 27 #define __MHW_VEBOX_G12_X_H__ 28 29 #include "mhw_vebox_generic.h" 30 #include "mhw_vebox_hwcmd_g12_X.h" 31 #include "renderhal_legacy.h" 32 33 #define MHW_VEBOX_TIMESTAMP_PER_TICK_IN_NS_G12 83.333f 34 35 #define MHW_LACE_COLOR_COMPENSATION_LUT_POINT_NUMBER 16 36 37 #define MHW_VEBOX_SLIM_IPU_DN_CMD_SIZE_INUSE 34 38 39 typedef struct _MHW_LACE_COLOR_WEIGHT_LUT 40 { 41 int32_t iPoint[MHW_LACE_COLOR_COMPENSATION_LUT_POINT_NUMBER]; // U5.3 42 int32_t iBias[MHW_LACE_COLOR_COMPENSATION_LUT_POINT_NUMBER]; // U5.8 43 int32_t iSlope[MHW_LACE_COLOR_COMPENSATION_LUT_POINT_NUMBER]; // U1.10 44 } MHW_LACE_COLOR_WEIGHT_LUT; 45 46 typedef struct _MHW_LACE_COLOR_CORRECTION 47 { 48 bool bColorCorrectionEnable; // Color correction enable from Gen12; 49 bool bYUVFullRange; // Color correction need YUV offset from Gen12 50 float fColorCompensationPowerFactor; // Color Compensation Power Factor from Gen12 51 MHW_LACE_COLOR_WEIGHT_LUT colorWeightLut; 52 } MHW_LACE_COLOR_CORRECTION; 53 54 #if (_DEBUG || _RELEASE_INTERNAL) 55 #define MHW_VEBOX_IS_VEBOX_SPECIFIED_IN_CONFIG(keyval, VDId, shift, mask, bUseVD) \ 56 do\ 57 {\ 58 int32_t TmpVal = keyval;\ 59 while (TmpVal != 0) \ 60 {\ 61 if (((TmpVal) & (mask)) == (VDId))\ 62 {\ 63 bUseVD = true;\ 64 break;\ 65 }\ 66 TmpVal >>= (shift);\ 67 };\ 68 }while(0) 69 #endif 70 71 const MHW_VEBOX_SETTINGS g_Vebox_Settings_g12 = 72 { 73 MHW_MAX_VEBOX_STATES, //!< uiNumInstances 74 MHW_SYNC_SIZE, //!< uiSyncSize 75 MHW_PAGE_SIZE, //!< uiDndiStateSize 76 MHW_PAGE_SIZE, //!< uiIecpStateSize 77 MHW_PAGE_SIZE * 2, //!< uiGamutStateSize 78 MHW_PAGE_SIZE, //!< uiVertexTableSize 79 MHW_PAGE_SIZE, //!< uiCapturePipeStateSize 80 MHW_PAGE_SIZE * 2, //!< uiGammaCorrectionStateSize 81 MHW_PAGE_SIZE * 18, //!< uiHdrStateSize 82 }; 83 84 class MhwVeboxInterfaceG12 : public MhwVeboxInterfaceGeneric<mhw_vebox_g12_X> 85 { 86 public: 87 // Chroma parameters 88 typedef struct _MHW_VEBOX_CHROMA_PARAMS 89 { 90 uint32_t dwPixRangeThresholdChromaU[MHW_PIXRANGETHRES_NUM]; 91 uint32_t dwPixRangeWeightChromaU[MHW_PIXRANGETHRES_NUM]; 92 uint32_t dwPixRangeThresholdChromaV[MHW_PIXRANGETHRES_NUM]; 93 uint32_t dwPixRangeWeightChromaV[MHW_PIXRANGETHRES_NUM]; 94 uint32_t dwHotPixelThresholdChromaU; 95 uint32_t dwHotPixelCountChromaU; 96 uint32_t dwHotPixelThresholdChromaV; 97 uint32_t dwHotPixelCountChromaV; 98 }MHW_VEBOX_CHROMA_PARAMS; 99 100 MhwVeboxInterfaceG12( 101 PMOS_INTERFACE pInputInterface); 102 ~MhwVeboxInterfaceG12()103 virtual ~MhwVeboxInterfaceG12() { MHW_FUNCTION_ENTER; } 104 105 MOS_STATUS VeboxAdjustBoundary( 106 PMHW_VEBOX_SURFACE_PARAMS pSurfaceParam, 107 uint32_t *pdwSurfaceWidth, 108 uint32_t *pdwSurfaceHeight, 109 bool bDIEnable); 110 111 MOS_STATUS AddVeboxState( 112 PMOS_COMMAND_BUFFER pCmdBuffer, 113 PMHW_VEBOX_STATE_CMD_PARAMS pVeboxStateCmdParams, 114 bool bUseCmBuffer); 115 116 MOS_STATUS AddVeboxDiIecp( 117 PMOS_COMMAND_BUFFER pCmdBuffer, 118 PMHW_VEBOX_DI_IECP_CMD_PARAMS pVeboxDiIecpCmdParams); 119 120 MOS_STATUS AddVeboxDndiState( 121 PMHW_VEBOX_DNDI_PARAMS pVeboxDndiParams); 122 123 MOS_STATUS AddVeboxIecpState( 124 PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams); 125 126 MOS_STATUS AddVeboxGamutState( 127 PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams, 128 PMHW_VEBOX_GAMUT_PARAMS pVeboxGamutParams); 129 130 MOS_STATUS AddVeboxHdrState( 131 PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams); 132 133 MOS_STATUS FindVeboxGpuNodeToUse( 134 PMHW_VEBOX_GPUNODE_LIMIT pGpuNodeLimit); 135 136 MOS_STATUS AddVeboxIecpAceState( 137 PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams); 138 SetVeboxIecpStateSTE(mhw_vebox_g12_X::VEBOX_STD_STE_STATE_CMD * pVeboxStdSteState,PMHW_COLORPIPE_PARAMS pColorPipeParams)139 MOS_STATUS SetVeboxIecpStateSTE( 140 mhw_vebox_g12_X::VEBOX_STD_STE_STATE_CMD *pVeboxStdSteState, 141 PMHW_COLORPIPE_PARAMS pColorPipeParams) 142 { 143 MOS_STATUS eStatus = MOS_STATUS_SUCCESS; 144 145 MHW_FUNCTION_ENTER; 146 147 MHW_CHK_NULL(pVeboxStdSteState); 148 MHW_CHK_NULL(pColorPipeParams); 149 150 MhwVeboxInterfaceGeneric<mhw_vebox_g12_X>::SetVeboxIecpStateSTE(pVeboxStdSteState, pColorPipeParams); 151 // Enable Skin Score Output surface to be written by Vebox 152 pVeboxStdSteState->DW1.StdScoreOutput = (pColorPipeParams->bEnableLACE && pColorPipeParams->LaceParams.bSTD) || pColorPipeParams->bEnableSTD; 153 154 finish: 155 return eStatus; 156 } 157 158 //! 159 //! \brief Set which vebox can be used by HW 160 //! \details VPHAL set whehter the VEBOX can be use by HW 161 //! \param [in] inputVebox0; 162 //! set whether Vebox0 can be used by HW 163 //! \param [in] inputVebox01; 164 //! set whether vebox1 can be use by HW 165 //! \return MOS_STATUS 166 //! MOS_STATUS_SUCCESS if success, else fail reason 167 MOS_STATUS SetVeboxInUse( 168 bool inputVebox0, 169 bool inputVebox1); 170 171 //! 172 //! \brief Set which vebox can be used by DNDI 173 //! \details VPHAL set Chroma parmaters can be use by DNDI 174 //! \param [in] chromaParams 175 //! Chroma parameter which will be used by DNDI 176 //! \return MOS_STATUS 177 //! MOS_STATUS_SUCCESS if success, else fail reason 178 MOS_STATUS SetVeboxChromaParams( 179 MHW_VEBOX_CHROMA_PARAMS *chromaParams); 180 181 //! \brief get the status for vebox's Scalability. 182 //! \details VPHAL will check whether the veobx support Scalabiltiy. 183 //! \return bool 184 //! false or true 185 bool IsScalabilitySupported(); 186 187 //! 188 //! \brief Add Vebox Surface Control Bits 189 //! \details Add Vebox Surface Control Bits 190 //! \param [in] pVeboxSurfCntlParams 191 //! Vebox Surface Control Parameters 192 //! \param [in] pSurfCtrlBits 193 //! Vebox Surface Control Control Bits 194 //! \return MOS_STATUS 195 //! MOS_STATUS_SUCCESS if success, else fail reason 196 MOS_STATUS AddVeboxSurfaceControlBits( 197 PMHW_VEBOX_SURFACE_CNTL_PARAMS pVeboxSurfCntlParams, 198 uint32_t *pSurfCtrlBits); 199 200 //! 201 //! \brief Add Vebox Tiling Convert Control Bits 202 //! \details Add Vebox Tiling Convert Control Bits 203 //! \param [in] cmdBuffer 204 //! Pointers to the HW Cmd buffer 205 //! \param [in] inSurParams 206 //! Pointer to input vebox surface params 207 //! \param [in] outSurParams 208 //! Pointer to output vebox surface params 209 //! \return MOS_STATUS 210 //! MOS_STATUS_SUCCESS if success, else fail reason 211 virtual MOS_STATUS AddVeboxTilingConvert( 212 PMOS_COMMAND_BUFFER cmdBuffer, 213 PMHW_VEBOX_SURFACE_PARAMS inSurParams, 214 PMHW_VEBOX_SURFACE_PARAMS outSurParams); 215 216 //! 217 //! \brief Set Vebox Lace Color Parameters 218 //! \details VPHAL Set Vebox Lace Color Parameters 219 //! \param [in] laceParams 220 //! Lace parameter which will be used by Lace color correction 221 //! \return MOS_STATUS 222 //! MOS_STATUS_SUCCESS if success, else fail reason 223 MOS_STATUS SetVeboxLaceColorParams( 224 MHW_LACE_COLOR_CORRECTION *pLaceParams); 225 226 //! 227 //! \brief Set Vebox Prolog CMD 228 //! \details VPHAL Set Vebox Prolog Cmd for MMC 229 //! \param [in] mhwMiInterface 230 //! Pointers to the HW Mi interface 231 //! \param [in] cmdBuffer 232 //! Pointers to the HW Cmd buffer 233 //! \return MOS_STATUS 234 //! MOS_STATUS_SUCCESS if success, else fail reason 235 MOS_STATUS setVeboxPrologCmd( 236 PMHW_MI_INTERFACE mhwMiInterface, 237 PMOS_COMMAND_BUFFER cmdBuffer); 238 239 //! 240 //! \brief Create Gpu Context for Vebox 241 //! \details Create Gpu Context for Vebox 242 //! \param [in] pOsInterface 243 //! OS interface 244 //! \param [in] VeboxGpuContext 245 //! Vebox Gpu Context 246 //! \param [in] VeboxGpuNode 247 //! Vebox Gpu Node 248 //! \return MOS_STATUS 249 //! MOS_STATUS_SUCCESS if success, else fail reason 250 //! 251 MOS_STATUS CreateGpuContext( 252 PMOS_INTERFACE pOsInterface, 253 MOS_GPU_CONTEXT VeboxGpuContext, 254 MOS_GPU_NODE VeboxGpuNode); 255 256 private: 257 uint32_t m_BT2020InvPixelValue[256]; 258 uint32_t m_BT2020FwdPixelValue[256]; 259 uint32_t m_BT2020InvGammaLUT[256]; 260 uint32_t m_BT2020FwdGammaLUT[256]; 261 bool m_vebox0InUse; 262 bool m_vebox1InUse; 263 bool m_veboxScalabilitySupported; 264 265 uint32_t m_veboxSplitRatio; 266 MHW_VEBOX_CHROMA_PARAMS m_chromaParams; 267 MHW_LACE_COLOR_CORRECTION m_laceColorCorrection; 268 269 //! 270 //! \brief Set Vebox Iecp State Back-End CSC 271 //! \details Set Back-End CSC part of the VEBOX IECP States 272 //! \param [in] pVeboxIecpState 273 //! Pointer to VEBOX IECP States 274 //! \param [in] pVeboxIecpParams 275 //! Pointer to VEBOX IECP State Params 276 //! \param [in] bEnableFECSC 277 //! Flag to enable FECSC 278 //! \return void 279 //! 280 void SetVeboxIecpStateBecsc( 281 mhw_vebox_g12_X::VEBOX_IECP_STATE_CMD *pVeboxIecpState, 282 PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams, 283 bool bEnableFECSC); 284 //! 285 //! \brief Manual mode H2S 286 //! \details Manual mode H2S 287 // Based on WW23'16 algorithm design. 288 //! \param [in] pVeboxIecpParams 289 //! Pointer to VEBOX IECP State Params 290 //! \param [in] pVeboxGamutParams 291 //! Pointer to VEBOX Gamut State Params 292 //! \return MOS_STATUS 293 //! 294 MOS_STATUS VeboxInterface_H2SManualMode( 295 PMHW_VEBOX_HEAP pVeboxHeapInput, 296 PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams, 297 PMHW_VEBOX_GAMUT_PARAMS pVeboxGamutParams); 298 299 //! 300 //! \brief Back end CSC setting, BT2020 YUV Full/Limited to BT2020 RGB Full (G10 +) 301 //! \details Back end CSC setting, BT2020 YUV Full/Limited to BT2020 RGB Full 302 //! \param [in] pVeboxIecpParams 303 //! Pointer to VEBOX IECP State Params 304 //! \param [in] pVeboxGamutParams 305 //! Pointer to VEBOX Gamut State Params 306 //! \return MOS_STATUS 307 //! 308 MOS_STATUS VeboxInterface_BT2020YUVToRGB( 309 PMHW_VEBOX_HEAP pVeboxHeapInput, 310 PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams, 311 PMHW_VEBOX_GAMUT_PARAMS pVeboxGamutParams); 312 313 //! 314 //! \brief init VEBOX IECP States 315 //! \details init Vebox IECP states STD/E, ACE, TCC, Gamut 316 //! \param [in] pVeboxIecpStateCmd 317 //! Pointer to Vebox Interface Structure 318 //! \return viod 319 //! 320 void IecpStateInitialization( 321 mhw_vebox_g12_X::VEBOX_IECP_STATE_CMD *pVeboxIecpState); 322 323 MOS_STATUS AdjustBoundary( 324 PMHW_VEBOX_SURFACE_PARAMS pSurfaceParam, 325 uint32_t *pdwSurfaceWidth, 326 uint32_t *pdwSurfaceHeight, 327 bool bDIEnable); 328 329 #if (_DEBUG || _RELEASE_INTERNAL) 330 //! 331 //! \brief Validate the GPU Node to use for Vebox 332 //! \details Validate the GPU Node to create gpu context used by vebox 333 //! \return MOS_STATUS 334 //! MOS_STATUS_SUCCESS if success, else fail reason 335 //! 336 MOS_STATUS ValidateVeboxScalabilityConfig(); 337 #endif 338 339 protected: 340 void SetVeboxSurfaces( 341 PMHW_VEBOX_SURFACE_PARAMS pSurfaceParam, 342 PMHW_VEBOX_SURFACE_PARAMS pDerivedSurfaceParam, 343 PMHW_VEBOX_SURFACE_PARAMS pSkinScoreSurfaceParam, 344 mhw_vebox_g12_X::VEBOX_SURFACE_STATE_CMD *pVeboxSurfaceState, 345 bool bIsOutputSurface, 346 bool bDIEnable); 347 }; 348 349 #endif 350