| 1 |
/* |
| 2 |
* Copyright (c) 2019, 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 mos_os_virtualengine_next.h |
| 24 |
//! \brief Common interface and structure used in MOS OS VirtualEngine |
| 25 |
//! \details Common interface and structure used in MOS OS VirtualEngine, and only necessary when KMD supports virtual engine |
| 26 |
//! |
| 27 |
#ifndef __MOS_OS_VIRTUALENGINE_NEXT_H__ |
| 28 |
#define __MOS_OS_VIRTUALENGINE_NEXT_H__ |
| 29 |
|
| 30 |
#include "mos_os_virtualengine_specific.h" |
| 31 |
#include "mos_os.h" |
| 32 |
#define MOS_VE_HAVE_SECONDARY_CMDBUFFER 0x2 |
| 33 |
|
| 34 |
typedef struct _MOS_VIRTUALENGINE_INIT_PARAMS |
| 35 |
{ |
| 36 |
bool bScalabilitySupported; |
| 37 |
|
| 38 |
//below only valid when scalability is supported |
| 39 |
bool bFESeparateSubmit; //!< for decode only |
| 40 |
uint8_t ucMaxNumOfSdryCmdBufInOneFrame; |
| 41 |
uint8_t ucMaxNumPipesInUse; |
| 42 |
uint8_t ucNumOfSdryCmdBufSets; |
| 43 |
} MOS_VIRTUALENGINE_INIT_PARAMS, *PMOS_VIRTUALENGINE_INIT_PARAMS; |
| 44 |
|
| 45 |
typedef struct _MOS_VIRTUALENGINE_SET_PARAMS |
| 46 |
{ |
| 47 |
bool bSameEngineAsLastSubmission; |
| 48 |
bool bNeedSyncWithPrevious; |
| 49 |
bool bSFCInUse; |
| 50 |
|
| 51 |
//below only valid when scalability is supported |
| 52 |
bool bScalableMode; |
| 53 |
bool bHaveFrontEndCmds; |
| 54 |
uint8_t ucScalablePipeNum; |
| 55 |
MOS_RESOURCE veBatchBuffer[MOS_MAX_ENGINE_INSTANCE_PER_CLASS]; |
| 56 |
} MOS_VIRTUALENGINE_SET_PARAMS, *PMOS_VIRTUALENGINE_SET_PARAMS; |
| 57 |
|
| 58 |
class MosVeInterface |
| 59 |
{ |
| 60 |
public: |
| 61 |
//! |
| 62 |
//! \brief Construct |
| 63 |
//! |
| 64 |
MosVeInterface() {} |
| 65 |
|
| 66 |
//! |
| 67 |
//! \brief Deconstruct |
| 68 |
//! |
| 69 |
virtual ~MosVeInterface() {} |
| 70 |
|
| 71 |
//! |
| 72 |
//! \brief initialize virtual engine interface |
| 73 |
//! \details initialize virtual engine interface |
| 74 |
//! \param [in] stream |
| 75 |
//! MOS stream state |
| 76 |
//! \param [in] veInitParms |
| 77 |
//! pointer to VE init parameters |
| 78 |
//! \return MOS_STATUS |
| 79 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 80 |
//! |
| 81 |
virtual MOS_STATUS Initialize( |
| 82 |
MOS_STREAM_HANDLE stream, |
| 83 |
PMOS_VIRTUALENGINE_INIT_PARAMS veInitParms); |
| 84 |
|
| 85 |
//! |
| 86 |
//! \brief check if scalability is supported |
| 87 |
//! \param [out] pbScalabilitySupported |
| 88 |
//! pointer to a bool value |
| 89 |
//! \return MOS_STATUS |
| 90 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 91 |
//! |
| 92 |
virtual MOS_STATUS IsScalabilitySupported( |
| 93 |
bool *pbScalabilitySupported); |
| 94 |
|
| 95 |
//! |
| 96 |
//! \brief Reset secondary cmd buffer state |
| 97 |
//! \details Reset secondary cmd buffer state in scalability virtual engine interface |
| 98 |
//! \return void |
| 99 |
//! |
| 100 |
virtual void ResetSecdryCmdBufStates() = 0; |
| 101 |
|
| 102 |
//! |
| 103 |
//! \brief Verify secondary cmd buffer size |
| 104 |
//! \param [in] dwNewRequestSize |
| 105 |
//! new request cmd buffer size |
| 106 |
//! \return bool |
| 107 |
//! true if size is enough, else the size < new requested size |
| 108 |
//! |
| 109 |
virtual bool VerifySecdryCmdBufSize( |
| 110 |
uint32_t dwNewRequestSize) = 0; |
| 111 |
|
| 112 |
//! |
| 113 |
//! \brief resize secondary cmd buffer |
| 114 |
//! \param [in] dwNewRequestSize |
| 115 |
//! new request cmd buffer size |
| 116 |
//! \return MOS_STATUS |
| 117 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 118 |
//! |
| 119 |
virtual MOS_STATUS ResizeSecdryCmdBuf( |
| 120 |
uint32_t dwNewRequestSize) = 0; |
| 121 |
|
| 122 |
//! |
| 123 |
//! \brief get secondary cmd buffer |
| 124 |
//! \param [in] pScdryCmdBuf |
| 125 |
//! pointer to secondry cmd buffer |
| 126 |
//! \param [in] dwBufIdxPlus1 |
| 127 |
//! secondary cmd buffer index plus 1 |
| 128 |
//! \return MOS_STATUS |
| 129 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 130 |
//! |
| 131 |
virtual MOS_STATUS GetSecdryCmdBuf( |
| 132 |
PMOS_COMMAND_BUFFER pScdryCmdBuf, |
| 133 |
uint32_t dwBufIdxPlus1) = 0; |
| 134 |
|
| 135 |
//! |
| 136 |
//! \brief return secondary cmd buffer |
| 137 |
//! \param [in] pScdryCmdBuf |
| 138 |
//! pointer to secondry cmd buffer address |
| 139 |
//! \param [in] dwBufIdxPlus1 |
| 140 |
//! secondary cmd buffer index plus 1 |
| 141 |
//! \return MOS_STATUS |
| 142 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 143 |
//! |
| 144 |
virtual MOS_STATUS ReturnSecdryCmdBuf( |
| 145 |
PMOS_COMMAND_BUFFER pScdryCmdBuf, |
| 146 |
uint32_t dwBufIdxPlus1) = 0; |
| 147 |
|
| 148 |
//! |
| 149 |
//! \brief done virtual engine secondary command buffers |
| 150 |
//! \details UnLock virtual engine secondary command buffers |
| 151 |
//! \return MOS_STATUS |
| 152 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 153 |
//! |
| 154 |
virtual MOS_STATUS DoneSecdryCmdBuf() = 0; |
| 155 |
|
| 156 |
//! |
| 157 |
//! \brief set hint parameters |
| 158 |
//! \details set hint parameters for virtual engine scalability or single pipe mode |
| 159 |
//! \param [in] pVEParams |
| 160 |
//! pointer to VE parameter data structure |
| 161 |
//! \return MOS_STATUS |
| 162 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 163 |
//! |
| 164 |
virtual MOS_STATUS SetHintParams( |
| 165 |
PMOS_VIRTUALENGINE_SET_PARAMS pVEParams) = 0; |
| 166 |
|
| 167 |
//! |
| 168 |
//! \brief get hint parameters |
| 169 |
//! \details get hint parameters for virtual engine scalability or single pipe mode |
| 170 |
//! \param [in] bScalableMode |
| 171 |
//! flag to indicate if scalability mode |
| 172 |
//! \param [in] ppHintParams |
| 173 |
//! pointer to VE hint parameter address |
| 174 |
//! \return MOS_STATUS |
| 175 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 176 |
//! |
| 177 |
virtual MOS_STATUS GetHintParams( |
| 178 |
bool bScalableMode, |
| 179 |
PMOS_VIRTUALENGINE_HINT_PARAMS *ppHintParams) = 0; |
| 180 |
|
| 181 |
//! |
| 182 |
//! \brief check hint parameters |
| 183 |
//! \details check hint parameters for virtual engine scalability or single pipe mode |
| 184 |
//! \return MOS_STATUS |
| 185 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 186 |
//! |
| 187 |
virtual MOS_STATUS CheckHintParamsValidity() = 0; |
| 188 |
|
| 189 |
//! |
| 190 |
//! \brief Destroy resources for virtual engine scalability |
| 191 |
//! |
| 192 |
//! \return void |
| 193 |
//! |
| 194 |
virtual void Destroy() = 0; |
| 195 |
|
| 196 |
//! |
| 197 |
//! \brief Set Submission Type for cmd buffer |
| 198 |
//! \param [out] cmdBuf |
| 199 |
//! Handle of cmd buffer to set submission type |
| 200 |
//! \param [in] type |
| 201 |
//! Submission type to set |
| 202 |
//! \return MOS_STATUS |
| 203 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 204 |
//! |
| 205 |
MOS_STATUS SetSubmissionType( |
| 206 |
COMMAND_BUFFER_HANDLE cmdBuf, |
| 207 |
MOS_SUBMISSION_TYPE type) |
| 208 |
{ |
| 209 |
MOS_OS_CHK_NULL_RETURN(cmdBuf); |
| 210 |
cmdBuf->iSubmissionType = type; |
| 211 |
return MOS_STATUS_SUCCESS; |
| 212 |
} |
| 213 |
|
| 214 |
#if _DEBUG || _RELEASE_INTERNAL |
| 215 |
//! |
| 216 |
//! \brief Get Engine Count |
| 217 |
//! \return uint8_t |
| 218 |
//! |
| 219 |
uint8_t GetEngineCount() |
| 220 |
{ |
| 221 |
return ucEngineCount; |
| 222 |
} |
| 223 |
|
| 224 |
//! |
| 225 |
//! \brief Get Engine Logic Id |
| 226 |
//! \param [in] instanceIdx |
| 227 |
//! Engine instance index |
| 228 |
//! \return uint8_t |
| 229 |
//! |
| 230 |
uint8_t GetEngineLogicId(uint32_t instanceIdx) |
| 231 |
{ |
| 232 |
return EngineLogicId[instanceIdx]; |
| 233 |
} |
| 234 |
#endif // _DEBUG || _RELEASE_INTERNAL |
| 235 |
|
| 236 |
protected: |
| 237 |
MOS_STREAM_HANDLE m_stream = MOS_INVALID_HANDLE; |
| 238 |
bool bScalabilitySupported = false; |
| 239 |
|
| 240 |
#if _DEBUG || _RELEASE_INTERNAL |
| 241 |
uint8_t EngineLogicId[MOS_MAX_ENGINE_INSTANCE_PER_CLASS] = {}; |
| 242 |
uint8_t ucEngineCount = 1; |
| 243 |
bool m_enableDbgOvrdInVirtualEngine = false; |
| 244 |
#endif // _DEBUG || _RELEASE_INTERNAL |
| 245 |
|
| 246 |
uint8_t ucMaxNumPipesInUse = 1; |
| 247 |
bool m_contextBasedScheduling = false; |
| 248 |
|
| 249 |
MOS_VIRTUALENGINE_HINT_PARAMS ScalabilityHintParams = {}; |
| 250 |
MOS_VIRTUALENGINE_HINT_PARAMS SinglePipeHintParams = {}; |
| 251 |
MEDIA_CLASS_DEFINE_END(MosVeInterface) |
| 252 |
}; |
| 253 |
|
| 254 |
typedef struct _MOS_VIRTUALENGINE_INTERFACE |
| 255 |
{ |
| 256 |
MosVeInterface *veInterface; |
| 257 |
|
| 258 |
bool bScalabilitySupported; |
| 259 |
PMOS_INTERFACE pOsInterface; |
| 260 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 261 |
uint8_t EngineLogicId[MOS_MAX_ENGINE_INSTANCE_PER_CLASS]; |
| 262 |
uint8_t ucEngineCount; |
| 263 |
#endif |
| 264 |
uint8_t ucMaxNumPipesInUse; |
| 265 |
uint8_t ucNumOfSdryCmdBufInCurFrm; //!< number of secondary cmd buffers for current frame |
| 266 |
uint32_t dwSdryCmdBufSize; //!< secondary cmd buffer size for current frame |
| 267 |
uint8_t ucMaxNumOfSdryCmdBufInOneFrame; |
| 268 |
uint32_t dwTotalNumOfSdryCmdBufs; |
| 269 |
uint8_t ucNumOfSdryCmdBufSets; |
| 270 |
uint8_t ucSdryCmdbufPoolIndx; |
| 271 |
bool *pbSdryCmdBufPrepared; |
| 272 |
PMOS_COMMAND_BUFFER pSecondryCmdBufPool; |
| 273 |
MOS_VIRTUALENGINE_HINT_PARAMS ScalabilityHintParams; |
| 274 |
MOS_VIRTUALENGINE_HINT_PARAMS SinglePipeHintParams; |
| 275 |
|
| 276 |
//! |
| 277 |
//! \brief check if scalability is supported |
| 278 |
//! \param [in] pVEInterface |
| 279 |
//! virtual engine interface |
| 280 |
//! \param [out] pbScalabilitySupported |
| 281 |
//! pointer to a bool value |
| 282 |
//! \return MOS_STATUS |
| 283 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 284 |
//! |
| 285 |
MOS_STATUS (*pfnVEIsScalabilitySupported) |
| 286 |
( |
| 287 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface, |
| 288 |
bool *pbScalabilitySupported); |
| 289 |
|
| 290 |
//! |
| 291 |
//! \brief Reset secondary cmd buffer state |
| 292 |
//! \details Reset secondary cmd buffer state in scalability virtual engine interface |
| 293 |
//! \param [in] pVEInterface |
| 294 |
//! virtual engine interface |
| 295 |
//! \return void |
| 296 |
//! |
| 297 |
void (*pfnVEResetSecdryCmdBufStates)( |
| 298 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface); |
| 299 |
|
| 300 |
//! |
| 301 |
//! \brief Verify secondary cmd buffer size |
| 302 |
//! \param [in] pVEInterface |
| 303 |
//! virtual engine interface |
| 304 |
//! \param [in] dwNewRequestSize |
| 305 |
//! new request cmd buffer size |
| 306 |
//! \return MOS_STATUS |
| 307 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 308 |
//! |
| 309 |
MOS_STATUS (*pfnVEVerifySecdryCmdBufSize) |
| 310 |
( |
| 311 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface, |
| 312 |
uint32_t dwNewRequestSize); |
| 313 |
|
| 314 |
//! |
| 315 |
//! \brief resize secondary cmd buffer |
| 316 |
//! \param [in] pVEInterface |
| 317 |
//! virtual engine interface |
| 318 |
//! \param [in] dwNewRequestSize |
| 319 |
//! new request cmd buffer size |
| 320 |
//! \return MOS_STATUS |
| 321 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 322 |
//! |
| 323 |
MOS_STATUS (*pfnVEResizeSecdryCmdBuf) |
| 324 |
( |
| 325 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface, |
| 326 |
uint32_t dwNewRequestSize); |
| 327 |
|
| 328 |
//! |
| 329 |
//! \brief get secondary cmd buffer |
| 330 |
//! \param [in] pVEInterface |
| 331 |
//! virtual engine interface |
| 332 |
//! \param [in] pScdryCmdBuf |
| 333 |
//! pointer to secondry cmd buffer |
| 334 |
//! \param [in] dwBufIdxPlus1 |
| 335 |
//! secondary cmd buffer index plus 1 |
| 336 |
//! \return MOS_STATUS |
| 337 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 338 |
//! |
| 339 |
MOS_STATUS (*pfnVEGetSecdryCmdBuf) |
| 340 |
( |
| 341 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface, |
| 342 |
PMOS_COMMAND_BUFFER pScdryCmdBuf, |
| 343 |
uint32_t dwBufIdxPlus1); |
| 344 |
|
| 345 |
//! |
| 346 |
//! \brief return secondary cmd buffer |
| 347 |
//! \param [in] pVEInterface |
| 348 |
//! virtual engine interface |
| 349 |
//! \param [in] pScdryCmdBuf |
| 350 |
//! pointer to secondry cmd buffer address |
| 351 |
//! \param [in] dwBufIdxPlus1 |
| 352 |
//! secondary cmd buffer index plus 1 |
| 353 |
//! \return MOS_STATUS |
| 354 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 355 |
//! |
| 356 |
MOS_STATUS (*pfnVEReturnSecdryCmdBuf) |
| 357 |
( |
| 358 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface, |
| 359 |
PMOS_COMMAND_BUFFER pScdryCmdBuf, |
| 360 |
uint32_t dwBufIdxPlus1); |
| 361 |
|
| 362 |
//! |
| 363 |
//! \brief done virtual engine secondary command buffers |
| 364 |
//! \details UnLock virtual engine secondary command buffers |
| 365 |
//! \param [in] pVEInterface |
| 366 |
//! virtual engine interface |
| 367 |
//! \return MOS_STATUS |
| 368 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 369 |
//! |
| 370 |
MOS_STATUS (*pfnVEDoneSecdryCmdBuf) |
| 371 |
( |
| 372 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface); |
| 373 |
|
| 374 |
//! |
| 375 |
//! \brief set hint parameters |
| 376 |
//! \details set hint parameters for virtual engine scalability or single pipe mode |
| 377 |
//! \param [in] pVEInterface |
| 378 |
//! virtual engine interface |
| 379 |
//! \param [in] pVEParams |
| 380 |
//! pointer to VE parameter data structure |
| 381 |
//! \return MOS_STATUS |
| 382 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 383 |
//! |
| 384 |
MOS_STATUS (*pfnVESetHintParams) |
| 385 |
( |
| 386 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface, |
| 387 |
PMOS_VIRTUALENGINE_SET_PARAMS pVEParams); |
| 388 |
|
| 389 |
//! |
| 390 |
//! \brief get hint parameters |
| 391 |
//! \details get hint parameters for virtual engine scalability or single pipe mode |
| 392 |
//! \param [in] pVEInterface |
| 393 |
//! virtual engine interface |
| 394 |
//! \param [in] bScalableMode |
| 395 |
//! flag to indicate if scalability mode |
| 396 |
//! \param [in] ppHintParams |
| 397 |
//! pointer to VE hint parameter address |
| 398 |
//! \return MOS_STATUS |
| 399 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 400 |
//! |
| 401 |
MOS_STATUS (*pfnVEGetHintParams) |
| 402 |
( |
| 403 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface, |
| 404 |
bool bScalableMode, |
| 405 |
PMOS_VIRTUALENGINE_HINT_PARAMS *ppHintParams); |
| 406 |
|
| 407 |
//! |
| 408 |
//! \brief check hint parameters |
| 409 |
//! \details check hint parameters for virtual engine scalability or single pipe mode |
| 410 |
//! \param [in] pVEInterface |
| 411 |
//! virtual engine interface |
| 412 |
//! \param [in] ppHintParams |
| 413 |
//! pointer to VE hint parameter address |
| 414 |
//! \return MOS_STATUS |
| 415 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 416 |
//! |
| 417 |
MOS_STATUS (*pfnVECheckHintParamsValidity) |
| 418 |
( |
| 419 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface); |
| 420 |
|
| 421 |
//! |
| 422 |
//! \brief Destroy resources for virtual engine scalability |
| 423 |
//! \param [in] pVEInterface |
| 424 |
//! virtual engine interface |
| 425 |
//! \return void |
| 426 |
//! |
| 427 |
void (*pfnVEDestroy)( |
| 428 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface); |
| 429 |
} MOS_VIRTUALENGINE_INTERFACE, *PMOS_VIRTUALENGINE_INTERFACE; |
| 430 |
|
| 431 |
#endif //__MOS_OS_VIRTUALENGINE_SCALABILITY_NEXT_H__ |
| 432 |
|