xref: /aosp_15_r20/external/intel-media-driver/media_driver/agnostic/Xe_M/Xe_XPM/vp/hal/vphal_xe_xpm.cpp (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*===================== begin_copyright_notice ==================================
2 
3 # Copyright (c) 2020-2021, Intel Corporation
4 
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the "Software"),
7 # to deal in the Software without restriction, including without limitation
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 # and/or sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following conditions:
11 
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 # OTHER DEALINGS IN THE SOFTWARE.
22 
23 ======================= end_copyright_notice ==================================*/
24 //!
25 //! \file     vphal_xe_xpm.cpp
26 //! \brief    Vphal Interface Definition
27 //! \details  Vphal Interface Definition Including:
28 //!           const and function
29 //!
30 #include "vphal_xe_xpm.h"
31 #include "vphal_renderer_xe_xpm.h"
32 
33 //!
34 //! \brief    Allocate VPHAL Resources
35 //! \details  Allocate VPHAL Resources
36 //!           - Allocate and initialize HW states
37 //!           - Allocate and initialize renderer states
38 //! \param    [in] pVpHalSettings
39 //!           Pointer to VPHAL Settings
40 //! \return   MOS_STATUS
41 //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
42 //!
Allocate(const VphalSettings * pVpHalSettings)43 MOS_STATUS VphalStateXe_Xpm::Allocate(
44     const VphalSettings       *pVpHalSettings)
45 {
46     MOS_STATUS                  eStatus;
47 
48     VPHAL_PUBLIC_CHK_NULL(m_osInterface);
49     VPHAL_PUBLIC_CHK_NULL(pVpHalSettings);
50     VPHAL_PUBLIC_CHK_NULL(m_renderHal);
51 
52     Mos_SetVirtualEngineSupported(m_osInterface, true);
53     m_osInterface->pfnVirtualEngineSupported(m_osInterface, true, true);
54 
55     VPHAL_PUBLIC_CHK_STATUS(VphalState::Allocate(pVpHalSettings));
56 
57     // Update MOCS
58     if (m_renderHal->pOsInterface &&  m_renderHal->pOsInterface->pfnCachePolicyGetMemoryObject &&  m_renderHal->pOsInterface->pfnGetGmmClientContext)
59     {
60         MHW_STATE_BASE_ADDR_PARAMS *pStateBaseParams = &m_renderHal->StateBaseAddressParams;
61         MEMORY_OBJECT_CONTROL_STATE StateMocs = m_renderHal->pOsInterface->pfnCachePolicyGetMemoryObject(MOS_MP_RESOURCE_USAGE_SurfaceState,
62             m_renderHal->pOsInterface->pfnGetGmmClientContext(m_renderHal->pOsInterface));
63 
64         //update MOCS for Instruction Cache
65         pStateBaseParams->mocs4InstructionCache = StateMocs.DwordValue;
66         //update MOCS for General state
67         pStateBaseParams->mocs4GeneralState = StateMocs.DwordValue;
68         //update MOCS for Dynamic state
69         pStateBaseParams->mocs4DynamicState = StateMocs.DwordValue;
70         //update MOCS for Surface state
71         pStateBaseParams->mocs4SurfaceState = StateMocs.DwordValue;
72         //update MOCS for Indirect Object
73         pStateBaseParams->mocs4IndirectObjectBuffer = StateMocs.DwordValue;
74         //update MOCS for Stateless Dataport access
75         pStateBaseParams->mocs4StatelessDataport = StateMocs.DwordValue;
76     }
77 
78 finish:
79     return eStatus;
80 }
81 
82 //!
83 //! \brief    Create instance of VphalRenderer
84 //! \details  Create instance of VphalRenderer
85 //! \return   MOS_STATUS
86 //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
87 //!
CreateRenderer()88 MOS_STATUS VphalStateXe_Xpm::CreateRenderer()
89 {
90     MOS_STATUS eStatus = MOS_STATUS_UNKNOWN;
91 
92     // Setup rendering interface functions
93     m_renderer = MOS_New(
94         VphalRendererXe_Xpm,
95         m_renderHal,
96         &eStatus);
97 
98     if (m_renderer == nullptr)
99     {
100         return MOS_STATUS_NULL_POINTER;
101     }
102     else
103     {
104         if (eStatus != MOS_STATUS_SUCCESS)
105         {
106             MOS_Delete(m_renderer);
107             m_renderer = nullptr;
108             return eStatus;
109         }
110         else
111         {
112             m_renderer->SetStatusReportTable(&m_statusTable);
113         }
114     }
115 
116     eStatus = m_renderer->InitKdllParam();
117     if (eStatus != MOS_STATUS_SUCCESS)
118     {
119         MOS_Delete(m_renderer);
120         m_renderer = nullptr;
121         return eStatus;
122     }
123 
124     eStatus = m_renderer->AllocateRenderComponents(
125                                 m_veboxInterface,
126                                 m_sfcInterface);
127 
128     return eStatus;
129 }
130