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_scalability_next.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_scalability_next.h"
29
30 #if (_DEBUG || _RELEASE_INTERNAL)
PopulateDbgOvrdParams(MOS_STREAM_HANDLE stream)31 MOS_STATUS MosOsVeScalability::PopulateDbgOvrdParams(
32 MOS_STREAM_HANDLE stream)
33 {
34 MOS_STATUS eStatus = MOS_STATUS_UNKNOWN;
35
36 MOS_OS_FUNCTION_ENTER;
37 MOS_OS_CHK_NULL_RETURN(stream);
38
39 uint8_t ucMaxEngineCnt = 0;
40 uint8_t ui8EngineId = 0;
41 int32_t iForceEngine = 0;
42
43 iForceEngine = MOS_INVALID_FORCEENGINE_VALUE;
44
45 switch (stream->component)
46 {
47 case COMPONENT_Decode:
48 iForceEngine = stream->eForceVdbox;
49 ucMaxEngineCnt = ucMaxNumPipesInUse + 1;
50 break;
51 case COMPONENT_VPCommon:
52 iForceEngine = stream->eForceVebox;
53 ucMaxEngineCnt = ucMaxNumPipesInUse;
54 break;
55 case COMPONENT_Encode:
56 iForceEngine = stream->eForceVdbox;
57 ucMaxEngineCnt = ucMaxNumPipesInUse;
58 break;
59 default:
60 eStatus = MOS_STATUS_INVALID_PARAMETER;
61 MOS_OS_ASSERTMESSAGE("Not supported MOS Component.")
62 return eStatus;
63 }
64
65 MosUtilities::MosZeroMemory(EngineLogicId, sizeof(EngineLogicId));
66 ucEngineCount = 0;
67 if (iForceEngine == 0)
68 {
69 EngineLogicId[0] = 0;
70 ucEngineCount = 1;
71 }
72 else
73 {
74 while (iForceEngine != 0)
75 {
76 switch (iForceEngine & MOS_FORCEENGINE_MASK)
77 {
78 case 1:
79 ui8EngineId = 0;
80 break;
81 case 2:
82 ui8EngineId = 1;
83 break;
84 case 3:
85 ui8EngineId = 2;
86 break;
87 case 4:
88 ui8EngineId = 3;
89 break;
90 default:
91 eStatus = MOS_STATUS_INVALID_PARAMETER;
92 MOS_OS_ASSERTMESSAGE("Invalid force engine value.");
93 return eStatus;
94 }
95 if (ucEngineCount >= MOS_MAX_ENGINE_INSTANCE_PER_CLASS)
96 {
97 eStatus = MOS_STATUS_INVALID_PARAMETER;
98 MOS_OS_ASSERTMESSAGE("number of engine exceeds the max value.");
99 return eStatus;
100 }
101 EngineLogicId[ucEngineCount] = ui8EngineId;
102 iForceEngine >>= MOS_FORCEENGINE_ENGINEID_BITSNUM;
103 ucEngineCount++;
104 }
105 }
106
107 if (ucEngineCount == 0)
108 {
109 eStatus = MOS_STATUS_INVALID_PARAMETER;
110 MOS_OS_ASSERTMESSAGE("number of engine specified can not be zero.");
111 return eStatus;
112 }
113
114 if (ucEngineCount > ucMaxEngineCnt)
115 {
116 eStatus = MOS_STATUS_INVALID_PARAMETER;
117 MOS_OS_ASSERTMESSAGE("number of engine specified exceeds HW engine number.");
118 return eStatus;
119 }
120
121 eStatus = MOS_STATUS_SUCCESS;
122
123 return eStatus;
124 }
125 #endif //(_DEBUG || _RELEASE_INTERNAL)
126
127