xref: /aosp_15_r20/external/intel-media-driver/media_softlet/linux/common/os/mos_context_specific_next.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2019-2020, 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_specific_next.h
24 //! \brief    Container for Linux specific parameters shared across different GPU contexts of the same device instance
25 //!
26 
27 #ifndef __MOS_CONTEXT_SPECIFIC_NEXT_H__
28 #define __MOS_CONTEXT_SPECIFIC_NEXT_H__
29 
30 #include "mos_context_next.h"
31 #include "mos_auxtable_mgr.h"
32 
33 class GraphicsResourceSpecificNext;
34 class CmdBufMgrNext;
35 class GpuContextMgrNext;
36 
37 class OsContextSpecificNext : public OsContextNext
38 {
39     friend class GraphicsResourceSpecificNext;
40 
41 public:
42     //!
43     //! \brief  Do not disable kmd watchdog, that is to say, pass
44     //!         < 0: I915_EXEC_ENABLE_WATCHDOG flag to KMD;
45     //!         < 1: Disable kmd watchdog;
46     //!         that is to say, DO NOT pass I915_EXEC_ENABLE_WATCHDOG flag to KMD;
47     struct PerfInfo {
48         bool     m_disableKmdWatchdog;
49         uint32_t m_enablePerfTag;
50     } ;
51 
52     //!
53     //! \brief  Constructor
54     //!
55     OsContextSpecificNext();
56 
57     //!
58     //! \brief  Destructor
59     //!
60     ~OsContextSpecificNext();
61 
62     //!
63     //! \brief  Initialize the MOS Context
64     //! \param  [in] pOsDriverContext
65     //!         ptr to DDI_DEVICE_CONTEXT created inside DDI
66     //! \return MOS_Success in pass case, MOS error status in fail cases
67     //!
68     MOS_STATUS Init(DDI_DEVICE_CONTEXT osDriverContext);
69 
70     //!
71     //! \brief  Destroy the os specific MOS context
72     //!
73     void Destroy();
74 
75     //!
76     //! \brief  Get the performance information
77     //!
GetPerfInfo()78     struct PerfInfo GetPerfInfo() { return m_performanceInfo; }
79 
80     //!
81     //! \brief  Get the performance information
82     //!
SetPerfInfo(const struct PerfInfo & performanceInfo)83     void SetPerfInfo(const struct PerfInfo &performanceInfo)
84     {
85         MosUtilities::MosSecureMemcpy(&m_performanceInfo, sizeof(struct PerfInfo), &performanceInfo, sizeof(struct PerfInfo));
86     }
87 
88     //!
89     //! \brief  Return whether we need 64bit relocation
90     //!
Is64BitRelocUsed()91     bool Is64BitRelocUsed() { return m_use64BitRelocs; }
92 
GetAuxTableMgr()93     AuxTableMgr* GetAuxTableMgr() { return m_auxTableMgr; }
94 
UseSwSwizzling()95     bool UseSwSwizzling() { return m_useSwSwizzling; }
GetTileYFlag()96     bool GetTileYFlag() { return m_tileYFlag; }
97 
GetBufMgr()98     MOS_BUFMGR *GetBufMgr()
99     {
100         return m_bufmgr;
101     }
102 
GetFd()103     int32_t GetFd()
104     {
105         return m_fd;
106     }
107 
GetDeviceType()108     int GetDeviceType()
109     {
110         return m_deviceType;
111     }
112 
113 private:
114     //!
115     //! \brief  Performance specific switch for debug purpose
116     //!
117     struct PerfInfo     m_performanceInfo = {};
118 
119     //!
120     //! \brief  switch for 64bit KMD relocation
121     //!
122     bool                m_use64BitRelocs = false;
123 
124     //!
125     //! \brief  tiling/untiling with CPU
126     //!
127     bool                m_useSwSwizzling = false;
128 
129     //!
130     //! \brief Sku tile Y flag
131     //!
132     bool                m_tileYFlag     = true;
133 
134     //!
135     //! \brief  ptr to DRM bufmgr
136     //!
137     MOS_BUFMGR          *m_bufmgr       = nullptr;
138 
139     //!
140     //! \brief  drm device fd
141     //!
142     int32_t             m_fd            = -1;
143 
144     //!
145     //! \brief  device type
146     //!
147     int                 m_deviceType   = DEVICE_TYPE_COUNT;
148     AuxTableMgr         *m_auxTableMgr = nullptr;
149     PERF_DATA           *m_perfData =   nullptr;
150 MEDIA_CLASS_DEFINE_END(OsContextSpecificNext)
151 };
152 #endif // #ifndef __MOS_CONTEXT_SPECIFIC_NEXT_H__
153