xref: /aosp_15_r20/external/intel-media-driver/media_softlet/agnostic/common/os/mos_context_next.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2019-2024, 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_context_next.h
24 //! \brief    Container for parameters shared across different GPU contextNexts of the same device instance
25 //!
26 
27 #ifndef __MOS_CONTEXT_NEXT_H__
28 #define __MOS_CONTEXT_NEXT_H__
29 
30 #include "mos_os.h"
31 #include "mos_gpucontextmgr_next.h"
32 #if !EMUL
33 #include "mos_cmdbufmgr_next.h"
34 #include "mos_decompression.h"
35 #endif
36 #include "mos_mediacopy.h"
37 
38 class MosOcaRTLogMgr;
39 
40 class OsContextNext
41 {
42 protected:
43     //!
44     //! \brief Constructor for the OsContextNext
45     //!
OsContextNext()46     OsContextNext(){};
47 
48     //!
49     //! \brief    Interface for initializing NULL Hardware.
50     //! \details  Interface for initializing NULL Hardware.
51     //! \param    [in] osContext
52     //!           Pointer to OS context.
53     //! \param    [in] osDeviceContext
54     //!           Pointer to OS device context.
55     //! \return   MOS_STATUS
56     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
57     //!
58     MOS_STATUS NullHwInit(MOS_CONTEXT_HANDLE osContext);
59 
60     //!
61     //! \brief    Destroy NULL Hardware.
62     //! \details  Destroy NULL Hardware.
63     //! \return   MOS_STATUS
64     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
65     //!
66     MOS_STATUS NullHwDestroy();
67 
68 public:
69     //!
70     //! \brief Destructor for the OsContextNext
71     //!
~OsContextNext()72     virtual ~OsContextNext(){};
73 
74     //!
75     //! \brief  Initialzie the OS ContextNext Object
76     //! \return MOS_STATUS_SUCCESS on success case, MOS error status on fail cases
77     //!
78     virtual MOS_STATUS Init(DDI_DEVICE_CONTEXT osDriverContextNext) = 0;
79 
80     //!
81     //! \brief  Static entrypoint, get the OS ContextNext Object
82     //! \return the os specific object for OS contextNext
83     //!
84     static class OsContextNext *GetOsContextObject();
85 
86     //!
87     //! \brief  Clean up the smartptr
88     //!
89     void CleanUp();
90 
91     //!
92     //! \brief  Get the skuTable
93     //! \return The active SKU Table
94     //!
GetSkuTable()95     MEDIA_FEATURE_TABLE *GetSkuTable() { return &m_skuTable; };
96 
97     //!
98     //! \brief  Get the waTable
99     //! \return The active WA table
100     //!
GetWaTable()101     MEDIA_WA_TABLE *GetWaTable() { return &m_waTable; };
102 
103     //!
104     //! \brief  Get the platform information string
105     //! \return value of m_platformInfo
106     //!
GetPlatformInfo()107     PLATFORM *GetPlatformInfo() { return &m_platformInfo; };
108 
109     //!
110     //! \brief  Get the gtSystemInfo string
111     //! \return value of m_gtSystemInfo
112     //!
GetGtSysInfo()113     MEDIA_SYSTEM_INFO *GetGtSysInfo() { return &m_gtSystemInfo; };
114 
115     //!
116     //! \brief  Check the platform is Atom or not
117     //! \return true on Atom platform, false on none Atom platform
118     //!
IsAtomSoc()119     bool IsAtomSoc() { return m_isAtomSOC; };
120 
121     //!
122     //! \brief  Set the OS ContextNext valid flag
123     //! \param   [in] isOsContextNextValid
124     //!          Flag to indicate if the os contextNext is valid.
125     //!
SetOsContextValid(bool isOsContextValid)126     void SetOsContextValid(bool isOsContextValid) { m_osContextValid = isOsContextValid; };
127 
128     //!
129     //! \brief  Return the OS ContextNext valid flag
130     //! \return true if the OS contextNext is valid, false if not valid
131     //!
GetOsContextValid()132     bool GetOsContextValid() { return m_osContextValid; };
133 
134     //!
135     //! \brief  Set Null Hw enabled flag
136     //! \param  [in] isNullHwEnabled
137     //!         Flag to indicate if Null Hw is enabled.
138     //!
SetNullHwIsEnabled(bool isNullHwEnabled)139     void SetNullHwIsEnabled(bool isNullHwEnabled) { m_nullHwIsEnabled = isNullHwEnabled; }
140 
141     //!
142     //! \brief  Return Null Hw enabled flag
143     //! \return true if Null Hw is enabled, false if not enabled
144     //!
GetNullHwIsEnabled()145     bool GetNullHwIsEnabled() { return m_nullHwIsEnabled; }
146 
147     //!
148     //! \brief  Get GPU context manager of the device
149     //! \return GPU context manager
150     //!
GetGpuContextMgr()151     GpuContextMgrNext *GetGpuContextMgr() { return m_gpuContextMgr; }
152 
153     //!
154     //! \brief  Get Cmd buffer manager of the device
155     //! \return Cmd buffer manager
156     //!
GetCmdBufferMgr()157     CmdBufMgrNext *GetCmdBufferMgr() { return m_cmdBufMgr; }
158 
159     //!
160     //! \brief  Get GMM client context of the device
161     //! \return Cmd buffer manager
162     //!
GetGmmClientContext()163     GMM_CLIENT_CONTEXT *GetGmmClientContext() { return m_gmmClientContext; }
164 
165     //!
166     //! \brief  Get MosDecompression
167     //! \return ptr to MosDecompression
168     //!
169 #if !EMUL
GetMosDecompression()170     MosDecompression *GetMosDecompression()
171     {
172         return m_mosDecompression;
173     }
174 #endif
175 
176     //!
177     //! \brief  Get MosMediaCopy
178     //! \return ptr to MosMediaCopy
179     //!
GetMosMediaCopy()180     MosMediaCopy *GetMosMediaCopy()
181     {
182         return m_mosMediaCopy;
183     }
184 
185     //! \brief  Get the DumpFrameNum
186     //! \return The current dumped frameNum
187     //!
GetDumpFrameNum()188     uint32_t GetDumpFrameNum() { return m_dumpframeNum; }
189 
190     //!
191     //! \brief  Set the DumpFrameNum
192     //! \return update the FrameNum and return success
193     //!
SetDumpFrameNum(uint32_t framNum)194     MOS_STATUS SetDumpFrameNum(uint32_t framNum)
195     {
196         m_dumpframeNum = framNum;
197         return MOS_STATUS_SUCCESS;
198     }
199 
200     //!
201     //! \brief  Reset the DumpFrameNum
202     //! \return init the FrameNum and return success
203     //!
ResetDumpFrameNum()204     MOS_STATUS ResetDumpFrameNum()
205     {
206         m_dumpframeNum = 0xffffffff;
207         return MOS_STATUS_SUCCESS;
208     }
209 
210     //!
211     //! \brief  Get the dumpLoc
212     //! \return The current dumped GetdumpLoc
213     //!
GetdumpLoc()214     char *GetdumpLoc() { return m_dumpLoc; }
215 
216     //!
217     //! \brief  Reset the dumpLoc
218     //! \return init the dumpLoc and return success
219     //!
ResetdumpLoc()220     MOS_STATUS ResetdumpLoc()
221     {
222         m_dumpLoc[0] = 0;
223         return MOS_STATUS_SUCCESS;
224     }
225 
226     //!
227     //! \brief  Determine whether the device is using async mode
228     //! \return true if the device is in async mode, false otherwise
229     //!
IsAynchronous()230     bool IsAynchronous() { return m_aynchronousDevice; }
231 
232     //!
233     //! \brief  Determine whether pooling resource is enabled
234     //! \return true if pooling resource is enabled, false otherwise
235     //!
IsPoolingResourceEnabled()236     bool IsPoolingResourceEnabled() { return m_resourcePooling; }
237 
238     //!
239     //! \brief  Set oca rtlog resource
240     //! \return Set oca rtlog resource and return success
241     //!
SetRtLogRes(PMOS_RESOURCE ocaRTLogResource)242     MOS_STATUS SetRtLogRes(PMOS_RESOURCE ocaRTLogResource)
243     {
244         m_ocaRTLogResource = ocaRTLogResource;
245         return MOS_STATUS_SUCCESS;
246     }
247 
248     //!
249     //! \brief  Get OcaRTLogResource
250     //! \return ptr to OcaRTLogResource
251     //!
GetOcaRTLogResource()252     PMOS_RESOURCE GetOcaRTLogResource()
253     {
254         return m_ocaRTLogResource;
255     }
256 
257 protected:
258     //!
259     //! \brief  Destory the OS ContextNext Object, internal function, called by cleanup
260     //!
261     virtual void Destroy() = 0;
262 
263 public:
264     static const uint32_t m_cmdBufAlignment = 16;   //!> Cmd buffer alignment
265     bool                  m_ocaLogSectionSupported = true;
266 
267 protected:
268     GpuContextMgrNext              *m_gpuContextMgr     = nullptr; //!> GPU context manager of the device
269     CmdBufMgrNext                  *m_cmdBufMgr         = nullptr; //!> Cmd buffer manager of the device
270     GMM_CLIENT_CONTEXT             *m_gmmClientContext  = nullptr; //!> GMM client context of the device
271 
272     PMOS_RESOURCE                   m_ocaRTLogResource  = nullptr;
273     uint32_t                        m_dumpframeNum = 0;             // For use when dump its compressed surface, override the frame number given from MediaVeboxDecompState
274     char                            m_dumpLoc[MAX_PATH] = {0};       // For use when dump its compressed surface, to distinguish each loc's pre/post decomp
275 
276     //! \brief  Platform string including product family, chipset family, etc
277     PLATFORM                        m_platformInfo = {};
278 
279     //! \brief  sku table
280     MEDIA_FEATURE_TABLE             m_skuTable = {};
281 
282      //! \brief  wa table
283     MEDIA_WA_TABLE                  m_waTable = {};
284 
285      //! \brief  GT system information, like EU counter, thread count, etc.
286     MEDIA_SYSTEM_INFO               m_gtSystemInfo = {};
287 
288     //! \brief  Whether the processor is Atom
289     bool                            m_isAtomSOC = false;
290 
291 
292     //! \brief  Flag to mark whether the os context is valid
293     bool                            m_osContextValid =  false;
294 
295     //! \brief  Flag to mark whether Null Hw is enabled
296     bool                            m_nullHwIsEnabled = false;
297 
298     //! \brief  Whether or not need deallocation on exit
299     bool                            m_deallocateOnExit = false;
300 
301     //! \brief  need KMD to track the media frame or not
302     bool                            m_enableKmdMediaFrameTracking = false;
303 
304     //! \brief   For Resource addressing, whether patch list mode is active
305     bool                            m_usesPatchList = false;
306 
307     //! \brief   For Resource addressing, whether GPU address mode is active
308     bool                            m_usesGfxAddress = false;
309 
310     //! \brief   Component info
311     MOS_COMPONENT                   m_component = COMPONENT_UNKNOWN;
312 
313     //! \brief   Flag to indicate if Tile64 is supported
314     bool                            m_mediaTile64 = false;
315 
316     //! \brief   Flag to indicate if NoGfxMemory is needed
317     bool                            m_noGfxMemoryNeeded = false;
318 
319     //! \brief  the ptr to mos decompression module
320 #if !EMUL
321     MosDecompression                *m_mosDecompression = nullptr;
322 #endif
323 
324     //! \brief the ptr to mos media copy module
325     MosMediaCopy                    *m_mosMediaCopy = nullptr;
326 
327     //!< Indicate if this device is working in aync mode or normal mode
328     bool                            m_aynchronousDevice = false;
329 
330     //! \brief is pooled resource is supported
331     bool                            m_resourcePooling = false;
332 MEDIA_CLASS_DEFINE_END(OsContextNext)
333 };
334 #endif // #ifndef __MOS_CONTEXTNext_NEXT_H__
335