Debian Codegraph @

media_driver/linux/ult/ult_app/driver_loader.h

raw
1 /*
2 * Copyright (c) 2018, 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 #ifndef __DRIVER_LOADER_H__
23 #define __DRIVER_LOADER_H__
24
25 #include <vector>
26 #include "devconfig.h"
27 #include "mos_defs_specific.h"
28 #include "mos_os.h"
29 #include "va/va_drmcommon.h"
30 #include "va/va_backend.h"
31 #include "va/va_backend_vpp.h"
32 #if VA_CHECK_VERSION(1,11,0)
33 #include <va/va_backend_prot.h>
34 #endif
35
36 struct FeatureID
37 {
38 VAProfile profile;
39 VAEntrypoint entrypoint;
40
41 bool operator==(const FeatureID &g2) const
42 {
43 return (profile == g2.profile) && (entrypoint == g2.entrypoint);
44 }
45
46 bool operator<(const FeatureID &g2) const
47 {
48 if (profile != g2.profile)
49 {
50 return profile < g2.profile;
51 }
52 else
53 {
54 return entrypoint < g2.entrypoint;
55 }
56 }
57 };
58
59 struct CompBufConif
60 {
61 VABufferType bufType;
62 uint32_t bufSize;
63 void* pData;
64 VABufferID bufID;
65 };
66
67 typedef VAStatus (*CmExtSendReqMsgFunc)(
68 VADisplay dpy,
69 void *moduleType,
70 uint32_t *inputFunId,
71 void *inputData,
72 uint32_t *inputDataLen,
73 uint32_t *outputFunId,
74 void *outputData,
75 uint32_t *outputDataLen);
76
77 typedef void (*MOS_SetUltFlagFunc)(uint8_t ultFlag);
78
79 typedef int32_t (*MOS_GetMemNinjaCounterFunc)();
80
81 typedef void (*UltGetCmdBufFunc)(PMOS_COMMAND_BUFFER pCmdBuffer);
82
83 struct DriverSymbols
84 {
85 bool Initialized() const
86 {
87 if (!__vaDriverInit_ ||
88 !vaCmExtSendReqMsg ||
89 !MOS_SetUltFlag ||
90 !MOS_GetMemNinjaCounter ||
91 !MOS_GetMemNinjaCounterGfx ||
92 !ppfnUltGetCmdBuf)
93 {
94 return false;
95 }
96 return true;
97 }
98
99 // Functions
100 VADriverInit __vaDriverInit_;
101 CmExtSendReqMsgFunc vaCmExtSendReqMsg;
102 MOS_SetUltFlagFunc MOS_SetUltFlag;
103 MOS_GetMemNinjaCounterFunc MOS_GetMemNinjaCounter;
104 MOS_GetMemNinjaCounterFunc MOS_GetMemNinjaCounterGfx;
105
106 // Data
107 UltGetCmdBufFunc *ppfnUltGetCmdBuf;
108 };
109
110 class DriverDllLoader
111 {
112 public:
113
114 DriverDllLoader();
115
116 DriverDllLoader(char *path);
117
118 const std::vector<Platform_t> &GetPlatforms() const { return m_platformArray; }
119
120 int GetPlatformNum() const { return m_platformArray.size(); }
121
122 const DriverSymbols &GetDriverSymbols() const { return m_drvSyms; }
123
124 VAStatus InitDriver(Platform_t platform_id);
125
126 VAStatus CloseDriver(bool detectMemLeak = true);
127
128 public:
129
130 VADriverContext m_ctx = {};
131 VADriverVTable m_vtable = {};
132 VADriverVTableVPP m_vtable_vpp = {};
133 #if VA_CHECK_VERSION(1,11,0)
134 VADriverVTableProt m_vtable_prot = {};
135 #endif
136
137 private:
138
139 VAStatus LoadDriverSymbols();
140
141 private:
142
143 const char *m_driver_path = nullptr;
144 void *m_umdhandle = nullptr;
145 DriverSymbols m_drvSyms = {};
146 drm_state m_drmstate = {};
147 Platform_t m_currentPlatform = igfxSKLAKE;
148 std::vector<Platform_t> m_platformArray;
149 };
150
151 #endif // __DRIVER_LOADER_H__