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.cpp
24 //! \brief Implements the MOS interface extension cross OS - virtual engine.
25 //! \details Implements the MOS interface extension cross OS - virtual engine. Only necessary when KMD virtual engine is supported
26 //!
27
28 #include "mos_os.h"
29 #include "mos_os_virtualengine_singlepipe_specific.h"
30 #include "mos_os_virtualengine_scalability_specific.h"
31 #include "mos_os_virtualengine_singlepipe_specific_next.h"
32 #include "mos_os_virtualengine_scalability_specific_next.h"
33
Mos_VirtualEngine_IsScalabilitySupported(PMOS_VIRTUALENGINE_INTERFACE pVEInterface,bool * pbScalabilitySupported)34 inline MOS_STATUS Mos_VirtualEngine_IsScalabilitySupported(
35 PMOS_VIRTUALENGINE_INTERFACE pVEInterface,
36 bool *pbScalabilitySupported)
37 {
38 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
39
40 MOS_OS_FUNCTION_ENTER;
41
42 MOS_OS_CHK_NULL(pVEInterface);
43 MOS_OS_CHK_NULL(pbScalabilitySupported);
44
45 *pbScalabilitySupported = pVEInterface->bScalabilitySupported;
46
47 finish:
48 return eStatus;
49 }
50
Mos_VirtualEngineInterface_Initialize(PMOS_INTERFACE pOsInterface,PMOS_VIRTUALENGINE_INIT_PARAMS pVEInitParms)51 MOS_STATUS Mos_VirtualEngineInterface_Initialize(
52 PMOS_INTERFACE pOsInterface,
53 PMOS_VIRTUALENGINE_INIT_PARAMS pVEInitParms)
54 {
55 PMOS_VIRTUALENGINE_INTERFACE pVEInterf = nullptr;
56 uint32_t i = 0;
57 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
58
59 MOS_OS_CHK_NULL(pOsInterface);
60 MOS_OS_CHK_NULL(pVEInitParms);
61
62 if (!MOS_VE_SUPPORTED(pOsInterface))
63 {
64 eStatus = MOS_STATUS_INVALID_PARAMETER;
65 MOS_OS_ASSERTMESSAGE("virtual engine is not supported.\n");
66 goto finish;
67 }
68
69 pVEInterf = (PMOS_VIRTUALENGINE_INTERFACE)MOS_AllocAndZeroMemory(sizeof(MOS_VIRTUALENGINE_INTERFACE));
70 MOS_OS_CHK_NULL(pVEInterf);
71
72 pVEInterf->pOsInterface = pOsInterface;
73 pVEInterf->bScalabilitySupported = pVEInitParms->bScalabilitySupported;
74 pVEInterf->ucMaxNumPipesInUse = pVEInitParms->ucMaxNumPipesInUse;
75
76 if (pVEInterf->bScalabilitySupported &&
77 (pVEInterf->ucMaxNumPipesInUse > MOS_MAX_ENGINE_INSTANCE_PER_CLASS ||
78 pVEInterf->ucMaxNumPipesInUse == 0))
79 {
80 eStatus = MOS_STATUS_INVALID_PARAMETER;
81 MOS_OS_ASSERTMESSAGE("invalid max pipe number in use for scalability");
82 goto finish;
83 }
84
85 pVEInterf->pfnVEIsScalabilitySupported = Mos_VirtualEngine_IsScalabilitySupported;
86
87 pOsInterface->pVEInterf = pVEInterf;
88
89 if (pVEInitParms->bScalabilitySupported)
90 {
91 MOS_OS_CHK_STATUS(Mos_Specific_VirtualEngine_Scalability_Initialize(pVEInterf, pVEInitParms));
92 }
93 else
94 {
95 MOS_OS_CHK_STATUS(Mos_Specific_VirtualEngine_SinglePipe_Initialize(pVEInterf, pVEInitParms));
96 }
97
98 if (pOsInterface->apoMosEnabled)
99 {
100 MOS_OS_CHK_NULL(pOsInterface->osStreamState);
101 if (pVEInitParms->bScalabilitySupported)
102 {
103 pVEInterf->veInterface = MOS_New(MosOsVeScalabilitySpecific);
104 }
105 else
106 {
107 pVEInterf->veInterface = MOS_New(MosOsVeSinglePipeSpecific);
108 }
109 MOS_OS_CHK_NULL(pVEInterf->veInterface);
110 MOS_OS_CHK_STATUS(pVEInterf->veInterface->Initialize(pOsInterface->osStreamState, pVEInitParms));
111 pOsInterface->osStreamState->virtualEngineInterface = pVEInterf->veInterface;
112 }
113 return eStatus;
114
115 finish:
116 MOS_SafeFreeMemory(pVEInterf);
117 return eStatus;
118 }
119
120