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