xref: /aosp_15_r20/external/intel-media-driver/media_driver/linux/common/ddi/ddi_media_context.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
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     ddi_media_context.h
24 //! \brief    ddi media context defination head file
25 //! \details  ddi media context defination head file
26 //!
27 
28 #ifndef __DDI_MEDIA_CONTEXT_H_
29 #define __DDI_MEDIA_CONTEXT_H_
30 
31 #include "mos_cmdbufmgr.h"
32 #include "media_libva_caps.h"
33 
34 //!
35 //! \struct DDI_MEDIA_CONTEXT
36 //! \brief  Media heap for shared internal structures
37 //!
38 struct DDI_MEDIA_CONTEXT
39 {
40     MOS_BUFMGR         *pDrmBufMgr  = nullptr;
41     // handle for /dev/dri/card0
42     int32_t             fd          = 0;
43     int32_t             iDeviceId   = 0;
44     bool                bIsAtomSOC  = 0;
45 
46     MEDIA_FEATURE_TABLE SkuTable    = {};
47     MEDIA_WA_TABLE      WaTable     = {};
48 
49     PDDI_MEDIA_HEAP     pSurfaceHeap  = nullptr;
50     uint32_t            uiNumSurfaces = 0;
51 
52     PDDI_MEDIA_HEAP     pBufferHeap   = nullptr;
53     uint32_t            uiNumBufs     = 0;
54 
55     PDDI_MEDIA_HEAP     pImageHeap    = nullptr;
56     uint32_t            uiNumImages   = 0;
57 
58     PDDI_MEDIA_HEAP     pDecoderCtxHeap = nullptr;
59     uint32_t            uiNumDecoders   = 0;
60 
61     PDDI_MEDIA_HEAP     pEncoderCtxHeap = nullptr;
62     uint32_t            uiNumEncoders   = 0;
63 
64     PDDI_MEDIA_HEAP     pVpCtxHeap      = nullptr;
65     uint32_t            uiNumVPs        = 0;
66 
67     PDDI_MEDIA_HEAP     pProtCtxHeap    = nullptr;
68     uint32_t            uiNumProts      = 0;
69 
70     PDDI_MEDIA_HEAP     pCmCtxHeap      = nullptr;
71     uint32_t            uiNumCMs        = 0;
72 
73     PDDI_MEDIA_HEAP     pMfeCtxHeap     = nullptr;
74     uint32_t            uiNumMfes       = 0;
75 
76     // display info
77     uint32_t            uiDisplayWidth  = 0;
78     uint32_t            uiDisplayHeight = 0;
79 
80     // media context reference number
81     uint32_t            uiRef           = 0;
82 
83     // modulized Gpu context and cmd buffer
84     bool                modularizedGpuCtxEnabled    = false;
85     OsContext           *m_osContext                = nullptr;
86     GpuContextMgr       *m_gpuContextMgr            = nullptr;
87     CmdBufMgr           *m_cmdBufMgr                = nullptr;
88 
89     // Apogeio MOS module
90     MOS_DEVICE_HANDLE   m_osDeviceContext = MOS_INVALID_HANDLE;
91 
92     // mutexs to protect the shared resource among multiple context
93     MEDIA_MUTEX_T       SurfaceMutex   = {};
94     MEDIA_MUTEX_T       MemDecompMutex = {};
95     MEDIA_MUTEX_T       BufferMutex    = {};
96     MEDIA_MUTEX_T       ImageMutex     = {};
97     MEDIA_MUTEX_T       DecoderMutex   = {};
98     MEDIA_MUTEX_T       EncoderMutex   = {};
99     MEDIA_MUTEX_T       VpMutex        = {};
100     MEDIA_MUTEX_T       ProtMutex      = {};
101     MEDIA_MUTEX_T       CmMutex        = {};
102     MEDIA_MUTEX_T       MfeMutex       = {};
103 
104     // GT system Info
105     MEDIA_SYSTEM_INFO  *pGtSystemInfo           = nullptr;
106 
107     // Media memory decompression data structure
108     void               *pMediaMemDecompState    = nullptr;
109 
110     // Media copy data structure
111     void               *pMediaCopyState         = nullptr;
112 
113     // Perf tag
114     PERF_DATA          *perfData                = nullptr;
115 
116     // Media reset enable flag
117     bool                bMediaResetEnable       = false;
118 
119     // Media memory decompression function
120     void (* pfnMemoryDecompress)(
121         PMOS_CONTEXT  pMosCtx,
122         PMOS_RESOURCE pOsResource)  = nullptr;
123 
124     //!
125     //! \brief  the function ptr for surface copy function
126     //!
127     void  (* pfnMediaMemoryCopy )(
128         PMOS_CONTEXT       pMosCtx,
129         PMOS_RESOURCE      pInputResource,
130         PMOS_RESOURCE      pOutputResource,
131         bool               bOutputCompressed)  = nullptr;
132 
133     //!
134     //! \brief  the function ptr for Media Memory 2D copy function
135     //!
136     void (* pfnMediaMemoryCopy2D)(
137         PMOS_CONTEXT       pMosCtx,
138         PMOS_RESOURCE      pInputResource,
139         PMOS_RESOURCE      pOutputResource,
140         uint32_t           copyWidth,
141         uint32_t           copyHeight,
142         uint32_t           copyInputOffset,
143         uint32_t           copyOutputOffset,
144         uint32_t           bpp,
145         bool               bOutputCompressed)  = nullptr;
146 
147     //!
148     //! \brief  the function ptr for Media Tile Convert function
149     //!
150     VAStatus (* pfnMediaMemoryTileConvert)(
151         PMOS_CONTEXT       pMosCtx,
152         PMOS_RESOURCE      pInputResource,
153         PMOS_RESOURCE      pOutputResource,
154         uint32_t           copyWidth,
155         uint32_t           copyHeight,
156         uint32_t           copyInputOffset,
157         uint32_t           copyOutputOffset,
158         bool               isTileToLinear,
159         bool               outputCompressed)  = nullptr;
160 
161     PLATFORM            platform            = {};
162 
163     MediaLibvaCaps     *m_caps              = nullptr;
164 
165     GMM_CLIENT_CONTEXT  *pGmmClientContext  = nullptr;
166 
167     // Aux Table Manager
168     AuxTableMgr         *m_auxTableMgr      = nullptr;
169 
170     bool                m_useSwSwizzling    = false;
171     bool                m_tileYFlag         = false;
172 
173 #if !defined(ANDROID) && defined(X11_FOUND)
174     // X11 Func table, for vpgPutSurface (Linux)
175     PDDI_X11_FUNC_TABLE X11FuncTable        = nullptr;
176 
177     /* VA/DRI (X11) specific data */
178     struct va_dri_output *dri_output        = nullptr;
179     //vpgPutSurfaceLinuxHW acceleration hack
180     MEDIA_MUTEX_T   PutSurfaceRenderMutex   = {};
181     MEDIA_MUTEX_T   PutSurfaceSwapBufferMutex = {};
182 #endif
183     bool                  m_apoMosEnabled     = false;
184 #ifdef _MANUAL_SOFTLET_
185     DdiMediaFunctions     *m_compList[CompCount]    = {};
186     MediaInterfacesHwInfo *m_hwInfo                 = nullptr;
187     MediaLibvaCapsNext    *m_capsNext               = nullptr;
188     bool                  m_apoDdiEnabled           = false;
189 #endif
190     MediaUserSettingSharedPtr m_userSettingPtr      = nullptr;  // used to save user setting instance
191 };
192 
193 #endif // __DDI_MEDIA_CONTEXT_H_
194