1 /* 2 * Copyright (c) 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_vdbox_avp_g12_X.h 24 //! \brief Defines functions for constructing Vdbox AVP commands on Gen12-based platforms 25 //! 26 27 #ifndef __MHW_VDBOX_AVP_G12_X_H__ 28 #define __MHW_VDBOX_AVP_G12_X_H__ 29 30 #include "mhw_vdbox_avp_generic.h" 31 #include "mhw_vdbox_avp_hwcmd_g12_X.h" 32 #include "mhw_vdbox_g12_X.h" 33 #include "media_user_settings_mgr_g12.h" 34 35 //! MHW Vdbox Avp interface for Gen12 36 /*! 37 This class defines the Avp command construction functions for Gen12 platform 38 */ 39 class MhwVdboxAvpInterfaceG12 : public MhwVdboxAvpInterfaceGeneric<mhw_vdbox_avp_g12_X> 40 { 41 protected: 42 #define PATCH_LIST_COMMAND(x) (x##_NUMBER_OF_ADDRESSES) 43 bool m_scalabilitySupported = false; //!< Indicate if scalability supported 44 45 enum CommandsNumberOfAddresses 46 { 47 MI_BATCH_BUFFER_START_CMD_NUMBER_OF_ADDRESSES = 1, // 2 DW for 1 address field 48 MI_STORE_DATA_IMM_CMD_NUMBER_OF_ADDRESSES = 1, // 2 DW for 1 address field 49 MI_FLUSH_DW_CMD_NUMBER_OF_ADDRESSES = 1, // 2 DW for 1 address field 50 MI_CONDITIONAL_BATCH_BUFFER_END_CMD_NUMBER_OF_ADDRESSES = 1, // 2 DW for 1 address field 51 MI_STORE_REGISTER_MEM_CMD_NUMBER_OF_ADDRESSES = 1, // 2 DW for 1 address field 52 MI_COPY_MEM_MEM_CMD_NUMBER_OF_ADDRESSES = 4, // 4 DW for 2 address fields 53 MI_SEMAPHORE_WAIT_CMD_NUMBER_OF_ADDRESSES = 1, // 2 DW for 1 address fields 54 MI_ATOMIC_CMD_NUMBER_OF_ADDRESSES = 1, // 2 DW for 1 address field 55 56 MFX_WAIT_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 57 58 AVP_PIPE_MODE_SELECT_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 59 AVP_SURFACE_STATE_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 60 AVP_PIPE_BUF_ADDR_STATE_CMD_NUMBER_OF_ADDRESSES = 56, // 56 address fields 61 AVP_IND_OBJ_BASE_ADDR_STATE_CMD_NUMBER_OF_ADDRESSES = 2, // 2 address fields 62 AVP_PIC_STATE_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 63 AVP_REF_IDX_STATE_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 64 AVP_SEGMENT_STATE_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 65 AVP_TILE_CODING_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 66 AVP_TILE_CODING_CMD_LST_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 67 AVP_BSD_OBJECT_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 68 AVP_INLOOP_FILTER_STATE_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 69 AVP_INTER_PRED_STATE_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 70 AVP_PAK_INSERT_OBJECT_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for address fields 71 VDENC_PIPE_BUF_ADDR_STATE_CMD_NUMBER_OF_ADDRESSES = 12, // 12 DW for 12 address fields 72 VD_PIPELINE_FLUSH_CMD_NUMBER_OF_ADDRESSES = 0, // 0 DW for 0 address fields 73 }; 74 75 public: 76 //! 77 //! \brief Constructor 78 //! MhwVdboxAvpInterfaceG12(PMOS_INTERFACE osInterface,MhwMiInterface * miInterface,MhwCpInterface * cpInterface,bool decodeInUse)79 MhwVdboxAvpInterfaceG12( 80 PMOS_INTERFACE osInterface, 81 MhwMiInterface *miInterface, 82 MhwCpInterface *cpInterface, 83 bool decodeInUse) 84 : MhwVdboxAvpInterfaceGeneric(osInterface, miInterface, cpInterface, decodeInUse) 85 { 86 MHW_FUNCTION_ENTER; 87 88 InitRowstoreUserFeatureSettings(); 89 90 MOS_USER_FEATURE_VALUE_DATA userFeatureData; 91 92 memset(&userFeatureData, 0, sizeof(userFeatureData)); 93 userFeatureData.i32DataFlag = MOS_USER_FEATURE_VALUE_DATA_FLAG_CUSTOM_DEFAULT_VALUE_TYPE; 94 #if (_DEBUG || _RELEASE_INTERNAL) 95 MOS_UserFeature_ReadValue_ID( 96 nullptr, 97 __MEDIA_USER_FEATURE_VALUE_ENABLE_AVP_SCALABILITY_DECODE_ID, 98 &userFeatureData, 99 this->m_osInterface->pOsContext); 100 #endif // _DEBUG || _RELEASE_INTERNAL 101 m_scalabilitySupported = userFeatureData.i32Data ? true : false; 102 } 103 104 //! 105 //! \brief Destructor 106 //! 107 virtual ~MhwVdboxAvpInterfaceG12(); 108 109 void InitRowstoreUserFeatureSettings(); 110 111 //! 112 //! \brief Judge if scalability is supported 113 //! 114 //! \return bool 115 //! true if supported, else false 116 //! IsScalabilitySupported()117 inline bool IsScalabilitySupported() 118 { 119 return m_scalabilitySupported; 120 } 121 122 MOS_STATUS GetRowstoreCachingAddrs( 123 PMHW_VDBOX_ROWSTORE_PARAMS rowstoreParams); 124 125 //! 126 //! \brief Calculates maximum size for AVP state level commands 127 //! \details Client facing function to calculate maximum size for AVP state level commands 128 //! \param [out] commandsSize 129 //! The maximum command buffer size 130 //! \param [out] patchListSize 131 //! The maximum command patch list size 132 //! \return MOS_STATUS 133 //! MOS_STATUS_SUCCESS if success, else fail reason 134 //! 135 MOS_STATUS GetAvpStateCommandSize( 136 uint32_t *commandsSize, 137 uint32_t *patchListSize, 138 PMHW_VDBOX_STATE_CMDSIZE_PARAMS params); 139 140 //! 141 //! \brief Calculates maximum size for AVP primitive level commands 142 //! \details Client facing function to calculate maximum size for AVP primitive level commands 143 //! \param [out] commandsSize 144 //! The maximum command buffer size 145 //! \param [out] patchListSize 146 //! The maximum command patch list size 147 //! \return MOS_STATUS 148 //! MOS_STATUS_SUCCESS if success, else fail reason 149 //! 150 MOS_STATUS GetAvpPrimitiveCommandSize( 151 uint32_t *commandsSize, 152 uint32_t *patchListSize); 153 154 //! 155 //! \brief Get AV1 Buffer size 156 //! 157 //! \param [in] bufferType 158 //! Buffer type to get size 159 //! \param [in] avpBufSizeParam 160 //! buffer size params 161 //! 162 //! \return MOS_STATUS 163 //! MOS_STATUS_SUCCESS if success, else fail reason 164 //! 165 virtual MOS_STATUS GetAv1BufferSize( 166 MhwVdboxAvpInternalBufferType bufferType, 167 MhwVdboxAvpBufferSizeParams *avpBufSizeParam); 168 169 //! 170 //! \brief check if AV1 Buffer reallocation is needed 171 //! \details function to check if AV1 Buffer reallocation is needed 172 //! 173 //! \param [in] bufferType 174 //! Buffer type to query 175 //! \param [in] reallocParam 176 //! reallocate params 177 //! 178 //! \return MOS_STATUS 179 //! MOS_STATUS_SUCCESS if success, else fail reason 180 //! 181 MOS_STATUS IsAv1BufferReallocNeeded( 182 MhwVdboxAvpInternalBufferType bufferType, 183 MhwVdboxAvpBufferReallocParams *reallocParam); 184 185 //! 186 //! \brief Adds AVP pipe mode select command 187 //! \details function to add AVP surface state command in command buffer 188 //! 189 //! \param [in] cmdBuffer 190 //! Command buffer to which HW command is added 191 //! \param [in] params 192 //! Params structure used to populate the HW command 193 //! 194 //! \return MOS_STATUS 195 //! MOS_STATUS_SUCCESS if success, else fail reason 196 //! 197 MOS_STATUS AddAvpPipeModeSelectCmd( 198 PMOS_COMMAND_BUFFER cmdBuffer, 199 PMHW_VDBOX_PIPE_MODE_SELECT_PARAMS params); 200 201 //! 202 //! \brief Adds AVP surface state command for decoder 203 //! \details function to add AVP surface state command in command buffer 204 //! 205 //! \param [in] cmdBuffer 206 //! Command buffer to which HW command is added 207 //! \param [in] params 208 //! Params structure used to populate the HW command 209 //! 210 //! \return MOS_STATUS 211 //! MOS_STATUS_SUCCESS if success, else fail reason 212 //! 213 MOS_STATUS AddAvpDecodeSurfaceStateCmd( 214 PMOS_COMMAND_BUFFER cmdBuffer, 215 PMHW_VDBOX_SURFACE_PARAMS params); 216 217 //! 218 //! \brief Adds AVP Pipe Buf Addr command 219 //! \details function to add AVP Pipe Buf Addr command in command buffer 220 //! 221 //! \param [in] cmdBuffer 222 //! Command buffer to which HW command is added 223 //! \param [in] params 224 //! Params structure used to populate the HW command 225 //! 226 //! \return MOS_STATUS 227 //! MOS_STATUS_SUCCESS if success, else fail reason 228 //! 229 virtual MOS_STATUS AddAvpPipeBufAddrCmd( 230 PMOS_COMMAND_BUFFER cmdBuffer, 231 MhwVdboxAvpPipeBufAddrParams *params); 232 233 //! 234 //! \brief Adds AVP Ind Obj Base Address command 235 //! \details function to add AVP Ind Obj Base Address command in command buffer 236 //! 237 //! \param [in] cmdBuffer 238 //! Command buffer to which HW command is added 239 //! \param [in] params 240 //! Params structure used to populate the HW command 241 //! 242 //! \return MOS_STATUS 243 //! MOS_STATUS_SUCCESS if success, else fail reason 244 //! 245 virtual MOS_STATUS AddAvpIndObjBaseAddrCmd( 246 PMOS_COMMAND_BUFFER cmdBuffer, 247 PMHW_VDBOX_IND_OBJ_BASE_ADDR_PARAMS params); 248 249 //! 250 //! \brief Adds AVP Pic State command for decoder 251 //! \details function to add AVP Segment State command in command buffer 252 //! 253 //! \param [in] cmdBuffer 254 //! Command buffer to which HW command is added 255 //! \param [in] params 256 //! Params structure used to populate the HW command 257 //! 258 //! \return MOS_STATUS 259 //! MOS_STATUS_SUCCESS if success, else fail reason 260 //! 261 MOS_STATUS AddAvpDecodePicStateCmd( 262 PMOS_COMMAND_BUFFER cmdBuffer, 263 MhwVdboxAvpPicStateParams *params); 264 265 //! 266 //! \brief Adds AVP Segment State command 267 //! \details function to add AVP Segment State command in command buffer 268 //! 269 //! \param [in] cmdBuffer 270 //! Command buffer to which HW command is added 271 //! \param [in] params 272 //! Params structure used to populate the HW command 273 //! 274 //! \return MOS_STATUS 275 //! MOS_STATUS_SUCCESS if success, else fail reason 276 //! 277 MOS_STATUS AddAvpSegmentStateCmd( 278 PMOS_COMMAND_BUFFER cmdBuffer, 279 MhwVdboxAvpSegmentStateParams *params); 280 281 //! 282 //! \brief Adds AVP tile coding command in command buffer 283 //! \details function to add AVP tile coding command in command buffer 284 //! 285 //! \param [in] cmdBuffer 286 //! Command buffer to which HW command is added 287 //! \param [in] batchBuffer 288 //! Batch buffer to which HW command is added 289 //! \param [in] params 290 //! Params structure used to populate the HW command 291 //! 292 //! \return MOS_STATUS 293 //! MOS_STATUS_SUCCESS if success, else fail reason 294 //! 295 MOS_STATUS AddAvpTileCodingCmd( 296 PMOS_COMMAND_BUFFER cmdBuffer, 297 PMHW_BATCH_BUFFER batchBuffer, 298 MhwVdboxAvpTileCodingParams *params); 299 300 //! 301 //! \brief Adds AVP tile coding command for decoder 302 //! \details function to add AVP tile coding command in command buffer or Batch buffer 303 //! 304 //! \param [in] cmdBuffer 305 //! Command buffer to which HW command is added 306 //! \param [in] batchBuffer 307 //! Batch buffer to which HW command is added 308 //! \param [in] params 309 //! Params structure used to populate the HW command 310 //! 311 //! \return MOS_STATUS 312 //! MOS_STATUS_SUCCESS if success, else fail reason 313 //! 314 MOS_STATUS AddAvpDecodeTileCodingCmd( 315 PMOS_COMMAND_BUFFER cmdBuffer, 316 PMHW_BATCH_BUFFER batchBuffer, 317 MhwVdboxAvpTileCodingParams *params); 318 319 //! 320 //! \brief Adds AVP tile coding command for Large Scale Tile decoding 321 //! \details function to add AVP tile coding command in command buffer or Batch buffer 322 //! 323 //! \param [in] cmdBuffer 324 //! Command buffer to which HW command is added 325 //! \param [in] batchBuffer 326 //! Batch buffer to which HW command is added 327 //! \param [in] params 328 //! Params structure used to populate the HW command 329 //! 330 //! \return MOS_STATUS 331 //! MOS_STATUS_SUCCESS if success, else fail reason 332 //! 333 MOS_STATUS AddAvpDecodeTileCodingCmdLst( 334 PMOS_COMMAND_BUFFER cmdBuffer, 335 PMHW_BATCH_BUFFER batchBuffer, 336 MhwVdboxAvpTileCodingParams *params); 337 338 //! 339 //! \brief Adds AVP BSD Object command in command buffer 340 //! \details function to add AVP BSD Object command in command buffer or Batch buffer 341 //! 342 //! \param [in] cmdBuffer 343 //! Command buffer to which HW command is added 344 //! \param [in] batchBuffer 345 //! Batch buffer to which HW command is added 346 //! \param [in] params 347 //! Params structure used to populate the HW command 348 //! 349 //! \return MOS_STATUS 350 //! MOS_STATUS_SUCCESS if success, else fail reason 351 //! 352 MOS_STATUS AddAvpBsdObjectCmd( 353 PMOS_COMMAND_BUFFER cmdBuffer, 354 PMHW_BATCH_BUFFER batchBuffer, 355 MhwVdboxAvpBsdParams *params); 356 357 //! 358 //! \brief Adds AVP Inloop Filter State command 359 //! \details function to add AVP Inloop Filter State command in command buffer 360 //! 361 //! \param [in] cmdBuffer 362 //! Command buffer to which HW command is added 363 //! \param [in] params 364 //! Params structure used to populate the HW command 365 //! 366 //! \return MOS_STATUS 367 //! MOS_STATUS_SUCCESS if success, else fail reason 368 //! 369 MOS_STATUS AddAvpInloopFilterStateCmd( 370 PMOS_COMMAND_BUFFER cmdBuffer, 371 MhwVdboxAvpPicStateParams *params); 372 373 374 //! 375 //! \brief Adds AVP Inter Prediction State command 376 //! \details function to add AVP Inter Prediction State command in command buffer 377 //! 378 //! \param [in] cmdBuffer 379 //! Command buffer to which HW command is added 380 //! \param [in] params 381 //! Params structure used to populate the HW command 382 //! 383 //! \return MOS_STATUS 384 //! MOS_STATUS_SUCCESS if success, else fail reason 385 //! 386 MOS_STATUS AddAvpInterPredStateCmd( 387 PMOS_COMMAND_BUFFER cmdBuffer, 388 MhwVdboxAvpPicStateParams *params); 389 }; 390 391 #endif 392