1 /*
2 * Copyright (c) 2022, 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 renderhal_legacy.cpp
24 //! \brief Render Engine state heap manager for VP and CM
25 //! \details Platform/OS Independent Render Engine state heap management interfaces
26 //!
27
28 #include "renderhal_legacy.h"
29
30 //!
31 //! \brief Create Interface
32 //! \details Create RenderHal Interface structure, responsible for HW
33 //! abstraction of HW Rendering Engine for CM(MDF) and VP.
34 //! \param PRENDERHAL_INTERFACE renderHal
35 //! [in/out] Pointer to Hardware Interface Structure
36 //! \param MhwCpInterface **cpInterface
37 //! [out] Pointer of pointer to MHW CP Interface Structure, which
38 //! is created during renderhal initialization
39 //! \param PMOS_INTERFACE osInterface
40 //! [in] Pointer to OS Interface Structure
41 //! \param PRENDERHAL_SETTINGS_LEGACY renderHalSettings
42 //! [in] Pointer to RenderHal Settings
43 //!
Create_RenderHal_Interface_Legacy(PRENDERHAL_INTERFACE & renderHal,MhwCpInterface ** cpInterface,PMOS_INTERFACE osInterface,PRENDERHAL_SETTINGS_LEGACY renderHalSettings)44 MOS_STATUS Create_RenderHal_Interface_Legacy(
45 PRENDERHAL_INTERFACE &renderHal,
46 MhwCpInterface **cpInterface,
47 PMOS_INTERFACE osInterface,
48 PRENDERHAL_SETTINGS_LEGACY renderHalSettings)
49 {
50 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
51 if (!cpInterface || !osInterface || !renderHalSettings)
52 {
53 MHW_RENDERHAL_ASSERTMESSAGE("Invalid parameters.");
54 return MOS_STATUS_NULL_POINTER;
55 }
56
57 renderHal = (PRENDERHAL_INTERFACE_LEGACY)MOS_AllocAndZeroMemory(sizeof(RENDERHAL_INTERFACE_LEGACY));
58 if (!renderHal)
59 {
60 MHW_RENDERHAL_ASSERTMESSAGE("Allocate render hal failed");
61 return MOS_STATUS_NULL_POINTER;
62 }
63
64 eStatus = RenderHal_InitInterface_Legacy(
65 (PRENDERHAL_INTERFACE_LEGACY)renderHal,
66 cpInterface,
67 osInterface);
68 if (eStatus != MOS_STATUS_SUCCESS)
69 {
70 MHW_RENDERHAL_ASSERTMESSAGE("Init render hal interface failed");
71 return MOS_STATUS_NULL_POINTER;
72 }
73
74 // Allocate and initialize HW states
75 renderHalSettings->iMediaStates = 32;
76 eStatus = renderHal->pfnInitialize(renderHal, renderHalSettings);
77 if (eStatus != MOS_STATUS_SUCCESS)
78 {
79 MHW_RENDERHAL_ASSERTMESSAGE("Init render hal failed");
80 return MOS_STATUS_NULL_POINTER;
81 }
82
83 return MOS_STATUS_SUCCESS;
84 }
85
86 //!
87 //! \brief Destroy Interface
88 //! \details Create RenderHal Interface structure, responsible for HW
89 //! abstraction of HW Rendering Engine for CM(MDF) and VP.
90 //! \param PRENDERHAL_INTERFACE_LEGACY renderHal
91 //! [in] Pointer to Hardware Interface Structure
92 //!
Destroy_RenderHal_Interface_Legacy(PRENDERHAL_INTERFACE_LEGACY renderHal)93 MOS_STATUS Destroy_RenderHal_Interface_Legacy(PRENDERHAL_INTERFACE_LEGACY renderHal)
94 {
95 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
96 if (renderHal)
97 {
98 eStatus = renderHal->pfnDestroy(renderHal);
99 if (eStatus != MOS_STATUS_SUCCESS)
100 {
101 MHW_RENDERHAL_ASSERTMESSAGE("Failed to destroy RenderHal, eStatus:%d.\n", eStatus);
102 }
103 MOS_FreeMemory(renderHal);
104
105 }
106
107 return eStatus;
108 }
109
110 //!
111 //! \brief Init Interface
112 //! \details Initializes RenderHal Interface structure, responsible for HW
113 //! abstraction of HW Rendering Engine for CM(MDF) and VP.
114 //! \param PRENDERHAL_INTERFACE_LEGACY pRenderHal
115 //! [in] Pointer to RenderHal Interface Structure
116 //! \param MhwCpInterface** ppCpInterface
117 //! [in/out] Pointer of pointer to MHW CP Interface Structure, which
118 //! is created during renderhal initialization
119 //! \param PMOS_INTERFACE pOsInterface
120 //! [in] Pointer to OS Interface Structure
121 //! \return MOS_STATUS
122 //! MOS_STATUS_UNKNOWN : Invalid parameters
123 //!
RenderHal_InitInterface_Legacy(PRENDERHAL_INTERFACE_LEGACY pRenderHal,MhwCpInterface ** ppCpInterface,PMOS_INTERFACE pOsInterface)124 MOS_STATUS RenderHal_InitInterface_Legacy(
125 PRENDERHAL_INTERFACE_LEGACY pRenderHal,
126 MhwCpInterface **ppCpInterface,
127 PMOS_INTERFACE pOsInterface)
128 {
129 //---------------------------------------
130 MHW_RENDERHAL_CHK_NULL_RETURN(pRenderHal);
131 MHW_RENDERHAL_CHK_NULL_RETURN(ppCpInterface);
132 MHW_RENDERHAL_CHK_NULL_RETURN(pOsInterface);
133 //---------------------------------------
134 MHW_RENDERHAL_CHK_STATUS_RETURN(RenderHal_InitInterface(pRenderHal, ppCpInterface, pOsInterface));
135
136 // ISA ASM Debug support functions
137 pRenderHal->pfnLoadDebugKernel = RenderHal_LoadDebugKernel;
138 pRenderHal->pfnLoadSipKernel = RenderHal_LoadSipKernel;
139 pRenderHal->pfnSendSipStateCmd = RenderHal_SendSipStateCmd;
140 // Tracker tag
141 pRenderHal->pfnSetupPrologParams = RenderHal_SetupPrologParams;
142 // Special functions
143 RenderHal_InitInterfaceEx_Legacy(pRenderHal);
144
145 return MOS_STATUS_SUCCESS;
146 }
147
148