| 1 |
/* |
| 2 |
* Copyright (c) 2016-2018, 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_scalability.c |
| 24 |
//! \brief Implements the MOS interface extension cross OS, supporting virtual engine scalability mode. |
| 25 |
//! \details Implements the MOS interface extension cross OS, supporting virtual engine scalability mode. Only necessary when KMD virtual engine is supported. |
| 26 |
//! |
| 27 |
#include "mos_os.h" |
| 28 |
#include "mos_os_virtualengine.h" |
| 29 |
|
| 30 |
//==<Functions>======================================================= |
| 31 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 32 |
MOS_STATUS Mos_VirtualEngine_Scalability_PopulateDbgOvrdParams( |
| 33 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface) |
| 34 |
{ |
| 35 |
PMOS_INTERFACE pOsInterface = nullptr; |
| 36 |
uint8_t ucMaxEngineCnt = 0; |
| 37 |
uint8_t ui8EngineId = 0; |
| 38 |
int32_t iForceEngine = 0; |
| 39 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 40 |
MOS_OS_FUNCTION_ENTER; |
| 41 |
|
| 42 |
MOS_OS_CHK_NULL(pVEInterface); |
| 43 |
MOS_OS_CHK_NULL(pVEInterface->pOsInterface); |
| 44 |
|
| 45 |
pOsInterface = pVEInterface->pOsInterface; |
| 46 |
|
| 47 |
iForceEngine = MOS_INVALID_FORCEENGINE_VALUE; |
| 48 |
|
| 49 |
switch (pOsInterface->Component) |
| 50 |
{ |
| 51 |
case COMPONENT_Decode: |
| 52 |
iForceEngine = pOsInterface->eForceVdbox; |
| 53 |
ucMaxEngineCnt = pVEInterface->ucMaxNumPipesInUse + 1; |
| 54 |
break; |
| 55 |
case COMPONENT_VPCommon: |
| 56 |
iForceEngine = pOsInterface->eForceVebox; |
| 57 |
ucMaxEngineCnt = pVEInterface->ucMaxNumPipesInUse; |
| 58 |
break; |
| 59 |
case COMPONENT_Encode: |
| 60 |
iForceEngine = pOsInterface->eForceVdbox; |
| 61 |
ucMaxEngineCnt = pVEInterface->ucMaxNumPipesInUse; |
| 62 |
break; |
| 63 |
default: |
| 64 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 65 |
MOS_OS_ASSERTMESSAGE("Not supported MOS Component.") |
| 66 |
goto finish; |
| 67 |
} |
| 68 |
|
| 69 |
MOS_ZeroMemory(pVEInterface->EngineLogicId, sizeof(pVEInterface->EngineLogicId)); |
| 70 |
pVEInterface->ucEngineCount = 0; |
| 71 |
if (iForceEngine == 0) |
| 72 |
{ |
| 73 |
pVEInterface->EngineLogicId[0] = 0; |
| 74 |
pVEInterface->ucEngineCount = 1; |
| 75 |
} |
| 76 |
else |
| 77 |
{ |
| 78 |
while (iForceEngine != 0) |
| 79 |
{ |
| 80 |
switch (iForceEngine & MOS_FORCEENGINE_MASK) |
| 81 |
{ |
| 82 |
case 1: |
| 83 |
ui8EngineId = 0; |
| 84 |
break; |
| 85 |
case 2: |
| 86 |
ui8EngineId = 1; |
| 87 |
break; |
| 88 |
case 3: |
| 89 |
ui8EngineId = 2; |
| 90 |
break; |
| 91 |
case 4: |
| 92 |
ui8EngineId = 3; |
| 93 |
break; |
| 94 |
default: |
| 95 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 96 |
MOS_OS_ASSERTMESSAGE("Invalid force engine value."); |
| 97 |
goto finish; |
| 98 |
} |
| 99 |
if (pVEInterface->ucEngineCount >= MOS_MAX_ENGINE_INSTANCE_PER_CLASS) |
| 100 |
{ |
| 101 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 102 |
MOS_OS_ASSERTMESSAGE("number of engine exceeds the max value."); |
| 103 |
goto finish; |
| 104 |
} |
| 105 |
pVEInterface->EngineLogicId[pVEInterface->ucEngineCount] = ui8EngineId; |
| 106 |
iForceEngine >>= MOS_FORCEENGINE_ENGINEID_BITSNUM; |
| 107 |
pVEInterface->ucEngineCount++; |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
if (pVEInterface->ucEngineCount == 0) |
| 112 |
{ |
| 113 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 114 |
MOS_OS_ASSERTMESSAGE("number of engine specified can not be zero."); |
| 115 |
goto finish; |
| 116 |
} |
| 117 |
|
| 118 |
if (pVEInterface->ucEngineCount > ucMaxEngineCnt) |
| 119 |
{ |
| 120 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 121 |
MOS_OS_ASSERTMESSAGE("number of engine specified exceeds HW engine number."); |
| 122 |
goto finish; |
| 123 |
} |
| 124 |
|
| 125 |
eStatus = MOS_STATUS_SUCCESS; |
| 126 |
|
| 127 |
finish: |
| 128 |
return eStatus; |
| 129 |
} |
| 130 |
#endif //(_DEBUG || _RELEASE_INTERNAL) |
| 131 |
|